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

Generic/ConstructorName: more defensive coding / prevent fatal error #814

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Feb 12, 2025

Description

Generic/ConstructorName: rename test case file

... to allow for adding additional test case files for parse error tests.

Generic/ConstructorName: more defensive coding

This sniff could throw the following fatal errors when it encountered parse errors/during live coding:

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in path/to/PHPCS/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php on line 83 in path/to/PHPCS/src/Runner.php on line 624

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in path/to/PHPCS/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php on line 167 in path/to/PHPCS/src/Runner.php on line 624

Fixed now by adding more defensive coding.

Includes tests safeguarding the fix.

Suggested changelog entry

Generic.NamingConventions.ConstructorName: prevent potential fatal errors during live coding

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

... to allow for adding additional test case files for parse error tests.
This sniff could throw the following fatal errors when it encountered parse errors/during live coding:

```
Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in path/to/PHPCS/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php on line 83 in path/to/PHPCS/src/Runner.php on line 624

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in path/to/PHPCS/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php on line 167 in path/to/PHPCS/src/Runner.php on line 624
```

Fixed now by adding more defensive coding.

Includes tests safeguarding the fix.
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.

1 participant