Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add parsing of hexadecimal strings for PHP 7 #14107

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

Merged
merged 1 commit into from
Mar 30, 2015
Merged

Add parsing of hexadecimal strings for PHP 7 #14107

merged 1 commit into from
Mar 30, 2015

Conversation

stof
Copy link
Member

@stof stof commented Mar 30, 2015

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #14086
License MIT
Doc PR n/a

PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly.

With this change, we should have a passing testsuite on PHP 7

PHP 7 does not handle the hexadecimal notation in is_numeric checks
anymore, so the detection needs to be implemented explicitly.
@@ -200,6 +200,8 @@ public static function phpize($value)
return false;
case is_numeric($value):
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;
case preg_match('/^0x[0-9a-f]++$/i', $value):
Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity: what is the meaning of the double ++ ?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a possessive quantifier to forbid backtracking (because backtracking cannot allow to find another way to match for this regex anyway). this allows to match much longer strings since we won't reach the backtracking limit.
See http://php.net/manual/en/regexp.reference.repetition.php for the doc about it

Copy link
Member

Choose a reason for hiding this comment

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

That's clever. Thanks.

@fabpot
Copy link
Member

fabpot commented Mar 30, 2015

Thank you @stof.

@fabpot fabpot merged commit e848040 into symfony:2.3 Mar 30, 2015
fabpot added a commit that referenced this pull request Mar 30, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

Add parsing of hexadecimal strings for PHP 7

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #14086
| License       | MIT
| Doc PR        | n/a

PHP 7 does not handle the hexadecimal notation in is_numeric checks anymore, so the detection needs to be implemented explicitly.

With this change, we should have a passing testsuite on PHP 7

Commits
-------

e848040 Add parsing of hexadecimal strings for PHP 7
@stof stof deleted the php_7 branch March 30, 2015 08:06
@stof
Copy link
Member Author

stof commented Mar 30, 2015

@fabpot should we remove the allow_failure for PHP 7 or not yet ?

@fabpot
Copy link
Member

fabpot commented Mar 30, 2015

@stof: Yes, let's do that.

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.

3 participants