magento / magento/magento-coding-standard

Compatibility with PHP 8

Open
#295 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Progress: ready for grooming
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.