Commit Graph

2868 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
Dmitry Stogov
cf8407a238 Fixed bug #79255 (PHP cannot be compiled with enable JIT) 2020-02-17 12:03:49 +03:00
Nikita Popov
7a8f180b19 Revert "Fixed bug #79255 (PHP cannot be compiled with enable JIT)"
This reverts commit de6984edd5.

Reverting to unbreak 32-bit CI.
2020-02-17 09:34:56 +01:00
Xinchen Hui
de6984edd5 Fixed bug #79255 (PHP cannot be compiled with enable JIT) 2020-02-17 13:13:49 +08: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
Dmitry Stogov
b79af3d4df Removed unused macro 2020-02-11 17:30:49 +03: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
Dmitry Stogov
a9e35b843c Save delayed call frame 2020-02-10 13:43:32 +03:00
Dmitry Stogov
cf8dc1c1a2 typo 2020-02-07 14:21:56 +03: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
Dmitry Stogov
ad3f768253 Fixed stack alignment 2020-02-07 13:00:48 +03:00
Nikita Popov
d8840a1b69 Try to fix Windows build 2020-02-07 12:59:48 +03:00
Nikita Popov
bc6bab6cb4 Basic JIT support for verify return 2020-02-07 12:59:48 +03:00
Dmitry Stogov
170cc10519 Fixed JIT for PTR_INC instruction to return de-referenced value of reference 2020-02-06 21:29:43 +03: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
Dmitry Stogov
daee985709 Fixed JIT for BIND_GLOBAL 2020-02-04 15:56:55 +03:00
Nikita Popov
f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Dmitry Stogov
2b279b428f We don't need "safe" destruction anymore 2020-01-31 16:01:09 +03:00
Dmitry Stogov
6b862e82d9 These EG(current_execute_data) = EX(prev_execute_data) assignments are useless now 2020-01-31 14:50:41 +03:00
Dmitry Stogov
08d2d9257d Export zend_dump_op() and add ZEND_DUMP_NUMERIC_OPLINES flag to print oplines as "dddd" instead of "Ld+" 2020-01-31 13:27:35 +03:00
Nikita Popov
d8a1e3dab0 Fix JIT as well 2020-01-31 10:35:46 +01:00
Dmitry Stogov
7e7a85e881 Fixed JIT part for bug #79094 2020-01-31 10:39:22 +03:00
Nikita Popov
b33697d47e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79193
2020-01-30 14:56:31 +01:00
Nikita Popov
f70b552326 Fixed bug #79193 2020-01-30 14:55:58 +01:00
Tyson Andre
5f92a085cc Convert ZEND_ECHO operand to string after sccp
And filter out echoes of the empty string (e.g. false/null)

Split out of #5097 (on GitHub)

Closes GH-5118
2020-01-27 20:21:24 -05:00
Nikita Popov
ebd00c5b65 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79128
2020-01-24 16:20:30 +01:00
Nikita Popov
3291891408 Fixed bug #79128
We need to extend the hash table before performing raw append
operations.

This doesn't matter if preloading happens in the same process,
as the tables will be large enough to hold all entries as a
side-effect of the preloading process. However, if preloading
happens in a different process, we need to reserve space here.
2020-01-24 16:18:48 +01:00
Xinchen Hui
ce5d722a6d Merge branch 'PHP-7.4'
* PHP-7.4:
  Let's make this safer from maliciously crafted filename
2020-01-20 12:35:08 +08:00
Xinchen Hui
2958cdc0b5 Let's make this safer from maliciously crafted filename 2020-01-20 12:33:37 +08:00
Xinchen Hui
5aa12d2e32 Merge branch 'PHP-7.4'
* PHP-7.4:
  minor cleanup
2020-01-20 12:29:23 +08:00
Xinchen Hui
dda2addab2 minor cleanup 2020-01-20 12:28:57 +08:00
Xinchen Hui
31dd635eb3 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79114 (Eval class during preload causes class to be only half available)
2020-01-20 12:25:10 +08:00
Xinchen Hui
9c2fd55d01 Fixed bug #79114 (Eval class during preload causes class to be only half available) 2020-01-20 12:24:49 +08:00
Máté Kocsis
99db00b1f2
Fix #78880 Another round 2020-01-19 18:28:43 +01:00
Tyson Andre
3c72105edb Remove leftover ZEND_CAST code for (unset) cast.
Followup for d74d3922ce

Attempting to require a file with (unset) casts results in an E_COMPILE_ERROR
that can't be caught or handled by set_exception_handler/set_error_handler.

Also remove the (bool) cast, because the ZEND_BOOL opcode handles that.

Remove inference that array -> object cast can throw.
It was added in 2a286ad599 - I don't know how creating an stdClass would throw.
(numeric keys, references, etc. don't cause it to throw)

Closes GH-5042
2020-01-18 11:06:19 -05:00
Nikita Popov
9ec1ee5976 Add support for deprecating constants
Internal constants can be marked as CONST_DEPRECATED, in which
case accessing them will throw a deprecation warning.

For now this is only supported on global constants, not class
constants. Complain to me if you need to deprecate a class
constant...

Closes GH-5072.
2020-01-17 10:05:06 +01:00
Nikita Popov
43719022ea Improve SSA representation of FE_FETCH
The op2 of FE_FETCH is only written if the loop edge is taken.
Fix up the SSA form to use the pre-assignment value if the exit
edge is taken.

This allows us to properly infer the type of the loop variable,
without letting the pre-loop type leak in.

Closes GH-5040.
2020-01-17 09:41:27 +01:00
Nikita Popov
bd1977282c Use zend_type inside type lists
Instead of having a completely independent encoding for type list
entries. This is going to use more memory, but I'm not particularly
concerned about that, as type unions that contain multiple classes
should be uncommon. On the other hand, this allows us to treat
top-level types and types inside lists mostly the same.

A new ZEND_TYPE_FOREACH macros allows to transparently treat list
and non-list types the same way. I'm not using it everywhere it could be
used for now, just the places that seemed most obvious.

Of course, this will make any future type system changes much simpler,
as it will not be necessary to duplicate all logic two times.
2020-01-17 09:37:54 +01:00
Máté Kocsis
afdaa91170
Fix #78880: Final spelling fixes 2020-01-16 19:14:31 +01:00
Máté Kocsis
0b4778c377
Fix #78880: Another bunch of spelling errors 2020-01-16 09:46:47 +01:00
Dmitry Stogov
8ee04946f0 typo 2020-01-13 16:25:42 +03:00
Nikita Popov
862a4f3a5e Fix build 2020-01-13 12:42:51 +01:00
Dmitry Stogov
27815959e1 Improve access to zend_map_ptr data 2020-01-13 14:27:35 +03:00
George Peter Banyard
bfe3f934a3 Add warning and convert to exception in string offset assignment:
Convert the empty string assignment to an Error as per RFC [1]
Add a warning that only the first byte will be assigned to the offset if provided
a needle that is longer than one byte.

[1] https://wiki.php.net/rfc/engine_warnings
2020-01-07 21:54:42 +01:00
Nikita Popov
9b6c0bdcd6 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove support for preloading on Windows
2020-01-06 22:42:31 +01:00
Nikita Popov
59c3ddab13 Remove support for preloading on Windows
Due to ASLR restrictions, preloading on Windows does not work with
any code that has preloading dependencies on internal classes.
This effectively makes it unusable for any non-trivial codebase.

Instead of pretending like preloading is going to work, only to
make people realize that it really doesn't once they get beyond
a dummy example, we disable support for preloading on Windows
entirely.

Closes GH-4999.
2020-01-06 22:41:55 +01:00
Nikita Popov
8abb2ced39 Fixed bug #79055
Fix file cache serialization of property types. I'm changing the
overall type serialization format to perform additional adjustments
in order to yield a plausible pointer for zend_type, rather than
using an entirely separate serialization format, as was previously
done. That would have been annoying to extend to the case of CE
pointers.
2020-01-02 15:53:15 +01:00