Initial proposal for PSR-2, clarification attempt for PSR-0 #28

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
@andrerom

This is a try at clearing some of the issues that came up during discussions in php-internals on splClassLoader rfc.

The issues that seems to come up where:

  • case sensitivity
  • handling of missing files
  • include path handling
  • questions on why pear compatibility was kept

The proposed changes (as of second commit) is currently two new lines:

* Namespace and class name is case sensitive as inherited from most
  file systems.
* If file is not present false is returned

And an extended example that shows this and which uses stream_resolve_include_path to maintain include path support if path is relative.

Formated version of proposal can be found here: https://github.com/andrerom/fig-standards/blob/psr2/proposed/PSR-2.md

andrerom added some commits Apr 16, 2012

Initial proposal for PSR-2, clarification attempt for PSR-0
This is a try at clearing some of the issues that came up during discussions in php-internals on splClassLoader rfc.

The issues that seems to come up where:
* case sensitivity
* handling of missing files
* include path handling
* questions on why pear compatibility was kept

This commit is by no means a perfect response to these, it's an attempt to start the discussion on fixing them so we can potentially move on with spl[Class]Loader.
Given the original PSR and the example in it, I have assumes it intended to be strict on purpose as it makes it easy to implement, understand, debug as well as being fast.
Hence why this proposal moves further in that direction but keeps support for some stuff currently in use with options.

Some options I have chosen not to include yet as I don't fully know if there are any value in them, and how they should be specified.
These are:

* PSR_2_EXCEPTION: Adds checks to see if file exists, if not throws
  exception. Still throws exception when combined with PSR_2_SILENT.

Given that autoload functionality in php does no currently support exceptions, I don't see any benefit atm.

* PSR_2_LOWERCASE: Changes namespace and class name to lowercase,
  hence folder and file names must be in lowercase in this mode.

Might add value for those that want to avoid potential edge case issues when developing on mac and then moving the project to linux for instance.

* PSR_2_INCLUDEPATH: Look-up file using include path.

Symfony / Zend will have to contribute / agree on how such a option should work.
Further reduce string functions used
And avoiding replace on parts of string that is later thrown away.
@Alexgalinier

This comment has been minimized.

Show comment Hide comment
@Alexgalinier

Alexgalinier Jun 6, 2012

I really like the job done in PSR-2, i must congrat all the workers.
I'm asking if someone plan to implement all this rules in a style checker ? May it already exists but i missed it!

Thx.

I really like the job done in PSR-2, i must congrat all the workers.
I'm asking if someone plan to implement all this rules in a style checker ? May it already exists but i missed it!

Thx.

@andrerom

This comment has been minimized.

Show comment Hide comment
@andrerom

andrerom Jun 8, 2012

This is not the coding style PSR-2, this was a proposal for PSR-0 clarifications made before that coding standard was proposed as two parts.
This one should be closed and resubmitted as a new proposal.

andrerom commented Jun 8, 2012

This is not the coding style PSR-2, this was a proposal for PSR-0 clarifications made before that coding standard was proposed as two parts.
This one should be closed and resubmitted as a new proposal.

@andrerom andrerom closed this Jun 12, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment