8000 [Finder] Check PHP version before applying a workaround for a PHP bug by alebo · Pull Request #17134 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Finder] Check PHP version before applying a workaround for a PHP bug #17134

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
8000 Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Corrected version check method.
  • Loading branch information
alebo committed Jan 10, 2016
commit f2e47df24f9d9e82a2fbc29c80b24c53865d89b7
3 changes: 1 addition & 2 deletions src/Symfony/Component/Finder/Iterator/FilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ abstract class FilterIterator extends \FilterIterator
*/
public function rewind()
{
if (version_compare(PHP_VERSION, '5.5.23', '<')
or (version_compare(PHP_VERSION, '5.6.0', '>=') and version_compare(PHP_VERSION, '5.6.7', '<'))) {
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use a guard close, it will improve the readability of this method:

if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
    parent::rewind();
   return;
}

Copy link
Member

Choose a reason for hiding this comment

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

👍

$iterator = $this;
while ($iterator instanceof \OuterIterator) {
$innerIterator = $iterator->getInnerIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public function rewind()
}

// @see https://bugs.php.net/bug.php?id=68557
if (version_compare(PHP_VERSION, '5.5.23', '<')
or (version_compare(PHP_VERSION, '5.6.0', '>=') and version_compare(PHP_VERSION, '5.6.7', '<'))) {
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dunglas, Do you think this one also needs to be changed to a guard clause? I think that the same condition should be used in both cases, but here duplication of the parent::rewind call in the guard clause and in the normal flow would look weird.

Copy link
Member

Choose a reason for hiding this comment

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

This one looks fine to me.

parent::next();
}

Expand Down
0