Skip to content

[DI] add return-types to generated containers #33242

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
Aug 19, 2019
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
33 changes: 10 additions & 23 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1030,12 +1030,13 @@ private function startClass(string $class, string $baseClass, string $baseClassW
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/*{$this->docStar}
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class $class extends $baseClass
{
Expand Down Expand Up @@ -1088,12 +1089,12 @@ public function __construct()
$code .= <<<EOF
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}
Expand Down Expand Up @@ -1184,7 +1185,7 @@ private function addRemovedIds(): string

return <<<EOF

public function getRemovedIds()
public function getRemovedIds(): array
{
return {$code};
}
Expand Down Expand Up @@ -1363,7 +1364,7 @@ public function getParameter($name)
return $this->parameters[$name];
}

public function hasParameter($name)
public function hasParameter($name): bool
{
$name = (string) $name;
if (isset($this->buildParameters[$name])) {
Expand All @@ -1373,12 +1374,12 @@ public function hasParameter($name)
return isset($this->parameters[$name]) || isset($this->loadedDynamicParameters[$name]) || array_key_exists($name, $this->parameters);
}

public function setParameter($name, $value)
public function setParameter($name, $value): void
{
throw new LogicException('Impossible to call set() on a frozen ParameterBag.');
}

public function getParameterBag()
public function getParameterBag(): ParameterBagInterface
{
if (null === $this->parameterBag) {
$parameters = $this->parameters;
Expand Down Expand Up @@ -1421,26 +1422,12 @@ public function getParameterBag()
private \$loadedDynamicParameters = {$loadedDynamicParameters};
private \$dynamicParameters = [];

/*{$this->docStar}
* Computes a dynamic parameter.
*
* @param string \$name The name of the dynamic parameter to load
*
* @return mixed The value of the dynamic parameter
*
* @throws InvalidArgumentException When the dynamic parameter does not exist
*/
private function getDynamicParameter(\$name)
private function getDynamicParameter(string \$name)
{
{$getDynamicParameter}
}

/*{$this->docStar}
* Gets the default parameters.
*
* @return array An array of the default parameters
*/
protected function getDefaultParameters()
protected function getDefaultParameters(): array
{
return $parameters;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class Symfony_DI_PhpDumper_Test_Aliases_Deprecation extends Container
{
Expand All @@ -31,17 +32,17 @@ public function __construct()
];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithoutArgumentsContainer
{
Expand All @@ -31,17 +32,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithMandatoryArgumentsContainer
{
Expand All @@ -28,17 +29,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\ConstructorWithOptionalArgumentsContainer
{
Expand All @@ -31,17 +32,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class ProjectServiceContainer extends \Symfony\Component\DependencyInjection\Tests\Fixtures\Container\NoConstructorContainer
{
Expand All @@ -28,17 +29,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer
{
Expand All @@ -28,17 +29,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;

/**
* This class has been auto-generated
* by the Symfony Dependency Injection Component.
*
* @final since Symfony 3.3
* @final
*/
class ProjectServiceContainer extends Container
{
Expand All @@ -26,17 +27,17 @@ public function __construct()
$this->aliases = [];
}

public function compile()
public function compile(): void
{
throw new LogicException('You cannot compile a dumped container that was already compiled.');
}

public function isCompiled()
public function isCompiled(): bool
{
return true;
}

public function getRemovedIds()
public function getRemovedIds(): array
{
return [
'Psr\\Container\\ContainerInterface' => true,
Expand Down
Loading