Skip to content
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

Prepare for new major release #539

Merged
merged 4 commits into from
Nov 10, 2024
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
16 changes: 0 additions & 16 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,10 @@
/**
* Definition of how the container builder should behave
*/
interface Builder

Check failure on line 14 in src/Builder.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\DependencyInjection\Builder#setGenerator() was removed

Check failure on line 14 in src/Builder.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\DependencyInjection\Builder#useDevelopmentMode() was removed
{
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 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

Check failure on line 22 in src/Compiler.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Lcobucci\DependencyInjection\Compiler was marked "@internal"
{
private const DEFAULT_PASS_CONFIG = [null, PassConfig::TYPE_BEFORE_OPTIMIZATION, 0];

Expand Down Expand Up @@ -82,7 +83,7 @@
$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,8 +10,10 @@
* Injects parameters into the container
*
* You should use this to define dynamic parameters using PHP
*
* @internal
*/
final class ParameterBag implements CompilerPassInterface

Check failure on line 16 in src/Compiler/ParameterBag.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Lcobucci\DependencyInjection\Compiler\ParameterBag was marked "@internal"
{
/** @param array<string, mixed> $parameters */
public function __construct(private array $parameters = [])
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,7 +20,8 @@

use const DIRECTORY_SEPARATOR;

/** @internal */
final class ContainerConfiguration

Check failure on line 24 in src/Config/ContainerConfiguration.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Lcobucci\DependencyInjection\Config\ContainerConfiguration was marked "@internal"
{
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

Check failure on line 18 in src/ContainerBuilder.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\DependencyInjection\ContainerBuilder::default() was removed

Check failure on line 18 in src/ContainerBuilder.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\DependencyInjection\ContainerBuilder#setGenerator() was removed

Check failure on line 18 in src/ContainerBuilder.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Method Lcobucci\DependencyInjection\ContainerBuilder#useDevelopmentMode() was removed
{
public function __construct(
private ContainerConfiguration $config,
Expand All @@ -25,19 +25,6 @@
$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 @@
$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 @@
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

Check failure on line 17 in src/Generator.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Lcobucci\DependencyInjection\Generator was marked "@internal"
{
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,7 +6,8 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/** @internal */
final class MakeServicesPublic implements CompilerPassInterface

Check failure on line 10 in src/Testing/MakeServicesPublic.php

View workflow job for this annotation

GitHub Actions / Backwards compatibility check

Lcobucci\DependencyInjection\Testing\MakeServicesPublic was marked "@internal"
{
/**
* You can modify the container here before it is dumped to PHP code.
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
Loading