We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ced9c19 commit 0166290Copy full SHA for 0166290
Zend/tests/pattern_matching/is/binding.phpt
@@ -36,10 +36,10 @@ var_dump($a);
36
var_dump('Hello world' is $a);
37
var_dump($a);
38
39
-var_dump(new Box(42) is Box { value: $a });
+var_dump(new Box(42) is Box & { value: $a });
40
41
42
-var_dump(new NotBox(43) is Box { value: $a });
+var_dump(new NotBox(43) is Box & { value: $a });
43
44
45
var_dump(43 is $a & int);
@@ -48,10 +48,10 @@ var_dump($a);
48
var_dump([] is $a & string);
49
50
51
-var_dump(new Many() is Many { $a, $b, $c, $d });
+var_dump(new Many() is { $a, $b, $c, $d });
52
var_dump($a, $b, $c, $d, isset($e));
53
54
-var_dump(new Many() is Many { $a, $b, $c, $d, $e, $f, $g, $h, $i, $j });
+var_dump(new Many() is { $a, $b, $c, $d, $e, $f, $g, $h, $i, $j });
55
var_dump($a, $b, $c, $d, $e, $f, $g, $h, $i, $j);
56
57
?>
Zend/tests/pattern_matching/is/delayed_binding.phpt
@@ -7,19 +7,19 @@ class Pair {
7
public function __construct(public $a, public $b) {}
8
}
9
10
-var_dump(new Pair(1, 2) is Pair { a: $a, b: $b });
+var_dump(new Pair(1, 2) is { a: $a, b: $b });
11
var_dump($a, $b);
12
unset($a, $b);
13
14
-var_dump(new Pair(1, 2) is Pair { a: $a, b: 3 });
+var_dump(new Pair(1, 2) is { a: $a, b: 3 });
15
16
17
18
-var_dump(new Pair(new \stdClass(), 2) is Pair { a: $a, b: 2 });
+var_dump(new Pair(new \stdClass(), 2) is { a: $a, b: 2 });
19
20
21
22
-var_dump(new Pair(new \stdClass(), 2) is Pair { a: $a, b: 3 });
+var_dump(new Pair(new \stdClass(), 2) is { a: $a, b: 3 });
23
24
25
Zend/tests/pattern_matching/is/object.phpt
@@ -9,21 +9,21 @@ class Foo {
) {}
public static function isSelfFoo($value) {
- return $value is self {};
+ return $value is self;
public static function isStaticFoo($value) {
- return $value is static {};
+ return $value is static;
class Bar extends Foo implements Baz {
public static function isSelfBar($value) {
public static function isParentBar($value) {
26
- return $value is parent {};
+ return $value is parent;
27
28
29
@@ -50,14 +50,14 @@ var_dump(null is Baz);
var_dump(null is Qux);
var_dump(null is Quux);
-var_dump($foo is Foo { a: 42 });
-var_dump($foo is Foo { a: 42|43 });
-var_dump($foo is Foo { a: 'hello world' });
-var_dump($foo is Foo { b: 42 });
-var_dump($bar is Foo { a: 42 });
58
-var_dump($bar is Foo { a: 42|43 });
59
-var_dump($bar is Foo { a: 'hello world' });
60
-var_dump($bar is Foo { b: 42 });
+var_dump($foo is { a: 42 });
+var_dump($foo is { a: 42|43 });
+var_dump($foo is { a: 'hello world' });
+var_dump($foo is { b: 42 });
+var_dump($bar is { a: 42 });
+var_dump($bar is { a: 42|43 });
+var_dump($bar is { a: 'hello world' });
+var_dump($bar is { b: 42 });
61
62
var_dump(Foo::isSelfFoo($foo));
63
var_dump(Foo::isSelfFoo($bar));
Zend/tests/pattern_matching/is/object_shorthand.phpt
@@ -7,9 +7,9 @@ class Foo {
-var_dump(new Foo(1, 2) is Foo { $a, b: 2 });
+var_dump(new Foo(1, 2) is { $a, b: 2 });
-var_dump(new Foo(1, 2) is Foo { a: 3, $b });
+var_dump(new Foo(1, 2) is { a: 3, $b });
var_dump($b);
Zend/zend_ast.h
@@ -116,6 +116,7 @@ enum _zend_ast_kind {
116
ZEND_AST_TYPE_PATTERN,
117
ZEND_AST_ARRAY_PATTERN,
118
ZEND_AST_BINDING_PATTERN,
119
+ ZEND_AST_OBJECT_PATTERN,
120
121
/* 2 child nodes */
122
ZEND_AST_DIM = 2 << ZEND_AST_NUM_CHILDREN_SHIFT,
@@ -161,7 +162,6 @@ enum _zend_ast_kind {
161
162
ZEND_AST_IS,
163
ZEND_AST_OR_PATTERN,
164
ZEND_AST_AND_PATTERN,
- ZEND_AST_OBJECT_PATTERN,
165
ZEND_AST_OBJECT_PATTERN_ELEMENT,
166
ZEND_AST_RANGE_PATTERN,
167
ZEND_AST_ARRAY_PATTERN_ELEMENT,
Zend/zend_language_parser.y
@@ -964,9 +964,9 @@ attributed_class_statement:
964
property_modifiers optional_type_without_static property_list ';'
965
{ $$ = zend_ast_create(ZEND_AST_PROP_GROUP, $2, $3, NULL);
966
$$->attr = $1; }
967
- /*| property_modifiers optional_type_without_static hooked_property
+ | property_modifiers optional_type_without_static hooked_property
968
{ $$ = zend_ast_create(ZEND_AST_PROP_GROUP, $2, zend_ast_create_list(1, ZEND_AST_PROP_DECL, $3), NULL);
969
- $$->attr = $1; }*/
+ $$->attr = $1; }
970
| class_const_modifiers T_CONST class_const_list ';'
971
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST_GROUP, $3, NULL, NULL);
972
@@ -1125,7 +1125,7 @@ property_hook_list:
1125
1126
optional_property_hook_list:
1127
%empty { $$ = NULL; }
1128
- /*| '{' property_hook_list '}' { $$ = $2; }*/
+ | '{' property_hook_list '}' { $$ = $2; }
1129
;
1130
1131
property_hook_modifiers:
@@ -1394,7 +1394,7 @@ scalar_pattern:
1394
1395
1396
object_pattern:
1397
- atomic_pattern '{' object_pattern_element_list '}' { $$ = zend_ast_create(ZEND_AST_OBJECT_PATTERN, $1, $3); }
+ '{' object_pattern_element_list '}' { $$ = zend_ast_create(ZEND_AST_OBJECT_PATTERN, $2); }
1398
1399
1400
object_pattern_element_list:
Zend/zend_pattern_matching.c
@@ -124,12 +124,7 @@ static pm_result match_object(zval *zv, zend_ast *pattern)
124
125
126
zend_object *obj = Z_OBJ_P(zv);
127
- pm_result type_result = match_type(zv, pattern->child[0]);
128
- if (type_result != PM_MATCH) {
129
- return type_result;
130
- }
131
-
132
- zend_ast_list *elements = zend_ast_get_list(pattern->child[1]);
+ zend_ast_list *elements = zend_ast_get_list(pattern->child[0]);
133
for (uint32_t i = 0; i < elements->children; i++) {
134
zend_ast *element = elements->child[i];
135
zend_ast *property_or_method_call = element->child[0];
0 commit comments