| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2012-09-02 07:46 UTC] reeze dot xia at gmail dot com
 Description:
------------
magic method are called in a special way, if those methods
was defined as generator, most of them will not work as expected.
We could disallow them when compiling.
Test script:
---------------
class A {
     public function __construct(array $data) {
           $this->initData = $data;
           // maybe more initialization...
           var_dump($this->initData);
           foreach$(this->initData as $v) {
               yield $v;
           }
     }
}
$a = new A(array(1, 2)); //  constructor didn't get called.
so does the that magic methods:
http://www.php.net/manual/en/language.oop5.magic.php
most of them are meanning less if they are generators.
*some of them* maybe useful if they return value but not void.
Those could be allowed: __call(), __callStatic(), __get(), __invoke()
but those seems meaningless to be generators
__construct(), __destruct(), __set(), __isset(), __unset(), __sleep(), __wakeup(), __toString(), __set_state() and __clone(), 
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 00:00:01 2025 UTC | 
like: $a = new A; foreach ($a->__construct() as $v) { } since we don't disallow call to __construct(magic methods) directly(although I don't like this).