the-liquid-metal opened a new issue, #6023:
URL: https://github.com/apache/netbeans/issues/6023

   ### Apache NetBeans version
   
   Apache NetBeans 18
   
   ### What happened
   
   Counting variable member other than array or Countable must produce error.
   
   ### How to reproduce
   
   ```php
   <?php
   declare(strict_types=1);
   
   class MyCountable 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 MyCountable;
       }
   }
   
   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 MyCountable;
   }
   
   $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 display error
   
   $var2b = returnNull();
   count($var2b);       // this statement must display error
   
   $var2c = $myInst->propNull;
   count($var2c);       // this statement must display error
   
   // --- undefined variable 
-----------------------------------------------------
   count($var3a);       // this statement must display error
   
   // --- boolean value 
----------------------------------------------------------
   $var4a = false;
   count($var4a);       // this statement must display error
   
   $var4b = returnBool();
   count($var4b);       // this statement must display error
   
   $var4c = $myInst->propBool;
   count($var4c);       // this statement must display error
   
   // --- int value 
--------------------------------------------------------------
   $var5a = 10;
   count($var5a);       // this statement must display error
   
   $var5b = returnInt();
   count($var5b);       // this statement must display error
   
   $var5c = $myInst->propInt;
   count($var5c);       // this statement must display error
   
   // --- float value 
------------------------------------------------------------
   $var6a = 20.34;
   count($var6a);       // this statement must display error
   
   $var6b = returnFloat();
   count($var6b);       // this statement must display error
   
   $var6c = $myInst->propFloat;
   count($var6c);       // this statement must display error
   
   // --- string value 
-----------------------------------------------------------
   $var7a = "Hello";
   count($var7a);       // this statement must display error
   
   $var7b = returnString();
   count($var7b);       // this statement must display error
   
   $var7c = $myInst->propString;
   count($var7c);       // this statement must display error
   
   // --- object value 
-----------------------------------------------------------
   $var8a = new MyClass;
   count($var8a);       // this statement must display error
   
   $var8b = returnObject();
   count($var8b);       // this statement must display error
   
   $var8c = $myInst->propObject;
   count($var8c);       // this statement must display error
   
   // --- closure value 
----------------------------------------------------------
   $var9a = fn($a) => $a*10;
   count($var9a);       // this statement must display error
   
   $var9b = returnClosure();
   count($var9b);          // this statement must display error
   
   $var9c = $myInst->propClosure;
   count($var9c);       // this statement must display error
   
   // --- callable value 
---------------------------------------------------------
   $var10a = returnCallable();
   count($var10a);        // this statement must display error
   
   $var10b = $myInst->propCallable;
   count($var10b);        // this statement must display error
   
   // --- closure value 
----------------------------------------------------------
   $var11a = new MyCountable;
   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 display error
       count($argInt);        // this statement must display error
       count($argFloat);      // this statement must display error
       count($argBool);       // this statement must display error
       count($argString);     // this statement must display error
       count($argObject);     // this statement must display error
       count($argClosure);    // this statement must display error
       count($argCallable);   // this statement must display error
       count($argCountable);  // OK
   }
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Windows 10
   
   ### JDK
   
   Java: 14.0.1; Java HotSpot(TM) 64-Bit Server VM 14.0.1+7 Runtime: Java(TM) 
SE Runtime Environment 14.0.1+7
   
   ### Apache NetBeans packaging
   
   Apache NetBeans binary zip
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to