Commit graph

1280 commits

Author SHA1 Message Date
Ilija Tovilo
1435fc6262
Private method incorrectly marked as "overwrites" in reflection
Fix GH-9409
Closes GH-9469
2022-09-08 10:43:25 +02:00
Arnaud Le Blanc
db1ef97209 Add tests 2022-09-02 13:33:21 +02:00
Nicolas Grekas
93f11d8429
Fix GH-8932: Provide a way to get the called-scope of closures (#9299)
Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>
2022-09-02 13:32:50 +02:00
Dmitry Stogov
088e5677fb Fix memory leak
This fixes oss-fuzz #47791
2022-06-06 11:35:01 +03:00
Ollie Read
d0f1b987a5
Fix GH-8421: Attributes that target functions are not valid for anonymous functions defined within a method
Closes GH-8424
2022-04-23 11:16:28 +02:00
Christoph M. Becker
0d266a24d6
Fix GH-8080: ReflectionClass::getConstants() depends on def. order
When we need to evaluate constant ASTs, we always have to do that in
the scope where the constant has been defined, which may be a parent
of the `ReflectionClass`'s scope.

Closes GH-8106.
2022-02-28 10:08:47 +01:00
Dmitry Stogov
f7c3f6e7e2 Fix ext/zend_test/tests/observer_bug81430_2.phpt failure 2022-01-12 12:08:59 +03:00
Benjamin Eberlei
2f6a06ccb0
Fix #81430: Attribute instantiation leaves dangling pointer
By switching attribute constructor stackframe to be called via
trampoline the stack allocation is not causing dangling pointers
in the zend_observer API anymore.

Co-Authored-By: Florian Sowade <f.sowade@suora.com>
Co-Authored-By: Christopher Becker <cmbecker69@gmx.de>
Co-Authored-By: Dmitry Stogov <dmitry@zend.com>

Closes GH-7885.
2022-01-10 12:40:15 +01:00
Nikita Popov
b302bfabe7 Implement Stringable automatically for internal classes
Requiring all internal classes (including those from 3rd-party
extensions) to implement Stringable if they provide __toString()
is too error prone. Case in point, our _ZendTestClass test class
was not doing so, resulting in preloading test failures after
recent changes.

Instead we automatically implement Stringable, the same as we do
for userland classes. We still allow explicit implementations,
but ignore them (normally they would result in an error due to
duplicate interface implementation). Finally, we need to be
careful about not trying to implement Stringable on Stringable
itself.

In some cases this changes the interface order, in particular the
automatic Stringable implementation will now come first.
2021-11-05 10:22:04 +01:00
sasezaki
e286313fa7 Fix bug #81474: Make ReflectionAttribute non-final
This backports GH-7520 to PHP 8.0.

Closes GH-7545.
2021-10-04 14:39:46 +02:00
Nikita Popov
b976bc44f1 Fixed bug #81208
The number of populated positional arguments is argc. i may also
include named args and thus try to dtor uninitialized zvals.
2021-07-01 13:36:57 +02:00
Felipe Pena
8813f2e0c3 Merge branch 'PHP-7.4' into PHP-8.0 2021-02-25 20:54:24 +00:00
Felipe Pena
988c3f9659 Fix memleak on ReflectionFunction and ReflectionGenerator classes when calling __construct after instantiation 2021-02-25 20:53:14 +00:00
Christoph M. Becker
b2fba0ef62 Fix build
We cannot `RETURN_THROWS()` here, since `return_value` is not defined.
2021-01-01 17:41:48 +01:00
Máté Kocsis
b23c865d15
Use RETURN_THROWS() in a few places 2021-01-01 16:52:48 +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
70f59b3416 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix usage of casted string in ReflectionParameter ctor
2020-11-24 16:42:52 +01:00
Nikita Popov
706241f82d Fix usage of casted string in ReflectionParameter ctor
Fixes oss-fuzz #27755.
2020-11-24 16:42:16 +01:00
Benjamin Eberlei
1727d96d0e Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
Closes GH-6428.
2020-11-17 10:54:27 +01:00
Nikita Popov
d033d5c07a Fix reflection getDefaultValue() with user arg info
The default value is part of the op_array in that case, but we have
no way to access it. Fail gracefully.
2020-11-12 11:02:04 +01:00
Nikita Popov
904c1b6589 FIxed bug #80299
The must_wrap was leaking across iterations.
2020-10-30 17:23:18 +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
Remi Collet
91f47ee263 don't display default value for variadic 2020-10-07 16:30:18 +02:00
Nikita Popov
dee802498e Fixed bug #80190 2020-10-06 10:20:27 +02:00
Nikita Popov
25f1c405ff Update ext/standard parameter names
Closes GH-6214.
2020-09-29 16:49:46 +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
Nikita Popov
5686c16db4 Honor strict_types=1 for attributes, improve backtraces
Make ReflectionAttribute::newInstance() respect the strict_types=1
declaration at the attribute use-site. More generally, pretend that
we are calling the attribute constructor from the place where the
attribute is used, which also means that the attribute location will
show up properly in backtraces and inside "called in" error information.

This requires us to store the attributes strict_types scope (as flags),
as well as the attribute line number. The attribute filename can be
recovered from the symbol it is used on. We might want to expose the
attribute line number via reflection as well.

See also https://externals.io/message/111915.

Closes GH-6201.
2020-09-27 10:42:58 +02:00
Máté Kocsis
64af12d13b
Add support for @implementation-alias in stubs
Closes GH-6170
2020-09-21 10:08:45 +02:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +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
Larry Garfield
96f2f3174b Update array parameter names for named parameters
* The array "subject" of a function gets called $array.

* Further parameters should be self-descriptive if used
  as a named parameter, and a full word, not an abbreviation.

* If there is a "bunch more arrays" variadic, it gets
  called $arrays (because that's what was already there).

* A few functions have a variadic "a bunch more arrays,
  and then a callable", and were already called $rest.
  I left those as is and died a little inside.

* Any callable provided to an array function that acts
  on the array is called $callback. (Nearly all were already,
  I just fixed the one or two outliers.)

* array_multisort() is beyond help so I ran screaming.
2020-09-14 14:56:49 +00:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
a59923befd
Refactor ReflectionMethod::__construct()
Closes GH-6098
2020-09-11 10:59:13 +02:00
Nikita Popov
d37d222835 Make array_multisort() signature more variadic
The second and third arguments are not always the sort_order and
sort_flags -- they can also be in reverse order, or be arrays
altogether. Move them into the variadic parameter to avoid awkward
error messages.
2020-09-09 11:36:38 +02:00
Máté Kocsis
9975986b7e
Improve error messages mentioning parameters instead of arguments
Closes GH-5999
2020-09-09 10:47:43 +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
Nikita Popov
53a87547c8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix leak on consteval exception in ReflectionClass::__toString()
2020-08-31 15:10:53 +02:00
Nikita Popov
1f6f9c70cb Fix leak on consteval exception in ReflectionClass::__toString() 2020-08-31 15:10:09 +02:00
Nikita Popov
1036fd2a70 Merge branch 'PHP-7.4'
* PHP-7.4:
  Check update constant failure in ReflectionClassConstant::__toString()
2020-08-31 14:50:40 +02:00
Nikita Popov
8bb2f406de Check update constant failure in ReflectionClassConstant::__toString() 2020-08-31 14:50:20 +02:00
Nikita Popov
b4196ae9df Fix fetching default value of internal function with userland arginfo
"Fix" in the sense of "not crash". We aren't able to actually
display the default value for this case, as there's no way to
fetch the relevant information right now.
2020-08-31 14:03:54 +02:00
Remi Collet
f16c1dc7ee fix test expectation 2020-08-13 09:36:42 +02:00
Tyson Andre
1e9a5c67ef Rename standard array function parameters to $array
This is targeting 8.0.

`$arg` seems like a poor choice of a name,
especially if the function were to have arguments added.

In many cases, the php.net documentation already has $array for these functions.
E.g. https://www.php.net/manual/en/function.array-intersect.php

I'd assume that since named arguments was added to 8.0 near the feature freeze,
PHP's maintainers had planned to make the names consistent
and gradually use the same name for  docs and implementation.
2020-08-11 19:11:59 -04:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00