Skip to content

Commit 82f556a

Browse files
Update tests; tweak comments
1 parent f87967f commit 82f556a

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

Zend/tests/attributes/delayed_target_validation/errors_from_validator.phpt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ readonly class DemoReadonly {}
2020
enum DemoEnum {}
2121

2222
class DemoClass {
23-
#[DelayedTargetValidation]
24-
#[NoDiscard] // Does nothing here
25-
public $val;
26-
2723
public string $hooked {
2824
#[DelayedTargetValidation]
2925
#[NoDiscard] // Does nothing here
@@ -88,7 +84,7 @@ array(2) {
8884
string(22) "AllowDynamicProperties"
8985
}
9086
}
91-
Error: Cannot apply #[AllowDynamicProperties] to trait DemoTrait
87+
Error: Cannot apply #[\AllowDynamicProperties] to trait DemoTrait
9288
********************
9389
Interface [ <user> interface DemoInterface ] {
9490
@@ %s %d-%d
@@ -121,7 +117,7 @@ array(2) {
121117
string(22) "AllowDynamicProperties"
122118
}
123119
}
124-
Error: Cannot apply #[AllowDynamicProperties] to interface DemoInterface
120+
Error: Cannot apply #[\AllowDynamicProperties] to interface DemoInterface
125121
********************
126122
Class [ <user> readonly class DemoReadonly ] {
127123
@@ %s %d-%d
@@ -154,7 +150,7 @@ array(2) {
154150
string(22) "AllowDynamicProperties"
155151
}
156152
}
157-
Error: Cannot apply #[AllowDynamicProperties] to readonly class DemoReadonly
153+
Error: Cannot apply #[\AllowDynamicProperties] to readonly class DemoReadonly
158154
********************
159155
Enum [ <user> enum DemoEnum implements UnitEnum ] {
160156
@@ %s %d-%d
@@ -194,7 +190,7 @@ array(2) {
194190
string(22) "AllowDynamicProperties"
195191
}
196192
}
197-
Error: Cannot apply #[AllowDynamicProperties] to enum DemoEnum
193+
Error: Cannot apply #[\AllowDynamicProperties] to enum DemoEnum
198194
********************
199195
Method [ <user> public method $hooked::get ] {
200196
@@ %s %d - %d

Zend/tests/attributes/delayed_target_validation/has_runtime_errors.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Class [ <user> <iterateable> class Demo ] {
8888

8989
- Properties [3] {
9090
Property [ public string $v1 ]
91-
Property [ public string $v2 ]
91+
Property [ public string $v2 { get; set; } ]
9292
Property [ public string $v3 ]
9393
}
9494

Zend/tests/attributes/delayed_target_validation/with_NoDiscard.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ $v = $d->printVal();
5757
var_dump($d->val);
5858
$d->hooked = "foo";
5959
var_dump($d->hooked);
60-
// NODiscard does not support property hooks, this should not complain
60+
// NoDiscard does not support property hooks, this should not complain
6161
$d->hooked;
6262
var_dump(DemoClass::CLASS_CONST);
6363
demoFn();

Zend/zend_attributes.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ static void validate_allow_dynamic_properties(
7474
zend_attribute *attr, uint32_t target, zend_class_entry *scope)
7575
{
7676
if (scope == NULL) {
77-
// Only reachable when validator is run but the attribute isn't applied
78-
// to a class; in the case of delayed target validation reflection will
79-
// complain about the target before running the validator;
77+
/* Only reachable when validator is run but the attribute isn't applied
78+
* to a class; in the case of delayed target validation reflection will
79+
* complain about the target before running the validator. */
8080
ZEND_ASSERT(target & ZEND_ATTRIBUTE_NO_TARGET_VALIDATION);
8181
return;
8282
}
@@ -215,8 +215,7 @@ static void validate_nodiscard(
215215
{
216216
/* There isn't an easy way to identify the *method* that the attribute is
217217
* applied to in a manner that works during both compilation (normal
218-
* validation) and runtime (delayed validation). So, handle them separately.
219-
*/
218+
* validation) and runtime (delayed validation). So, handle them separately. */
220219
if (CG(in_compilation)) {
221220
ZEND_ASSERT((target & ZEND_ATTRIBUTE_DELAYED_TARGET_VALIDATION) == 0);
222221
zend_op_array *op_array = CG(active_op_array);

0 commit comments

Comments
 (0)