3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* Challenge 1: Modify Test::$secret before it's output. Rules:: 1. No use of Reflection API / runkit extension 2. No stopping execution before Test::run() 3. No Exceptions or PHP errors / warnings notices allowed Hints: 1. Caesar 2. Magic methods 3. Requires a new feature of PHP 5.4 */ class Test { private $secret = 'Nyy lbhe Onfr ner orybat gb hf.'; private $callback; final public function run() { call_user_func($this->callback); return $this->secret . PHP_EOL; } public function __set($k, $v) { $key = $v[($v[$v])]; // $v is some kind of weird array $value = $v(); // and a callback! $this->{$key} = $value; } } $test = new Test; // start editing here //Instantiate the reflection object $reflector = new ReflectionClass('Test'); //Now get all the properties from class A in to $properties array $properties = $reflector->getProperties(); $i =1; //Now go through the $properties array and populate each property foreach($properties as $property) { //Populating properties $a->{$property->getName()}=$i; //Invoking the method to print what was populated $a->{"echo".ucfirst($property->getName())}()."\n"; $i++; } // end editing here echo $test->run();
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/uBFNA
function name:  (null)
number of ops:  34
compiled vars:  !0 = $test, !1 = $reflector, !2 = $properties, !3 = $i, !4 = $property, !5 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   NEW                                              $6      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $6
   46     3        NEW                                              $9      'ReflectionClass'
          4        SEND_VAL_EX                                              'Test'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $9
   49     7        INIT_METHOD_CALL                                         !1, 'getProperties'
          8        DO_FCALL                                      0  $12     
          9        ASSIGN                                                   !2, $12
   51    10        ASSIGN                                                   !3, 1
   53    11      > FE_RESET_R                                       $15     !2, ->29
         12    > > FE_FETCH_R                                               $15, !4, ->29
   56    13    >   INIT_METHOD_CALL                                         !4, 'getName'
         14        DO_FCALL                                      0  $16     
         15        ASSIGN_OBJ                                               !5, $16
         16        OP_DATA                                                  !3
   58    17        INIT_FCALL                                               'ucfirst'
         18        INIT_METHOD_CALL                                         !4, 'getName'
         19        DO_FCALL                                      0  $18     
         20        SEND_VAR                                                 $18
         21        DO_ICALL                                         $19     
         22        CONCAT                                           ~20     'echo', $19
         23        INIT_METHOD_CALL                                         !5, ~20
         24        DO_FCALL                                      0  $21     
         25        CONCAT                                           ~22     $21, '%0A'
         26        FREE                                                     ~22
   60    27        PRE_INC                                                  !3
   53    28      > JMP                                                      ->12
         29    >   FE_FREE                                                  $15
   65    30        INIT_METHOD_CALL                                         !0, 'run'
         31        DO_FCALL                                      0  $24     
         32        ECHO                                                     $24
         33      > RETURN                                                   1

Class Test:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uBFNA
function name:  run
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   FETCH_OBJ_R                                      ~0      'callback'
          1        INIT_USER_CALL                                0          'call_user_func', ~0
          2        DO_FCALL                                      0          
   28     3        FETCH_OBJ_R                                      ~2      'secret'
          4        CONCAT                                           ~3      ~2, '%0A'
          5      > RETURN                                                   ~3
   29     6*     > RETURN                                                   null

End of function run

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uBFNA
function name:  __set
number of ops:  11
compiled vars:  !0 = $k, !1 = $v, !2 = $key, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   33     2        FETCH_DIM_R                                      ~4      !1, !1
          3        FETCH_DIM_R                                      ~5      !1, ~4
          4        ASSIGN                                                   !2, ~5
   34     5        INIT_DYNAMIC_CALL                                        !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !3, $7
   35     8        ASSIGN_OBJ                                               !2
          9        OP_DATA                                                  !3
   36    10      > RETURN                                                   null

End of function __set

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.8 ms | 1400 KiB | 15 Q