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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function isMatch(Node $node): bool
*/
public function create(Node $node, string $docContent): AttributeAwareNodeInterface
{
// @todo how to get content here
foreach ($node->types as $key => $unionedType) {
$node->types[$key] = $this->attributeAwareNodeFactory->createFromNode($unionedType, $docContent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ public function __construct(array $items, ?string $originalContent = null)
*/
public function __toString(): string
{
$items = $this->completeItemsQuotes($this->items);
return $this->printItems($this->items);
}

protected function printItems(array $items): string
{
$items = $this->completeItemsQuotes($items);
$items = $this->filterOutMissingItems($items);
$items = $this->makeKeysExplicit($items);

Expand Down Expand Up @@ -117,7 +122,6 @@ protected function printArrayItem(array $item, ?string $key = null): string

// should unquote
if ($this->isValueWithoutQuotes($key)) {
// @todo resolve per key item
$json = Strings::replace($json, '#"#');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@ final class SymfonyRouteTagValueNode extends AbstractTagValueNode implements Sho

public function __toString(): string
{
if (isset($this->items['path']) || isset($this->items['localizedPaths'])) {
$this->items['path'] = $this->items['path'] ?? $this->items['localizedPaths'];
$items = $this->items;
if (isset($items['path']) || isset($items['localizedPaths'])) {
$items['path'] = $items['path'] ?? $this->items['localizedPaths'];
}

$items = $this->completeItemsQuotes($this->items);
$items = $this->makeKeysExplicit($items);

return $this->printContentItems($items);
return $this->printItems($items);
}

public function changeMethods(array $methods): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ public function getShortName(): string

public function toAttributeString(): string
{
$items = $this->filterOutMissingItems($this->items);
$items = $this->completeItemsQuotes($items);

$content = $this->printPhpAttributeItemsAsArray($items);

return $this->printPhpAttributeContent($content);
return $this->printItemsToAttributeAsArrayString($this->items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ private function resolveTokenEnd(TokenIterator $tokenIterator): int

private function getOriginalContentFromTokenIterator(TokenIterator $tokenIterator): string
{
// @todo iterate through tokens...
$originalTokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
$originalContent = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private function completeTypesToClassMethodParams(ClassMethod $classMethod, arra

if (count($parameterData) > 1) {
// is union or nullable type?
// @todo
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ private function resolveParent(Name $name): Type

$type = new ObjectType($parentClassName);

// @todo abstract
$parentParentClass = get_parent_class($parentClassName);
if ($parentParentClass) {
$type = new UnionType([$type, new ObjectType($parentParentClass)]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
use PhpParser\Node\Param;
use PhpParser\NodeTraverser;
use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use Rector\Core\PhpParser\NodeTraverser\CallableNodeTraverser;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Contract\NodeTypeResolverInterface;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\NodeTypeResolver\NodeTypeResolver;
use Rector\StaticTypeMapper\StaticTypeMapper;

/**
* @see \Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ParamTypeResolver\ParamTypeResolverTest
Expand All @@ -40,6 +40,11 @@ final class ParamTypeResolver implements NodeTypeResolverInterface
*/
private $nodeTypeResolver;

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

public function __construct(NodeNameResolver $nodeNameResolver, CallableNodeTraverser $callableNodeTraverser)
{
$this->nodeNameResolver = $nodeNameResolver;
Expand All @@ -49,9 +54,12 @@ public function __construct(NodeNameResolver $nodeNameResolver, CallableNodeTrav
/**
* @required
*/
public function autowirePropertyTypeResolver(NodeTypeResolver $nodeTypeResolver): void
{
public function autowirePropertyTypeResolver(
NodeTypeResolver $nodeTypeResolver,
StaticTypeMapper $staticTypeMapper
): void {
$this->nodeTypeResolver = $nodeTypeResolver;
$this->staticTypeMapper = $staticTypeMapper;
}

/**
Expand Down Expand Up @@ -83,11 +91,7 @@ public function resolve(Node $node): Type
private function resolveFromType(Node $node): Type
{
if ($node->type !== null && ! $node->type instanceof Identifier) {
$resolveTypeName = $this->nodeNameResolver->getName($node->type);
if ($resolveTypeName) {
// @todo map the other way every type :)
return new ObjectType($resolveTypeName);
}
return $this->staticTypeMapper->mapPhpParserNodePHPStanType($node->type);
}

return new MixedType();
Expand Down
1 change: 0 additions & 1 deletion packages/node-type-resolver/src/PHPStan/TypeHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function createTypeHash(Type $type): string
}

if ($type instanceof ArrayType) {
// @todo sort to make different order identical
return $this->createTypeHash($type->getItemType()) . '[]';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public function mapToDocString(Type $type, ?Type $parentType = null): string
return $this->phpStanStaticTypeMapper->mapToDocString($itemType, $parentType) . '[]';
}

/**
* @todo improve
*/
private function convertUnionArrayTypeNodesToArrayTypeOfUnionTypeNodes(
UnionTypeNode $unionTypeNode
): AttributeAwareUnionTypeNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
// has some elseif, we need to check them too later @todo
if ((bool) $node->elseifs) {
return null;
}
Expand All @@ -97,7 +96,6 @@ public function refactor(Node $node): ?Node

private function refactorIsMatch(If_ $if): void
{
// has some elseif, we need to check them too @todo
if ((bool) $if->elseifs) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
final class NodesToReplaceCollector implements NodeCollectorInterface
{
/**
* @todo use value object
* @var Node[][]
*/
private $nodesToReplace = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class UseNodesToAddCollector implements NodeCollectorInterface
private $useImportTypesInFilePath = [];

/**
* @todo use value object
* @var string[][]
*/
private $removedShortUsesInFilePath = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public function refactor(SmartFileInfo $smartFileInfo): void
$renamedNamespaceValueObject
);

// @todo
// create helping rename class rector.yaml + class_alias autoload file
// $this->renamedClassesCollector->addClassRename($oldClass, $newClass);

$this->moveFile($smartFileInfo, $newFileLocation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $name
return new IterableType(new MixedType(), new MixedType());
}

// @todo improve - making many false positives now
$objectType = new ObjectType($typeNode->name);

return $this->objectTypeSpecifier->narrowToFullyQualifiedOrAlaisedObjectType($node, $objectType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ public function isVendorLocked(ClassMethod $classMethod): bool
/** @var string $methodName */
$methodName = $this->nodeNameResolver->getName($classMethod);

// @todo extract to some "inherited parent method" service
/** @var string|null $parentClassName */
$parentClassName = $classMethod->getAttribute(AttributeKey::PARENT_CLASS_NAME);

if ($parentClassName !== null) {
return $this->isVendorLockedByParentClass($parentClassName, $methodName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ public function isVendorLocked(Property $property): bool
throw new ShouldNotHappenException();
}

// @todo extract to some "inherited parent method" service
// extract to some "inherited parent method" service
/** @var string|null $parentClassName */
$parentClassName = $classNode->getAttribute(AttributeKey::PARENT_CLASS_NAME);

if ($parentClassName !== null) {
$parentClassProperty = $this->findParentProperty($parentClassName, $propertyName);

// @todo validate type is conflicting
// validate type is conflicting
// parent class property in local scope → it's ok
if ($parentClassProperty !== null) {
return $parentClassProperty->type !== null;
}

// if not, look for it's parent parent - @todo recursion
// if not, look for it's parent parent - recursion

if (property_exists($parentClassName, $propertyName)) {
// @todo validate type is conflicting
// validate type is conflicting
// parent class property in external scope → it's not ok
return true;

// if not, look for it's parent parent - @todo recursion
// if not, look for it's parent parent
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function refactor(Node $node): ?Node
return null;
}

// @todo important, maybe unique condition
$newName = $this->resolveNewMethodNameByCondition($node, $typeAndMethodNames);
$node->name = new Identifier($newName);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading