8000 feature #42088 [Contracts] add return types and bump to v3 (nicolas-g… · symfony/symfony@b28f7e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit b28f7e7

Browse files
committed
feature #42088 [Contracts] add return types and bump to v3 (nicolas-grekas)
This PR was merged into the 6.0 branch. Discussion ---------- [Contracts] add return types and bump to v3 | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #42058 | License | MIT | Doc PR | - Commits ------- 44b1a7a [Contracts] add return types and bump to v3
2 parents f821d76 + 44b1a7a commit b28f7e7

File tree

92 files changed

+143
-185
lines changed

Some content is hidden

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

92 files changed

+143
-185
lines changed

composer.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
"provide": {
1919
"php-http/async-client-implementation": "*",
2020
"php-http/client-implementation": "*",
21-
"psr/cache-implementation": "1.0|2.0|3.0",
22-
"psr/container-implementation": "1.0",
21+
"psr/cache-implementation": "2.0|3.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",
2626
"psr/log-implementation": "1.0",
2727
"psr/simple-cache-implementation": "1.0",
28-
"symfony/cache-implementation": "1.0|2.0",
29-
"symfony/event-dispatcher-implementation": "2.0",
30-
"symfony/http-client-implementation": "2.4",
31-
"symfony/service-implementation": "1.0|2.0",
32-
"symfony/translation-implementation": "2.3"
28+
"symfony/cache-implementation": "1.1|2.0|3.0",
29+
"symfony/event-dispatcher-implementation": "2.0|3.0",
30+
"symfony/http-client-implementation": "2.5|3.0",
31+
"symfony/service-implementation": "1.1|2.0|3.0",
32+
"symfony/translation-implementation": "2.3|3.0"
3333
},
3434
"require": {
3535
"php": ">=8.0.2",
@@ -38,12 +38,12 @@
3838
"doctrine/event-manager": "~1.0",
3939
"doctrine/persistence": "^2",
4040
"twig/twig": "^2.13|^3.0.4",
41-
"psr/cache": "^1.0|^2.0|^3.0",
42-
"psr/container": "^1.0",
41+
"psr/cache": "^2.0|^3.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/Bridge/Doctrine/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"php": ">=8.0.2",
2020
"doctrine/event-manager": "~1.0",
2121
"doctrine/persistence": "^2",
22-
"symfony/deprecation-contracts": "^2.1",
22+
"symfony/deprecation-contracts": "^2.1|^3.0",
2323
"symfony/polyfill-ctype": "~1.8",
2424
"symfony/polyfill-mbstring": "~1.0",
25-
"symfony/service-contracts": "^1.1|^2"
25+
"symfony/service-contracts": "^1.1|^2.0|^3.0"
2626
},
2727
"require-dev": {
2828
"composer/package-versions-deprecated": "^1.8",

src/Symfony/Bridge/Monolog/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.0.2",
2020
"monolog/monolog": "^1.25.1|^2",
21-
"symfony/service-contracts": "^1.1|^2",
21+
"symfony/service-contracts": "^1.1|^2.0|^3.0",
2222
"symfony/http-kernel": "^5.4|^6.0"
2323
},
2424
"require-dev": {

src/Symfony/Bridge/PhpUnit/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"php": ">=7.1.3"
2222
},
2323
"require-dev": {
24-
"symfony/deprecation-contracts": "^2.1",
24+
"symfony/deprecation-contracts": "^2.1|^3.0",
2525
"symfony/error-handler": "^5.4|^6.0"
2626
},
2727
"suggest": {

src/Symfony/Bridge/Twig/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.0.2",
20-
"symfony/translation-contracts": "^1.1|^2",
20+
"symfony/translation-contracts": "^1.1|^2.0|^3.0",
2121
"twig/twig": "^2.13|^3.0.4"
2222
},
2323
"require-dev": {

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/FrameworkBundle/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/cache": "^5.4|^6.0",
2222
"symfony/config": "^5.4|^6.0",
2323
"symfony/dependency-injection": "^5.4|^6.0",
24-
"symfony/deprecation-contracts": "^2.1",
24+
"symfony/deprecation-contracts": "^2.1|^3.0",
2525
"symfony/event-dispatcher": "^5.4|^6.0",
2626
"symfony/error-handler": "^5.4|^6.0",
2727
"symfony/http-foundation": "^5.4|^6.0",

src/Symfony/Bundle/SecurityBundle/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"ext-xml": "*",
2121
"symfony/config": "^5.4|^6.0",
2222
"symfony/dependency-injection": "^5.4|^6.0",
23-
"symfony/deprecation-contracts": "^2.1",
23+
"symfony/deprecation-contracts": "^2.1|^3.0",
2424
"symfony/event-dispatcher": "^5.4|^6.0",
2525
"symfony/http-kernel": "^5.4|^6.0",
2626
"symfony/http-foundation": "^5.4|^6.0",

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

Expand all lines: 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/Cache/composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"provide": {
1919
"psr/cache-implementation": "2.0|3.0",
2020
"psr/simple-cache-implementation": "1.0",
21-
"symfony/cache-implementation": "1.0|2.0"
21+
"symfony/cache-implementation": "1.1|2.0|3.0"
2222
},
2323
"require": {
2424
"php": ">=8.0.2",
2525
"psr/cache": "^2.0|^3.0",
2626
"psr/log": "^1.1",
27-
"symfony/cache-contracts": "^1.1.7|^2",
28-
"symfony/deprecation-contracts": "^2.1",
29-
"symfony/service-contracts": "^1.1|^2",
27+
"symfony/cache-contracts": "^1.1.7|^2.0|^3.0",
28+
"symfony/deprecation-contracts": "^2.1|^3.0",
29+
"symfony/service-contracts": "^1.1|^2.0|^3.0",
3030
"symfony/var-exporter": "^5.4|^6.0"
3131
},
3232
"require-dev": {

src/Symfony/Component/Config/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-
"symfony/deprecation-contracts": "^2.1",
20+
"symfony/deprecation-contracts": "^2.1|^3.0",
2121
"symfony/filesystem": "^5.4|^6.0",
2222
"symfony/polyfill-ctype": "~1.8",
2323
"symfony/polyfill-php81": "^1.22"
@@ -26,7 +26,7 @@
2626
"symfony/event-dispatcher": "^5.4|^6.0",
2727
"symfony/finder": "^5.4|^6.0",
2828
"symfony/messenger": "^5.4|^6.0",
29-
"symfony/service-contracts": "^1.1|^2",
29+
"symfony/service-contracts": "^1.1|^2.0|^3.0",
3030
"symfony/yaml": "^5.4|^6.0"
3131
},
3232
"conflict": {

src/Symfony/Component/Console/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.0.2",
2020
"symfony/polyfill-mbstring": "~1.0",
21-
"symfony/service-contracts": "^1.1|^2",
21+
"symfony/service-contracts": "^1.1|^2.0|^3.0",
2222
"symfony/string": "^5.4|^6.0"
2323
},
2424
"require-dev": {

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
}

0 commit comments

Comments
 (0)
0