From 1564887547bae32a17080e3d2f658f6a2762790b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Aug 2021 16:46:41 +0200 Subject: [PATCH] Add return types - batch 1/n --- .../Cache/Adapter/AbstractAdapter.php | 4 +- .../Cache/Adapter/AbstractTagAwareAdapter.php | 2 +- .../Component/Cache/Adapter/ApcuAdapter.php | 10 +-- .../Component/Cache/Adapter/ChainAdapter.php | 2 +- .../Cache/Adapter/CouchbaseBucketAdapter.php | 4 +- .../Cache/Adapter/DoctrineAdapter.php | 10 +-- .../Adapter/FilesystemTagAwareAdapter.php | 2 +- .../Cache/Adapter/MemcachedAdapter.php | 14 ++--- .../Component/Cache/Adapter/PdoAdapter.php | 12 ++-- .../Cache/Adapter/PhpArrayAdapter.php | 4 +- .../Cache/Adapter/PhpFilesAdapter.php | 15 ++--- .../Component/Cache/Adapter/Psr16Adapter.php | 10 +-- .../Cache/Adapter/TagAwareAdapter.php | 5 +- .../Cache/Adapter/TraceableAdapter.php | 2 +- .../Cache/Marshaller/DefaultMarshaller.php | 2 +- .../Cache/Marshaller/DeflateMarshaller.php | 2 +- .../Cache/Marshaller/MarshallerInterface.php | 4 +- .../Cache/Marshaller/SodiumMarshaller.php | 2 +- .../Cache/Marshaller/TagAwareMarshaller.php | 2 +- .../Component/Cache/PruneableInterface.php | 5 +- .../Cache/Traits/AbstractAdapterTrait.php | 15 ++--- .../Cache/Traits/FilesystemCommonTrait.php | 9 +-- .../Cache/Traits/FilesystemTrait.php | 11 ++-- .../Component/Cache/Traits/ProxyTrait.php | 2 +- .../Component/Cache/Traits/RedisTrait.php | 14 ++--- .../ErrorHandler/BufferingLogger.php | 5 +- .../Exception/FlattenException.php | 35 +++++------ .../Filesystem/Exception/IOException.php | 2 +- .../Exception/IOExceptionInterface.php | 2 +- .../Component/Filesystem/Filesystem.php | 14 ++--- .../Component/HttpClient/HttpOptions.php | 56 ++++++++--------- .../Reader/BundleEntryReaderInterface.php | 2 +- .../Bundle/Reader/BundleReaderInterface.php | 2 +- .../Component/Intl/Util/IcuVersion.php | 4 +- src/Symfony/Component/Intl/Util/Version.php | 4 +- src/Symfony/Component/Lock/LockInterface.php | 8 +-- .../Lock/PersistingStoreInterface.php | 2 +- .../Component/Lock/SharedLockInterface.php | 2 +- .../Component/Lock/Store/CombinedStore.php | 2 +- .../Component/Lock/Store/FlockStore.php | 2 +- .../Component/Lock/Store/InMemoryStore.php | 2 +- .../Component/Lock/Store/MemcachedStore.php | 2 +- src/Symfony/Component/Lock/Store/PdoStore.php | 2 +- .../Component/Lock/Store/PostgreSqlStore.php | 2 +- .../Component/Lock/Store/RedisStore.php | 2 +- .../Component/Lock/Store/SemaphoreStore.php | 2 +- .../Component/Lock/Store/StoreFactory.php | 2 +- .../Lock/Strategy/ConsensusStrategy.php | 4 +- .../Lock/Strategy/StrategyInterface.php | 4 +- .../Lock/Strategy/UnanimousStrategy.php | 4 +- .../Component/Runtime/GenericRuntime.php | 2 +- .../Component/Runtime/SymfonyRuntime.php | 2 +- src/Symfony/Component/Stopwatch/Section.php | 20 +++--- src/Symfony/Component/Stopwatch/Stopwatch.php | 14 ++--- .../Component/Stopwatch/StopwatchEvent.php | 24 +++---- .../Component/Stopwatch/StopwatchPeriod.php | 8 +-- .../Component/String/AbstractString.php | 62 +++++++++---------- .../String/AbstractUnicodeString.php | 34 +++++----- src/Symfony/Component/String/ByteString.php | 40 ++++++------ .../Component/String/CodePointString.php | 10 +-- src/Symfony/Component/String/LazyString.php | 4 +- .../Component/String/UnicodeString.php | 16 ++--- .../VarDumper/Cloner/AbstractCloner.php | 8 +-- .../VarDumper/Cloner/ClonerInterface.php | 2 +- .../Component/VarDumper/Cloner/Data.php | 16 ++--- .../Component/VarDumper/Cloner/VarCloner.php | 2 +- .../VarDumper/Dumper/AbstractDumper.php | 8 +-- .../Component/VarDumper/Dumper/CliDumper.php | 4 +- .../Component/VarDumper/Dumper/HtmlDumper.php | 4 +- .../Component/WebLink/GenericLinkProvider.php | 4 +- src/Symfony/Component/WebLink/Link.php | 10 +-- .../Component/Workflow/DefinitionBuilder.php | 16 ++--- .../Workflow/Dumper/DumperInterface.php | 2 +- .../Workflow/Dumper/GraphvizDumper.php | 2 +- .../Dumper/StateMachineGraphvizDumper.php | 2 +- .../EventListener/AuditTrailListener.php | 2 +- .../MarkingStore/MarkingStoreInterface.php | 2 +- src/Symfony/Component/Workflow/Registry.php | 2 +- .../Component/Workflow/Tests/WorkflowTest.php | 11 ---- src/Symfony/Component/Workflow/Transition.php | 6 +- src/Symfony/Component/Workflow/Workflow.php | 14 ++--- .../Component/Workflow/WorkflowInterface.php | 14 ++--- .../Component/Yaml/Command/LintCommand.php | 2 +- .../Yaml/Exception/ParseException.php | 6 +- 84 files changed, 327 insertions(+), 380 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 6e09cdb96a5a7..c919e574308f7 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -98,10 +98,8 @@ static function ($deferred, $namespace, &$expiredIds, $getId, $defaultLifetime) * Returns the best possible adapter that your runtime supports. * * Using ApcuAdapter makes system caches compatible with read-only filesystems. - * - * @return AdapterInterface */ - public static function createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null) + public static function createSystemCache(string $namespace, int $defaultLifetime, string $version, string $directory, LoggerInterface $logger = null): AdapterInterface { $opcache = new PhpFilesAdapter($namespace, $defaultLifetime, $directory, true); if (null !== $logger) { diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index 42ae7a987a772..cbc0a458bd543 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -138,7 +138,7 @@ abstract protected function doSave(array $values, int $lifetime, array $addTagDa * * @return bool True if the items were successfully removed, false otherwise */ - abstract protected function doDelete(array $ids); + abstract protected function doDelete(array $ids): bool; /** * Removes relations between tags and deleted items. diff --git a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php index dc6279e8ba7dd..77e8a70cbcd48 100644 --- a/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ApcuAdapter.php @@ -55,7 +55,7 @@ public static function isSupported() /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { $unserializeCallbackHandler = ini_set('unserialize_callback_func', __CLASS__.'::handleUnserializeCallback'); try { @@ -77,7 +77,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { return apcu_exists($id); } @@ -85,7 +85,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { return isset($namespace[0]) && class_exists(\APCuIterator::class, false) && ('cli' !== \PHP_SAPI || filter_var(ini_get('apc.enable_cli'), \FILTER_VALIDATE_BOOLEAN)) ? apcu_delete(new \APCuIterator(sprintf('/^%s/', preg_quote($namespace, '/')), \APC_ITER_KEY)) @@ -95,7 +95,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { foreach ($ids as $id) { apcu_delete($id); @@ -107,7 +107,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { if (null !== $this->marshaller && (!$values = $this->marshaller->marshall($values, $failed))) { return $failed; diff --git a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php index f0782e3ea633d..925e9f2f6b5bc 100644 --- a/src/Symfony/Component/Cache/Adapter/ChainAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/ChainAdapter.php @@ -292,7 +292,7 @@ public function commit(): bool /** * {@inheritdoc} */ - public function prune() + public function prune(): bool { $pruned = true; diff --git a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php index 5cd25f422e541..82957a8ca24c0 100644 --- a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php @@ -161,7 +161,7 @@ private static function initOptions(array $options): array /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { $resultsCouchbase = $this->bucket->get($ids); @@ -218,7 +218,7 @@ protected function doDelete(array $ids): bool /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; diff --git a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php index 2bd8978401505..908498c59ae13 100644 --- a/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/DoctrineAdapter.php @@ -39,7 +39,7 @@ public function reset() /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { $unserializeCallbackHandler = ini_set('unserialize_callback_func', parent::class.'::handleUnserializeCallback'); try { @@ -65,7 +65,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { return $this->provider->contains($id); } @@ -73,7 +73,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { $namespace = $this->provider->getNamespace(); @@ -85,7 +85,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { $ok = true; foreach ($ids as $id) { @@ -98,7 +98,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { return $this->provider->saveMultiple($values, $lifetime); } diff --git a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php index c06557d323596..140c91f48ddea 100644 --- a/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/FilesystemTagAwareAdapter.php @@ -44,7 +44,7 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { $ok = $this->doClearCache($namespace); diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 0590af3c00461..2d484895a5324 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -92,11 +92,9 @@ public static function isSupported() * @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs * @param array $options An array of options * - * @return \Memcached - * * @throws \ErrorException When invalid options or servers are provided */ - public static function createConnection(array|string $servers, array $options = []) + public static function createConnection(array|string $servers, array $options = []): \Memcached { if (\is_string($servers)) { $servers = [$servers]; @@ -243,7 +241,7 @@ public static function createConnection(array|string $servers, array $options = /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; @@ -264,7 +262,7 @@ protected function doSave(array $values, int $lifetime) /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { try { $encodedIds = array_map('self::encodeKey', $ids); @@ -285,7 +283,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { return false !== $this->getClient()->get(self::encodeKey($id)) || $this->checkResultCode(\Memcached::RES_SUCCESS === $this->client->getResultCode()); } @@ -293,7 +291,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { $ok = true; $encodedIds = array_map('self::encodeKey', $ids); @@ -309,7 +307,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { return '' === $namespace && $this->getClient()->flush(); } diff --git a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php index 3bd4f7ea92c9a..dc64545d98f5b 100644 --- a/src/Symfony/Component/Cache/Adapter/PdoAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PdoAdapter.php @@ -181,7 +181,7 @@ public function configureSchema(Schema $schema, Connection $forConnection): void /** * {@inheritdoc} */ - public function prune() + public function prune(): bool { $deleteSql = "DELETE FROM $this->table WHERE $this->lifetimeCol + $this->timeCol <= :time"; @@ -213,7 +213,7 @@ public function prune() /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { $now = time(); $expired = []; @@ -257,7 +257,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND ($this->lifetimeCol IS NULL OR $this->lifetimeCol + $this->timeCol > :time)"; $stmt = $this->getConnection()->prepare($sql); @@ -272,7 +272,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { $conn = $this->getConnection(); @@ -302,7 +302,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { $sql = str_pad('', (\count($ids) << 1) - 1, '?,'); $sql = "DELETE FROM $this->table WHERE $this->idCol IN ($sql)"; @@ -319,7 +319,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; diff --git a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php index 1e5d1fc2eeec4..99a450b0db607 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php @@ -68,10 +68,8 @@ static function ($key, $value, $isHit) { * * @param string $file The PHP file were values are cached * @param CacheItemPoolInterface $fallbackPool A pool to fallback on when an item is not hit - * - * @return CacheItemPoolInterface */ - public static function create(string $file, CacheItemPoolInterface $fallbackPool) + public static function create(string $file, CacheItemPoolInterface $fallbackPool): CacheItemPoolInterface { if (!$fallbackPool instanceof AdapterInterface) { $fallbackPool = new ProxyAdapter($fallbackPool); diff --git a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php index 7e735f2837e25..8e5c34a2d102b 100644 --- a/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/PhpFilesAdapter.php @@ -61,10 +61,7 @@ public static function isSupported() return \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN)); } - /** - * @return bool - */ - public function prune() + public function prune(): bool { $time = time(); $pruned = true; @@ -95,7 +92,7 @@ public function prune() /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { if ($this->appendOnly) { $now = 0; @@ -171,7 +168,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { if ($this->appendOnly && isset($this->values[$id])) { return true; @@ -211,7 +208,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { $ok = true; $expiry = $lifetime ? time() + $lifetime : 'PHP_INT_MAX'; @@ -273,7 +270,7 @@ protected function doSave(array $values, int $lifetime) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { $this->values = []; @@ -283,7 +280,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { foreach ($ids as $id) { unset($this->values[$id]); diff --git a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php index f51604baa0d91..664c18bba4474 100644 --- a/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php +++ b/src/Symfony/Component/Cache/Adapter/Psr16Adapter.php @@ -43,7 +43,7 @@ public function __construct(CacheInterface $pool, string $namespace = '', int $d /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { foreach ($this->pool->getMultiple($ids, $this->miss) as $key => $value) { if ($this->miss !== $value) { @@ -55,7 +55,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { return $this->pool->has($id); } @@ -63,7 +63,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { return $this->pool->clear(); } @@ -71,7 +71,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { return $this->pool->deleteMultiple($ids); } @@ -79,7 +79,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { return $this->pool->setMultiple($values, 0 === $lifetime ? null : $lifetime); } diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 6966402bfc1d6..e21b1372aa29b 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -297,10 +297,7 @@ public function commit(): bool return $this->invalidateTags([]); } - /** - * @return array - */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php index ba69f68fb16b8..5e68907bfd8d7 100644 --- a/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TraceableAdapter.php @@ -212,7 +212,7 @@ public function commit(): bool /** * {@inheritdoc} */ - public function prune() + public function prune(): bool { if (!$this->pool instanceof PruneableInterface) { return false; diff --git a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php index a9630176592f8..4cd1a5f0e8d89 100644 --- a/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php @@ -57,7 +57,7 @@ public function marshall(array $values, ?array &$failed): array /** * {@inheritdoc} */ - public function unmarshall(string $value) + public function unmarshall(string $value): mixed { if ('b:0;' === $value) { return false; diff --git a/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php b/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php index 83cd148db3a4b..95e3d320694aa 100644 --- a/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/DeflateMarshaller.php @@ -42,7 +42,7 @@ public function marshall(array $values, ?array &$failed): array /** * {@inheritdoc} */ - public function unmarshall(string $value) + public function unmarshall(string $value): mixed { if (false !== $inflatedValue = @gzinflate($value)) { $value = $inflatedValue; diff --git a/src/Symfony/Component/Cache/Marshaller/MarshallerInterface.php b/src/Symfony/Component/Cache/Marshaller/MarshallerInterface.php index cdd6c4022ca4f..5b81aad2d8582 100644 --- a/src/Symfony/Component/Cache/Marshaller/MarshallerInterface.php +++ b/src/Symfony/Component/Cache/Marshaller/MarshallerInterface.php @@ -32,9 +32,7 @@ public function marshall(array $values, ?array &$failed): array; /** * Unserializes a single value and throws an exception if anything goes wrong. * - * @return mixed - * * @throws \Exception Whenever unserialization fails */ - public function unmarshall(string $value); + public function unmarshall(string $value): mixed; } diff --git a/src/Symfony/Component/Cache/Marshaller/SodiumMarshaller.php b/src/Symfony/Component/Cache/Marshaller/SodiumMarshaller.php index 8a317e33868ac..4d8a04ee6da45 100644 --- a/src/Symfony/Component/Cache/Marshaller/SodiumMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/SodiumMarshaller.php @@ -66,7 +66,7 @@ public function marshall(array $values, ?array &$failed): array /** * {@inheritdoc} */ - public function unmarshall(string $value) + public function unmarshall(string $value): mixed { foreach ($this->decryptionKeys as $k) { if (false !== $decryptedValue = @sodium_crypto_box_seal_open($value, $k)) { diff --git a/src/Symfony/Component/Cache/Marshaller/TagAwareMarshaller.php b/src/Symfony/Component/Cache/Marshaller/TagAwareMarshaller.php index 9db211cf60cc7..60961538584e2 100644 --- a/src/Symfony/Component/Cache/Marshaller/TagAwareMarshaller.php +++ b/src/Symfony/Component/Cache/Marshaller/TagAwareMarshaller.php @@ -67,7 +67,7 @@ public function marshall(array $values, ?array &$failed): array /** * {@inheritdoc} */ - public function unmarshall(string $value) + public function unmarshall(string $value): mixed { // detect the compact format used in marshall() using magic numbers in the form 9D-..-..-..-..-00-..-..-..-5F if (13 >= \strlen($value) || "\x9D" !== $value[0] || "\0" !== $value[5] || "\x5F" !== $value[9]) { diff --git a/src/Symfony/Component/Cache/PruneableInterface.php b/src/Symfony/Component/Cache/PruneableInterface.php index 42615253689fe..3095c80f40c85 100644 --- a/src/Symfony/Component/Cache/PruneableInterface.php +++ b/src/Symfony/Component/Cache/PruneableInterface.php @@ -16,8 +16,5 @@ */ interface PruneableInterface { - /** - * @return bool - */ - public function prune(); + public function prune(): bool; } diff --git a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php index 01dd5aaf998ee..ae029da5d47d1 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php @@ -54,7 +54,7 @@ trait AbstractAdapterTrait * * @return array|\Traversable The corresponding values found in the cache */ - abstract protected function doFetch(array $ids); + abstract protected function doFetch(array $ids): iterable; /** * Confirms if the cache contains specified cache item. @@ -63,7 +63,7 @@ abstract protected function doFetch(array $ids); * * @return bool True if item exists in the cache, false otherwise */ - abstract protected function doHave(string $id); + abstract protected function doHave(string $id): bool; /** * Deletes all items in the pool. @@ -72,7 +72,7 @@ abstract protected function doHave(string $id); * * @return bool True if the pool was successfully cleared, false otherwise */ - abstract protected function doClear(string $namespace); + abstract protected function doClear(string $namespace): bool; /** * Removes multiple items from the pool. @@ -81,7 +81,7 @@ abstract protected function doClear(string $namespace); * * @return bool True if the items were successfully removed, false otherwise */ - abstract protected function doDelete(array $ids); + abstract protected function doDelete(array $ids): bool; /** * Persists several cache items immediately. @@ -91,7 +91,7 @@ abstract protected function doDelete(array $ids); * * @return array|bool The identifiers that failed to be cached or a boolean stating if caching succeeded or not */ - abstract protected function doSave(array $values, int $lifetime); + abstract protected function doSave(array $values, int $lifetime): array|bool; /** * {@inheritdoc} @@ -303,10 +303,7 @@ public function reset() $this->ids = []; } - /** - * @return array - */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 50e6bdb647567..40d6f43a1aedd 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -53,7 +53,7 @@ private function init(string $namespace, ?string $directory) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { $ok = true; @@ -71,7 +71,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { $ok = true; @@ -171,10 +171,7 @@ public static function throwError(int $type, string $message, string $file, int throw new \ErrorException($message, 0, $type, $file, $line); } - /** - * @return array - */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php index 3c55234850c08..05ad8ed674a64 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemTrait.php @@ -26,10 +26,7 @@ trait FilesystemTrait private MarshallerInterface $marshaller; - /** - * @return bool - */ - public function prune() + public function prune(): bool { $time = time(); $pruned = true; @@ -53,7 +50,7 @@ public function prune() /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { $values = []; $now = time(); @@ -82,7 +79,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { $file = $this->getFile($id); @@ -92,7 +89,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { $expiresAt = $lifetime ? (time() + $lifetime) : 0; $values = $this->marshaller->marshall($values, $failed); diff --git a/src/Symfony/Component/Cache/Traits/ProxyTrait.php b/src/Symfony/Component/Cache/Traits/ProxyTrait.php index 8ca264ae0a964..ba6f8cba90e13 100644 --- a/src/Symfony/Component/Cache/Traits/ProxyTrait.php +++ b/src/Symfony/Component/Cache/Traits/ProxyTrait.php @@ -26,7 +26,7 @@ trait ProxyTrait /** * {@inheritdoc} */ - public function prune() + public function prune(): bool { return $this->pool instanceof PruneableInterface && $this->pool->prune(); } diff --git a/src/Symfony/Component/Cache/Traits/RedisTrait.php b/src/Symfony/Component/Cache/Traits/RedisTrait.php index 7a70095a6b59b..a928fafc1e2b1 100644 --- a/src/Symfony/Component/Cache/Traits/RedisTrait.php +++ b/src/Symfony/Component/Cache/Traits/RedisTrait.php @@ -77,11 +77,9 @@ private function init(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInterface|R * * @param array $options See self::$defaultConnectionOptions * - * @return \Redis|\RedisArray|\RedisCluster|RedisClusterProxy|RedisProxy|\Predis\ClientInterface According to the "class" option - * * @throws InvalidArgumentException when the DSN is invalid */ - public static function createConnection(string $dsn, array $options = []) + public static function createConnection(string $dsn, array $options = []): \Redis|\RedisArray|\RedisCluster|RedisClusterProxy|RedisProxy|\Predis\ClientInterface { if (str_starts_with($dsn, 'redis:')) { $scheme = 'redis'; @@ -320,7 +318,7 @@ public static function createConnection(string $dsn, array $options = []) /** * {@inheritdoc} */ - protected function doFetch(array $ids) + protected function doFetch(array $ids): iterable { if (!$ids) { return []; @@ -356,7 +354,7 @@ protected function doFetch(array $ids) /** * {@inheritdoc} */ - protected function doHave(string $id) + protected function doHave(string $id): bool { return (bool) $this->redis->exists($id); } @@ -364,7 +362,7 @@ protected function doHave(string $id) /** * {@inheritdoc} */ - protected function doClear(string $namespace) + protected function doClear(string $namespace): bool { if ($this->redis instanceof \Predis\ClientInterface) { $prefix = $this->redis->getOptions()->prefix ? $this->redis->getOptions()->prefix->getPrefix() : ''; @@ -428,7 +426,7 @@ protected function doClear(string $namespace) /** * {@inheritdoc} */ - protected function doDelete(array $ids) + protected function doDelete(array $ids): bool { if (!$ids) { return true; @@ -465,7 +463,7 @@ protected function doDelete(array $ids) /** * {@inheritdoc} */ - protected function doSave(array $values, int $lifetime) + protected function doSave(array $values, int $lifetime): array|bool { if (!$values = $this->marshaller->marshall($values, $failed)) { return $failed; diff --git a/src/Symfony/Component/ErrorHandler/BufferingLogger.php b/src/Symfony/Component/ErrorHandler/BufferingLogger.php index 8f9ae5025c0df..d1fd9ed29e4ee 100644 --- a/src/Symfony/Component/ErrorHandler/BufferingLogger.php +++ b/src/Symfony/Component/ErrorHandler/BufferingLogger.php @@ -35,10 +35,7 @@ public function cleanLogs(): array return $logs; } - /** - * @return array - */ - public function __sleep() + public function __sleep(): array { throw new \BadMethodCallException('Cannot serialize '.__CLASS__); } diff --git a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php index fc4abccdf8f48..6087c374b9fb7 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php @@ -60,18 +60,12 @@ class FlattenException /** @var string|null */ private $asString; - /** - * @return static - */ - public static function create(\Exception $exception, int $statusCode = null, array $headers = []): self + public static function create(\Exception $exception, int $statusCode = null, array $headers = []): static { return static::createFromThrowable($exception, $statusCode, $headers); } - /** - * @return static - */ - public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self + public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): static { $e = new static(); $e->setMessage($exception->getMessage()); @@ -133,7 +127,7 @@ public function getStatusCode(): int /** * @return $this */ - public function setStatusCode(int $code): self + public function setStatusCode(int $code): static { $this->statusCode = $code; @@ -148,7 +142,7 @@ public function getHeaders(): array /** * @return $this */ - public function setHeaders(array $headers): self + public function setHeaders(array $headers): static { $this->headers = $headers; @@ -163,7 +157,7 @@ public function getClass(): string /** * @return $this */ - public function setClass(string $class): self + public function setClass(string $class): static { $this->class = str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; @@ -178,7 +172,7 @@ public function getFile(): string /** * @return $this */ - public function setFile(string $file): self + public function setFile(string $file): static { $this->file = $file; @@ -193,7 +187,7 @@ public function getLine(): int /** * @return $this */ - public function setLine(int $line): self + public function setLine(int $line): static { $this->line = $line; @@ -220,7 +214,7 @@ public function getMessage(): string /** * @return $this */ - public function setMessage(string $message): self + public function setMessage(string $message): static { if (str_contains($message, "@anonymous\0")) { $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { @@ -236,7 +230,7 @@ public function setMessage(string $message): self /** * @return int|string int most of the time (might be a string with PDOException) */ - public function getCode() + public function getCode(): int|string { return $this->code; } @@ -244,7 +238,7 @@ public function getCode() /** * @return $this */ - public function setCode(int|string $code): self + public function setCode(int|string $code): static { $this->code = $code; @@ -259,7 +253,7 @@ public function getPrevious(): ?self /** * @return $this */ - public function setPrevious(self $previous): self + public function setPrevious(self $previous): static { $this->previous = $previous; @@ -288,7 +282,7 @@ public function getTrace(): array /** * @return $this */ - public function setTraceFromThrowable(\Throwable $throwable): self + public function setTraceFromThrowable(\Throwable $throwable): static { $this->traceAsString = $throwable->getTraceAsString(); @@ -296,10 +290,9 @@ public function setTraceFromThrowable(\Throwable $throwable): self } /** - * * @return $this */ - public function setTrace(array $trace, ?string $file, ?int $line): self + public function setTrace(array $trace, ?string $file, ?int $line): static { $this->trace = []; $this->trace[] = [ @@ -386,7 +379,7 @@ public function getTraceAsString(): string /** * @return $this */ - public function setAsString(?string $asString): self + public function setAsString(?string $asString): static { $this->asString = $asString; diff --git a/src/Symfony/Component/Filesystem/Exception/IOException.php b/src/Symfony/Component/Filesystem/Exception/IOException.php index 3043ee2cafee7..bcca860de498b 100644 --- a/src/Symfony/Component/Filesystem/Exception/IOException.php +++ b/src/Symfony/Component/Filesystem/Exception/IOException.php @@ -32,7 +32,7 @@ public function __construct(string $message, int $code = 0, \Throwable $previous /** * {@inheritdoc} */ - public function getPath() + public function getPath(): ?string { return $this->path; } diff --git a/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php b/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php index f9d4644a87279..6e5d006eea510 100644 --- a/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php +++ b/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php @@ -23,5 +23,5 @@ interface IOExceptionInterface extends ExceptionInterface * * @return string|null The path */ - public function getPath(); + public function getPath(): ?string; } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 7acf53073a6ab..a6014112da2c5 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -102,7 +102,7 @@ public function mkdir(string|iterable $dirs, int $mode = 0777) * * @return bool true if the file exists, false otherwise */ - public function exists(string|iterable $files) + public function exists(string|iterable $files): bool { $maxPathLength = \PHP_MAXPATHLEN - 2; @@ -399,10 +399,8 @@ private function linkException(string $origin, string $target, string $linkType) * With $canonicalize = true * - if $path does not exist, returns null * - if $path exists, returns its absolute fully resolved final version - * - * @return string|null */ - public function readlink(string $path, bool $canonicalize = false) + public function readlink(string $path, bool $canonicalize = false): ?string { if (!$canonicalize && !is_link($path)) { return null; @@ -424,7 +422,7 @@ public function readlink(string $path, bool $canonicalize = false) * * @return string Path of target relative to starting path */ - public function makePathRelative(string $endPath, string $startPath) + public function makePathRelative(string $endPath, string $startPath): string { if (!$this->isAbsolutePath($startPath)) { throw new InvalidArgumentException(sprintf('The start path "%s" is not absolute.', $startPath)); @@ -570,10 +568,8 @@ public function mirror(string $originDir, string $targetDir, \Traversable $itera /** * Returns whether the file path is an absolute path. - * - * @return bool */ - public function isAbsolutePath(string $file) + public function isAbsolutePath(string $file): bool { return '' !== $file && (strspn($file, '/\\', 0, 1) || (\strlen($file) > 3 && ctype_alpha($file[0]) @@ -593,7 +589,7 @@ public function isAbsolutePath(string $file) * * @return string The new temporary filename (with path), or throw an exception on failure */ - public function tempnam(string $dir, string $prefix/*, string $suffix = ''*/) + public function tempnam(string $dir, string $prefix/*, string $suffix = ''*/): string { $suffix = \func_num_args() > 2 ? func_get_arg(2) : ''; [$scheme, $hierarchy] = $this->getSchemeAndHierarchy($dir); diff --git a/src/Symfony/Component/HttpClient/HttpOptions.php b/src/Symfony/Component/HttpClient/HttpOptions.php index 2034a5f284d82..8a5b5b217dc31 100644 --- a/src/Symfony/Component/HttpClient/HttpOptions.php +++ b/src/Symfony/Component/HttpClient/HttpOptions.php @@ -32,7 +32,7 @@ public function toArray(): array /** * @return $this */ - public function setAuthBasic(string $user, string $password = '') + public function setAuthBasic(string $user, string $password = ''): static { $this->options['auth_basic'] = $user; @@ -46,7 +46,7 @@ public function setAuthBasic(string $user, string $password = '') /** * @return $this */ - public function setAuthBearer(string $token) + public function setAuthBearer(string $token): static { $this->options['auth_bearer'] = $token; @@ -56,7 +56,7 @@ public function setAuthBearer(string $token) /** * @return $this */ - public function setQuery(array $query) + public function setQuery(array $query): static { $this->options['query'] = $query; @@ -66,7 +66,7 @@ public function setQuery(array $query) /** * @return $this */ - public function setHeaders(iterable $headers) + public function setHeaders(iterable $headers): static { $this->options['headers'] = $headers; @@ -78,7 +78,7 @@ public function setHeaders(iterable $headers) * * @return $this */ - public function setBody(mixed $body) + public function setBody(mixed $body): static { $this->options['body'] = $body; @@ -88,7 +88,7 @@ public function setBody(mixed $body) /** * @return $this */ - public function setJson(mixed $json) + public function setJson(mixed $json): static { $this->options['json'] = $json; @@ -98,7 +98,7 @@ public function setJson(mixed $json) /** * @return $this */ - public function setUserData(mixed $data) + public function setUserData(mixed $data): static { $this->options['user_data'] = $data; @@ -108,7 +108,7 @@ public function setUserData(mixed $data) /** * @return $this */ - public function setMaxRedirects(int $max) + public function setMaxRedirects(int $max): static { $this->options['max_redirects'] = $max; @@ -118,7 +118,7 @@ public function setMaxRedirects(int $max) /** * @return $this */ - public function setHttpVersion(string $version) + public function setHttpVersion(string $version): static { $this->options['http_version'] = $version; @@ -128,7 +128,7 @@ public function setHttpVersion(string $version) /** * @return $this */ - public function setBaseUri(string $uri) + public function setBaseUri(string $uri): static { $this->options['base_uri'] = $uri; @@ -138,7 +138,7 @@ public function setBaseUri(string $uri) /** * @return $this */ - public function buffer(bool $buffer) + public function buffer(bool $buffer): static { $this->options['buffer'] = $buffer; @@ -148,7 +148,7 @@ public function buffer(bool $buffer) /** * @return $this */ - public function setOnProgress(callable $callback) + public function setOnProgress(callable $callback): static { $this->options['on_progress'] = $callback; @@ -158,7 +158,7 @@ public function setOnProgress(callable $callback) /** * @return $this */ - public function resolve(array $hostIps) + public function resolve(array $hostIps): static { $this->options['resolve'] = $hostIps; @@ -168,7 +168,7 @@ public function resolve(array $hostIps) /** * @return $this */ - public function setProxy(string $proxy) + public function setProxy(string $proxy): static { $this->options['proxy'] = $proxy; @@ -178,7 +178,7 @@ public function setProxy(string $proxy) /** * @return $this */ - public function setNoProxy(string $noProxy) + public function setNoProxy(string $noProxy): static { $this->options['no_proxy'] = $noProxy; @@ -188,7 +188,7 @@ public function setNoProxy(string $noProxy) /** * @return $this */ - public function setTimeout(float $timeout) + public function setTimeout(float $timeout): static { $this->options['timeout'] = $timeout; @@ -198,7 +198,7 @@ public function setTimeout(float $timeout) /** * @return $this */ - public function bindTo(string $bindto) + public function bindTo(string $bindto): static { $this->options['bindto'] = $bindto; @@ -208,7 +208,7 @@ public function bindTo(string $bindto) /** * @return $this */ - public function verifyPeer(bool $verify) + public function verifyPeer(bool $verify): static { $this->options['verify_peer'] = $verify; @@ -218,7 +218,7 @@ public function verifyPeer(bool $verify) /** * @return $this */ - public function verifyHost(bool $verify) + public function verifyHost(bool $verify): static { $this->options['verify_host'] = $verify; @@ -228,7 +228,7 @@ public function verifyHost(bool $verify) /** * @return $this */ - public function setCaFile(string $cafile) + public function setCaFile(string $cafile): static { $this->options['cafile'] = $cafile; @@ -238,7 +238,7 @@ public function setCaFile(string $cafile) /** * @return $this */ - public function setCaPath(string $capath) + public function setCaPath(string $capath): static { $this->options['capath'] = $capath; @@ -248,7 +248,7 @@ public function setCaPath(string $capath) /** * @return $this */ - public function setLocalCert(string $cert) + public function setLocalCert(string $cert): static { $this->options['local_cert'] = $cert; @@ -258,7 +258,7 @@ public function setLocalCert(string $cert) /** * @return $this */ - public function setLocalPk(string $pk) + public function setLocalPk(string $pk): static { $this->options['local_pk'] = $pk; @@ -268,7 +268,7 @@ public function setLocalPk(string $pk) /** * @return $this */ - public function setPassphrase(string $passphrase) + public function setPassphrase(string $passphrase): static { $this->options['passphrase'] = $passphrase; @@ -278,7 +278,7 @@ public function setPassphrase(string $passphrase) /** * @return $this */ - public function setCiphers(string $ciphers) + public function setCiphers(string $ciphers): static { $this->options['ciphers'] = $ciphers; @@ -288,7 +288,7 @@ public function setCiphers(string $ciphers) /** * @return $this */ - public function setPeerFingerprint(string|array $fingerprint) + public function setPeerFingerprint(string|array $fingerprint): static { $this->options['peer_fingerprint'] = $fingerprint; @@ -298,7 +298,7 @@ public function setPeerFingerprint(string|array $fingerprint) /** * @return $this */ - public function capturePeerCertChain(bool $capture) + public function capturePeerCertChain(bool $capture): static { $this->options['capture_peer_cert_chain'] = $capture; @@ -308,7 +308,7 @@ public function capturePeerCertChain(bool $capture) /** * @return $this */ - public function setExtra(string $name, mixed $value) + public function setExtra(string $name, mixed $value): static { $this->options['extra'][$name] = $value; diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php index c4a0f565aa808..8858bf7f808c3 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php @@ -50,5 +50,5 @@ interface BundleEntryReaderInterface extends BundleReaderInterface * * @throws MissingResourceException If the indices cannot be accessed */ - public function readEntry(string $path, string $locale, array $indices, bool $fallback = true); + public function readEntry(string $path, string $locale, array $indices, bool $fallback = true): mixed; } diff --git a/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php b/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php index 545be464c88f8..737b44d9df1d0 100644 --- a/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php +++ b/src/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php @@ -24,5 +24,5 @@ interface BundleReaderInterface * @return mixed returns an array or {@link \ArrayAccess} instance for * complex data, a scalar value otherwise */ - public function read(string $path, string $locale); + public function read(string $path, string $locale): mixed; } diff --git a/src/Symfony/Component/Intl/Util/IcuVersion.php b/src/Symfony/Component/Intl/Util/IcuVersion.php index 3b1d7486e8fcb..5ad76544a585a 100644 --- a/src/Symfony/Component/Intl/Util/IcuVersion.php +++ b/src/Symfony/Component/Intl/Util/IcuVersion.php @@ -50,7 +50,7 @@ class IcuVersion * * @see normalize() */ - public static function compare(string $version1, string $version2, string $operator, int $precision = null) + public static function compare(string $version1, string $version2, string $operator, int $precision = null): bool { $version1 = self::normalize($version1, $precision); $version2 = self::normalize($version2, $precision); @@ -83,7 +83,7 @@ public static function compare(string $version1, string $version2, string $opera * @return string|null the normalized ICU version or NULL if it couldn't be * normalized */ - public static function normalize(string $version, ?int $precision) + public static function normalize(string $version, ?int $precision): ?string { $version = preg_replace('/^(\d)\.(\d)/', '$1$2', $version); diff --git a/src/Symfony/Component/Intl/Util/Version.php b/src/Symfony/Component/Intl/Util/Version.php index 4b74e09022db3..f045853a5323b 100644 --- a/src/Symfony/Component/Intl/Util/Version.php +++ b/src/Symfony/Component/Intl/Util/Version.php @@ -40,7 +40,7 @@ class Version * * @see normalize() */ - public static function compare(string $version1, string $version2, string $operator, int $precision = null) + public static function compare(string $version1, string $version2, string $operator, int $precision = null): bool { $version1 = self::normalize($version1, $precision); $version2 = self::normalize($version2, $precision); @@ -66,7 +66,7 @@ public static function compare(string $version1, string $version2, string $opera * @return string|null the normalized version or NULL if it couldn't be * normalized */ - public static function normalize(string $version, ?int $precision) + public static function normalize(string $version, ?int $precision): ?string { if (null === $precision) { return $version; diff --git a/src/Symfony/Component/Lock/LockInterface.php b/src/Symfony/Component/Lock/LockInterface.php index 40b75244b31ed..383469e732438 100644 --- a/src/Symfony/Component/Lock/LockInterface.php +++ b/src/Symfony/Component/Lock/LockInterface.php @@ -31,7 +31,7 @@ interface LockInterface * @throws LockConflictedException If the lock is acquired by someone else in blocking mode * @throws LockAcquiringException If the lock can not be acquired */ - public function acquire(bool $blocking = false); + public function acquire(bool $blocking = false): bool; /** * Increase the duration of an acquired lock. @@ -48,7 +48,7 @@ public function refresh(float $ttl = null); * * @return bool */ - public function isAcquired(); + public function isAcquired(): bool; /** * Release the lock. @@ -60,12 +60,12 @@ public function release(); /** * @return bool */ - public function isExpired(); + public function isExpired(): bool; /** * Returns the remaining lifetime. * * @return float|null Remaining lifetime in seconds. Null when the lock won't expire. */ - public function getRemainingLifetime(); + public function getRemainingLifetime(): ?float; } diff --git a/src/Symfony/Component/Lock/PersistingStoreInterface.php b/src/Symfony/Component/Lock/PersistingStoreInterface.php index 03309a90b5662..50a5ee0e23298 100644 --- a/src/Symfony/Component/Lock/PersistingStoreInterface.php +++ b/src/Symfony/Component/Lock/PersistingStoreInterface.php @@ -40,7 +40,7 @@ public function delete(Key $key); * * @return bool */ - public function exists(Key $key); + public function exists(Key $key): bool; /** * Extends the TTL of a resource. diff --git a/src/Symfony/Component/Lock/SharedLockInterface.php b/src/Symfony/Component/Lock/SharedLockInterface.php index 62cedc5cd014a..38d1cf07fcb28 100644 --- a/src/Symfony/Component/Lock/SharedLockInterface.php +++ b/src/Symfony/Component/Lock/SharedLockInterface.php @@ -30,5 +30,5 @@ interface SharedLockInterface extends LockInterface * @throws LockConflictedException If the lock is acquired by someone else in blocking mode * @throws LockAcquiringException If the lock can not be acquired */ - public function acquireRead(bool $blocking = false); + public function acquireRead(bool $blocking = false): bool; } diff --git a/src/Symfony/Component/Lock/Store/CombinedStore.php b/src/Symfony/Component/Lock/Store/CombinedStore.php index 8d0526b088466..0ca6707067ef5 100644 --- a/src/Symfony/Component/Lock/Store/CombinedStore.php +++ b/src/Symfony/Component/Lock/Store/CombinedStore.php @@ -192,7 +192,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { $successCount = 0; $failureCount = 0; diff --git a/src/Symfony/Component/Lock/Store/FlockStore.php b/src/Symfony/Component/Lock/Store/FlockStore.php index a5c24183b7aa1..724ec44c9c25f 100644 --- a/src/Symfony/Component/Lock/Store/FlockStore.php +++ b/src/Symfony/Component/Lock/Store/FlockStore.php @@ -161,7 +161,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { return $key->hasState(__CLASS__); } diff --git a/src/Symfony/Component/Lock/Store/InMemoryStore.php b/src/Symfony/Component/Lock/Store/InMemoryStore.php index 8b1dc1c7ce493..6842abea76aa3 100644 --- a/src/Symfony/Component/Lock/Store/InMemoryStore.php +++ b/src/Symfony/Component/Lock/Store/InMemoryStore.php @@ -94,7 +94,7 @@ public function delete(Key $key) } } - public function exists(Key $key) + public function exists(Key $key): bool { $hashKey = (string) $key; $token = $this->getUniqueToken($key); diff --git a/src/Symfony/Component/Lock/Store/MemcachedStore.php b/src/Symfony/Component/Lock/Store/MemcachedStore.php index e844a35bb6cfc..6f37ab1c4e16c 100644 --- a/src/Symfony/Component/Lock/Store/MemcachedStore.php +++ b/src/Symfony/Component/Lock/Store/MemcachedStore.php @@ -134,7 +134,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { return $this->memcached->get((string) $key) === $this->getUniqueToken($key); } diff --git a/src/Symfony/Component/Lock/Store/PdoStore.php b/src/Symfony/Component/Lock/Store/PdoStore.php index f938e1e808f2c..4550144051848 100644 --- a/src/Symfony/Component/Lock/Store/PdoStore.php +++ b/src/Symfony/Component/Lock/Store/PdoStore.php @@ -200,7 +200,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { $sql = "SELECT 1 FROM $this->table WHERE $this->idCol = :id AND $this->tokenCol = :token AND $this->expirationCol > {$this->getCurrentTimestampStatement()}"; $stmt = $this->getConnection()->prepare($sql); diff --git a/src/Symfony/Component/Lock/Store/PostgreSqlStore.php b/src/Symfony/Component/Lock/Store/PostgreSqlStore.php index 8db769873a196..575d574bda82e 100644 --- a/src/Symfony/Component/Lock/Store/PostgreSqlStore.php +++ b/src/Symfony/Component/Lock/Store/PostgreSqlStore.php @@ -148,7 +148,7 @@ public function delete(Key $key) $store->delete($key); } - public function exists(Key $key) + public function exists(Key $key): bool { $sql = "SELECT count(*) FROM pg_locks WHERE locktype='advisory' AND objid=:key AND pid=pg_backend_pid()"; $stmt = $this->getConnection()->prepare($sql); diff --git a/src/Symfony/Component/Lock/Store/RedisStore.php b/src/Symfony/Component/Lock/Store/RedisStore.php index 5f596fac09741..633ab1f21a6c2 100644 --- a/src/Symfony/Component/Lock/Store/RedisStore.php +++ b/src/Symfony/Component/Lock/Store/RedisStore.php @@ -218,7 +218,7 @@ public function delete(Key $key) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { $script = ' local key = KEYS[1] diff --git a/src/Symfony/Component/Lock/Store/SemaphoreStore.php b/src/Symfony/Component/Lock/Store/SemaphoreStore.php index 88c7a22174c57..7b8caf3a7910c 100644 --- a/src/Symfony/Component/Lock/Store/SemaphoreStore.php +++ b/src/Symfony/Component/Lock/Store/SemaphoreStore.php @@ -107,7 +107,7 @@ public function putOffExpiration(Key $key, float $ttl) /** * {@inheritdoc} */ - public function exists(Key $key) + public function exists(Key $key): bool { return $key->hasState(__CLASS__); } diff --git a/src/Symfony/Component/Lock/Store/StoreFactory.php b/src/Symfony/Component/Lock/Store/StoreFactory.php index 57e88daa8df7d..545800944842e 100644 --- a/src/Symfony/Component/Lock/Store/StoreFactory.php +++ b/src/Symfony/Component/Lock/Store/StoreFactory.php @@ -28,7 +28,7 @@ class StoreFactory /** * @return PersistingStoreInterface */ - public static function createStore(object|string $connection) + public static function createStore(object|string $connection): PersistingStoreInterface { switch (true) { case $connection instanceof \Redis: diff --git a/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php b/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php index 1338b10dd63f4..7c3508aa999d7 100644 --- a/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php +++ b/src/Symfony/Component/Lock/Strategy/ConsensusStrategy.php @@ -21,7 +21,7 @@ class ConsensusStrategy implements StrategyInterface /** * {@inheritdoc} */ - public function isMet(int $numberOfSuccess, int $numberOfItems) + public function isMet(int $numberOfSuccess, int $numberOfItems): bool { return $numberOfSuccess > ($numberOfItems / 2); } @@ -29,7 +29,7 @@ public function isMet(int $numberOfSuccess, int $numberOfItems) /** * {@inheritdoc} */ - public function canBeMet(int $numberOfFailure, int $numberOfItems) + public function canBeMet(int $numberOfFailure, int $numberOfItems): bool { return $numberOfFailure < ($numberOfItems / 2); } diff --git a/src/Symfony/Component/Lock/Strategy/StrategyInterface.php b/src/Symfony/Component/Lock/Strategy/StrategyInterface.php index 7c5f9d8cdfc7a..be3aeeba3c758 100644 --- a/src/Symfony/Component/Lock/Strategy/StrategyInterface.php +++ b/src/Symfony/Component/Lock/Strategy/StrategyInterface.php @@ -23,7 +23,7 @@ interface StrategyInterface * * @return bool */ - public function isMet(int $numberOfSuccess, int $numberOfItems); + public function isMet(int $numberOfSuccess, int $numberOfItems): bool; /** * Returns whether or not the quorum *could* be met. @@ -33,5 +33,5 @@ public function isMet(int $numberOfSuccess, int $numberOfItems); * * @return bool */ - public function canBeMet(int $numberOfFailure, int $numberOfItems); + public function canBeMet(int $numberOfFailure, int $numberOfItems): bool; } diff --git a/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php b/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php index 63f9d1b4a1b2a..2a2c4ab014fb8 100644 --- a/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php +++ b/src/Symfony/Component/Lock/Strategy/UnanimousStrategy.php @@ -21,7 +21,7 @@ class UnanimousStrategy implements StrategyInterface /** * {@inheritdoc} */ - public function isMet(int $numberOfSuccess, int $numberOfItems) + public function isMet(int $numberOfSuccess, int $numberOfItems): bool { return $numberOfSuccess === $numberOfItems; } @@ -29,7 +29,7 @@ public function isMet(int $numberOfSuccess, int $numberOfItems) /** * {@inheritdoc} */ - public function canBeMet(int $numberOfFailure, int $numberOfItems) + public function canBeMet(int $numberOfFailure, int $numberOfItems): bool { return 0 === $numberOfFailure; } diff --git a/src/Symfony/Component/Runtime/GenericRuntime.php b/src/Symfony/Component/Runtime/GenericRuntime.php index e9484f755e3c6..dbfd1e23b0e1a 100644 --- a/src/Symfony/Component/Runtime/GenericRuntime.php +++ b/src/Symfony/Component/Runtime/GenericRuntime.php @@ -147,7 +147,7 @@ public function getRunner(?object $application): RunnerInterface /** * @return mixed */ - protected function getArgument(\ReflectionParameter $parameter, ?string $type) + protected function getArgument(\ReflectionParameter $parameter, ?string $type): mixed { if ('array' === $type) { switch ($parameter->name) { diff --git a/src/Symfony/Component/Runtime/SymfonyRuntime.php b/src/Symfony/Component/Runtime/SymfonyRuntime.php index 9df2f5ca4b7b3..a6c576d495c1c 100644 --- a/src/Symfony/Component/Runtime/SymfonyRuntime.php +++ b/src/Symfony/Component/Runtime/SymfonyRuntime.php @@ -158,7 +158,7 @@ public function getRunner(?object $application): RunnerInterface /** * @return mixed */ - protected function getArgument(\ReflectionParameter $parameter, ?string $type) + protected function getArgument(\ReflectionParameter $parameter, ?string $type): mixed { switch ($type) { case Request::class: diff --git a/src/Symfony/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index b3ab3a1b2769c..e25eb1abe41ca 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -47,7 +47,7 @@ public function __construct(float $origin = null, bool $morePrecision = false) * * @return self|null The child section or null when none found */ - public function get(string $id) + public function get(string $id): ?self { foreach ($this->children as $child) { if ($id === $child->getId()) { @@ -65,7 +65,7 @@ public function get(string $id) * * @return self */ - public function open(?string $id) + public function open(?string $id): self { if (null === $id || null === $session = $this->get($id)) { $session = $this->children[] = new self(microtime(true) * 1000, $this->morePrecision); @@ -77,7 +77,7 @@ public function open(?string $id) /** * @return string|null The identifier of the section */ - public function getId() + public function getId(): ?string { return $this->id; } @@ -87,7 +87,7 @@ public function getId() * * @return $this */ - public function setId(string $id) + public function setId(string $id): static { $this->id = $id; @@ -99,7 +99,7 @@ public function setId(string $id) * * @return StopwatchEvent The event */ - public function startEvent(string $name, ?string $category) + public function startEvent(string $name, ?string $category): StopwatchEvent { if (!isset($this->events[$name])) { $this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category, $this->morePrecision, $name); @@ -113,7 +113,7 @@ public function startEvent(string $name, ?string $category) * * @return bool */ - public function isEventStarted(string $name) + public function isEventStarted(string $name): bool { return isset($this->events[$name]) && $this->events[$name]->isStarted(); } @@ -125,7 +125,7 @@ public function isEventStarted(string $name) * * @throws \LogicException When the event has not been started */ - public function stopEvent(string $name) + public function stopEvent(string $name): StopwatchEvent { if (!isset($this->events[$name])) { throw new \LogicException(sprintf('Event "%s" is not started.', $name)); @@ -141,7 +141,7 @@ public function stopEvent(string $name) * * @throws \LogicException When the event has not been started */ - public function lap(string $name) + public function lap(string $name): StopwatchEvent { return $this->stopEvent($name)->start(); } @@ -153,7 +153,7 @@ public function lap(string $name) * * @throws \LogicException When the event is not known */ - public function getEvent(string $name) + public function getEvent(string $name): StopwatchEvent { if (!isset($this->events[$name])) { throw new \LogicException(sprintf('Event "%s" is not known.', $name)); @@ -167,7 +167,7 @@ public function getEvent(string $name) * * @return StopwatchEvent[] */ - public function getEvents() + public function getEvents(): array { return $this->events; } diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index d42e5bce3a82e..89b6a941926fe 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -47,7 +47,7 @@ public function __construct(bool $morePrecision = false) /** * @return Section[] */ - public function getSections() + public function getSections(): array { return $this->sections; } @@ -98,7 +98,7 @@ public function stopSection(string $id) * * @return StopwatchEvent */ - public function start(string $name, string $category = null) + public function start(string $name, string $category = null): StopwatchEvent { return end($this->activeSections)->startEvent($name, $category); } @@ -108,7 +108,7 @@ public function start(string $name, string $category = null) * * @return bool */ - public function isStarted(string $name) + public function isStarted(string $name): bool { return end($this->activeSections)->isEventStarted($name); } @@ -118,7 +118,7 @@ public function isStarted(string $name) * * @return StopwatchEvent */ - public function stop(string $name) + public function stop(string $name): StopwatchEvent { return end($this->activeSections)->stopEvent($name); } @@ -128,7 +128,7 @@ public function stop(string $name) * * @return StopwatchEvent */ - public function lap(string $name) + public function lap(string $name): StopwatchEvent { return end($this->activeSections)->stopEvent($name)->start(); } @@ -138,7 +138,7 @@ public function lap(string $name) * * @return StopwatchEvent */ - public function getEvent(string $name) + public function getEvent(string $name): StopwatchEvent { return end($this->activeSections)->getEvent($name); } @@ -148,7 +148,7 @@ public function getEvent(string $name) * * @return StopwatchEvent[] */ - public function getSectionEvents(string $id) + public function getSectionEvents(string $id): array { return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : []; } diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index 81985bb78cf37..e512a94329b16 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -55,7 +55,7 @@ public function __construct(float $origin, string $category = null, bool $morePr * * @return string The category */ - public function getCategory() + public function getCategory(): string { return $this->category; } @@ -65,7 +65,7 @@ public function getCategory() * * @return float The origin in milliseconds */ - public function getOrigin() + public function getOrigin(): float { return $this->origin; } @@ -75,7 +75,7 @@ public function getOrigin() * * @return $this */ - public function start() + public function start(): static { $this->started[] = $this->getNow(); @@ -89,7 +89,7 @@ public function start() * * @throws \LogicException When stop() is called without a matching call to start() */ - public function stop() + public function stop(): static { if (!\count($this->started)) { throw new \LogicException('stop() called but start() has not been called before.'); @@ -105,7 +105,7 @@ public function stop() * * @return bool */ - public function isStarted() + public function isStarted(): bool { return !empty($this->started); } @@ -115,7 +115,7 @@ public function isStarted() * * @return $this */ - public function lap() + public function lap(): static { return $this->stop()->start(); } @@ -135,7 +135,7 @@ public function ensureStopped() * * @return StopwatchPeriod[] */ - public function getPeriods() + public function getPeriods(): array { return $this->periods; } @@ -145,7 +145,7 @@ public function getPeriods() * * @return int|float The time (in milliseconds) */ - public function getStartTime() + public function getStartTime(): int|float { if (isset($this->periods[0])) { return $this->periods[0]->getStartTime(); @@ -163,7 +163,7 @@ public function getStartTime() * * @return int|float The time (in milliseconds) */ - public function getEndTime() + public function getEndTime(): int|float { $count = \count($this->periods); @@ -175,7 +175,7 @@ public function getEndTime() * * @return int|float The duration (in milliseconds) */ - public function getDuration() + public function getDuration(): int|float { $periods = $this->periods; $left = \count($this->started); @@ -197,7 +197,7 @@ public function getDuration() * * @return int The memory usage (in bytes) */ - public function getMemory() + public function getMemory(): int { $memory = 0; foreach ($this->periods as $period) { @@ -214,7 +214,7 @@ public function getMemory() * * @return float Time in ms */ - protected function getNow() + protected function getNow(): float { return $this->formatTime(microtime(true) * 1000 - $this->origin); } diff --git a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php index adf4da977e6ad..b2492f94109f5 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php +++ b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php @@ -39,7 +39,7 @@ public function __construct(int|float $start, int|float $end, bool $morePrecisio * * @return int|float The time (in milliseconds) */ - public function getStartTime() + public function getStartTime(): int|float { return $this->start; } @@ -49,7 +49,7 @@ public function getStartTime() * * @return int|float The time (in milliseconds) */ - public function getEndTime() + public function getEndTime(): int|float { return $this->end; } @@ -59,7 +59,7 @@ public function getEndTime() * * @return int|float The period duration (in milliseconds) */ - public function getDuration() + public function getDuration(): int|float { return $this->end - $this->start; } @@ -69,7 +69,7 @@ public function getDuration() * * @return int The memory usage (in bytes) */ - public function getMemory() + public function getMemory(): int { return $this->memory; } diff --git a/src/Symfony/Component/String/AbstractString.php b/src/Symfony/Component/String/AbstractString.php index 62a4f89200c63..71a981e7d466e 100644 --- a/src/Symfony/Component/String/AbstractString.php +++ b/src/Symfony/Component/String/AbstractString.php @@ -95,7 +95,7 @@ public static function wrap(array $values): array * * @return static */ - public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self + public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static { $str = clone $this; $i = \PHP_INT_MAX; @@ -130,7 +130,7 @@ public function after(string|iterable $needle, bool $includeNeedle = false, int * * @return static */ - public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self + public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static { $str = clone $this; $i = null; @@ -163,14 +163,14 @@ public function afterLast(string|iterable $needle, bool $includeNeedle = false, /** * @return static */ - abstract public function append(string ...$suffix): self; + abstract public function append(string ...$suffix): static; /** * @param string|string[] $needle * * @return static */ - public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self + public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static { $str = clone $this; $i = \PHP_INT_MAX; @@ -205,7 +205,7 @@ public function before(string|iterable $needle, bool $includeNeedle = false, int * * @return static */ - public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): self + public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static { $str = clone $this; $i = null; @@ -248,7 +248,7 @@ public function bytesAt(int $offset): array /** * @return static */ - abstract public function camel(): self; + abstract public function camel(): static; /** * @return static[] @@ -258,7 +258,7 @@ abstract public function chunk(int $length = 1): array; /** * @return static */ - public function collapseWhitespace(): self + public function collapseWhitespace(): static { $str = clone $this; $str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string)); @@ -295,7 +295,7 @@ public function endsWith(string|iterable $suffix): bool /** * @return static */ - public function ensureEnd(string $suffix): self + public function ensureEnd(string $suffix): static { if (!$this->endsWith($suffix)) { return $this->append($suffix); @@ -310,7 +310,7 @@ public function ensureEnd(string $suffix): self /** * @return static */ - public function ensureStart(string $prefix): self + public function ensureStart(string $prefix): static { $prefix = new static($prefix); @@ -350,12 +350,12 @@ public function equalsTo(string|iterable $string): bool /** * @return static */ - abstract public function folded(): self; + abstract public function folded(): static; /** * @return static */ - public function ignoreCase(): self + public function ignoreCase(): static { $str = clone $this; $str->ignoreCase = true; @@ -415,7 +415,7 @@ public function isEmpty(): bool /** * @return static */ - abstract public function join(array $strings, string $lastGlue = null): self; + abstract public function join(array $strings, string $lastGlue = null): static; public function jsonSerialize(): string { @@ -427,7 +427,7 @@ abstract public function length(): int; /** * @return static */ - abstract public function lower(): self; + abstract public function lower(): static; /** * Matches the string using a regular expression. @@ -441,27 +441,27 @@ abstract public function match(string $regexp, int $flags = 0, int $offset = 0): /** * @return static */ - abstract public function padBoth(int $length, string $padStr = ' '): self; + abstract public function padBoth(int $length, string $padStr = ' '): static; /** * @return static */ - abstract public function padEnd(int $length, string $padStr = ' '): self; + abstract public function padEnd(int $length, string $padStr = ' '): static; /** * @return static */ - abstract public function padStart(int $length, string $padStr = ' '): self; + abstract public function padStart(int $length, string $padStr = ' '): static; /** * @return static */ - abstract public function prepend(string ...$prefix): self; + abstract public function prepend(string ...$prefix): static; /** * @return static */ - public function repeat(int $multiplier): self + public function repeat(int $multiplier): static { if (0 > $multiplier) { throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier)); @@ -476,34 +476,34 @@ public function repeat(int $multiplier): self /** * @return static */ - abstract public function replace(string $from, string $to): self; + abstract public function replace(string $from, string $to): static; /** * @param string|callable $to * * @return static */ - abstract public function replaceMatches(string $fromRegexp, string|callable $to): self; + abstract public function replaceMatches(string $fromRegexp, string|callable $to): static; /** * @return static */ - abstract public function reverse(): self; + abstract public function reverse(): static; /** * @return static */ - abstract public function slice(int $start = 0, int $length = null): self; + abstract public function slice(int $start = 0, int $length = null): static; /** * @return static */ - abstract public function snake(): self; + abstract public function snake(): static; /** * @return static */ - abstract public function splice(string $replacement, int $start = 0, int $length = null): self; + abstract public function splice(string $replacement, int $start = 0, int $length = null): static; /** * @return static[] @@ -574,7 +574,7 @@ public function startsWith(string|iterable $prefix): bool /** * @return static */ - abstract public function title(bool $allWords = false): self; + abstract public function title(bool $allWords = false): static; public function toByteString(string $toEncoding = null): ByteString { @@ -625,22 +625,22 @@ public function toUnicodeString(): UnicodeString /** * @return static */ - abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self; + abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static; /** * @return static */ - abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self; + abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static; /** * @return static */ - abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self; + abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static; /** * @return static */ - public function truncate(int $length, string $ellipsis = '', bool $cut = true): self + public function truncate(int $length, string $ellipsis = '', bool $cut = true): static { $stringLength = $this->length(); @@ -670,7 +670,7 @@ public function truncate(int $length, string $ellipsis = '', bool $cut = true): /** * @return static */ - abstract public function upper(): self; + abstract public function upper(): static; /** * Returns the printable length on a terminal. @@ -680,7 +680,7 @@ abstract public function width(bool $ignoreAnsiDecoration = true): int; /** * @return static */ - public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self + public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): static { $lines = '' !== $break ? $this->split($break) : [clone $this]; $chars = []; diff --git a/src/Symfony/Component/String/AbstractUnicodeString.php b/src/Symfony/Component/String/AbstractUnicodeString.php index ecb53481b4e35..dc85c67ce2eae 100644 --- a/src/Symfony/Component/String/AbstractUnicodeString.php +++ b/src/Symfony/Component/String/AbstractUnicodeString.php @@ -53,7 +53,7 @@ abstract class AbstractUnicodeString extends AbstractString /** * @return static */ - public static function fromCodePoints(int ...$codes): self + public static function fromCodePoints(int ...$codes): static { $string = ''; @@ -157,7 +157,7 @@ public function ascii(array $rules = []): self return $str; } - public function camel(): parent + public function camel(): static { $str = clone $this; $str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) { @@ -187,7 +187,7 @@ public function codePointsAt(int $offset): array return $codePoints; } - public function folded(bool $compat = true): parent + public function folded(bool $compat = true): static { $str = clone $this; @@ -201,7 +201,7 @@ public function folded(bool $compat = true): parent return $str; } - public function join(array $strings, string $lastGlue = null): parent + public function join(array $strings, string $lastGlue = null): static { $str = clone $this; @@ -215,7 +215,7 @@ public function join(array $strings, string $lastGlue = null): parent return $str; } - public function lower(): parent + public function lower(): static { $str = clone $this; $str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8'); @@ -255,7 +255,7 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array /** * @return static */ - public function normalize(int $form = self::NFC): self + public function normalize(int $form = self::NFC): static { if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) { throw new InvalidArgumentException('Unsupported normalization form.'); @@ -267,7 +267,7 @@ public function normalize(int $form = self::NFC): self return $str; } - public function padBoth(int $length, string $padStr = ' '): parent + public function padBoth(int $length, string $padStr = ' '): static { if ('' === $padStr || !preg_match('//u', $padStr)) { throw new InvalidArgumentException('Invalid UTF-8 string.'); @@ -279,7 +279,7 @@ public function padBoth(int $length, string $padStr = ' '): parent return $this->pad($length, $pad, \STR_PAD_BOTH); } - public function padEnd(int $length, string $padStr = ' '): parent + public function padEnd(int $length, string $padStr = ' '): static { if ('' === $padStr || !preg_match('//u', $padStr)) { throw new InvalidArgumentException('Invalid UTF-8 string.'); @@ -291,7 +291,7 @@ public function padEnd(int $length, string $padStr = ' '): parent return $this->pad($length, $pad, \STR_PAD_RIGHT); } - public function padStart(int $length, string $padStr = ' '): parent + public function padStart(int $length, string $padStr = ' '): static { if ('' === $padStr || !preg_match('//u', $padStr)) { throw new InvalidArgumentException('Invalid UTF-8 string.'); @@ -303,7 +303,7 @@ public function padStart(int $length, string $padStr = ' '): parent return $this->pad($length, $pad, \STR_PAD_LEFT); } - public function replaceMatches(string $fromRegexp, string|callable $to): parent + public function replaceMatches(string $fromRegexp, string|callable $to): static { if ($this->ignoreCase) { $fromRegexp .= 'i'; @@ -354,7 +354,7 @@ public function replaceMatches(string $fromRegexp, string|callable $to): parent return $str; } - public function reverse(): parent + public function reverse(): static { $str = clone $this; $str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY))); @@ -362,7 +362,7 @@ public function reverse(): parent return $str; } - public function snake(): parent + public function snake(): static { $str = $this->camel()->title(); $str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8'); @@ -370,7 +370,7 @@ public function snake(): parent return $str; } - public function title(bool $allWords = false): parent + public function title(bool $allWords = false): static { $str = clone $this; @@ -383,7 +383,7 @@ public function title(bool $allWords = false): parent return $str; } - public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent + public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static { if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) { throw new InvalidArgumentException('Invalid UTF-8 chars.'); @@ -396,7 +396,7 @@ public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent return $str; } - public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent + public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static { if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) { throw new InvalidArgumentException('Invalid UTF-8 chars.'); @@ -409,7 +409,7 @@ public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): pare return $str; } - public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent + public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static { if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) { throw new InvalidArgumentException('Invalid UTF-8 chars.'); @@ -422,7 +422,7 @@ public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): pa return $str; } - public function upper(): parent + public function upper(): static { $str = clone $this; $str->string = mb_strtoupper($str->string, 'UTF-8'); diff --git a/src/Symfony/Component/String/ByteString.php b/src/Symfony/Component/String/ByteString.php index 63183bd489b4c..eaf09671a8256 100644 --- a/src/Symfony/Component/String/ByteString.php +++ b/src/Symfony/Component/String/ByteString.php @@ -92,7 +92,7 @@ public function bytesAt(int $offset): array return '' === $str ? [] : [\ord($str)]; } - public function append(string ...$suffix): parent + public function append(string ...$suffix): static { $str = clone $this; $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix); @@ -100,7 +100,7 @@ public function append(string ...$suffix): parent return $str; } - public function camel(): parent + public function camel(): static { $str = clone $this; $str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string)))); @@ -155,7 +155,7 @@ public function equalsTo(string|iterable|AbstractString $string): bool return $string === $this->string; } - public function folded(): parent + public function folded(): static { $str = clone $this; $str->string = strtolower($str->string); @@ -202,7 +202,7 @@ public function isUtf8(): bool return '' === $this->string || preg_match('//u', $this->string); } - public function join(array $strings, string $lastGlue = null): parent + public function join(array $strings, string $lastGlue = null): static { $str = clone $this; @@ -217,7 +217,7 @@ public function length(): int return \strlen($this->string); } - public function lower(): parent + public function lower(): static { $str = clone $this; $str->string = strtolower($str->string); @@ -254,7 +254,7 @@ public function match(string $regexp, int $flags = 0, int $offset = 0): array return $matches; } - public function padBoth(int $length, string $padStr = ' '): parent + public function padBoth(int $length, string $padStr = ' '): static { $str = clone $this; $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH); @@ -262,7 +262,7 @@ public function padBoth(int $length, string $padStr = ' '): parent return $str; } - public function padEnd(int $length, string $padStr = ' '): parent + public function padEnd(int $length, string $padStr = ' '): static { $str = clone $this; $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT); @@ -270,7 +270,7 @@ public function padEnd(int $length, string $padStr = ' '): parent return $str; } - public function padStart(int $length, string $padStr = ' '): parent + public function padStart(int $length, string $padStr = ' '): static { $str = clone $this; $str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT); @@ -278,7 +278,7 @@ public function padStart(int $length, string $padStr = ' '): parent return $str; } - public function prepend(string ...$prefix): parent + public function prepend(string ...$prefix): static { $str = clone $this; $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string; @@ -286,7 +286,7 @@ public function prepend(string ...$prefix): parent return $str; } - public function replace(string $from, string $to): parent + public function replace(string $from, string $to): static { $str = clone $this; @@ -297,7 +297,7 @@ public function replace(string $from, string $to): parent return $str; } - public function replaceMatches(string $fromRegexp, string|callable $to): parent + public function replaceMatches(string $fromRegexp, string|callable $to): static { if ($this->ignoreCase) { $fromRegexp .= 'i'; @@ -337,7 +337,7 @@ public function replaceMatches(string $fromRegexp, string|callable $to): parent return $str; } - public function reverse(): parent + public function reverse(): static { $str = clone $this; $str->string = strrev($str->string); @@ -345,7 +345,7 @@ public function reverse(): parent return $str; } - public function slice(int $start = 0, int $length = null): parent + public function slice(int $start = 0, int $length = null): static { $str = clone $this; $str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX); @@ -353,7 +353,7 @@ public function slice(int $start = 0, int $length = null): parent return $str; } - public function snake(): parent + public function snake(): static { $str = $this->camel()->title(); $str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string)); @@ -361,7 +361,7 @@ public function snake(): parent return $str; } - public function splice(string $replacement, int $start = 0, int $length = null): parent + public function splice(string $replacement, int $start = 0, int $length = null): static { $str = clone $this; $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX); @@ -407,7 +407,7 @@ public function startsWith(string|iterable|AbstractString $prefix): bool return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix))); } - public function title(bool $allWords = false): parent + public function title(bool $allWords = false): static { $str = clone $this; $str->string = $allWords ? ucwords($str->string) : ucfirst($str->string); @@ -457,7 +457,7 @@ public function toCodePointString(string $fromEncoding = null): CodePointString return $u; } - public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent + public function trim(string $chars = " \t\n\r\0\x0B\x0C"): static { $str = clone $this; $str->string = trim($str->string, $chars); @@ -465,7 +465,7 @@ public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent return $str; } - public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent + public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): static { $str = clone $this; $str->string = rtrim($str->string, $chars); @@ -473,7 +473,7 @@ public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent return $str; } - public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent + public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): static { $str = clone $this; $str->string = ltrim($str->string, $chars); @@ -481,7 +481,7 @@ public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent return $str; } - public function upper(): parent + public function upper(): static { $str = clone $this; $str->string = strtoupper($str->string); diff --git a/src/Symfony/Component/String/CodePointString.php b/src/Symfony/Component/String/CodePointString.php index de52a821942c5..926ff79849a36 100644 --- a/src/Symfony/Component/String/CodePointString.php +++ b/src/Symfony/Component/String/CodePointString.php @@ -33,7 +33,7 @@ public function __construct(string $string = '') $this->string = $string; } - public function append(string ...$suffix): AbstractString + public function append(string ...$suffix): static { $str = clone $this; $str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix); @@ -153,7 +153,7 @@ public function length(): int return mb_strlen($this->string, 'UTF-8'); } - public function prepend(string ...$prefix): AbstractString + public function prepend(string ...$prefix): static { $str = clone $this; $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; @@ -165,7 +165,7 @@ public function prepend(string ...$prefix): AbstractString return $str; } - public function replace(string $from, string $to): AbstractString + public function replace(string $from, string $to): static { $str = clone $this; @@ -186,7 +186,7 @@ public function replace(string $from, string $to): AbstractString return $str; } - public function slice(int $start = 0, int $length = null): AbstractString + public function slice(int $start = 0, int $length = null): static { $str = clone $this; $str->string = mb_substr($this->string, $start, $length, 'UTF-8'); @@ -194,7 +194,7 @@ public function slice(int $start = 0, int $length = null): AbstractString return $str; } - public function splice(string $replacement, int $start = 0, int $length = null): AbstractString + public function splice(string $replacement, int $start = 0, int $length = null): static { if (!preg_match('//u', $replacement)) { throw new InvalidArgumentException('Invalid UTF-8 string.'); diff --git a/src/Symfony/Component/String/LazyString.php b/src/Symfony/Component/String/LazyString.php index ba168888906c6..9a9f94f34b6ab 100644 --- a/src/Symfony/Component/String/LazyString.php +++ b/src/Symfony/Component/String/LazyString.php @@ -25,7 +25,7 @@ class LazyString implements \Stringable, \JsonSerializable * * @return static */ - public static function fromCallable(callable|array $callback, mixed ...$arguments): self + public static function fromCallable(callable|array $callback, mixed ...$arguments): static { if (\is_array($callback) && !\is_callable($callback) && !(($callback[0] ?? null) instanceof \Closure || 2 < \count($callback))) { throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']')); @@ -52,7 +52,7 @@ public static function fromCallable(callable|array $callback, mixed ...$argument /** * @return static */ - public static function fromStringable(string|int|float|bool|\Stringable $value): self + public static function fromStringable(string|int|float|bool|\Stringable $value): static { if (\is_object($value)) { return static::fromCallable([$value, '__toString']); diff --git a/src/Symfony/Component/String/UnicodeString.php b/src/Symfony/Component/String/UnicodeString.php index b3d4f50fd2150..a33d90d1c2f84 100644 --- a/src/Symfony/Component/String/UnicodeString.php +++ b/src/Symfony/Component/String/UnicodeString.php @@ -41,7 +41,7 @@ public function __construct(string $string = '') } } - public function append(string ...$suffix): AbstractString + public function append(string ...$suffix): static { $str = clone $this; $str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix)); @@ -176,7 +176,7 @@ public function indexOfLast(string|iterable|AbstractString $needle, int $offset return false === $i ? null : $i; } - public function join(array $strings, string $lastGlue = null): AbstractString + public function join(array $strings, string $lastGlue = null): static { $str = parent::join($strings, $lastGlue); normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); @@ -192,7 +192,7 @@ public function length(): int /** * @return static */ - public function normalize(int $form = self::NFC): parent + public function normalize(int $form = self::NFC): static { $str = clone $this; @@ -208,7 +208,7 @@ public function normalize(int $form = self::NFC): parent return $str; } - public function prepend(string ...$prefix): AbstractString + public function prepend(string ...$prefix): static { $str = clone $this; $str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string; @@ -221,7 +221,7 @@ public function prepend(string ...$prefix): AbstractString return $str; } - public function replace(string $from, string $to): AbstractString + public function replace(string $from, string $to): static { $str = clone $this; normalizer_is_normalized($from) ?: $from = normalizer_normalize($from); @@ -248,7 +248,7 @@ public function replace(string $from, string $to): AbstractString return $str; } - public function replaceMatches(string $fromRegexp, string|callable $to): AbstractString + public function replaceMatches(string $fromRegexp, string|callable $to): static { $str = parent::replaceMatches($fromRegexp, $to); normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string); @@ -256,7 +256,7 @@ public function replaceMatches(string $fromRegexp, string|callable $to): Abstrac return $str; } - public function slice(int $start = 0, int $length = null): AbstractString + public function slice(int $start = 0, int $length = null): static { $str = clone $this; @@ -265,7 +265,7 @@ public function slice(int $start = 0, int $length = null): AbstractString return $str; } - public function splice(string $replacement, int $start = 0, int $length = null): AbstractString + public function splice(string $replacement, int $start = 0, int $length = null): static { $str = clone $this; diff --git a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php index 8e9dc975814cf..b189975ee0b50 100644 --- a/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php @@ -260,7 +260,7 @@ public function setMinDepth(int $minDepth) * * @return Data The cloned variable represented by a Data object */ - public function cloneVar(mixed $var, int $filter = 0) + public function cloneVar(mixed $var, int $filter = 0): Data { $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) { if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) { @@ -295,7 +295,7 @@ public function cloneVar(mixed $var, int $filter = 0) * * @return array The cloned variable represented in an array */ - abstract protected function doClone(mixed $var); + abstract protected function doClone(mixed $var): array; /** * Casts an object to an array representation. @@ -304,7 +304,7 @@ abstract protected function doClone(mixed $var); * * @return array The object casted as array */ - protected function castObject(Stub $stub, bool $isNested) + protected function castObject(Stub $stub, bool $isNested): array { $obj = $stub->value; $class = $stub->class; @@ -363,7 +363,7 @@ protected function castObject(Stub $stub, bool $isNested) * * @return array The resource casted as array */ - protected function castResource(Stub $stub, bool $isNested) + protected function castResource(Stub $stub, bool $isNested): array { $a = []; $res = $stub->value; diff --git a/src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php b/src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php index fa1df1e8fd3db..d781784159bbb 100644 --- a/src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php +++ b/src/Symfony/Component/VarDumper/Cloner/ClonerInterface.php @@ -21,5 +21,5 @@ interface ClonerInterface * * @return Data The cloned variable represented by a Data object */ - public function cloneVar(mixed $var); + public function cloneVar(mixed $var): Data; } diff --git a/src/Symfony/Component/VarDumper/Cloner/Data.php b/src/Symfony/Component/VarDumper/Cloner/Data.php index 6836a7100b3f2..f50b5bf1d5d84 100644 --- a/src/Symfony/Component/VarDumper/Cloner/Data.php +++ b/src/Symfony/Component/VarDumper/Cloner/Data.php @@ -38,7 +38,7 @@ public function __construct(array $data) /** * @return string|null The type of the value */ - public function getType() + public function getType(): ?string { $item = $this->data[$this->position][$this->key]; @@ -69,7 +69,7 @@ public function getType() * * @return string|int|float|bool|array|Data[]|null A native representation of the original value */ - public function getValue(array|bool $recursive = false) + public function getValue(array|bool $recursive = false): string|int|float|bool|array|null { $item = $this->data[$this->position][$this->key]; @@ -136,7 +136,7 @@ public function __get(string $key) /** * @return bool */ - public function __isset(string $key) + public function __isset(string $key): bool { return null !== $this->seek($key); } @@ -177,7 +177,7 @@ public function __toString(): string * * @return static */ - public function withMaxDepth(int $maxDepth) + public function withMaxDepth(int $maxDepth): static { $data = clone $this; $data->maxDepth = (int) $maxDepth; @@ -190,7 +190,7 @@ public function withMaxDepth(int $maxDepth) * * @return static */ - public function withMaxItemsPerDepth(int $maxItemsPerDepth) + public function withMaxItemsPerDepth(int $maxItemsPerDepth): static { $data = clone $this; $data->maxItemsPerDepth = (int) $maxItemsPerDepth; @@ -205,7 +205,7 @@ public function withMaxItemsPerDepth(int $maxItemsPerDepth) * * @return static */ - public function withRefHandles(bool $useRefHandles) + public function withRefHandles(bool $useRefHandles): static { $data = clone $this; $data->useRefHandles = $useRefHandles ? -1 : 0; @@ -216,7 +216,7 @@ public function withRefHandles(bool $useRefHandles) /** * @return static */ - public function withContext(array $context) + public function withContext(array $context): static { $data = clone $this; $data->context = $context; @@ -229,7 +229,7 @@ public function withContext(array $context) * * @return static|null Null if the key is not set */ - public function seek(string|int $key) + public function seek(string|int $key): ?static { $item = $this->data[$this->position][$this->key]; diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 4a6817c1c4869..800bc9566ede8 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -22,7 +22,7 @@ class VarCloner extends AbstractCloner /** * {@inheritdoc} */ - protected function doClone(mixed $var) + protected function doClone(mixed $var): array { $len = 1; // Length of $queue $pos = 0; // Number of cloned items past the minimum depth diff --git a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php index 6064ea99f572b..fd9aea3cd1100 100644 --- a/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php @@ -84,7 +84,7 @@ public function setOutput($output) * * @return string The previous charset */ - public function setCharset(string $charset) + public function setCharset(string $charset): string { $prev = $this->charset; @@ -103,7 +103,7 @@ public function setCharset(string $charset) * * @return string The previous indent pad */ - public function setIndentPad(string $pad) + public function setIndentPad(string $pad): string { $prev = $this->indentPad; $this->indentPad = $pad; @@ -118,7 +118,7 @@ public function setIndentPad(string $pad) * * @return string|null The dump as string when $output is true */ - public function dump(Data $data, $output = null) + public function dump(Data $data, $output = null): ?string { $this->decimalPoint = localeconv(); $this->decimalPoint = $this->decimalPoint['decimal_point']; @@ -182,7 +182,7 @@ protected function echoLine(string $line, int $depth, string $indentPad) * * @return string|null The string converted to UTF-8 */ - protected function utf8Encode(?string $s) + protected function utf8Encode(?string $s): ?string { if (null === $s || preg_match('//u', $s)) { return $s; diff --git a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php index 68b85390937e1..2cb5baff83ae6 100644 --- a/src/Symfony/Component/VarDumper/Dumper/CliDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/CliDumper.php @@ -437,7 +437,7 @@ protected function dumpKey(Cursor $cursor) * * @return string The value with style decoration */ - protected function style(string $style, string $value, array $attr = []) + protected function style(string $style, string $value, array $attr = []): string { if (null === $this->colors) { $this->colors = $this->supportsColors(); @@ -513,7 +513,7 @@ protected function style(string $style, string $value, array $attr = []) /** * @return bool Tells if the current output stream supports ANSI colors or not */ - protected function supportsColors() + protected function supportsColors(): bool { if ($this->outputStream !== static::$defaultOutput) { return $this->hasColorSupport($this->outputStream); diff --git a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php index ee4c8da0841ad..f432507806d90 100644 --- a/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php +++ b/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php @@ -134,7 +134,7 @@ public function setDumpBoundaries(string $prefix, string $suffix) /** * {@inheritdoc} */ - public function dump(Data $data, $output = null, array $extraDisplayOptions = []) + public function dump(Data $data, $output = null, array $extraDisplayOptions = []): ?string { $this->extraDisplayOptions = $extraDisplayOptions; $result = parent::dump($data, $output); @@ -846,7 +846,7 @@ public function leaveHash(Cursor $cursor, int $type, string|int|null $class, boo /** * {@inheritdoc} */ - protected function style(string $style, string $value, array $attr = []) + protected function style(string $style, string $value, array $attr = []): string { if ('' === $value) { return ''; diff --git a/src/Symfony/Component/WebLink/GenericLinkProvider.php b/src/Symfony/Component/WebLink/GenericLinkProvider.php index 4cb25a423fc2a..66796e7f9092d 100644 --- a/src/Symfony/Component/WebLink/GenericLinkProvider.php +++ b/src/Symfony/Component/WebLink/GenericLinkProvider.php @@ -64,7 +64,7 @@ public function getLinksByRel(string $rel): array * * @return static */ - public function withLink(LinkInterface $link) + public function withLink(LinkInterface $link): static { $that = clone $this; $that->links[spl_object_id($link)] = $link; @@ -77,7 +77,7 @@ public function withLink(LinkInterface $link) * * @return static */ - public function withoutLink(LinkInterface $link) + public function withoutLink(LinkInterface $link): static { $that = clone $this; unset($that->links[spl_object_id($link)]); diff --git a/src/Symfony/Component/WebLink/Link.php b/src/Symfony/Component/WebLink/Link.php index b7785992fdb18..4dccd6c3a4759 100644 --- a/src/Symfony/Component/WebLink/Link.php +++ b/src/Symfony/Component/WebLink/Link.php @@ -95,7 +95,7 @@ public function getAttributes(): array * * @return static */ - public function withHref(string|\Stringable $href) + public function withHref(string|\Stringable $href): static { $that = clone $this; $that->href = $href; @@ -108,7 +108,7 @@ public function withHref(string|\Stringable $href) * * @return static */ - public function withRel(string $rel) + public function withRel(string $rel): static { $that = clone $this; $that->rel[$rel] = $rel; @@ -121,7 +121,7 @@ public function withRel(string $rel) * * @return static */ - public function withoutRel(string $rel) + public function withoutRel(string $rel): static { $that = clone $this; unset($that->rel[$rel]); @@ -134,7 +134,7 @@ public function withoutRel(string $rel) * * @return static */ - public function withAttribute(string $attribute, string|\Stringable|int|float|bool|array $value) + public function withAttribute(string $attribute, string|\Stringable|int|float|bool|array $value): static { $that = clone $this; $that->attributes[$attribute] = $value; @@ -147,7 +147,7 @@ public function withAttribute(string $attribute, string|\Stringable|int|float|bo * * @return static */ - public function withoutAttribute(string $attribute) + public function withoutAttribute(string $attribute): static { $that = clone $this; unset($that->attributes[$attribute]); diff --git a/src/Symfony/Component/Workflow/DefinitionBuilder.php b/src/Symfony/Component/Workflow/DefinitionBuilder.php index 9cfdcae772934..b023e62087966 100644 --- a/src/Symfony/Component/Workflow/DefinitionBuilder.php +++ b/src/Symfony/Component/Workflow/DefinitionBuilder.php @@ -40,7 +40,7 @@ public function __construct(array $places = [], array $transitions = []) /** * @return Definition */ - public function build() + public function build(): Definition { return new Definition($this->places, $this->transitions, $this->initialPlaces, $this->metadataStore); } @@ -50,7 +50,7 @@ public function build() * * @return $this */ - public function clear() + public function clear(): static { $this->places = []; $this->transitions = []; @@ -65,7 +65,7 @@ public function clear() * * @return $this */ - public function setInitialPlaces(string|array|null $initialPlaces) + public function setInitialPlaces(string|array|null $initialPlaces): static { $this->initialPlaces = $initialPlaces; @@ -75,7 +75,7 @@ public function setInitialPlaces(string|array|null $initialPlaces) /** * @return $this */ - public function addPlace(string $place) + public function addPlace(string $place): static { if (!$this->places) { $this->initialPlaces = $place; @@ -91,7 +91,7 @@ public function addPlace(string $place) * * @return $this */ - public function addPlaces(array $places) + public function addPlaces(array $places): static { foreach ($places as $place) { $this->addPlace($place); @@ -105,7 +105,7 @@ public function addPlaces(array $places) * * @return $this */ - public function addTransitions(array $transitions) + public function addTransitions(array $transitions): static { foreach ($transitions as $transition) { $this->addTransition($transition); @@ -117,7 +117,7 @@ public function addTransitions(array $transitions) /** * @return $this */ - public function addTransition(Transition $transition) + public function addTransition(Transition $transition): static { $this->transitions[] = $transition; @@ -127,7 +127,7 @@ public function addTransition(Transition $transition) /** * @return $this */ - public function setMetadataStore(MetadataStoreInterface $metadataStore) + public function setMetadataStore(MetadataStoreInterface $metadataStore): static { $this->metadataStore = $metadataStore; diff --git a/src/Symfony/Component/Workflow/Dumper/DumperInterface.php b/src/Symfony/Component/Workflow/Dumper/DumperInterface.php index e1d8c7d682b35..1b7461154a6a3 100644 --- a/src/Symfony/Component/Workflow/Dumper/DumperInterface.php +++ b/src/Symfony/Component/Workflow/Dumper/DumperInterface.php @@ -27,5 +27,5 @@ interface DumperInterface * * @return string The representation of the workflow */ - public function dump(Definition $definition, Marking $marking = null, array $options = []); + public function dump(Definition $definition, Marking $marking = null, array $options = []): string; } diff --git a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php index a8186a8548c07..37dad66cfe2cb 100644 --- a/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/GraphvizDumper.php @@ -44,7 +44,7 @@ class GraphvizDumper implements DumperInterface * * node: The default options for nodes (places + transitions) * * edge: The default options for edges */ - public function dump(Definition $definition, Marking $marking = null, array $options = []) + public function dump(Definition $definition, Marking $marking = null, array $options = []): string { $places = $this->findPlaces($definition, $marking); $transitions = $this->findTransitions($definition); diff --git a/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php b/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php index 4bd818d5363fc..95b19c497c632 100644 --- a/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/StateMachineGraphvizDumper.php @@ -27,7 +27,7 @@ class StateMachineGraphvizDumper extends GraphvizDumper * * node: The default options for nodes (places) * * edge: The default options for edges */ - public function dump(Definition $definition, Marking $marking = null, array $options = []) + public function dump(Definition $definition, Marking $marking = null, array $options = []): string { $places = $this->findPlaces($definition, $marking); $edges = $this->findEdges($definition); diff --git a/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php b/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php index 95a9590cef4b2..f7a8f66861917 100644 --- a/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php +++ b/src/Symfony/Component/Workflow/EventListener/AuditTrailListener.php @@ -46,7 +46,7 @@ public function onEnter(Event $event) } } - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { return [ 'workflow.leave' => ['onLeave'], diff --git a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php index 2d8d6ad731141..a9a2de6e45500 100644 --- a/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php +++ b/src/Symfony/Component/Workflow/MarkingStore/MarkingStoreInterface.php @@ -29,7 +29,7 @@ interface MarkingStoreInterface * * @return Marking The marking */ - public function getMarking(object $subject); + public function getMarking(object $subject): Marking; /** * Sets a Marking to a subject. diff --git a/src/Symfony/Component/Workflow/Registry.php b/src/Symfony/Component/Workflow/Registry.php index 3474e953fa637..2753a8d7368b6 100644 --- a/src/Symfony/Component/Workflow/Registry.php +++ b/src/Symfony/Component/Workflow/Registry.php @@ -41,7 +41,7 @@ public function has(object $subject, string $workflowName = null): bool /** * @return Workflow */ - public function get(object $subject, string $workflowName = null) + public function get(object $subject, string $workflowName = null): Workflow { $matched = []; diff --git a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php index 6eca532331d03..75885c0bb9e85 100644 --- a/src/Symfony/Component/Workflow/Tests/WorkflowTest.php +++ b/src/Symfony/Component/Workflow/Tests/WorkflowTest.php @@ -12,7 +12,6 @@ use Symfony\Component\Workflow\Exception\NotEnabledTransitionException; use Symfony\Component\Workflow\Exception\UndefinedTransitionException; use Symfony\Component\Workflow\Marking; -use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface; use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore; use Symfony\Component\Workflow\Transition; use Symfony\Component\Workflow\TransitionBlocker; @@ -23,16 +22,6 @@ class WorkflowTest extends TestCase { use WorkflowBuilderTrait; - public function testGetMarkingWithInvalidStoreReturn() - { - $this->expectException(LogicException::class); - $this->expectExceptionMessage('The value returned by the MarkingStore is not an instance of "Symfony\Component\Workflow\Marking" for workflow "unnamed".'); - $subject = new Subject(); - $workflow = new Workflow(new Definition([], []), $this->createMock(MarkingStoreInterface::class)); - - $workflow->getMarking($subject); - } - public function testGetMarkingWithEmptyDefinition() { $this->expectException(LogicException::class); diff --git a/src/Symfony/Component/Workflow/Transition.php b/src/Symfony/Component/Workflow/Transition.php index b6947fe1faed9..b8dc03299428c 100644 --- a/src/Symfony/Component/Workflow/Transition.php +++ b/src/Symfony/Component/Workflow/Transition.php @@ -35,7 +35,7 @@ public function __construct(string $name, string|array $froms, string|array $tos /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -43,7 +43,7 @@ public function getName() /** * @return string[] */ - public function getFroms() + public function getFroms(): array { return $this->froms; } @@ -51,7 +51,7 @@ public function getFroms() /** * @return string[] */ - public function getTos() + public function getTos(): array { return $this->tos; } diff --git a/src/Symfony/Component/Workflow/Workflow.php b/src/Symfony/Component/Workflow/Workflow.php index 12a0bab57a040..fc6c467f7ff2a 100644 --- a/src/Symfony/Component/Workflow/Workflow.php +++ b/src/Symfony/Component/Workflow/Workflow.php @@ -79,7 +79,7 @@ public function __construct(Definition $definition, MarkingStoreInterface $marki /** * {@inheritdoc} */ - public function getMarking(object $subject, array $context = []) + public function getMarking(object $subject, array $context = []): Marking { $marking = $this->markingStore->getMarking($subject); @@ -125,7 +125,7 @@ public function getMarking(object $subject, array $context = []) /** * {@inheritdoc} */ - public function can(object $subject, string $transitionName) + public function can(object $subject, string $transitionName): bool { $transitions = $this->definition->getTransitions(); $marking = $this->getMarking($subject); @@ -184,7 +184,7 @@ public function buildTransitionBlockerList(object $subject, string $transitionNa /** * {@inheritdoc} */ - public function apply(object $subject, string $transitionName, array $context = []) + public function apply(object $subject, string $transitionName, array $context = []): Marking { $marking = $this->getMarking($subject, $context); @@ -252,7 +252,7 @@ public function apply(object $subject, string $transitionName, array $context = /** * {@inheritdoc} */ - public function getEnabledTransitions(object $subject) + public function getEnabledTransitions(object $subject): array { $enabledTransitions = []; $marking = $this->getMarking($subject); @@ -289,7 +289,7 @@ public function getEnabledTransition(object $subject, string $name): ?Transition /** * {@inheritdoc} */ - public function getName() + public function getName(): string { return $this->name; } @@ -297,7 +297,7 @@ public function getName() /** * {@inheritdoc} */ - public function getDefinition() + public function getDefinition(): Definition { return $this->definition; } @@ -305,7 +305,7 @@ public function getDefinition() /** * {@inheritdoc} */ - public function getMarkingStore() + public function getMarkingStore(): MarkingStoreInterface { return $this->markingStore; } diff --git a/src/Symfony/Component/Workflow/WorkflowInterface.php b/src/Symfony/Component/Workflow/WorkflowInterface.php index 39d9361a5fe72..6dfeca1c067d3 100644 --- a/src/Symfony/Component/Workflow/WorkflowInterface.php +++ b/src/Symfony/Component/Workflow/WorkflowInterface.php @@ -27,14 +27,14 @@ interface WorkflowInterface * * @throws LogicException */ - public function getMarking(object $subject); + public function getMarking(object $subject): Marking; /** * Returns true if the transition is enabled. * * @return bool true if the transition is enabled */ - public function can(object $subject, string $transitionName); + public function can(object $subject, string $transitionName): bool; /** * Builds a TransitionBlockerList to know why a transition is blocked. @@ -48,29 +48,29 @@ public function buildTransitionBlockerList(object $subject, string $transitionNa * * @throws LogicException If the transition is not applicable */ - public function apply(object $subject, string $transitionName, array $context = []); + public function apply(object $subject, string $transitionName, array $context = []): Marking; /** * Returns all enabled transitions. * * @return Transition[] All enabled transitions */ - public function getEnabledTransitions(object $subject); + public function getEnabledTransitions(object $subject): array; /** * @return string */ - public function getName(); + public function getName(): string; /** * @return Definition */ - public function getDefinition(); + public function getDefinition(): Definition; /** * @return MarkingStoreInterface */ - public function getMarkingStore(); + public function getMarkingStore(): MarkingStoreInterface; public function getMetadataStore(): MetadataStoreInterface; } diff --git a/src/Symfony/Component/Yaml/Command/LintCommand.php b/src/Symfony/Component/Yaml/Command/LintCommand.php index 32eab0c61b127..bd0c927411927 100644 --- a/src/Symfony/Component/Yaml/Command/LintCommand.php +++ b/src/Symfony/Component/Yaml/Command/LintCommand.php @@ -81,7 +81,7 @@ protected function configure() ; } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $filenames = (array) $input->getArgument('filename'); diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index 74d5a533e1288..9379138703f8c 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -46,7 +46,7 @@ public function __construct(string $message, int $parsedLine = -1, string $snipp * * @return string The snippet of code */ - public function getSnippet() + public function getSnippet(): string { return $this->snippet; } @@ -68,7 +68,7 @@ public function setSnippet(string $snippet) * * @return string The filename */ - public function getParsedFile() + public function getParsedFile(): string { return $this->parsedFile; } @@ -88,7 +88,7 @@ public function setParsedFile(string $parsedFile) * * @return int The file line */ - public function getParsedLine() + public function getParsedLine(): int { return $this->parsedLine; }