Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/AllRectorsOverview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# All 451 Rectors Overview
# All 452 Rectors Overview

- [Projects](#projects)
- [General](#general)
Expand Down
24 changes: 24 additions & 0 deletions packages/better-php-doc-parser/src/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Constant\ConstantArrayType;
Expand Down Expand Up @@ -188,6 +189,29 @@ public function getParamType(string $name): Type
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($paramTagValue, $this->node);
}

/**
* @return Type[]
*/
public function getThrowsTypes(): array
{
$throwsPhpDocNodes = $this->getTagsByName('throws');

$throwsTypes = [];

foreach ($throwsPhpDocNodes as $throwsPhpDocNode) {
if (! $throwsPhpDocNode->value instanceof ThrowsTagValueNode) {
continue;
}

$throwsTypes[] = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType(
$throwsPhpDocNode->value,
$this->node
);
}

return $throwsTypes;
}

/**
* @return Type[]
*/
Expand Down
235 changes: 0 additions & 235 deletions packages/coding-style/src/Rector/Throw_/AnnotateThrowablesRector.php

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\Type\MixedType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
use Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper;
Expand All @@ -34,10 +33,6 @@ public function getNodeType(): string
*/
public function mapToPHPStan(Node $node): Type
{
if ($node->name === 'string') {
return new StringType();
}

$type = $this->scalarStringToTypeMapper->mapScalarStringToType($node->name);
if ($type !== null) {
return $type;
Expand Down
4 changes: 3 additions & 1 deletion packages/static-type-mapper/src/StaticTypeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -93,7 +94,8 @@ public function mapPHPStanPhpDocTypeToPHPStanType(PhpDocTagValueNode $phpDocTagV
{
if ($phpDocTagValueNode instanceof ReturnTagValueNode ||
$phpDocTagValueNode instanceof ParamTagValueNode ||
$phpDocTagValueNode instanceof VarTagValueNode
$phpDocTagValueNode instanceof VarTagValueNode ||
$phpDocTagValueNode instanceof ThrowsTagValueNode
) {
return $this->mapPHPStanPhpDocTypeNodeToPHPStanType($phpDocTagValueNode->type, $node);
}
Expand Down
Loading