Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Add ConstantScanner to Zend\Code\Scanner #4465

Closed
wants to merge 6 commits into from
Closed

Add ConstantScanner to Zend\Code\Scanner #4465

wants to merge 6 commits into from

Conversation

MatyCZ
Copy link
Contributor

@MatyCZ MatyCZ commented May 13, 2013

Fix bug introduced in #4457 and add some new features.

  • Can parse constants of type float, number or string
  • Can parse constants with docblock on previous line
  • Can parse constants with self:: reference
  • Added has* methods for constant and property
  • Updated docblocks

There is one BC break. Method getConstants() don't return constant names now, but return instance of ConstantScanner.

*
* @return ConstantScanner[]
*/
public function getConstants()
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely a BC break, and we can't do that.

I'd argue instead for the following:

  • have an optional flag argument to getConstants(), $namesOnly, that defaults to true.
  • When $namesOnly is true, it will proxy to getConstantNames(). Additionally, raise an E_USER_DEPRECATED error, so that developers know they should alter their code to use getConstantNames() if they want the original behavior.
  • when the flag is false, do the new behavior.

This will allow developers to opt-in to the new behavior, and give us a migration path.

@ghost ghost assigned weierophinney May 23, 2013
@MatyCZ
Copy link
Contributor Author

MatyCZ commented May 27, 2013

@weierophinney Addition of E_USER_DEPRECATED breaks tests. It's OK or I must change it to E_USER_NOTICE with same message?

@weierophinney
Copy link
Member

@MatyCZ alter the tests to check for the error as well as the behavior.

weierophinney added a commit that referenced this pull request Jun 11, 2013
Add ConstantScanner to Zend\Code\Scanner
weierophinney added a commit that referenced this pull request Jun 11, 2013
- Add error handler, and verify E_USER_DEPRECATED was raised
- Ensure name of constant is correct case
weierophinney added a commit that referenced this pull request Jun 11, 2013
@ghost ghost assigned weierophinney Jun 11, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants