To Reproduce
Steps to reproduce the behavior: copy-paste this script to the IDE
<?php
declare(strict_types=1);
namespace ns1\ns2;
use closure;
use Countable;
use stdClass;
class Test48 implements Countable {
public function count() {
return 1;
}
}
class MyClass {
public array $propArray = [];
public null $propNull = null;
public int $propInt = 10;
public float $propFloat = 20.34;
public bool $propBool = false;
public string $propString = "Hello";
public object $propObject;
public closure $propClosure;
/**
* @var callable
*/
public $propCallable;
public Countable $propCountable;
public static function statFunc() {
echo "from statFunc\n";
}
public function __construct() {
$this->propObject = new stdClass;
$this->propClosure = fn($a) => $a*10;
$this->propCallable = [self::class, "statFunc"];
$this->propCountable = new Test48;
}
}
function returnArray(): array {
return [];
}
function returnNull(): null{
return null;
}
function returnInt(): int {
return 10;
}
function returnFloat(): float{
return 20.34;
}
function returnBool(): bool {
return false;
}
function returnString(): bool {
return false;
}
function returnObject(): object {
return new MyClass;
}
function returnClosure(): closure {
return fn($a) => $a;
}
function returnCallable(): callable {
return [MyClass::class, "statFunc"];
}
function returnCountable(): Countable {
return new Test48;
}
$myInst = new MyClass;
// --- array value ------------------------------------------------------------
$var1a = [1,2,3];
count($var1a); // OK
$var1b = returnArray();
count($var1b); // OK
$var1c = $myInst->propArray;
count($var1c); // OK
// --- null value -------------------------------------------------------------
$var2a = null;
count($var2a); // this statement must trigger error
$var2b = returnNull();
count($var2b); // this statement must trigger error
$var2c = $myInst->propNull;
count($var2c); // this statement must trigger error
// --- undefined variable -----------------------------------------------------
count($var3a); // this statement must trigger error
// --- boolean value ----------------------------------------------------------
$var4a = false;
count($var4a); // this statement must trigger error
$var4b = returnBool();
count($var4b); // this statement must trigger error
$var4c = $myInst->propBool;
count($var4c); // this statement must trigger error
// --- int value --------------------------------------------------------------
$var5a = 10;
count($var5a); // this statement must trigger error
$var5b = returnInt();
count($var5b); // this statement must trigger error
$var5c = $myInst->propInt;
count($var5c); // this statement must trigger error
// --- float value ------------------------------------------------------------
$var6a = 20.34;
count($var6a); // this statement must trigger error
$var6b = returnFloat();
count($var6b); // this statement must trigger error
$var6c = $myInst->propFloat;
count($var6c); // this statement must trigger error
// --- string value -----------------------------------------------------------
$var7a = "Hello";
count($var7a); // this statement must trigger error
$var7b = returnString();
count($var7b); // this statement must trigger error
$var7c = $myInst->propString;
count($var7c); // this statement must trigger error
// --- object value -----------------------------------------------------------
$var8a = new MyClass;
count($var8a); // this statement must trigger error
$var8b = returnObject();
count($var8b); // this statement must trigger error
$var8c = $myInst->propObject;
count($var8c); // this statement must trigger error
// --- closure value ----------------------------------------------------------
$var9a = fn($a) => $a*10;
count($var9a); // this statement must trigger error
$var9b = returnClosure();
count($var9b); // this statement must trigger error
$var9c = $myInst->propClosure;
count($var9c); // this statement must trigger error
// --- callable value ---------------------------------------------------------
$var10a = returnCallable();
count($var10a); // this statement must trigger error
$var10b = $myInst->propCallable;
count($var10b); // this statement must trigger error
// --- closure value ----------------------------------------------------------
$var11a = new Test48;
count($var11a); // OK
$var11b = returnCountable();
count($var11b); // OK
$var11c = $myInst->propCountable;
count($var11c); // OK
// ----------------------------------------------------------------------------
function test(
array $argArray,
null $argNull,
int $argInt,
float $argFloat,
bool $argBool,
string $argString,
object $argObject,
closure $argClosure,
callable $argCallable,
Countable $argCountable,
) {
count($argArray); // OK
count($argNull); // this statement must trigger error
count($argInt); // this statement must trigger error
count($argFloat); // this statement must trigger error
count($argBool); // this statement must trigger error
count($argString); // this statement must trigger error
count($argObject); // this statement must trigger error
count($argClosure); // this statement must trigger error
count($argCallable); // this statement must trigger error
count($argCountable); // OK
}
Bug Description Missing error on counting variable member other than array or Countable.
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