Skip to content

PHP 8.3 | ✨ New PHPCompatibility.ParameterValues.NewClassAliasInternalClass sniff#1951

Merged
wimg merged 1 commit intodevelopfrom
php-8.3/new-newclassaliasinternalclass-sniff
Oct 27, 2025
Merged

PHP 8.3 | ✨ New PHPCompatibility.ParameterValues.NewClassAliasInternalClass sniff#1951
wimg merged 1 commit intodevelopfrom
php-8.3/new-newclassaliasinternalclass-sniff

Conversation

@jrfnl
Copy link
Copy Markdown
Member

@jrfnl jrfnl commented Oct 26, 2025

. class_alias() now supports creating an alias of an internal class.

This commit introduces a new sniff which does best-effort detection for calls to the class_alias() function where the class being aliased is a PHP native class.

Mind:

  • If a PHP native class is being aliased, but that class does not exist in the PHP version on which PHPCS is being run, the sniff will stay silent (false negative).
  • If a PHP native class is being aliased, but the extension which declares the class is not loaded for the PHP environment on which PHPCS is being run, the sniff will stay silent (false negative).

Future scope:

  • The sniff currently does not handle class_alias() class with the class being aliased in the following format: ClassName::class. Once the namespace and use statement trackers are available in PHPCSUtils, handling of that syntax should be added to the sniff.

Includes tests.
Includes documentation.

Ref:

Related to #1589

…alClass` sniff

> . class_alias() now supports creating an alias of an internal class.

This commit introduces a new sniff which does best-effort detection for calls to the `class_alias()` function where the class being aliased is a PHP native class.

Mind:
* If a PHP native class is being aliased, but that class does not exist in the PHP version on which PHPCS is being run, the sniff will stay silent (false negative).
* If a PHP native class is being aliased, but the extension which declares the class is not loaded for the PHP environment on which PHPCS is being run, the sniff will stay silent (false negative).

Future scope:
* The sniff currently does not handle `class_alias()` class with the class being aliased in the following format: `ClassName::class`.
    Once the namespace and use statement trackers are available in PHPCSUtils, handling of that syntax should be added to the sniff.

Includes tests.
Includes documentation.

Ref:
* https://github.com/php/php-src/blob/ed9529a7d3c1f5dfbf16c2d388d944af8ec86a76/UPGRADING#L248
* php/php-src 9826
* php/php-src 10483
* php/php-src@821fc55

Related to 1589
@wimg wimg merged commit 89baa33 into develop Oct 27, 2025
76 checks passed
@wimg wimg deleted the php-8.3/new-newclassaliasinternalclass-sniff branch October 27, 2025 20:41
@jrfnl jrfnl added the PHP: 8.3 label Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants