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
27 changes: 27 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/WrongVariableNameInVarTagRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,33 @@ public function testBug12458(): void
$this->analyse([__DIR__ . '/data/bug-12458.php'], []);
}

public function testBug11015(): void
{
$this->checkTypeAgainstNativeType = true;
$this->checkTypeAgainstPhpDocType = true;
$this->strictWideningCheck = true;

$this->analyse([__DIR__ . '/data/bug-11015.php'], []);
}

public function testBug10861(): void
{
$this->checkTypeAgainstNativeType = true;
$this->checkTypeAgainstPhpDocType = true;
$this->strictWideningCheck = true;

$this->analyse([__DIR__ . '/data/bug-10861.php'], []);
}

public function testBug11535(): void
{
$this->checkTypeAgainstNativeType = true;
$this->checkTypeAgainstPhpDocType = true;
$this->strictWideningCheck = true;

$this->analyse([__DIR__ . '/data/bug-11535.php'], []);
}

public function testEnums(): void
{
if (PHP_VERSION_ID < 80100) {
Expand Down
23 changes: 23 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/bug-10861.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php declare(strict_types = 1);

namespace Bug10861;

class HelloWorld
{
/**
*
* @param array<string,mixed> $array1
* @param-out array<string,mixed> $array1
*/
public function sayHello(array &$array1): void
{
$values_1 = $array1;

$values_1 = array_filter($values_1, function (mixed $value): bool {
return $value !== [];
});

/** @var array<string,mixed> $values_1 */
$array1 = $values_1;
}
}
25 changes: 25 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/bug-11015.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php declare(strict_types = 1);

namespace Bug11015;

class HelloWorld
{
public function sayHello(PDOStatement $date): void
{
$b = $date->fetch();
if (empty($b)) {
return;
}

/** @var array<string, int> $b */
echo $b['a'];
}

public function sayHello2(PDOStatement $date): void
{
$b = $date->fetch();

/** @var array<string, int> $b */
echo $b['a'];
}
}
18 changes: 18 additions & 0 deletions tests/PHPStan/Rules/PhpDoc/data/bug-11535.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types = 1);

namespace Bug11535;

/** @var \Closure(string): array<int> */
$a = function(string $b) {
return [1,2,3];
};

/** @var \Closure(array): array */
$a = function(array $b) {
return $b;
};

/** @var \Closure(string): string */
$a = function(string $b) {
return $b;
};
Loading