Commit graph

500 commits

Author SHA1 Message Date
Dmitry Stogov
e7446c1b2d Separate common code abd eliminate useless checks 2019-06-27 13:11:08 +03:00
Dmitry Stogov
31670211e2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Inline hot path
2019-06-27 11:28:14 +03:00
Dmitry Stogov
a58964be82 Inline hot path 2019-06-27 11:27:53 +03:00
Dmitry Stogov
e2effc96b4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Avoid double checks on early binding
2019-06-27 02:25:57 +03:00
Dmitry Stogov
83b99527df Avoid double checks on early binding 2019-06-27 02:13:06 +03:00
Dmitry Stogov
8dac19278e Merge branch 'PHP-7.4'
* PHP-7.4:
  Private methods don't have to be duplicated
2019-06-26 13:27:41 +03:00
Dmitry Stogov
36b7021e2c Private methods don't have to be duplicated 2019-06-26 13:27:13 +03:00
Dmitry Stogov
db97bbc0c5 Merge branch 'PHP-7.4'
* PHP-7.4:
  Reorder conditions to minimize number of checks on fast path
2019-06-26 01:08:43 +03:00
Dmitry Stogov
f7faa62c43 Reorder conditions to minimize number of checks on fast path 2019-06-26 01:00:31 +03:00
Dmitry Stogov
0c932e0aff Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove always true/false conditions, remove dead conde and simplify code.
2019-06-26 00:44:10 +03:00
Dmitry Stogov
6288fc19dd Remove always true/false conditions, remove dead conde and simplify code. 2019-06-26 00:32:22 +03:00
Dmitry Stogov
5ce26b4895 Merge branch 'PHP-7.4'
* PHP-7.4:
  Replace previosly checked conditions by ZEND_ASSERT()
2019-06-25 18:27:30 +03:00
Dmitry Stogov
215b5a7db8 Replace previosly checked conditions by ZEND_ASSERT() 2019-06-25 18:26:56 +03:00
Dmitry Stogov
7dc4dd4d7c Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed variance check for abstract constructor during erlay binding
2019-06-25 17:44:49 +03:00
Dmitry Stogov
f09d41ffc0 Fixed variance check for abstract constructor during erlay binding 2019-06-25 17:43:46 +03:00
Dmitry Stogov
c6ce159384 Merge branch 'PHP-7.4'
* PHP-7.4:
  Cleanup
2019-06-25 16:53:46 +03:00
Dmitry Stogov
ccbc121cb1 Cleanup 2019-06-25 16:37:42 +03:00
Dmitry Stogov
83c2e6787d Merge branch 'PHP-7.4'
* PHP-7.4:
  Prevent useless hash lookups
  Update NEWS for 7.4.0alpha3
  Update NEWS for PHP 7.4.0alpha2
2019-06-25 12:42:36 +03:00
Dmitry Stogov
bd0cb99d8c Prevent useless hash lookups 2019-06-25 12:41:06 +03:00
Dmitry Stogov
ca22c456ca Merge branch 'PHP-7.4'
* PHP-7.4:
  Keep lowercased parent class name as second argument of DECLARE_CLASS to avoid extra work at run-time
2019-06-25 11:32:03 +03:00
Dmitry Stogov
759f4ecd8b Keep lowercased parent class name as second argument of DECLARE_CLASS to avoid extra work at run-time 2019-06-25 11:30:58 +03:00
Dmitry Stogov
e18c60cd8d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug 78175 (Preloading must store default values of static variables and properties)
2019-06-24 20:34:05 +03:00
Dmitry Stogov
0f29fb5cd8 Fixed bug 78175 (Preloading must store default values of static variables and properties) 2019-06-24 20:32:27 +03:00
Nikita Popov
e4fae9c061 Merge branch 'PHP-7.4' 2019-06-11 13:16:38 +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
Nikita Popov
89b2d88659 Register class before fetching parent
We want the class declaration to be available while compiling the
parent class.
2019-06-11 13:09:33 +02:00
Nikita Popov
13f675b858 Merge branch 'PHP-7.4' 2019-05-27 09:38:33 +02:00
Nikita Popov
e6fac86dc3 Accept flags argument in zend_lookup_class_ex()
Instead of a single boolean, so we have space for extension here.
2019-05-27 09:36:25 +02:00
Nikita Popov
e06ec226bc Merge branch 'PHP-7.4' 2019-05-24 09:33:58 +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
Nikita Popov
afec3a9208 Avoid early-binding on unresolved types
Fixes bug #76451, and more importantly lays necessary groundwork for
covariant/contravariant types. Bug #76451 is just an edge case, but
once covariance is introduced this will become a common problem instead.
2019-05-24 09:30:13 +02:00
Nikita Popov
c3ee12e786 Merge branch 'PHP-7.4' 2019-05-23 10:41:27 +02:00
Nikita Popov
64918c7702 Forbid use of not fully linked classes 2019-05-23 10:41:10 +02:00
Nikita Popov
6ada4db002 Merge branch 'PHP-7.4' 2019-05-08 12:13:11 +02:00
Nikita Popov
f778e1a0b2 Refactor inheritance type check implementation
Extract the self/parent name resolution code and drop unnecessary
string copies/releases. Store the fe/proto types in local variables.
2019-05-08 12:13:06 +02:00
Nikita Popov
11655d0974 Merge branch 'PHP-7.4' 2019-05-08 11:51:50 +02:00
Nikita Popov
5c474010fb Deduplicate inheritance type check implementation
Make the check covariant (insofar as it is allowed now, i.e.
nullability and iterable) and call it with appropriate argument
order for both parameter and return types.

This makes it simpler to extend to full variance support.
2019-05-08 11:51:23 +02:00
Nikita Popov
97cce70e55 Merge branch 'PHP-7.4' 2019-05-08 11:38:10 +02:00
Nikita Popov
d5ef9c5b28 Merge branch 'PHP-7.3' into PHP-7.4 2019-05-08 11:38:03 +02:00
Nikita Popov
e2ef4e9e2f Merge branch 'PHP-7.2' into PHP-7.3 2019-05-08 11:37:49 +02:00
Nikita Popov
d19b6aa5ba Fix resolution of "parent" during inheritance check
We can't assume that the method we're checking against is part of
the parent class...
2019-05-08 11:35:26 +02:00
Nikita Popov
fd2db11929 Always generate fatal error for LSP failures
RFC: https://wiki.php.net/rfc/lsp_errors
2019-05-07 13:45:28 +02:00
Nikita Popov
73a59eff52 Merge branch 'PHP-7.4' 2019-03-27 18:11:00 +01:00
Nikita Popov
0585548106 Treat abstract ctors the same, regardless of origin
Abstract ctor signatures should always be respected by all children,
independently of whether it comes from an interface or an abstract
class. Previously abstract ctor signatures (if they didn't come from
an interface) were only checked to one level of inheritance.
2019-03-27 18:09:09 +01:00
Nikita Popov
6d71d983da Merge branch 'PHP-7.4' 2019-03-27 13:05:04 +01:00
Nikita Popov
d1e5006c14 Fix lineno for more inheritance errors
And also include explicit linenos in tests.
2019-03-27 13:02:28 +01:00
Nikita Popov
9b7a78b1c2 Merge branch 'PHP-7.4' 2019-03-27 12:43:23 +01:00
Nikita Popov
251f293cb7 Make line numbers for inheritance errors more precise
Use the line of the conflicting child method, rather than either the
first or last line of the class.
2019-03-27 12:42:35 +01:00
Peter Kokot
18295b396f Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix typos in code comments in Zend/ [skip ci]
2019-02-18 17:56:38 +01:00
Tyson Andre
da3316ff0f Fix typos in code comments in Zend/ [skip ci] 2019-02-18 17:56:28 +01:00