From 87311633114e3a6968af0ff5fadfd83f72ae5ab6 Mon Sep 17 00:00:00 2001 From: Tel Date: Thu, 5 Sep 2024 04:15:10 -0400 Subject: [PATCH] Convert ini_get result to bool before evaluating (#446) * Convert ini_get result to bool before evaluating. FILTER_VALIDATE_BOOLEAN will return true for ["1", "true", "on" and "yes"] and false for ["0", "false", "off" and "no"] * Coding standards fixes --------- Co-authored-by: Tel Smith --- .../Common/Annotations/AnnotationReader.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Common/Annotations/AnnotationReader.php b/lib/Doctrine/Common/Annotations/AnnotationReader.php index 1f538ee53..32254ce6f 100644 --- a/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -9,10 +9,13 @@ use ReflectionMethod; use ReflectionProperty; +use const FILTER_VALIDATE_BOOLEAN; + +use function extension_loaded; use function array_merge; use function class_exists; -use function extension_loaded; use function ini_get; +use function filter_var; /** * A reader for docblock annotations. @@ -109,13 +112,15 @@ public static function addGlobalIgnoredNamespace($namespace) public function __construct(?DocParser $parser = null) { if ( - extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === '0' || - ini_get('opcache.save_comments') === '0') + extension_loaded('Zend Optimizer+') && + (filter_var(ini_get('zend_optimizerplus.save_comments'), FILTER_VALIDATE_BOOLEAN) === false || + filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) ) { throw AnnotationException::optimizerPlusSaveComments(); } - if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') === 0) { + if (extension_loaded('Zend OPcache') && + filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) { throw AnnotationException::optimizerPlusSaveComments(); }