[php-src] Issue #22354: zend_compile_implements() assumes that the class entry has no interfaces already

[email protected] (DanielEScherzer) Wed, 17 Jun 2026 17:44:16 +0000
Newsgroups php.bugs
Message-ID <hvzEAk8fZ4S24WdpqT2oC1ndp8WxNCwvXFajB6MySaY@main.internal.php.net>
Issue: https://github.com/php/php-src/issues/22354
Author: DanielEScherzer

### Description

See https://github.com/php/php-src/blob/b0c78657949289c87d36eda5385d032294c40118/Zend/zend_compile.c#L8959-L8977

If an attribute validator added an interface to the class, it gets silently dropped and triggers leaks, because class attributes are compiled before implements, see

https://github.com/php/php-src/blob/b0c78657949289c87d36eda5385d032294c40118/Zend/zend_compile.c#L9110-L9116

Discovered while working on https://github.com/DanielEScherzer/CustomCast, not sure if I noticed this earlier and just didn't report it but it has been there for a while

### PHP Version

```plain
8.4+
```

### Operating System

_No response_