Skip to content

Commit b5305f3

Browse files
Merge branch '7.3' into 7.4
* 7.3: [JsonStreamer] Fix exponential resource class memory growth [Cache] Fix DSN auth not passed to clusters in RedisTrait do not parse "scalar" as an object [Form] Fix OrderedHashMap auto-increment logic with mixed keys [HttpClient] Skip HTTP/3 when using a proxy don't skip custom view transformers while normalizing submitted newlines [Serializer] Fix is/has/can accessor naming regression while preserving collision detection
2 parents 2811cbc + 2b6410e commit b5305f3

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

Tests/Extractor/PhpDocExtractorTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,23 @@ public function testUnknownPseudoTypeLegacy()
447447
{
448448
$this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor::getTypes()" method is deprecated, use "Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor::getType()" instead.');
449449

450-
$this->assertEquals([new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'scalar')], $this->extractor->getTypes(PseudoTypeDummy::class, 'unknownPseudoType'));
450+
$this->assertEquals([
451+
new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'Symfony\\Component\\PropertyInfo\\Tests\\Fixtures\\unknownpseudo')
452+
], $this->extractor->getTypes(PseudoTypeDummy::class, 'unknownPseudoType'));
453+
}
454+
455+
#[IgnoreDeprecations]
456+
#[Group('legacy')]
457+
public function testScalarPseudoTypeLegacy()
458+
{
459+
$this->expectUserDeprecationMessage('Since symfony/property-info 7.3: The "Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor::getTypes()" method is deprecated, use "Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor::getType()" instead.');
460+
461+
$this->assertEquals([
462+
new LegacyType(LegacyType::BUILTIN_TYPE_BOOL),
463+
new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT),
464+
new LegacyType(LegacyType::BUILTIN_TYPE_INT),
465+
new LegacyType(LegacyType::BUILTIN_TYPE_STRING),
466+
], $this->extractor->getTypes(PseudoTypeDummy::class, 'scalarPseudoType'));
451467
}
452468

453469
#[IgnoreDeprecations]
@@ -814,9 +830,15 @@ public static function propertiesParentTypeProvider(): iterable
814830

815831
public function testUnknownPseudoType()
816832
{
817-
$this->assertEquals(Type::object('scalar'), $this->extractor->getType(PseudoTypeDummy::class, 'unknownPseudoType'));
833+
$this->assertEquals(Type::object('Symfony\\Component\\PropertyInfo\\Tests\\Fixtures\\unknownpseudo'), $this->extractor->getType(PseudoTypeDummy::class, 'unknownPseudoType'));
818834
}
819835

836+
public function testScalarPseudoType()
837+
{
838+
$this->assertEquals(Type::object('scalar'), $this->extractor->getType(PseudoTypeDummy::class, 'scalarPseudoType'));
839+
}
840+
841+
820842
#[DataProvider('constructorTypesProvider')]
821843
public function testExtractConstructorType(string $property, ?Type $type)
822844
{

Tests/Fixtures/PseudoTypeDummy.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@ class PseudoTypeDummy
1616
/**
1717
* @var scalar
1818
*/
19+
public $scalarPseudoType;
20+
21+
/**
22+
* @var unknownpseudo
23+
*/
1924
public $unknownPseudoType;
2025
}

Util/PhpDocTypeHelper.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use phpDocumentor\Reflection\Types\Integer;
2222
use phpDocumentor\Reflection\Types\Null_;
2323
use phpDocumentor\Reflection\Types\Nullable;
24+
use phpDocumentor\Reflection\Types\Scalar;
2425
use phpDocumentor\Reflection\Types\String_;
2526
use Symfony\Component\PropertyInfo\Type as LegacyType;
2627
use Symfony\Component\TypeInfo\Type;
@@ -62,6 +63,15 @@ public function getTypes(DocType $varType): array
6263
$varType = $varType->getActualType();
6364
}
6465

66+
if ($varType instanceof Scalar) {
67+
return [
68+
new LegacyType(LegacyType::BUILTIN_TYPE_BOOL),
69+
new LegacyType(LegacyType::BUILTIN_TYPE_FLOAT),
70+
new LegacyType(LegacyType::BUILTIN_TYPE_INT),
71+
new LegacyType(LegacyType::BUILTIN_TYPE_STRING),
72+
];
73+
}
74+
6575
if (!$varType instanceof Compound) {
6676
if ($varType instanceof Null_) {
6777
$nullable = true;

0 commit comments

Comments
 (0)