Skip to content

Commit

Permalink
Convert ini_get result to bool before evaluating (#446)
Browse files Browse the repository at this point in the history
* 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 <tel@slickdeals.net>
  • Loading branch information
74656c and slicktel authored Sep 5, 2024
1 parent af1295b commit 8731163
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/Doctrine/Common/Annotations/AnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
use ReflectionMethod;
use ReflectionProperty;

use const FILTER_VALIDATE_BOOLEAN;

use function extension_loaded;

Check failure on line 14 in lib/Doctrine/Common/Annotations/AnnotationReader.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

Use statements should be sorted alphabetically. The first wrong one is 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.
Expand Down Expand Up @@ -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') &&

Check failure on line 122 in lib/Doctrine/Common/Annotations/AnnotationReader.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

The first expression of a multi-line control structure must be on the line after the opening parenthesis
filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) {

Check failure on line 123 in lib/Doctrine/Common/Annotations/AnnotationReader.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.1)

The closing parenthesis of a multi-line control structure must be on the line after the last expression
throw AnnotationException::optimizerPlusSaveComments();
}

Expand Down

0 comments on commit 8731163

Please sign in to comment.