Skip to content

Commit acffef3

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents bcda9e5 + c4bc95b commit acffef3

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

Encoder/JsonDecode.php

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

87-
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
87+
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
8888
return $decodedData;
8989
}
9090

91-
if (JSON_ERROR_NONE !== json_last_error()) {
91+
if (\JSON_ERROR_NONE !== json_last_error()) {
9292
throw new NotEncodableValueException(json_last_error_msg());
9393
}
9494

Encoder/JsonEncode.php

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

49-
if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
49+
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
5050
return $encodedJson;
5151
}
5252

53-
if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
53+
if (\JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & \JSON_PARTIAL_OUTPUT_ON_ERROR))) {
5454
throw new NotEncodableValueException(json_last_error_msg());
5555
}
5656

Encoder/XmlEncoder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
5757

5858
private $defaultContext = [
5959
self::AS_COLLECTION => false,
60-
self::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE, XML_COMMENT_NODE],
60+
self::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE, \XML_COMMENT_NODE],
6161
self::ENCODER_IGNORED_NODE_TYPES => [],
62-
self::LOAD_OPTIONS => LIBXML_NONET | LIBXML_NOBLANKS,
62+
self::LOAD_OPTIONS => \LIBXML_NONET | \LIBXML_NOBLANKS,
6363
self::REMOVE_EMPTY_TAGS => false,
6464
self::ROOT_NODE_NAME => 'response',
6565
self::TYPE_CAST_ATTRIBUTES => true,
@@ -83,7 +83,7 @@ public function __construct(array $defaultContext = [])
8383
public function encode($data, string $format, array $context = [])
8484
{
8585
$encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
86-
$ignorePiNode = \in_array(XML_PI_NODE, $encoderIgnoredNodeTypes, true);
86+
$ignorePiNode = \in_array(\XML_PI_NODE, $encoderIgnoredNodeTypes, true);
8787
if ($data instanceof \DOMDocument) {
8888
return $data->saveXML($ignorePiNode ? $data->documentElement : null);
8989
}
@@ -115,7 +115,7 @@ public function decode(string $data, string $format, array $context = [])
115115
}
116116

117117
$internalErrors = libxml_use_internal_errors(true);
118-
if (LIBXML_VERSION < 20900) {
118+
if (\LIBXML_VERSION < 20900) {
119119
$disableEntities = libxml_disable_entity_loader(true);
120120
}
121121
libxml_clear_errors();
@@ -124,7 +124,7 @@ public function decode(string $data, string $format, array $context = [])
124124
$dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]);
125125

126126
libxml_use_internal_errors($internalErrors);
127-
if (LIBXML_VERSION < 20900) {
127+
if (\LIBXML_VERSION < 20900) {
128128
libxml_disable_entity_loader($disableEntities);
129129
}
130130

@@ -137,7 +137,7 @@ public function decode(string $data, string $format, array $context = [])
137137
$rootNode = null;
138138
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
139139
foreach ($dom->childNodes as $child) {
140-
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
140+
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
141141
throw new NotEncodableValueException('Document types are not allowed.');
142142
}
143143
if (!$rootNode && !\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) {
@@ -307,7 +307,7 @@ private function parseXmlAttributes(\DOMNode $node, array $context = []): array
307307
continue;
308308
}
309309

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

313313
continue;
@@ -330,7 +330,7 @@ private function parseXmlValue(\DOMNode $node, array $context = [])
330330
return $node->nodeValue;
331331
}
332332

333-
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [XML_TEXT_NODE, XML_CDATA_SECTION_NODE])) {
333+
if (1 === $node->childNodes->length && \in_array($node->firstChild->nodeType, [\XML_TEXT_NODE, \XML_CDATA_SECTION_NODE])) {
334334
return $node->firstChild->nodeValue;
335335
}
336336

@@ -384,7 +384,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
384384
} elseif ('#' === $key) {
385385
$append = $this->selectNodeType($parentNode, $data);
386386
} elseif ('#comment' === $key) {
387-
if (!\in_array(XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
387+
if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
388388
$append = $this->appendComment($parentNode, $data);
389389
}
390390
} elseif (\is_array($data) && false === is_numeric($key)) {

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
[new \ArrayObject(), '{}', []],
5050
[new \ArrayObject(['foo' => 'bar']), '{"foo":"bar"}', []],
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

Tests/Encoder/XmlEncoderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ public function testDecodePreserveComments()
580580

581581
$this->encoder = new XmlEncoder([
582582
XmlEncoder::ROOT_NODE_NAME => 'people',
583-
XmlEncoder::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE],
583+
XmlEncoder::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE],
584584
]);
585585
$serializer = new Serializer([new CustomNormalizer()], ['xml' => new XmlEncoder()]);
586586
$this->encoder->setSerializer($serializer);
@@ -813,7 +813,7 @@ public function testEncodeWithoutPi()
813813
{
814814
$encoder = new XmlEncoder([
815815
XmlEncoder::ROOT_NODE_NAME => 'response',
816-
XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_PI_NODE],
816+
XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [\XML_PI_NODE],
817817
]);
818818

819819
$expected = '<response/>';
@@ -825,7 +825,7 @@ public function testEncodeWithoutComment()
825825
{
826826
$encoder = new XmlEncoder([
827827
XmlEncoder::ROOT_NODE_NAME => 'response',
828-
XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [XML_COMMENT_NODE],
828+
XmlEncoder::ENCODER_IGNORED_NODE_TYPES => [\XML_COMMENT_NODE],
829829
]);
830830

831831
$expected = <<<'XML'

0 commit comments

Comments
 (0)