Commit Graph

15509 Commits

Author SHA1 Message Date
Máté Kocsis
ac0853eb26
Make type error messages more consistent
Closes GH-5092
2020-02-17 14:22:17 +01:00
Nikita Popov
72bd55902d Improve generated names for anonymous classes
In order of preference, the generated name will be:

    new class extends ParentClass {};
    // -> ParentClass@anonymous
    new class implements FirstInterface, SecondInterface {};
    // -> FirstInterface@anonymous
    new class {};
    // -> class@anonymous

This is intended to display a more useful class name in error messages
and stack traces, and thus make debugging easier.

Closes GH-5153.
2020-02-17 12:21:33 +01:00
Nikita Popov
43443857b7 Add static return type
RFC: https://wiki.php.net/rfc/static_return_type

The "static" type is represented as MAY_BE_STATIC, rather than
a class type like "self" and "parent", as it has special
resolution semantics, and cannot be cached in the runtime cache.

Closes GH-5062.
2020-02-17 11:51:09 +01:00
Michael Voříšek
d2ba848572 Use strlen for INI_* macros
strlen() is resolved at compile time by optimizing compilers.

Prevent mistakes and allow to use INI_* macros with char * variables
which can have sizeof() == 1.

Closes GH-5174.
2020-02-17 11:11:14 +01:00
Christoph M. Becker
6ee6097688 Constrain number parameter of numfmt_format to int|float
This is inline with similar changes to the math functions.  Especially,
array to number conversion makes no sense here, and is likely to hide
a programming error.

To make that feasible, we introduce the `n` specifier for classic ZPP
so we can stick with `zend_parse_method_parameters()`.

We also remove a test case, which has been degenerated to a ZPP test.
2020-02-16 16:48:35 +01:00
Nikita Popov
f3d8ac1d95 Fix JIT trait type errors
We need to load EX->func here rather than use a hardcoded op_array,
as it may be copied with adjusted scope for traits.
2020-02-13 15:16:23 +01:00
Michael Voříšek
f15b5ff353 Add const modifier for name strings
Closes GH-5173.
2020-02-13 14:44:06 +01:00
Nikita Popov
907ae8d4c6 Reset required_num_args for disabled functions
Otherwise we may get arginfo/zpp mismatch errors.
2020-02-12 12:01:22 +01:00
Nikita Popov
ae6f45ad45 var_dump(): Don't skip recursion detection on first level
This is confusing. The current output doesn't make it clear that
we're in fact recursing to the top-level structure.

Closes GH-5171.
2020-02-12 11:25:50 +01:00
Dmitry Stogov
437404b03a Reuse SEPARATE_ARRAY() macro 2020-02-11 16:42:23 +03:00
Nikita Popov
c141ee3f9c Allow arbitrary expressions in new/instanceof using () syntax 2020-02-11 12:33:23 +01:00
Nikita Popov
357fbc9902 Treat magic constants like normal constants 2020-02-11 12:33:23 +01:00
Nikita Popov
ab154b7a64 Make class constants fully dereferencable 2020-02-11 12:33:23 +01:00
Nikita Popov
de7c7efee9 Unify array and object dereferencability 2020-02-11 12:33:23 +01:00
Nikita Popov
465e6f53ed Split into fully_dereferencable and array_dereferencable 2020-02-11 12:33:23 +01:00
Nikita Popov
cf5689e961 Split class_constant from constant production 2020-02-11 12:33:23 +01:00
Nikita Popov
24e365f9e2 Make encapsed strings fully dereferencable
This allows operations that were previously allowed on constant
strings on interpolated strings as well.
2020-02-11 12:33:23 +01:00
Nikita Popov
d933591674 Add support for $obj::class
This allows $obj::class, which gives the same result as get_class($obj).
Anything other than an object results in TypeError.

RFC: https://wiki.php.net/rfc/class_name_literal_on_object

Closes GH-5065.
2020-02-11 12:16:30 +01:00
George Peter Banyard
e01d2162b2 Fix [-Wmissing-field-initializers] compiler warning in zend_iterator
Add missing NULL pointer for get_properties_for in iterator_object_handlers
initialization.

Also add two missing comments describing what the NULL pointer refer
to in iterator_object_handlers initialization.
2020-02-10 11:46:19 +01:00
Nikita Popov
fc0c71ad30 Deref slow-path ASSIGN_OBJ result
We should not store a reference inside IS_TMP_VAR.
2020-02-10 10:42:06 +01:00
Xinchen Hui
421a7342fe Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
2020-02-10 13:02:45 +08:00
Xinchen Hui
6295ff77b7 Fixed bug #79244 (php crashes during parsing INI file). (Laruence)
Cherry-picked the fix(not sure why this wasn't merged to 7.4) for:
Fixed bug #77589 (Core dump using parse_ini_string with numeric sections)

Section name should not be typed(NULL, FALSE, TRUE etc)

Conflicts:

	Zend/zend_ini_scanner.c
2020-02-10 13:01:51 +08:00
Dmitry Stogov
64b40f69dc Make ASSIGN, ASSIGN_OP, INC and DEC opcodes to return IS_TMP_VAR instead of IS_VAR.
This helps to avoid unnecessary IS_REFERENCE checks.
This changes some notices "Only variables should be passed by reference" to exception "Cannot pass parameter %d by reference".

Also, for consistency, compile-time fatal error "Only variables can be passed by reference" was converted to exception "Cannot pass parameter %d by reference"
2020-02-07 13:36:52 +03:00
Nikita Popov
bc6bab6cb4 Basic JIT support for verify return 2020-02-07 12:59:48 +03:00
Dmitry Stogov
b53445422a Merge branch 'PHP-7.4'
* PHP-7.4:
  Make opcodes to return de-refereced values of typed references (in the same was as for non-typed)
2020-02-06 15:57:29 +03:00
Dmitry Stogov
5d0ef4c239 Make opcodes to return de-refereced values of typed references (in the same was as for non-typed) 2020-02-06 15:48:54 +03:00
Nikita Popov
d4de3f95d6 Remove spurious const qualifier from function return type 2020-02-06 11:59:52 +01:00
Nikita Popov
53e527ad43 Remove ZEND_ACC_IMPLEMENT_INTERFACES flag
This is equivalent to checking ce->num_interfaces. The only subtle
moment is during inheritance, where num_interface may change when
parent interfaces are inherited. The check in zend_do_link_class
thus uses "interfaces", not "ce->num_interfaces".
2020-02-06 10:53:12 +01:00
Nikita Popov
f57f0920fd Remove ZEND_ACC_IMPLEMENTS_TRAITS flag
This is equivalent to checking ce->num_traits.
2020-02-06 10:45:49 +01:00
Nikita Popov
4f5f72c7af Remove ZEND_ACC_INHERITED flag
It is equivalent to checking ce->parent != NULL. Just adds more
state that needs to be kept in sync.
2020-02-06 10:42:25 +01:00
George Peter Banyard
62c51fc4a7 Adjust XFAIL tests due to TypeErrors
Closes GH-5152
2020-02-05 23:45:10 +01:00
George Peter Banyard
c343c1bcae Fix some -Wold-style-declaration compiler warnings 2020-02-05 17:39:29 +01:00
Nikita Popov
f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Nikita Popov
169805777c Merge branch 'PHP-7.4'
* PHP-7.4:
  Apply tidy formatting
2020-02-03 13:42:08 +01:00
Nikita Popov
58b17906f5 Apply tidy formatting
Mostly reindent PHP scripts to spaces.
2020-02-03 13:41:31 +01:00
Derick Rethans
d6b04bfbd5 Export zend_type_to_string() with ZEND_API 2020-02-03 10:26:20 +00:00
Nikita Popov
98a8ab1389 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add WHITESPACE_SENSITIVE run-tests section
2020-02-03 10:08:20 +01:00
Nikita Popov
27fb0b28dd Add WHITESPACE_SENSITIVE run-tests section
This is used to indicate that the test should not be changed by
automated formatting changes.
2020-02-03 10:08:15 +01:00
Akim Demaille
4cbffd89d9
Clean up the generation of the parsers
Prefer '%define api.value.type' to '#define YYSTYPE', so that Bison
know the type.

Use '%code requires' to declare what is needed to define the api.value.type
(that code is output in the generated header before the generated
definition of YYSTYPE).

Prefer '%define api.prefix' inside the grammar file to '-p' outside,
as anyway the functions defined in the file actually use this prefix.

Prefer `%param` to both `%parse-param` and `%lex-param`.

Closes GH-5138
2020-02-01 14:21:53 +01:00
Akim Demaille
2127a37b83
Bison: enable all the warnings and fix them
First, fix 5547d36120: the definition of
YFLAGS was not passed into the Makefile: AC_SUBST does not suffice, we
need PHP_SUBST_OLD.  While at it, allow to pass variable and value at
the same time.

Then pass -Wall to bison, rather than only -Wempty-rules.

Use %precedence where associativity is useless.

Remove useless %precedence.
GH-5138
2020-02-01 14:21:21 +01:00
Dmitry Stogov
2b279b428f We don't need "safe" destruction anymore 2020-01-31 16:01:09 +03:00
Nikita Popov
ec0ce49f5c Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #76047
2020-01-31 10:30:09 +01:00
Nikita Popov
d422478f6d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #76047
2020-01-31 10:29:45 +01:00
Nikita Popov
ef1e4891b4 Fix bug #76047
Unlink the current stack frame before freeing CVs or extra args.
This means it will no longer show up in back traces that are
generated during CV destruction.

We already did this prior to destructing the object/closure,
presumably for the same reason.
2020-01-31 10:26:40 +01:00
Akim Demaille
37d0f7d3b3
Use "%empty" in the parsers, instead of comments
The annotation %empty is properly enforced: warnings when it's
missing, and errors when it's inappropriate.  Support for %empty was
introduced in Bison 3.0.

Pass -Wempty-rule to Bison.

Closes GH-5134
2020-01-31 09:52:40 +01:00
Dmitry Stogov
7ebf1d44ed Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79094 (Crashing when running recursion function)
2020-01-31 10:34:28 +03:00
Dmitry Stogov
db7193f31e Fixed bug #79094 (Crashing when running recursion function) 2020-01-31 10:34:04 +03:00
Nikita Popov
981fdd9f51 Merge branch 'PHP-7.4'
* PHP-7.4:
  fix cross compilation failure due to size_t typecast in define
2020-01-30 15:52:22 +01:00
Pascal de Bruijn
f0f5c415a6 fix cross compilation failure due to size_t typecast in define
The following commit introduces a cross-compilation failure:

   93c728b77c
  "Try to control ZEND_MM_ALIGNED_SIZE type"

br-arm-full/build/php-7.4.2/Zend/zend_alloc.h:30:38:
error: missing binary operator before token "8"
                                              ^
br-arm-full/build/php-7.4.2/ext/opcache/ZendAccelerator.c:1380:7:
note: in expansion of macro ‘ZEND_MM_ALIGNMENT’

Closes GH-5128.
2020-01-30 15:51:54 +01:00
Nikita Popov
38e27625ea Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix live range calculation for FE_FETCH
2020-01-30 14:24:28 +01:00