You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/12/11 22:14:45 UTC
[GitHub] [netbeans] the-liquid-metal opened a new issue, #5070: [PHP] Autovivification is not produce warning/error message on simple value
the-liquid-metal opened a new issue, #5070:
URL: https://github.com/apache/netbeans/issues/5070
### Apache NetBeans version
Apache NetBeans 16
### What happened
Autovivification is the automatic creation of new array as required every time a value is dereferenced.
In autovivification context, PHP 7.x and 8.x treat values in different ways:
- undefined and null are always produce new array
- other values produce error or warning
reference:
- [Deprecate autovivification on false](https://wiki.php.net/rfc/pure-intersection-types)
At the moment, Netbeans does not produce warning/error message on any value
### How to reproduce
```php
<?php
declare(strict_types=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;
}
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 stdClass;
}
$myInst = new MyClass;
// --- below are OK ------------------------------------------------------------
$var1a = [];
$var1a[] = 100;
$var1b = returnArray();
$var1b[] = 100;
$var1c = $myInst->propArray;
$var1c[] = 100;
// --- below are OK ------------------------------------------------------------
$var2a = null;
$var2a[] = 100;
$var2b = returnNull();
$var2b[] = 100;
$var2c = $myInst->propNull;
$var2c[] = 100;
// --- below are OK ------------------------------------------------------------
// $var3 is undefined
$var3[] = 100;
// --- below are produce deprecation error in 8.1 and fatal error in 9.0. ------
$var4a = false;
$var4a[] = 100;
$var4b[] = returnBool();
$var4b[] = 100;
$var4b[] = $myInst->propBool;
$var4b[] = 100;
// --- below are produce Fatal error in 8.x and warning in 7.x -----------------
$var5a = 10;
$var5a[] = 100;
$var5b = returnInt();
$var5b[] = 100;
$var5c = $myInst->propInt;
$var5c[] = 100;
// --- below are produce Fatal error in 8.x and warning in 7.x -----------------
$var6a = 20.34;
$var6a[] = 100;
$var6b = returnFloat();
$var6b[] = 100;
$var6c = $myInst->propFloat;
$var6c[] = 100;
// --- below are produce Fatal error in 8.x and warning in 7.x -----------------
$var7a = "Hello";
$var7a[] = 100;
$var7b = returnString();
$var7b[] = 100;
$var7c = $myInst->propString;
$var7c[] = 100;
// --- below are produce Fatal error -------------------------------------------
$var8a = new stdClass;
$var8a[] = 100;
$var8b = returnObject();
$var8b[] = 100;
$var8c = $myInst->propObject;
$var8c[] = 100;
// -----------------------------------------------------------------------------
function test(
array $argArray,
null $argNull,
int $argInt,
float $argFloat,
bool $argBool,
string $argString,
object $argObject
) {
// --- below are OK --------------------------------------------------------
$argArray[] = 100;
$argNull[] = 100;
// --- below are produce Fatal error in 8.x and warning in 7.x -------------
$argInt[] = 100;
$argFloat[] = 100;
$argBool[] = 100;
$argString[] = 100;
// --- below are produce Fatal error ---------------------------------------
$argObject[] = 100;
}
### 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 provided installer
### Anything else
_No response_
### Are you willing to submit a pull request?
No
### Code of Conduct
Yes
--
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: notifications-unsubscribe@netbeans.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists