TheCelavi

Aop idea

Feb 23rd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. $example = new Original();
  4.  
  5. // autoloading kick in to load this class...
  6.  
  7. class Original {
  8.    
  9. }
  10.  
  11. // Intercept composer autoloading, use roave/better-reflection, generate proxy
  12.  
  13. class Original__AopProxy extends Original {  
  14.  
  15.     private $original;
  16.  
  17.     public function __construct()
  18.     {
  19.         uopz_unset_mock(Original::class, self::class);
  20.         $this->original = new Original();
  21.         uopz_set_mock(Original::class, self::class);
  22.     }
  23. }
  24.  
  25. // now, load Original and Original__AopProxy
  26. // and bind what has to binded
  27. uopz_set_mock(Original::class, self::class);
  28.  
  29. // proceed with our first line of code, classes are loaded.
  30. $example = new Original();
Advertisement
Add Comment
Please, Sign In to add comment