8000 Add missing `@return` annotations to fix deprecations on PHP 8 by nicolas-grekas · Pull Request #39614 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add missing @return annotations to fix deprecations on PHP 8 #39614

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
Dec 23, 2020
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
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ before_install:
if [[ $PHP = 8.* ]]; then
tfold ext.memcached tpecl memcached-3.1.5 memcached.so $INI
else
tfold ext.mongodb tpecl mongodb-1.6.16 mongodb.so $INI
tfold ext.mongodb tpecl mongodb-1.8.1 mongodb.so $INI
tfold ext.zookeeper tpecl zookeeper-0.7.2 zookeeper.so $INI
tfold ext.amqp tpecl amqp-1.10.2 amqp.so $INI
fi
Expand Down Expand Up @@ -215,13 +215,6 @@ install:
export COMPONENTS=$(find src/Symfony -mindepth 2 -type f -name phpunit.xml.dist -not -wholename '*/Bridge/PhpUnit/*' -printf '%h\n' | sort)
fi

- |
# Set composer's platform to php 7.4 if we're on php 8.
if [[ $PHP = 8.* ]]; then
composer config platform.php 7.4.99
export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
fi

- |
# Install symfony/flex
if [[ $deps = low ]]; then
Expand Down Expand Up @@ -262,7 +255,7 @@ install:
fi
phpenv global $PHP
rm vendor/composer/package-versions-deprecated -Rf
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer config platform.ext-mongodb 1.6.99; composer require --dev --no-update mongodb/mongodb ~1.5.0)
([[ $deps ]] && cd src/Symfony/Component/HttpFoundation; cp composer.json composer.bak; composer config platform.ext-mongodb 1.8.99; composer require --dev --no-update mongodb/mongodb ^1.8.1)
tfold 'composer update' $COMPOSER_UP
tfold 'phpunit install' ./phpunit install
if [[ $deps = high ]]; then
Expand All @@ -279,7 +272,7 @@ install:
git fetch --depth=2 origin $SYMFONY_VERSION
git checkout -m FETCH_HEAD
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort)
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.6.99; composer require --dev --no-update mongodb/mongodb)
(cd src/Symfony/Component/HttpFoundation; composer config platform.ext-mongodb 1.8.99; composer require --dev --no-update mongodb/mongodb)
[[ ! $COMPONENTS ]] || tfold 'phpunit install' SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT=1 ./phpunit install
[[ ! $COMPONENTS ]] || echo "$COMPONENTS" | parallel --gnu "tfold {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT_X$LEGACY'" || X=1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class StringWrapperType extends StringType
{
/**
* {@i 6D47 nheritdoc}
*
* @return mixed
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
Expand All @@ -26,6 +28,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)

/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $pla

/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
Expand All @@ -58,6 +60,8 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)

/**
* {@inheritdoc}
*
* @return mixed
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Monolog/Formatter/ConsoleFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public function __construct(array $options = [])

/**
* {@inheritdoc}
*
* @return mixed
*/
public function formatBatch(array $records)
{
Expand All @@ -95,6 +97,8 @@ public function formatBatch(array $records)

/**
* {@inheritdoc}
*
* @return mixed
*/
public function format(array $record)
{
Expand Down
10 changes: 10 additions & 0 deletions src/Symfony/Bridge/Monolog/Formatter/VarDumperFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function __construct(VarCloner $cloner = null)
$this->cloner = $cloner ?: new VarCloner();
}

/**
* {@inheritdoc}
*
* @return mixed
*/
public function format(array $record)
{
$record['context'] = $this->cloner->cloneVar($record['context']);
Expand All @@ -34,6 +39,11 @@ public function format(array $record)
return $record;
}

/**
* {@inheritdoc}
*
* @return mixed
*/
public function formatBatch(array $records)
{
foreach ($records as $k => $record) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function setContainer(ContainerInterface $container): ?ContainerInterface
/**
* Gets a container parameter by its name.
*
* @return mixed
* @return array|bool|float|int|string|null
*
* @final
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class Controller implements ContainerAwareInterface
/**
* Gets a container configuration parameter by its name.
*
* @return mixed
* @return array|bool|float|int|string|null
*
* @final
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function __construct(ContainerInterface $container, ContainerInterface $s

/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public function getParameterBag(): ParameterBagInterface

/**
* {@inheritdoc}
*
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function getKey(): string

/**
* {@inheritdoc}
*
* @return mixed
*/
public function get()
{
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Cache/Psr16Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) {

/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($key, $default = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function __construct(\Closure $factory, array $serviceMap, array $service

/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getParameterBag()
*
* @param string $name The parameter name
*
* @return mixed The parameter value
* @return array|bool|float|int|string|null The parameter value
*
* @throws InvalidArgumentException if the parameter is not defined
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function initialized($id);
*
* @param string $name The parameter name
*
* @return mixed The parameter value
* @return array|bool|float|int|string|null The parameter value
*
* @throws InvalidArgumentException if the parameter is not defined
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,9 @@ private function addDefaultParametersMethod(): string

$code = <<<'EOF'

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/DependencyInjection/ServiceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ServiceLocator implements ServiceProviderInterface
private $externalId;
private $container;

/**
* {@inheritdoc}
*
* @return mixed
*/
public function get($id)
{
if (!$this->externalId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ public function __construct(ServiceLocator $locator)
$this->locator = $locator;
}

/**
* @return mixed
*/
public function get($id)
{
return $this->locator->get($id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ protected fu 10000 nction getTestService()
return $this->services['test'] = new \stdClass(['only dot' => '.', 'concatenation as value' => '.\'\'.', 'concatenation from the start value' => '\'\'.', '.' => 'dot as a key', '.\'\'.' => 'concatenation as a key', '\'\'.' => 'concatenation from the start key', 'optimize concatenation' => 'string1-string2', 'optimize concatenation with empty string' => 'string1string2', 'optimize concatenation from the start' => 'start', 'optimize concatenation at the end' => 'end', 'new line' => 'string with '."\n".'new line']);
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ protected function getTestService()
return $this->services['test'] = new \stdClass(('file://'.\dirname(__DIR__, 1)), [('file://'.\dirname(__DIR__, 1)) => (\dirname(__DIR__, 2).'/')]);
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ protected function getServiceWithMethodCallAndFactoryService()
return $instance;
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected function getTestService()
return $this->services['test'] = new ${($_ = $this->getEnv('FOO')) && false ?: "_"}($this->getEnv('Bar'), 'foo'.$this->getEnv('string:FOO').'baz', $this->getEnv('int:Baz'));
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getRemovedIds(): array
];
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ class ProjectServiceContainer extends Container
return $instance;
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ protected function getFactorySimpleService()
return new \SimpleFactoryClass('foo');
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ class ProjectServiceContainer extends Container
return new \SimpleFactoryClass('foo');
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class ProjectServiceContainer extends Container
return new \Bar\FooClass(new \Bar\FooLazyClass());
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ protected function getBarService()
return $instance;
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getRemovedIds(): array
];
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getRemovedIds(): array
];
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function getRemovedIds(): array
];
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ protected function getFooService()
return $this->services['foo'] = new \stdClass(($this->privates['bar_%env(BAR)%'] ?? ($this->privates['bar_%env(BAR)%'] = new \stdClass())), ['baz_'.$this->getEnv('string:BAR') => new \stdClass()]);
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ protected function getFactorySimpleService()
return new \SimpleFactoryClass('foo');
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ protected function getC2Service()
return $this->services['Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\includes\\HotPath\\C2'] = new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C2(new \Symfony\Component\DependencyInjection\Tests\Fixtures\includes\HotPath\C3());
}

/**
* @return array|bool|float|int|string|null
*/
public function getParameter($name)
{
$name = (string) $name;
Expand Down
Loading
0