[php-src] PR #25494: Fix ReflectionMethod::getClosure() on abstract methods
| From: | nicolas-grekas | Date: | Mon, 16 Nov 2026 17:10:04 +0000 |
| Subject: | [php-src] PR #25494: Fix ReflectionMethod::getClosure() on abstract methods | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40697@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25494
Author: nicolas-grekas
ReflectionMethod::getClosure() accepts abstract methods. Calling the closure does
nothing for a user method, and crashes for the method of an internal class or interface:
```php
$closure = (new ReflectionMethod('Countable', 'count'))->getClosure(new
ArrayObject());
$closure(); // segfault
```
This PR makes getClosure() throw a ReflectionException for abstract
methods, like invoke() does.
I targeted PHP-8.4 because of the crash. Tell me if you prefer master, since user methods are
affected too.