PHP 7.0: new NewUnicodeEscapeSequence sniff#856
Merged
Conversation
... to get all parts of a multi-line text string. This method is a duplicate of a new utility method which will be introduced in PHPCS 3.5.0. The upstream version is accompanied by plenty of unit tests.
> ### Unicode codepoint escape syntax
>
> This takes a Unicode codepoint in hexadecimal form, and outputs that codepoint in UTF-8 to a double-quoted string or a heredoc. Any valid codepoint is accepted, with leading 0's being optional.
> ```php
> echo "\u{aa}";
> echo "\u{0000aa}";
> echo "\u{9999}";
> ```
> ### `\u{` may cause errors ¶
>
> Due to the addition of the new Unicode codepoint escape syntax, strings containing a literal `\u{` followed by an invalid sequence will cause a fatal error. To avoid this, the leading backslash should be escaped.
Refs:
* https://wiki.php.net/rfc/unicode_escape
* https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.unicode-codepoint-escape-syntax
* https://www.php.net/manual/en/migration70.incompatible.php#migration70.incompatible.strings.unicode-escapes
* php/php-src@bae46f3
Includes unit tests.
wimg
reviewed
Aug 28, 2019
wimg
approved these changes
Aug 28, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs:
Includes unit tests.
Implementation notes
TextStrings.Sniff::getCompleteTextString()utility method to get all parts of a multi-line text string.This method is a duplicate of a new utility method which will be introduced in PHPCS 3.5.0.
The upstream version is accompanied by plenty of unit tests.