8000 [PropertyAccess][VarExporter] `isReadable` fails on lazy objects’ non-existent properties by MatTheCat · Pull Request #54068 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[PropertyAccess][VarExporter] isReadable fails on lazy objects’ non-existent properties #54068

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

Closed
wants to merge 1 commit into from
Closed
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
31 changes: 31 additions & 0 deletions src/Symfony/Component/PropertyAccess/Tests/Fixtures/LazyObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Tests\Fixtures;

use Symfony\Component\VarExporter\LazyGhostTrait;

class LazyObject
{
use LazyGhostTrait;

public bool $readableProperty;

public function __construct()
{
self::createLazyGhost(initializer: $this->hydrate(...), instance: $this);
}

private function hydrate(): void
{
$this->readableProperty = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\PropertyAccess\Tests\Fixtures\ExtendedUninitializedProperty;
use Symfony\Component\PropertyAccess\Tests\Fixtures\LazyObject;
use Symfony\Component\PropertyAccess\Tests\Fixtures\ReturnTyped;
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidArgumentLength;
use Symfony\Component\PropertyAccess\Tests\Fixtures\TestAdderRemoverInvalidMethods;
Expand Down Expand Up @@ -465,6 +466,14 @@ public function testIsReadableRecognizesMagicCallIfEnabled()
$this->assertTrue($this->propertyAccessor->isReadable(new TestClassMagicCall('Bernhard'), 'magicCallProperty'));
}

public function testIsReadableReturnsFalseIfInitializedLazyObjectPropertyDoesNotExist()
{
$object = new LazyObject();
$object->initializeLazyObject();

$this->assertFalse($this->propertyAccessor->isReadable($object, 'nonExistentProperty'));
}

/**
* @dataProvider 9EB7 getValidWritePropertyPaths
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/PropertyAccess/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"symfony/property-info": "^5.4|^6.0|^7.0"
},
"require-dev": {
"symfony/cache": "^5.4|^6.0|^7.0"
"symfony/cache": "^5.4|^6.0|^7.0",
"symfony/var-exporter": "^6.2|^7.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\PropertyAccess\\": "" },
Expand Down
0