On Tue, May 12, 2020 at 3:26 AM Nikita Popov <nikita....@gmail.com> wrote: > // WeakMap::getIterator(): Iterator > ZEND_METHOD(WeakMap, getIterator) > { > if (zend_parse_parameters_none() == FAILURE) { > return; > } > zend_create_internal_iterator_zval(return_value, ZEND_THIS); > } > Given that the body of this method seems to usually (always?) be the same, why not define it in InternalIterator and allow it to be inherited?
> There's some bikeshed potential here regarding the class name. > Not personally over-picky, but I do agree that "Internal*" is a bit awkward. Unfortunately there's not much that's better and appropriate for exposing to scripts. This might be one of those rare occasions where exposing "Zend" into userspace makes sense. "PHP" is overloaded into several meanings that are significant for userspace developers, but something like "ZendIterator" might convey the right level of "This has to do with the engine, please move along". Or maybe go verbose: 'IteratorForExtensionClassImplementations'. :p > ZEND_ASSERT(scope->get_iterator != zend_user_it_get_new_iterator); > Does this mean that if I do `class Foo implements InternalIterator {}` in a script, I can assert (crash) PHP? I don't see anything obvious (at a glance) preventing me from inheriting from InternalIterator. -Sara