3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Produto { public function getNome(): string; public function setValor(float $valor); } class SmartphoneImportado implements Produto { private float $valor; public function getNome(): string { return "Smartphone Importado XPTO"; } public function setValor(float $valor) { $this->valor = $valor; } } abstract class ProdutoFactory { public abstract function criarProduto(): Produto; public function get(): Produto { return $this->criarProduto(); } } class SmartphoneImportadoFactory extends ProdutoFactory { private const URI_API = 'https://api.exchangeratesapi.io/latest?base=USD&symbols=BRL'; public function criarProduto(): \Produto { $cotacao_json = json_decode(file_get_contents(self::URI_API)); $cotacao = $cotacao_json->rates->BRL; $produto = new SmartphoneImportado(); $produto->setValor($cotacao * 100); return $produto; } } $factory = new SmartphoneImportadoFactory(); $produto = $factory->criarProduto(); var_dump($produto);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZcOmX
function name:  (null)
number of ops:  11
compiled vars:  !0 = $factory, !1 = $produto
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'smartphoneimportado'
   43     1        NEW                                              $2      'SmartphoneImportadoFactory'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   44     4        INIT_METHOD_CALL                                         !0, 'criarProduto'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   45     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

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

End of function getnome

Function setvalor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZcOmX
function name:  setValor
number of ops:  2
compiled vars:  !0 = $valor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function setvalor

End of class Produto.

Class SmartphoneImportado:
Function getnome:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZcOmX
function name:  getNome
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'Smartphone+Importado+XPTO'
   13     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function getnome

Function setvalor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZcOmX
function name:  setValor
number of ops:  4
compiled vars:  !0 = $valor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ                                               'valor'
          2        OP_DATA                                                  !0
   17     3      > RETURN                                                   null

End of function setvalor

End of class SmartphoneImportado.

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

End of function criarproduto

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

End of function get

End of class ProdutoFactory.

Class SmartphoneImportadoFactory:
Function criarproduto:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZcOmX
function name:  criarProduto
number of ops:  21
compiled vars:  !0 = $cotacao_json, !1 = $cotacao, !2 = $produto
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'json_decode'
          1        INIT_FCALL                                               'file_get_contents'
          2        SEND_VAL                                                 'https%3A%2F%2Fapi.exchangeratesapi.io%2Flatest%3Fbase%3DUSD%26symbols%3DBRL'
          3        DO_ICALL                                         $3      
          4        SEND_VAR                                                 $3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !0, $4
   34     7        FETCH_OBJ_R                                      ~6      !0, 'rates'
          8        FETCH_OBJ_R                                      ~7      ~6, 'BRL'
          9        ASSIGN                                                   !1, ~7
   36    10        NEW                                              $9      'SmartphoneImportado'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !2, $9
   37    13        INIT_METHOD_CALL                                         !2, 'setValor'
         14        MUL                                              ~12     !1, 100
         15        SEND_VAL_EX                                              ~12
         16        DO_FCALL                                      0          
   39    17        VERIFY_RETURN_TYPE                                       !2
         18      > RETURN                                                   !2
   40    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function criarproduto

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

End of function get

End of class SmartphoneImportadoFactory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.17 ms | 1404 KiB | 19 Q