8000 [DependencyInjection] fix tests by xabbuh · Pull Request #53878 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] fix tests #53878

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
Feb 9, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\DependencyInjection\Tests\Fixtures;

readonly class ReadonlyTest
readonly class ReadOnlyClass
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class renamed so that it is not being eagerly loaded by PHPUnit

{
public function say(): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\LazyServiceDumper;
use Symfony\Component\DependencyInjection\Tests\Fixtures\ReadonlyTest;
use Symfony\Component\DependencyInjection\Tests\Fixtures\ReadOnlyClass;

class LazyServiceDumperTest extends TestCase
{
Expand Down Expand Up @@ -55,15 +55,15 @@ public function testInvalidClass()
}

/**
* @requires PHP 8.2
* @requires PHP 8.3
*/
public function testReadonlyClass()
{
$dumper = new LazyServiceDumper();
$definition = (new Definition(ReadonlyTest::class))->setLazy(true);
$definition = (new Definition(ReadOnlyClass::class))->setLazy(true);

$this->assertTrue($dumper->isProxyCandidate($definition));
$this->assertStringContainsString('readonly class ReadonlyTestGhost', $dumper->getProxyCode($definition));
$this->assertStringContainsString('readonly class ReadOnlyClassGhost', $dumper->getProxyCode($definition));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/VarExporter/ProxyHelper.php
4D4E
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class ProxyHelper
public static function generateLazyGhost(\ReflectionClass $class): string
{
if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class->isReadOnly()) {
throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is readonly.', $class->name));
throw new LogicException(sprintf('Cannot generate lazy ghost with PHP < 8.3: class "%s" is readonly.', $class->name));
}
if ($class->isFinal()) {
throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is final.', $class->name));
Expand Down Expand Up @@ -92,7 +92,7 @@ public static function generateLazyProxy(?\ReflectionClass $class, array $interf
throw new LogicException(sprintf('Cannot generate lazy proxy: class "%s" is final.', $class->name));
}
if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class?->isReadOnly()) {
throw new LogicException(sprintf('Cannot generate lazy proxy: class "%s" is readonly.', $class->name));
throw new LogicException(sprintf('Cannot generate lazy proxy with PHP < 8.3: class "%s" is readonly.', $class->name));
}

$methodReflectors = [$class?->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) ?? []];
Expand Down
0