Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
composer.lock
composer.phar
vendor
tests/coverage
clover.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should have went into your global .gitignore.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/coverage and clover.xml are specified in the phpunit.xml. Are you sure they should be global?

Copy link
Member

@sanmai sanmai Feb 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have .phpunit.result.cache in pretty much in every other project. Two others are not belong here in the first place. E.g. you can put them into a build folder, then ignore it globally. Or add a local .gitignore with a * in that folder. But I'm just nitpicking here. Great job!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you concerning .phpunit.result.cache but for the 2 others adding a dedicated folder which itself is ignored looks just as adding out of scope complexity. It could be necessary, if ever a full build process had to be configured, but later, when the build folder would gather more stuff. And taking this in consideration here seems much less important than considering coverage for example.

If you have an example of a build process applied to other Pear packages, I would follow it gladly. Is it the case?

14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
language: php
install:
- pear install -a package.xml
- composer install --prefer-dist --no-progress

php:
- 5.5
script: phpunit test/
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4

script:
- vendor/bin/phpunit
3 changes: 0 additions & 3 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
//
// $Id$

require_once('PEAR.php');
require_once('Config/Container.php');

$GLOBALS['CONFIG_TYPES'] =
array(
'apache' => array('Config/Container/Apache.php', 'Config_Container_Apache'),
Expand Down
11 changes: 4 additions & 7 deletions Config/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
//
// $Id$

require_once 'Config.php';

/**
* Interface for Config containers
*
Expand Down Expand Up @@ -62,7 +60,7 @@ class Config_Container {
* Array of attributes for this item
* @var array
*/
var $attributes;
var $attributes = [];

/**
* Unique id to differenciate nodes
Expand All @@ -82,7 +80,7 @@ class Config_Container {
* @param string $content Content of container object
* @param array $attributes Array of attributes for container object
*/
function __construct($type = 'section', $name = '', $content = '', $attributes = null)
function __construct($type = 'section', $name = '', $content = '', $attributes = [])
{
$this->type = $type;
$this->name = $name;
Expand Down Expand Up @@ -694,15 +692,15 @@ function toArray($useAttr = true)
$array[$this->name] = array();
switch ($this->type) {
case 'directive':
if ($useAttr && count($this->attributes) > 0) {
if ($useAttr && !empty($this->attributes)) {
$array[$this->name]['#'] = $this->content;
$array[$this->name]['@'] = $this->attributes;
} else {
$array[$this->name] = $this->content;
}
break;
case 'section':
if ($useAttr && count($this->attributes) > 0) {
if ($useAttr && !empty($this->attributes)) {
$array[$this->name]['@'] = $this->attributes;
}
if ($count = count($this->children)) {
Expand Down Expand Up @@ -773,4 +771,3 @@ function writeDatasrc($datasrc, $configType, $options = array())
}
} // end func writeDatasrc
} // end class Config_Container
?>
2 changes: 1 addition & 1 deletion Config/Container/IniCommented.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function _quoteAndCommaParser($text)
$pos = 0; // position in $text

do {
$char = $text{$pos};
$char = $text[$pos];
$state = $this->_getQACEvent($stack);

if ($tokens[$state]) {
Expand Down
4 changes: 3 additions & 1 deletion Config/Container/IniFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function parseDatasrc($datasrc, $obj)
null, PEAR_ERROR_RETURN
);
}

$currentSection = $obj->container;
$confArray = parse_ini_file($datasrc, true);
if (!$confArray) {
Expand All @@ -74,6 +75,7 @@ function parseDatasrc($datasrc, $obj)
null, PEAR_ERROR_RETURN
);
}

foreach ($confArray as $key => $value) {
if (is_array($value)) {
$currentSection =& $obj->container->createSection($key);
Expand Down Expand Up @@ -213,4 +215,4 @@ function contentToString($content)
return $content;
}

} // end class Config_Container_IniFile
} // end class Config_Container_IniFile
5 changes: 2 additions & 3 deletions Config/Container/PHPConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @version SVN: $Id$
* @link http://pear.php.net/package/Config
*/
require_once 'Config/Container.php';

/**
* Config parser for PHP constant files
Expand All @@ -22,7 +21,7 @@
* @license http://www.php.net/license PHP License
* @link http://pear.php.net/package/Config
*/
class Config_Container_PHPConstants extends Config_Container
class Config_Container_PHPConstants
{
/**
* Valid config options:
Expand Down Expand Up @@ -125,7 +124,7 @@ function &parseDatasrc($datasrc, &$obj)
*
* @access public
*/
function toString(&$obj)
function toString(&$obj, $options = array())
{
$string = '';

Expand Down
3 changes: 0 additions & 3 deletions Config/Container/XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
//
// $Id$

require_once('XML/Parser.php');
require_once('XML/Util.php');

/**
* Config parser for XML Files
*
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Pear / Config
Configuration parsers for Apache, Ini files, PHP constants, Xml and generic .conf files.

[![Build Status](https://travis-ci.org/pear/config.png?branch=master)](https://travis-ci.org/pear/config)

## Installation
Add the following to your composer.json:
```
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pear/Config"
"no-api": true
}
],
"require": {
"pear/Config": "dev-master",
}
}
```
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
},
"type": "library",
"require": {
"pear/pear_exception": "*"
"pear/pear": "^1.10",
"pear/xml_parser": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"suggest": {
"pear/xml_parser": "Install optionally via your project's composer.json"
}
}
}
28 changes: 28 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit backupGlobals="false"
defaultTestSuite="all_tests"
backupStaticAttributes="true"
colors="true"
bootstrap="./tests/bootstrap_phpunit.php"
>

<testsuites>
<!-- TODO defaultTestSuite will work with phpunit 6.1 -->
<testsuite name="all_tests">
<directory>./tests/integration</directory>
<directory>./tests/legacy</directory>
</testsuite>
</testsuites>

<filter>
<!-- /!\ whitelist will exclude every outside class from coverage -->
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./Config</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="clover.xml"/>
<log type="coverage-html" target="tests/coverage/"/>
</logging>
</phpunit>
Loading