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

Merged
merged 2 commits into from
Feb 18, 2025

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)

Sorry, something went wrong.

Copy link
Contributor

@rodrigoprimo rodrigoprimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I left just one comment about something that is not totally clear to me.

Verified

This commit was signed with the committer’s verified signature.
jrfnl Juliette
... to allow for adding additional test case files for parse error tests.

Verified

This commit was signed with the committer’s verified signature.
jrfnl Juliette
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 test safeguarding the fix.
@jrfnl jrfnl force-pushed the feature/generic-constructorname-more-defensive-coding branch from f7e0548 to 3a76062 Compare February 18, 2025 01:51
@jrfnl jrfnl merged commit ce20d6a into master Feb 18, 2025
57 checks passed
@jrfnl jrfnl deleted the feature/generic-constructorname-more-defensive-coding branch February 18, 2025 02:28
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