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

Update Reflector.php for PHP 7.2 compatibility #148

Merged
merged 3 commits into from
May 25, 2017
Merged

Update Reflector.php for PHP 7.2 compatibility #148

merged 3 commits into from
May 25, 2017

Conversation

drbyte
Copy link
Contributor

@drbyte drbyte commented May 9, 2017

PHP 7.2 has deprecated each()

@@ -129,7 +129,7 @@ public function getTraits($class)
} while ($class = get_parent_class($class));

// get traits from ancestor traits
while (list($trait) = each($traits)) {
foreach($traits as &$trait) {
Copy link
Member

@harikt harikt May 10, 2017

Choose a reason for hiding this comment

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

Thank you for the information.

Why did you used & ?

It may be good if you can add a space between foreach and ( as foreach ($traits .

Not sure why the tests fails, will look into it.

Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first attempt didn't use the &. In fact, prefer not to use it.

But running the tests on PHP 7.1 triggered the same errors you're seeing on 5.5 and 5.6.
So while looking at the recursive flow in that code section a colleague suggested the & might resolve it. It did ... for PHP 7.1.

Still not understanding why it's breaking on 5.5 and 5.6

Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a space after foreach and before the opening parenthesis.

@harikt harikt mentioned this pull request May 10, 2017
@harikt
Copy link
Member

harikt commented May 10, 2017

I made some changes to .travis.yml and composer.json and made a PR #149 . Currently it fails on 5.5 and 5.6 . I may want to dig more in-order to find the reason behind the same.

@drbyte
Copy link
Contributor Author

drbyte commented May 24, 2017

Tests are now passing on PHP 5.5 through 7.2

Copy link
Member

@harikt harikt left a comment

Choose a reason for hiding this comment

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

Thank you for the changes. @pmjones will verify and merge. I am a bit concerned about the performance with this. But I don't know for sure without bench-marking this.

composer.json Outdated
@@ -19,7 +19,8 @@
],
"require": {
"php": ">=5.5.0",
"container-interop/container-interop": "~1.0"
"container-interop/container-interop": "~1.0",
"phpunit/phpunit": "~5.7 || ~4.8"
Copy link
Member

Choose a reason for hiding this comment

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

move phpunit to require-dev.

@pmjones
Copy link
Member

pmjones commented May 25, 2017

@harikt Point taken on performance; no way to know without benchmarking. However, my guess is that, since we're using reflection already, the loop change is not a significant factor.

@pmjones pmjones merged commit 2c63b9d into auraphp:3.x May 25, 2017
@pmjones
Copy link
Member

pmjones commented May 25, 2017

@drbyte Thanks for this!

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.

None yet

4 participants