Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Aug 4, 2023

8.0.0 Calling this function from outside a class, without any arguments, will now throw an Error.
Previously, an E_WARNING was raised and the function returned false.

Applies to both get_class() as well as get_called_class().

Refs:

This adds a new sniff to detect the above, which wasn't mentioned in the PHP 8.0 generic changelog nor in the migration guide, though a note about it can be found on the functions manual pages.

Includes tests and documentation.

Related to #809

…ArgsOutsideOO` sniff

> 8.0.0 	Calling this function from outside a class, without any arguments, will now throw an `Error`.
>            Previously, an `E_WARNING` was raised and the function returned `false`.

Applies to both `get_class()` as well as `get_called_class()`.

Refs:
* https://www.php.net/manual/en/function.get-class.php#refsect1-function.get-class-changelog
* php/php-src@213b666
* https://3v4l.org/f05rn
* https://3v4l.org/a7h7r

This adds a new sniff to detect the above, which wasn't mentioned in the PHP 8.0 generic changelog nor in the migration guide, though a note about it can be found on the functions manual pages.

Includes tests and documentation.

Related to 809
@jrfnl jrfnl added this to the 10.0.0 milestone Aug 4, 2023
@jrfnl jrfnl requested a review from wimg August 4, 2023 22:15
@wimg wimg merged commit 82e3334 into develop Aug 10, 2023
@wimg wimg deleted the php-8.0/new-forbiddengetclassnoargsoutsideoo-sniff branch August 10, 2023 19:01
@jrfnl jrfnl added the PHP: 8.0 label Nov 4, 2025
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.

3 participants