mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
b10416a652
This deprecates passing null to non-nullable scale arguments of internal functions, with the eventual goal of making the behavior consistent with userland functions, where null is never accepted for non-nullable arguments. This change is expected to cause quite a lot of fallout. In most cases, calling code should be adjusted to avoid passing null. In some cases, PHP should be adjusted to make some function arguments nullable. I have already fixed a number of functions before landing this, but feel free to file a bug if you encounter a function that doesn't accept null, but probably should. (The rule of thumb for this to be applicable is that the function must have special behavior for 0 or "", which is distinct from the natural behavior of the parameter.) RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg Closes GH-6475.
67 lines
2.2 KiB
PHP
67 lines
2.2 KiB
PHP
--TEST--
|
|
Bug #43201 (Crash on using uninitialized vals and __get/__set)
|
|
--FILE--
|
|
<?php
|
|
class Foo {
|
|
function __get($k) {
|
|
return null;
|
|
}
|
|
function __set($k, $v) {
|
|
$this->$k = $v;
|
|
}
|
|
}
|
|
|
|
$c = new Foo();
|
|
|
|
$c->arr[0]["k"] = 1;
|
|
$c->arr[0]["k2"] = $ref;
|
|
for($cnt=0;$cnt<6;$cnt++) {
|
|
$ref = chop($undef);
|
|
$c->arr[$cnt]["k2"] = $ref;
|
|
}
|
|
echo "ok\n";
|
|
?>
|
|
--EXPECTF--
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 13
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 14
|
|
|
|
Warning: Undefined variable $ref in %s on line %d
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
|
|
Warning: Undefined variable $undef in %s on line %d
|
|
|
|
Deprecated: chop(): Passing null to parameter #1 ($string) of type string is deprecated in %s on line %d
|
|
|
|
Notice: Indirect modification of overloaded property Foo::$arr has no effect in %sbug43201.php on line 17
|
|
ok
|