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
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
arm:
resource_class: arm.medium
docker:
- image: cimg/base:current-22.04
- image: cimg/base:current-24.04
- image: mysql:8.3
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: true
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
libreadline-dev \
libldap2-dev \
libsodium-dev \
libargon2-0-dev \
libargon2-dev \
libmm-dev \
libsnmp-dev \
snmpd \
Expand All @@ -78,7 +78,7 @@ jobs:
libqdbm-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev
libfreetype-dev
- run:
name: ./configure
command: |
Expand Down
54 changes: 54 additions & 0 deletions Zend/tests/enum/comparison-internal.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--TEST--
Enum comparison (internal enum)
--EXTENSIONS--
zend_test
--FILE--
<?php

$foo = ZendTestUnitEnum::Foo;
$bar = ZendTestUnitEnum::Bar;

var_dump($foo === $foo);
var_dump($foo == $foo);

var_dump($foo === $bar);
var_dump($foo == $bar);

var_dump($bar === $foo);
var_dump($bar == $foo);

var_dump($foo > $foo);
var_dump($foo < $foo);
var_dump($foo >= $foo);
var_dump($foo <= $foo);

var_dump($foo > $bar);
var_dump($foo < $bar);
var_dump($foo >= $bar);
var_dump($foo <= $bar);

var_dump($foo > true);
var_dump($foo < true);
var_dump($foo >= true);
var_dump($foo <= true);

?>
--EXPECT--
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
14 changes: 14 additions & 0 deletions Zend/tests/enum/implements-internal.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
Enum implements (internal enum)
--EXTENSIONS--
zend_test
--FILE--
<?php

var_dump(ZendTestUnitEnum::Foo instanceof _ZendTestInterface);
var_dump(ZendTestEnumWithInterface::Foo instanceof _ZendTestInterface);

?>
--EXPECT--
bool(false)
bool(true)
6 changes: 6 additions & 0 deletions Zend/tests/enum/instanceof-backed-enum.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Auto implement BackedEnum interface
--EXTENSIONS--
zend_test
--FILE--
<?php

Expand All @@ -13,8 +15,12 @@ enum Baz: int {

var_dump(Foo::Bar instanceof BackedEnum);
var_dump(Baz::Qux instanceof BackedEnum);
var_dump(ZendTestUnitEnum::Foo instanceof BackedEnum);
var_dump(ZendTestIntEnum::Foo instanceof BackedEnum);

?>
--EXPECT--
bool(false)
bool(true)
bool(false)
bool(true)
4 changes: 4 additions & 0 deletions Zend/tests/enum/instanceof-unitenum.phpt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Auto implement UnitEnum interface
--EXTENSIONS--
zend_test
--FILE--
<?php

Expand All @@ -11,8 +13,10 @@ class Baz {}

var_dump(Foo::Bar instanceof UnitEnum);
var_dump((new Baz()) instanceof UnitEnum);
var_dump(ZendTestUnitEnum::Foo instanceof UnitEnum);

?>
--EXPECT--
bool(true)
bool(false)
bool(true)
16 changes: 16 additions & 0 deletions Zend/tests/enum/no-clone-internal.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Enum disallows cloning (internal enum)
--EXTENSIONS--
zend_test
--FILE--
<?php

try {
var_dump(clone ZendTestIntEnum::Foo);
} catch (Error $e) {
echo $e->getMessage() . "\n";
}

?>
--EXPECT--
Trying to clone an uncloneable object of class ZendTestIntEnum
18 changes: 18 additions & 0 deletions Zend/tests/enum/no-dynamic-properties-internal.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Enum case disallows dynamic properties (internal enum)
--EXTENSIONS--
zend_test
--FILE--
<?php

$bar = ZendTestUnitEnum::Bar;

try {
$bar->baz = 'Baz';
} catch (\Error $e) {
echo $e->getMessage();
}

?>
--EXPECT--
Cannot create dynamic property ZendTestUnitEnum::$baz
17 changes: 17 additions & 0 deletions Zend/tests/oss-fuzz-474613951.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
OSS-Fuzz #474613951: Leaked parent property default value
--FILE--
<?php

class A {
public $prop = C { get => $this->prop; }
}

class B extends A {
public $prop { get => 42; }
}

?>
===DONE===
--EXPECT--
===DONE===
1 change: 1 addition & 0 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(

break;
}
EMPTY_SWITCH_DEFAULT_CASE()
}

zend_create_fake_closure(result, fptr, fptr->common.scope, called_scope, NULL);
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_enum.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ ZEND_API zend_class_entry *zend_register_internal_enum(
zend_class_implements(ce, 1, zend_ce_backed_enum);
}

ce->default_object_handlers = &zend_enum_object_handlers;

return ce;
}

Expand Down
5 changes: 2 additions & 3 deletions Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1515,10 +1515,9 @@ static void do_inherit_property(zend_property_info *parent_info, zend_string *ke
}

int parent_num = OBJ_PROP_TO_NUM(parent_info->offset);
/* Don't keep default properties in GC (they may be freed by opcache) */
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));
if (child_info->offset != ZEND_VIRTUAL_PROPERTY_OFFSET) {
/* Don't keep default properties in GC (they may be freed by opcache) */
zval_ptr_dtor_nogc(&(ce->default_properties_table[parent_num]));

if (use_child_prop) {
ZVAL_UNDEF(&ce->default_properties_table[parent_num]);
} else {
Expand Down
2 changes: 2 additions & 0 deletions ext/zend_test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static zend_class_entry *zend_test_ns2_ns_foo_class;
static zend_class_entry *zend_test_unit_enum;
static zend_class_entry *zend_test_string_enum;
static zend_class_entry *zend_test_int_enum;
static zend_class_entry *zend_test_enum_with_interface;
static zend_class_entry *zend_test_magic_call;
static zend_object_handlers zend_test_class_handlers;

Expand Down Expand Up @@ -1576,6 +1577,7 @@ PHP_MINIT_FUNCTION(zend_test)
zend_test_unit_enum = register_class_ZendTestUnitEnum();
zend_test_string_enum = register_class_ZendTestStringEnum();
zend_test_int_enum = register_class_ZendTestIntEnum();
zend_test_enum_with_interface = register_class_ZendTestEnumWithInterface(zend_test_interface);

zend_test_magic_call = register_class__ZendTestMagicCall();

Expand Down
5 changes: 5 additions & 0 deletions ext/zend_test/test.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@ enum ZendTestIntEnum: int {
case Baz = -1;
}

enum ZendTestEnumWithInterface implements _ZendTestInterface {
case Foo;
case Bar;
}

function zend_trigger_bailout(): never {}

function zend_test_array_return(): array {}
Expand Down
16 changes: 15 additions & 1 deletion ext/zend_test/test_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.