minor #4814 Remove obsolete PHP 8.0 workaround for Closure::__invoke attribute access (fabpot)

This PR was merged into the 3.x branch.

Discussion
----------

Remove obsolete PHP 8.0 workaround for Closure::__invoke attribute access

The removed code was needed for `isset($closure->__invoke)` to work with PHP pre-8.0 (to avoid a fatal error):

 * 7.4: Fatal error: Uncaught Error: Closure object cannot have properties
 * 8.0: Fatal error: Uncaught Error: Closure object cannot have properties
 * 8.1+: bool(false) clean, no error

Commits
-------

42ccc472a2 Remove obsolete PHP 8.0 workaround for Closure::__invoke attribute access
This commit is contained in:
Fabien Potencier
2026-05-25 08:28:24 +02:00
-4
View File
@@ -1795,10 +1795,6 @@ final class CoreExtension extends AbstractExtension
static $propertyCheckers = [];
if ($object instanceof \Closure && '__invoke' === $item) {
return $isDefinedTest ? true : $object();
}
if (isset($object->$item)
|| ($propertyCheckers[$object::class][$item] ??= self::getPropertyChecker($object::class, $item))($object, $item)
) {