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
20 changes: 20 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ jobs:
mv src/Bar.php.orig src/Bar.php
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
- script: |
cd e2e/result-cache-9
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
patch -b src/Foo.php < patch-1.patch
cat baseline-1.neon > phpstan-baseline.neon
../../bin/phpstan -vvv
mv src/Foo.php.orig src/Foo.php
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
- script: |
cd e2e/result-cache-10
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
patch -b src/Foo.php < patch-1.patch
cat baseline-1.neon > phpstan-baseline.neon
../../bin/phpstan -vvv
mv src/Foo.php.orig src/Foo.php
echo -n > phpstan-baseline.neon
../../bin/phpstan -vvv
- script: |
cd e2e/bug10449
../../bin/phpstan analyze
Expand Down
6 changes: 6 additions & 0 deletions e2e/result-cache-10/baseline-1.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Access to protected property TestResultCache10\\\\Foo\\:\\:\\$x\\.$#"
count: 1
path: src/Bar.php
10 changes: 10 additions & 0 deletions e2e/result-cache-10/patch-1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- src/Foo.php 2022-10-24 14:28:45.000000000 +0200
+++ src/Foo.php 2022-10-24 14:30:02.000000000 +0200
@@ -7,7 +7,7 @@

public function __construct(
- public string $x,
+ protected string $x,
)
{
}
Empty file.
7 changes: 7 additions & 0 deletions e2e/result-cache-10/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: 8
paths:
- src
13 changes: 13 additions & 0 deletions e2e/result-cache-10/src/Bar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace TestResultCache10;

class Bar
{

public function doBar(Foo $foo): void
{
echo $foo->x;
}

}
14 changes: 14 additions & 0 deletions e2e/result-cache-10/src/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace TestResultCache10;

class Foo
{

public function __construct(
public string $x,
)
{
}

}
6 changes: 6 additions & 0 deletions e2e/result-cache-9/baseline-1.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$strings of method TestResultCache9\\\\Bar\\:\\:acceptStrings\\(\\) expects list\\<string\\>, list\\<int\\> given\\.$#"
count: 1
path: src/Bar.php
10 changes: 10 additions & 0 deletions e2e/result-cache-9/patch-1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- src/Foo.php 2022-10-24 14:28:45.000000000 +0200
+++ src/Foo.php 2022-10-24 14:30:02.000000000 +0200
@@ -7,7 +7,7 @@

public function __construct(
- /** @var list<string> */
+ /** @var list<int> */
public array $x,
)
{
Empty file.
7 changes: 7 additions & 0 deletions e2e/result-cache-9/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: 8
paths:
- src
20 changes: 20 additions & 0 deletions e2e/result-cache-9/src/Bar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace TestResultCache9;

class Bar
{

/**
* @param list<string> $strings
*/
public function acceptStrings(array $strings): void
{
}

public function doBar(Foo $foo): void
{
$this->acceptStrings($foo->x);
}

}
15 changes: 15 additions & 0 deletions e2e/result-cache-9/src/Foo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace TestResultCache9;

class Foo
{

public function __construct(
/** @var list<string> */
public array $x,
)
{
}

}
23 changes: 22 additions & 1 deletion src/Dependency/ExportedNode/ExportedParameterNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public function __construct(
private bool $variadic,
private bool $hasDefault,
private array $attributes,
private ?ExportedPhpDocNode $phpDoc = null,
private int $flags = 0,
)
{
}
Expand All @@ -43,11 +45,24 @@ public function equals(ExportedNode $node): bool
}
}

if ($this->phpDoc === null) {
if ($node->phpDoc !== null) {
return false;
}
} elseif ($node->phpDoc !== null) {
if (!$this->phpDoc->equals($node->phpDoc)) {
return false;
}
} else {
return false;
}

return $this->name === $node->name
&& $this->type === $node->type
&& $this->byRef === $node->byRef
&& $this->variadic === $node->variadic
&& $this->hasDefault === $node->hasDefault;
&& $this->hasDefault === $node->hasDefault
&& $this->flags === $node->flags;
}

/**
Expand All @@ -62,6 +77,8 @@ public static function __set_state(array $properties): self
$properties['variadic'],
$properties['hasDefault'],
$properties['attributes'],
$properties['phpDoc'] ?? null,
$properties['flags'] ?? 0,
);
}

Expand All @@ -81,6 +98,8 @@ public function jsonSerialize()
'variadic' => $this->variadic,
'hasDefault' => $this->hasDefault,
'attributes' => $this->attributes,
'phpDoc' => $this->phpDoc,
'flags' => $this->flags,
],
];
}
Expand All @@ -102,6 +121,8 @@ public static function decode(array $data): self
}
return ExportedAttributeNode::decode($attributeData['data']);
}, $data['attributes']),
isset($data['phpDoc']) ? ExportedPhpDocNode::decode($data['phpDoc']['data']) : null,
$data['flags'] ?? 0,
);
}

Expand Down
16 changes: 12 additions & 4 deletions src/Dependency/ExportedNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function resolve(string $fileName, Node $node): ?RootExportedNode
),
$node->byRef,
NodeTypePrinter::printType($node->returnType),
$this->exportParameterNodes($node->params),
$this->exportParameterNodes($node->params, $fileName, null),
$this->exportAttributeNodes($node->attrGroups),
);
}
Expand All @@ -233,7 +233,7 @@ public function resolve(string $fileName, Node $node): ?RootExportedNode
* @param Node\Param[] $params
* @return ExportedParameterNode[]
*/
private function exportParameterNodes(array $params): array
private function exportParameterNodes(array $params, string $fileName, ?string $className): array
{
$nodes = [];
foreach ($params as $param) {
Expand All @@ -254,13 +254,21 @@ private function exportParameterNodes(array $params): array
$type = new Node\NullableType($type);
}
}
$docComment = $param->getDocComment();
$nodes[] = new ExportedParameterNode(
$param->var->name,
NodeTypePrinter::printType($type),
$param->byRef,
$param->variadic,
$param->default !== null,
$this->exportAttributeNodes($param->attrGroups),
$this->exportPhpDocNode(
$fileName,
$className,
null,
$docComment !== null ? $docComment->getText() : null,
),
$param->flags,
);
}

Expand Down Expand Up @@ -335,7 +343,7 @@ private function exportClassStatement(Node\Stmt $node, string $fileName, string
$node->isFinal(),
$node->isStatic(),
NodeTypePrinter::printType($node->returnType),
$this->exportParameterNodes($node->params),
$this->exportParameterNodes($node->params, $fileName, $namespacedName),
$this->exportAttributeNodes($node->attrGroups),
);
}
Expand Down Expand Up @@ -482,7 +490,7 @@ private function exportPropertyHooks(
$hook->body === null,
$hook->isFinal(),
$hook->body instanceof Expr,
$this->exportParameterNodes($hook->params),
$this->exportParameterNodes($hook->params, $fileName, $namespacedName),
$this->exportAttributeNodes($hook->attrGroups),
);
}
Expand Down
Loading