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

Comments

gawalin created an issue. See original summary.

gawalin’s picture

Issue summary: View changes
gawalin’s picture

Issue summary: View changes
cilefen’s picture

Version: 9.1.x-dev » 9.4.x-dev
Component: other » field system
Priority: Major » Normal
Issue tags: -string, -Reserved Keyword, -field
dhirendra.mishra’s picture

Status: Active » Needs review
StatusFileSize
new4.18 KB

Here is the patch for it.

gawalin’s picture

#5 patch is applied successfully.

Thanks!

smustgrave’s picture

Status: Needs review » Needs work

This 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?

smustgrave’s picture

I 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.

smustgrave’s picture

Version: 9.4.x-dev » 9.5.x-dev
smustgrave’s picture

Status: Needs work » Needs review
StatusFileSize
new3.84 KB
new3.25 KB

Rerolled for D10

Status: Needs review » Needs work

The last submitted patch, 10: 3304246-10-D10.patch, failed testing. View results

smustgrave’s picture

Status: Needs work » Needs review
StatusFileSize
new629 bytes
new4.2 KB

No idea why the reroll didn't rename properly but did it by hand for 10.1.x

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The 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.

cpierce42’s picture

Status: Needs work » Reviewed & tested by the community

Reviewed and tested. Patch #5 works make D9 more compatible with php 8.1

  • catch committed c43a80db on 10.1.x
    Issue #3304246 by smustgrave, dhirendra.mishra, gawalin: string' is a...

  • catch committed 29d21a77 on 11.x
    Issue #3304246 by smustgrave, dhirendra.mishra, gawalin: string' is a...
catch’s picture

Version: 9.5.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Fixed

A 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!

neclimdul’s picture

We 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...

neclimdul’s picture

Actually, 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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.