PHPCompatibility / PHPCompatibility/PHPCompatibility

`eregDeprecated` sniff picks up method names

Open
#1,492 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: duplicate
Dominant language
PHP
Stars
2.3k
Forks
201
Avg merge
3d 18h
Merged PRs (30d)
42

Description

Bug Description

The following sniffs pick up method names in addition to function names, causing an error where it shouldn't:

  • eregDeprecatedRemoved
  • eregiDeprecatedRemoved
  • ereg_replaceDeprecatedRemoved
  • eregi_replaceDeprecatedRemoved

Given the following reproduction Scenario

The issue happens when running this command:

phpcs -ps file.php --standard=PHPCompatibility --runtime-set testVersion 8.1

... over a file containing this code:

MyClass::eregi($value, $string);
I'd expect the following behaviour

No errors or warnings.

Instead this happened

PHPCompatibility.Extensions.RemovedExtensions.eregDeprecatedRemoved

Environment

Environment Answer
PHP version 8.2.3
PHP_CodeSniffer version 3.7.2
PHPCompatibility version 9.3.5
Install type Composer project

Tested Against develop branch?

  • I have verified the issue still exists in the develop branch of PHPCompatibility.

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

Reproduce the report with phpcs -ps file.php --standard=PHPCompatibility --runtime-set testVersion 8.1 using the shown MyClass::eregi($value, $string); code. Start by locating the RemovedExtensions sniffs named in the report and their related tests. Done means static method names no longer trigger these errors while the deprecated functions remain detected.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.