3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface MoneyFormatter { public function format($value, $decimals = 0, $decimalPoint = '.', $thousandsSeparator = ','); } class GDPMoneyFormatter implements MoneyFormatter { public function format($value, $decimals = 0, $decimalPoint = '.', $thousandsSeparator = ',') { return sprintf('$%s', number_format($number, $decimals, $decPoint, $thousandsSep)); } } class WeirdMoneyFormatter implements MoneyFormatter { public function format($value, $decimals = 0, $decimalPoint = '.', $thousandsSeparator = ',') { return sprintf('$%s', number_format($number, $decimals, $decPoint, $thousandsSep)); } } abstract class MoneyFormatterExtension { protected $formatter; public function __construct(MoneyFormatter $formatter) { $this->formatter = $formatter; } public function getFilters() { return array( new \Twig_SimpleFilter($this->getFilterName(), array($this->formatter, 'format')), ); } public function getName() { return sprintf('%s_money_formatter_extension', $this->getFilterName()); } abstract protected function getFilterName(); } class WeirdFormatterExtension extends MoneyFormatterExtension { public function __construct(WeirdMoneyFormatter $formatter) { parent::__construct($formatter); } protected function getFilterName() { return 'weird'; } } class GDPFormatterExtension extends MoneyFormatterExtension { public function __construct(GDPMoneyFormatter $formatter) { parent::__construct($formatter); } protected function getFilterName() { return 'gdp'; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'gdpmoneyformatter'
   16     1        DECLARE_CLASS                                            'weirdmoneyformatter'
   72     2      > RETURN                                                   1

Class MoneyFormatter:
Function format:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  format
number of ops:  5
compiled vars:  !0 = $value, !1 = $decimals, !2 = $decimalPoint, !3 = $thousandsSeparator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      '.'
          3        RECV_INIT                                        !3      '%2C'
          4      > RETURN                                                   null

End of function format

End of class MoneyFormatter.

Class GDPMoneyFormatter:
Function format:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  format
number of ops:  16
compiled vars:  !0 = $value, !1 = $decimals, !2 = $decimalPoint, !3 = $thousandsSeparator, !4 = $number, !5 = $decPoint, !6 = $thousandsSep
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      '.'
          3        RECV_INIT                                        !3      '%2C'
   12     4        INIT_FCALL                                               'sprintf'
          5        SEND_VAL                                                 '%24%25s'
          6        INIT_FCALL                                               'number_format'
          7        SEND_VAR                                                 !4
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !5
         10        SEND_VAR                                                 !6
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                         $8      
         14      > RETURN                                                   $8
   13    15*     > RETURN                                                   null

End of function format

End of class GDPMoneyFormatter.

Class WeirdMoneyFormatter:
Function format:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  format
number of ops:  16
compiled vars:  !0 = $value, !1 = $decimals, !2 = $decimalPoint, !3 = $thousandsSeparator, !4 = $number, !5 = $decPoint, !6 = $thousandsSep
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      0
          2        RECV_INIT                                        !2      '.'
          3        RECV_INIT                                        !3      '%2C'
   20     4        INIT_FCALL                                               'sprintf'
          5        SEND_VAL                                                 '%24%25s'
          6        INIT_FCALL                                               'number_format'
          7        SEND_VAR                                                 !4
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !5
         10        SEND_VAR                                                 !6
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                         $8      
         14      > RETURN                                                   $8
   21    15*     > RETURN                                                   null

End of function format

End of class WeirdMoneyFormatter.

Class MoneyFormatterExtension:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  __construct
number of ops:  4
compiled vars:  !0 = $formatter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        ASSIGN_OBJ                                               'formatter'
          2        OP_DATA                                                  !0
   31     3      > RETURN                                                   null

End of function __construct

Function getfilters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilters
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $0      'Twig_SimpleFilter'
          1        INIT_METHOD_CALL                                         'getFilterName'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        FETCH_OBJ_R                                      ~2      'formatter'
          5        INIT_ARRAY                                       ~3      ~2
          6        ADD_ARRAY_ELEMENT                                ~3      'format'
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~5      $0
         10      > RETURN                                                   ~5
   38    11*     > RETURN                                                   null

End of function getfilters

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getName
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'sprintf'
          1        SEND_VAL                                                 '%25s_money_formatter_extension'
          2        INIT_METHOD_CALL                                         'getFilterName'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   43     7*     > RETURN                                                   null

End of function getname

Function getfiltername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilterName
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E > > RETURN                                                   null

End of function getfiltername

End of class MoneyFormatterExtension.

Class WeirdFormatterExtension:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  __construct
number of ops:  5
compiled vars:  !0 = $formatter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
   52     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   53     4      > RETURN                                                   null

End of function __construct

Function getfiltername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilterName
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E > > RETURN                                                   'weird'
   58     1*     > RETURN                                                   null

End of function getfiltername

Function getfilters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilters
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $0      'Twig_SimpleFilter'
          1        INIT_METHOD_CALL                                         'getFilterName'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        FETCH_OBJ_R                                      ~2      'formatter'
          5        INIT_ARRAY                                       ~3      ~2
          6        ADD_ARRAY_ELEMENT                                ~3      'format'
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~5      $0
         10      > RETURN                                                   ~5
   38    11*     > RETURN                                                   null

End of function getfilters

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getName
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'sprintf'
          1        SEND_VAL                                                 '%25s_money_formatter_extension'
          2        INIT_METHOD_CALL                                         'getFilterName'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   43     7*     > RETURN                                                   null

End of function getname

End of class WeirdFormatterExtension.

Class GDPFormatterExtension:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  __construct
number of ops:  5
compiled vars:  !0 = $formatter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV                                             !0      
   65     1        INIT_STATIC_METHOD_CALL                                  
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   66     4      > RETURN                                                   null

End of function __construct

Function getfiltername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilterName
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E > > RETURN                                                   'gdp'
   71     1*     > RETURN                                                   null

End of function getfiltername

Function getfilters:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getFilters
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $0      'Twig_SimpleFilter'
          1        INIT_METHOD_CALL                                         'getFilterName'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR_NO_REF_EX                                       $1
          4        FETCH_OBJ_R                                      ~2      'formatter'
          5        INIT_ARRAY                                       ~3      ~2
          6        ADD_ARRAY_ELEMENT                                ~3      'format'
          7        SEND_VAL_EX                                              ~3
          8        DO_FCALL                                      0          
          9        INIT_ARRAY                                       ~5      $0
         10      > RETURN                                                   ~5
   38    11*     > RETURN                                                   null

End of function getfilters

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/COWQp
function name:  getName
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_FCALL                                               'sprintf'
          1        SEND_VAL                                                 '%25s_money_formatter_extension'
          2        INIT_METHOD_CALL                                         'getFilterName'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                         $1      
          6      > RETURN                                                   $1
   43     7*     > RETURN                                                   null

End of function getname

End of class GDPFormatterExtension.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.81 ms | 1416 KiB | 17 Q