-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix traits issue in parallel analysis
- Loading branch information
1 parent
e39baa7
commit cedc99f
Showing
5 changed files
with
107 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
tests/PHPStan/Parallel/ParallelAnalyserIntegrationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Parallel; | ||
|
||
use Nette\Utils\Json; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ParallelAnalyserIntegrationTest extends TestCase | ||
{ | ||
|
||
public function testTraitsInDifferentJobAnalysed(): void | ||
{ | ||
exec(sprintf( | ||
'%s %s analyse -l 8 -c %s --error-format json %s', | ||
escapeshellarg(PHP_BINARY), | ||
escapeshellarg(__DIR__ . '/../../../bin/phpstan'), | ||
escapeshellarg(__DIR__ . '/parallel-analyser.neon'), | ||
implode(' ', array_map(static function (string $path): string { | ||
return escapeshellarg($path); | ||
}, [ | ||
__DIR__ . '/data/trait-definition.php', | ||
__DIR__ . '/data/traits.php', | ||
])) | ||
), $outputLines, $exitCode); | ||
$output = implode("\n", $outputLines); | ||
$this->assertJsonStringEqualsJsonString(Json::encode([ | ||
'totals' => [ | ||
'errors' => 0, | ||
'file_errors' => 3, | ||
], | ||
'files' => [ | ||
sprintf('%s/data/trait-definition.php (in context of class ParallelAnalyserIntegrationTest\\Bar)', __DIR__) => [ | ||
'errors' => 1, | ||
'messages' => [ | ||
[ | ||
'message' => 'Method ParallelAnalyserIntegrationTest\\Bar::doFoo() has no return typehint specified.', | ||
'line' => 8, | ||
'ignorable' => true, | ||
], | ||
], | ||
], | ||
sprintf('%s/data/trait-definition.php (in context of class ParallelAnalyserIntegrationTest\\Foo)', __DIR__) => [ | ||
'errors' => 2, | ||
'messages' => [ | ||
[ | ||
'message' => 'Method ParallelAnalyserIntegrationTest\\Foo::doFoo() has no return typehint specified.', | ||
'line' => 8, | ||
'ignorable' => true, | ||
], | ||
[ | ||
'message' => 'Access to an undefined property ParallelAnalyserIntegrationTest\\Foo::$test.', | ||
'line' => 10, | ||
'ignorable' => true, | ||
], | ||
], | ||
], | ||
], | ||
'errors' => [], | ||
]), $output); | ||
$this->assertSame(1, $exitCode); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace ParallelAnalyserIntegrationTest; | ||
|
||
trait FooTrait | ||
{ | ||
|
||
public function doFoo() | ||
{ | ||
$this->test = 1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace ParallelAnalyserIntegrationTest; | ||
|
||
class Foo | ||
{ | ||
|
||
use FooTrait; | ||
|
||
} | ||
|
||
class Bar | ||
{ | ||
|
||
use FooTrait; | ||
|
||
/** @var int */ | ||
private $test; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
parameters: | ||
featureToggles: | ||
parallel: true | ||
parallel: | ||
jobSize: 1 |