Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  Enable "native_constant_invocation" CS rule
  Make AbstractPhpFileCacheWarmer public
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
2 parents 043bf86 + d061a45 commit 3880541
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Definition/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function finalizeValue($value)
}

if ($child->isDeprecated()) {
@trigger_error($child->getDeprecationMessage($name, $this->getPath()), E_USER_DEPRECATED);
@trigger_error($child->getDeprecationMessage($name, $this->getPath()), \E_USER_DEPRECATED);
}

try {
Expand Down Expand Up @@ -305,7 +305,7 @@ protected function normalizeValue($value)
$guesses = [];

foreach (array_keys($value) as $subject) {
$minScore = INF;
$minScore = \INF;
foreach ($proposals as $proposal) {
$distance = levenshtein($subject, $proposal);
if ($distance <= $minScore && $distance < 3) {
Expand Down
2 changes: 1 addition & 1 deletion Definition/Builder/NodeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function setPathSeparator(string $separator)
$child->setPathSeparator($separator);
}
} else {
@trigger_error(sprintf('Not implementing the "%s::getChildNodeDefinitions()" method in "%s" is deprecated since Symfony 4.1.', ParentNodeDefinitionInterface::class, static::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Not implementing the "%s::getChildNodeDefinitions()" method in "%s" is deprecated since Symfony 4.1.', ParentNodeDefinitionInterface::class, static::class), \E_USER_DEPRECATED);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Definition/Builder/TreeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TreeBuilder implements NodeParentInterface
public function __construct(string $name = null, string $type = 'array', NodeBuilder $builder = null)
{
if (null === $name) {
@trigger_error('A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.', E_USER_DEPRECATED);
@trigger_error('A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.', \E_USER_DEPRECATED);
} else {
$builder = $builder ?: new NodeBuilder();
$this->root = $builder->node($name, $type)->setParent($this);
Expand All @@ -48,7 +48,7 @@ public function __construct(string $name = null, string $type = 'array', NodeBui
*/
public function root($name, $type = 'array', NodeBuilder $builder = null)
{
@trigger_error(sprintf('The "%s()" method called for the "%s" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.', __METHOD__, $name), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method called for the "%s" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.', __METHOD__, $name), \E_USER_DEPRECATED);

$builder = $builder ?: new NodeBuilder();

Expand Down
4 changes: 2 additions & 2 deletions Definition/Dumper/XmlReferenceDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function writeNode(NodeInterface $node, int $depth = 0, bool $root = fal
$commentDepth = $depth + 4 + \strlen($attrName) + 2;
$commentLines = explode("\n", $comment);
$multiline = (\count($commentLines) > 1);
$comment = implode(PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);
$comment = implode(\PHP_EOL.str_repeat(' ', $commentDepth), $commentLines);

if ($multiline) {
$this->writeLine('<!--', $depth);
Expand Down Expand Up @@ -259,7 +259,7 @@ private function writeLine(string $text, int $indent = 0)
$indent = \strlen($text) + $indent;
$format = '%'.$indent.'s';

$this->reference .= sprintf($format, $text).PHP_EOL;
$this->reference .= sprintf($format, $text).\PHP_EOL;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Definition/VariableNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function finalizeValue($value)
// deny environment variables only when using custom validators
// this avoids ever passing an empty value to final validation closures
if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) {
@trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), E_USER_DEPRECATED);
@trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), \E_USER_DEPRECATED);
// $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath()));
// if ($hint = $this->getInfo()) {
// $e->addHint($hint);
Expand Down
2 changes: 1 addition & 1 deletion FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function isAbsolutePath(string $file): bool
&& ':' === $file[1]
&& ('\\' === $file[2] || '/' === $file[2])
)
|| null !== parse_url($file, PHP_URL_SCHEME)
|| null !== parse_url($file, \PHP_URL_SCHEME)
) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Loader/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getLocator()
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null/*, $exclude = null*/)
{
if (\func_num_args() < 5 && __CLASS__ !== static::class && 0 !== strpos(static::class, 'Symfony\Component\\') && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) {
@trigger_error(sprintf('The "%s()" method will have a new "$exclude = null" argument in version 5.0, not defining it is deprecated since Symfony 4.4.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have a new "$exclude = null" argument in version 5.0, not defining it is deprecated since Symfony 4.4.', __METHOD__), \E_USER_DEPRECATED);
}
$exclude = \func_num_args() >= 5 ? func_get_arg(4) : null;

Expand Down
8 changes: 4 additions & 4 deletions Resource/GlobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function __construct(string $prefix, string $pattern, bool $recursive, bo
$this->recursive = $recursive;
$this->forExclusion = $forExclusion;
$this->excludedPrefixes = $excludedPrefixes;
$this->globBrace = \defined('GLOB_BRACE') ? GLOB_BRACE : 0;
$this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;

if (false === $this->prefix) {
throw new \InvalidArgumentException(sprintf('The path "%s" does not exist.', $prefix));
Expand Down Expand Up @@ -107,10 +107,10 @@ public function getIterator()

if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) {
if ($this->globBrace || false === strpos($this->pattern, '{')) {
$paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | $this->globBrace);
$paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace);
} elseif (false === strpos($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) {
foreach ($this->expandGlob($this->pattern) as $p) {
$paths[] = glob($this->prefix.$p, GLOB_NOSORT);
$paths[] = glob($this->prefix.$p, \GLOB_NOSORT);
}
$paths = array_merge(...$paths);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ private function computeHash(): string

private function expandGlob(string $pattern): array
{
$segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, PREG_SPLIT_DELIM_CAPTURE);
$segments = preg_split('/\{([^{}]*+)\}/', $pattern, -1, \PREG_SPLIT_DELIM_CAPTURE);
$paths = [$segments[0]];
$patterns = [];

Expand Down
2 changes: 1 addition & 1 deletion ResourceCheckerConfigCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function write($content, array $metadata = null)
}
}

if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN)) {
if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) {
@opcache_invalidate($this->file, true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Definition/ArrayNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function testSetDeprecated()

$deprecationTriggered = false;
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
if (E_USER_DEPRECATED === $level) {
if (\E_USER_DEPRECATED === $level) {
return $deprecationTriggered = true;
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Definition/Dumper/XmlReferenceDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testNamespaceDumper()

private function getConfigurationAsString()
{
return str_replace("\n", PHP_EOL, <<<'EOL'
return str_replace("\n", \PHP_EOL, <<<'EOL'
<!-- Namespace: http://example.org/schema/dic/acme_root -->
<!-- scalar-required: Required -->
<!-- scalar-deprecated: Deprecated (The child node "scalar_deprecated" at path "acme_root" is deprecated.) -->
Expand Down
2 changes: 1 addition & 1 deletion Tests/Definition/ScalarNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testSetDeprecated()

$deprecationTriggered = 0;
$deprecationHandler = function ($level, $message, $file, $line) use (&$prevErrorHandler, &$deprecationTriggered) {
if (E_USER_DEPRECATED === $level) {
if (\E_USER_DEPRECATED === $level) {
return ++$deprecationTriggered;
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/Loader/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function load($resource, $type = null)

public function supports($resource, $type = null): bool
{
return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION);
return \is_string($resource) && 'foo' === pathinfo($resource, \PATHINFO_EXTENSION);
}

public function getType()
Expand Down
4 changes: 2 additions & 2 deletions Tests/Util/XmlUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function testLoadEmptyXmlFile()
// test for issue https://github.com/symfony/symfony/issues/9731
public function testLoadWrongEmptyXMLWithErrorHandler()
{
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$originalDisableEntities = libxml_disable_entity_loader(false);
}
$errorReporting = error_reporting(-1);
Expand All @@ -221,7 +221,7 @@ public function testLoadWrongEmptyXMLWithErrorHandler()
error_reporting($errorReporting);
}

if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
libxml_disable_entity_loader($disableEntities);

Expand Down
12 changes: 6 additions & 6 deletions Util/XmlUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public static function parse($content, $schemaOrCallable = null)
}

$internalErrors = libxml_use_internal_errors(true);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}
libxml_clear_errors();

$dom = new \DOMDocument();
$dom->validateOnParse = true;
if (!$dom->loadXML($content, LIBXML_NONET | (\defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
if (LIBXML_VERSION < 20900) {
if (!$dom->loadXML($content, \LIBXML_NONET | (\defined('LIBXML_COMPACT') ? \LIBXML_COMPACT : 0))) {
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}

Expand All @@ -69,12 +69,12 @@ public static function parse($content, $schemaOrCallable = null)
$dom->normalizeDocument();

libxml_use_internal_errors($internalErrors);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
libxml_disable_entity_loader($disableEntities);
}

foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new XmlParsingException('Document types are not allowed.');
}
}
Expand Down Expand Up @@ -267,7 +267,7 @@ protected static function getXmlErrors($internalErrors)
$errors = [];
foreach (libxml_get_errors() as $error) {
$errors[] = sprintf('[%s %s] %s (in %s - line %d, column %d)',
LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
\LIBXML_ERR_WARNING == $error->level ? 'WARNING' : 'ERROR',
$error->code,
trim($error->message),
$error->file ?: 'n/a',
Expand Down

0 comments on commit 3880541

Please sign in to comment.