From 183961962cf73061ad4b598a56c2a46889e8feb2 Mon Sep 17 00:00:00 2001 From: Tel Smith Date: Tue, 9 Aug 2022 18:38:59 -0700 Subject: [PATCH 1/2] 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"] --- lib/Doctrine/Common/Annotations/AnnotationReader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/Common/Annotations/AnnotationReader.php b/lib/Doctrine/Common/Annotations/AnnotationReader.php index 1f538ee53..2d5ad3bd2 100644 --- a/lib/Doctrine/Common/Annotations/AnnotationReader.php +++ b/lib/Doctrine/Common/Annotations/AnnotationReader.php @@ -109,13 +109,13 @@ 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(); } From 9b16bfd5571f30b978b62cab7ea8373d21c9f890 Mon Sep 17 00:00:00 2001 From: Tel Smith Date: Wed, 10 Aug 2022 07:44:07 -0700 Subject: [PATCH 2/2] Coding standards fixes --- .../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 2d5ad3bd2..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+') && (filter_var(ini_get('zend_optimizerplus.save_comments'),FILTER_VALIDATE_BOOLEAN) === false || - filter_var(ini_get('opcache.save_comments'),FILTER_VALIDATE_BOOLEAN) === false) + 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') && filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) { + if (extension_loaded('Zend OPcache') && + filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) { throw AnnotationException::optimizerPlusSaveComments(); }