Skip to content

Update repo for usage with php >=8.2 and general fixes #22

Closed as not planned

Description

@yCodeTech

I'm just creating an issue, because I'm not sure what your plans are for this repo, or regarding PRs.

For anyone that's interested, I have a local copy of this repo (the config-repos branch) that I (and Copilot) fixed to use on PHP >= 8.2, with lots of bug fixes, and dependency updates.

The packages changed:

  • roave/better-reflection to use the latest version, and changed all old API usages to use the new API that was breaking changes.
  • nikic/php-parser to use the latest version.
  • phpunit/phpunit to use the latest version.
  • Removed danielstjules/stringy which is not compatible with PHP 8.1 (has outstanding issues). Added voku/stringy as a drop-in replacement.

The test suit (with lots of code fixes) now passes, and the generator also completely works for different external standards packages as well as PHPCS built-in standards.

I also have the Copilot chat history to help with a changelog if needed.

Now that the generator works, I'm hoping to add functionality to get all sniff error/violation codes (not just public customisable ones), as set by addError(..., 'SingleLine'); etc. I know there is the ViolationParser class, but that seems to only parse the docs xml files. In particular the getErrorCode method has from what can I only assume is a no-longer supported path of the error/violation code docs. At least no current internal or external standards use this path. I will probably change this class to parse the actual *Sniff.php instead to find and retrieve the specific violation codes of the sniff, and possibly the error message as a description.

private function getErrorCode(string $xmlFilePath): string
{
$xmlFilePath = Functions::normalizeSlashes($xmlFilePath);
$part = '([^/]*)';
preg_match("`$part/Docs/$part/{$part}Standard/$part\.xml$`", $xmlFilePath, $matches);
if ($matches === []) {
throw NotAViolationPath::fromPath($xmlFilePath);
}
return sprintf('%s.%s.%s.%s', $matches[1], $matches[2], $matches[3], $matches[4]);
}

Activity

  1. jrfnl commented on Jun 20, 2025

    @jrfnl
    Member

    As per the contributing guide of the main PHP_CodeSniffer repo: any use of AI is strictly forbidden in the PHPCS projects. You don't know what code the AI is trained on and what license that code was released under. It is basically theft of copyrighted material.

    So, sorry, while I appreciate you wanting to contribute, this is not an acceptable way to do it.

  2. yCodeTech commented on Jun 21, 2025

    @yCodeTech
    Author

    Ah ok, I didn't realise the usage of AI is unacceptable. I'll go read the contribution terms, but thanks for letting me know. Sorry for violating the contribution terms regarding AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions