8000 Merge branch '7.1' into 7.2 · symfony/property-info@e2eb701 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2eb701

Browse files
Merge branch '7.1' into 7.2
* 7.1: [DoctrineBridge] Fix Connection::createSchemaManager() for Doctrine DBAL v2 [HttpClient] Various cleanups after recent changes do not add child nodes to EmptyNode instances consider write property visibility to decide whether a property is writable add comment explaining why HttpClient tests are run separately silence warnings issued by Redis Sentinel on connection issues
2 parents 8e868c5 + 17a97fd commit e2eb701

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

Extractor/ReflectionExtractor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,10 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
713713
return false;
714714
}
715715

716+
if (\PHP_VERSION_ID >= 80400 && $writeAccessRequired && ($reflectionProperty->isProtectedSet() || $reflectionProperty->isPrivateSet())) {
717+
return false;
718+
}
719+
716720
return (bool) ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags);
717721
} catch (\ReflectionException) {
718722
// Return false if the property doesn't exist

Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\PropertyInfo\PropertyReadInfo;
1717
use Symfony\Component\PropertyInfo\PropertyWriteInfo;
1818
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
19+
use Symfony\Component\PropertyInfo\Tests\Fixtures\AsymmetricVisibility;
1920
use Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy;
2021
use Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue;
2122
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
@@ -688,6 +689,19 @@ public static function provideLegacyExtractConstructorTypes(): array
688689
];
689690
}
690691

692+
/**
693+
* @requires PHP 8.4
694+
*/
695+
public function testAsymmetricVisibility()
696+
{
697+
$this->assertTrue($this->extractor->isReadable(AsymmetricVisibility::class, 'publicPrivate'));
698+
$this->assertTrue($this->extractor->isReadable(AsymmetricVisibility::class, 'publicProtected'));
699+
$this->assertFalse($this->extractor->isReadable(AsymmetricVisibility::class, 'protectedPrivate'));
700+
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'publicPrivate'));
701+
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'publicProtected'));
702+
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'protectedPrivate'));
703+
}
704+
691705
/**
692706
* @dataProvider typesProvider
693707
*/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
13+
14+
class AsymmetricVisibility
15+
{
16+
public private(set) mixed $publicPrivate;
17+
public protected(set) mixed $publicProtected;
18+
protected private(set) mixed $protectedPrivate;
19+
}

0 commit comments

Comments
 (0)
0