Skip to content

Commit b7d9a52

Browse files
Enable "native_constant_invocation" CS rule
1 parent e3e34e8 commit b7d9a52

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Encoder/JsonDecode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ public function decode($data, $format, array $context = [])
7878
throw new NotEncodableValueException($e->getMessage(), 0, $e);
7979
}
8080

81-
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
81+
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
8282
return $decodedData;
8383
}
8484

85-
if (JSON_ERROR_NONE !== json_last_error()) {
85+
if (\JSON_ERROR_NONE !== json_last_error()) {
8686
throw new NotEncodableValueException(json_last_error_msg());
8787
}
8888

Encoder/JsonEncode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ public function encode($data, $format, array $context = [])
4343
throw new NotEncodableValueException($e->getMessage(), 0, $e);
4444
}
4545

46-
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
46+
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
4747
return $encodedJson;
4848
}
4949

50-
if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
50+
if (\JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & \JSON_PARTIAL_OUTPUT_ON_ERROR))) {
5151
throw new NotEncodableValueException(json_last_error_msg());
5252
}
5353

Encoder/XmlEncoder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
4444
public function __construct($rootNodeName = 'response', $loadOptions = null)
4545
{
4646
$this->rootNodeName = $rootNodeName;
47-
$this->loadOptions = null !== $loadOptions ? $loadOptions : LIBXML_NONET | LIBXML_NOBLANKS;
47+
$this->loadOptions = null !== $loadOptions ? $loadOptions : \LIBXML_NONET | \LIBXML_NOBLANKS;
4848
}
4949

5050
/**
@@ -83,7 +83,7 @@ public function decode($data, $format, array $context = [])
8383
}
8484

8585
$internalErrors = libxml_use_internal_errors(true);
86-
if (LIBXML_VERSION < 20900) {
86+
if (\LIBXML_VERSION < 20900) {
8787
$disableEntities = libxml_disable_entity_loader(true);
8888
}
8989
libxml_clear_errors();
@@ -92,7 +92,7 @@ public function decode($data, $format, array $context = [])
9292
$dom->loadXML($data, $this->loadOptions);
9393

9494
libxml_use_internal_errors($internalErrors);
95-
if (LIBXML_VERSION < 20900) {
95+
if (\LIBXML_VERSION < 20900) {
9696
libxml_disable_entity_loader($disableEntities);
9797
}
9898

@@ -104,10 +104,10 @@ public function decode($data, $format, array $context = [])
104104

105105
$rootNode = null;
106106
foreach ($dom->childNodes as $child) {
107-
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
107+
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
108108
throw new NotEncodableValueException('Document types are not allowed.');
109109
}
110-
if (!$rootNode && XML_PI_NODE !== $child->nodeType) {
110+
if (!$rootNode && \XML_PI_NODE !== $child->nodeType) {
111111
$rootNode = $child;
112112
}
113113
}
@@ -310,7 +310,7 @@ private function parseXmlAttributes(\DOMNode $node, array $context = [])
310310
continue;
311311
}
312312

313-
if (false !== $val = filter_var($attr->nodeValue, FILTER_VALIDATE_INT)) {
313+
if (false !== $val = filter_var($attr->nodeValue, \FILTER_VALIDATE_INT)) {
314314
$data['@'.$attr->nodeName] = $val;
315315

316316
continue;
@@ -333,14 +333,14 @@ private function parseXmlValue(\DOMNode $node, array $context = [])
333333
return $node->nodeValue;
334334
}
335335

336-
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [XML_TEXT_NODE, XML_CDATA_SECTION_NODE])) {
336+
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [\XML_TEXT_NODE, \XML_CDATA_SECTION_NODE])) {
337337
return $node->firstChild->nodeValue;
338338
}
339339

340340
$value = [];
341341

342342
foreach ($node->childNodes as $subnode) {
343-
if (XML_PI_NODE === $subnode->nodeType) {
343+
if (\XML_PI_NODE === $subnode->nodeType) {
344344
continue;
345345
}
346346

Mapping/Factory/ClassMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(LoaderInterface $loader, Cache $cache = null)
3535
$this->cache = $cache;
3636

3737
if (null !== $cache) {
38-
@trigger_error(sprintf('Passing a Doctrine Cache instance as 2nd parameter of the "%s" constructor is deprecated since Symfony 3.1. This parameter will be removed in Symfony 4.0. Use the "%s" class instead.', __CLASS__, CacheClassMetadataFactory::class), E_USER_DEPRECATED);
38+
@trigger_error(sprintf('Passing a Doctrine Cache instance as 2nd parameter of the "%s" constructor is deprecated since Symfony 3.1. This parameter will be removed in Symfony 4.0. Use the "%s" class instead.', __CLASS__, CacheClassMetadataFactory::class), \E_USER_DEPRECATED);
3939
}
4040
}
4141

Normalizer/AbstractNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
307307
if (__CLASS__ !== static::class) {
308308
$r = new \ReflectionMethod($this, __FUNCTION__);
309309
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
310-
@trigger_error(sprintf('Method %s::%s() will have a 6th `string $format = null` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', static::class, __FUNCTION__), E_USER_DEPRECATED);
310+
@trigger_error(sprintf('Method %s::%s() will have a 6th `string $format = null` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', static::class, __FUNCTION__), \E_USER_DEPRECATED);
311311
}
312312
}
313313

Serializer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function supportsNormalization($data, $format = null/*, array $context =
196196
if (__CLASS__ !== static::class) {
197197
$r = new \ReflectionMethod($this, __FUNCTION__);
198198
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
199-
@trigger_error(sprintf('The "%s()" method will have a third `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
199+
@trigger_error(sprintf('The "%s()" method will have a third `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), \E_USER_DEPRECATED);
200200
}
201201
}
202202

@@ -217,7 +217,7 @@ public function supportsDenormalization($data, $type, $format = null/*, array $c
217217
if (__CLASS__ !== static::class) {
218218
$r = new \ReflectionMethod($this, __FUNCTION__);
219219
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
220-
@trigger_error(sprintf('The "%s()" method will have a fourth `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
220+
@trigger_error(sprintf('The "%s()" method will have a fourth `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), \E_USER_DEPRECATED);
221221
}
222222
}
223223

@@ -295,7 +295,7 @@ public function supportsEncoding($format/*, array $context = []*/)
295295
if (__CLASS__ !== static::class) {
296296
$r = new \ReflectionMethod($this, __FUNCTION__);
297297
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
298-
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
298+
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), \E_USER_DEPRECATED);
299299
}
300300
}
301301

@@ -316,7 +316,7 @@ public function supportsDecoding($format/*, array $context = []*/)
316316
if (__CLASS__ !== static::class) {
317317
$r = new \ReflectionMethod($this, __FUNCTION__);
318318
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
319-
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), E_USER_DEPRECATED);
319+
@trigger_error(sprintf('The "%s()" method will have a second `$context = []` argument in version 4.0. Not defining it is deprecated since Symfony 3.3.', __METHOD__), \E_USER_DEPRECATED);
320320
}
321321
}
322322

Tests/Encoder/JsonEncodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function encodeProvider()
4545
{
4646
return [
4747
[[], '[]', []],
48-
[[], '{}', ['json_encode_options' => JSON_FORCE_OBJECT]],
48+
[[], '{}', ['json_encode_options' => \JSON_FORCE_OBJECT]],
4949
];
5050
}
5151

Tests/Encoder/JsonEncoderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testComplexObject()
4848

4949
public function testOptions()
5050
{
51-
$context = ['json_encode_options' => JSON_NUMERIC_CHECK];
51+
$context = ['json_encode_options' => \JSON_NUMERIC_CHECK];
5252

5353
$arr = [];
5454
$arr['foo'] = '3';
@@ -78,7 +78,7 @@ public function testEncodeNotUtf8WithoutPartialOnError()
7878

7979
public function testEncodeNotUtf8WithPartialOnError()
8080
{
81-
$context = ['json_encode_options' => JSON_PARTIAL_OUTPUT_ON_ERROR];
81+
$context = ['json_encode_options' => \JSON_PARTIAL_OUTPUT_ON_ERROR];
8282

8383
$arr = [
8484
'utf8' => 'Hello World!',
@@ -88,16 +88,16 @@ public function testEncodeNotUtf8WithPartialOnError()
8888
$result = $this->encoder->encode($arr, 'json', $context);
8989
$jsonLastError = json_last_error();
9090

91-
$this->assertSame(JSON_ERROR_UTF8, $jsonLastError);
91+
$this->assertSame(\JSON_ERROR_UTF8, $jsonLastError);
9292
$this->assertEquals('{"utf8":"Hello World!","notUtf8":null}', $result);
9393

94-
$this->assertEquals('0', $this->serializer->serialize(NAN, 'json', $context));
94+
$this->assertEquals('0', $this->serializer->serialize(\NAN, 'json', $context));
9595
}
9696

9797
public function testDecodeFalseString()
9898
{
9999
$result = $this->encoder->decode('false', 'json');
100-
$this->assertSame(JSON_ERROR_NONE, json_last_error());
100+
$this->assertSame(\JSON_ERROR_NONE, json_last_error());
101101
$this->assertFalse($result);
102102
}
103103

0 commit comments

Comments
 (0)