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 f8e1211 + b7d9a52 commit c4bc95b
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Encoder/CsvEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CsvEncoder implements EncoderInterface, DecoderInterface
public function __construct($defaultContext = [], string $enclosure = '"', string $escapeChar = '', string $keySeparator = '.', bool $escapeFormulas = false)
{
if (!\is_array($defaultContext)) {
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED);
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', \E_USER_DEPRECATED);

$defaultContext = [
self::DELIMITER_KEY => (string) $defaultContext,
Expand Down Expand Up @@ -214,7 +214,7 @@ public function decode($data, $format, array $context = [])
}

if (!isset($context['as_collection'])) {
@trigger_error('Relying on the default value (false) of the "as_collection" option is deprecated since 4.2. You should set it to false explicitly instead as true will be the default value in 5.0.', E_USER_DEPRECATED);
@trigger_error('Relying on the default value (false) of the "as_collection" option is deprecated since 4.2. You should set it to false explicitly instead as true will be the default value in 5.0.', \E_USER_DEPRECATED);
}

// If there is only one data line in the document, return it (the line), the result is not considered as a collection
Expand Down
6 changes: 3 additions & 3 deletions Encoder/JsonDecode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class JsonDecode implements DecoderInterface
public function __construct($defaultContext = [], int $depth = 512)
{
if (!\is_array($defaultContext)) {
@trigger_error(sprintf('Using constructor parameters that are not a default context is deprecated since Symfony 4.2, use the "%s" and "%s" keys of the context instead.', self::ASSOCIATIVE, self::RECURSION_DEPTH), E_USER_DEPRECATED);
@trigger_error(sprintf('Using constructor parameters that are not a default context is deprecated since Symfony 4.2, use the "%s" and "%s" keys of the context instead.', self::ASSOCIATIVE, self::RECURSION_DEPTH), \E_USER_DEPRECATED);

$defaultContext = [
self::ASSOCIATIVE => (bool) $defaultContext,
Expand Down Expand Up @@ -98,11 +98,11 @@ public function decode($data, $format, array $context = [])
throw new NotEncodableValueException($e->getMessage(), 0, $e);
}

if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
return $decodedData;
}

if (JSON_ERROR_NONE !== json_last_error()) {
if (\JSON_ERROR_NONE !== json_last_error()) {
throw new NotEncodableValueException(json_last_error_msg());
}

Expand Down
6 changes: 3 additions & 3 deletions Encoder/JsonEncode.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class JsonEncode implements EncoderInterface
public function __construct($defaultContext = [])
{
if (!\is_array($defaultContext)) {
@trigger_error(sprintf('Passing an integer as first parameter of the "%s()" method is deprecated since Symfony 4.2, use the "json_encode_options" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing an integer as first parameter of the "%s()" method is deprecated since Symfony 4.2, use the "json_encode_options" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->defaultContext[self::OPTIONS] = (int) $defaultContext;
} else {
Expand All @@ -55,11 +55,11 @@ public function encode($data, $format, array $context = [])
throw new NotEncodableValueException($e->getMessage(), 0, $e);
}

if (\PHP_VERSION_ID >= 70300 && (JSON_THROW_ON_ERROR & $options)) {
if (\PHP_VERSION_ID >= 70300 && (\JSON_THROW_ON_ERROR & $options)) {
return $encodedJson;
}

if (JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & JSON_PARTIAL_OUTPUT_ON_ERROR))) {
if (\JSON_ERROR_NONE !== json_last_error() && (false === $encodedJson || !($options & \JSON_PARTIAL_OUTPUT_ON_ERROR))) {
throw new NotEncodableValueException(json_last_error_msg());
}

Expand Down
28 changes: 14 additions & 14 deletions Encoder/XmlEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa

private $defaultContext = [
self::AS_COLLECTION => false,
self::DECODER_IGNORED_NODE_TYPES => [XML_PI_NODE, XML_COMMENT_NODE],
self::DECODER_IGNORED_NODE_TYPES => [\XML_PI_NODE, \XML_COMMENT_NODE],
self::ENCODER_IGNORED_NODE_TYPES => [],
self::LOAD_OPTIONS => LIBXML_NONET | LIBXML_NOBLANKS,
self::LOAD_OPTIONS => \LIBXML_NONET | \LIBXML_NOBLANKS,
self::REMOVE_EMPTY_TAGS => false,
self::ROOT_NODE_NAME => 'response',
self::TYPE_CAST_ATTRIBUTES => true,
Expand All @@ -78,15 +78,15 @@ class XmlEncoder implements EncoderInterface, DecoderInterface, NormalizationAwa
/**
* @param array $defaultContext
*/
public function __construct($defaultContext = [], int $loadOptions = null, array $decoderIgnoredNodeTypes = [XML_PI_NODE, XML_COMMENT_NODE], array $encoderIgnoredNodeTypes = [])
public function __construct($defaultContext = [], int $loadOptions = null, array $decoderIgnoredNodeTypes = [\XML_PI_NODE, \XML_COMMENT_NODE], array $encoderIgnoredNodeTypes = [])
{
if (!\is_array($defaultContext)) {
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED);
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', \E_USER_DEPRECATED);

$defaultContext = [
self::DECODER_IGNORED_NODE_TYPES => $decoderIgnoredNodeTypes,
self::ENCODER_IGNORED_NODE_TYPES => $encoderIgnoredNodeTypes,
self::LOAD_OPTIONS => $loadOptions ?? LIBXML_NONET | LIBXML_NOBLANKS,
self::LOAD_OPTIONS => $loadOptions ?? \LIBXML_NONET | \LIBXML_NOBLANKS,
self::ROOT_NODE_NAME => (string) $defaultContext,
];
}
Expand All @@ -100,7 +100,7 @@ public function __construct($defaultContext = [], int $loadOptions = null, array
public function encode($data, $format, array $context = [])
{
$encoderIgnoredNodeTypes = $context[self::ENCODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::ENCODER_IGNORED_NODE_TYPES];
$ignorePiNode = \in_array(XML_PI_NODE, $encoderIgnoredNodeTypes, true);
$ignorePiNode = \in_array(\XML_PI_NODE, $encoderIgnoredNodeTypes, true);
if ($data instanceof \DOMDocument) {
return $data->saveXML($ignorePiNode ? $data->documentElement : null);
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public function decode($data, $format, array $context = [])
}

$internalErrors = libxml_use_internal_errors(true);
if (LIBXML_VERSION < 20900) {
if (\LIBXML_VERSION < 20900) {
$disableEntities = libxml_disable_entity_loader(true);
}
libxml_clear_errors();
Expand All @@ -141,7 +141,7 @@ public function decode($data, $format, array $context = [])
$dom->loadXML($data, $context[self::LOAD_OPTIONS] ?? $this->defaultContext[self::LOAD_OPTIONS]);

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

Expand All @@ -154,7 +154,7 @@ public function decode($data, $format, array $context = [])
$rootNode = null;
$decoderIgnoredNodeTypes = $context[self::DECODER_IGNORED_NODE_TYPES] ?? $this->defaultContext[self::DECODER_IGNORED_NODE_TYPES];
foreach ($dom->childNodes as $child) {
if (XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
if (\XML_DOCUMENT_TYPE_NODE === $child->nodeType) {
throw new NotEncodableValueException('Document types are not allowed.');
}
if (!$rootNode && !\in_array($child->nodeType, $decoderIgnoredNodeTypes, true)) {
Expand Down Expand Up @@ -220,7 +220,7 @@ public function supportsDecoding($format)
*/
public function setRootNodeName($name)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->defaultContext[self::ROOT_NODE_NAME] = $name;
}
Expand All @@ -234,7 +234,7 @@ public function setRootNodeName($name)
*/
public function getRootNodeName()
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the context instead.', __METHOD__), \E_USER_DEPRECATED);

return $this->defaultContext[self::ROOT_NODE_NAME];
}
Expand Down Expand Up @@ -352,7 +352,7 @@ private function parseXmlAttributes(\DOMNode $node, array $context = []): array
continue;
}

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

continue;
Expand All @@ -375,7 +375,7 @@ private function parseXmlValue(\DOMNode $node, array $context = [])
return $node->nodeValue;
}

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

Expand Down Expand Up @@ -429,7 +429,7 @@ private function buildXml(\DOMNode $parentNode, $data, string $xmlRootNodeName =
} elseif ('#' === $key) {
$append = $this->selectNodeType($parentNode, $data);
} elseif ('#comment' === $key) {
if (!\in_array(XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
if (!\in_array(\XML_COMMENT_NODE, $encoderIgnoredNodeTypes, true)) {
$append = $this->appendComment($parentNode, $data);
}
} elseif (\is_array($data) && false === is_numeric($key)) {
Expand Down
12 changes: 6 additions & 6 deletions Normalizer/AbstractNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
*/
public function setCircularReferenceLimit($circularReferenceLimit)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_limit" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_limit" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->defaultContext[self::CIRCULAR_REFERENCE_LIMIT] = $this->circularReferenceLimit = $circularReferenceLimit;

Expand All @@ -212,7 +212,7 @@ public function setCircularReferenceLimit($circularReferenceLimit)
*/
public function setCircularReferenceHandler(callable $circularReferenceHandler)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_handler" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "circular_reference_handler" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->defaultContext[self::CIRCULAR_REFERENCE_HANDLER] = $this->circularReferenceHandler = $circularReferenceHandler;

Expand All @@ -232,7 +232,7 @@ public function setCircularReferenceHandler(callable $circularReferenceHandler)
*/
public function setCallbacks(array $callbacks)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "callbacks" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "callbacks" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

foreach ($callbacks as $attribute => $callback) {
if (!\is_callable($callback)) {
Expand All @@ -253,7 +253,7 @@ public function setCallbacks(array $callbacks)
*/
public function setIgnoredAttributes(array $ignoredAttributes)
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "ignored_attributes" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "ignored_attributes" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->defaultContext[self::IGNORED_ATTRIBUTES] = $this->ignoredAttributes = $ignoredAttributes;

Expand Down Expand Up @@ -317,7 +317,7 @@ protected function isCircularReference($object, &$context)
protected function handleCircularReference($object/*, string $format = null, array $context = []*/)
{
if (\func_num_args() < 2 && __CLASS__ !== static::class && __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 two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method will have two new "string $format = null" and "array $context = []" arguments in version 5.0, not defining it is deprecated since Symfony 4.2.', __METHOD__), \E_USER_DEPRECATED);
}
$format = \func_num_args() > 1 ? func_get_arg(1) : null;
$context = \func_num_args() > 2 ? func_get_arg(2) : [];
Expand Down Expand Up @@ -553,7 +553,7 @@ protected function denormalizeParameter(\ReflectionClass $class, \ReflectionPara
protected function createChildContext(array $parentContext, $attribute/*, ?string $format */): array
{
if (\func_num_args() < 3) {
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), \E_USER_DEPRECATED);
}
if (isset($parentContext[self::ATTRIBUTES][$attribute])) {
$parentContext[self::ATTRIBUTES] = $parentContext[self::ATTRIBUTES][$attribute];
Expand Down
4 changes: 2 additions & 2 deletions Normalizer/AbstractObjectNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ abstract protected function getAttributeValue($object, $attribute, $format = nul
*/
public function setMaxDepthHandler(?callable $handler): void
{
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "max_depth_handler" key of the context instead.', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.2, use the "max_depth_handler" key of the context instead.', __METHOD__), \E_USER_DEPRECATED);

$this->maxDepthHandler = $handler;
}
Expand Down Expand Up @@ -595,7 +595,7 @@ protected function createChildContext(array $parentContext, $attribute/*, ?strin
if (\func_num_args() >= 3) {
$format = func_get_arg(2);
} else {
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), E_USER_DEPRECATED);
@trigger_error(sprintf('Method "%s::%s()" will have a third "?string $format" argument in version 5.0; not defining it is deprecated since Symfony 4.3.', static::class, __FUNCTION__), \E_USER_DEPRECATED);
$format = null;
}

Expand Down
4 changes: 2 additions & 2 deletions Normalizer/DataUriNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class DataUriNormalizer implements NormalizerInterface, DenormalizerInterface, C
public function __construct($mimeTypeGuesser = null)
{
if ($mimeTypeGuesser instanceof DeprecatedMimeTypeGuesserInterface) {
@trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedMimeTypeGuesserInterface::class, __METHOD__, MimeTypeGuesserInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a %s to "%s()" is deprecated since Symfony 4.3, pass a "%s" instead.', DeprecatedMimeTypeGuesserInterface::class, __METHOD__, MimeTypeGuesserInterface::class), \E_USER_DEPRECATED);
} elseif (null === $mimeTypeGuesser) {
if (class_exists(MimeTypes::class)) {
$mimeTypeGuesser = MimeTypes::getDefault();
} elseif (class_exists(MimeTypeGuesser::class)) {
@trigger_error(sprintf('Passing null to "%s()" to use a default MIME type guesser without Symfony Mime installed is deprecated since Symfony 4.3. Try running "composer require symfony/mime".', __METHOD__), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing null to "%s()" to use a default MIME type guesser without Symfony Mime installed is deprecated since Symfony 4.3. Try running "composer require symfony/mime".', __METHOD__), \E_USER_DEPRECATED);
$mimeTypeGuesser = MimeTypeGuesser::getInstance();
}
} elseif (!$mimeTypeGuesser instanceof MimeTypes) {
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/DateIntervalNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DateIntervalNormalizer implements NormalizerInterface, DenormalizerInterfa
public function __construct($defaultContext = [])
{
if (!\is_array($defaultContext)) {
@trigger_error(sprintf('The "format" parameter is deprecated since Symfony 4.2, use the "%s" key of the context instead.', self::FORMAT_KEY), E_USER_DEPRECATED);
@trigger_error(sprintf('The "format" parameter is deprecated since Symfony 4.2, use the "%s" key of the context instead.', self::FORMAT_KEY), \E_USER_DEPRECATED);

$defaultContext = [self::FORMAT_KEY => (string) $defaultContext];
}
Expand Down
2 changes: 1 addition & 1 deletion Normalizer/DateTimeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($defaultContext = [], \DateTimeZone $timezone = null
];

if (!\is_array($defaultContext)) {
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', E_USER_DEPRECATED);
@trigger_error('Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.', \E_USER_DEPRECATED);

$defaultContext = [self::FORMAT_KEY => (string) $defaultContext];
$defaultContext[self::TIMEZONE_KEY] = $timezone;
Expand Down
Loading

0 comments on commit c4bc95b

Please sign in to comment.