-
-
Notifications
You must be signed in to change notification settings - Fork 163
Closed
Description
Function URL
https://www.php.net/manual/en/function.get-cfg-var.php
PHP Version
8.4
Safe Version
3.0.2
Description
If Safe\get_cfg_var()
is called with a value that does not exist in the current configuration, it crashes PHPStan with an uncaught exception.
Example:
Use Safe\get_cfg_var;
get_cfg_var('does not exist');
$> ./vendor/bin/phpstan
Fatal error: Uncaught Safe\Exceptions\InfoException: An error occurred in /path/to/project/vendor/thecodingmachine/safe/generated/Exceptions/InfoException.php:9
Stack trace:
#0 /path/to/project/vendor/thecodingmachine/safe/generated/8.1/info.php(228): Safe\Exceptions\InfoException::createFromPhpError()
#1 /path/to/project/file.php(3): Safe\get_cfg_var()
#2 /path/to/project/vendor/composer/autoload_real.php(41): require('...')
#3 /path/to/project/vendor/composer/autoload_real.php(45): {closure}()
#4 /path/to/project/vendor/autoload.php(25): ComposerAutoloaderInit1cc678e3a0a52264b4c2205084c653d4::getLoader()
#5 phar:///path/to/project/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(55): require_once('...')
#6 phar:///path/to/project/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(115): _PHPStan_24e2736d6\{closure}()
#7 /path/to/project/vendor/phpstan/phpstan/phpstan(8): require('...')
#8 /path/to/project/vendor/bin/phpstan(119): include('...')
#9 {main}
thrown in /path/to/project/vendor/thecodingmachine/safe/generated/Exceptions/InfoException.php on line 9
Compare the base function for which PHPStan works as expected:
\get_cfg_var('does not exist');
$> ./vendor/bin/phpstan
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Line lib/Constants.php
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 Function get_cfg_var is unsafe to use. It can return FALSE instead of throwing an exception. Please add 'use function Safe\get_cfg_var;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library.
🪪 theCodingMachineSafe.function
------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Metadata
Metadata
Assignees
Labels
No labels