php-src/ext/opcache/tests/bool_not_cv.phpt
Tyson Andre a2c41c0ea6 Fix $x = (bool)$x; for undefined with opcache
And `$x = !$x`

Noticed while working on GH-4912

The included test would not emit undefined variable errors in php 8.0
with opcache enabled. The command used:

```
php -d zend_extension=opcache.so --no-php-ini -d error_reporting=E_ALL \
    -d opcache.file_cache= -d opcache.enable_cli=1  test.php
```
2019-11-18 11:24:03 +03:00

35 lines
617 B
PHP

--TEST--
$v = !$v/(bool)$v checks for undefined variables
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_cache_only=0
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
function undef_negation() {
echo "In undef_negation\n";
$v = !$v;
var_export($v);
echo "\n";
}
function undef_bool_cast() {
echo "In undef_bool_cast\n";
$v = (bool)$v;
var_export($v);
echo "\n";
}
undef_negation();
undef_bool_cast();
?>
--EXPECTF--
In undef_negation
Notice: Undefined variable: v in %s on line 4
true
In undef_bool_cast
Notice: Undefined variable: v in %s on line 10
false