summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
Commit message (Collapse)AuthorAgeFilesLines
...
* | Add zend_call_known_function() API familyNikita Popov2020-06-091-75/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the following APIs: void zend_call_known_function( zend_function *fn, zend_object *object, zend_class_entry *called_scope, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method( zend_function *fn, zend_object *object, zval *retval_ptr, int param_count, zval *params); void zend_call_known_instance_method_with_0_params( zend_function *fn, zend_object *object, zval *retval_ptr); void zend_call_known_instance_method_with_1_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param); void zend_call_known_instance_method_with_2_params( zend_function *fn, zend_object *object, zval *retval_ptr, zval *param1, zval *param2); These are used to perform a call if you already have the zend_function you want to call. zend_call_known_function() is the base API, the rest are just really thin wrappers around it for the common case of instance method calls. Closes GH-5692.
* | Add $filter parameter for ReflectionClass::(getConstants|getReflectionConstants)Gabriel Caruso2020-06-071-16/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Fix expression warnings and break warningstwosee2020-06-071-3/+3
| | | | | | | | Close GH-5675.
* | Implement "Constructor Promotion" RFCNikita Popov2020-06-051-0/+24
| | | | | | | | | | | | RFC: https://wiki.php.net/rfc/constructor_promotion Closes GH-5291.
* | Add AttributesBenjamin Eberlei2020-06-041-2/+396
| | | | | | | | Co-authored-by: Martin Schröder <m.schroeder2007@gmail.com>
* | Add support for the mixed typeMáté Kocsis2020-05-221-3/+3
| | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/mixed_type_v2 Closes GH-5313 Co-authored-by: Dan Ackroyd <danack@basereality.com>
* | Use int|string Fast ZPP macro in ReflectionGeorge Peter Banyard2020-05-061-19/+20
| | | | | | | | | | | | | | Moreover, throw a more appropriate ValueError in case the integer position provided is less than 0. Closes GH-5513
* | Completely remove disabled functions from function tableNikita Popov2020-04-301-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Remove ZEND_ACC_DTOR flagNikita Popov2020-04-171-5/+3
| | | | | | | | | | | | | | | | | | | | This is only used in reflection, where doing a simple string check is acceptable. I'm also dropping the "dtor" printing in the reflection dump. Dtors are just one of many magic methods, I don't think there's a point in explicitly highlighting them, when the name is already unambiguous.
* | Improve some TypeError and ValueError messagesMáté Kocsis2020-04-141-2/+2
| | | | | | | | Closes GH-5377
* | Generate method entries for ext/session and ext/reflectionMáté Kocsis2020-04-131-475/+204
| | | | | | | | Closes GH-5376
* | Export API for fetching internal func defaultNikita Popov2020-04-091-98/+2
| | | | | | | | Make this functionality available outside reflection.
* | Store default parameter values of internal functions in arg infoMáté Kocsis2020-04-081-84/+168
| | | | | | | | | | | | | | 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>
* | Remove most uses of _default_get_name()Nikita Popov2020-04-071-28/+48
| | | | | | | | | | | | Instead fetch the name from the respective structure. The only place where this is still used is ReflectionClassConst, as zend_class_const does not store the name.
* | Eliminate uses of _default_load_name()Nikita Popov2020-04-071-88/+65
| | | | | | | | | | | | Instead fetch the name from the function/class/property, as appropriate. This makes us independent of the property, and eliminates error conditions related to it.
* | Optimize internal name fetching in reflectionNikita Popov2020-04-071-1/+5
| | | | | | | | | | | | Directly fetch the name property, instead of construction the properties hash table and performing a lookup in it. This is both slow and wastes a lot of memory.
* | Assert that arginfo parameter name is presentNikita Popov2020-04-071-9/+6
| |
* | Remove <default> prefix from reflection dumpNikita Popov2020-04-021-4/+0
| | | | | | | | | | This really doesn't add anything, and only makes for confusing terminology. Only marking properties as dynamic is sufficient.
* | Display property default value in reflection dumpsNikita Popov2020-04-021-56/+64
| |
* | Show property type in reflection exportNikita Popov2020-04-021-1/+8
| |
* | Improve error messages of ext/reflectionMáté Kocsis2020-03-231-11/+8
| | | | | | | | Closes GH-5277
* | Store aliased name of trait methodNikita Popov2020-03-031-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, trait methods are aliased will continue to use the original function name. In a few places in the codebase, we will try to look up the actual method name instead. However, this does not work if an aliased method is used indirectly (https://bugs.php.net/bug.php?id=69180). I think it would be better to instead actually change the method name to the alias. This is in principle easy: We have to allow function_name to be changed even if op array is otherwise shared (similar to static_variables). This means we need to addref/release the function_name separately, but I don't think there is a performance concern here (especially as everything is usually interned). There is a bit of complication in opcache, where we need to make sure that the function name is released the correct number of times (interning may overwrite the name in the original op_array, but we need to release it as many times as the op_array is shared). Fixes bug #69180. Fixes bug #74939. Closes GH-5226.
* | Define Stringable with __toString():string methodNicolas Grekas2020-03-021-1/+2
| |
* | Fixed bug #77325Nikita Popov2020-02-281-5/+5
| | | | | | | | | | | | Make ReflectionClassConstant->class the declaring class, not the class on which the constant was fetched. This matches the behavior for properties and methods.
* | Fixed bug #64592Nikita Popov2020-02-281-0/+4
| | | | | | | | | | | | Make ReflectionClass::getMethods() behave the same ways as ReflectionClass::getProperties() by not including private methods from parent classes.
* | Remove the deprecated reflection export methodsMáté Kocsis2020-02-191-194/+0
| | | | | | | | Closes GH-5188
* | Add static return typeNikita Popov2020-02-171-1/+3
| | | | | | | | | | | | | | | | | | | | RFC: https://wiki.php.net/rfc/static_return_type The "static" type is represented as MAY_BE_STATIC, rather than a class type like "self" and "parent", as it has special resolution semantics, and cannot be cached in the runtime cache. Closes GH-5062.
* | Always invoke zpp in ReflectionProperty::getValue/isInitializedNikita Popov2020-02-101-4/+14
| | | | | | | | | | | | Make sure we still perform a zpp check for the static case, and also always enforce that the parameter is ?object. Otherwise we violate the specified signature.
* | Rename reflection stub fileNikita Popov2020-02-101-1/+1
| | | | | | | | | | Where possible, the stub file should match the name of the C file, so that the build system integration automatically recompiles it.
* | Fix some -Wold-style-declaration compiler warningsGeorge Peter Banyard2020-02-051-1/+1
| |
* | Add ReflectionProperty::getDefaultValue and ReflectionProperty::hasDefaultValueBenjamin Eberlei2020-01-221-0/+86
| |
* | Simplify ReflectionProperty::getDeclaringClass()Nikita Popov2020-01-211-16/+2
| |
* | Merge branch 'PHP-7.4'Nikita Popov2020-01-171-0/+2
|\ \ | |/ | | | | | | * PHP-7.4: Fixed bug #79115
| * Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2020-01-171-0/+2
| |\ | | | | | | | | | | | | * PHP-7.3: Fixed bug #79115
| | * Fixed bug #79115Nikita Popov2020-01-171-0/+2
| | |
* | | Use zend_type inside type listsNikita Popov2020-01-171-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having a completely independent encoding for type list entries. This is going to use more memory, but I'm not particularly concerned about that, as type unions that contain multiple classes should be uncommon. On the other hand, this allows us to treat top-level types and types inside lists mostly the same. A new ZEND_TYPE_FOREACH macros allows to transparently treat list and non-list types the same way. I'm not using it everywhere it could be used for now, just the places that seemed most obvious. Of course, this will make any future type system changes much simpler, as it will not be necessary to duplicate all logic two times.
* | | Fix reflection leak if type inside type list is resolvedNikita Popov2020-01-161-18/+7
| | |
* | | Use RETURN_THROWS() in various placesMáté Kocsis2020-01-031-3/+3
| | |
* | | Use RETURN_THROWS() after try_convert_to_string()Máté Kocsis2020-01-031-1/+1
| | |
* | | Use RETURN_THROWS() after zend_throw_exception() in reflection extensionMáté Kocsis2020-01-031-57/+57
| | |
* | | Use RETURN_THROWS() after zend_throw_error()Máté Kocsis2020-01-011-1/+1
| | |
* | | Use RETURN_THROWS() after zend_type_error()Máté Kocsis2020-01-011-1/+1
| | |
* | | Use RETURN_THROWS() during ZPP in the remaining extensionsMáté Kocsis2019-12-311-167/+167
| | | | | | | | | | | | In reflection, sodium, and SPL
* | | Merge branch 'PHP-7.4'Dmitry Stogov2019-12-091-1/+2
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #78895 (Reflection detects abstract non-static class as abstract static. IS_IMPLICIT_ABSTRACT is not longer used)
| * | Fixed bug #78895 (Reflection detects abstract non-static class as abstract ↵Dmitry Stogov2019-12-091-1/+2
| | | | | | | | | | | | static. IS_IMPLICIT_ABSTRACT is not longer used)
* | | Implement union typesNikita Popov2019-11-081-9/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to RFC: https://wiki.php.net/rfc/union_types_v2 The type representation now makes use of both the pointer payload and the type mask at the same time. Additionall, zend_type_list is introduced as a new kind of pointer payload, which is used to store multiple class types. Each of the class types is a tagged pointer, which may be either a class name or class entry. The latter is only used for typed properties, while arguments/returns will instead use cache slots. A type list can contain a mix of both names and CEs at the same time, as not all classes may be resolvable. One thing this is missing is support for union types in arginfo and stubs, which I want to handle separately. I've also dropped the special object code from the JIT implementation for now -- I plan to add this back in a different form at a later time. For now I did not want to include non-trivial JIT changes together with large functional changes. Another possible piece of follow-up work is to implement "iterable" as an internal alias for "array|Traversable". I believe this will eliminate quite a few special-cases that had to be implemented. Closes GH-4838.
* | | Make zend_type a 2-field structNikita Popov2019-11-081-13/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now store the pointer payload and the type mask separately. This is in preparation for union types, where we will be using both at the same time. To avoid increasing the size of arginfo structures, the pass_by_reference and is_variadic fields are now stored as part of the type_mask (8-bit are reserved for custom use). Different types of pointer payloads are distinguished based on bits in the type_mask.
* | | Remove dead code related to inherits props in reflectionNikita Popov2019-11-041-29/+0
| | | | | | | | | | | | | | | | | | Public/protected properties defined in parent classes will be inherited in the child -- there is no need to explicitly try to walk up the chain and look them up.
* | | Store pointer to property_info in reflectionNikita Popov2019-11-041-61/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of constructing a dummy property_info for dynamic properties, leave the field as NULL and handle this as appropriate. This was originally part of an alternative fix for bug #78774, but I think doing it this way is generally preferrable independently of that.
* | | Merge branch 'PHP-7.4'Nikita Popov2019-11-041-1/+13
|\ \ \ | |/ / | | | | | | | | | * PHP-7.4: Fixed bug #78774