Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 649313f

Browse files
Fix tests
1 parent d407bc2 commit 649313f

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

‎src/Testing/TestCaseSourceLocatorFactory.php‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,18 @@ public function __construct(
3636

3737
public function create(): SourceLocator
3838
{
39+
$locators = [];
40+
41+
$astLocator = new Locator($this->phpParser);
42+
$astPhp8Locator = new Locator($this->php8Parser);
43+
44+
$locators[] = new PhpInternalSourceLocator($astPhp8Locator, $this->phpstormStubsSourceStubber);
45+
$locators[] = new AutoloadSourceLocator($this->fileNodesFetcher, true);
46+
$locators[] = new PhpVersionBlacklistSourceLocator(new PhpInternalSourceLocator($astLocator, $this->reflectionSourceStubber), $this->phpstormStubsSourceStubber);
47+
$locators[] = new PhpVersionBlacklistSourceLocator(new EvaledCodeSourceLocator($astLocator, $this->reflectionSourceStubber), $this->phpstormStubsSourceStubber);
48+
3949
$classLoaders = ClassLoader::getRegisteredLoaders();
4050
$classLoaderReflection = new ReflectionClass(ClassLoader::class);
41-
$locators = [];
4251
if ($classLoaderReflection->hasProperty('vendorDir')) {
4352
$vendorDirProperty = $classLoaderReflection->getProperty('vendorDir');
4453
$vendorDirProperty->setAccessible(true);
@@ -56,14 +65,6 @@ public function create(): SourceLocator
5665
}
5766
}
5867

59-
$astLocator = new Locator($this->phpParser);
60-
$astPhp8Locator = new Locator($this->php8Parser);
61-
62-
$locators[] = new PhpInternalSourceLocator($astPhp8Locator, $this->phpstormStubsSourceStubber);
63-
$locators[] = new AutoloadSourceLocator($this->fileNodesFetcher, true);
64-
$locators[] = new PhpVersionBlacklistSourceLocator(new PhpInternalSourceLocator($astLocator, $this->reflectionSourceStubber), $this->phpstormStubsSourceStubber);
65-
$locators[] = new PhpVersionBlacklistSourceLocator(new EvaledCodeSourceLocator($astLocator, $this->reflectionSourceStubber), $this->phpstormStubsSourceStubber);
66-
6768
return new MemoizingSourceLocator(new AggregateSourceLocator($locators));
6869
}
6970

‎tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,35 @@ public function testRemoveArrayFromIterable(): void
390390

391391
public function testUnpackOperator(): void
392392
{
393+
$expectedType = PHP_VERSION_ID >= 80000 ? 'bool|float|int|string|Stringable|null' : 'bool|float|int|object|string|null';
394+
393395
$this->analyse([__DIR__ . '/data/unpack-operator.php'], [
394396
[
395-
'Parameter #2 ...$values of function sprintf expects bool|float|int|object|string|null, array<string> given.',
397+
sprintf('Parameter #2 ...$values of function sprintf expects %s, array<string> given.', $expectedType),
396398
18,
397399
],
398400
[
399-
'Parameter #2 ...$values of function sprintf expects bool|float|int|object|string|null, array<int, string> given.',
401+
sprintf('Parameter #2 ...$values of function sprintf expects %s, array<int, string> given.', $expectedType),
400402
19,
401403
],
402404
[
403-
'Parameter #2 ...$values of function sprintf expects bool|float|int|object|string|null, UnpackOperator\Foo given.',
405+
sprintf('Parameter #2 ...$values of function sprintf expects %s, UnpackOperator\Foo given.', $expectedType),
404406
22,
405407
],
406408
[
407-
'Parameter #2 ...$values of function printf expects bool|float|int|object|string|null, UnpackOperator\Foo given.',
409+
sprintf('Parameter #2 ...$values of function printf expects %s, UnpackOperator\Foo given.', $expectedType),
408410
24,
409411
],
410412
]);
411413
}
412414

413415
public function testFputCsv(): void
414416
{
417+
$expectedType = PHP_VERSION_ID >= 80000 ? 'bool|float|int|string|Stringable|null' : 'bool|float|int|object|string|null';
418+
415419
$this->analyse([__DIR__ . '/data/fputcsv-fields-parameter.php'], [
416420
[
417-
'Parameter #2 $fields of function fputcsv expects array<int|string, bool|float|int|object|string|null>, array<int, Fputcsv\Person> given.',
421+
sprintf('Parameter #2 $fields of function fputcsv expects array<int|string, %s>, array<int, Fputcsv\Person> given.', $expectedType),
418422
35,
419423
],
420424
]);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /