Skip to content

Zend: add object_init_instantiable_class() API and use it#22212

Draft
Girgias wants to merge 2 commits into
php:masterfrom
Girgias:object_init_known_instantiable
Draft

Zend: add object_init_instantiable_class() API and use it#22212
Girgias wants to merge 2 commits into
php:masterfrom
Girgias:object_init_known_instantiable

Conversation

@Girgias
Copy link
Copy Markdown
Member

@Girgias Girgias commented Jun 2, 2026

This is an idea that kinda came up while working on #19797

In most cases when an extension calls object_init_ex() it's instantiating one of its own classes, and thus it knows it is instantiable. Therefore, I propose to introduce a new API which skips the (albeit cheap) check.

The secondary motivation is that I'm not fully certain I agree that it should be the task of object_init_ex() to check if an object is instantiable. This is especially relevant for #19797 as I would like to have a single API to that checks that the CE is a concrete class, but also that the constructor is actually callable (i.e. public or within scope) prior to attempting to create the object.

It is probably possible to convert more object_init_ex() (especially those in ext/date) but those are not immediately obvious.

Girgias added 2 commits June 2, 2026 20:42
To remove the need to check (and throw an exception) if a class is instantiable if we know it is.
As those class_entries are known to be instantiable
@Girgias Girgias force-pushed the object_init_known_instantiable branch from 907f31d to decf28a Compare June 2, 2026 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant