Skip to content

Commit 35f0696

Browse files
committed
Regression tests
Closes phpstan/phpstan#7012 Closes phpstan/phpstan#6192
1 parent 4d0bdc1 commit 35f0696

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

tests/PHPStan/Analyser/AnalyserIntegrationTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,26 @@ public function testBug7030(): void
695695
null, $shippingLongitude = null, $shippingNeutralShipping = null)): Unexpected token "\n * ", expected type at offset 193', $errors[0]->getMessage());
696696
}
697697

698+
public function testBug7012(): void
699+
{
700+
if (PHP_VERSION_ID < 80100) {
701+
$this->markTestSkipped('Test requires PHP 8.1.');
702+
}
703+
704+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-7012.php');
705+
$this->assertNoErrors($errors);
706+
}
707+
708+
public function testBug6192(): void
709+
{
710+
if (PHP_VERSION_ID < 80100) {
711+
$this->markTestSkipped('Test requires PHP 8.1.');
712+
}
713+
714+
$errors = $this->runAnalyse(__DIR__ . '/data/bug-6192.php');
715+
$this->assertNoErrors($errors);
716+
}
717+
698718
/**
699719
* @param string[]|null $allAnalysedFiles
700720
* @return Error[]
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php // lint >= 8.1
2+
3+
namespace Bug6192;
4+
5+
class Foo {
6+
public function __construct(
7+
public string $value = 'default foo foo'
8+
) {}
9+
}
10+
11+
class Bar {
12+
public function __construct(
13+
public Foo $foo = new Foo('default bar foo')
14+
) {}
15+
}
16+
17+
class Baz
18+
{
19+
20+
public function doFoo(): void
21+
{
22+
echo "Testing Foo\n";
23+
var_export(new Foo('testing foo'));
24+
echo "\n";
25+
}
26+
27+
public function doBar(): void
28+
{
29+
echo "Testing Bar\n";
30+
var_export(new Bar(new Foo('testing bar')));
31+
echo "\n";
32+
}
33+
34+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php // lint >= 8.1
2+
3+
namespace Bug7012;
4+
5+
enum Foo
6+
{
7+
case BAR;
8+
}
9+
10+
function test(Foo $f = Foo::BAR): void
11+
{
12+
}
13+
14+
function test2(): void
15+
{
16+
test();
17+
}

0 commit comments

Comments
 (0)