Commit graph

53 commits

Author SHA1 Message Date
Máté Kocsis
194f1f095f
Revert unintended tentative return type change
I accidentally made the return type of all Reflection*::getAttributes() methods tentative, even though they have already been declared natively.
2021-09-02 17:06:19 +02:00
Máté Kocsis
2378f35787
Use single line phpdoc in stubs where possible 2021-07-20 13:16:56 +02:00
Joe Watkins
27bb57356c
Merge branch 'master' of github.com:php/php-src
* 'master' of github.com:php/php-src:
  Implement readonly properties
2021-07-20 12:32:51 +02:00
Joe Watkins
570d9b63e9
Not serializable flag permeation 2021-07-20 12:28:35 +02: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
Máté Kocsis
fc0d8983d3
Fix some smaller formatting inconsistencies in stubs 2021-07-20 00:52:26 +02:00
Benjamin Eberlei
bc39abe8c3 Fix #80097: Have ReflectionAttribute implement Reflector and __toString
Implement printing for ReflectionAttribute. Attributes aren't
printed as part of reflection output for other structures (classes
etc) yet.

Closes GH-6117.
2021-07-07 12:42:04 +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
Joe Watkins
aad0d26816
Fix bug #81200 ReflectionMethod::isStatic belongs on ReflectionFunctionAbstract 2021-06-28 09:49:30 +02:00
Máté Kocsis
fccb7274e8
Do not verify the signature of ReflectionEnumUnitCase::getValue()
This method legally have a different return type (UnitEnum) from its parent's return type (mixed).
2021-05-26 12:38:04 +02:00
Máté Kocsis
78ecd4a5f0
Declare tentative return types for ext/reflection
Closes GH-7011
2021-05-23 15:59:57 +02:00
Joe Watkins
b227a72285
ReflectionFunctionAbstract::getClosureUsedVariables
Make a distinction at compile time between bind types for static
  variables

  getStaticVariables remains unchanged

  Fixes #80071
2021-05-21 15:25:35 +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
Nikita Popov
50b4a7adf9 Property handle unset name on ReflectionClassConstant
While the typed property ensures that the value is a string,
we should make sure that we handle an unset property gracefully.

Do this by throwing the same error we would normally throw if
you access an uninitializde typed property.
2021-05-07 12:39:17 +02:00
Aaron Piotrowski
c276c16b66
Implement Fibers
RFC: https://wiki.php.net/rfc/fibers

Closes GH-6875.
2021-04-26 11:07:06 -05:00
Máté Kocsis
533a6bcb29
Get rid of private final methods (#6892) 2021-04-21 10:08:25 +02: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
Máté Kocsis
bf0f6aaf18
Improve class entry generation
Related to GH-6701
2021-02-16 13:09:56 +01:00
Nikita Popov
2ccf630917 Used typed properties for reflection $name and $class
These are read-only properties, and Reflection makes sure to assign
only strings.
2021-02-15 12:09:18 +01:00
Máté Kocsis
5b5bfd6be4
Generate class entries from stubs for phar, posix, pspell, readline, reflection, session, shmop
Closes GH-6692
2021-02-15 00:11:22 +01:00
Christoph M. Becker
82f9e004da Fix ReflectionClass::getConstants() stub
If `zval_update_constant_ex()` fails, an exception has already been
thrown, so we clarify that in the implementation as well.

Closes GH-6557.
2021-01-01 14:46:28 +01:00
Nikita Popov
7f462c97f9 Revert "Make ReflectionUnionType final"
This reverts commit ef6adb4e27.

Per Ondrej's comment, this is already being used by BetterReflection
adaptors, ugh.
2020-10-26 08:51:06 +01:00
Máté Kocsis
ef6adb4e27
Make ReflectionUnionType final
Closes GH-6384
2020-10-25 20:14:07 +01:00
Máté Kocsis
47bbfe1fc0
Require stubs to declare return types for magic methods when possible
Closes GH-6376
2020-10-23 16:33:16 +02:00
Máté Kocsis
351776eae5
Make the $filter parameter of ReflectionClass::get*Constants() nullable 2020-09-29 11:04:10 +02:00
Máté Kocsis
e19599287e
Reflection param renames amendment
Closes GH-6230
2020-09-29 11:04:10 +02:00
Máté Kocsis
64af12d13b
Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Gabriel Caruso
1a8936cde3
Check ReflectionReference::fromArrayElement with union types
ReflectionReference::fromArrayElement(array $array, int|string $key): ?ReflectionReference
is going to be its official signature for PHP 8.0.

Closes GH-5651
2020-09-15 12:56:10 +02:00
Máté Kocsis
a59923befd
Refactor ReflectionMethod::__construct()
Closes GH-6098
2020-09-11 10:59:13 +02:00
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
Máté Kocsis
0d330e1a02
Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Máté Kocsis
8664ff7ae1
Cleanup argument handling in ext/reflection
Closes GH-5850
2020-07-24 17:47:42 +02:00
Nikita Popov
b3ea6ce720 Make ReflectionGenerator final
This class is not safe against malicious extension / instantiation.
2020-07-21 11:53:00 +02:00
Nikita Popov
a4b253c40b ReflectionMethod::invoke() object is not optional 2020-07-06 11:53:57 +02:00
Martin Schröder
053ef28b8d Implement Attribute Amendments.
RFC: https://wiki.php.net/rfc/attribute_amendments

Support for attribute grouping is left out, because the short
attribute syntax RFC will likely make it obsolete.

Closes GH-5751.
2020-06-29 10:45:51 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
Gabriel Caruso
7439941d55
Add $filter parameter for ReflectionClass::(getConstants|getReflectionConstants)
This solves [#79628](https://bugs.php.net/79628).

Similar to `ReflectionClass::getMethods()` and `ReflectionClass::getProperties()`,
this new `$filter` argument allows the filtering of constants defined in a class by
their visibility.

For that, we create three new constants for `ReflectionClassConstant`:

  * `IS_PUBLIC`
  * `IS_PROTECTED`
  * `IS_PRIVATE`

Closes GH-5649.
2020-06-07 15:57:48 +02:00
Nikita Popov
064b464448 Implement "Constructor Promotion" RFC
RFC: https://wiki.php.net/rfc/constructor_promotion

Closes GH-5291.
2020-06-05 15:15:51 +02:00
Benjamin Eberlei
a7908c2d11 Add Attributes
Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
2020-06-04 18:19:49 +02:00
Máté Kocsis
b3718430de
Annotate internal functions with the mixed type
Closes GH-5618
2020-05-25 17:30:57 +02:00
Nikita Popov
28af364d2a Deprecate old ReflectionParameter type declaration APIs
This deprecates:

    ReflectionParameter::isArray()
    ReflectionParameter::isCallable()
    ReflectionParameter::getClass()

These APIs have been superseded by ReflectionParameter::getType()
since PHP 7.0. Types introduced since that time are not available
through the old APIs, and their behavior is getting increasingly
confusing. This is how they interact with PHP 8 union types:

 * isArray() will return true if the type is array or ?array,
   but not any other union type
 * Same for isCallable().
 * getClass() will return a class for T|int etc, as long as the
   union only contains a single type. T1|T2 will return null.

This behavior is not particularly reasonable or useful, and will
get more confusing as new type system extensions are added.

Closes GH-5209.
2020-05-11 17:01:40 +02:00
George Peter Banyard
038502b92a Use int|string Fast ZPP macro in Reflection
Moreover, throw a more appropriate ValueError in case the integer
position provided is less than 0.

Closes GH-5513
2020-05-06 21:51:59 +02:00
Nikita Popov
53eee290b6 Completely remove disabled functions from function table
Currently, disabling a function only replaces the internal
function handler with one that throws a warning, and a few
places in the engine special-case such functions, such as
function_exists. This leaves us with a Schrödinger's function,
which both does not exist (function_exists returns false) and
does exist (you cannot define a function with the same name).
In particular, this prevents the implementation of robust
polyfills, as reported in https://bugs.php.net/bug.php?id=79382:

    if (!function_exists('getallheaders')) {
        function getallheaders(...) { ... }
    }

If getallheaders() is a disabled function, this code will break.

This patch changes disable_functions to remove the functions from
the function table completely. For all intents and purposes, it
will look like the function does not exist.

This also renders two bits of PHP functionality obsolete and thus
deprecated:

 * ReflectionFunction::isDisabled(), as it will no longer be
   possible to construct the ReflectionFunction of a disabled
   function in the first place.
 * get_defined_functions() with $exclude_disabled=false, as
   get_defined_functions() now never returns disabled functions.

Fixed bug #79382.

Closes GH-5473.
2020-04-30 09:53:57 +02:00
Máté Kocsis
1bba691ecc
Generate method entries for ext/session and ext/reflection
Closes GH-5376
2020-04-13 13:04:06 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Máté Kocsis
373a6d8274
Regenerate reflection stubs 2020-03-07 20:26:06 +01:00
Nicolas Grekas
9e775db025 Define Stringable with __toString():string method 2020-03-02 15:25:32 +01:00
Máté Kocsis
4f89211810
Remove the deprecated reflection export methods
Closes GH-5188
2020-02-19 13:19:37 +01:00
Christoph M. Becker
7d0102dfa7 Revert "Replace @param annotations with type declarations"
This reverts commit c31029f335.
2020-02-17 08:55:18 +01:00