Skip to content

Commit 78c1652

Browse files
committed
fixup! Implement the "Redacting parameters in back traces" RFC
1 parent e9f0d34 commit 78c1652

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
A SensitiveParameterValue does not allow dynamic properties.
3+
--FILE--
4+
<?php
5+
6+
$v = new SensitiveParameterValue('secret');
7+
8+
$v->foo = 'bar';
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Uncaught Error: Cannot create dynamic property SensitiveParameterValue::$foo in %ssensitive_parameter_value_no_dynamic_property.php:5
13+
Stack trace:
14+
#0 {main}
15+
thrown in %ssensitive_parameter_value_no_dynamic_property.php on line 5

Zend/zend_attributes.stub.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,17 @@ final class AllowDynamicProperties
1919
public function __construct() {}
2020
}
2121

22+
/**
23+
* @strict-properties
24+
*/
2225
final class SensitiveParameter
2326
{
2427
public function __construct() {}
2528
}
2629

30+
/**
31+
* @strict-properties
32+
*/
2733
final class SensitiveParameterValue
2834
{
2935
private readonly mixed $value;

Zend/zend_attributes_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: dad2a0b36a6868cb6a15b600d12e155c40779114 */
2+
* Stub hash: f483cdaeb4123e65d6a1e29ce4ecb4f68b54d69b */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Attribute___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "Attribute::TARGET_ALL")
@@ -118,7 +118,7 @@ static zend_class_entry *register_class_SensitiveParameter(void)
118118

119119
INIT_CLASS_ENTRY(ce, "SensitiveParameter", class_SensitiveParameter_methods);
120120
class_entry = zend_register_internal_class_ex(&ce, NULL);
121-
class_entry->ce_flags |= ZEND_ACC_FINAL;
121+
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
122122

123123
return class_entry;
124124
}
@@ -129,7 +129,7 @@ static zend_class_entry *register_class_SensitiveParameterValue(void)
129129

130130
INIT_CLASS_ENTRY(ce, "SensitiveParameterValue", class_SensitiveParameterValue_methods);
131131
class_entry = zend_register_internal_class_ex(&ce, NULL);
132-
class_entry->ce_flags |= ZEND_ACC_FINAL;
132+
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NO_DYNAMIC_PROPERTIES;
133133

134134
zval property_value_default_value;
135135
ZVAL_UNDEF(&property_value_default_value);

0 commit comments

Comments
 (0)