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
@@ -0,0 +1,31 @@
<?php

namespace Rector\Tests\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromAssignsParamToParamReferenceRector\Fixture;

final class SkipReprintDoc
{
/**
* Recursively traverse the Tiptap document tree to find user mentions
*
* @param array|null $node The current node to check
* @param mixed[] $mentions Array to collect mentions
*/
private function traverseNodes($node, array &$mentions): void
{
if (! $node || ! is_array($node)) {
return;
}

// Check if current node is a user mention
if (isset($node['type']) && $node['type'] === 'userMention' && isset($node['attrs']['user'])) {
$mentions[] = $node['attrs']['user'];
}

// Check content array
if (isset($node['content']) && is_array($node['content'])) {
foreach ($node['content'] as $childNode) {
$this->traverseNodes($childNode, $mentions);
}
}
}
}
6 changes: 6 additions & 0 deletions rules/TypeDeclarationDocblocks/NodeDocblockTypeDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Property;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
Expand Down Expand Up @@ -48,6 +49,11 @@ public function decorateGenericIterableParamType(
return false;
}

$paramTagValueNode = $phpDocInfo->getParamTagValueByName($parameterName);
if ($paramTagValueNode instanceof ParamTagValueNode && (string) $paramTagValueNode->type === (string) $typeNode) {
return false;
}

$this->phpDocTypeChanger->changeParamTypeNode($functionLike, $phpDocInfo, $param, $parameterName, $typeNode);

return true;
Expand Down
Loading