PHP 5.3: New `PHPCompatibility.Namespaces.ReservedNames` sniff by jrfnl · Pull Request #1026 · PHPCompatibility/PHPCompatibility

@jrfnl jrfnl changed the title New PHPCompatibility.Namespaces.ReservedNames sniff PHP 5.3: New PHPCompatibility.Namespaces.ReservedNames sniff

May 2, 2020

@jrfnl

> The Namespace name PHP, and compound names starting with this name (like PHP\Classes) are reserved for internal language use and should not be used in the userspace code.

Source: https://www.php.net/manual/en/language.namespaces.rationale.php

This PR introduces a new `PHPCompatibility.Namespaces.ReservedNames` sniff to detect use of namespace names reserved by PHP, in userland code.

The sniff will throw a `warning` when a reserved namespace name is detected.

This sniff is along the same lines as the `PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames` sniff which does the same for reserved function names to prevent code being introduced in userland code which has a high risk of being incompatible with future PHP versions.

Includes unit tests.

Fixes 1025

wimg

wimg approved these changes May 5, 2020

@wimg wimg deleted the feature/1025-new-namespace-reserved-name-sniff branch

May 5, 2020 12:10