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

Support for string parser #111

Merged
merged 19 commits into from
Oct 3, 2018
Merged

Conversation

filips123
Copy link
Collaborator

@filips123 filips123 commented Jul 23, 2018

It add support for parsing strings and specifying file and string parsers. It closes #108 and closes #51. It also closes #109.
It also fixes some styling and tests.

Documentation is also updated.

This was referenced Jul 24, 2018
@hassankhan hassankhan requested a review from DavidePastore July 24, 2018 13:05
@hassankhan
Copy link
Owner

Looks good to me overall, just waiting on @DavidePastore's review 👍

@filips123
Copy link
Collaborator Author

I've fixed documentation and added warning about arbitrary code execution.

@hassankhan
Copy link
Owner

Thanks for all your work @filips123 👍 Does this PR supersede #109?

@filips123
Copy link
Collaborator Author

Yes.

@hassankhan
Copy link
Owner

I've had another look at the PR - I guess my main concern is that there seems to be some code duplication between the StringParser and FileParser classes. Could we perhaps create an AbstractParser with similar abstract classes that both the *Parser classes then extend?

@filips123
Copy link
Collaborator Author

I've been thinking about this, but I don't know how exactly should I make this. Do you have some ideas?
I will probably add support for writing configuration to files and strings in the future, so this should also be considered.

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.

@filips123 Thanks for all your work! 😮 Please, improve the code following @hassankhan feedback and my code reviews.

* INI string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* Abstract string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* JSON string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* PHP string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* Config string parser interface
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* XML string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

* YAML string parser
*
* @package Config
* @author Jesus A. Domingo <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author of this class, removing the others.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

src/Config.php Outdated

/**
* Config
* Configuration reader and writer for PHP.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please, add yourself as author in every file you edited.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've fixed this.

@@ -0,0 +1,73 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file is very similar to FileParser/Ini.php. We should share the similar functionalities in a common place. The same issue is present in Json, Xml, Yaml and in part in Php parsers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've been thinking about this, but I don't know how exactly should I make this. Do you have some ideas?

@hassankhan
Copy link
Owner

@filips123, with regards to "write" support, do you mean writing config values back to a file, or are you talking about adding methods like update() and delete()?

@filips123
Copy link
Collaborator Author

filips123 commented Jul 28, 2018

I currently can't program until next Thursday so I will add changes then.

@filips123
Copy link
Collaborator Author

@hassankhan I mean writing to files and also methods like update() and delete().

@hassankhan
Copy link
Owner

Hi @filips123, thanks for replying. No worries, take your time 😄.

So I'd just like to mention that we've discussed adding functionality similar to this (#23 and #76 ) and decided against it in the end, as we do not feel that configuration values should be changed during application runtime.

Writing to files, however, is something that could definitely be handy for a variety of use-cases (concatenating various configs and writing the result to a file via a PHP CLI script).

@filips123
Copy link
Collaborator Author

Writing to files (or strings) would also be usable for user friendly installation programs.

@filips123
Copy link
Collaborator Author

@hassankhan @DavidePastore I've fixed some requested changes about authors, but I still don't know how to join file and string parser. Do you have some ideas?

@hassankhan
Copy link
Owner

I think the best way would be as I mentioned here. It also may be worthwhile renaming any *Parser classes to *Reader instead, which will simplify things when the inevitable '*Writer` classes are added.

@hassankhan hassankhan self-requested a review August 1, 2018 20:46
@filips123
Copy link
Collaborator Author

@hassankhan What function should be joined and how exactly? Maybe we could just have string parser and then pass file content to them if needed?

@filips123
Copy link
Collaborator Author

filips123 commented Aug 25, 2018

@hassankhan @DavidePastore I've joined file and string parsers.

@filips123
Copy link
Collaborator Author

I also updated PHPUnit to namespaced syntax and added PHP 7.2 to Travis CI (see #110).

@filips123
Copy link
Collaborator Author

Can you please quickly merge this PR because I want to start working on configuration writing?

@hassankhan
Copy link
Owner

Really sorry for the delay, is there any chance you could rebase your PR on the develop branch? If you could do that, I'll merge the PR immediately 👍

@filips123 filips123 changed the base branch from master to develop October 3, 2018 20:11
@filips123
Copy link
Collaborator Author

I changed branch.

@hassankhan hassankhan merged commit 77256d6 into hassankhan:develop Oct 3, 2018
@hassankhan
Copy link
Owner

Just waiting for the build to pass (expect it should be fine), will tag a new version shortly after.

@hassankhan
Copy link
Owner

Aaaaaand released as 2.0.0 🎉 !!

Thanks @filips123 for your contribution, much appreciated 👍

@DavidePastore DavidePastore added this to the 2.0.0 milestone Oct 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support to read from string Load from string?
3 participants