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

Run tests on PHP 7.3 and 7.4 on Travis #356

Closed
wants to merge 1 commit into from
Closed

Run tests on PHP 7.3 and 7.4 on Travis #356

wants to merge 1 commit into from

Conversation

WyriHaximus
Copy link
Member

No description provided.

@WyriHaximus WyriHaximus added this to the v0.8.6 milestone Jan 9, 2020
@WyriHaximus WyriHaximus requested a review from clue January 10, 2020 20:38
@@ -122,12 +122,12 @@ public function handleData($data)
}
}

$this->chunkSize = \hexdec($hexValue);
if (\dechex($this->chunkSize) !== $hexValue) {
if (\ctype_xdigit($hexValue) === false || \dechex(\hexdec($hexValue)) !== $hexValue) {
Copy link
Member

Choose a reason for hiding this comment

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

Changes LGTM 👍

Note that this requires ext-ctype which could potentially be disabled explicitly. As an alternative we could also keep the previous logic and suppress errors for PHP 7.4 support. What do you think about this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Was more thinking along the lines of using: https://github.com/symfony/polyfill-ctype

Copy link
Member Author

Choose a reason for hiding this comment

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

Alternatively I can do a PHP version check and only run it on PHP 7.4 and above and do some extra trickery so we can seamlessly do this

Copy link

Choose a reason for hiding this comment

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

It's funny that there's no changelog about the deprecation notice on the function page.

Copy link

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

lol doh I assumed I missed it 😂

Comment on lines 126 to 127
!(
\PHP_VERSION_ID >= 70400 &&
(
(\function_exists('ctype_xdigit') && \ctype_xdigit($hexValue) === false) ||
// From: https://github.com/symfony/polyfill-ctype/blob/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3/Ctype.php#L196
(\is_string($hexValue) && '' !== $hexValue && !preg_match('/[^A-Fa-f0-9]/', $hexValue))
)
) ||
\dechex(\hexdec($hexValue)) !== $hexValue
Copy link
Member

@clue clue Jan 11, 2020

Choose a reason for hiding this comment

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

That's a lot of code 👀

What do you think about this https://3v4l.org/pSZCT vs https://3v4l.org/FJAD6? PHP's documentation suggests it should ignore all invalid characters, which matches the output, so we may as well ignore the deprecation warning (which would only affect PHP 7.4+)?

Copy link
Member Author

Choose a reason for hiding this comment

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

@clue here is the issue: https://3v4l.org/Hiqht

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@clue could still do @\dechex(@\hexdec($hexValue)) !== $hexValue to validate it tho

Copy link
Member Author

Choose a reason for hiding this comment

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

@clue just pushed a simpler version, which falls back to the @\dechex(@\hexdec($hexValue)) !== $hexValue one fails (because the maxlength one was failing while the rest passed)

Most of these changes have been based on reactphp/stream#147

Additionally some changes have been made to ensure chunked encoding
works on PHP 7.4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants