Skip to content

[Contracts] add return types and bump to v3 #42088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"provide": {
"php-http/async-client-implementation": "*",
"php-http/client-implementation": "*",
"psr/cache-implementation": "1.0|2.0|3.0",
"psr/container-implementation": "1.0",
"psr/cache-implementation": "2.0|3.0",
"psr/container-implementation": "1.1|2.0",
"psr/event-dispatcher-implementation": "1.0",
"psr/http-client-implementation": "1.0",
"psr/link-implementation": "1.0",
"psr/log-implementation": "1.0",
"psr/simple-cache-implementation": "1.0",
"symfony/cache-implementation": "1.0|2.0",
"symfony/event-dispatcher-implementation": "2.0",
"symfony/http-client-implementation": "2.4",
"symfony/service-implementation": "1.0|2.0",
"symfony/translation-implementation": "2.3"
"symfony/cache-implementation": "1.1|2.0|3.0",
"symfony/event-dispatcher-implementation": "2.0|3.0",
"symfony/http-client-implementation": "2.5|3.0",
"symfony/service-implementation": "1.1|2.0|3.0",
"symfony/translation-implementation": "2.3|3.0"
},
"require": {
"php": ">=8.0.2",
Expand All @@ -38,12 +38,12 @@
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "^2",
"twig/twig": "^2.13|^3.0.4",
"psr/cache": "^1.0|^2.0|^3.0",
"psr/container": "^1.0",
"psr/cache": "^2.0|^3.0",
"psr/container": "^1.1|^2.0",
"psr/event-dispatcher": "^1.0",
"psr/link": "^1.1",
"psr/log": "~1.0",
"symfony/contracts": "^2.5",
"symfony/contracts": "^2.5|^3.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-icu": "~1.0",
Expand Down Expand Up @@ -186,7 +186,7 @@
"url": "src/Symfony/Contracts",
"options": {
"versions": {
"symfony/contracts": "2.5.x-dev"
"symfony/contracts": "3.0.x-dev"
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"php": ">=8.0.2",
"doctrine/event-manager": "~1.0",
"doctrine/persistence": "^2",
"symfony/deprecation-contracts": "^2.1",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0",
"symfony/service-contracts": "^1.1|^2"
"symfony/service-contracts": "^1.1|^2.0|^3.0"
},
"require-dev": {
"composer/package-versions-deprecated": "^1.8",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Monolog/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=8.0.2",
"monolog/monolog": "^1.25.1|^2",
"symfony/service-contracts": "^1.1|^2",
"symfony/service-contracts": "^1.1|^2.0|^3.0",
"symfony/http-kernel": "^5.4|^6.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/PhpUnit/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"php": ">=7.1.3"
},
"require-dev": {
"symfony/deprecation-contracts": "^2.1",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/error-handler": "^5.4|^6.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=8.0.2",
"symfony/translation-contracts": "^1.1|^2",
"symfony/translation-contracts": "^1.1|^2.0|^3.0",
"twig/twig": "^2.13|^3.0.4"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function isOptional()
/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'translator' => TranslatorInterface::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getParameter(string $name)
return $this->container->get('parameter_bag')->get($name);
}

public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'router' => '?'.RouterInterface::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private function resolve(mixed $value): mixed
/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'routing.loader' => LoaderInterface::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Translation\Loader\LoaderInterface;
use Symfony\Component\Translation\Loader\YamlFileLoader;
use Symfony\Component\Translation\MessageCatalogue;
use Symfony\Contracts\Translation\TranslatorInterface;

class TranslatorTest extends TestCase
{
Expand Down Expand Up @@ -310,7 +311,7 @@ protected function getContainer($loader)
return $container;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"symfony/cache": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/deprecation-contracts": "^2.1",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/error-handler": "^5.4|^6.0",
"symfony/http-foundation": "^5.4|^6.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"ext-xml": "*",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/deprecation-contracts": "^2.1",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/http-foundation": "^5.4|^6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function isOptional()
/**
* {@inheritdoc}
*/
public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return [
'twig' => Environment::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function deleteItems(array $keys): bool
/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags)
public function invalidateTags(array $tags): bool
{
if (empty($tags)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static function ($key, $value, $isHit) {
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
$item = $this->getItem($key);
$metadata = $item->getMetadata();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ChainAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static function ($sourceItem, $item, $defaultLifetime, $sourceMetadata = null) {
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
$lastItem = null;
$i = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/NullAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static function ($key) {
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
$save = true;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/PhpArrayAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static function create(string $file, CacheItemPoolInterface $fallbackPool
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
if (!isset($this->values)) {
$this->initialize();
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static function (CacheItemInterface $innerItem, array $item) {
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
if (!$this->pool instanceof CacheInterface) {
return $this->doGet($this, $key, $callback, $beta, $metadata);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static function (AdapterInterface $tagsAdapter, array $tags) {
/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags)
public function invalidateTags(array $tags): bool
{
$ok = true;
$tagsByKey = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ interface TagAwareAdapterInterface extends AdapterInterface
*
* @throws InvalidArgumentException When $tags is not valid
*/
public function invalidateTags(array $tags);
public function invalidateTags(array $tags): bool;
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/TraceableAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(AdapterInterface $pool)
/**
* {@inheritdoc}
*/
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null)
public function get(string $key, callable $callback, float $beta = null, array &$metadata = null): mixed
{
if (!$this->pool instanceof CacheInterface) {
throw new \BadMethodCallException(sprintf('Cannot call "%s::get()": this class doesn\'t implement "%s".', get_debug_type($this->pool), CacheInterface::class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(TagAwareAdapterInterface $pool)
/**
* {@inheritdoc}
*/
public function invalidateTags(array $tags)
public function invalidateTags(array $tags): bool
{
$event = $this->start(__FUNCTION__);
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function expiresAfter(mixed $time): static
/**
* {@inheritdoc}
*/
public function tag(mixed $tags): ItemInterface
public function tag(mixed $tags): static
{
if (!$this->isTaggable) {
throw new LogicException(sprintf('Cache item "%s" comes from a non tag-aware pool: you cannot tag it.', $this->key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(int $value)
$this->value = $value;
}

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

Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
"provide": {
"psr/cache-implementation": "2.0|3.0",
"psr/simple-cache-implementation": "1.0",
"symfony/cache-implementation": "1.0|2.0"
"symfony/cache-implementation": "1.1|2.0|3.0"
},
"require": {
"php": ">=8.0.2",
"psr/cache": "^2.0|^3.0",
"psr/log": "^1.1",
"symfony/cache-contracts": "^1.1.7|^2",
"symfony/deprecation-contracts": "^2.1",
"symfony/service-contracts": "^1.1|^2",
"symfony/cache-contracts": "^1.1.7|^2.0|^3.0",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/service-contracts": "^1.1|^2.0|^3.0",
"symfony/var-exporter": "^5.4|^6.0"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Config/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"require": {
"php": ">=8.0.2",
"symfony/deprecation-contracts": "^2.1",
"symfony/deprecation-contracts": "^2.1|^3.0",
"symfony/filesystem": "^5.4|^6.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-php81": "^1.22"
Expand All @@ -26,7 +26,7 @@
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/finder": "^5.4|^6.0",
"symfony/messenger": "^5.4|^6.0",
"symfony/service-contracts": "^1.1|^2",
"symfony/service-contracts": "^1.1|^2.0|^3.0",
"symfony/yaml": "^5.4|^6.0"
},
"conflict": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=8.0.2",
"symfony/polyfill-mbstring": "~1.0",
"symfony/service-contracts": "^1.1|^2",
"symfony/service-contracts": "^1.1|^2.0|^3.0",
"symfony/string": "^5.4|^6.0"
},
"require-dev": {
Expand Down
9 changes: 1 addition & 8 deletions src/Symfony/Component/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,7 @@ public function set(string $id, ?object $service)
$this->services[$id] = $service;
}

/**
* Returns true if the given service is defined.
*
* @param string $id The service identifier
*
* @return bool true if the service is defined, false otherwise
*/
public function has(string $id)
public function has(string $id): bool
{
if (isset($this->aliases[$id])) {
$id = $this->aliases[$id];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,7 @@ public function removeDefinition(string $id)
}
}

/**
* Returns true if the given service is defined.
*
* @param string $id The service identifier
*
* @return bool true if the service is defined, false otherwise
*/
public function has(string $id)
public function has(string $id): bool
{
return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || parent::has($id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALI
/**
* @return bool true if the service is defined, false otherwise
*/
public function has(string $id);
public function has(string $id): bool;

/**
* Check for whether or not a service has been initialized.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ public function get(string $name)

/**
* {@inheritdoc}
*
* @return bool
*/
public function has(string $name)
public function has(string $name): bool
{
return $this->container->hasParameter($name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class ServiceLocatorTest extends BaseServiceLocatorTest
{
public function getServiceLocator(array $factories)
public function getServiceLocator(array $factories): ServiceLocator
{
return new ServiceLocator($factories);
}
Expand Down
Loading