Compatibility issue with PHP 7.0 - Use of reserved keyword 'string' as namespace
RishiKulshreshtha opened this issue · 1 comments
I have found a compatibility issue in the project with PHP version 7.0. The error message reads as follows: "'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)." on this line https://git.drupalcode.org/project/graphql/-/blob/8.x-4.x/src/Plugin/GraphQL/DataProducer/String/Uppercase.php#L3
It seems that the project is using the keyword 'string' as part of a namespace which is causing the error to occur. As PHP 7.0 is still in use in some environments, this issue should be addressed to ensure compatibility with the older version of PHP.
I suggest replacing the use of 'string' as a namespace with a different name that is not a reserved keyword in PHP to resolve this issue, maybe namespace Drupal\graphql\Plugin\GraphQL\DataProducer\Strings;
(plural)?
Hi Rishi, thanks for reporting this issue.
7.0 has been unsupported for a few years now. A Slack discussion was opened around this issue flagged by PHPCS as well: https://drupal.slack.com/archives/C6LMJ0ZAT/p1680202137758099
However, on currently non-EOL PHP versions (8.0 and up) this is valid syntax. Namespaces are treated as a single token and can thus include reserved keywords.