Advertisement
fruffl

AOP/Injectable Object

Jan 26th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.87 KB | None | 0 0
  1.  
  2.     class baz extends \ILLI\Core\StaticObject
  3.     {
  4.         protected static $baz = [];
  5.         public static function reseiveMyWorld($param1, $param2)
  6.         {
  7.             static::$baz = [__METHOD__ => get_defined_vars()];
  8.             return get_defined_vars();
  9.         }
  10.     }
  11.    
  12.     baz::construct();
  13.    
  14.     class bar extends \ILLI\Net\Message {}
  15.     class foo extends \ILLI\Net\Message {}
  16.    
  17.     $bar = new bar;
  18.     $foo = new foo;
  19.    
  20.     $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 499, ['root\baz', 'reseiveMyWorld']);
  21.     $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 500, [$bar, 'propertySet']);
  22.     $foo->registerSignal('propertySet', bar::T_SIGNAL_EMIT_EVENT_INIT, 501, function($_, $_, $_, $params)
  23.     {
  24.         return $params;
  25.     });
  26.    
  27.     $foo->propertySet('scheme', 'http');
  28.    
  29.     var_dump($foo->to('array'));
  30.     var_dump($bar->to('array'));
  31.     var_dump(baz::to('array'));
  32.    
  33.     var_dump($foo, $bar);
  34.  
  35.  
  36.  
  37. /*
  38. array(7) {
  39.   ["scheme"]=>
  40.   string(4) "http"
  41.   ["host"]=>
  42.   string(9) "localhost"
  43.   ["port"]=>
  44.   NULL
  45.   ["username"]=>
  46.   NULL
  47.   ["password"]=>
  48.   NULL
  49.   ["path"]=>
  50.   NULL
  51.   ["body"]=>
  52.   array(0) {
  53.   }
  54. }
  55. array(7) {
  56.   ["scheme"]=>
  57.   string(4) "http"
  58.   ["host"]=>
  59.   string(9) "localhost"
  60.   ["port"]=>
  61.   NULL
  62.   ["username"]=>
  63.   NULL
  64.   ["password"]=>
  65.   NULL
  66.   ["path"]=>
  67.   NULL
  68.   ["body"]=>
  69.   array(0) {
  70.   }
  71. }
  72. array(1) {
  73.   ["baz"]=>
  74.   array(1) {
  75.     ["root\baz::reseiveMyWorld"]=>
  76.     array(2) {
  77.       ["param1"]=>
  78.       string(6) "scheme"
  79.       ["param2"]=>
  80.       string(4) "http"
  81.     }
  82.   }
  83. }
  84. object(root\foo)#9 (19) {
  85.   ["scheme":protected]=>
  86.   string(4) "http"
  87.   ["host":protected]=>
  88.   string(9) "localhost"
  89.   ["port":protected]=>
  90.   NULL
  91.   ["username":protected]=>
  92.   NULL
  93.   ["password":protected]=>
  94.   NULL
  95.   ["path":protected]=>
  96.   NULL
  97.   ["body":protected]=>
  98.   array(0) {
  99.   }
  100.   ["__initConfig":protected]=>
  101.   array(17) {
  102.     ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
  103.     bool(true)
  104.     ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
  105.     string(6) "__main"
  106.     ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
  107.     array(0) {
  108.     }
  109.     ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
  110.     array(0) {
  111.     }
  112.     ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
  113.     array(0) {
  114.     }
  115.     ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
  116.     array(0) {
  117.     }
  118.     ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
  119.     array(0) {
  120.     }
  121.     ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
  122.     array(0) {
  123.     }
  124.     ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
  125.     array(0) {
  126.     }
  127.     ["ILLI\Core\Object\I_Object::DEF_TO"]=>
  128.     array(9) {
  129.       ["string"]=>
  130.       string(8) "toString"
  131.       ["array"]=>
  132.       string(7) "toArray"
  133.       ["body"]=>
  134.       string(6) "toBody"
  135.       ["context"]=>
  136.       string(9) "toContext"
  137.       ["hostAndDefaultPort"]=>
  138.       string(20) "toHostAndDefaultPort"
  139.       ["hostAndPort"]=>
  140.       string(13) "toHostAndPort"
  141.       ["uri"]=>
  142.       string(5) "toUri"
  143.       ["url"]=>
  144.       string(5) "toUrl"
  145.       ["port"]=>
  146.       string(6) "toPort"
  147.     }
  148.     ["scheme"]=>
  149.     string(3) "tcp"
  150.     ["host"]=>
  151.     string(9) "localhost"
  152.     ["port"]=>
  153.     NULL
  154.     ["path"]=>
  155.     NULL
  156.     ["username"]=>
  157.     NULL
  158.     ["password"]=>
  159.     NULL
  160.     ["body"]=>
  161.     array(0) {
  162.     }
  163.   }
  164.   ["__export"]=>
  165.   array(0) {
  166.   }
  167.   ["__Core_Object_T_Class_registry":protected]=>
  168.   array(0) {
  169.   }
  170.   ["__Core_Object_T_Delegate_registry":protected]=>
  171.   array(0) {
  172.   }
  173.   ["__Core_Object_T_Filter_registry":protected]=>
  174.   array(0) {
  175.   }
  176.   ["__Core_Object_T_Method_registry":protected]=>
  177.   array(0) {
  178.   }
  179.   ["__Core_Object_T_MethodFacade_registry":protected]=>
  180.   array(0) {
  181.   }
  182.   ["__Core_Object_T_MethodProto_registry":protected]=>
  183.   array(0) {
  184.   }
  185.   ["__Core_Object_T_Observer_registry":protected]=>
  186.   array(0) {
  187.   }
  188.   ["__Core_Object_T_Signal_registry":protected]=>
  189.   array(1) {
  190.     ["propertySet"]=>
  191.     array(1) {
  192.       ["ILLI\Core\Object\I_Signal::T_SIGNAL_EMIT_EVENT_INIT"]=>
  193.       array(3) {
  194.         [499]=>
  195.         array(2) {
  196.           [0]=>
  197.           string(8) "root\baz"
  198.           [1]=>
  199.           string(14) "reseiveMyWorld"
  200.         }
  201.         [500]=>
  202.         array(2) {
  203.           [0]=>
  204.           object(root\bar)#6 (19) {
  205.             ["scheme":protected]=>
  206.             string(4) "http"
  207.             ["host":protected]=>
  208.             string(9) "localhost"
  209.             ["port":protected]=>
  210.             NULL
  211.             ["username":protected]=>
  212.             NULL
  213.             ["password":protected]=>
  214.             NULL
  215.             ["path":protected]=>
  216.             NULL
  217.             ["body":protected]=>
  218.             array(0) {
  219.             }
  220.             ["__initConfig":protected]=>
  221.             array(17) {
  222.               ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
  223.               bool(true)
  224.               ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
  225.               string(6) "__main"
  226.               ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
  227.               array(0) {
  228.               }
  229.               ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
  230.               array(0) {
  231.               }
  232.               ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
  233.               array(0) {
  234.               }
  235.               ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
  236.               array(0) {
  237.               }
  238.               ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
  239.               array(0) {
  240.               }
  241.               ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
  242.               array(0) {
  243.               }
  244.               ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
  245.               array(0) {
  246.               }
  247.               ["ILLI\Core\Object\I_Object::DEF_TO"]=>
  248.               array(9) {
  249.                 ["string"]=>
  250.                 string(8) "toString"
  251.                 ["array"]=>
  252.                 string(7) "toArray"
  253.                 ["body"]=>
  254.                 string(6) "toBody"
  255.                 ["context"]=>
  256.                 string(9) "toContext"
  257.                 ["hostAndDefaultPort"]=>
  258.                 string(20) "toHostAndDefaultPort"
  259.                 ["hostAndPort"]=>
  260.                 string(13) "toHostAndPort"
  261.                 ["uri"]=>
  262.                 string(5) "toUri"
  263.                 ["url"]=>
  264.                 string(5) "toUrl"
  265.                 ["port"]=>
  266.                 string(6) "toPort"
  267.               }
  268.               ["scheme"]=>
  269.               string(3) "tcp"
  270.               ["host"]=>
  271.               string(9) "localhost"
  272.               ["port"]=>
  273.               NULL
  274.               ["path"]=>
  275.               NULL
  276.               ["username"]=>
  277.               NULL
  278.               ["password"]=>
  279.               NULL
  280.               ["body"]=>
  281.               array(0) {
  282.               }
  283.             }
  284.             ["__export"]=>
  285.             array(0) {
  286.             }
  287.             ["__Core_Object_T_Class_registry":protected]=>
  288.             array(0) {
  289.             }
  290.             ["__Core_Object_T_Delegate_registry":protected]=>
  291.             array(0) {
  292.             }
  293.             ["__Core_Object_T_Filter_registry":protected]=>
  294.             array(0) {
  295.             }
  296.             ["__Core_Object_T_Method_registry":protected]=>
  297.             array(0) {
  298.             }
  299.             ["__Core_Object_T_MethodFacade_registry":protected]=>
  300.             array(0) {
  301.             }
  302.             ["__Core_Object_T_MethodProto_registry":protected]=>
  303.             array(0) {
  304.             }
  305.             ["__Core_Object_T_Observer_registry":protected]=>
  306.             array(0) {
  307.             }
  308.             ["__Core_Object_T_Signal_registry":protected]=>
  309.             array(0) {
  310.             }
  311.             ["__Core_Object_T_Signal_results":protected]=>
  312.             array(0) {
  313.             }
  314.             ["__Core_Object_T_To_registry":protected]=>
  315.             array(9) {
  316.               ["string"]=>
  317.               array(2) {
  318.                 [0]=>
  319.                 *RECURSION*
  320.                 [1]=>
  321.                 string(8) "toString"
  322.               }
  323.               ["array"]=>
  324.               array(2) {
  325.                 [0]=>
  326.                 *RECURSION*
  327.                 [1]=>
  328.                 string(7) "toArray"
  329.               }
  330.               ["body"]=>
  331.               array(2) {
  332.                 [0]=>
  333.                 *RECURSION*
  334.                 [1]=>
  335.                 string(6) "toBody"
  336.               }
  337.               ["context"]=>
  338.               array(2) {
  339.                 [0]=>
  340.                 *RECURSION*
  341.                 [1]=>
  342.                 string(9) "toContext"
  343.               }
  344.               ["hostAndDefaultPort"]=>
  345.               array(2) {
  346.                 [0]=>
  347.                 *RECURSION*
  348.                 [1]=>
  349.                 string(20) "toHostAndDefaultPort"
  350.               }
  351.               ["hostAndPort"]=>
  352.               array(2) {
  353.                 [0]=>
  354.                 *RECURSION*
  355.                 [1]=>
  356.                 string(13) "toHostAndPort"
  357.               }
  358.               ["uri"]=>
  359.               array(2) {
  360.                 [0]=>
  361.                 *RECURSION*
  362.                 [1]=>
  363.                 string(5) "toUri"
  364.               }
  365.               ["url"]=>
  366.               array(2) {
  367.                 [0]=>
  368.                 *RECURSION*
  369.                 [1]=>
  370.                 string(5) "toUrl"
  371.               }
  372.               ["port"]=>
  373.               array(2) {
  374.                 [0]=>
  375.                 *RECURSION*
  376.                 [1]=>
  377.                 string(6) "toPort"
  378.               }
  379.             }
  380.           }
  381.           [1]=>
  382.           string(11) "propertySet"
  383.         }
  384.         [501]=>
  385.         array(2) {
  386.           [0]=>
  387.           *RECURSION*
  388.           [1]=>
  389.           object(Closure)#11 (2) {
  390.             ["this"]=>
  391.             *RECURSION*
  392.             ["parameter"]=>
  393.             array(2) {
  394.               ["$_"]=>
  395.               string(10) "<required>"
  396.               ["$params"]=>
  397.               string(10) "<required>"
  398.             }
  399.           }
  400.         }
  401.       }
  402.     }
  403.   }
  404.   ["__Core_Object_T_Signal_results":protected]=>
  405.   array(1) {
  406.     ["propertySet"]=>
  407.     array(1) {
  408.       ["ILLI\Core\Object\I_Signal::T_SIGNAL_EMIT_EVENT_INIT"]=>
  409.       array(3) {
  410.         [499]=>
  411.         array(2) {
  412.           ["param1"]=>
  413.           string(6) "scheme"
  414.           ["param2"]=>
  415.           string(4) "http"
  416.         }
  417.         [500]=>
  418.         string(4) "http"
  419.         [501]=>
  420.         array(2) {
  421.           ["__property"]=>
  422.           string(6) "scheme"
  423.           ["__value"]=>
  424.           string(4) "http"
  425.         }
  426.       }
  427.     }
  428.   }
  429.   ["__Core_Object_T_To_registry":protected]=>
  430.   array(9) {
  431.     ["string"]=>
  432.     array(2) {
  433.       [0]=>
  434.       *RECURSION*
  435.       [1]=>
  436.       string(8) "toString"
  437.     }
  438.     ["array"]=>
  439.     array(2) {
  440.       [0]=>
  441.       *RECURSION*
  442.       [1]=>
  443.       string(7) "toArray"
  444.     }
  445.     ["body"]=>
  446.     array(2) {
  447.       [0]=>
  448.       *RECURSION*
  449.       [1]=>
  450.       string(6) "toBody"
  451.     }
  452.     ["context"]=>
  453.     array(2) {
  454.       [0]=>
  455.       *RECURSION*
  456.       [1]=>
  457.       string(9) "toContext"
  458.     }
  459.     ["hostAndDefaultPort"]=>
  460.     array(2) {
  461.       [0]=>
  462.       *RECURSION*
  463.       [1]=>
  464.       string(20) "toHostAndDefaultPort"
  465.     }
  466.     ["hostAndPort"]=>
  467.     array(2) {
  468.       [0]=>
  469.       *RECURSION*
  470.       [1]=>
  471.       string(13) "toHostAndPort"
  472.     }
  473.     ["uri"]=>
  474.     array(2) {
  475.       [0]=>
  476.       *RECURSION*
  477.       [1]=>
  478.       string(5) "toUri"
  479.     }
  480.     ["url"]=>
  481.     array(2) {
  482.       [0]=>
  483.       *RECURSION*
  484.       [1]=>
  485.       string(5) "toUrl"
  486.     }
  487.     ["port"]=>
  488.     array(2) {
  489.       [0]=>
  490.       *RECURSION*
  491.       [1]=>
  492.       string(6) "toPort"
  493.     }
  494.   }
  495. }
  496. object(root\bar)#6 (19) {
  497.   ["scheme":protected]=>
  498.   string(4) "http"
  499.   ["host":protected]=>
  500.   string(9) "localhost"
  501.   ["port":protected]=>
  502.   NULL
  503.   ["username":protected]=>
  504.   NULL
  505.   ["password":protected]=>
  506.   NULL
  507.   ["path":protected]=>
  508.   NULL
  509.   ["body":protected]=>
  510.   array(0) {
  511.   }
  512.   ["__initConfig":protected]=>
  513.   array(17) {
  514.     ["ILLI\Core\Object\I_Object::DEF_RUN"]=>
  515.     bool(true)
  516.     ["ILLI\Core\Object\I_Object::DEF_MAIN"]=>
  517.     string(6) "__main"
  518.     ["ILLI\Core\Object\I_Object::DEF_CLASS"]=>
  519.     array(0) {
  520.     }
  521.     ["ILLI\Core\Object\I_Object::DEF_DELEGATE"]=>
  522.     array(0) {
  523.     }
  524.     ["ILLI\Core\Object\I_Object::DEF_FILTER"]=>
  525.     array(0) {
  526.     }
  527.     ["ILLI\Core\Object\I_Object::DEF_METHOD"]=>
  528.     array(0) {
  529.     }
  530.     ["ILLI\Core\Object\I_Object::DEF_OBSERVER"]=>
  531.     array(0) {
  532.     }
  533.     ["ILLI\Core\Object\I_Object::DEF_METHOD_PROTO"]=>
  534.     array(0) {
  535.     }
  536.     ["ILLI\Core\Object\I_Object::DEF_SIGNAL"]=>
  537.     array(0) {
  538.     }
  539.     ["ILLI\Core\Object\I_Object::DEF_TO"]=>
  540.     array(9) {
  541.       ["string"]=>
  542.       string(8) "toString"
  543.       ["array"]=>
  544.       string(7) "toArray"
  545.       ["body"]=>
  546.       string(6) "toBody"
  547.       ["context"]=>
  548.       string(9) "toContext"
  549.       ["hostAndDefaultPort"]=>
  550.       string(20) "toHostAndDefaultPort"
  551.       ["hostAndPort"]=>
  552.       string(13) "toHostAndPort"
  553.       ["uri"]=>
  554.       string(5) "toUri"
  555.       ["url"]=>
  556.       string(5) "toUrl"
  557.       ["port"]=>
  558.       string(6) "toPort"
  559.     }
  560.     ["scheme"]=>
  561.     string(3) "tcp"
  562.     ["host"]=>
  563.     string(9) "localhost"
  564.     ["port"]=>
  565.     NULL
  566.     ["path"]=>
  567.     NULL
  568.     ["username"]=>
  569.     NULL
  570.     ["password"]=>
  571.     NULL
  572.     ["body"]=>
  573.     array(0) {
  574.     }
  575.   }
  576.   ["__export"]=>
  577.   array(0) {
  578.   }
  579.   ["__Core_Object_T_Class_registry":protected]=>
  580.   array(0) {
  581.   }
  582.   ["__Core_Object_T_Delegate_registry":protected]=>
  583.   array(0) {
  584.   }
  585.   ["__Core_Object_T_Filter_registry":protected]=>
  586.   array(0) {
  587.   }
  588.   ["__Core_Object_T_Method_registry":protected]=>
  589.   array(0) {
  590.   }
  591.   ["__Core_Object_T_MethodFacade_registry":protected]=>
  592.   array(0) {
  593.   }
  594.   ["__Core_Object_T_MethodProto_registry":protected]=>
  595.   array(0) {
  596.   }
  597.   ["__Core_Object_T_Observer_registry":protected]=>
  598.   array(0) {
  599.   }
  600.   ["__Core_Object_T_Signal_registry":protected]=>
  601.   array(0) {
  602.   }
  603.   ["__Core_Object_T_Signal_results":protected]=>
  604.   array(0) {
  605.   }
  606.   ["__Core_Object_T_To_registry":protected]=>
  607.   array(9) {
  608.     ["string"]=>
  609.     array(2) {
  610.       [0]=>
  611.       *RECURSION*
  612.       [1]=>
  613.       string(8) "toString"
  614.     }
  615.     ["array"]=>
  616.     array(2) {
  617.       [0]=>
  618.       *RECURSION*
  619.       [1]=>
  620.       string(7) "toArray"
  621.     }
  622.     ["body"]=>
  623.     array(2) {
  624.       [0]=>
  625.       *RECURSION*
  626.       [1]=>
  627.       string(6) "toBody"
  628.     }
  629.     ["context"]=>
  630.     array(2) {
  631.       [0]=>
  632.       *RECURSION*
  633.       [1]=>
  634.       string(9) "toContext"
  635.     }
  636.     ["hostAndDefaultPort"]=>
  637.     array(2) {
  638.       [0]=>
  639.       *RECURSION*
  640.       [1]=>
  641.       string(20) "toHostAndDefaultPort"
  642.     }
  643.     ["hostAndPort"]=>
  644.     array(2) {
  645.       [0]=>
  646.       *RECURSION*
  647.       [1]=>
  648.       string(13) "toHostAndPort"
  649.     }
  650.     ["uri"]=>
  651.     array(2) {
  652.       [0]=>
  653.       *RECURSION*
  654.       [1]=>
  655.       string(5) "toUri"
  656.     }
  657.     ["url"]=>
  658.     array(2) {
  659.       [0]=>
  660.       *RECURSION*
  661.       [1]=>
  662.       string(5) "toUrl"
  663.     }
  664.     ["port"]=>
  665.     array(2) {
  666.       [0]=>
  667.       *RECURSION*
  668.       [1]=>
  669.       string(6) "toPort"
  670.     }
  671.   }
  672. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement