Skip to content

Commit bc9c55a

Browse files
committed
Fix match location logic
1 parent 8ba3235 commit bc9c55a

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

src/Node/LocationNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function matches(array $excludes): bool
3333
$pathname = \str_replace('\\', '/', $this->file->name);
3434

3535
foreach ($excludes as $ignored) {
36-
if (\str_starts_with($pathname, \str_replace('\\', '/', $ignored))) {
36+
if (\str_starts_with(\str_replace('\\', '/', $ignored), $pathname)) {
3737
return false;
3838
}
3939
}

src/PhpStormMetadataGenerator/GenerateExportFunctions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public function __construct(
4848

4949
public function enter(NamespaceNode $ctx, FunctionNode|TypeDefinitionNode $node): iterable
5050
{
51-
if (!$node instanceof FunctionNode || $node->name === null || !$node->location->matches($this->excludes)) {
51+
if (!$node instanceof FunctionNode
52+
|| $node->name === null
53+
|| $node->location->matches($this->excludes)
54+
) {
5255
return [];
5356
}
5457

src/PhpStormMetadataGenerator/GenerateStructOverrides.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ private function getTypeAliases(TypeInterface $type): ?array
101101
{
102102
if ($type instanceof RecordTypeNode && $type->name !== null) {
103103
if ($type->location->matches($this->ignoreDirectories)) {
104-
return [$type->name];
104+
return null;
105105
}
106106

107-
return null;
107+
return [$type->name];
108108
}
109109

110110
if ($type instanceof TypeDefinitionNode) {

src/PhpStormMetadataGenerator/GenerateStructures.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function enter(NamespaceNode $ctx, FunctionNode|TypeDefinitionNode $node)
4242
{
4343
if (!$node instanceof TypeDefinitionNode
4444
|| !$node->type instanceof RecordTypeNode
45-
|| !$node->location->matches($this->excludes)) {
45+
|| $node->location->matches($this->excludes)) {
4646
return;
4747
}
4848

src/PhpStormMetadataGenerator/Visitor.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace FFI\Generator\PhpStormMetadataGenerator;
66

77
use FFI\Generator\Node\FunctionNode;
8-
use FFI\Generator\Node\LocationNode;
98
use FFI\Generator\Node\NamespaceNode;
109
use FFI\Generator\Node\Type\TypeDefinitionNode;
1110
use PhpParser\Node\Stmt;
@@ -37,12 +36,4 @@ public function enter(NamespaceNode $ctx, TypeDefinitionNode|FunctionNode $node)
3736
{
3837
return [];
3938
}
40-
41-
/**
42-
* @param list<non-empty-string> $ignoreDirectories
43-
*/
44-
protected function locationMatches(?LocationNode $location, array $ignoreDirectories): bool
45-
{
46-
return $location === null || $location->matches($ignoreDirectories);
47-
}
4839
}

0 commit comments

Comments
 (0)