REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 1.96 KB
Close
/opt/cpanel/ea-wappspector/vendor/rector/rector/src/BetterPhpDocParser/Printer/RemoveNodesStartAndEndResolver.php
Text
Base64
<?php declare (strict_types=1); namespace Rector\BetterPhpDocParser\Printer; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Lexer\Lexer; use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey; use Rector\BetterPhpDocParser\ValueObject\StartAndEnd; final class RemoveNodesStartAndEndResolver { /** * @param mixed[] $tokens * @return StartAndEnd[] */ public function resolve(PhpDocNode $originalPhpDocNode, PhpDocNode $currentPhpDocNode, array $tokens) : array { $removedNodePositions = []; /** @var PhpDocChildNode[] $removedChildNodes */ $removedChildNodes = \array_diff($originalPhpDocNode->children, $currentPhpDocNode->children); $lastEndPosition = null; foreach ($removedChildNodes as $removedChildNode) { /** @var StartAndEnd|null $removedPhpDocNodeInfo */ $removedPhpDocNodeInfo = $removedChildNode->getAttribute(PhpDocAttributeKey::START_AND_END); // it's not there when comment block has empty row "\s\*\n" if (!$removedPhpDocNodeInfo instanceof StartAndEnd) { continue; } // change start position to start of the line, so the whole line is removed $seekPosition = $removedPhpDocNodeInfo->getStart(); while ($seekPosition >= 0 && $tokens[$seekPosition][1] !== Lexer::TOKEN_HORIZONTAL_WS) { if ($tokens[$seekPosition][1] === Lexer::TOKEN_PHPDOC_EOL) { break; } // do not colide if ($lastEndPosition < $seekPosition) { break; } --$seekPosition; } $lastEndPosition = $removedPhpDocNodeInfo->getEnd(); $removedNodePositions[] = new StartAndEnd(\max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd()); } return $removedNodePositions; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 4
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
DocBlockInliner.php
696 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EmptyPhpDocDetector.php
704 B
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PhpDocInfoPrinter.php
12.23 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
RemoveNodesStartAndEndResolver.php
1.96 KB
lrw-r--r--
2024-11-08 13:59:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).