This commit is contained in:
Fabien Potencier 2019-06-13 13:03:18 +02:00
parent 84bc7aba91
commit 9526988eca
51 changed files with 84 additions and 84 deletions

View File

@ -30,17 +30,17 @@ class ClassExistsMock
public static function class_exists($name, $autoload = true) public static function class_exists($name, $autoload = true)
{ {
return (bool) (self::$classes[ltrim($name, '\\')] ?? \class_exists($name, $autoload)); return (bool) (self::$classes[ltrim($name, '\\')] ?? class_exists($name, $autoload));
} }
public static function interface_exists($name, $autoload = true) public static function interface_exists($name, $autoload = true)
{ {
return (bool) (self::$classes[ltrim($name, '\\')] ?? \interface_exists($name, $autoload)); return (bool) (self::$classes[ltrim($name, '\\')] ?? interface_exists($name, $autoload));
} }
public static function trait_exists($name, $autoload = true) public static function trait_exists($name, $autoload = true)
{ {
return (bool) (self::$classes[ltrim($name, '\\')] ?? \trait_exists($name, $autoload)); return (bool) (self::$classes[ltrim($name, '\\')] ?? trait_exists($name, $autoload));
} }
public static function register($class) public static function register($class)

View File

@ -46,7 +46,7 @@ class HttpFoundationExtension extends AbstractExtension
$requestContext = null; $requestContext = null;
if (2 === \func_num_args()) { if (2 === \func_num_args()) {
$requestContext = \func_get_arg(1); $requestContext = func_get_arg(1);
if (null !== $requestContext && !$requestContext instanceof RequestContext) { if (null !== $requestContext && !$requestContext instanceof RequestContext) {
throw new \TypeError(sprintf('The second argument must be an instance of "%s".', RequestContext::class)); throw new \TypeError(sprintf('The second argument must be an instance of "%s".', RequestContext::class));
} }

View File

@ -1115,12 +1115,12 @@ class FrameworkExtension extends Extension
$defaultDir = $container->getParameterBag()->resolveValue($config['default_path']); $defaultDir = $container->getParameterBag()->resolveValue($config['default_path']);
$rootDir = $container->getParameter('kernel.root_dir'); $rootDir = $container->getParameter('kernel.root_dir');
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) { foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
if (\is_dir($dir = $bundle['path'].'/Resources/translations')) { if (is_dir($dir = $bundle['path'].'/Resources/translations')) {
$dirs[] = $dir; $dirs[] = $dir;
} else { } else {
$nonExistingDirs[] = $dir; $nonExistingDirs[] = $dir;
} }
if (\is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) { if (is_dir($dir = $rootDir.sprintf('/Resources/%s/translations', $name))) {
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
$dirs[] = $dir; $dirs[] = $dir;
} else { } else {
@ -1129,7 +1129,7 @@ class FrameworkExtension extends Extension
} }
foreach ($config['paths'] as $dir) { foreach ($config['paths'] as $dir) {
if (\is_dir($dir)) { if (is_dir($dir)) {
$dirs[] = $transPaths[] = $dir; $dirs[] = $transPaths[] = $dir;
} else { } else {
throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir)); throw new \UnexpectedValueException(sprintf('%s defined in translator.paths does not exist or is not a directory', $dir));
@ -1144,13 +1144,13 @@ class FrameworkExtension extends Extension
$container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths); $container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths);
} }
if (\is_dir($defaultDir)) { if (is_dir($defaultDir)) {
$dirs[] = $defaultDir; $dirs[] = $defaultDir;
} else { } else {
$nonExistingDirs[] = $defaultDir; $nonExistingDirs[] = $defaultDir;
} }
if (\is_dir($dir = $rootDir.'/Resources/translations')) { if (is_dir($dir = $rootDir.'/Resources/translations')) {
if ($dir !== $defaultDir) { if ($dir !== $defaultDir) {
@trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED); @trigger_error(sprintf('Translations directory "%s" is deprecated since Symfony 4.2, use "%s" instead.', $dir, $defaultDir), E_USER_DEPRECATED);
} }
@ -1186,7 +1186,7 @@ class FrameworkExtension extends Extension
$translator->getArgument(4), $translator->getArgument(4),
[ [
'resource_files' => $files, 'resource_files' => $files,
'scanned_directories' => \array_merge($dirs, $nonExistingDirs), 'scanned_directories' => array_merge($dirs, $nonExistingDirs),
] ]
); );

View File

@ -195,7 +195,7 @@ trait WebTestAssertionsTrait
} }
if (!$client instanceof KernelBrowser) { if (!$client instanceof KernelBrowser) {
static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__)); static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__));
} }
return $client; return $client;

View File

@ -60,7 +60,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
$item->metadata[CacheItem::METADATA_TAGS] = $value['tags'] ?? []; $item->metadata[CacheItem::METADATA_TAGS] = $value['tags'] ?? [];
if (isset($value['meta'])) { if (isset($value['meta'])) {
// For compactness these values are packed, & expiry is offset to reduce size // For compactness these values are packed, & expiry is offset to reduce size
$v = \unpack('Ve/Nc', $value['meta']); $v = unpack('Ve/Nc', $value['meta']);
$item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET; $item->metadata[CacheItem::METADATA_EXPIRY] = $v['e'] + CacheItem::METADATA_EXPIRY_OFFSET;
$item->metadata[CacheItem::METADATA_CTIME] = $v['c']; $item->metadata[CacheItem::METADATA_CTIME] = $v['c'];
} }
@ -96,16 +96,16 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
if ($metadata) { if ($metadata) {
// For compactness, expiry and creation duration are packed, using magic numbers as separators // For compactness, expiry and creation duration are packed, using magic numbers as separators
$value['meta'] = \pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME]); $value['meta'] = pack('VN', (int) $metadata[CacheItem::METADATA_EXPIRY] - CacheItem::METADATA_EXPIRY_OFFSET, $metadata[CacheItem::METADATA_CTIME]);
} }
// Extract tag changes, these should be removed from values in doSave() // Extract tag changes, these should be removed from values in doSave()
$value['tag-operations'] = ['add' => [], 'remove' => []]; $value['tag-operations'] = ['add' => [], 'remove' => []];
$oldTags = $item->metadata[CacheItem::METADATA_TAGS] ?? []; $oldTags = $item->metadata[CacheItem::METADATA_TAGS] ?? [];
foreach (\array_diff($value['tags'], $oldTags) as $addedTag) { foreach (array_diff($value['tags'], $oldTags) as $addedTag) {
$value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag); $value['tag-operations']['add'][] = $getId($tagPrefix.$addedTag);
} }
foreach (\array_diff($oldTags, $value['tags']) as $removedTag) { foreach (array_diff($oldTags, $value['tags']) as $removedTag) {
$value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag); $value['tag-operations']['remove'][] = $getId($tagPrefix.$removedTag);
} }
@ -236,7 +236,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
} }
try { try {
if ($this->doDelete(\array_values($ids), $tagData)) { if ($this->doDelete(array_values($ids), $tagData)) {
return true; return true;
} }
} catch (\Exception $e) { } catch (\Exception $e) {
@ -271,7 +271,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA
} }
$tagIds = []; $tagIds = [];
foreach (\array_unique($tags) as $tag) { foreach (array_unique($tags) as $tag) {
$tagIds[] = $this->getId(self::TAGS_PREFIX.$tag); $tagIds[] = $this->getId(self::TAGS_PREFIX.$tag);
} }

View File

@ -126,7 +126,7 @@ class FilesystemTagAwareAdapter extends AbstractTagAwareAdapter implements Prune
} }
$valueFile = $itemLink->getRealPath(); $valueFile = $itemLink->getRealPath();
if ($valueFile && \file_exists($valueFile)) { if ($valueFile && file_exists($valueFile)) {
@unlink($valueFile); @unlink($valueFile);
} }

View File

@ -82,7 +82,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
$this->init($redisClient, $namespace, $defaultLifetime, $marshaller); $this->init($redisClient, $namespace, $defaultLifetime, $marshaller);
// Make sure php-redis is 3.1.3 or higher configured for Redis classes // Make sure php-redis is 3.1.3 or higher configured for Redis classes
if (!$this->redis instanceof Predis\Client && \version_compare(\phpversion('redis'), '3.1.3', '<')) { if (!$this->redis instanceof Predis\Client && version_compare(phpversion('redis'), '3.1.3', '<')) {
throw new LogicException('RedisTagAwareAdapter requires php-redis 3.1.3 or higher, alternatively use predis/predis'); throw new LogicException('RedisTagAwareAdapter requires php-redis 3.1.3 or higher, alternatively use predis/predis');
} }
} }
@ -120,7 +120,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
foreach ($results as $id => $result) { foreach ($results as $id => $result) {
// Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not // Skip results of SADD/SREM operations, they'll be 1 or 0 depending on if set value already existed or not
if (\is_numeric($result)) { if (is_numeric($result)) {
continue; continue;
} }
// setEx results // setEx results
@ -152,7 +152,7 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
} }
foreach ($tagData as $tagId => $idList) { foreach ($tagData as $tagId => $idList) {
yield 'sRem' => \array_merge([$tagId], $idList); yield 'sRem' => array_merge([$tagId], $idList);
} }
})->rewind(); })->rewind();
@ -178,10 +178,10 @@ class RedisTagAwareAdapter extends AbstractTagAwareAdapter
}); });
// Flatten generator result from pipeline, ignore keys (tag ids) // Flatten generator result from pipeline, ignore keys (tag ids)
$ids = \array_unique(\array_merge(...\iterator_to_array($tagIdSets, false))); $ids = array_unique(array_merge(...iterator_to_array($tagIdSets, false)));
// Delete cache in chunks to avoid overloading the connection // Delete cache in chunks to avoid overloading the connection
foreach (\array_chunk($ids, self::BULK_DELETE_LIMIT) as $chunkIds) { foreach (array_chunk($ids, self::BULK_DELETE_LIMIT) as $chunkIds) {
$this->doDelete($chunkIds); $this->doDelete($chunkIds);
} }

View File

@ -250,7 +250,7 @@ final class ProgressBar
*/ */
public function iterate(iterable $iterable, ?int $max = null): iterable public function iterate(iterable $iterable, ?int $max = null): iterable
{ {
$this->start($max ?? (\is_countable($iterable) ? \count($iterable) : 0)); $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
foreach ($iterable as $key => $value) { foreach ($iterable as $key => $value) {
yield $key => $value; yield $key => $value;

View File

@ -884,7 +884,7 @@ class ProgressBarTest extends TestCase
{ {
$bar = new ProgressBar($output = $this->getOutputStream()); $bar = new ProgressBar($output = $this->getOutputStream());
$this->assertEquals([1, 2], \iterator_to_array($bar->iterate([1, 2]))); $this->assertEquals([1, 2], iterator_to_array($bar->iterate([1, 2])));
rewind($output->getStream()); rewind($output->getStream());
$this->assertEquals( $this->assertEquals(
@ -900,7 +900,7 @@ class ProgressBarTest extends TestCase
{ {
$bar = new ProgressBar($output = $this->getOutputStream()); $bar = new ProgressBar($output = $this->getOutputStream());
$this->assertEquals([1, 2], \iterator_to_array($bar->iterate((function () { $this->assertEquals([1, 2], iterator_to_array($bar->iterate((function () {
yield 1; yield 1;
yield 2; yield 2;
})()))); })())));

View File

@ -238,7 +238,7 @@ class DebugClassLoader
} }
} }
if ($refl->isInterface() && false !== \strpos($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+(?:[\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, PREG_SET_ORDER)) { if ($refl->isInterface() && false !== strpos($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+(?:[\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, PREG_SET_ORDER)) {
foreach ($notice as $method) { foreach ($notice as $method) {
$static = '' !== $method[1]; $static = '' !== $method[1];
$name = $method[2]; $name = $method[2];

View File

@ -457,10 +457,10 @@ EOF;
private function addElementToGhost() private function addElementToGhost()
{ {
if (!isset(self::GHOST_ADDONS[\date('m-d')])) { if (!isset(self::GHOST_ADDONS[date('m-d')])) {
return ''; return '';
} }
return '<path d="'.self::GHOST_ADDONS[\date('m-d')].'" fill="#fff" fill-opacity="0.6"></path>'; return '<path d="'.self::GHOST_ADDONS[date('m-d')].'" fill="#fff" fill-opacity="0.6"></path>';
} }
} }

View File

@ -354,7 +354,7 @@ class Definition
if (empty($method)) { if (empty($method)) {
throw new InvalidArgumentException('Method name cannot be empty.'); throw new InvalidArgumentException('Method name cannot be empty.');
} }
$this->calls[] = 2 < \func_num_args() && \func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments]; $this->calls[] = 2 < \func_num_args() && func_get_arg(2) ? [$method, $arguments, true] : [$method, $arguments];
return $this; return $this;
} }

View File

@ -566,7 +566,7 @@ class Crawler implements \Countable, \IteratorAggregate
{ {
if (!$this->nodes) { if (!$this->nodes) {
if (0 < \func_num_args()) { if (0 < \func_num_args()) {
return \func_get_arg(0); return func_get_arg(0);
} }
throw new \InvalidArgumentException('The current node list is empty.'); throw new \InvalidArgumentException('The current node list is empty.');
@ -588,7 +588,7 @@ class Crawler implements \Countable, \IteratorAggregate
{ {
if (!$this->nodes) { if (!$this->nodes) {
if (0 < \func_num_args()) { if (0 < \func_num_args()) {
return \func_get_arg(0); return func_get_arg(0);
} }
throw new \InvalidArgumentException('The current node list is empty.'); throw new \InvalidArgumentException('The current node list is empty.');

View File

@ -45,7 +45,7 @@ final class CrawlerSelectorTextContains extends Constraint
return false; return false;
} }
return false !== \mb_strpos($crawler->text(), $this->expectedText); return false !== mb_strpos($crawler->text(), $this->expectedText);
} }
/** /**

View File

@ -140,7 +140,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
} }
$currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : ''; $currentRequestHash = $this->currentRequestHash = $this->requestStack && ($request = $this->requestStack->getCurrentRequest()) ? spl_object_hash($request) : '';
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; $eventName = 1 < \func_num_args() ? func_get_arg(1) : null;
if (\is_object($event)) { if (\is_object($event)) {
$eventName = $eventName ?? \get_class($event); $eventName = $eventName ?? \get_class($event);
@ -193,7 +193,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
return []; return [];
} }
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null; $hash = 1 <= \func_num_args() && null !== ($request = func_get_arg(0)) ? spl_object_hash($request) : null;
$called = []; $called = [];
foreach ($this->callStack as $listener) { foreach ($this->callStack as $listener) {
list($eventName, $requestHash) = $this->callStack->getInfo(); list($eventName, $requestHash) = $this->callStack->getInfo();
@ -223,7 +223,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
return []; return [];
} }
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null; $hash = 1 <= \func_num_args() && null !== ($request = func_get_arg(0)) ? spl_object_hash($request) : null;
$calledListeners = []; $calledListeners = [];
if (null !== $this->callStack) { if (null !== $this->callStack) {
@ -258,7 +258,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
*/ */
public function getOrphanedEvents(/* Request $request = null */): array public function getOrphanedEvents(/* Request $request = null */): array
{ {
if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) { if (1 <= \func_num_args() && null !== $request = func_get_arg(0)) {
return $this->orphanedEvents[spl_object_hash($request)] ?? []; return $this->orphanedEvents[spl_object_hash($request)] ?? [];
} }

View File

@ -50,7 +50,7 @@ class EventDispatcher implements EventDispatcherInterface
*/ */
public function dispatch($event/*, string $eventName = null*/) public function dispatch($event/*, string $eventName = null*/)
{ {
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; $eventName = 1 < \func_num_args() ? func_get_arg(1) : null;
if (\is_object($event)) { if (\is_object($event)) {
$eventName = $eventName ?? \get_class($event); $eventName = $eventName ?? \get_class($event);

View File

@ -32,9 +32,9 @@ class ImmutableEventDispatcher implements EventDispatcherInterface
*/ */
public function dispatch($event/*, string $eventName = null*/) public function dispatch($event/*, string $eventName = null*/)
{ {
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; $eventName = 1 < \func_num_args() ? func_get_arg(1) : null;
if (\is_scalar($event)) { if (is_scalar($event)) {
// deprecated // deprecated
$swap = $event; $swap = $event;
$event = $eventName ?? new Event(); $event = $eventName ?? new Event();

View File

@ -53,7 +53,7 @@ final class LegacyEventDispatcherProxy implements EventDispatcherInterface
*/ */
public function dispatch($event/*, string $eventName = null*/) public function dispatch($event/*, string $eventName = null*/)
{ {
$eventName = 1 < \func_num_args() ? \func_get_arg(1) : null; $eventName = 1 < \func_num_args() ? func_get_arg(1) : null;
if (\is_object($event)) { if (\is_object($event)) {
$eventName = $eventName ?? \get_class($event); $eventName = $eventName ?? \get_class($event);

View File

@ -61,7 +61,7 @@ class SplFileInfo extends \SplFileInfo
{ {
$filename = $this->getFilename(); $filename = $this->getFilename();
return \pathinfo($filename, PATHINFO_FILENAME); return pathinfo($filename, PATHINFO_FILENAME);
} }
/** /**

View File

@ -61,7 +61,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
$this->name = $name; $this->name = $name;
$this->options = $options; $this->options = $options;
if (\preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) { if (preg_match('/^([^a-z0-9_].*)?(.*[^a-zA-Z0-9_\-:].*)?$/D', $name, $matches)) {
if (isset($matches[1])) { if (isset($matches[1])) {
@trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED); @trigger_error(sprintf('Using names for buttons that do not start with a letter, a digit, or an underscore is deprecated since Symfony 4.3 and will throw an exception in 5.0 ("%s" given).', $name), E_USER_DEPRECATED);
} }

View File

@ -236,7 +236,7 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
return; return;
} }
$groupLabels = \is_array($groupLabels) ? \array_map('strval', $groupLabels) : [(string) $groupLabels]; $groupLabels = \is_array($groupLabels) ? array_map('strval', $groupLabels) : [(string) $groupLabels];
foreach ($groupLabels as $groupLabel) { foreach ($groupLabels as $groupLabel) {
// Initialize the group views if necessary. Unnecessarily built group // Initialize the group views if necessary. Unnecessarily built group

View File

@ -109,7 +109,7 @@ class CachingHttpClient implements HttpClientInterface
{ {
if ($responses instanceof ResponseInterface) { if ($responses instanceof ResponseInterface) {
$responses = [$responses]; $responses = [$responses];
} elseif (!\is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of ResponseInterface objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
} }

View File

@ -284,7 +284,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
{ {
if ($responses instanceof CurlResponse) { if ($responses instanceof CurlResponse) {
$responses = [$responses]; $responses = [$responses];
} elseif (!\is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
} }

View File

@ -200,7 +200,7 @@ trait HttpClientTrait
if (\is_int($name)) { if (\is_int($name)) {
[$name, $values] = explode(':', $values, 2); [$name, $values] = explode(':', $values, 2);
$values = [ltrim($values)]; $values = [ltrim($values)];
} elseif (!\is_iterable($values)) { } elseif (!is_iterable($values)) {
$values = (array) $values; $values = (array) $values;
} }

View File

@ -78,7 +78,7 @@ class MockHttpClient implements HttpClientInterface
{ {
if ($responses instanceof ResponseInterface) { if ($responses instanceof ResponseInterface) {
$responses = [$responses]; $responses = [$responses];
} elseif (!\is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of MockResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
} }

View File

@ -220,7 +220,7 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
{ {
if ($responses instanceof NativeResponse) { if ($responses instanceof NativeResponse) {
$responses = [$responses]; $responses = [$responses];
} elseif (!\is_iterable($responses)) { } elseif (!is_iterable($responses)) {
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses))); throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of NativeResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
} }

View File

@ -44,7 +44,7 @@ class MockResponse implements ResponseInterface
*/ */
public function __construct($body = '', array $info = []) public function __construct($body = '', array $info = [])
{ {
$this->body = \is_iterable($body) ? $body : (string) $body; $this->body = is_iterable($body) ? $body : (string) $body;
$this->info = $info + $this->info; $this->info = $info + $this->info;
if (!isset($info['response_headers'])) { if (!isset($info['response_headers'])) {

View File

@ -232,7 +232,7 @@ class HttpClientTraitTest extends TestCase
public function provideFingerprints() public function provideFingerprints()
{ {
foreach (['md5', 'sha1', 'sha256'] as $algo) { foreach (['md5', 'sha1', 'sha256'] as $algo) {
$hash = \hash($algo, $algo); $hash = hash($algo, $algo);
yield [$hash, [$algo => $hash]]; yield [$hash, [$algo => $hash]];
} }

View File

@ -58,7 +58,7 @@ class StoreFactory
return new FlockStore(substr($connection, 8)); return new FlockStore(substr($connection, 8));
case 'semaphore' === $connection: case 'semaphore' === $connection:
return new SemaphoreStore(); return new SemaphoreStore();
case \class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection): case class_exists(AbstractAdapter::class) && preg_match('#^[a-z]++://#', $connection):
return static::createStore(AbstractAdapter::createConnection($connection)); return static::createStore(AbstractAdapter::createConnection($connection));
default: default:
throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection)); throw new InvalidArgumentException(sprintf('Unsupported Connection: %s.', $connection));

View File

@ -38,23 +38,23 @@ class StoreFactoryTest extends TestCase
public function validConnections() public function validConnections()
{ {
if (\class_exists(\Redis::class)) { if (class_exists(\Redis::class)) {
yield [$this->createMock(\Redis::class), RedisStore::class]; yield [$this->createMock(\Redis::class), RedisStore::class];
} }
if (\class_exists(RedisProxy::class)) { if (class_exists(RedisProxy::class)) {
yield [$this->createMock(RedisProxy::class), RedisStore::class]; yield [$this->createMock(RedisProxy::class), RedisStore::class];
} }
yield [new \Predis\Client(), RedisStore::class]; yield [new \Predis\Client(), RedisStore::class];
if (\class_exists(\Memcached::class)) { if (class_exists(\Memcached::class)) {
yield [new \Memcached(), MemcachedStore::class]; yield [new \Memcached(), MemcachedStore::class];
} }
if (\class_exists(\Zookeeper::class)) { if (class_exists(\Zookeeper::class)) {
yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class]; yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class];
} }
if (\extension_loaded('sysvsem')) { if (\extension_loaded('sysvsem')) {
yield ['semaphore', SemaphoreStore::class]; yield ['semaphore', SemaphoreStore::class];
} }
if (\class_exists(\Memcached::class) && \class_exists(AbstractAdapter::class)) { if (class_exists(\Memcached::class) && class_exists(AbstractAdapter::class)) {
yield ['memcached://server.com', MemcachedStore::class]; yield ['memcached://server.com', MemcachedStore::class];
} }

View File

@ -76,7 +76,7 @@ class SesTransport extends AbstractApiTransport
if ($email->getAttachments()) { if ($email->getAttachments()) {
return [ return [
'Action' => 'SendRawEmail', 'Action' => 'SendRawEmail',
'RawMessage.Data' => \base64_encode($email->toString()), 'RawMessage.Data' => base64_encode($email->toString()),
]; ];
} }

View File

@ -56,7 +56,7 @@ class SesTransport extends AbstractHttpTransport
], ],
'body' => [ 'body' => [
'Action' => 'SendRawEmail', 'Action' => 'SendRawEmail',
'RawMessage.Data' => \base64_encode($message->toString()), 'RawMessage.Data' => base64_encode($message->toString()),
], ],
]); ]);

View File

@ -27,7 +27,7 @@ class SesTransport extends EsmtpTransport
*/ */
public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
{ {
parent::__construct(\sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, 'tls', null, $dispatcher, $logger); parent::__construct(sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, 'tls', null, $dispatcher, $logger);
$this->setUsername($username); $this->setUsername($username);
$this->setPassword($password); $this->setPassword($password);

View File

@ -67,7 +67,7 @@ class SendgridTransport extends AbstractApiTransport
} }
$personalization = [ $personalization = [
'to' => \array_map($addressStringifier, $this->getRecipients($email, $envelope)), 'to' => array_map($addressStringifier, $this->getRecipients($email, $envelope)),
'subject' => $email->getSubject(), 'subject' => $email->getSubject(),
]; ];
if ($emails = array_map($addressStringifier, $email->getCc())) { if ($emails = array_map($addressStringifier, $email->getCc())) {

View File

@ -68,9 +68,9 @@ class Transport
throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a mailer name.', $dsn)); throw new InvalidArgumentException(sprintf('The "%s" mailer DSN must contain a mailer name.', $dsn));
} }
$user = \urldecode($parsedDsn['user'] ?? ''); $user = urldecode($parsedDsn['user'] ?? '');
$pass = \urldecode($parsedDsn['pass'] ?? ''); $pass = urldecode($parsedDsn['pass'] ?? '');
\parse_str($parsedDsn['query'] ?? '', $query); parse_str($parsedDsn['query'] ?? '', $query);
switch ($parsedDsn['host']) { switch ($parsedDsn['host']) {
case 'null': case 'null':

View File

@ -93,7 +93,7 @@ abstract class AbstractTransport implements TransportInterface
*/ */
protected function stringifyAddresses(array $addresses): array protected function stringifyAddresses(array $addresses): array
{ {
return \array_map(function (Address $a) { return array_map(function (Address $a) {
return $a->toString(); return $a->toString();
}, $addresses); }, $addresses);
} }

View File

@ -61,8 +61,8 @@ abstract class AbstractApiTransport extends AbstractTransport
protected function getRecipients(Email $email, SmtpEnvelope $envelope): array protected function getRecipients(Email $email, SmtpEnvelope $envelope): array
{ {
return \array_filter($envelope->getRecipients(), function (Address $address) use ($email) { return array_filter($envelope->getRecipients(), function (Address $address) use ($email) {
return false === \in_array($address, \array_merge($email->getCc(), $email->getBcc()), true); return false === \in_array($address, array_merge($email->getCc(), $email->getBcc()), true);
}); });
} }
} }

View File

@ -88,7 +88,7 @@ final class Envelope
$cloned = clone $this; $cloned = clone $this;
foreach ($cloned->stamps as $class => $stamps) { foreach ($cloned->stamps as $class => $stamps) {
if ($class === $type || \is_subclass_of($class, $type)) { if ($class === $type || is_subclass_of($class, $type)) {
unset($cloned->stamps[$class]); unset($cloned->stamps[$class]);
} }
} }

View File

@ -61,7 +61,7 @@ class SendFailedMessageToFailureTransportListener implements EventSubscriberInte
$throwable = $throwable->getNestedExceptions()[0]; $throwable = $throwable->getNestedExceptions()[0];
} }
$flattenedException = \class_exists(FlattenException::class) ? FlattenException::createFromThrowable($throwable) : null; $flattenedException = class_exists(FlattenException::class) ? FlattenException::createFromThrowable($throwable) : null;
$envelope = $envelope->withoutAll(ReceivedStamp::class) $envelope = $envelope->withoutAll(ReceivedStamp::class)
->withoutAll(TransportMessageIdStamp::class) ->withoutAll(TransportMessageIdStamp::class)
->with(new SentToFailureTransportStamp($event->getReceiverName())) ->with(new SentToFailureTransportStamp($event->getReceiverName()))

View File

@ -38,7 +38,7 @@ class StackMiddleware implements MiddlewareInterface, StackInterface
$this->stack->iterator = $middlewareIterator; $this->stack->iterator = $middlewareIterator;
} elseif ($middlewareIterator instanceof MiddlewareInterface) { } elseif ($middlewareIterator instanceof MiddlewareInterface) {
$this->stack->stack[] = $middlewareIterator; $this->stack->stack[] = $middlewareIterator;
} elseif (!\is_iterable($middlewareIterator)) { } elseif (!is_iterable($middlewareIterator)) {
throw new \TypeError(sprintf('Argument 1 passed to %s() must be iterable of %s, %s given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator))); throw new \TypeError(sprintf('Argument 1 passed to %s() must be iterable of %s, %s given.', __METHOD__, MiddlewareInterface::class, \is_object($middlewareIterator) ? \get_class($middlewareIterator) : \gettype($middlewareIterator)));
} else { } else {
$this->stack->iterator = (function () use ($middlewareIterator) { $this->stack->iterator = (function () use ($middlewareIterator) {

View File

@ -30,7 +30,7 @@ class ConnectionTest extends TestCase
$stmt = $this->getStatementMock([ $stmt = $this->getStatementMock([
'id' => 1, 'id' => 1,
'body' => '{"message":"Hi"}', 'body' => '{"message":"Hi"}',
'headers' => \json_encode(['type' => DummyMessage::class]), 'headers' => json_encode(['type' => DummyMessage::class]),
]); ]);
$driverConnection $driverConnection

View File

@ -80,7 +80,7 @@ class DoctrineReceiverTest extends TestCase
$connection->method('findAll')->with(50)->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]); $connection->method('findAll')->with(50)->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]);
$receiver = new DoctrineReceiver($connection, $serializer); $receiver = new DoctrineReceiver($connection, $serializer);
$actualEnvelopes = \iterator_to_array($receiver->all(50)); $actualEnvelopes = iterator_to_array($receiver->all(50));
$this->assertCount(2, $actualEnvelopes); $this->assertCount(2, $actualEnvelopes);
$this->assertEquals(new DummyMessage('Hi'), $actualEnvelopes[0]->getMessage()); $this->assertEquals(new DummyMessage('Hi'), $actualEnvelopes[0]->getMessage());
} }

View File

@ -123,7 +123,7 @@ class Connection
$this->executeQuery($queryBuilder->getSQL(), [ $this->executeQuery($queryBuilder->getSQL(), [
':body' => $body, ':body' => $body,
':headers' => \json_encode($headers), ':headers' => json_encode($headers),
':queue_name' => $this->configuration['queue_name'], ':queue_name' => $this->configuration['queue_name'],
':created_at' => self::formatDateTime($now), ':created_at' => self::formatDateTime($now),
':available_at' => self::formatDateTime($availableAt), ':available_at' => self::formatDateTime($availableAt),
@ -155,7 +155,7 @@ class Connection
return null; return null;
} }
$doctrineEnvelope['headers'] = \json_decode($doctrineEnvelope['headers'], true); $doctrineEnvelope['headers'] = json_decode($doctrineEnvelope['headers'], true);
$queryBuilder = $this->driverConnection->createQueryBuilder() $queryBuilder = $this->driverConnection->createQueryBuilder()
->update($this->configuration['table_name']) ->update($this->configuration['table_name'])

View File

@ -124,7 +124,7 @@ class Connection
} }
foreach ($messages[$this->stream] ?? [] as $key => $message) { foreach ($messages[$this->stream] ?? [] as $key => $message) {
$redisEnvelope = \json_decode($message['message'], true); $redisEnvelope = json_decode($message['message'], true);
return [ return [
'id' => $key, 'id' => $key,

View File

@ -110,7 +110,7 @@ class PropertyInfoCacheExtractor implements PropertyInfoExtractorInterface, Prop
} }
// Calling rawurlencode escapes special characters not allowed in PSR-6's keys // Calling rawurlencode escapes special characters not allowed in PSR-6's keys
$encodedMethod = \rawurlencode($method); $encodedMethod = rawurlencode($method);
if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) { if (\array_key_exists($encodedMethod, $this->arrayCache) && \array_key_exists($serializedArguments, $this->arrayCache[$encodedMethod])) {
return $this->arrayCache[$encodedMethod][$serializedArguments]; return $this->arrayCache[$encodedMethod][$serializedArguments];
} }

View File

@ -173,7 +173,7 @@ abstract class AbstractToken implements TokenInterface
{ {
$serialized = $this->__serialize(); $serialized = $this->__serialize();
if (null === $isCalledFromOverridingMethod = \func_num_args() ? \func_get_arg(0) : null) { if (null === $isCalledFromOverridingMethod = \func_num_args() ? func_get_arg(0) : null) {
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
$isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
} }

View File

@ -48,7 +48,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti
public static function isSupported(): bool public static function isSupported(): bool
{ {
if (\class_exists('ParagonIE_Sodium_Compat') && \method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) { if (class_exists('ParagonIE_Sodium_Compat') && method_exists('ParagonIE_Sodium_Compat', 'crypto_pwhash_is_available')) {
return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available(); return \ParagonIE_Sodium_Compat::crypto_pwhash_is_available();
} }
@ -65,7 +65,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti
} }
if (\function_exists('sodium_crypto_pwhash_str')) { if (\function_exists('sodium_crypto_pwhash_str')) {
return \sodium_crypto_pwhash_str($raw, $this->opsLimit, $this->memLimit); return sodium_crypto_pwhash_str($raw, $this->opsLimit, $this->memLimit);
} }
if (\extension_loaded('libsodium')) { if (\extension_loaded('libsodium')) {
@ -90,7 +90,7 @@ final class SodiumPasswordEncoder implements PasswordEncoderInterface, SelfSalti
} }
if (\function_exists('sodium_crypto_pwhash_str_verify')) { if (\function_exists('sodium_crypto_pwhash_str_verify')) {
return \sodium_crypto_pwhash_str_verify($encoded, $raw); return sodium_crypto_pwhash_str_verify($encoded, $raw);
} }
if (\extension_loaded('libsodium')) { if (\extension_loaded('libsodium')) {

View File

@ -69,7 +69,7 @@ class AuthenticationException extends RuntimeException
{ {
$serialized = $this->__serialize(); $serialized = $this->__serialize();
if (null === $isCalledFromOverridingMethod = \func_num_args() ? \func_get_arg(0) : null) { if (null === $isCalledFromOverridingMethod = \func_num_args() ? func_get_arg(0) : null) {
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2); $trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
$isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object']; $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
} }

View File

@ -46,7 +46,7 @@ class TranslatorPathsPass extends AbstractRecursivePass
} }
foreach ($this->findControllerArguments($container) as $controller => $argument) { foreach ($this->findControllerArguments($container) as $controller => $argument) {
$id = \substr($controller, 0, \strpos($controller, ':') ?: \strlen($controller)); $id = substr($controller, 0, strpos($controller, ':') ?: \strlen($controller));
if ($container->hasDefinition($id)) { if ($container->hasDefinition($id)) {
list($locatorRef) = $argument->getValues(); list($locatorRef) = $argument->getValues();
$this->controllers[(string) $locatorRef][$container->getDefinition($id)->getClass()] = true; $this->controllers[(string) $locatorRef][$container->getDefinition($id)->getClass()] = true;

View File

@ -204,7 +204,7 @@ class PhpExtractor extends AbstractFileExtractor implements ExtractorInterface
if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __CLASS__ !== (new \ReflectionMethod($this, __FUNCTION__))->getDeclaringClass()->getName() && !$this instanceof \PHPUnit\Framework\MockObject\MockObject && !$this instanceof \Prophecy\Prophecy\ProphecySubjectInterface) { if (\func_num_args() < 3 && __CLASS__ !== \get_class($this) && __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 "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED); @trigger_error(sprintf('The "%s()" method will have a new "string $filename" argument in version 5.0, not defining it is deprecated since Symfony 4.3.', __METHOD__), E_USER_DEPRECATED);
} }
$filename = 2 < \func_num_args() ? \func_get_arg(2) : ''; $filename = 2 < \func_num_args() ? func_get_arg(2) : '';
$tokenIterator = new \ArrayIterator($tokens); $tokenIterator = new \ArrayIterator($tokens);

View File

@ -80,7 +80,7 @@ switch ($vars['REQUEST_URI']) {
case '/post': case '/post':
$output = json_encode($_POST + ['REQUEST_METHOD' => $vars['REQUEST_METHOD']], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $output = json_encode($_POST + ['REQUEST_METHOD' => $vars['REQUEST_METHOD']], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
header('Content-Type: application/json', true); header('Content-Type: application/json', true);
header('Content-Length: '.\strlen($output)); header('Content-Length: '.strlen($output));
echo $output; echo $output;
exit; exit;