@Override
    public final YieldAdapterIterator<T> iterator() {
        final ThreadedYieldAdapter<T> yieldAdapter = new ThreadedYieldAdapter<T>();
        Collector<T> collector = new Collector<T>() {

            protected YieldAdapterIterator iterator;

            @Override
            public void collect(final ResultHandler<T> handler) throws CollectionAbortedException {
                resultHandler = handler;
                run(iterator);
            }

            public void setIterator(YieldAdapterIterator iterator) {
                this.iterator = iterator;
            }
        };

        YieldAdapterIterator<T> iterator = yieldAdapter.adapt(collector).iterator();
        collector.setIterator(iterator);
        return iterator;
    }
The method that will generate your results. Call yield() in here.
jphp-runtime/src/php/runtime/util/generator/Generator.java