Commit Graph

460 Commits

Author SHA1 Message Date
Bob Weinand
b30448f48f Fix observing inherited internal functions
Fixes GH-9871
2022-11-02 15:33:04 +01:00
Bob Weinand
a01dd9feda Revert "Port all internally used classes to use default_object_handlers"
This reverts commit 94ee4f9834.

The commit was a bit too late to be included in PHP 8.2 RC1. Given it's a massive ABI break, we decide to postpone the change to PHP 8.3.
2022-09-14 11:13:23 +02:00
Bob Weinand
94ee4f9834 Port all internally used classes to use default_object_handlers
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-31 16:45:27 +02:00
Bob Weinand
bf427b732a Add an API to observe functions and classes being linked
To observe when the functions and classes start being officially available to the user

Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
2022-08-23 15:22:22 +02:00
Máté Kocsis
0897266219
Fix GH-9285 Traits cannot be used in readonly classes 2022-08-21 10:33:08 +02:00
sji
3b62d66098
Implement constants in traits (#8888)
RFC: https://wiki.php.net/rfc/constants_in_traits
2022-08-04 20:08:40 +01:00
George Peter Banyard
f905590764
Add support for Disjoint Normal Form (DNF) types (#8725)
RFC: https://wiki.php.net/rfc/dnf_types

This allows to combine union and intersection types together in the following form (A&B)|(X&Y)|T but not of the form (X|A)&(Y|B) or (X|A)&(Y|B)|T.

* Improve union type parsing

Co-authored-by: Sara Golemon <pollita@php.net>
2022-07-08 11:30:23 +01:00
George Peter Banyard
b40ae80804
Convert iterable into an internal alias for Traversable|array (#7309)
This does a compile time transformation of ``iterable`` into ``Traversable|array`` which simplifies some of the LSP variance handling.

The arginfo generation script from stubs is updated to produce a union type when it encounters the type ``iterable``
Extension functions which do not regenerate the arginfo, or write them manually are still supported by mimicking the compile time transformation while registering the function.

Type Reflection is preserved for single ``iterable`` (and ``?iterable``) to produce a ReflectionNamedType with name ``iterable``, however usage of ``iterable`` in union types will be converted to ``array|Traversable``
2022-06-07 13:35:34 +01:00
Máté Kocsis
7850c10389
Add support for readonly classes (#7305)
RFC: https://wiki.php.net/rfc/readonly_classes
2022-05-16 20:40:23 +02:00
Dmitry Stogov
f080a90a88 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix memory leak
2022-05-11 11:47:38 +03:00
Dmitry Stogov
b1b79c74fb Fix memory leak
This fixes oss-fuzz #47088
2022-05-11 11:43:01 +03:00
Jakub Zelenka
436cffc971
Merge branch 'PHP-8.1' 2022-04-22 23:08:23 +01:00
Arnaud Le Blanc
f20e11cbe1 Clear recorded errors before executing shutdown functions
Recorded errors may be attached to the wrong cached script when a fatal error
occurs during recording. This happens because the fatal error will cause a
bailout, which may prevent the recorded errors from being freed. If an other
script is compiled after bailout, or if a class is linked after bailout, the
recorded errors will be attached to it.

This change fixes this by freeing recorded errors before executing shutdown
functions.

Fixes GH-8063
2022-04-22 18:14:08 +02:00
Ilija Tovilo
733023b2e3
Improve error message class type
Refer to interfaces/enums instead of classes in more places.

Closes GH-7792
Closes GH-8187
2022-03-20 20:54:36 +01:00
Christoph M. Becker
dd6b1b7ef7
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7757: Multi-inherited final constant causes fatal error
2021-12-12 22:23:07 +01:00
Christoph M. Becker
206c521a1f
Fix GH-7757: Multi-inherited final constant causes fatal error
"Diamond" inheritance of final constants is supposed to be supported.

Closes GH-7767.
2021-12-12 22:22:51 +01:00
Nikita Popov
902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00
Dmitry Stogov
d56ec0a624 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81607 (CE_CACHE allocation with concurrent access)
2021-11-17 18:25:00 +03:00
Dmitry Stogov
76548e5093 Fixed bug #81607 (CE_CACHE allocation with concurrent access) 2021-11-17 18:23:36 +03:00
Nikita Popov
76df12cff0 Merge branch 'PHP-8.1'
* PHP-8.1:
  Combine variance obligation processing and error reporting
2021-11-08 10:42:41 +01:00
Nikita Popov
b969ce3b98 Combine variance obligation processing and error reporting
I don't believe there's a reason anymore to first resolve all
delayed variance obligations, and then report errors if any are
left.  We can report errors directly when resolving obligations.
2021-11-08 10:42:03 +01:00
Nikita Popov
53332b7f66 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #78647
2021-11-08 10:00:07 +01:00
Nikita Popov
a38f4f9881 Fix bug #78647
We can't take ownership of the delayed autoload table here. It is
important that pending classes get loaded before resolving variance
of any nested classed, as they might actually be lower in the
hierarchy.
2021-11-08 09:59:33 +01:00
Nikita Popov
ee2cec186c Merge branch 'PHP-8.1'
* PHP-8.1:
  Partially address bug #78647
2021-11-05 17:07:14 +01:00
Nikita Popov
a2fe8d48b1 Partially address bug #78647
Produce a sensible error message for the case where inheritance
should fail. There is still a remaining issue that we sometimes
fail inheritance while we should not.
2021-11-05 17:05:55 +01:00
Nikita Popov
2d38f701e0 Merge branch 'PHP-8.1'
* PHP-8.1:
  Don't implement Stringable on traits
2021-11-05 09:48:33 +01:00
Nikita Popov
4bdb271894 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Don't implement Stringable on traits
2021-11-05 09:48:28 +01:00
Nikita Popov
d478ae73b1 Don't implement Stringable on traits
Traits do not support interfaces, so we should not implement
Stringable on them.

Also check the __toString() return type in the same way other
magic methods do, otherwise we would now miss the check in the
trait case.
2021-11-05 09:42:58 +01:00
Nikita Popov
52ccb4d16b Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix typo

[ci skip]
2021-11-04 15:06:21 +01:00
Nikita Popov
94cacba1ee Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix typo

[ci skip]
2021-11-04 15:05:58 +01:00
Nikita Popov
462271c7e0 Fix typo
[ci skip]
2021-11-04 15:05:43 +01:00
Nikita Popov
9793b694e7 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fixed bug #81582
2021-11-04 11:58:59 +01:00
Nikita Popov
1d6f4db2ba Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed bug #81582
2021-11-04 11:58:43 +01:00
Nikita Popov
d3932682e7 Fixed bug #81582
If __toString() comes from a trait, implement Stringable during
inheritance.
2021-11-04 11:58:33 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Dmitry Stogov
ddaf64b56c Avoid non-immutable map_ptr indirection 2021-10-14 12:16:18 +03:00
Nikita Popov
c19977d054 Fix delayed early binding with optimization
It's possible for delayed early binding opcodes to get optimized
away if they are "unreachable". However, we still need to attempt
early binding for them. (In some cases we also corrupt the early
binding list outright during optimization, which is how I got here.)

Fix this by storing information about delayed early binding
independently of DECLARE_CLASS_DELAYED opcodes, so early binding is
performed even after the opcode has been dropped.
2021-09-29 18:00:20 +02:00
Nikita Popov
c8fa477064 Convert exception during delayed autoload to fatal error
Same as with other exceptions during inheritance, convert those
thrown during delayed class loading into fatal errors. We can't
properly deal with such exceptions, as inheritance cannot be
gracefully aborted at this point.

Fixes oss-fuzz #39405.
2021-09-29 10:03:23 +02:00
Nikita Popov
3991483727 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Bail on exception during delayed autoload
2021-09-23 12:46:56 +02:00
Nikita Popov
be8217368b Bail on exception during delayed autoload
We shouldn't try to load further classes if one autoload throws.

This fixes oss-fuzz #38881, though I believe there are still two
deeper issues here: 1) Why do we allow autoloading with an active
exception? 2) Exception save & restore should probably also save
and restore the exception opline.
2021-09-23 12:46:39 +02:00
Nikita Popov
3eeeeeb104 Fully qualify ReturnTypeWillChange in deprecation message
When adding the #[ReturnTypeWillChange] attribute in namespaced
code, you also need to use ReturnTypeWillChange, otherwise it
will be silently ignored and may result in confusion. Change the
deprecation message to suggest #[\ReturnTypeWillChange], which
will always work.

Closes GH-7454.
2021-09-03 13:57:23 +02:00
Nikita Popov
4bb66ddc76 Set EG(active)=0 during preloading shutdown
Just like during normal shutdown, we should set EG(active)=0
during the partial preloading shutdown, to make sure that no
user code can run.

We need to slightly tweak inheritance class loading to still
pick the right code path.
2021-08-16 15:53:12 +02:00
Nikita Popov
1c6df2dffd Fixed bug #81192
Normally the filename is the current filename, but when traits
are involved, it might be a different one.
2021-08-12 14:35:13 +02:00
Nikita Popov
315f40942b
Always use CE_CACHE, remove TYPE_HAS_CE (#7336)
Currently, CE_CACHE on strings is only used with opcache interned strings. This
patch extends usage to non-opcache interned strings as well. This means that
most type strings can now make use of CE_CACHE even if opcache is not loaded,
which allows us to remove TYPE_HAS_CE kind, and fix some discrepancies
depending on whether a type stores a resolved or non-resolved name.

There are two cases where CE_CACHE will not be used:

 * When opcache is not used and a permanent interned string (that is not an
   internal class name) is used as a type name during the request. In this case
   we can't allocate a map_ptr index for the permanent string, as it would be
   not be in the permanent map_ptr index space.
 * When opcache is used but the script is not cached (e.g. eval'd code or
   opcache full). If opcache is used, we can't allocate additional map_ptr
   indexes at runtime, because they may conflict with indexes allocated by
   opcache.

In these two cases we would end up not using CE caching for property types
(argument/return types still have the separate cache slot).
2021-08-11 10:28:52 +02:00
Nikita Popov
6e91a820d8 Fix mutable data initialization during lazy class loading 2021-08-02 11:06:27 +02:00
Nikita Popov
d836046ab8 Perform preloading attempt on copied class
It is very hard to determine in advance whether class linking will
fail due to missing dependencies in variance checks (#7314 attempts
this). This patch takes an alternative approach where we try to
perform inheritance on a copy of the class (zend_lazy_class_load)
and then restore the original class if inheritance fails. The fatal
error in that case is recorded and thrown as a warning later.

Closes GH-7319.
2021-07-30 15:09:49 +02:00
Nikita Popov
b5746a4c7f Drop HAS_UNLINKED_USES flag
Instead always use the unlinked_uses table, which is already used
if opcache is used. Not much point in having a different mechanism
for the non-opcache case.
2021-07-29 16:10:50 +02:00
Nikita Popov
e011952576
Preload unlinked classes, remove preload autoload (#7311)
Currently, classes that can't be linked get moved back into the original script
and are not preloaded. As such classes may be referenced from functions that
did get preloaded, there is a preload autoload mechanism to load them at
runtime.

Since PHP 8.1, we can safely preload unlinked classes, which will then go
through usual lazy loading. This means that we no longer need the preload
autoload mechanism. However, we need to be careful not to modify any hash
table buckets in-place, and should create new buckets for lazy loaded classes.
2021-07-28 14:27:58 +02:00
Nikita Popov
f78216f62e Extract early binding registration code
This is the same for the cached and uncached cases and will make
GH-7311 a bit simpler.
2021-07-28 11:19:39 +02:00
Nikita Popov
56ef117419 Remove special ctor handling in abstract class verification
This seems to be some kind of leftover from PHP 4 ctor support.
2021-07-27 10:16:47 +02:00
Máté Kocsis
663536d7d9
Improve class inheritance error messages (#7307) 2021-07-27 09:42:37 +02:00
Nikita Popov
3eb97a4566 Always use separate static_members_table
When running without opcache, static_members_table is shared with
default_static_members_table. This is visible in reflection output,
because ReflectionProperty::getDefaultValue() will return the
current value, rather than the default value.

Address this by never sharing the table, which matches the behavior
we already see under opcache.

Fixes bug #80821.

Closes GH-7299.
2021-07-23 09:29:32 +02:00
Levi Morrison
ae8647d9d3
Remove leading underscore for _zend_hash_find_known_hash (#7260)
Convert zend_hash_find_ex(..., 1) to zend_hash_find_known_hash(...)
Convert zend_hash_find_ex(..., 0) to zend_hash_find(...)

Also add serializable changes to UPGRADING.INTERNALS summary
2021-07-20 17:07:17 -06:00
Nikita Popov
6780aaa532 Implement readonly properties
Add support for readonly properties, for which only a single
initializing assignment from the declaring scope is allowed.

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

Closes GH-7089.
2021-07-20 12:05:46 +02:00
Nikita Popov
814a932734 Add ZEND_ACC_NOT_SERIALIZABLE flag
This prevents serialization and unserialization of a class and its
children in a way that does not depend on the zend_class_serialize_deny
and zend_class_unserialize_deny handlers that will be going away
in PHP 9 together with the Serializable interface.

In stubs, `@not-serializable` can be used to set this flag.

This patch only uses the new flag for a handful of Zend classes,
converting the remainder is left for later.

Closes GH-7249.
Fixes bug #81111.
2021-07-19 15:59:11 +02:00
Nikita Popov
a837d35366 Don't track internal class dependencies
Subtyping relationships established on internal classes are always
going to hold (if we ignore Windows), so there is no need to
explicitly track them.

This fixes an assertion failure in GH-7251.
2021-07-19 10:55:22 +02:00
Nikita Popov
1bc5bd7fe2 Handle both WARNING and UNRESOLVED during early binding
We would previously early exit on the WARNING, and miss the
later UNRESOLVED.
2021-07-15 15:27:15 +02:00
Máté Kocsis
a5360e80c2
Add support for final class constants
RFC: https://wiki.php.net/rfc/final_class_const

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-06 21:42:38 +02:00
George Peter Banyard
069a9fa5e4
Pure Intersection types (#6799)
Implement pure intersection types RFC

RFC: https://wiki.php.net/rfc/pure-intersection-types

Co-authored-by: Nikita Popov <nikic@php.net>
Co-authored-by: Ilija Tovilo <ilutov@php.net>
2021-07-05 14:11:03 +02:00
Nikita Popov
ac99d5b502 Simplify registration of unresolved classes
If we have an UNRESOLVED result, simply register all classes that
occur in either of the types. I believe that's equivalent to what
we're currently doing in a more complicated way.
2021-07-01 10:21:46 +02:00
Nikita Popov
f256c3f617 Move INHERITANCE_WARNING handling one layer up
There is only a single place where we need to convert ERROR into
WARNING, don't thread it through more places than necessary.
2021-06-30 15:45:42 +02:00
Máté Kocsis
773e9ba5d6
Mention ReturnTypeWillChange attribute in the error message (#7183) 2021-06-28 14:56:21 +02:00
Patrick Allaert
ceb6fa6dc0 Convert some recently introduced zend_bool to bool
As well as `scripts/dev/check_parameters.php` utility.

Cfr. 3e01f5afb1
2021-06-18 15:21:39 +01:00
Nikita Popov
100a1e8e21 Convert exception during inheritance to fatal error
Now that inheritance can throw deprecations again, these may be
converted to exception by a custom error handler. In this case
we need to convert the exception to a fatal error, as inheritance
cannot safely throw in the general case.
2021-05-28 10:19:23 +02:00
Nikita Popov
f0858d891f Record warnings during early binding
These should also get replayed when the class is loaded from
opcache.
2021-05-17 10:18:26 +02:00
Nikita Popov
3b7edb6587 Don't directly throw warning during method compatibility check
Only return the INHERITANCE_WARNING status.
2021-05-17 10:16:47 +02:00
Máté Kocsis
532c60cb92
Add support for tentative return types of internal methods
RFC: https://wiki.php.net/rfc/internal_method_return_types

Closses GH-6971
2021-05-14 15:55:25 +02:00
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
Máté Kocsis
fcd18757b2
Add reproducer for possible issue with object return type inheritance (#6961)
Fix early inheritance

Co-authored-by: Joe Watkins <krakjoe@php.net>
2021-05-10 12:52:59 +02:00
Nikita Popov
f71bfe4544 Merge branch 'PHP-8.0'
* PHP-8.0:
  Don't autoload classes during covariant type check against mixed
2021-05-10 09:46:49 +02:00
Nikita Popov
7fbfcfa851 Don't autoload classes during covariant type check against mixed
mixed should be behaving the same way as no type here, and not
require X to be autoloaded. Everything apart from "void" is trivially
covariant to "mixed".
2021-05-10 09:45:48 +02:00
Nikita Popov
79071d5e3e
Don't duplicate internal prop info (#6929)
Userland property infos are no longer duplicated since PHP 7.4, when we
stopped setting SHADOW flags on inherited private properties. Stop duplicating
internal property infos as well.

This requires switching class destruction to work in reverse order, as child
classes may be reusing structures from parent classes, and as such should be
destroyed first.
2021-04-29 20:31:24 +02:00
Nikita Popov
dd86987b2c
Replay warnings during inheritance (#6928)
Since 3e6b447979 it is again possible to have
warnings (deprecations) during inheritance, and more such functionality is
likely in the future. This is a problem, because such warnings will only be
shown on the first request if the opcache inheritance cache is used. This
currently causes test failures in --repeat builds.

Fix this by uplifting the error recording functionality from opcache to Zend,
and then using it to persist a warning trace in the inheritance cache, which
can then be used to replay the warnings on subsequent executions.
2021-04-29 16:37:53 +02:00
Nikita Popov
9a1da9f61f Don't use separate static variables in inherited methods
RFC: https://wiki.php.net/rfc/static_variable_inheritance

Closes GH-6719.
2021-04-28 17:08:50 +02:00
Nikita Popov
fd1d5ec2b4 Add ZEND_CLASS_CONST_FLAGS() macro
And drop Z_ACCESS_FLAGS(). We no longer store *only* access flags
in these.
2021-04-28 14:51:54 +02:00
Matt Brown
6cd0b48cac Implement never return type
The never type can be used to indicate that a function never
returns, for example because it always unwinds.

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

Closes GH-6761.
2021-04-19 11:27:29 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Dmitry Stogov
4dcde9cf18 Don't evalutae ZEND_AST_CLASS_CONST to ZEND_AST_CONSTANT ar
compile-time. Keep at to run-time and use Fast Class Cache during
run-time evaluation.
2021-04-09 17:48:28 +03:00
Dmitry Stogov
d8e4fbae62 Fast Class Cache
This is generalization of idea, that was previously usesd for caching
resolution of class_entries in zend_type. Now very similar mechanizm is
used for general zend_string into zend_class_entry resolution.

Interned zend_string with IS_STR_CLASS_NAME_MAP_PTR GC_FLAG uses its
refcount to adress corresponding zend_class_entry cache slot.
The refcount keeps an offset to this slot from CG(map_ptr_base).
Flag may be checked by ZSTR_HAS_CE_CACHE(str), cache slot may be read by
ZSTR_GET_CE_CACHE(str) and set by ZSTR_SET_CE_CACHE(str, ce).
2021-04-08 23:37:40 +03:00
Nikita Popov
fba8b955e9 Fix incorrect prop_name release
After 2c4346f9de the property
name should no longer be released.

This should fix the preloading failure under asan.
2021-03-30 12:53:09 +02:00
Nikita Popov
2c4346f9de Remove unnecessary property unmangling in trait binding
The unmangled name is already available as the hashtable key,
use it directly.
2021-03-26 12:14:32 +01:00
Nikita Popov
5fd2a5b13b Fix handling of unknown class in trait precedence list
Fixes oss-fuzz #31983.
2021-03-19 16:04:47 +01:00
Ilija Tovilo
269c8dac1d
Implement enums
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6489.
2021-03-17 19:08:03 +01:00
Dmitry Stogov
fe3dbe5294 Fixed compilation warning 2021-03-12 21:50:26 +03:00
Dmitry Stogov
65859fe17e Inheritance cache optimization 2021-03-11 13:42:35 +03:00
Nikita Popov
5d160e309e Fix static variable behavior with inheritance
When a method is inherited, the static variables will now always
use the initial values, rather than the values at the time of
inheritance. As such, behavior no longer depends on whether
inheritance happens before or after a method has been called.

This is implemented by always keeping static_variables as the
original values, and static_variables_ptr as the modified copy.

Closes GH-6705.
2021-02-18 11:18:19 +01:00
Dmitry Stogov
e1fda1025c Link unbound simple classes (without parent/intefaces/traits) in first place. 2021-02-10 23:57:50 +03:00
Dmitry Stogov
ef51648185 Use zend_type.ce_cache__ptr for caching class resulution during argument/result type checks 2021-02-10 18:00:00 +03:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Dmitry Stogov
b3bbb8fe3b Mark classes cached by opcache by ZEND_ACC_CACHED flag and prevent useless copying and desrpoying of immutable data. 2021-01-19 11:55:09 +03:00
Dmitry Stogov
c195fcd678 Avoid modification of trait info 2021-01-19 11:54:01 +03:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
dd335359e9 Fix infinite recursion in unlinked_instanceof
I suspect this is only a partial fix for the issue, it's probably
possible to recurse through a more complex pathway as well.

Fixes oss-fuzz #28961.
2021-01-05 13:03:41 +01:00
Nikita Popov
912cb8b8b5 Fixed bug #80391
Iterable was not considered a subtype of array|object, and thus
also not a subtype of mixed.
2020-11-24 10:09:28 +01:00
Nikita Popov
670fe594b9 Fix static variable in methods inheritance during preloading
This is now "bug compatible" with the normal behavior, and more
imporantly, does not crash :)
2020-11-04 15:42:52 +01:00
Nikita Popov
9fd8e00f1a Fix use of type copy ctor when importing trait properties
We shouldn't call the copy constructor inside the original type,
duh.
2020-11-03 15:29:18 +01:00
Nikita Popov
7e55317558 Allow unlinked classes when performing in_compilation variance check
As preloading runs in in_compilation mode, we also need to allow
use of unlinked classes in lookup_class().
2020-11-03 14:49:10 +01:00
Nikita Popov
ee934f8245 Fix variance checks on resolved union types
This is a bit annoying: When preloading is used, types might be
resolved during inheritance checks, so we need to deal with CE
types rather than just NAME types everywhere.
2020-11-03 14:19:15 +01:00
Nikita Popov
4ece62fba9 Fix bug #80055
We need to perform trait scope fixup for both methods involved
in the inheritance check. For that purpose we already need to
thread through a separate fn scope through the entire inheritance
checking machinery.
2020-10-15 14:24:25 +02:00
Nikita Popov
ec484a0788 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #80126
2020-10-06 16:34:02 +02:00