Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 6.4:
  [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
  • Loading branch information
nicolas-grekas committed Nov 25, 2024
2 parents 402ab84 + 5786298 commit 17a97fd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Extractor/ReflectionExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,10 @@ private function isAllowedProperty(string $class, string $property, bool $writeA
return false;
}

if (\PHP_VERSION_ID >= 80400 && $writeAccessRequired && ($reflectionProperty->isProtectedSet() || $reflectionProperty->isPrivateSet())) {
return false;
}

return (bool) ($reflectionProperty->getModifiers() & $this->propertyReflectionFlags);
} catch (\ReflectionException) {
// Return false if the property doesn't exist
Expand Down
14 changes: 14 additions & 0 deletions Tests/Extractor/ReflectionExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\PropertyInfo\PropertyReadInfo;
use Symfony\Component\PropertyInfo\PropertyWriteInfo;
use Symfony\Component\PropertyInfo\Tests\Fixtures\AdderRemoverDummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\AsymmetricVisibility;
use Symfony\Component\PropertyInfo\Tests\Fixtures\ConstructorDummy;
use Symfony\Component\PropertyInfo\Tests\Fixtures\DefaultValue;
use Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy;
Expand Down Expand Up @@ -689,6 +690,19 @@ public static function provideLegacyExtractConstructorTypes(): array
];
}

/**
* @requires PHP 8.4
*/
public function testAsymmetricVisibility()
{
$this->assertTrue($this->extractor->isReadable(AsymmetricVisibility::class, 'publicPrivate'));
$this->assertTrue($this->extractor->isReadable(AsymmetricVisibility::class, 'publicProtected'));
$this->assertFalse($this->extractor->isReadable(AsymmetricVisibility::class, 'protectedPrivate'));
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'publicPrivate'));
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'publicProtected'));
$this->assertFalse($this->extractor->isWritable(AsymmetricVisibility::class, 'protectedPrivate'));
}

/**
* @dataProvider typesProvider
*/
Expand Down
19 changes: 19 additions & 0 deletions Tests/Fixtures/AsymmetricVisibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

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

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

class AsymmetricVisibility
{
public private(set) mixed $publicPrivate;
public protected(set) mixed $publicProtected;
protected private(set) mixed $protectedPrivate;
}

0 comments on commit 17a97fd

Please sign in to comment.