-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get rid of bleedingEdge stubs, use a separate config option for enabl…
…ing literal-string parameters
- Loading branch information
1 parent
ca69937
commit e71f08d
Showing
12 changed files
with
261 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/PhpDoc/Doctrine/DoctrineLiteralStringTypeNodeResolverExtension.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDoc\Doctrine; | ||
|
||
use PHPStan\Analyser\NameScope; | ||
use PHPStan\PhpDoc\TypeNodeResolverExtension; | ||
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode; | ||
use PHPStan\PhpDocParser\Ast\Type\TypeNode; | ||
use PHPStan\Type\Accessory\AccessoryLiteralStringType; | ||
use PHPStan\Type\IntersectionType; | ||
use PHPStan\Type\StringType; | ||
use PHPStan\Type\Type; | ||
|
||
class DoctrineLiteralStringTypeNodeResolverExtension implements TypeNodeResolverExtension | ||
{ | ||
|
||
/** @var bool */ | ||
private $bleedingEdge; | ||
|
||
public function __construct(bool $bleedingEdge) | ||
{ | ||
$this->bleedingEdge = $bleedingEdge; | ||
} | ||
|
||
public function resolve(TypeNode $typeNode, NameScope $nameScope): ?Type | ||
{ | ||
if (!$typeNode instanceof IdentifierTypeNode) { | ||
return null; | ||
} | ||
|
||
if ($typeNode->name !== '__doctrine-literal-string') { | ||
return null; | ||
} | ||
|
||
if ($this->bleedingEdge) { | ||
return new IntersectionType([ | ||
new StringType(), | ||
new AccessoryLiteralStringType(), | ||
]); | ||
} | ||
|
||
return new StringType(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.