3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); /** * ========================================================================== * SISTEMA BANCÁRIO FUNCIONAL COM IDEMPOTÊNCIA EM PHP MODERN * ========================================================================== * * Conceitos aplicados do Mapa Mental: * 1. Pure Functions * 2. Higher-Order Functions (array_reduce, array_walk) * 3. Immutability (Readonly DTOs) * 4. Function Composition * 5. Currying * 6. Lazy Evaluation with Generators (yield) * 7. Pattern Matching (match) */ /** * -------------------------------------------------------------------------- * 1. IMUTABILIDADE (Readonly DTOs) * -------------------------------------------------------------------------- * As estruturas de dados são imutáveis. Alterações geram novas instâncias. */ readonly class Conta { public function __construct( public string $id, public float $saldo ) {} } readonly class Transacao { public function __construct( public string $idempotencyKey, public string $tipo, // 'DEPOSITO' ou 'SAQUE' public float $valor, public string $contaId ) {} } /** * -------------------------------------------------------------------------- * 2. PURE FUNCTIONS (Funções Puras) * -------------------------------------------------------------------------- * Sem efeitos colaterais. Entrada idêntica = Nova saída idêntica. */ function depositar(Conta $conta, float $valor): Conta { return new Conta($conta->id, $conta->saldo + $valor); } function sacar(Conta $conta, float $valor): Conta { if ($valor > $conta->saldo) { throw new InvalidArgumentException("Saldo insuficiente na conta {$conta->id}!"); } return new Conta($conta->id, $conta->saldo - $valor); } /** * -------------------------------------------------------------------------- * 3. PATTERN MATCHING (PHP 8 `match`) * -------------------------------------------------------------------------- * Avaliação declarativa de tipos de operação. */ function aplicarTransacao(Conta $conta, Transacao $tx): Conta { return match ($tx->tipo) { 'DEPOSITO' => depositar($conta, $tx->valor), 'SAQUE' => sacar($conta, $tx->valor), default => throw new InvalidArgumentException("Tipo de transação desconhecido: {$tx->tipo}") }; } /** * -------------------------------------------------------------------------- * 4. CURRYING * -------------------------------------------------------------------------- * Decompõe funções de múltiplos argumentos para pré-configuração. */ function criarValidadorValorMinimo(float $valorMinimo): callable { return fn(float $valor) => fn(callable $operacao) => $valor < $valorMinimo ? throw new InvalidArgumentException("Valor mínimo deve ser R$ {$valorMinimo}") : $operacao(); } /** * -------------------------------------------------------------------------- * 5. FUNCTION COMPOSITION (Composição de Funções) * -------------------------------------------------------------------------- * Pipeline de execução encadeando funções puras. */ function compor(callable ...$funcoes): callable { return fn($input) => array_reduce( $funcoes, fn($acc, $fn) => $fn($acc), $input ); } /** * -------------------------------------------------------------------------- * 6. HIGHER-ORDER FUNCTIONS & IDEMPOTÊNCIA (`array_reduce`) * -------------------------------------------------------------------------- * Substitui o loop foreach imperativo por uma redução funcional que * acumula imutavelmente o estado de contas e chaves processadas. */ function processarComIdempotencia(array $contasIniciais, iterable $transacoes): array { $listaTransacoes = is_array($transacoes) ? $transacoes : iterator_to_array($transacoes); $estadoInicial = [ 'contas' => $contasIniciais, 'chaves' => [] ]; $estadoFinal = array_reduce( $listaTransacoes, function (array $estado, Transacao $tx): array { // Garantia de Idempotência if (in_array($tx->idempotencyKey, $estado['chaves'], true)) { echo "⚠️ [IDEMPOTÊNCIA] Transação {$tx->idempotencyKey} ignorada (já processada).\n"; return $estado; } $contaAtual = $estado['contas'][$tx->contaId] ?? new Conta($tx->contaId, 0.0); $novaConta = aplicarTransacao($contaAtual, $tx); echo "✅ Transação {$tx->tipo} de R$ {$tx->valor} na conta {$tx->contaId} concluída. Saldo atual: R$ {$novaConta->saldo}\n"; return [ 'contas' => array_merge($estado['contas'], [$tx->contaId => $novaConta]), 'chaves' => array_merge($estado['chaves'], [$tx->idempotencyKey]) ]; }, $estadoInicial ); return $estadoFinal['contas']; } /** * -------------------------------------------------------------------------- * 7. LAZY EVALUATION WITH GENERATORS (`yield`) * -------------------------------------------------------------------------- * Stream de transações consumido sob demanda com baixa pegada de memória. */ function gerarStreamTransacoes(): Generator { yield new Transacao('tx_key_001', 'DEPOSITO', 500.0, 'conta_A'); yield new Transacao('tx_key_002', 'SAQUE', 150.0, 'conta_A'); yield new Transacao('tx_key_001', 'DEPOSITO', 500.0, 'conta_A'); // Duplicada (Ignorada) yield new Transacao('tx_key_003', 'DEPOSITO', 1000.0, 'conta_B'); yield new Transacao('tx_key_002', 'SAQUE', 150.0, 'conta_A'); // Duplicada (Ignorada) } // ========================================================================== // EXECUÇÃO DO SCRIPT // ========================================================================== echo "=== INICIANDO SISTEMA BANCÁRIO FUNCIONAL ===\n\n"; // Estado inicial $contas = [ 'conta_A' => new Conta('conta_A', 0.0), 'conta_B' => new Conta('conta_B', 100.0), ]; // Teste de Currying + Composition $validarMinimo10 = criarValidadorValorMinimo(10.0); try { echo "--- Teste de Validação (Currying + Composition) ---\n"; $depositoValidado = $validarMinimo10(50.0)( fn() => depositar($contas['conta_A'], 50.0) ); echo "Depósito de R$ 50 validado! Novo saldo simulado da conta_A: R$ {$depositoValidado->saldo}\n\n"; } catch (Exception $e) { echo "Erro: " . $e->getMessage() . "\n\n"; } // Processamento funcional com Idempotência echo "--- Processando Stream com array_reduce (Idempotência & Generators) ---\n"; $contasFinais = processarComIdempotencia($contas, gerarStreamTransacoes()); // Exibição funcional declarativa usando a função nativa array_walk echo "\n--- SALDO FINAL DAS CONTAS ---\n"; array_walk($contasFinais, function (Conta $conta) { echo "Conta: {$conta->id} | Saldo Final: R$ {$conta->saldo}\n"; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 32
Branch analysis from position: 32
2 jumps found. (Code = 107) Position 1 = 33, Position 2 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  (null)
number of ops:  53
compiled vars:  !0 = $contas, !1 = $validarMinimo10, !2 = $depositoValidado, !3 = $e, !4 = $contasFinais
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  167     0  E >   ECHO                                                         '%3D%3D%3D+INICIANDO+SISTEMA+BANC%C3%81RIO+FUNCIONAL+%3D%3D%3D%0A%0A'
  171     1        NEW                                                  $5      'Conta'
          2        SEND_VAL_EX                                                  'conta_A'
          3        SEND_VAL_EX                                                  0
          4        DO_FCALL                                          0          
          5        INIT_ARRAY                                           ~7      $5, 'conta_A'
  172     6        NEW                                                  $8      'Conta'
          7        SEND_VAL_EX                                                  'conta_B'
          8        SEND_VAL_EX                                                  100
          9        DO_FCALL                                          0          
         10        ADD_ARRAY_ELEMENT                                    ~7      $8, 'conta_B'
  170    11        ASSIGN                                                       !0, ~7
  176    12        INIT_FCALL                                                   'criarvalidadorvalorminimo'
         13        SEND_VAL                                                     10
         14        DO_FCALL                                          0  $11     
         15        ASSIGN                                                       !1, $11
  179    16        ECHO                                                         '---+Teste+de+Valida%C3%A7%C3%A3o+%28Currying+%2B+Composition%29+---%0A'
  180    17        INIT_DYNAMIC_CALL                                            !1
         18        SEND_VAL_EX                                                  50
         19        DO_FCALL                                          0  $13     
         20        INIT_DYNAMIC_CALL                                            $13
  181    21        DECLARE_LAMBDA_FUNCTION                              ~14     [0]
         22        BIND_LEXICAL                                                 ~14, !0
  182    23        SEND_VAL_EX                                                  ~14
  180    24        DO_FCALL                                          0  $15     
         25        ASSIGN                                                       !2, $15
  183    26        ROPE_INIT                                         3  ~19     'Dep%C3%B3sito+de+R%24+50+validado%21+Novo+saldo+simulado+da+conta_A%3A+R%24+'
         27        FETCH_OBJ_R                                          ~17     !2, 'saldo'
         28        ROPE_ADD                                          1  ~19     ~19, ~17
         29        ROPE_END                                          2  ~18     ~19, '%0A%0A'
         30        ECHO                                                         ~18
         31      > JMP                                                          ->38
  184    32  E > > CATCH                                           last         'Exception'
  185    33    >   INIT_METHOD_CALL                                             !3, 'getMessage'
         34        DO_FCALL                                          0  $21     
         35        CONCAT                                               ~22     'Erro%3A+', $21
         36        CONCAT                                               ~23     ~22, '%0A%0A'
         37        ECHO                                                         ~23
  189    38    >   ECHO                                                         '---+Processando+Stream+com+array_reduce+%28Idempot%C3%AAncia+%26+Generators%29+---%0A'
  190    39        INIT_FCALL                                                   'processarcomidempotencia'
         40        SEND_VAR                                                     !0
         41        INIT_FCALL                                                   'gerarstreamtransacoes'
         42        DO_FCALL                                          0  $24     
         43        SEND_VAR                                                     $24
         44        DO_FCALL                                          0  $25     
         45        ASSIGN                                                       !4, $25
  193    46        ECHO                                                         '%0A---+SALDO+FINAL+DAS+CONTAS+---%0A'
  194    47        INIT_FCALL                                                   'array_walk'
         48        SEND_REF                                                     !4
         49        DECLARE_LAMBDA_FUNCTION                              ~27     [1]
  196    50        SEND_VAL                                                     ~27
  194    51        DO_ICALL                                                     
  196    52      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:/in/g3OlH:181}
number of ops:  8
compiled vars:  !0 = $contas
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  181     0  E >   BIND_STATIC                                                  !0
          1        INIT_FCALL                                                   'depositar'
          2        FETCH_DIM_R                                          ~1      !0, 'conta_A'
          3        SEND_VAL                                                     ~1
          4        SEND_VAL                                                     50
          5        DO_FCALL                                          0  $2      
          6      > RETURN                                                       $2
  182     7*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:/in/g3OlH:194}
number of ops:  10
compiled vars:  !0 = $conta
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  194     0  E >   RECV                                                 !0      
  195     1        ROPE_INIT                                         5  ~4      'Conta%3A+'
          2        FETCH_OBJ_R                                          ~1      !0, 'id'
          3        ROPE_ADD                                          1  ~4      ~4, ~1
          4        ROPE_ADD                                          2  ~4      ~4, '+%7C+Saldo+Final%3A+R%24+'
          5        FETCH_OBJ_R                                          ~2      !0, 'saldo'
          6        ROPE_ADD                                          3  ~4      ~4, ~2
          7        ROPE_END                                          4  ~3      ~4, '%0A'
          8        ECHO                                                         ~3
  196     9      > RETURN                                                       null

End of Dynamic Function 1

Function depositar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  depositar
number of ops:  14
compiled vars:  !0 = $conta, !1 = $valor
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   50     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   52     2        NEW                                                  $2      'Conta'
          3        CHECK_FUNC_ARG                                               
          4        FETCH_OBJ_FUNC_ARG                                   $3      !0, 'id'
          5        SEND_FUNC_ARG                                                $3
          6        FETCH_OBJ_R                                          ~4      !0, 'saldo'
          7        ADD                                                  ~5      ~4, !1
          8        SEND_VAL_EX                                                  ~5
          9        DO_FCALL                                          0          
         10        VERIFY_RETURN_TYPE                                           $2
         11      > RETURN                                                       $2
   53    12*       VERIFY_RETURN_TYPE                                           
         13*     > RETURN                                                       null

End of function depositar

Function sacar:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  sacar
number of ops:  25
compiled vars:  !0 = $conta, !1 = $valor
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   55     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   57     2        FETCH_OBJ_R                                          ~2      !0, 'saldo'
          3        IS_SMALLER                                                   ~2, !1
          4      > JMPZ                                                         ~3, ->13
   58     5    >   NEW                                                  $4      'InvalidArgumentException'
          6        ROPE_INIT                                         3  ~7      'Saldo+insuficiente+na+conta+'
          7        FETCH_OBJ_R                                          ~5      !0, 'id'
          8        ROPE_ADD                                          1  ~7      ~7, ~5
          9        ROPE_END                                          2  ~6      ~7, '%21'
         10        SEND_VAL_EX                                                  ~6
         11        DO_FCALL                                          0          
         12      > THROW                                             0          $4
   60    13    >   NEW                                                  $10     'Conta'
         14        CHECK_FUNC_ARG                                               
         15        FETCH_OBJ_FUNC_ARG                                   $11     !0, 'id'
         16        SEND_FUNC_ARG                                                $11
         17        FETCH_OBJ_R                                          ~12     !0, 'saldo'
         18        SUB                                                  ~13     ~12, !1
         19        SEND_VAL_EX                                                  ~13
         20        DO_FCALL                                          0          
         21        VERIFY_RETURN_TYPE                                           $10
         22      > RETURN                                                       $10
   61    23*       VERIFY_RETURN_TYPE                                           
         24*     > RETURN                                                       null

End of function sacar

Function aplicartransacao:
Finding entry points
Branch analysis from position: 0
3 jumps found. (Code = 195) Position 1 = 4, Position 2 = 11, Position 3 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 18
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/g3OlH
function name:  aplicarTransacao
number of ops:  32
compiled vars:  !0 = $conta, !1 = $tx
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   69     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   71     2        FETCH_OBJ_R                                          ~2      !1, 'tipo'
          3      > MATCH                                                        ~2, [ 'DEPOSITO':->4, 'SAQUE':->11, ], ->18
   72     4    >   INIT_FCALL                                                   'depositar'
          5        SEND_VAR                                                     !0
          6        FETCH_OBJ_R                                          ~4      !1, 'valor'
          7        SEND_VAL                                                     ~4
          8        DO_FCALL                                          0  $5      
          9        QM_ASSIGN                                            ~6      $5
         10      > JMP                                                          ->27
   73    11    >   INIT_FCALL                                                   'sacar'
         12        SEND_VAR                                                     !0
         13        FETCH_OBJ_R                                          ~7      !1, 'valor'
         14        SEND_VAL                                                     ~7
         15        DO_FCALL                                          0  $8      
         16        QM_ASSIGN                                            ~6      $8
         17      > JMP                                                          ->27
   74    18    >   NEW                                                  $9      'InvalidArgumentException'
         19        NOP                                                          
         20        FETCH_OBJ_R                                          ~10     !1, 'tipo'
         21        FAST_CONCAT                                          ~11     'Tipo+de+transa%C3%A7%C3%A3o+desconhecido%3A+', ~10
         22        SEND_VAL_EX                                                  ~11
         23        DO_FCALL                                          0          
         24      > THROW                                             1          $9
         25*       QM_ASSIGN                                            ~6      <true>
         26*       JMP                                                          ->27
         27    >   FREE                                                         ~2
         28        VERIFY_RETURN_TYPE                                           ~6
         29      > RETURN                                                       ~6
   76    30*       VERIFY_RETURN_TYPE                                           
         31*     > RETURN                                                       null

End of function aplicartransacao

Function criarvalidadorvalorminimo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  criarValidadorValorMinimo
number of ops:  8
compiled vars:  !0 = $valorMinimo, !1 = $operacao
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   84     0  E >   RECV                                                 !0      
   86     1        DECLARE_LAMBDA_FUNCTION                              ~2      [0]
          2        BIND_LEXICAL                                                 ~2, !0
          3        BIND_LEXICAL                                                 ~2, !1
   89     4        VERIFY_RETURN_TYPE                                           ~2
          5      > RETURN                                                       ~2
   90     6*       VERIFY_RETURN_TYPE                                           
          7*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:criarValidadorValorMinimo():86}
number of ops:  8
compiled vars:  !0 = $valor, !1 = $valorMinimo, !2 = $operacao
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   86     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
          3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          4        BIND_LEXICAL                                                 ~3, !0
          5        BIND_LEXICAL                                                 ~3, !1
   89     6      > RETURN                                                       ~3
          7*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:{closure:criarValidadorValorMinimo():86}:86}
number of ops:  18
compiled vars:  !0 = $operacao, !1 = $valor, !2 = $valorMinimo
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   86     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
   87     3        IS_SMALLER                                                   !1, !2
          4      > JMPZ                                                         ~3, ->13
   88     5    >   NEW                                                  $4      'InvalidArgumentException'
          6        NOP                                                          
          7        FAST_CONCAT                                          ~5      'Valor+m%C3%ADnimo+deve+ser+R%24+', !2
          8        SEND_VAL_EX                                                  ~5
          9        DO_FCALL                                          0          
         10      > THROW                                             1          $4
         11*       QM_ASSIGN                                            ~7      <true>
         12*       JMP                                                          ->16
   89    13    >   INIT_DYNAMIC_CALL                                            !0
         14        DO_FCALL                                          0  $8      
         15        QM_ASSIGN                                            ~7      $8
         16      > RETURN                                                       ~7
         17*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

End of function criarvalidadorvalorminimo

Function compor:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  compor
number of ops:  9
compiled vars:  !0 = $funcoes, !1 = $fn, !2 = $acc
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   98     0  E >   RECV_VARIADIC                                        !0      
  100     1        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
          2        BIND_LEXICAL                                                 ~3, !0
          3        BIND_LEXICAL                                                 ~3, !1
          4        BIND_LEXICAL                                                 ~3, !2
  104     5        VERIFY_RETURN_TYPE                                           ~3
          6      > RETURN                                                       ~3
  105     7*       VERIFY_RETURN_TYPE                                           
          8*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:compor():100}
number of ops:  12
compiled vars:  !0 = $input, !1 = $funcoes, !2 = $fn, !3 = $acc
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  100     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
          4        INIT_FCALL                                                   'array_reduce'
  101     5        SEND_VAR                                                     !1
  102     6        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
          7        SEND_VAL                                                     ~4
  103     8        SEND_VAR                                                     !0
  100     9        DO_ICALL                                             $5      
  103    10      > RETURN                                                       $5
  104    11*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:{closure:compor():100}:102}
number of ops:  7
compiled vars:  !0 = $acc, !1 = $fn
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  102     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        INIT_DYNAMIC_CALL                                            !1
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0  $2      
          5      > RETURN                                                       $2
          6*     > RETURN                                                       null

End of Dynamic Function 0

End of Dynamic Function 0

End of function compor

Function processarcomidempotencia:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  processarComIdempotencia
number of ops:  26
compiled vars:  !0 = $contasIniciais, !1 = $transacoes, !2 = $listaTransacoes, !3 = $estadoInicial, !4 = $estadoFinal
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  114     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  116     2        TYPE_CHECK                                      128          !1
          3      > JMPZ                                                         ~5, ->6
          4    >   QM_ASSIGN                                            ~6      !1
          5      > JMP                                                          ->10
          6    >   INIT_FCALL                                                   'iterator_to_array'
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                             $7      
          9        QM_ASSIGN                                            ~6      $7
         10    >   ASSIGN                                                       !2, ~6
  119    11        INIT_ARRAY                                           ~9      !0, 'contas'
         12        ADD_ARRAY_ELEMENT                                    ~9      <array>, 'chaves'
  118    13        ASSIGN                                                       !3, ~9
  123    14        INIT_FCALL                                                   'array_reduce'
  124    15        SEND_VAR                                                     !2
  125    16        DECLARE_LAMBDA_FUNCTION                              ~11     [0]
  141    17        SEND_VAL                                                     ~11
  142    18        SEND_VAR                                                     !3
  123    19        DO_ICALL                                             $12     
         20        ASSIGN                                                       !4, $12
  145    21        FETCH_DIM_R                                          ~14     !4, 'contas'
         22        VERIFY_RETURN_TYPE                                           ~14
         23      > RETURN                                                       ~14
  146    24*       VERIFY_RETURN_TYPE                                           
         25*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g3OlH
function name:  {closure:processarComIdempotencia():125}
number of ops:  65
compiled vars:  !0 = $estado, !1 = $tx, !2 = $contaAtual, !3 = $novaConta
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  125     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
  127     2        FETCH_OBJ_R                                          ~4      !1, 'idempotencyKey'
          3        FETCH_DIM_R                                          ~5      !0, 'chaves'
          4        FRAMELESS_ICALL_3                in_array            ~6      ~4, ~5
          5        OP_DATA                                                      <true>
          6      > JMPZ                                                         ~6, ->14
  128     7    >   ROPE_INIT                                         3  ~9      '%E2%9A%A0%EF%B8%8F+%5BIDEMPOT%C3%8ANCIA%5D+Transa%C3%A7%C3%A3o+'
          8        FETCH_OBJ_R                                          ~7      !1, 'idempotencyKey'
          9        ROPE_ADD                                          1  ~9      ~9, ~7
         10        ROPE_END                                          2  ~8      ~9, '+ignorada+%28j%C3%A1+processada%29.%0A'
         11        ECHO                                                         ~8
  129    12        VERIFY_RETURN_TYPE                                           !0
         13      > RETURN                                                       !0
  132    14    >   FETCH_OBJ_R                                          ~12     !1, 'contaId'
         15        FETCH_DIM_IS                                         ~11     !0, 'contas'
         16        FETCH_DIM_IS                                         ~13     ~11, ~12
         17        COALESCE                                             ~14     ~13
         18        NEW                                                  $15     'Conta'
         19        CHECK_FUNC_ARG                                               
         20        FETCH_OBJ_FUNC_ARG                                   $16     !1, 'contaId'
         21        SEND_FUNC_ARG                                                $16
         22        SEND_VAL_EX                                                  0
         23        DO_FCALL                                          0          
         24        QM_ASSIGN                                            ~14     $15
         25        ASSIGN                                                       !2, ~14
  133    26        INIT_FCALL                                                   'aplicartransacao'
         27        SEND_VAR                                                     !2
         28        SEND_VAR                                                     !1
         29        DO_FCALL                                          0  $19     
         30        ASSIGN                                                       !3, $19
  135    31        ROPE_INIT                                         9  ~26     '%E2%9C%85+Transa%C3%A7%C3%A3o+'
         32        FETCH_OBJ_R                                          ~21     !1, 'tipo'
         33        ROPE_ADD                                          1  ~26     ~26, ~21
         34        ROPE_ADD                                          2  ~26     ~26, '+de+R%24+'
         35        FETCH_OBJ_R                                          ~22     !1, 'valor'
         36        ROPE_ADD                                          3  ~26     ~26, ~22
         37        ROPE_ADD                                          4  ~26     ~26, '+na+conta+'
         38        FETCH_OBJ_R                                          ~23     !1, 'contaId'
         39        ROPE_ADD                                          5  ~26     ~26, ~23
         40        ROPE_ADD                                          6  ~26     ~26, '+conclu%C3%ADda.+Saldo+atual%3A+R%24+'
         41        FETCH_OBJ_R                                          ~24     !3, 'saldo'
         42        ROPE_ADD                                          7  ~26     ~26, ~24
         43        ROPE_END                                          8  ~25     ~26, '%0A'
         44        ECHO                                                         ~25
  138    45        INIT_FCALL                                                   'array_merge'
         46        FETCH_DIM_R                                          ~31     !0, 'contas'
         47        SEND_VAL                                                     ~31
         48        FETCH_OBJ_R                                          ~32     !1, 'contaId'
         49        INIT_ARRAY                                           ~33     !3, ~32
         50        SEND_VAL                        

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.51 ms | 1572 KiB | 24 Q