Skip to content

Tests: fix two missing import use statements - #250

Merged
jrfnl merged 1 commit into
mainfrom
feature/tests-fix-missing-use-statements
Jul 17, 2025
Merged

Tests: fix two missing import use statements#250
jrfnl merged 1 commit into
mainfrom
feature/tests-fix-missing-use-statements

Conversation

@jrfnl

@jrfnl jrfnl commented Jul 9, 2025

Copy link
Copy Markdown
Member

Proposed Changes

Add two import use statements for the PHP native RuntimeException class, which is used to signal certain failures in the test set up.

The fact that this wasn't noticed before clearly means the tests never failed at those Exceptions before ;-)

Suggested changelog entry

N/A (general housekeeping)

Add two import `use` statements for the PHP native `RuntimeException` class, which is used to signal certain failures in the test set up.

The fact that this wasn't noticed before clearly means the tests never failed at those Exceptions before ;-)
@jrfnl jrfnl added this to the 1.1.2 milestone Jul 9, 2025
@jrfnl
jrfnl requested a review from a team July 9, 2025 12:54
@Potherca

Copy link
Copy Markdown
Member

I have no issues with approving these changes, but as I recall, the imports not being there shouldn't cause an issue.

Not finding RuntimeException in PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer\Tests\IntegrationTest, PHP should traverse the namespace until it reaches "" and use the global RuntimeException, right?

(or am I mixing up languages again? 😕 )

@jrfnl

jrfnl commented Jul 17, 2025

Copy link
Copy Markdown
Member Author

I have no issues with approving these changes, but as I recall, the imports not being there shouldn't cause an issue.

Not finding RuntimeException in PHPCSStandards\Composer\Plugin\Installers\PHPCodeSniffer\Tests\IntegrationTest, PHP should traverse the namespace until it reaches "" and use the global RuntimeException, right?

(or am I mixing up languages again? 😕 )

Yes, you're mixing up languages.

In PHP, in namespaced files, there is no fallback to the global namespace (or traversing) for classes. Only functions and constants fall back to the global namespace.

So, no, this missing use statement results in a fatal "class not found" error when the code using the class would be executed (which is how I came across it).

@jrfnl
jrfnl merged commit 76f1a99 into main Jul 17, 2025
115 of 117 checks passed
@jrfnl
jrfnl deleted the feature/tests-fix-missing-use-statements branch July 17, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants