1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

45 Commits

Author SHA1 Message Date
Arnaud Le Blanc
626f3c3c7c Unify arg info representation for internal and user functions
The arg_info member of zend_function is now always a zend_arg_info*. Before,
it was a zend_internal_arg_info* on internal functions, unless the
ZEND_ACC_USER_ARG_INFO flag was set.

Closes GH-19022
2025-12-15 16:50:49 +01:00
Ilija Tovilo
28fd7597ba Add first-class callable cache
This cache is implemented in two levels: A EG(callable_convert_cache) global
that maps zend_function pointers to a shared callable instance, and a
CALLABLE_CONVERT cache slot to remember the result of the hash table lookup.

Fixes GH-19754
Closes GH-19863
2025-10-03 01:04:56 +02:00
Niels Dossche
d6300a3065 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19653: Closure named argument unpacking between temporary closures can cause a crash
2025-09-14 22:11:22 +02:00
Niels Dossche
a3d27aab03 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19653: Closure named argument unpacking between temporary closures can cause a crash
2025-09-14 22:08:41 +02:00
Niels Dossche
22252954ef Fix GH-19653: Closure named argument unpacking between temporary closures can cause a crash
Due to user closures, the `fbc` address isn't unique if the memory address is reused.
We need to distinguish using a unique key, and we choose arg_info such
that it can be reused across different functions.

Closes GH-19654.
2025-09-14 22:07:36 +02:00
Alexandre Daubois
273d9e2901 [RFC] Deprecate closure binding issues (#19510)
https://wiki.php.net/rfc/deprecations_php_8_5
2025-08-24 00:10:18 -07:00
Alexandre Daubois
e43074a1d8 Rename poorly named tests in Zend/tests (#19332)
And move some into their relevant folders
2025-07-31 19:58:01 +01:00
Ilija Tovilo
eb65ec41b7 Implement Closure::getCurrent() to retrieve current closure
Fixes GH-18163
Closes GH-18167
2025-07-21 16:07:49 +02:00
Gina Peter Banyard
f91f80ca19 Zend: Return anonymous closure names in zend_get_callable_name_ex() (#19011)
This returns the usual `{closure:FILE_NAME/FUNCTION:LINE_NO}` for anonymous functions rather than `Closure::__invoke` this is visible for `is_callable()` and any Engine call that uses `zend_fcall_info_init()` to get the name of the callable.

Related to GH-18063.
2025-07-03 12:01:11 +01:00
Shivam Mathur
9adc94985f Merge branch 'PHP-8.4' 2025-06-25 03:23:03 +05:30
Tim Düsterhus
45d1acf916 Zend: Fix reference counting for Closures in const-expr (#17853)
* Clean up closure static variable handling

* Zend: Fix reference counting for Closures in const-expr

Fixes php/php-src#17851

---------

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
2025-03-27 10:11:44 +01:00
DanielEScherzer
babf7a32bf Zend/tests: organize some tests with sub directories (10) (#17920)
Add directories for tests relating to
- halting the compiler
- `declare()` usage
- exception handlers
- `get_class_methods()`
- `get_class_vars()`
- `isset()`
- name collisions

As well as organizing a couple of tests into existing sub directories along the
way

Work towards GH-15631
2025-02-25 09:48:52 +00:00
DanielEScherzer
a50f82bebf Zend/tests: organize some tests with sub directories (6) (#17807)
Move more tests into existing directories

Work towards GH-15631
2025-02-15 14:55:07 +00:00
DanielEScherzer
d22abca488 Zend/tests: organize some tests with sub directories (5) (#17800)
Second pass through `Zend/tests/bug*` to organize the tests.

Move tests to existing sub directories, and create some new sub directories:
* `ArrayAccess`
* `autoload`
* `clone`
* `serialize` (also covers `unserialize()`)
* `switch`

Work towards GH-15631
2025-02-14 11:49:14 +00:00
DanielEScherzer
a81649f992 Zend/tests: organize some tests with sub directories (4) (#17778)
First pass at moving `Zend/tests/gh*` tests to existing sub directories

Work towards GH-15631
2025-02-13 16:17:36 +00:00
DanielEScherzer
bce1f4aeb1 Zend/tests: organize some tests with sub directories (3) (#16444)
First pass at moving `Zend/tests/bug*` tests to existing sub directories

Work towards GH-15631
2025-02-10 00:35:51 +00:00
DanielEScherzer
8475d5fea1 Zend/tests: organize some tests with subdirectories (#15638)
Move some low-hanging fruit, creating new directories for the tests for

* access modifiers
* `class_alias()`
* constant expressions
* constructor property promotion
* `__debugInfo()`
* dereferencing
* first class callable syntax

Additionally, move some tests into the existing subdirectory for
closure-related tests

Work towards GH-15631
2024-10-13 14:21:07 +01:00
DanielEScherzer
ea297654f4 Zend/*: fix a bunch of typos (GH-16017)
* Zend/*: fix a bunch of typos

* Zend/tests/try/try_catch_finally_005.phpt: update string length
2024-09-24 10:55:21 +02:00
Nikita Popov
ee510eed68 Deprecate partially supported callables
This deprecates all callables that are accepted by
call_user_func($callable) but not by $callable(). In particular:

    "self::method"
    "parent::method"
    "static::method"
    ["self", "method"]
    ["parent", "method"]
    ["static", "method"]
    ["Foo", "Bar::method"]
    [new Foo, "Bar::method"]

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

Closes GH-7446.
2021-10-22 10:15:24 +02:00
twosee
559c3f6d86 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80929
2021-04-16 09:59:01 +08:00
twosee
09f55604ec Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80929
2021-04-16 09:49:36 +08:00
twosee
c0b1bdcdc3 Fixed bug #80929
The function name should be kept if Closure was created from the function which is marked as ZEND_ACC_CALL_VIA_TRAMPOLINE, because it is not a one-time thing and it may be called multiple times.

Closes GH-6867.
2021-04-16 09:48:36 +08:00
Markus Staab
fd3692ba41 Fix typo [ci skip]
Closes GH-6713.
2021-02-22 09:02:31 +01:00
Nikita Popov
f37fe68e63 Fix closure GC handler for fake closures
Fixes oss-fuzz #31135.
2021-02-20 11:16:37 +01:00
Máté Kocsis
d30cd7d7e7 Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +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
Nikita Popov
f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Máté Kocsis
0b4778c377 Fix #78880: Another bunch of spelling errors 2020-01-16 09:46:47 +01:00
Fabien Villepinte
a555cc0b3d Clean DONE tags from tests
Remove most of the `===DONE===` tags and its variations.
Keep `===DONE===` if the test output otherwise becomes empty.

Closes GH-4872.
2019-11-07 21:31:47 +01:00
Peter Kokot
bc56250d2a Merge branch 'PHP-7.4'
* PHP-7.4:
  Test to verify that closures can't be instantiated
2019-02-09 02:47:02 +01:00
MarkBaker
c5f9855283 Test to verify that closures can't be instantiated 2019-02-09 02:46:09 +01:00
Nikita Popov
6c73b50cf6 Remove static calls to non-static methods 2019-01-30 09:19:02 +01:00
Peter Kokot
d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00
Gabriel Caruso
ded3d984c6 Use EXPECT instead of EXPECTF when possible
EXPECTF logic in run-tests.php is considerable, so let's avoid it.
2018-02-20 21:53:48 +01:00
Gabriel Caruso
21e3b0c70c Remove trailing whitespace in inc files 2018-02-10 19:20:23 +01:00
Nikita Popov
bf907b9961 Revert ReflectionType::__toString() behavior + deprecate 2016-09-28 19:21:51 +02:00
Aaron Piotrowski
08c5d77027 Revert "Fix closure tests using ReflectionType::__toString()"
This reverts commit 6fcedc96fb.
2016-08-20 23:26:01 -05:00
Aaron Piotrowski
6fcedc96fb Fix closure tests using ReflectionType::__toString() 2016-08-16 13:05:51 -05:00
Nikita Popov
dbe6a23194 Closure::fromCallable(): Getting non-static method statically
As this is new functionality, I'm going directly for a TypeError,
rather than a deprecation warning.
2016-07-05 15:52:03 +02:00
Nikita Popov
ceae9fb540 Closure::fromCallable(): Better LSB handling
The previous fix missed the "late" part of "late static binding" :)
2016-07-05 15:44:17 +02:00
Nikita Popov
e959a9b652 Closure::fromCallable(): Fix late static binding 2016-07-05 15:31:11 +02:00
Nikita Popov
e395b62c51 Closure::fromCallable(): Use fake closures 2016-07-05 15:13:51 +02:00
Nikita Popov
03fbc27f07 Closure::fromCallable(): Fix test files and names 2016-07-05 15:13:51 +02:00
Danack
fc92eeeadf Added reflection test. Standardised filename for other tests. 2016-06-01 21:53:01 +01:00
Danack
63ca65daef Add Closure::fromCallable().
Add the ability to create closures from callable as part of RFC: https://wiki.php.net/rfc/closurefromcallable
2016-05-15 17:39:47 +01:00