fruffl icon

AOP/Injectable Object

fruffl | 01/26/13 07:02:14 AM UTC | 0 ⭐ | 266 👁️ | Never ⏰ | []
PHP |

14.87 KB

|

None

|

0 👍

/

0 👎

 
    class baz extends \ILLI\Core\StaticObject
    {
        protected static $baz = [];
        public static function reseiveMyWorld($param1, $param2)
        {
            static::$baz = [__METHOD__ => get_defined_vars()];
            return get_defined_vars();
        }
    }
    
    baz::construct();
    
    class bar extends \ILLI\Net\Message {}
    class foo extends \ILLI\Net\Message {}
    
    $bar = new bar;
    $foo = new foo;
    
    $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 499, ['root\baz', 'reseiveMyWorld']);
    $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bar, 'propertySet']);
    $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 501, function($_, $_, $_, $params)
    {
        return $params;
    });
    
    $foo->propertySet('scheme', 'http');
    
    var_dump($foo->to('array'));
    var_dump($bar->to('array'));
    var_dump(baz::to('array'));
    
    var_dump($foo, $bar);
 
 
 
/*
array(7) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(9) "localhost"
  ["port"]=>
  NULL
  ["username"]=>
  NULL
  ["password"]=>
  NULL
  ["path"]=>
  NULL
  ["body"]=>
  array(0) {
  }
}
array(7) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(9) "localhost"
  ["port"]=>
  NULL
  ["username"]=>
  NULL
  ["password"]=>
  NULL
  ["path"]=>
  NULL
  ["body"]=>
  array(0) {
  }
}
array(1) {
  ["baz"]=>
  array(1) {
    ["root\baz::reseiveMyWorld"]=>
    array(2) {
      ["param1"]=>
      string(6) "scheme"
      ["param2"]=>
      string(4) "http"
    }
  }
}
object(root\foo)#9 (19) {
  ["scheme":protected]=>
  string(4) "http"
  ["host":protected]=>
  string(9) "localhost"
  ["port":protected]=>
  NULL
  ["username":protected]=>
  NULL
  ["password":protected]=>
  NULL
  ["path":protected]=>
  NULL
  ["body":protected]=>
  array(0) {
  }
  ["__initConfig":protected]=>
  array(17) {
    ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
    bool(true)
    ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
    string(6) "__main"
    ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_TO"]=>
    array(9) {
      ["string"]=>
      string(8) "toString"
      ["array"]=>
      string(7) "toArray"
      ["body"]=>
      string(6) "toBody"
      ["context"]=>
      string(9) "toContext"
      ["hostAndDefaultPort"]=>
      string(20) "toHostAndDefaultPort"
      ["hostAndPort"]=>
      string(13) "toHostAndPort"
      ["uri"]=>
      string(5) "toUri"
      ["url"]=>
      string(5) "toUrl"
      ["port"]=>
      string(6) "toPort"
    }
    ["scheme"]=>
    string(3) "tcp"
    ["host"]=>
    string(9) "localhost"
    ["port"]=>
    NULL
    ["path"]=>
    NULL
    ["username"]=>
    NULL
    ["password"]=>
    NULL
    ["body"]=>
    array(0) {
    }
  }
  ["__export"]=>
  array(0) {
  }
  ["__Core_Object_T_Class_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Delegate_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Filter_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Method_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_MethodFacade_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_MethodProto_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Observer_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Signal_registry":protected]=>
  array(1) {
    ["propertySet"]=>
    array(1) {
      ["ILLI\Core\Object\I_Signal::T_SIGNAL_EMIT_EVENT_INIT"]=>
      array(3) {
        [499]=>
        array(2) {
          [0]=>
          string(8) "root\baz"
          [1]=>
          string(14) "reseiveMyWorld"
        }
        [500]=>
        array(2) {
          [0]=>
          object(root\bar)#6 (19) {
            ["scheme":protected]=>
            string(4) "http"
            ["host":protected]=>
            string(9) "localhost"
            ["port":protected]=>
            NULL
            ["username":protected]=>
            NULL
            ["password":protected]=>
            NULL
            ["path":protected]=>
            NULL
            ["body":protected]=>
            array(0) {
            }
            ["__initConfig":protected]=>
            array(17) {
              ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
              bool(true)
              ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
              string(6) "__main"
              ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
              array(0) {
              }
              ["ILLI\Core\Object\I_Object::DEF_TO"]=>
              array(9) {
                ["string"]=>
                string(8) "toString"
                ["array"]=>
                string(7) "toArray"
                ["body"]=>
                string(6) "toBody"
                ["context"]=>
                string(9) "toContext"
                ["hostAndDefaultPort"]=>
                string(20) "toHostAndDefaultPort"
                ["hostAndPort"]=>
                string(13) "toHostAndPort"
                ["uri"]=>
                string(5) "toUri"
                ["url"]=>
                string(5) "toUrl"
                ["port"]=>
                string(6) "toPort"
              }
              ["scheme"]=>
              string(3) "tcp"
              ["host"]=>
              string(9) "localhost"
              ["port"]=>
              NULL
              ["path"]=>
              NULL
              ["username"]=>
              NULL
              ["password"]=>
              NULL
              ["body"]=>
              array(0) {
              }
            }
            ["__export"]=>
            array(0) {
            }
            ["__Core_Object_T_Class_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Delegate_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Filter_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Method_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_MethodFacade_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_MethodProto_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Observer_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Signal_registry":protected]=>
            array(0) {
            }
            ["__Core_Object_T_Signal_results":protected]=>
            array(0) {
            }
            ["__Core_Object_T_To_registry":protected]=>
            array(9) {
              ["string"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(8) "toString"
              }
              ["array"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(7) "toArray"
              }
              ["body"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(6) "toBody"
              }
              ["context"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(9) "toContext"
              }
              ["hostAndDefaultPort"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(20) "toHostAndDefaultPort"
              }
              ["hostAndPort"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(13) "toHostAndPort"
              }
              ["uri"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(5) "toUri"
              }
              ["url"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(5) "toUrl"
              }
              ["port"]=>
              array(2) {
                [0]=>
                *RECURSION*
                [1]=>
                string(6) "toPort"
              }
            }
          }
          [1]=>
          string(11) "propertySet"
        }
        [501]=>
        array(2) {
          [0]=>
          *RECURSION*
          [1]=>
          object(Closure)#11 (2) {
            ["this"]=>
            *RECURSION*
            ["parameter"]=>
            array(2) {
              ["$_"]=>
              string(10) "<required>"
              ["$params"]=>
              string(10) "<required>"
            }
          }
        }
      }
    }
  }
  ["__Core_Object_T_Signal_results":protected]=>
  array(1) {
    ["propertySet"]=>
    array(1) {
      ["ILLI\Core\Object\I_Signal::T_SIGNAL_EMIT_EVENT_INIT"]=>
      array(3) {
        [499]=>
        array(2) {
          ["param1"]=>
          string(6) "scheme"
          ["param2"]=>
          string(4) "http"
        }
        [500]=>
        string(4) "http"
        [501]=>
        array(2) {
          ["__property"]=>
          string(6) "scheme"
          ["__value"]=>
          string(4) "http"
        }
      }
    }
  }
  ["__Core_Object_T_To_registry":protected]=>
  array(9) {
    ["string"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(8) "toString"
    }
    ["array"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(7) "toArray"
    }
    ["body"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(6) "toBody"
    }
    ["context"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(9) "toContext"
    }
    ["hostAndDefaultPort"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(20) "toHostAndDefaultPort"
    }
    ["hostAndPort"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(13) "toHostAndPort"
    }
    ["uri"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(5) "toUri"
    }
    ["url"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(5) "toUrl"
    }
    ["port"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(6) "toPort"
    }
  }
}
object(root\bar)#6 (19) {
  ["scheme":protected]=>
  string(4) "http"
  ["host":protected]=>
  string(9) "localhost"
  ["port":protected]=>
  NULL
  ["username":protected]=>
  NULL
  ["password":protected]=>
  NULL
  ["path":protected]=>
  NULL
  ["body":protected]=>
  array(0) {
  }
  ["__initConfig":protected]=>
  array(17) {
    ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
    bool(true)
    ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
    string(6) "__main"
    ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
    array(0) {
    }
    ["ILLI\Core\Object\I_Object::DEF_TO"]=>
    array(9) {
      ["string"]=>
      string(8) "toString"
      ["array"]=>
      string(7) "toArray"
      ["body"]=>
      string(6) "toBody"
      ["context"]=>
      string(9) "toContext"
      ["hostAndDefaultPort"]=>
      string(20) "toHostAndDefaultPort"
      ["hostAndPort"]=>
      string(13) "toHostAndPort"
      ["uri"]=>
      string(5) "toUri"
      ["url"]=>
      string(5) "toUrl"
      ["port"]=>
      string(6) "toPort"
    }
    ["scheme"]=>
    string(3) "tcp"
    ["host"]=>
    string(9) "localhost"
    ["port"]=>
    NULL
    ["path"]=>
    NULL
    ["username"]=>
    NULL
    ["password"]=>
    NULL
    ["body"]=>
    array(0) {
    }
  }
  ["__export"]=>
  array(0) {
  }
  ["__Core_Object_T_Class_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Delegate_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Filter_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Method_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_MethodFacade_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_MethodProto_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Observer_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Signal_registry":protected]=>
  array(0) {
  }
  ["__Core_Object_T_Signal_results":protected]=>
  array(0) {
  }
  ["__Core_Object_T_To_registry":protected]=>
  array(9) {
    ["string"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(8) "toString"
    }
    ["array"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(7) "toArray"
    }
    ["body"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(6) "toBody"
    }
    ["context"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(9) "toContext"
    }
    ["hostAndDefaultPort"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(20) "toHostAndDefaultPort"
    }
    ["hostAndPort"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(13) "toHostAndPort"
    }
    ["uri"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(5) "toUri"
    }
    ["url"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(5) "toUrl"
    }
    ["port"]=>
    array(2) {
      [0]=>
      *RECURSION*
      [1]=>
      string(6) "toPort"
    }
  }
}

Comments