php-src/Zend/tests/function_arguments
Marco Pivetta 25cb9cdb79
Fix GH-8232 - always reference classes in var_export() via their FQCN
Closes GH-8233

This fix corrects a behavior of `var_export()` that was mostly "hidden" until PHP 8.1 introduced:

* properties with object initializers
* constants containing object references
* default values of class properties containing `enum`s

Since `var_export(..., true)` is mostly used in conjunction with code generation,
and we cannot make assumptions about the generated code being placed in the root
namespace, we must always provide the FQCN of a class in exported code.

For example:

```php
<?php

namespace MyNamespace { class Foo {} }

namespace { echo "<?php\n\nnamespace Example;\n\n" . var_export(new \MyNamespace\Foo(), true) . ';'; }
```

produces:

```php
<?php

namespace Example;

MyNamespace\Foo::__set_state(array(
));
```

This code snippet is invalid, because `Example\MyNamespace\Foo::__set_state()` (which
does not exist) is called.

With this patch applied, the code looks like following (valid):

```php
<?php

namespace Example;

\MyNamespace\Foo::__set_state(array(
));
```

Ref: https://github.com/php/php-src/issues/8232
Ref: https://github.com/Ocramius/ProxyManager/issues/754
Ref: https://externals.io/message/117466
2022-04-23 11:06:21 +02:00
..
argument_count_correct.phpt
argument_count_correct_strict.phpt
argument_count_incorrect_internal.phpt
argument_count_incorrect_internal_strict.phpt
argument_count_incorrect_userland.phpt
argument_count_incorrect_userland_strict.phpt
call_with_leading_comma_error.phpt
call_with_multi_inner_comma_error.phpt
call_with_multi_trailing_comma_error.phpt
call_with_only_comma_error.phpt
call_with_trailing_comma_basic.phpt
sensitive_parameter.phpt
sensitive_parameter_arrow_function.phpt
sensitive_parameter_closure.phpt
sensitive_parameter_correctly_captures_original.phpt
sensitive_parameter_eval_call.phpt
sensitive_parameter_eval_define.phpt
sensitive_parameter_extra_arguments.phpt
sensitive_parameter_multiple_arguments.phpt
sensitive_parameter_named_arguments.phpt
sensitive_parameter_nested_calls.phpt
sensitive_parameter_value.phpt Fix GH-8232 - always reference classes in var_export() via their FQCN 2022-04-23 11:06:21 +02:00
sensitive_parameter_value_clone.phpt
sensitive_parameter_value_keeps_object_alive.phpt
sensitive_parameter_value_no_dynamic_property.phpt
sensitive_parameter_value_reflection.phpt
sensitive_parameter_value_serialize.phpt
sensitive_parameter_value_to_string.phpt
sensitive_parameter_variadic_arguments.phpt
variadic_argument_type_error.phpt