Skip to content

Commit 1824db4

Browse files
authored
Fix reported PHPCS errors (#281)
1 parent 18da586 commit 1824db4

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

finder.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
declare(strict_types=1);
44

5+
use StubsGenerator\Finder;
6+
57
// phpcs:disable Squiz.PHP.CommentedOutCode
68

7-
return \StubsGenerator\Finder::create()
9+
return Finder::create()
810
->in('source/wordpress')
911
// Shim for load-styles.php and load-scripts.php.
1012
->notPath('wp-admin/includes/noop.php')

src/Visitor.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
use PhpParser\Node\Stmt\Property;
3131
use PhpParser\Node\Stmt\Return_ as Stmt_Return;
3232
use StubsGenerator\NodeVisitor;
33+
use phpDocumentor\Reflection\DocBlockFactoryInterface;
34+
use phpDocumentor\Reflection\DocBlockFactory;
35+
use function assert;
3336

3437
// phpcs:disable SlevomatCodingStandard.Functions.FunctionLength.FunctionLength,NeutronStandard.Functions.TypeHint.NoReturnType
3538

@@ -40,7 +43,7 @@ class Visitor extends NodeVisitor
4043
*/
4144
private const WP_INDENT_SIZE = 4;
4245

43-
private \phpDocumentor\Reflection\DocBlockFactoryInterface $docBlockFactory;
46+
private DocBlockFactoryInterface $docBlockFactory;
4447

4548
/** @var array<string,array<int|string,string>> */
4649
private array $functionMap;
@@ -51,11 +54,11 @@ class Visitor extends NodeVisitor
5154
/** @var array<string, list<string>> */
5255
private array $additionalTagStrings = [];
5356

54-
private \PhpParser\NodeFinder $nodeFinder;
57+
private NodeFinder $nodeFinder;
5558

5659
public function __construct()
5760
{
58-
$this->docBlockFactory = \phpDocumentor\Reflection\DocBlockFactory::createInstance();
61+
$this->docBlockFactory = DocBlockFactory::createInstance();
5962
$this->nodeFinder = new NodeFinder();
6063
$this->functionMap = require sprintf('%s/functionMap.php', dirname(__DIR__));
6164
}
@@ -124,15 +127,15 @@ private function getSymbolName(Node $node): string
124127
$name = $node->props[0]->name->name;
125128
}
126129

127-
\assert(isset($name), 'Node does not have a name');
130+
assert(isset($name), 'Node does not have a name');
128131

129132
if ($node instanceof Function_ || $node instanceof Class_) {
130133
return $name;
131134
}
132135

133136
$parent = $this->stack[count($this->stack) - 2];
134-
\assert($parent instanceof \PhpParser\Node\Stmt\ClassLike);
135-
\assert($parent->name instanceof \PhpParser\Node\Identifier);
137+
assert($parent instanceof ClassLike);
138+
assert($parent->name instanceof Identifier);
136139

137140
return sprintf(
138141
'%1$s::%2$s%3$s',

tests/TypeInferenceTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace PhpStubs\WordPress\Core\Tests;
66

7-
class TypeInferenceTest extends \PHPStan\Testing\TypeInferenceTestCase
7+
use PHPStan\Testing\TypeInferenceTestCase;
8+
9+
class TypeInferenceTest extends TypeInferenceTestCase
810
{
911
/** @return iterable<mixed> */
1012
public function dataFileAsserts(): iterable

visitor.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
use PhpStubs\WordPress\Core\Visitor;
6+
57
require sprintf('%s/vendor/autoload.php', __DIR__);
68

7-
return new PhpStubs\WordPress\Core\Visitor();
9+
return new Visitor();

0 commit comments

Comments
 (0)