Skip to content

Commit

Permalink
Enable "native_constant_invocation" CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
1 parent 801a3bb commit d061a45
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion 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
4 changes: 2 additions & 2 deletions Definition/Builder/ArrayNodeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ protected function createNode()
}

if (false === $this->allowEmptyValue) {
@trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), E_USER_DEPRECATED);
@trigger_error(sprintf('Using %s::cannotBeEmpty() at path "%s" has no effect, consider requiresAtLeastOneElement() instead. In 4.0 both methods will behave the same.', __CLASS__, $node->getPath()), \E_USER_DEPRECATED);
}

if (true === $this->atLeastOne) {
Expand Down Expand Up @@ -476,7 +476,7 @@ protected function validateConcreteNode(ArrayNode $node)
}

if (false === $this->allowEmptyValue) {
@trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), E_USER_DEPRECATED);
@trigger_error(sprintf('->cannotBeEmpty() is not applicable to concrete nodes at path "%s". In 4.0 it will throw an exception.', $path), \E_USER_DEPRECATED);
}

if (true === $this->atLeastOne) {
Expand Down
4 changes: 2 additions & 2 deletions Definition/Dumper/XmlReferenceDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private function writeNode(NodeInterface $node, $depth = 0, $root = false, $name
$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 @@ -267,7 +267,7 @@ private function writeLine($text, $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 DependencyInjection/ConfigCachePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Config\DependencyInjection;

@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use tagged iterator arguments instead.', ConfigCachePass::class), E_USER_DEPRECATED);
@trigger_error(sprintf('The %s class is deprecated since Symfony 3.4 and will be removed in 4.0. Use tagged iterator arguments instead.', ConfigCachePass::class), \E_USER_DEPRECATED);

use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
Expand Down
2 changes: 1 addition & 1 deletion FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function isAbsolutePath($file)
&& ':' === $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 Resource/GlobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getIterator()
}

if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/') && (\defined('GLOB_BRACE') || false === strpos($this->pattern, '{'))) {
$paths = glob($this->prefix.$this->pattern, GLOB_NOSORT | (\defined('GLOB_BRACE') ? GLOB_BRACE : 0));
$paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0));
sort($paths);
foreach ($paths as $path) {
if ($this->recursive && is_dir($path)) {
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 @@ -216,7 +216,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)
{
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 d061a45

Please sign in to comment.