Skip to content

Commit

Permalink
Merge pull request #539 from lcobucci/clean-up-for-new-major
Browse files Browse the repository at this point in the history
Prepare for new major release
  • Loading branch information
lcobucci authored Nov 10, 2024
2 parents f4b8a7b + 2ffdcc7 commit 3b74ea3
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 65 deletions.
16 changes: 0 additions & 16 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/DumpXmlContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Compiler/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 1 addition & 0 deletions src/Config/ContainerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use const DIRECTORY_SEPARATOR;

/** @internal */
final class ContainerConfiguration
{
public const CLASS_NAME = 'AppContainer';
Expand Down
27 changes: 1 addition & 26 deletions src/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<SymfonyBuilder> $builderClass */
public static function xml(
string $configurationFile,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<SymfonyBuilder> $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();
}
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/Delegating.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/Php.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Generators/Yaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Testing/MakeServicesPublic.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/** @internal */
final class MakeServicesPublic implements CompilerPassInterface
{
/**
Expand Down
13 changes: 0 additions & 13 deletions test/ContainerBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function namedConstructorsShouldSimplifyTheObjectCreation(
/** @return iterable<string, array{string, Generator, 2?: class-string<\Symfony\Component\DependencyInjection\ContainerBuilder>}> */
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__)];
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 3b74ea3

Please sign in to comment.