Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ini_get result to bool before evaluating #446

Open
wants to merge 2 commits into
base: 1.14.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
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') &&
filter_var(ini_get('opcache.save_comments'), FILTER_VALIDATE_BOOLEAN) === false) {
throw AnnotationException::optimizerPlusSaveComments();
}

Expand Down