mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Improve test cases
This commit is contained in:
parent
34c1f9dccf
commit
5c1d8489da
@ -12,7 +12,7 @@ class A {
|
||||
}
|
||||
|
||||
$a = new A();
|
||||
$a->foo(1, 2);
|
||||
echo $a->foo(1, 2);
|
||||
```
|
||||
|
||||
Can be suppressed by prefixing the parameter name with an underscore:
|
||||
|
@ -109,9 +109,6 @@
|
||||
</PossiblyUnusedProperty>
|
||||
|
||||
<PossiblyUnusedMethod>
|
||||
<errorLevel type="info">
|
||||
<file name="src/Psalm/Internal/Provider/FileReferenceProvider.php" />
|
||||
</errorLevel>
|
||||
<errorLevel type="suppress">
|
||||
<directory name="src/Psalm/Plugin"/>
|
||||
<directory name="src/Psalm/SourceControl/Git/"/>
|
||||
|
@ -166,7 +166,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new B)->foo();',
|
||||
echo (new B)->foo();',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
@ -185,7 +185,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new B)->foo();',
|
||||
echo (new B)->foo();',
|
||||
],
|
||||
],
|
||||
'error_message' => 'InvalidReturnStatement',
|
||||
@ -208,7 +208,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new B)->foo();',
|
||||
echo (new B)->foo();',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
@ -226,7 +226,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new B)->foo();',
|
||||
echo (new B)->foo();',
|
||||
],
|
||||
],
|
||||
'error_message' => 'InvalidReturnStatement',
|
||||
@ -259,7 +259,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new C)->existingMethod();',
|
||||
echo (new C)->existingMethod();',
|
||||
],
|
||||
[
|
||||
getcwd() . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'A.php' => '<?php
|
||||
@ -289,7 +289,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
public function newMethod() : void {}
|
||||
}
|
||||
|
||||
(new C)->existingMethod();
|
||||
echo (new C)->existingMethod();
|
||||
// newly-added call, removed in the next code block
|
||||
(new C)->newMethod();',
|
||||
],
|
||||
@ -319,7 +319,7 @@ class ErrorAfterUpdateTest extends \Psalm\Tests\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
(new C)->existingMethod();',
|
||||
echo (new C)->existingMethod();',
|
||||
],
|
||||
],
|
||||
'error_message' => 'NullableReturnStatement',
|
||||
|
@ -206,13 +206,11 @@ class UnusedCodeTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private function a(int $a, int $b): self
|
||||
private function a(int $a, int $b): void
|
||||
{
|
||||
$this->v($a, $b);
|
||||
|
||||
$this->i->foo();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function v(int $a, int $b): void
|
||||
@ -414,15 +412,14 @@ class UnusedCodeTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param class-string<O>|null $type
|
||||
* @return self
|
||||
*/
|
||||
public function addType(?string $type, array $ids = array())
|
||||
public function addType(?string $type, array $ids = array()): void
|
||||
{
|
||||
if ($this->a) {
|
||||
$ids = self::mirror($ids);
|
||||
}
|
||||
$this->_types[$type ?: ""] = new ArrayObject($ids);
|
||||
return $this;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user