magento / magento/magento-coding-standard
Compatibility with PHP 8
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 375
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
### Preconditions
In PHP 8, functions like **token_get_all** treat namespaced names as single token, e.g.
```
// Before: T_NS_SEPARATOR T_STRING
// After: T_NAME_FULLY_QUALIFIED
```
Details:
https://wiki.php.net/rfc/namespaced_names_as_token
There are couple places in the code that rely on the php7-style implementation:
```
\Magento2\Sniffs\Exceptions\ThrowCatchSniff::getFullClassName
\Magento2\Sniffs\NamingConvention\ReservedWordsSniff::validateNamespace
```
### Expected result
These methods should be checked and updated, the logic should work on PHP 8 as it was on PHP 7.
example from the main repo where new approach is used together with the old one:
https://github.com/magento/magento2/blob/platform-health/setup/src/Magento/Setup/Module/Di/Code/Reader/FileClassScanner.php#L155
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading ThrowCatchSniff::getFullClassName and ReservedWordsSniff::validateNamespace, focusing on their token handling and the PHP 8 namespaced-name token behavior described in the issue. Compare the referenced Magento approach, then verify both sniffs preserve PHP 7 behavior while working correctly with PHP 8 tokens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100