-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #4. Add support for union types on Yii::createObject()
- Loading branch information
1 parent
0d703b1
commit 855910b
Showing
9 changed files
with
175 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace ErickSkrauch\PHPStan\Yii2\Helper; | ||
|
||
use PHPStan\Rules\FileRuleError; | ||
use PHPStan\Rules\IdentifierRuleError; | ||
use PHPStan\Rules\MetadataRuleError; | ||
use PHPStan\Rules\NonIgnorableRuleError; | ||
use PHPStan\Rules\RuleError; | ||
use PHPStan\Rules\RuleErrorBuilder; | ||
use PHPStan\Rules\TipRuleError; | ||
|
||
final class RuleHelper { | ||
|
||
/** | ||
* @template T of RuleError | ||
* @param T $error | ||
* @return T | ||
*/ | ||
public static function removeLine(RuleError $error): RuleError { | ||
$builder = RuleErrorBuilder::message($error->getMessage()); | ||
// @phpstan-ignore-next-line | ||
if ($error instanceof IdentifierRuleError) { | ||
$builder = $builder->identifier($error->getIdentifier()); | ||
} | ||
|
||
// @phpstan-ignore-next-line | ||
if ($error instanceof NonIgnorableRuleError) { | ||
$builder = $builder->nonIgnorable(); | ||
} | ||
|
||
// @phpstan-ignore-next-line | ||
if ($error instanceof TipRuleError) { | ||
$builder = $builder->tip($error->getTip()); | ||
} | ||
|
||
// @phpstan-ignore-next-line | ||
if ($error instanceof MetadataRuleError) { | ||
$builder = $builder->metadata($error->getMetadata()); | ||
} | ||
|
||
// @phpstan-ignore-next-line | ||
if ($error instanceof FileRuleError) { | ||
$builder = $builder->file($error->getFile()); | ||
} | ||
|
||
return $builder->build(); // @phpstan-ignore-line I don't understand why there is an error | ||
} | ||
|
||
} |
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
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.