Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.0] Bump to promoted properties #4

Merged
merged 6 commits into from
May 10, 2021
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 3 additions & 8 deletions packages/BetterPhpDocParser/Comment/CommentsMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,9 @@

final class CommentsMerger
{
/**
* @var SimpleCallableNodeTraverser
*/
private $simpleCallableNodeTraverser;

public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
{
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
public function __construct(
private SimpleCallableNodeTraverser $simpleCallableNodeTraverser
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,16 @@

final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
{
/**
* @var string
*/
private $annotationClass;

/**
* @param array<mixed, mixed> $values
*/
public function __construct(
// values
string $annotationClass,
private string $annotationClass,
?string $originalContent = null,
array $values = [],
?string $silentKey = null
) {
$this->hasChanged = true;
$this->annotationClass = $annotationClass;

parent::__construct($values, $originalContent, $silentKey);
}
Expand Down
57 changes: 7 additions & 50 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,73 +53,30 @@ final class PhpDocInfo
*/
private $isSingleLine = false;

/**
* @var PhpDocNode
*/
private $phpDocNode;

/**
* @var PhpDocNode
*/
private $originalPhpDocNode;

/**
* @var StaticTypeMapper
*/
private $staticTypeMapper;

/**
* @var \PhpParser\Node
*/
private $node;

/**
* @var bool
*/
private $hasChanged = false;

/**
* @var AnnotationNaming
*/
private $annotationNaming;

/**
* @var CurrentNodeProvider
*/
private $currentNodeProvider;

/**
* @var RectorChangeCollector
*/
private $rectorChangeCollector;

/**
* @var BetterTokenIterator
*/
private $betterTokenIterator;

public function __construct(
PhpDocNode $phpDocNode,
BetterTokenIterator $betterTokenIterator,
StaticTypeMapper $staticTypeMapper,
\PhpParser\Node $node,
AnnotationNaming $annotationNaming,
CurrentNodeProvider $currentNodeProvider,
RectorChangeCollector $rectorChangeCollector
private PhpDocNode $phpDocNode,
private BetterTokenIterator $betterTokenIterator,
private StaticTypeMapper $staticTypeMapper,
private \PhpParser\Node $node,
private AnnotationNaming $annotationNaming,
private CurrentNodeProvider $currentNodeProvider,
private RectorChangeCollector $rectorChangeCollector
) {
$this->phpDocNode = $phpDocNode;
$this->betterTokenIterator = $betterTokenIterator;
$this->originalPhpDocNode = clone $phpDocNode;

if (! $betterTokenIterator->containsTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
$this->isSingleLine = true;
}

$this->staticTypeMapper = $staticTypeMapper;
$this->node = $node;
$this->annotationNaming = $annotationNaming;
$this->currentNodeProvider = $currentNodeProvider;
$this->rectorChangeCollector = $rectorChangeCollector;
}

public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode): void
Expand Down
57 changes: 7 additions & 50 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
use PHPStan\PhpDocParser\Lexer\Lexer;
use PHPStan\PhpDocParser\Parser\PhpDocParser;
use Rector\BetterPhpDocParser\Annotation\AnnotationNaming;
use Rector\BetterPhpDocParser\Contract\PhpDocNodeFactoryInterface;
use Rector\BetterPhpDocParser\PhpDocNodeMapper;
Expand All @@ -23,62 +22,20 @@

final class PhpDocInfoFactory
{
/**
* @var PhpDocParser
*/
private $betterPhpDocParser;

/**
* @var Lexer
*/
private $lexer;

/**
* @var CurrentNodeProvider
*/
private $currentNodeProvider;

/**
* @var StaticTypeMapper
*/
private $staticTypeMapper;

/**
* @var PhpDocNodeMapper
*/
private $phpDocNodeMapper;

/**
* @var AnnotationNaming
*/
private $annotationNaming;

/**
* @var RectorChangeCollector
*/
private $rectorChangeCollector;

/**
* @var array<string, PhpDocInfo>
*/
private $phpDocInfosByObjectHash = [];

public function __construct(
PhpDocNodeMapper $phpDocNodeMapper,
CurrentNodeProvider $currentNodeProvider,
Lexer $lexer,
BetterPhpDocParser $betterPhpDocParser,
StaticTypeMapper $staticTypeMapper,
AnnotationNaming $annotationNaming,
RectorChangeCollector $rectorChangeCollector
private PhpDocNodeMapper $phpDocNodeMapper,
private CurrentNodeProvider $currentNodeProvider,
private Lexer $lexer,
private BetterPhpDocParser $betterPhpDocParser,
private StaticTypeMapper $staticTypeMapper,
private AnnotationNaming $annotationNaming,
private RectorChangeCollector $rectorChangeCollector
) {
$this->betterPhpDocParser = $betterPhpDocParser;
$this->lexer = $lexer;
$this->currentNodeProvider = $currentNodeProvider;
$this->staticTypeMapper = $staticTypeMapper;
$this->phpDocNodeMapper = $phpDocNodeMapper;
$this->annotationNaming = $annotationNaming;
$this->rectorChangeCollector = $rectorChangeCollector;
}

public function createFromNodeOrEmpty(Node $node): PhpDocInfo
Expand Down
18 changes: 4 additions & 14 deletions packages/BetterPhpDocParser/PhpDocInfo/TokenIteratorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,10 @@ final class TokenIteratorFactory
*/
private const INDEX = 'index';

/**
* @var Lexer
*/
private $lexer;

/**
* @var PrivatesAccessor
*/
private $privatesAccessor;

public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor)
{
$this->lexer = $lexer;
$this->privatesAccessor = $privatesAccessor;
public function __construct(
private Lexer $lexer,
private PrivatesAccessor $privatesAccessor
) {
}

public function create(string $content): BetterTokenIterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@

final class PhpDocClassRenamer
{
/**
* @var ClassAnnotationMatcher
*/
private $classAnnotationMatcher;

public function __construct(ClassAnnotationMatcher $classAnnotationMatcher)
{
$this->classAnnotationMatcher = $classAnnotationMatcher;
public function __construct(
private ClassAnnotationMatcher $classAnnotationMatcher
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,11 @@

final class PhpDocTypeChanger
{
/**
* @var TypeComparator
*/
private $typeComparator;

/**
* @var StaticTypeMapper
*/
private $staticTypeMapper;

/**
* @var ParamPhpDocNodeFactory
*/
private $paramPhpDocNodeFactory;

public function __construct(
StaticTypeMapper $staticTypeMapper,
TypeComparator $typeComparator,
ParamPhpDocNodeFactory $paramPhpDocNodeFactory
private StaticTypeMapper $staticTypeMapper,
private TypeComparator $typeComparator,
private ParamPhpDocNodeFactory $paramPhpDocNodeFactory
) {
$this->typeComparator = $typeComparator;
$this->staticTypeMapper = $staticTypeMapper;
$this->paramPhpDocNodeFactory = $paramPhpDocNodeFactory;
}

public function changeVarType(PhpDocInfo $phpDocInfo, Type $newType): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@

final class PropertyDocBlockManipulator
{
/**
* @var PhpDocInfoFactory
*/
private $phpDocInfoFactory;

public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
public function __construct(
private PhpDocInfoFactory $phpDocInfoFactory
) {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,10 @@

final class VarAnnotationManipulator
{
/**
* @var PhpDocInfoFactory
*/
private $phpDocInfoFactory;

/**
* @var PhpDocTypeChanger
*/
private $phpDocTypeChanger;

public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocTypeChanger $phpDocTypeChanger)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->phpDocTypeChanger = $phpDocTypeChanger;
public function __construct(
private PhpDocInfoFactory $phpDocInfoFactory,
private PhpDocTypeChanger $phpDocTypeChanger
) {
}

public function decorateNodeWithInlineVarType(
Expand Down
33 changes: 4 additions & 29 deletions packages/BetterPhpDocParser/PhpDocNodeMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
use Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider;
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
use Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface;
use Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
use Symplify\SimplePhpDocParser\PhpDocNodeVisitor\CloningPhpDocNodeVisitor;
use Symplify\SimplePhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitor;
Expand All @@ -18,39 +17,15 @@
*/
final class PhpDocNodeMapper
{
/**
* @var PhpDocNodeVisitorInterface[]
*/
private $phpDocNodeVisitors = [];

/**
* @var CurrentTokenIteratorProvider
*/
private $currentTokenIteratorProvider;

/**
* @var ParentConnectingPhpDocNodeVisitor
*/
private $parentConnectingPhpDocNodeVisitor;

/**
* @var CloningPhpDocNodeVisitor
*/
private $cloningPhpDocNodeVisitor;

/**
* @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors
*/
public function __construct(
CurrentTokenIteratorProvider $currentTokenIteratorProvider,
ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor,
CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor,
array $phpDocNodeVisitors
private CurrentTokenIteratorProvider $currentTokenIteratorProvider,
private ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor,
private CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor,
private array $phpDocNodeVisitors
) {
$this->phpDocNodeVisitors = $phpDocNodeVisitors;
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
$this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor;
$this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor;
}

public function transform(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@

final class ChangedPhpDocNodeTraverserFactory
{
/**
* @var ChangedPhpDocNodeVisitor
*/
private $changedPhpDocNodeVisitor;

public function __construct(ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor)
{
$this->changedPhpDocNodeVisitor = $changedPhpDocNodeVisitor;
public function __construct(
private ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor
) {
}

public function create(): PhpDocNodeTraverser
Expand Down
Loading