php-src/ext/date
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
..
lib Updated to version 2022.1 (2022a) 2022-04-07 10:45:21 +01:00
tests Fix GH-8232 - always reference classes in var_export() via their FQCN 2022-04-23 11:06:21 +02:00
config0.m4 Drop -Wno-implicit-fallthrough compiler flag 2021-04-19 13:59:18 +01:00
config.w32 Upgrade timelib to 2021.03 and fix many date/time issues 2021-04-06 20:50:32 +01:00
CREDITS
php_date_arginfo.h getTimestamp does not return false 2021-09-30 09:13:55 +01:00
php_date.c Merge branch 'PHP-8.1' 2022-04-14 10:32:25 +01:00
php_date.h Use bool/zend_result instead of int in Date extension 2021-09-29 17:15:50 +01:00
php_date.stub.php getTimestamp does not return false 2021-09-30 09:13:55 +01:00