Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 73f7e73

Browse files
Add support for the callable-string type
1 parent ff570e7 commit 73f7e73

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎src/PhpDoc/TypeNodeResolver.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ private function resolveIdentifierTypeNode(IdentifierTypeNode $typeNode, NameSco
133133
case 'class-string':
134134
return new ClassStringType();
135135

136+
case 'callable-string':
137+
return new IntersectionType([new StringType(), new CallableType()]);
138+
136139
case 'array-key':
137140
return new BenevolentUnionType([new IntegerType(), new StringType()]);
138141

‎tests/PHPStan/Type/TypeCombinatorTest.php‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,30 @@ public function dataUnion(): array
13691369
UnionType::class,
13701370
'\'stdClass\'|class-string<Exception>',
13711371
],
1372+
[
1373+
[
1374+
new StringType(),
1375+
new IntersectionType([new StringType(), new CallableType()]),
1376+
],
1377+
StringType::class,
1378+
'string',
1379+
],
1380+
[
1381+
[
1382+
new IntersectionType([new StringType(), new CallableType()]),
1383+
new ConstantStringType('test_function'),
1384+
],
1385+
UnionType::class,
1386+
'\'test_function\'|(callable(): mixed&string)',
1387+
],
1388+
[
1389+
[
1390+
new IntersectionType([new StringType(), new CallableType()]),
1391+
new IntegerType(),
1392+
],
1393+
UnionType::class,
1394+
'(callable(): mixed&string)|int',
1395+
],
13721396
[
13731397
[
13741398
IntegerRangeType::fromInterval(1, 3),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /