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

Skip to content

Commit bd68e60

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

33 files changed

+46
-89
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
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/Component/Cache/CacheItem.php

Lines changed: 1 addition & 1 deletion
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/DependencyInjection/Container.php

Lines changed: 1 addition & 8 deletions
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

Lines changed: 1 addition & 8 deletions
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/ParameterBag/ContainerBag.php

Lines changed: 1 addition & 3 deletions
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/composer.json

Lines changed: 2 additions & 2 deletions
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/Security/Core/composer.json

Lines changed: 1 addition & 1 deletion
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/Translation/DataCollectorTranslator.php

Lines changed: 1 addition & 1 deletion
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);

src/Symfony/Component/Translation/LoggingTranslator.php

Lines changed: 1 addition & 1 deletion
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);

src/Symfony/Component/Translation/Translator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 1 deletion
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.

src/Symfony/Contracts/Cache/CacheTrait.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ trait CacheTrait
2727
{
2828
/**
2929
* {@inheritdoc}
30-
*
31-
* @return mixed
3230
*/
33-
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
31+
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
3432
{
3533
return $this->doGet($this, $key, $callback, $beta, $metadata);
3634
}
@@ -43,7 +41,7 @@ public function delete(string $key): bool
4341
return $this->deleteItem($key);
4442
}
4543

46-
private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, LoggerInterface $logger = null)
44+
private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null, LoggerInterface $logger = null): mixed
4745
{
4846
if (0 > $beta = $beta ?? 1.0) {
4947
throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException { };

src/Symfony/Contracts/Cache/CallbackInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ interface CallbackInterface
2626
*
2727
* @return mixed The computed value for the passed item
2828
*/
29-
public function __invoke(CacheItemInterface $item, bool &$save);
29+
public function __invoke(CacheItemInterface $item, bool &$save): mixed;
3030
}

src/Symfony/Contracts/Cache/ItemInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface ItemInterface extends CacheItemInterface
5454
* @throws InvalidArgumentException When $tag is not valid
5555
* @throws CacheException When the item comes from a pool that is not tag-aware
5656
*/
57-
public function tag(string|iterable $tags): self;
57+
public function tag(string|iterable $tags): static;
5858

5959
/**
6060
* Returns a list of metadata info that were saved alongside with the cached value.

src/Symfony/Contracts/Cache/TagAwareCacheInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ interface TagAwareCacheInterface extends CacheInterface
3434
*
3535
* @throws InvalidArgumentException When $tags is not valid
3636
*/
37-
public function invalidateTags(array $tags);
37+
public function invalidateTags(array $tags): bool;
3838
}

src/Symfony/Contracts/Cache/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"minimum-stability": "dev",
2929
"extra": {
3030
"branch-alias": {
31-
"dev-main": "2.5-dev"
31+
"dev-main": "3.0-dev"
3232
},
3333
"thanks": {
3434
"name": "symfony/contracts",

src/Symfony/Contracts/Deprecation/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=7.1"
18+
"php": ">=8.0.2"
1919
},
2020
"autoload": {
2121
"files": [
@@ -25,7 +25,7 @@
2525
"minimum-stability": "dev",
2626
"extra": {
2727
"branch-alias": {
28-
"dev-main": "2.5-dev"
28+
"dev-main": "3.0-dev"
2929
},
3030
"thanks": {
3131
"name": "symfony/contracts",

src/Symfony/Contracts/EventDispatcher/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"minimum-stability": "dev",
2929
"extra": {
3030
"branch-alias": {
31-
"dev-main": "2.5-dev"
31+
"dev-main": "3.0-dev"
3232
},
3333
"thanks": {
3434
"name": "symfony/contracts",

src/Symfony/Contracts/HttpClient/ResponseInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ public function cancel(): void;
105105
* @return mixed An array of all available info, or one of them when $type is
106106
* provided, or null when an unsupported type is requested
107107
*/
108-
public function getInfo(string $type = null);
108+
public function getInfo(string $type = null): mixed;
109109
}

src/Symfony/Contracts/HttpClient/Test/TestHttpServer.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ class TestHttpServer
1818
{
1919
private static $process = [];
2020

21-
/**
22-
* @return Process
23-
*/
24-
public static function start(int $port = 8057)
21+
public static function start(int $port = 8057): Process
2522
{
2623
if (isset(self::$process[$port])) {
2724
self::$process[$port]->stop();

src/Symfony/Contracts/HttpClient/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"minimum-stability": "dev",
2828
"extra": {
2929
"branch-alias": {
30-
"dev-main": "2.5-dev"
30+
"dev-main": "3.0-dev"
3131
},
3232
"thanks": {
3333
"name": "symfony/contracts",

src/Symfony/Contracts/Service/ServiceLocatorTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ public function __construct(array $factories)
4040

4141
/**
4242
* {@inheritdoc}
43-
*
44-
* @return bool
4543
*/
46-
public function has(string $id)
44+
public function has(string $id): bool
4745
{
4846
return isset($this->factories[$id]);
4947
}

src/Symfony/Contracts/Service/ServiceSubscriberInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ interface ServiceSubscriberInterface
4949
*
5050
* @return string[] The required service types, optionally keyed by service names
5151
*/
52-
public static function getSubscribedServices();
52+
public static function getSubscribedServices(): array;
5353
}

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ public static function getSubscribedServices(): array
5252

5353
/**
5454
* @required
55-
*
56-
* @return ContainerInterface|null
5755
*/
58-
public function setContainer(ContainerInterface $container)
56+
public function setContainer(ContainerInterface $container): ?ContainerInterface
5957
{
6058
$this->container = $container;
6159

src/Symfony/Contracts/Service/Test/ServiceLocatorTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
abstract class ServiceLocatorTest extends TestCase
1919
{
20-
/**
21-
* @return ContainerInterface
22-
*/
23-
protected function getServiceLocator(array $factories)
20+
protected function getServiceLocator(array $factories): ContainerInterface
2421
{
2522
return new class($factories) implements ContainerInterface {
2623
use ServiceLocatorTrait;
< 10000 /div>

src/Symfony/Contracts/Service/composer.json

Lines changed: 2 additions & 2 deletions
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"
20+
"psr/container": "^1.1|^2.0"
2121
},
2222
"conflict": {
2323
"ext-psr": "<1.1|>=2"
@@ -31,7 +31,7 @@
3131
"minimum-stability": "dev",
3232
"extra": {
3333
"branch-alias": {
34-
"dev-main": "2.5-dev"
34+
"dev-main": "3.0-dev"
3535
},
3636
"thanks": {
3737
"name": "symfony/contracts",

src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ public function aParentService(): Service1
4242
{
4343
}
4444

45-
/**
46-
* @return ?ContainerInterface
47-
*/
48-
public function setContainer(ContainerInterface $container)
45+
public function setContainer(ContainerInterface $container): ?ContainerInterface
4946
{
5047
return $container;
5148
}

src/Symfony/Contracts/Translation/LocaleAwareInterface.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@ interface LocaleAwareInterface
1616
/**
1717
* Sets the current locale.
1818
*
19-
* @param string $locale The locale
20-
*
2119
* @throws \InvalidArgumentException If the locale contains invalid characters
2220
*/
2321
public function setLocale(string $locale);
2422

2523
/**
2624
* Returns the current locale.
27-
*
28-
* @return string The locale
2925
*/
30-
public function getLocale();
26+
public function getLocale(): string;
3127
}

src/Symfony/Contracts/Translation/Test/TranslatorTest.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ protected function tearDown(): void
4343
\Locale::setDefault($this->defaultLocale);
4444
}
4545

46-
/**
47-
* @return TranslatorInterface
48-
*/
49-
public function getTranslator()
46+
public function getTranslator(): TranslatorInterface
5047
{
5148
return new class() implements TranslatorInterface {
5249
use TranslatorTrait;
@@ -317,10 +314,8 @@ public function testLangcodes($nplural, $langCodes)
317314
* This array should contain all currently known langcodes.
318315
*
319316
* As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
320-
*
321-
* @return array
322317
*/
323-
public function successLangcodes()
318+
public function successLangcodes(): array
324319
{
325320
return [
326321
['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
@@ -339,7 +334,7 @@ public function successLangcodes()
339334
*
340335
* @return array with nplural together with langcodes
341336
*/
342-
public function failingLangcodes()
337+
public function failingLangcodes(): array
343338
{
344339
return [
345340
['1', ['fa']],
@@ -353,11 +348,10 @@ public function failingLangcodes()
353348
/**
354349
* We validate only on the plural coverage. Thus the real rules is not tested.
355350
*
356-
* @param string $nplural Plural expected
357-
* @param array $matrix Containing langcodes and their plural index values
358-
* @param bool $expectSuccess
351+
* @param string $nplural Plural expected
352+
* @param array $matrix Containing langcodes and their plural index values
359353
*/
360-
protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
354+
protected function validateMatrix(string $nplural, array $matrix, bool $expectSuccess = true)
361355
{
362356
foreach ($matrix as $langCode => $data) {
363357
$indexes = array_flip($data);

0 commit comments

Comments
 (0)
0