diff --git a/src/Builder.php b/src/Builder.php index 0393805b..32128143 100644 --- a/src/Builder.php +++ b/src/Builder.php @@ -15,13 +15,6 @@ interface Builder { public const DEFAULT_PRIORITY = 0; - /** - * Changes the generator to handle the files - * - * @deprecated This is deprecated in favour of using the correct naming constructor. - */ - public function setGenerator(Generator $generator): Builder; - /** * Add a file to be loaded */ @@ -58,15 +51,6 @@ public function addPackage(string $className, array $constructArguments = []): B */ public function setProfileName(string $profileName): Builder; - /** - * Mark the container to be used as development mode - * - * @deprecated this method will be removed in favour of a more explicit name. - * - * @see enableDebugging - */ - public function useDevelopmentMode(): Builder; - /** * Configure the container to track file updates */ diff --git a/src/Compiler.php b/src/Compiler.php index 95209cf0..81e0f7e7 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -18,7 +18,8 @@ use function is_array; use function is_string; -final class Compiler +/** @internal */ +final readonly class Compiler { private const DEFAULT_PASS_CONFIG = [null, PassConfig::TYPE_BEFORE_OPTIMIZATION, 0]; @@ -82,7 +83,7 @@ private function getContainerContent( $options['as_files'] = true; $options['inline_factories'] = $options['debug'] === false; - $options['inline_class_loader'] = $options['debug'] === false; + $options['inline_class_loader'] = $options['inline_factories']; $content = (new PhpDumper($container))->dump($options); assert(is_array($content)); diff --git a/src/Compiler/DumpXmlContainer.php b/src/Compiler/DumpXmlContainer.php index 3fdb61a6..d15f5b78 100644 --- a/src/Compiler/DumpXmlContainer.php +++ b/src/Compiler/DumpXmlContainer.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Dumper\XmlDumper; -final class DumpXmlContainer implements CompilerPassInterface +final readonly class DumpXmlContainer implements CompilerPassInterface { public function __construct(private ConfigCacheInterface $configCache) { diff --git a/src/Compiler/ParameterBag.php b/src/Compiler/ParameterBag.php index 36b057a0..2e36f70b 100644 --- a/src/Compiler/ParameterBag.php +++ b/src/Compiler/ParameterBag.php @@ -10,6 +10,8 @@ * Injects parameters into the container * * You should use this to define dynamic parameters using PHP + * + * @internal */ final class ParameterBag implements CompilerPassInterface { diff --git a/src/Config/ContainerConfiguration.php b/src/Config/ContainerConfiguration.php index c64378d9..bc83186d 100644 --- a/src/Config/ContainerConfiguration.php +++ b/src/Config/ContainerConfiguration.php @@ -20,6 +20,7 @@ use const DIRECTORY_SEPARATOR; +/** @internal */ final class ContainerConfiguration { public const CLASS_NAME = 'AppContainer'; diff --git a/src/ContainerBuilder.php b/src/ContainerBuilder.php index 9aa752e9..5015b8bb 100644 --- a/src/ContainerBuilder.php +++ b/src/ContainerBuilder.php @@ -15,7 +15,7 @@ use function assert; use function is_bool; -final class ContainerBuilder implements Builder +final readonly class ContainerBuilder implements Builder { public function __construct( private ContainerConfiguration $config, @@ -25,19 +25,6 @@ public function __construct( $this->setDefaultConfiguration(); } - /** - * @deprecated Use the named constructor according to the generator - * - * @see ContainerBuilder::xml() - * @see ContainerBuilder::yaml() - * @see ContainerBuilder::php() - * @see ContainerBuilder::delegating() - */ - public static function default(string $configurationFile, string $namespace): self - { - return self::xml($configurationFile, $namespace); - } - /** @param class-string $builderClass */ public static function xml( string $configurationFile, @@ -100,13 +87,6 @@ private function setDefaultConfiguration(): void $this->config->addPass($this->parameterBag); } - public function setGenerator(Generator $generator): Builder - { - $this->generator = $generator; - - return $this; - } - public function addFile(string $file): Builder { $this->config->addFile($file); @@ -151,11 +131,6 @@ public function setProfileName(string $profileName): Builder return $this; } - public function useDevelopmentMode(): Builder - { - return $this->enableDebugging(); - } - public function enableDebugging(): Builder { $this->parameterBag->set('app.devmode', true); diff --git a/src/Generator.php b/src/Generator.php index 3c81d4e3..67ce764f 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -13,14 +13,15 @@ use function assert; use function is_a; -abstract class Generator +/** @internal */ +abstract readonly class Generator { private Compiler $compiler; /** @param class-string $builderClass */ public function __construct( - private readonly string $configurationFile, - private readonly string $builderClass = SymfonyBuilder::class, + private string $configurationFile, + private string $builderClass = SymfonyBuilder::class, ) { $this->compiler = new Compiler(); } diff --git a/src/Generators/Delegating.php b/src/Generators/Delegating.php index 4e0eb481..ed9f3739 100644 --- a/src/Generators/Delegating.php +++ b/src/Generators/Delegating.php @@ -15,8 +15,10 @@ /** * The dependency injection generator that allows XML, YAML and PHP files + * + * @internal */ -final class Delegating extends Generator +final readonly class Delegating extends Generator { /** @inheritDoc */ public function getLoader(SymfonyBuilder $container, array $paths, ?string $profileName = null): LoaderInterface diff --git a/src/Generators/Php.php b/src/Generators/Php.php index 85c34b00..b15ed9fc 100644 --- a/src/Generators/Php.php +++ b/src/Generators/Php.php @@ -11,8 +11,10 @@ /** * The dependency injection generator for PHP files + * + * @internal */ -final class Php extends Generator +final readonly class Php extends Generator { /** @inheritDoc */ public function getLoader(SymfonyBuilder $container, array $paths, ?string $profileName = null): LoaderInterface diff --git a/src/Generators/Xml.php b/src/Generators/Xml.php index dba92122..3b1242c9 100644 --- a/src/Generators/Xml.php +++ b/src/Generators/Xml.php @@ -11,8 +11,10 @@ /** * The dependency injection generator for XML files + * + * @internal */ -final class Xml extends Generator +final readonly class Xml extends Generator { /** @inheritDoc */ public function getLoader(SymfonyBuilder $container, array $paths, ?string $profileName = null): LoaderInterface diff --git a/src/Generators/Yaml.php b/src/Generators/Yaml.php index 668057ba..e33222f2 100644 --- a/src/Generators/Yaml.php +++ b/src/Generators/Yaml.php @@ -11,8 +11,10 @@ /** * The dependency injection generator for YAML files + * + * @internal */ -final class Yaml extends Generator +final readonly class Yaml extends Generator { /** @inheritDoc */ public function getLoader(SymfonyBuilder $container, array $paths, ?string $profileName = null): LoaderInterface diff --git a/src/Testing/MakeServicesPublic.php b/src/Testing/MakeServicesPublic.php index 1f2fbc45..a4ee234f 100644 --- a/src/Testing/MakeServicesPublic.php +++ b/src/Testing/MakeServicesPublic.php @@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; +/** @internal */ final class MakeServicesPublic implements CompilerPassInterface { /** diff --git a/test/ContainerBuilderTest.php b/test/ContainerBuilderTest.php index d61f4bb7..19900330 100644 --- a/test/ContainerBuilderTest.php +++ b/test/ContainerBuilderTest.php @@ -59,7 +59,6 @@ public function namedConstructorsShouldSimplifyTheObjectCreation( /** @return iterable}> */ public static function supportedFormats(): iterable { - yield 'default' => ['default', new Generators\Xml(__FILE__)]; yield 'xml' => ['xml', new Generators\Xml(__FILE__)]; yield 'yaml' => ['yaml', new Generators\Yaml(__FILE__)]; yield 'php' => ['php', new Generators\Php(__FILE__)]; @@ -99,18 +98,6 @@ public function constructShouldReceiveTheDependenciesAsArguments(): void self::assertFalse($this->parameterBag->get('app.devmode')); } - #[PHPUnit\Test] - public function setGeneratorShouldChangeTheAttributeAndReturnSelf(): void - { - $builder = new ContainerBuilder($this->config, $this->generator, $this->parameterBag); - $generator = $this->createMock(Generator::class); - $expected = new ContainerBuilder($this->config, $generator, $this->parameterBag); - - // @phpstan-ignore-next-line method is deprecated and will be removed in the next major version - self::assertSame($builder, $builder->setGenerator($generator)); - self::assertEquals($expected, $builder); - } - #[PHPUnit\Test] public function addFileShouldAppendANewFileOnTheListAndReturnSelf(): void {