3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait SerializationHelper { /** * @deprecated Use serializeToArray * * @return string */ public function serialize() { return serialize($this->serializeToArray()); } /** * @deprecated Use unserializeFromArray * * @param string $str * * @return void */ public function unserialize($str) { $this->unserializeFromArray(unserialize($str)); } public function __serialize(): array { return [$this->serialize()]; } public function __unserialize(array $data): void { $this->unserialize($data[0]); } } class ClassMetadata implements \Serializable { use SerializationHelper; /** * @var array */ private $indexMetadatas = []; public function addIndexMetadata($contextName, IndexMetadata $indexMetadata) { $indexMetadata->setClassMetadata($this); $this->indexMetadatas[$contextName] = $indexMetadata; } public function serializeToArray(): array { return [$this->indexMetadatas,]; } public function unserializeFromArray(array $data): void { list($indexMetadata) = $data; $this->indexMetadatas = $indexMetadata; } } class IndexMetadata { /** * @var ClassMetadata */ private $classMetadata; public function getClassMetadata() { return $this->classMetadata; } public function setClassMetadata(ClassMetadata $classMetadata) { $this->classMetadata = $classMetadata; } } $classMetadata = new ClassMetadata(); $indexMetadata = new IndexMetadata(); $classMetadata->addIndexMetadata('test', $indexMetadata); var_dump(serialize($classMetadata));

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  (null)
number of ops:  18
compiled vars:  !0 = $classMetadata, !1 = $indexMetadata
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   38     0  E >   DECLARE_CLASS                                                'classmetadata'
   85     1        NEW                                                  $2      'ClassMetadata'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   86     4        NEW                                                  $5      'IndexMetadata'
          5        DO_FCALL                                          0          
          6        ASSIGN                                                       !1, $5
   88     7        INIT_METHOD_CALL                                             !0, 'addIndexMetadata'
          8        SEND_VAL_EX                                                  'test'
          9        SEND_VAR_EX                                                  !1
         10        DO_FCALL                                          0          
   90    11        INIT_FCALL                                                   'var_dump'
         12        INIT_FCALL                                                   'serialize'
         13        SEND_VAR                                                     !0
         14        DO_ICALL                                             $9      
         15        SEND_VAR                                                     $9
         16        DO_ICALL                                                     
         17      > RETURN                                                       1

Class SerializationHelper:
Function serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                                   'serialize'
          1        INIT_METHOD_CALL                                             'serializeToArray'
          2        DO_FCALL                                          0  $0      
          3        SEND_VAR                                                     $0
          4        DO_ICALL                                             $1      
          5      > RETURN                                                       $1
   13     6*     > RETURN                                                       null

End of function serialize

Function unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  unserialize
number of ops:  8
compiled vars:  !0 = $str
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   24     1        INIT_METHOD_CALL                                             'unserializeFromArray'
          2        INIT_FCALL                                                   'unserialize'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $1      
          5        SEND_VAR_NO_REF_EX                                           $1
          6        DO_FCALL                                          0          
   25     7      > RETURN                                                       null

End of function unserialize

Function __serialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  __serialize
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   29     0  E >   INIT_METHOD_CALL                                             'serialize'
          1        DO_FCALL                                          0  $0      
          2        INIT_ARRAY                                           ~1      $0
          3        VERIFY_RETURN_TYPE                                           ~1
          4      > RETURN                                                       ~1
   30     5*       VERIFY_RETURN_TYPE                                           
          6*     > RETURN                                                       null

End of function __serialize

Function __unserialize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  __unserialize
number of ops:  7
compiled vars:  !0 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   RECV                                                 !0      
   34     1        INIT_METHOD_CALL                                             'unserialize'
          2        CHECK_FUNC_ARG                                               
          3        FETCH_DIM_FUNC_ARG                                   $1      !0, 0
          4        SEND_FUNC_ARG                                                $1
          5        DO_FCALL                                          0          
   35     6      > RETURN                                                       null

End of function __unserialize

End of class SerializationHelper.

Class ClassMetadata:
Function addindexmetadata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  addIndexMetadata
number of ops:  10
compiled vars:  !0 = $contextName, !1 = $indexMetadata
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   50     2        INIT_METHOD_CALL                                             !1, 'setClassMetadata'
          3        FETCH_THIS                                           $2      
          4        SEND_VAR_EX                                                  $2
          5        DO_FCALL                                          0          
   51     6        FETCH_OBJ_W                                          $4      'indexMetadatas'
          7        ASSIGN_DIM                                                   $4, !0
          8        OP_DATA                                                      !1
   52     9      > RETURN                                                       null

End of function addindexmetadata

Function serializetoarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  serializeToArray
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   56     0  E >   FETCH_OBJ_R                                          ~0      'indexMetadatas'
          1        INIT_ARRAY                                           ~1      ~0
          2        VERIFY_RETURN_TYPE                                           ~1
          3      > RETURN                                                       ~1
   57     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function serializetoarray

Function unserializefromarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  unserializeFromArray
number of ops:  8
compiled vars:  !0 = $data, !1 = $indexMetadata
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   59     0  E >   RECV                                                 !0      
   61     1        QM_ASSIGN                                            ~2      !0
          2        FETCH_LIST_R                                         $3      ~2, 0
          3        ASSIGN                                                       !1, $3
          4        FREE                                                         ~2
   62     5        ASSIGN_OBJ                                                   'indexMetadatas'
          6        OP_DATA                                                      !1
   63     7      > RETURN                                                       null

End of function unserializefromarray

End of class ClassMetadata.

Class IndexMetadata:
Function getclassmetadata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  getClassMetadata
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   76     0  E >   FETCH_OBJ_R                                          ~0      'classMetadata'
          1      > RETURN                                                       ~0
   77     2*     > RETURN                                                       null

End of function getclassmetadata

Function setclassmetadata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/40nda
function name:  setClassMetadata
number of ops:  4
compiled vars:  !0 = $classMetadata
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   79     0  E >   RECV                                                 !0      
   81     1        ASSIGN_OBJ                                                   'classMetadata'
          2        OP_DATA                                                      !0
   82     3      > RETURN                                                       null

End of function setclassmetadata

End of class IndexMetadata.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.56 ms | 3765 KiB | 16 Q