mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
4110ec351b
* Bumped phpspec/prophecy version to prevent 7.4 deprecations
* Fix DOMDocument::$config type
This property was documented as containing DOMConfiguration object, but
in fact always returned `null` (see [php source](ee80567a83/ext/dom/document.c (L542)
)).
DOMConfiguration class is removed in PHP 8.
* Dropped unused use
* Allow to set PHP 8.0 as current version
* Fix CallMap issues for PHP 8.0
- Use both major and minor version to load deltas
- Don't load non-existent deltas
- Stop at lowest possible delta
169 lines
4.6 KiB
PHP
169 lines
4.6 KiB
PHP
<?php
|
|
namespace Psalm\Tests\FileManipulation;
|
|
|
|
class UnnecessaryVarAnnotationManipulationTest extends FileManipulationTest
|
|
{
|
|
/**
|
|
* @return array<string,array{string,string,string,string[],bool}>
|
|
*/
|
|
public function providerValidCodeParse()
|
|
{
|
|
return [
|
|
'removeSingleLineVarAnnotation' => [
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/** @var string */
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
'removeSingleLineVarAnnotationFlipped' => [
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();
|
|
|
|
/** @var string */
|
|
$a = foo();',
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();
|
|
|
|
$a = foo();',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
'removeSingleLineVarAnnotationAndType' => [
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/** @var string $a */
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
'removeMultipleLineVarAnnotation' => [
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
'removeMultipleLineVarAnnotationKeepComment' => [
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/**
|
|
* @var string
|
|
* this comment should stay
|
|
*/
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'<?php
|
|
function foo() : string {
|
|
return "hello";
|
|
}
|
|
|
|
/**
|
|
* this comment should stay
|
|
*/
|
|
$a = foo();
|
|
|
|
/** @var "a"|"b" */
|
|
$b = foo();',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
'removeMultipleLineVarAnnotationOnce' => [
|
|
'<?php
|
|
/** @return string[] */
|
|
function foo() : array {
|
|
return ["hello"];
|
|
}
|
|
|
|
/**
|
|
* @var int $k
|
|
* @var string $v
|
|
*/
|
|
foreach (foo() as $k => $v) {}',
|
|
'<?php
|
|
/** @return string[] */
|
|
function foo() : array {
|
|
return ["hello"];
|
|
}
|
|
|
|
/**
|
|
* @var int $k
|
|
*/
|
|
foreach (foo() as $k => $v) {}',
|
|
'5.6',
|
|
['UnnecessaryVarAnnotation'],
|
|
true,
|
|
],
|
|
];
|
|
}
|
|
}
|