string' is a reserved keyword as of PHP version 7.0 and should not be used to name a class, interface or trait or as part of a namespace (T_NAMESPACE)
modules\field\tests\src\Kernel\String\RawStringFormatterTest.php
modules\field\tests\src\Functional\String\StringFieldTest.php
modules\field\tests\src\Kernel\String\StringFormatterTest.php
modules\field\tests\src\Kernel\String\UuidFormatterTest.php
root\core\modules\field\tests\src\Kernel\String\UuidItemTest.php
Steps to reproduce
PHP Compatability Report:
vendor\bin\phpcs -p . --standard=PHPCompatibility --runtime-set testVersion 8.1 --extensions=php,module,install,inc --report-full==drupal9-php8-compatibility.txt
Technology Details:
PHP 8.1 , Drupal 9.4.1
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3304246-nr-bot.txt | 144 bytes | needs-review-queue-bot |
| #12 | 3304246-12.patch | 4.2 KB | smustgrave |
| #12 | diff-5-12.txt | 629 bytes | smustgrave |
| #5 | 3304246-5.patch | 4.18 KB | dhirendra.mishra |
Comments
Comment #2
gawalin commentedComment #3
gawalin commentedComment #4
cilefen commentedComment #5
dhirendra.mishra commentedHere is the patch for it.
Comment #6
gawalin commented#5 patch is applied successfully.
Thanks!
Comment #7
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.
For something like this should it be deprecated first? Concern being if any modules are using these they will immediately break without time to fix.
And since this currently doesn't seem to be breaking core maybe these could be deprecated in 10.1 and replaced in 11?
Comment #8
smustgrave commentedI stand corrected. @quietone pointed out to me on slack https://www.drupal.org/about/core/policies/core-change-policies/drupal-d... 'we don't deprecate test classes', so I was mistaken.
Queued up patch #5 for D10 and 9.5 and can mark pending those.
Comment #9
smustgrave commentedComment #10
smustgrave commentedRerolled for D10
Comment #12
smustgrave commentedNo idea why the reroll didn't rename properly but did it by hand for 10.1.x
Comment #13
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #14
cpierce42Reviewed and tested. Patch #5 works make D9 more compatible with php 8.1
Comment #17
catchA bit confused that this hasn't bitten us yet, maybe PHP isn't actually enforcing it, but also just test code and an easy change.
Committed/pushed to 11.x and cherry-picked to 10.1.x, thanks!
Comment #18
neclimdulWe haven't run into it because its not a problem to use String as a namespace:
https://3v4l.org/RDj7e
PHPUnit actually uses a String namespace:
https://github.com/sebastianbergmann/phpunit/tree/main/src/Framework/Con...
Comment #19
neclimdulActually, the answer is in the docs:
"The following words cannot be used to name a class, interface or trait. Prior to PHP 8.0, they are also prohibited from being used in namespaces."
https://www.php.net/manual/en/reserved.other-reserved-words.php