Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IniParser refactoring, filename prefixes, test fixes #104

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

IniParser refactoring, filename prefixes, test fixes #104

wants to merge 5 commits into from

Conversation

kekenec
Copy link

@kekenec kekenec commented Mar 25, 2018

  • IniParser::parse method refactored. There was a problem with an error checking. For example, in IniTest we are testing the case where $data equals to null and parse_ini_file didn't throw any error/warning. So when we call error_get_last we assume that there wasn't errors in the past that are suppressed via @/custom error handler. But even PHPUnit uses @ operator, e.g. for creating log directories and files specified in configuration file, and it may cause warning/error while testing.
  • Added argument $prefix for Config::__construct method. If $prefix is true, then every configuration file provided in the first argument will be parsed as an array containing the config array itself by the filename as a key.
  • Changed every QCN in test files to FQCN.
  • Minor code and docblock fixes.

I'm sorry for this huge pull request. If needed, i can break it up to several small requests.

@kekenec kekenec changed the base branch from master to develop March 26, 2018 12:10
@DavidePastore DavidePastore added this to the Future Release milestone Apr 9, 2018
Copy link
Collaborator

@DavidePastore DavidePastore left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! Sorry for the late answer. Can you please address the requested changes? Maybe @hassankhan could add some tips for this PR.

*
* @throws EmptyDirectoryException If `$path` is an empty directory
*/
public function __construct($path)
public function __construct($path, $prefix = false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please use an associative array with the configuration instead of having $prefix directly as second parameter?

Copy link
Owner

Choose a reason for hiding this comment

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

Just to clarify, the constructor method should look like __construct($path, $options = []) where prefix would be a key under $options.

*
* @throws EmptyDirectoryException If `$path` is an empty directory
*/
public function __construct($path)
public function __construct($path, $prefix = false)
Copy link
Owner

Choose a reason for hiding this comment

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

Just to clarify, the constructor method should look like __construct($path, $options = []) where prefix would be a key under $options.

@hassankhan
Copy link
Owner

Hi @kekenec, thanks for the PR!

Just curious as to whether there was a specific reason for changing the QCNs in the test files?

@peter279k
Copy link
Contributor

This PR has the conflicted files and it should be fixed.

*/
protected $data = null;
protected $data = array();
Copy link
Contributor

Choose a reason for hiding this comment

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

How about setting the short array syntax []?

* @covers \Noodlehaus\Config::__construct()
* @covers \Noodlehaus\Config::get()
*/
public function testConstructWithPrefix() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method code block should be:

public function testConstructWithPrefix()
{
......
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants