3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Cookpedia; class Entry { private $hydrated = false; private $data = [ 'id' => 0, 'title' => null, 'latin_title' => null, 'category' => 0, 'calories' => 0, 'proteins' => 0, 'fats' => 0, 'carbohydrates' => 0, 'description' => null, 'tags' => null, 'measures' => [], ]; public function hydrate(PDO $dbh, int $id): void { $stmt = $dbh->prepare("SELECT `title`, `latin_title`, `category`, `calories`, `proteins`, `fats`, `carbohydrates`, `description`, `measures`, `tags` FROM `cook_encyclopedia_entries` WHERE `id`=:id"); $result = $stmt->execute($id); $this->data = $result->fetch(PDO::FETCH_ASSOC); $this->data['measures'] = $this->computeMeasures($this->data['measures']); $this->hydrated = true; } public function getData(): array { if (!$this->hydrated) { throw new \Exception('hydrate first'); } return $this->data; } private function computeMeasures(string $measures): array { $measureArray = explode('|', $measures); return [ 'g_in_tsp' => $measureArray[0], 'g_in_tbsp' => $measureArray[1], 'g_in_glass' => $measureArray[2], 'g_in_cup' => $measureArray[3], ]; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rQ3oV
function name:  (null)
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  52     0  E > > RETURN                                                   1

Class Cookpedia\Entry:
Function hydrate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rQ3oV
function name:  hydrate
number of ops:  28
compiled vars:  !0 = $dbh, !1 = $id, !2 = $stmt, !3 = $result
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  22     0  E >   RECV                                             !0      
         1        RECV                                             !1      
  24     2        INIT_METHOD_CALL                                         !0, 'prepare'
         3        SEND_VAL_EX                                              'SELECT+%60title%60%2C+%60latin_title%60%2C+%60category%60%2C+%60calories%60%2C+%60proteins%60%2C+%60fats%60%2C+%60carbohydrates%60%2C+%60description%60%2C+%60measures%60%2C+%60tags%60+FROM+%60cook_encyclopedia_entries%60+WHERE+%60id%60%3D%3Aid'
         4        DO_FCALL                                      0  $4      
         5        ASSIGN                                                   !2, $4
  25     6        INIT_METHOD_CALL                                         !2, 'execute'
         7        SEND_VAR_EX                                              !1
         8        DO_FCALL                                      0  $6      
         9        ASSIGN                                                   !3, $6
  27    10        INIT_METHOD_CALL                                         !3, 'fetch'
        11        FETCH_CLASS_CONSTANT                             ~9      'Cookpedia%5CPDO', 'FETCH_ASSOC'
        12        SEND_VAL_EX                                              ~9
        13        DO_FCALL                                      0  $10     
        14        ASSIGN_OBJ                                               'data'
        15        OP_DATA                                                  $10
  28    16        INIT_METHOD_CALL                                         'computeMeasures'
        17        CHECK_FUNC_ARG                                           
        18        FETCH_OBJ_FUNC_ARG                               $13     'data'
        19        FETCH_DIM_FUNC_ARG                               $14     $13, 'measures'
        20        SEND_FUNC_ARG                                            $14
        21        DO_FCALL                                      0  $15     
        22        FETCH_OBJ_W                                      $11     'data'
        23        ASSIGN_DIM                                               $11, 'measures'
        24        OP_DATA                                                  $15
  29    25        ASSIGN_OBJ                                               'hydrated'
        26        OP_DATA                                                  <true>
  30    27      > RETURN                                                   null

End of function hydrate

Function getdata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rQ3oV
function name:  getData
number of ops:  12
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  34     0  E >   FETCH_OBJ_R                                      ~0      'hydrated'
         1        BOOL_XOR                                         ~1      ~0
         2      > JMPZ                                                     ~1, ->7
  35     3    >   NEW                                              $2      :14
         4        SEND_VAL_EX                                              'hydrate+first'
         5        DO_FCALL                                      0          
         6      > THROW                                         0          $2
  38     7    >   FETCH_OBJ_R                                      ~4      'data'
         8        VERIFY_RETURN_TYPE                                       ~4
         9      > RETURN                                                   ~4
  39    10*       VERIFY_RETURN_TYPE                                       
        11*     > RETURN                                                   null

End of function getdata

Function computemeasures:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rQ3oV
function name:  computeMeasures
number of ops:  18
compiled vars:  !0 = $measures, !1 = $measureArray
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  41     0  E >   RECV                                             !0      
  43     1        INIT_NS_FCALL_BY_NAME                                    'Cookpedia%5Cexplode'
         2        SEND_VAL_EX                                              '%7C'
         3        SEND_VAR_EX                                              !0
         4        DO_FCALL                                      0  $2      
         5        ASSIGN                                                   !1, $2
  46     6        FETCH_DIM_R                                      ~4      !1, 0
         7        INIT_ARRAY                                       ~5      ~4, 'g_in_tsp'
  47     8        FETCH_DIM_R                                      ~6      !1, 1
         9        ADD_ARRAY_ELEMENT                                ~5      ~6, 'g_in_tbsp'
  48    10        FETCH_DIM_R                                      ~7      !1, 2
        11        ADD_ARRAY_ELEMENT                                ~5      ~7, 'g_in_glass'
  49    12        FETCH_DIM_R                                      ~8      !1, 3
        13        ADD_ARRAY_ELEMENT                                ~5      ~8, 'g_in_cup'
        14        VERIFY_RETURN_TYPE                                       ~5
        15      > RETURN                                                   ~5
  51    16*       VERIFY_RETURN_TYPE                                       
        17*     > RETURN                                                   null

End of function computemeasures

End of class Cookpedia\Entry.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
14.51 ms | 416 KiB | 7 Q