Skip to content

Commit 11dbba6

Browse files
committed
add fixture to keep protected method
1 parent 045b2ca commit 11dbba6

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\Fixture;
6+
7+
use PhpParser\PrettyPrinter\Standard;
8+
use Rector\PhpParser\Node\FileNode;
9+
10+
final class SkipProtectedMagicCalledFromParent extends Standard
11+
{
12+
protected function pFileNode(FileNode $fileNode)
13+
{
14+
}
15+
}

src/PhpParser/Node/FileNode.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ public function __construct(
2828

2929
}
3030

31+
/**
32+
* This triggers Printed method with "pFileNode" name
33+
* @see \Rector\PhpParser\Printer\BetterStandardPrinter::pStmt_FileNode()
34+
*/
3135
public function getType(): string
3236
{
33-
return 'CustomNode_File';
37+
return 'Stmt_FileNode';
3438
}
3539

3640
/**

src/PhpParser/Printer/BetterStandardPrinter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function p(
135135
: $content;
136136
}
137137

138-
protected function pCustomNode_File(FileNode $fileNode): string
138+
protected function pStmt_FileNode(FileNode $fileNode): string
139139
{
140140
return $this->pStmts($fileNode->stmts, true);
141141
}

0 commit comments

Comments
 (0)