Skip to content

Commit

Permalink
minor #33242 [DI] add return-types to generated containers (nicolas-g…
Browse files Browse the repository at this point in the history
…rekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DI] add return-types to generated containers

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

A chunk of #33236 ready for 4.4

Commits
-------

9170919 [DI] add return-types to generated containers
  • Loading branch information
fabpot committed Aug 19, 2019
2 parents c098374 + 9170919 commit b681e93
Show file tree
Hide file tree
Showing 48 changed files with 350 additions and 610 deletions.
33 changes: 10 additions & 23 deletions src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
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
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
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
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
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
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
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
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

0 comments on commit b681e93

Please sign in to comment.