Skip to content

Commit

Permalink
Fixed internal error with attributes referencing self::
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 9, 2021
1 parent 78b00d0 commit b5e44f7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -23,7 +23,7 @@
"nette/utils": "^3.1.3",
"nikic/php-parser": "4.13.1",
"ondram/ci-detector": "^3.4.0",
"ondrejmirtes/better-reflection": "4.3.78",
"ondrejmirtes/better-reflection": "4.3.79",
"phpstan/php-8-stubs": "^0.1.23",
"phpstan/phpdoc-parser": "^1.2.0",
"react/child-process": "^0.6.4",
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Expand Up @@ -453,6 +453,15 @@ public function testBug5657(): void
$this->assertCount(0, $errors);
}

public function testBug5951(): void
{
if (PHP_VERSION_ID < 80000 && !self::$useStaticReflectionProvider) {
$this->markTestSkipped('Test requires PHP 8.0.');
}
$errors = $this->runAnalyse(__DIR__ . '/data/bug-5951.php');
$this->assertCount(0, $errors);
}

/**
* @param string $file
* @return \PHPStan\Analyser\Error[]
Expand Down
31 changes: 31 additions & 0 deletions tests/PHPStan/Analyser/data/bug-5951.php
@@ -0,0 +1,31 @@
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug5951;

#[\Attribute]
class Route
{

/** @param string[] $methods */
public function __construct(public string $path, public string $name, public array $methods)
{

}

}

class Response
{

}

final class SomeController
{
public const ROUTE_INDEX = 'some_index';

#[Route('/some', name: self::ROUTE_INDEX, methods: ['GET'])]
public function index(): Response
{
return new Response();
}
}

0 comments on commit b5e44f7

Please sign in to comment.