Repository: php/php-src (2025-07-30T15:45:04Z)

Issue:
Assertion failure in `zend_compile.c` found by `php-fuzz-execute`
### Description

### Description

The following code:

```php
<?php
$foo = new class {
    public self $v;
};
$foo->v= 0;
```

Resulted in this output:
```
php-fuzz-execute: /src/php-src/Zend/zend_compile.c:1396: zend_string *resolve_class_name(zend_string *, zend_class_entry *): Assertion `scope && "This should only happen with resolved types"' failed.
Aborted (core dumped)
```





### PHP Version

https://github.com/php/php-src/commit/16b2fc41a3cf3871d5481c1efc2e16ac99a2890e


### Operating System

_No response_


Discussion:

Patch:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 19252c26f862e..e66389bc7ee5b 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1393,7 +1393,6 @@ static zend_string *resolve_class_name(zend_string *name, zend_class_entry *scop
 	 * null byte here, to avoid larger parts of the type being omitted by printing code later. */
 	size_t len = strlen(ZSTR_VAL(name));
 	if (len != ZSTR_LEN(name)) {
-		ZEND_ASSERT(scope && "This should only happen with resolved types");
 		return zend_string_init(ZSTR_VAL(name), len, 0);
 	}
 	return zend_string_copy(name);


Test patch:
diff --git a/Zend/tests/gh19304.phpt b/Zend/tests/gh19304.phpt
new file mode 100644
index 0000000000000..c77fc2d6facc2
--- /dev/null
+++ b/Zend/tests/gh19304.phpt
@@ -0,0 +1,18 @@
+--TEST--
+GH-19304: Incorrect anonymous class type name assertion
+--FILE--
+<?php
+
+$foo = new class {
+    public self $v;
+};
+
+try {
+    $foo->v = 0;
+} catch (Error $e) {
+    echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Cannot assign int to property class@anonymous::$v of type class@anonymous