Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@
<file>./test/compliance/UnserializeEmptySilentJITTest.php</file>
<file>./test/compliance/DynPropIncUndefinedWarnVMTest.php</file>
<file>./test/compliance/DynPropIncUndefinedWarnJITTest.php</file>
<file>./test/compliance/MagicPropIncNoUndefWarnVMTest.php</file>
<file>./test/compliance/MagicPropIncNoUndefWarnJITTest.php</file>
<file>./test/compliance/MagicPropDecNoUndefWarnVMTest.php</file>
<file>./test/compliance/MagicPropDecNoUndefWarnJITTest.php</file>
<file>./test/compliance/XmlGetCurrentReflectionVMTest.php</file>
<file>./test/compliance/XmlParserGetOptionReflectionVMTest.php</file>
<file>./test/compliance/XmlParserFreeReflectionVMTest.php</file>
Expand Down
29 changes: 29 additions & 0 deletions test/compliance/MagicPropDecNoUndefWarnJITTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

require_once __DIR__.'/../BaseTest.php';

/**
* JIT: --$obj->n / $obj->n-- with __get/__set emits no Undefined property (#32014).
*/
final class MagicPropDecNoUndefWarnJITTest extends BaseTest
{
protected static string $DIR = __DIR__;

public static function providePHPTests(): \Generator
{
$file = 'magic_prop_dec_no_undef_warn.phpt';
yield $file => self::parsePHPT(
__DIR__.'/cases/language/'.$file,
$file
);
}

public function setUp(): void
{
$this->BIN = realpath(__DIR__.'/../../bin/jit.php');
}
}
29 changes: 29 additions & 0 deletions test/compliance/MagicPropDecNoUndefWarnVMTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace PHPCompiler;

require_once __DIR__.'/../BaseTest.php';

/**
* VM: --$obj->n / $obj->n-- with __get/__set emits no Undefined property (#32014).
*/
final class MagicPropDecNoUndefWarnVMTest extends BaseTest
{
protected static string $DIR = __DIR__;

public static function providePHPTests(): \Generator
{
$file = 'magic_prop_dec_no_undef_warn.phpt';
yield $file => self::parsePHPT(
__DIR__.'/cases/language/'.$file,
$file
);
}

public function setUp(): void
{
$this->BIN = realpath(__DIR__.'/../../bin/vm.php');
}
}
28 changes: 28 additions & 0 deletions test/compliance/cases/language/magic_prop_dec_no_undef_warn.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
Language: --$obj->n / $obj->n-- with __get/__set emits no Undefined property (#32014, zend_object_handlers.c)
--FILE--
<?php
error_reporting(E_ALL);
class M {
private $d = ['n' => 1];
public function __get($k) { return $this->d[$k]; }
public function __set($k, $v) { $this->d[$k] = $v; }
}
$errs = [];
set_error_handler(static function (int $errno, string $errstr) use (&$errs): bool {
$errs[] = [$errno, $errstr];
return true;
});
$m = new M();
--$m->n;
restore_error_handler();
foreach ($errs as $e) {
echo "err[{$e[0]}] {$e[1]}\n";
}
echo "dec=", $m->n, "\n";
$m = new M();
$m->n--;
echo "postdec=", $m->n, "\n";
--EXPECT--
dec=0
postdec=0
10 changes: 10 additions & 0 deletions test/repro/maintainer_gap_magic_prop_dec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
error_reporting(E_ALL);
class M {
private $d = ['n' => 1];
public function __get($k) { return $this->d[$k]; }
public function __set($k, $v) { $this->d[$k] = $v; }
}
$m = new M();
--$m->n;
echo 'dec=', $m->n, "\n";
10 changes: 10 additions & 0 deletions test/repro/maintainer_gap_magic_prop_postdec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
error_reporting(E_ALL);
class M {
private $d = ['n' => 1];
public function __get($k) { return $this->d[$k]; }
public function __set($k, $v) { $this->d[$k] = $v; }
}
$m = new M();
$m->n--;
echo 'postdec=', $m->n, "\n";