Bug Description
Currently, PHP type system covers most of the cases. With mixed, other unrepresented types can be represented by it. Another purpose of mixed is to discern whether people forgot to give a type or not. Adding types to all possible places is a good discipline. PDT need to provide additional validation to switch on and off to adjust this rule to the project policy.
To Reproduce
Steps to reproduce the behavior: copy-paste this script to the IDE
<?php
declare(strict_types=1);
namespace ns1\ns2;
interface Test25 {
public function fn1(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int;
public function fn2(
int $par1,
int $par2,
int $par3,
); // this statement should trigger warning
}
class Test25b
{
public int $prop1;
public $prop2; // this statement should trigger warning
public function fn1(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int {}
public function fn2(
int $par1,
int $par2,
int $par3,
){} // this statement should trigger warning
}
trait Test25c
{
public int $prop1;
public $prop2; // this statement should trigger warning
public function fn1(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int {}
public function fn2(
int $par1,
int $par2,
int $par3,
){} // this statement should trigger warning
}
function fn1(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int {}
function fn2(
int $par1,
int $par2,
int $par3,
){} // this statement should trigger warning
$var1 = function(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int {};
$var2 = function(
int $par1,
int $par2,
int $par3,
) {}; // this statement should trigger warning
$var3 = fn(
int $par1,
int $par2,
$par3, // this statement should trigger warning
): int => 10;
$var4 = fn(
int $par1,
int $par2,
int $par3,
) => 10; // this statement should trigger warning
var_dump($var1, $var2, $var3, $var4);
Bug Description Currently, PHP type system covers most of the cases. With
mixed
, other unrepresented types can be represented by it. Another purpose ofmixed
is to discern whether people forgot to give a type or not. Adding types to all possible places is a good discipline. PDT need to provide additional validation to switch on and off to adjust this rule to the project policy.Eclipse environment Version: 2023-06 (4.28.0) Build id: 20230608-1333 PDT: 8.0.0.202306050832
System
To Reproduce Steps to reproduce the behavior: copy-paste this script to the IDE