1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00
Commit Graph

20 Commits

Author SHA1 Message 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
Nikita Popov 7485978339 Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Nikita Popov f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Gabriel Caruso 9c144e0d82 Trim trailing whitespace in tests 2018-10-14 12:07:20 -03:00
Andrea Faulds e4e9cd8355 Export stdClass objects using (object) cast (fixes #48016)
Before this change, var_export()'s output for stdClass objects calls
the non-existent stdClass::__set_state method, and is therefore useless.

This commit makes var_export() output an (object) cast from an array
instead, which when evaluated, will produce a stdClass object. Other
classes see unchanged output.
2018-07-12 13:22:26 +02:00
Ben Scholzen d896878ad5 Let MessageFormatter and IntlDateFormatter accept DateTimeImmutable as well 2017-03-29 00:20:46 +02:00
krakjoe e530817209 fix the version requirements for these tests 2014-08-21 09:29:43 +01:00
Adam Harvey 6d9cc92238 Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4:
  Fix broken test caused by fdb2709.

Conflicts:
	ext/intl/tests/dateformat_format.phpt
2014-05-23 15:14:00 +00:00
Adam Harvey 319611ffbd Fix broken test caused by fdb2709. 2014-05-23 15:07:19 +00:00
Stanislav Malyshev ee1b807219 fix the test according to how new date code does it 2014-04-05 20:09:53 -07:00
Anatol Belski 4840b0a749 fixed failing tests for ICU >= 51.2 2013-10-07 13:49:10 +02:00
Gustavo André dos Santos Lopes 06e06f026d Merge branch '5.4'
* 5.4:
  Fix test title and limit it to ICU >= 4.8
  Remove executable bit from files
  Limit test to ICU 49
  Remove executable bit from files
2012-07-30 11:04:48 +02:00
Gustavo André dos Santos Lopes 9762609cec Remove executable bit from files 2012-07-30 10:25:17 +02:00
Gustavo André dos Santos Lopes 2f0775b999 Added IntlDateFormatter::formatObject(). Refactor
To better support IntlCalendar, added this function:

string IntlDateFormatter::formatObject(IntlCalendar|DateTime $obj [,
	array|int|string $format = null [, string $locale = null).

$format is either of the constants IntlDateFormatter::FULL, etc., in
which case this format applies to both the date and the time, an array
in the form array($dateFormat, $timeFormat), or a string with the
SimpleDateFormat pattern.

This uses both the Calendar type and the timezone of the passed object
to configure the formatter (a GregorianCalendar is forced for
DateTime).

Some stuff was moved around and slighlt modified to allow for more code
reuse.
2012-07-22 04:22:23 +02:00
Gustavo André dos Santos Lopes 2416719fb1 Unified zval -> UDate conversions
Now IntlDateFormatter::format() also accepts IntlCalendar objects.
Code is shared in MessageFormatter and IntlDateFormatter.
2012-07-02 00:24:54 +02:00
Gustavo André dos Santos Lopes 758f0686d4 Added and fixed tests given eb346ef 2012-06-04 00:02:35 +02:00
Stanislav Malyshev 0ba1cd1bd2 Add support for DateTime in datefmt_format 2010-11-20 02:09:04 +00:00
Stanislav Malyshev 4415b3af51 Add support for DateTime in datefmt_format 2010-11-20 02:09:04 +00:00
Stanislav Malyshev 9bb39338db fix tests 2008-09-04 00:16:58 +00:00
Stanislav Malyshev 0d16b1516b Merge intl extension into core 2008-07-07 22:51:04 +00:00