Commit Graph

598 Commits

Author SHA1 Message Date
Nikita Popov
184ba0c91c Remove recursive check from instanceof_interface
Parent interfaces are copied into the interface list during
inheritance, so there's no need to perform a recursive check.

Only exception are instanceof checks performed during inheritance
itself. However, we already have unlinked_instanceof for this
purpose, it just needs to be taught to handle this case.

Closes GH-4857.
2019-10-25 10:19:42 +02:00
Nikita Popov
c63a0e005a Optimize instanceof_class/interface
instanceof_class does not need to check for a NULL pointer in the
first iteration -- passing NULL to this function is illegal.

instanceof_interface does not need to use instanceof_class(), it
only has to check whether the CEs match exactly. There is no way
for an interface to appear inside "parent", it will always be in
"interfaces" only.
2019-10-24 17:47:35 +02:00
Nikita Popov
435f269108 Clean up and clarify instanceof_function_ex()
The instanceof_interface_only() function was dead code (always
returned zero).

Clarify that the last parameter indicates whether the passed CE
is interface or class and rewrite the code in terms of assertions.
2019-10-24 17:40:25 +02:00
Nikita Popov
21148679d1 Handle "non well formed" exception during ZPP
Previously if the "non well formed" notice was converted into an
exception we'd still end up executing the function.

Also drop the now unnecessary EG(exception) checks in the engine.

Additionally remote a bogus exception in zend_is_callable: It
should only be writing to error, but not directly throwing.
2019-10-08 17:17:49 +02:00
Nikita Popov
d71f859a56 Merge branch 'PHP-7.3' into PHP-7.4 2019-09-26 13:47:41 +02:00
Nikita Popov
91c4abcfcc Merge branch 'PHP-7.2' into PHP-7.3 2019-09-26 13:47:19 +02:00
Nikita Popov
ab938d7bbc Fix memory leak with ** on array operands 2019-09-26 13:45:45 +02:00
Peter Kokot
638c21765c Remove HAVE_STRCOLL check
The strcoll function is defined in the C89 standard and should be
on today's systems always available via the <string.h> header.

https://port70.net/~nsz/c/c89/c89-draft.html#4.11.4.3

- Remove also SKIPIF strcoll check in test
2019-06-28 00:05:55 +02:00
Nikita Popov
a59e0cfce5 Disable float division by zero sanitizer for div_function
We intentionally divide by zero here and want to get IEEE-754
semantics.
2019-06-20 16:21:47 +02:00
Nikita Popov
ed2a242317 Fix signed shift UB 2019-06-19 15:09:00 +02:00
Nikita Popov
82a34e71c5 Avoid overflow UB in is_numeric_string
We intentionally overflow the signed space here, so make this an
unsigned variable and only cast to signed at the end.
2019-06-19 15:09:00 +02:00
Nikita Popov
8f8fcbbd39 Support full variance if autoloading is used
Keep track of delayed variance obligations and check them after
linking a class is otherwise finished. Obligations may either be
unresolved method compatibility (because the necessecary classes
aren't available yet) or open parent/interface dependencies. The
latter occur because we allow the use of not fully linked classes
as parents/interfaces now.

An important aspect of the implementation is we do not require
classes involved in variance checks to be fully linked in order for
the class to be fully linked. Because the involved types do have to
exist in the class table (as partially linked classes) and we do
check these for correct variance, we have the guarantee that either
those classes will successfully link lateron or generate an error,
but there is no way to actually use them until that point and as
such no possibility of violating the variance contract. This is
important because it ensures that a class declaration always either
errors or will produce an immediately usable class afterwards --
there are no cases where the finalization of the class declaration
has to be delayed until a later time, as earlier variants of this
patch did.

Because variance checks deal with classes in various stages of
linking, we need to use a special instanceof implementation that
supports this, and also introduce finer-grained flags that tell us
which parts have been linked already and which haven't.

Class autoloading for variance checks is delayed into a separate
stage after the class is otherwise linked and before delayed
variance obligations are processed. This separation is needed to
handle cases like A extends B extends C, where B is the autoload
root, but C is required to check variance. This could end up
loading C while the class structure of B is in an inconsistent
state.
2019-06-11 13:09:33 +02:00
Dmitry Stogov
be74ca4976 Support for exceptions thrown during "Array to string conversion" error processing 2019-06-06 14:09:42 +03:00
Dmitry Stogov
457392fa64 Cheaper checks for exceptions thrown from __toString() 2019-06-06 01:47:22 +03:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Nikita Popov
49a3b03e9f Implement basic variance support
This is a minimal variance implementation: It does not support any
cyclic type dependencies. Additionally the preloading requirements
are much more restrictive than necessary. Hopefully we can relax
these in the future.
2019-05-24 09:30:37 +02:00
Dmitry Stogov
9038d5c6ee Make is_identical() functions return zend_bool (instead of int) 2019-04-04 18:18:12 +03:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Nikita Popov
7ec8087f80 Introduce get_properties_for() handler
This handler allows getting the object properties for a particular
purpose, such as array casting, serialization, etc.
2018-10-10 10:39:10 +02:00
Dmitry Stogov
c1706980c0 Remove dead code (only IS_ARRAY may relive zendi_convert_scalar_to_number()), and micro-optimization. 2018-09-27 13:11:48 +03:00
Dmitry Stogov
689c6fb188 Replace ZEND_ACC_ANON_BOUND, ZEND_ACC_UNRESOLVED_PARENT and ZEND_ACC_UNRESOLVED_INTERFACES with single ZEND_ACC_LINKED. 2018-09-18 11:41:40 +03:00
Nikita Popov
dfa166e7ed Remove unused ZEND_FILE_LINE in i_zval_ptr_dtor 2018-09-16 17:16:26 +02:00
Remi Collet
2e4489fdf4 Merge branch 'PHP-7.3'
* PHP-7.3:
  fix double cast to int on 32-bit
2018-08-30 09:05:01 +02:00
Remi Collet
cf6c32545e Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  fix double cast to int on 32-bit
2018-08-30 09:04:43 +02:00
Remi Collet
6e703c957e Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  fix double cast to int on 32-bit
2018-08-30 09:04:13 +02:00
Remi Collet
c1729272b1 fix double cast to int on 32-bit 2018-08-30 09:03:50 +02:00
Dmitry Stogov
d140df58e6 Keep information about unresolved interfaces in zend_class_entry->interface_names.
Move interface implementation code into ZEND_DECLARE_*CLASS opcodes.
Remove ZEND_ADD_INTERFACE and ZEND_VERIFY_ABSTRACT_CLASS opcodes.
2018-08-23 17:16:28 +03:00
Dmitry Stogov
aed3de1bc5 Split add/sub_function(s) into fast and slow parts 2018-07-25 12:48:16 +03:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
ebd1f5af3e API cleanup.
Removed useless filename and lineno arguments, used in DEBUG build.
The patch doesn't break source compatibility of public API (only binary compatibility).
2018-07-23 15:24:07 +03:00
Dmitry Stogov
62b3464871 Removed deprecated condition 2018-07-10 11:04:10 +03:00
Dmitry Stogov
bd8e76761f Use zval_ptr_dtor() instead of zval_dtor() in in-place array/object conversion functions 2018-07-06 12:07:13 +03:00
Dmitry Stogov
ca40664ad6 Conversion related optimizations 2018-07-06 01:26:43 +03:00
Dmitry Stogov
6c0ddcda47 Removed legacy zval_dtor() usage. It doesn't work with zvals with refcount == 0, anyway. 2018-07-05 02:28:00 +03:00
Dmitry Stogov
5898583e94 Fixed some incorrect zval_dtor() usages 2018-07-04 23:48:39 +03:00
Dmitry Stogov
af341213f7 se zval_ptr_dtor_str() instead of zend_string_release_ex(Z_STR(*), 0) 2018-07-04 12:08:07 +03:00
Dmitry Stogov
5f19816f53 concat_function() micro optimization 2018-07-04 12:05:51 +03:00
Dmitry Stogov
ff58d70548 Avoid agressive inlining in rarely used paths 2018-05-30 14:03:48 +03:00
Dmitry Stogov
d90c6f2443 Removed useless zval_ptr_dtor() 2018-05-29 17:58:06 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Dmitry Stogov
9716bd68a3 Avoid double copying 2018-03-06 21:58:40 +03:00
Gabriel Caruso
414aaa207c
Use bool instead of boolean 2018-02-08 10:00:49 +01:00
Dmitry Stogov
19676fdf55 Added zendi_smart_streq() for smart string equality check 2018-01-16 17:24:00 +03:00
Dmitry Stogov
9d7544aa1c Convert "sparse switch" statements into sequences of "if" with the most probable conditions first 2018-01-10 15:12:03 +03:00
Gabriel Caruso
6400264856 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-03 14:38:00 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00