Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QA: add use statements for the aliased PHPCS and PHPUnit classes #774

Merged
merged 1 commit into from Dec 16, 2018

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 14, 2018

For those classes which have 1-on-1 aliases across PHPCS versions, we can use use ... as ... statements to import the aliased class and use a shorter reference inline.

This applies to:

  • PHP_CodeSniffer_File - aliased as File which is the PHPCS 3.x class name.
  • PHP_CodeSniffer_Tokens - aliased as Tokens which is the PHPCS 3.x class name.
  • PHP_CodeSniffer_Exception - in PHPCS 3.x, this class is called PHP_CodeSniffer\Exceptions\RuntimeException, aliased to PHPCS_Exception to prevent confusion with the PHP native RuntimeException class.
  • Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff - aliased as PHPCS_CamelCapsFunctionNameSniff.
  • PHP_CodeSniffer_Standards_AbstractScopeSniff - aliased as PHPCS_AbstractScopeSniff to prevent confusion with the PHPCompatibility native abstract sniffs.

Note: this is not possible for those classes which don't have a direct counter-part between PHPCS 2 and PHPCS 3!

Additionally, the references to the PHPUnit class - which is aliased within the phpunit-bootstrap.php file - have also been changed to use statements.

For those classes which have 1-on-1 aliases across PHPCS versions, we can use `use ... as ...` statements to import the aliased class and use a shorter reference inline.

This applies to:
* `PHP_CodeSniffer_File` - aliased as `File` which is the PHPCS 3.x class name.
* `PHP_CodeSniffer_Tokens` - aliased as `Tokens` which is the PHPCS 3.x class name.
* `PHP_CodeSniffer_Exception` - in PHPCS 3.x, this class is called `PHP_CodeSniffer\Exceptions\RuntimeException`, aliased to `PHPCS_Exception` to prevent confusion with the PHP native `RuntimeException` class.
* `Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff` - aliased as `PHPCS_CamelCapsFunctionNameSniff`.
* `PHP_CodeSniffer_Standards_AbstractScopeSniff` - aliased as `PHPCS_AbstractScopeSniff` to prevent confusion with the PHPCompatibility native abstract sniffs.

Note: this is not possible for those classes which don't have a direct counter-part between PHPCS 2 and PHPCS 3!

Additionally, the references to the PHPUnit class - which is aliased within the `phpunit-bootstrap.php` file - have also been changed to `use` statements.
@wimg wimg merged commit d478e85 into master Dec 16, 2018
@wimg wimg deleted the feature/add-use-tokens-statements branch December 16, 2018 19:12
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.

None yet

2 participants