Commit graph

178 commits

Author SHA1 Message Date
Nikita Popov
e2194c18df FETCH_STATIC_PROP_IS may return undef
We don't go out of our way to convert IS_UNDEF to IS_NULL for
this opcode. Reflect this in type info.
2021-07-21 17:19:43 +02:00
Nikita Popov
e3d90fa7de Transfer MAY_BE_INDIRECT for VERIFY_RETURN
If the input is indirect, the output will be indirect too.
2021-07-21 17:19:43 +02:00
Kamil Tekiela
052af90b86 Deprecate autovivification on false
Deprecate automatically converting "false" into an empty array
on write operands. Autovivification continues to be supported
for "null" values, as well as undefined/uninitialized values.

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

Closes GH-7131.

Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 14:49:37 +02:00
Joe Watkins
d0b09a7be4 Add first-class callables
Support acquiring a Closure to a callable using the syntax
func(...), $obj->method(...), etc. This is essentially a
shortcut for Closure::fromCallable().

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

Closes GH-7019.

Co-Authored-By: Nikita Popov <nikita.ppv@gmail.com>
2021-07-14 14:37:25 +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
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov
be369dec70 Deduplicate code for handling zend_type in inference
This should be doing the same for the argument and the property
type case.
2021-06-18 11:37:15 +02:00
Nikita Popov
0d9269de75 Extract helper for fetching class entry in optimizer
This code is repeated a few time. Two occurrences additionally
contained checks for user classes in CG(class_table) with the
same file name, but as far as I know these should always be in
the script class_table, so I'm omitting the check here.
2021-06-18 10:48:48 +02:00
Dmitry Stogov
cc0aac3f73 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed incorrect type inference for "(array)$null".
2021-06-17 13:05:45 +03:00
Dmitry Stogov
c8ff5a1082 Fix assertions 2021-06-11 11:39:39 +03:00
Dmitry Stogov
7368d0c418 Fixed bug #81096: Inconsistent range inferece for variables passed by reference
Detect references before range inference and exclude them from range
inference.
2021-06-10 11:43:15 +03:00
Nikita Popov
cbe485db05 Make PRE_INC/PRE_DEC type inference more accurate
The return value can never be a reference, even if the variable
is a reference.

While here, also exclude the resource and array types which throw
a TypeError since PHP 8.0.
2021-06-09 15:15:23 +02:00
George Peter Banyard
b6958bb847
Implement "Deprecate implicit non-integer-compatible float to int conversions" RFC. (#6661)
RFC: https://wiki.php.net/rfc/implicit-float-int-deprecate

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-05-31 15:48:45 +01: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
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
b82242a88d Remove unnecessary php.h includes from Zend/
The Zend/ directory really shouldn't be including php headers.
These particular includes are plain unnecessary.
2021-04-20 12:21:45 +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
Nikita Popov
6bd46d2f68 Don't use range information from a prototype method
The method may be overridden.
2021-04-12 10:30:04 +02:00
Dmitry Stogov
12ed58eca0 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed type inference for OP_DATA
2021-04-09 14:53:44 +03:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
2f3538c215 Improved type inference for FE_FETCH_R 2021-03-25 16:00:36 +03:00
Nikita Popov
2d0e2733c8 Support prototypes in call graph
Even if we don't know the exact method being called, include it
in the call graph with the is_prototype flag. In particular, we
can still make use of return types from prototype methods, as
PHP 8 makes LSP violations a hard error.

Most other places are adjusted to skip calls with !is_prototype.
Maybe some of them would be fine, but ignoring them is conservative.
2021-03-19 10:49:15 +01:00
Nikita Popov
e67156e967 Add missing rc1/rcn to return type initialization 2021-03-19 10:04:56 +01:00
Nikita Popov
dcac654fd5 Allow inferring narrowed return type
Even if an explicit return type is given, we might still infer
a more narrow one based on return statements. We shouldn't
pessimize this just because a type has been declared.
2021-03-18 17:11:56 +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
Nikita Popov
77ebf81492 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix refcount inference for typed properties
2021-03-16 11:18:12 +01:00
Nikita Popov
27cd7a11cb Add support for string keys in array unpacking
This adds support for:

    $array1 = ['a' => 1, 'b' => 2];
    $array2 = ['b' => 3, 'c' => 4];
    $array = [...$array1, ...$array2];
    // => ['a' => 1, 'b' => 3, 'c' => 4]

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

Closes GH-6584.
2021-02-09 10:04:27 +01:00
Nikita Popov
83be073abe Move optimizer into core
This only moves the files, adjusts the build system, exports APIs
and does minor fixups to make sure the code builds.

This does not yet try to make the optimizer usable independently
of opcache.

Closes GH-6642.
2021-01-28 10:38:25 +01:00
Renamed from ext/opcache/Optimizer/zend_inference.c (Browse further)