8000 [Contracts] add return types and bump to v3 · symfony/symfony@c200b51 · GitHub
[go: up one dir, main page]

Skip to content

Commit c200b51

Browse files
[Contracts] add return types and bump to v3
1 parent fa9f02f commit c200b51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+73
-115
lines changed

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php-http/async-client-implementation": "*",
2020
"php-http/client-implementation": "*",
2121
"psr/cache-implementation": "1.0|2.0|3.0",
22-
"psr/container-implementation": "1.0",
22+
"psr/container-implementation": "1.1|2.0",
2323
"psr/event-dispatcher-implementation": "1.0",
2424
"psr/http-client-implementation": "1.0",
2525
"psr/link-implementation": "1.0",
@@ -39,11 +39,11 @@
3939
"doctrine/persistence": "^2",
4040
"twig/twig": "^2.13|^3.0.4",
4141
"psr/cache": "^1.0|^2.0|^3.0",
42-
"psr/container": "^1.0",
42+
"psr/container": "^1.1|^2.0",
4343
"psr/event-dispatcher": "^1.0",
4444
"psr/link": "^1.1",
4545
"psr/log": "~1.0",
46-
"symfony/contracts": "^2.5",
46+
"symfony/contracts": "^2.5|^3.0",
4747
"symfony/polyfill-ctype": "~1.8",
4848
"symfony/polyfill-intl-grapheme": "~1.0",
4949
"symfony/polyfill-intl-icu": "~1.0",
@@ -186,7 +186,7 @@
186186
"url": "src/Symfony/Contracts",
187187
"options": {
188188
"versions": {
189-
"symfony/contracts": "2.5.x-dev"
189+
"symfony/contracts": "3.0.x-dev"
190190
}
191191
}
192192
},

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function isOptional()
6262
/**
6363
* {@inheritdoc}
6464
*/
65-
public static function getSubscribedServices()
65+
public static function getSubscribedServices(): array
6666
{
6767
return [
6868
'translator' => TranslatorInterface::class,

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function getParameter(string $name)
8686
return $this->container->get('parameter_bag')->get($name);
8787
}
8888

89-
public static function getSubscribedServices()
89+
public static function getSubscribedServices(): array
9090
{
9191
return [
9292
'router' => '?'.RouterInterface::class,

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private function resolve(mixed $value): mixed
196196
/**
197197
* {@inheritdoc}
198198
*/
199-
public static function getSubscribedServices()
199+
public static function getSubscribedServices(): array
200200
{
201201
return [
202202
'routing.loader' => LoaderInterface::class,

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Symfony\Component\Translation\Loader\LoaderInterface;
2323
use Symfony\Component\Translation\Loader\YamlFileLoader;
2424
use Symfony\Component\Translation\MessageCatalogue;
25+
use Symfony\Contracts\Translation\TranslatorInterface;
2526

2627
class TranslatorTest extends TestCase
2728
{
@@ -310,7 +311,7 @@ protected function getContainer($loader)
310311
return $container;
311312
}
312313

313-
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = Translator::class, $defaultLocale = 'en', array $enabledLocales = [])
314+
public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = Translator::class, $defaultLocale = 'en', array $enabledLocales = []): TranslatorInterface
314315
{
315316
$translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale, $enabledLocales);
316317

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function isOptional()
8181
/**
8282
* {@inheritdoc}
8383
*/
84-
public static function getSubscribedServices()
84+
public static function getSubscribedServices(): array
8585
{
8686
return [
8787
'twig' => Environment::class,

src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function deleteItems(array $keys): bool
282282
/**
283283
* {@inheritdoc}
284284
*/
285-
public function invalidateTags(array $tags)
285+
public function invalidateTags(array $tags): bool
286286
{
287287
if (empty($tags)) {
288288
return false;

src/Symfony/Component/Cache/Adapter/ArrayAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static function ($key, $value, $isHit) {
7373
/**
7474
* {@inheritdoc}
7575
*/
76-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
76+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
7777
{
7878
$item = $this->getItem($key);
7979
$metadata = $item->getMetadata();

src/Symfony/Component/Cache/Adapter/ChainAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static function ($sourceItem, $item, $defaultLifetime, $sourceMetadata = null) {
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
95+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
9696
{
9797
$lastItem = null;
9898
$i = 0;

src/Symfony/Component/Cache/Adapter/NullAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static function ($key) {
4040
/**
4141
* {@inheritdoc}
4242
*/
43-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
43+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
4444
{
4545
$save = true;
4646

src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function create(string $file, CacheItemPoolInterface $fallbackPool
8383
/**
8484
* {@inheritdoc}
8585
*/
86-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
86+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
8787
{
8888
if (!isset($this->values)) {
8989
$this->initialize();

src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static function (CacheItemInterface $innerItem, array $item) {
102102
/**
103103
* {@inheritdoc}
104104
*/
105-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
105+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
106106
{
107107
if (!$this->pool instanceof CacheInterface) {
108108
return $this->doGet($this, $key, $callback, $beta, $metadata);

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static function (AdapterInterface $tagsAdapter, array $tags) {
112112
/**
113113
* {@inheritdoc}
114114
*/
115-
public function invalidateTags(array $tags)
115+
public function invalidateTags(array $tags): bool
116116
{
117117
$ok = true;
118118
$tagsByKey = [];

src/Symfony/Component/Cache/Adapter/TagAwareAdapterInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ interface TagAwareAdapterInterface extends AdapterInterface
2929
*
3030
* @throws InvalidArgumentException When $tags is not valid
3131
*/
32-
public function invalidateTags(array $tags);
32+
public function invalidateTags(array $tags): bool;
3333
}

src/Symfony/Component/Cache/Adapter/TraceableAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(AdapterInterface $pool)
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
41+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
4242
{
4343
if (!$this->pool instanceof CacheInterface) {
4444
throw new \BadMethodCallException(sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class));

src/Symfony/Component/Cache/Adapter/TraceableTagAwareAdapter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(TagAwareAdapterInterface $pool)
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function invalidateTags(array $tags)
29+
public function invalidateTags(array $tags): bool
3030
{
3131
$event = $this->start(__FUNCTION__);
3232
try {

src/Symfony/Component/Cache/CacheItem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function expiresAfter(mixed $time): static
104104
/**
105105
* {@inheritdoc}
106106
*/
107-
public function tag(mixed $tags): ItemInterface
107+
public function tag(mixed $tags): static
108108
{
109109
if (!$this->isTaggable) {
110110
throw new LogicException(sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key));

src/Symfony/Component/Cache/Tests/Adapter/AdapterTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function __construct(int $value)
7979
$this->value = $value;
8080
}
8181

82-
public function __invoke(CacheItemInterface $item, bool &$save)
82+
public function __invoke(CacheItemInterface $item, bool &$save): mixed
8383
{
8484
Assert::assertSame('bar', $item->getKey());
8585

src/Symfony/Component/DependencyInjection/Container.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,7 @@ public function set(string $id, ?object $service)
173173
$this->services[$id] = $service;
174174
}
175175

176-
/**
177-
* Returns true if the given service is defined.
178-
*
179-
* @param string $id The service identifier
180-
*
181-
* @return bool true if the service is defined, false otherwise
182-
*/
183-
public function has(string $id)
176+
public function has(string $id): bool
184177
{
185178
if (isset($this->aliases[$id])) {
186179
$id = $this->aliases[$id];

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

+1-8
Original file line numberDiff line numberDiff line change
@@ -491,14 +491,7 @@ public function removeDefinition(string $id)
491491
}
492492
}
493493

494-
/**
495-
* Returns true if the given service is defined.
496-
*
497-
* @param string $id The service identifier
498-
*
499-
* @return bool true if the service is defined, false otherwise
500-
*/
501-
public function has(string $id)
494+
public function has(string $id): bool
502495
{
503496
return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || parent::has($id);
504497
}

src/Symfony/Component/DependencyInjection/ContainerInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALI
4545
/**
4646
* @return bool true if the service is defined, false otherwise
4747
*/
48-
public function has(string $id);
48+
public function has(string $id): bool;
4949

5050
/**
5151
* Check for whether or not a service has been initialized.

src/Symfony/Component/DependencyInjection/ParameterBag/ContainerBag.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ public function get(string $name)
4545

4646
/**
4747
* {@inheritdoc}
48-
*
49-
* @return bool
5048
*/
51-
public function has(string $name)
49+
public function has(string $name): bool
5250
{
5351
return $this->container->hasParameter($name);
5452
}

src/Symfony/Component/DependencyInjection/Tests/ServiceLocatorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
class ServiceLocatorTest extends BaseServiceLocatorTest
2323
{
24-
public function getServiceLocator(array $factories)
24+
public function getServiceLocator(array $factories): ServiceLocator
2525
{
2626
return new ServiceLocator($factories);
2727
}

src/Symfony/Component/DependencyInjection/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.0.2",
20-
"psr/container": "^1.1.1",
20+
"psr/container": "^1.1|^2.0",
2121
"symfony/deprecation-contracts": "^2.1",
2222
"symfony/service-contracts": "^1.1.6|^2"
2323
},
@@ -41,7 +41,7 @@
4141
"symfony/yaml": "<5.4"
4242
},
4343
"provide": {
44-
"psr/container-implementation": "1.0",
44+
"psr/container-implementation": "1.1|2.0",
4545
"symfony/service-implementation": "1.0|2.0"
4646
},
4747
"autoload": {

src/Symfony/Component/HttpClient/Response/AsyncContext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function cancel(): ChunkInterface
110110
/**
111111
* Returns the current info of the response.
112112
*/
113-
public function getInfo(string $type = null)
113+
public function getInfo(string $type = null): mixed
114114
{
115115
if (null !== $type) {
116116
return $this->info[$type] ?? $this->response->getInfo($type);

src/Symfony/Component/HttpClient/Response/MockResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function getRequestMethod(): string
9393
/**
9494
* {@inheritdoc}
9595
*/
96-
public function getInfo(string $type = null)
96+
public function getInfo(string $type = null): mixed
9797
{
9898
return null !== $type ? $this->info[$type] ?? null : $this->info;
9999
}

src/Symfony/Component/Security/Core/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/password-hasher": "^5.4|^6.0"
2424
},
2525
"require-dev": {
26-
"psr/container": "^1.0|^2.0",
26+
"psr/container": "^1.1|^2.0",
2727
"psr/cache": "^1.0|^2.0|^3.0",
2828
"symfony/cache": "^5.4|^6.0",
2929
"symfony/event-dispatcher": "^5.4|^6.0",

src/Symfony/Component/String/Slugger/AsciiSlugger.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function setLocale(string $locale)
8383
/**
8484
* {@inheritdoc}
8585
*/
86-
public function getLocale()
86+
public function getLocale(): string
8787
{
8888
return $this->defaultLocale;
8989
}

src/Symfony/Component/Translation/DataCollectorTranslator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __construct(TranslatorInterface $translator)
4747
/**
4848
* {@inheritdoc}
4949
*/
50-
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null)
50+
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
5151
{
5252
$trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale);
5353
$this->collectMessage($locale, $domain, $id, $trans, $parameters);
@@ -66,7 +66,7 @@ public function setLocale(string $locale)
6666
/**
6767
* {@inheritdoc}
6868
*/
69-
public function getLocale()
69+
public function getLocale(): string
7070
{
7171
return $this->translator->getLocale();
7272
}

src/Symfony/Component/Translation/LoggingTranslator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(TranslatorInterface $translator, LoggerInterface $lo
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null)
47+
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
4848
{
4949
$trans = $this->translator->trans($id = (string) $id, $parameters, $domain, $locale);
5050
$this->log($id, $domain, $locale);
@@ -69,7 +69,7 @@ public function setLocale(string $locale)
6969
/**
7070
* {@inheritdoc}
7171
*/
72-
public function getLocale()
72+
public function getLocale(): string
7373
{
7474
return $this->translator->getLocale();
7575
}

src/Symfony/Component/Translation/MessageCatalogue.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(string $locale, array $messages = [])
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function getLocale()
41+
public function getLocale(): string
4242
{
4343
return $this->locale;
4444
}

src/Symfony/Component/Translation/Tests/IdentityTranslatorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function tearDown(): void
3333
\Locale::setDefault($this->defaultLocale);
3434
}
3535

36-
public function getTranslator()
36+
public function getTranslator(): IdentityTranslator
3737
{
3838
return new IdentityTranslator();
3939
}

src/Symfony/Component/Translation/Translator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function setLocale(string $locale)
156156
/**
157157
* {@inheritdoc}
158158
*/
159-
public function getLocale()
159+
public function getLocale(): string
160160
{
161161
return $this->locale;
162162
}
@@ -191,7 +191,7 @@ public function getFallbackLocales(): array
191191
/**
192192
* {@inheritdoc}
193193
*/
194-
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null)
194+
public function trans(?string $id, array $parameters = [], string $domain = null, string $locale = null): string
195195
{
196196
if (null === $id || '' === $id) {
197197
return '';

src/Symfony/Contracts/Cache/CacheInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface CacheInterface
4242
*
4343
* @throws InvalidArgumentException When $key is not valid or when $beta is negative
4444
*/
45-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null);
45+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed;
4646

4747
/**
4848
* Removes an item from the pool.

0 commit comments

Comments
 (0)
0