Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 091769a

Browse files
committed
[PropertyInfo] Support for the never return type
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 83357b1 commit 091769a

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

.github/patch-types.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
4343
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'):
4444
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'):
45+
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.php'):
4546
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
4647
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
4748
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):

src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private function extractFromReflectionType(\ReflectionType $reflectionType, \Ref
335335

336336
foreach ($reflectionType instanceof \ReflectionUnionType ? $reflectionType->getTypes() : [$reflectionType] as $type) {
337337
$phpTypeOrClass = $reflectionType instanceof \ReflectionNamedType ? $reflectionType->getName() : (string) $type;
338-
if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass) {
338+
if ('null' === $phpTypeOrClass || 'mixed' === $phpTypeOrClass || 'never' === $phpTypeOrClass) {
339339
continue;
340340
}
341341

src/Symfony/Component/PropertyInfo/Tests/Extractor/ReflectionExtractorTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function php71TypesProvider()
233233
}
234234

235235
/**
236-
* * @dataProvider php80TypesProvider
236+
* @dataProvider php80TypesProvider
237237
* @requires PHP 8
238238
*/
239239
public function testExtractPhp80Type($property, array $type = null)
@@ -255,6 +255,14 @@ public function php80TypesProvider()
255255
];
256256
}
257257

258+
/**
259+
* @requires PHP 8.1
260+
*/
261+
public function testExtractPhp81Type()
262+
{
263+
$this->assertNull($this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Php81Dummy', 'nothing', []));
264+
}
265+
258266
/**
259267
* @dataProvider defaultValueProvider
260268
*/
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
4+
5+
class Php81Dummy
6+
{
7+
public function getNothing(): never
8+
{
9+
throw new \Exception('Oops');
10+
}
11+
}

0 commit comments

Comments
 (0)