3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TableController extends Controller { private string $tableName; private array $conditions; public function __construct() { parent::__construct(); $this->tableName = $this->urlInst->params['tableName'] ?? 'book'; } /** * 更新 */ public function editAction(): void { $requestData = json_decode(file_get_contents('php://input'), true); $params = $this->urlInst->params; $tableName = $params['tableName']; // 編集できるテーブルか検証 if (!in_array($tableName, ['book'])) { throw new IllegalPostedException("Illegal tableNamee: {$tableName}"); } if ($tableName === 'book') { $itemMapperInst = new BookMapper(); // 個別に編集に $resItems に結果を追加していく $resItems = []; foreach ($requestData as $info) { // 一部が失敗したらその内容を返し処理を続けたいので // ループ内で catch し, 再 throw はしない try { $itemInst = new Book(); $itemInst->fromAry($info); $itemMapperInst->editItem($itemInst); $resItems[] = $itemInst; } catch (SkipException $e) { $parsed_exception = $e->getParsedException(); } catch (IllegalPostedException | \Exception | \Throwable $e) { $parsed_exception = parse_exception($e); } if (isset($parsed_exception)) { save_exception_log($parsed_exception); $resItems[] = $parsed_exception; } } } else { // 他の $tableName の場合の処理 } $this->adminRender([ 'resItems' => $resItems ]); } } class BookMapper extends ItemMapper { /** * 更新 */ public function editItem(object $bookInst): void { try { $this->pdo->beginTransaction(); // uniqueId から id を取得 $rowMapperInst = new CombinedBookRowMapper(); $combinedBookId = $rowMapperInst->getIdByUniqueId($bookInst->combinedBookUniqueId); if (!$combinedBookId) { // uniqueId が存在しない場合 throw new NotFoundException("not found uniqueId: {$bookInst->combinedBookUniqueId}"); } $bookInst->combinedBookId = $rowMapperInst->getIdByUniqueId($bookInst->combinedBookUniqueId); // tbl_books テーブルをUPDATE $rowMapperInst = new BookRowMapper(); $rowMapperInst->editByBookInst($bookInst); // tbl_combined_book_titles テーブルをUPDATE $rowMapperInst = new CombinedBookTitleRowMapper(); $rowMapperInst->editByBookInst($bookInst); $this->pdo->commit(); } catch (SkipException $e) { $this->pdo->rollBack(); throw new SkipException($e->getParsedException()); } catch (\Exception $e) { $this->pdo->rollBack(); throw new SkipException(parse_exception($e)); } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YpsZN
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'tablecontroller', 'controller'
   66     1        DECLARE_CLASS                                            'bookmapper', 'itemmapper'
  103     2      > RETURN                                                   1

Class TableController:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YpsZN
function name:  __construct
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_STATIC_METHOD_CALL                                  
          1        DO_FCALL                                      0          
   11     2        FETCH_OBJ_IS                                     ~2      'urlInst'
          3        FETCH_OBJ_IS                                     ~3      ~2, 'params'
          4        FETCH_DIM_IS                                     ~4      ~3, 'tableName'
          5        COALESCE                                         ~5      ~4
          6        QM_ASSIGN                                        ~5      'book'
          7        ASSIGN_OBJ                                               'tableName'
          8        OP_DATA                                                  ~5
   12     9      > RETURN                                                   null

End of function __construct

Function editaction:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 66
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 64
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 64
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 63
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 63
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
Branch analysis from position: 66
Found catch point at position: 42
Branch analysis from position: 42
2 jumps found. (Code = 107) Position 1 = 43, Position 2 = 47
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 47
2 jumps found. (Code = 107) Position 1 = 48, Position 2 = 49
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 63
Branch analysis from position: 58
Branch analysis from position: 63
Branch analysis from position: 49
2 jumps found. (Code = 107) Position 1 = 50, Position 2 = 51
Branch analysis from position: 50
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 51
2 jumps found. (Code = 107) Position 1 = 52, Position 2 = -2
Branch analysis from position: 52
Found catch point at position: 47
Branch analysis from position: 47
Found catch point at position: 49
Branch analysis from position: 49
Found catch point at position: 51
Branch analysis from position: 51
filename:       /in/YpsZN
function name:  editAction
number of ops:  71
compiled vars:  !0 = $requestData, !1 = $params, !2 = $tableName, !3 = $itemMapperInst, !4 = $resItems, !5 = $info, !6 = $itemInst, !7 = $e, !8 = $parsed_exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'json_decode'
          1        INIT_FCALL                                               'file_get_contents'
          2        SEND_VAL                                                 'php%3A%2F%2Finput'
          3        DO_ICALL                                         $9      
          4        SEND_VAR                                                 $9
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $10     
          7        ASSIGN                                                   !0, $10
   21     8        FETCH_OBJ_R                                      ~12     'urlInst'
          9        FETCH_OBJ_R                                      ~13     ~12, 'params'
         10        ASSIGN                                                   !1, ~13
   22    11        FETCH_DIM_R                                      ~15     !1, 'tableName'
         12        ASSIGN                                                   !2, ~15
   25    13        IN_ARRAY                                         ~17     !2, <array>
         14        BOOL_NOT                                         ~18     ~17
         15      > JMPZ                                                     ~18, ->22
   26    16    >   NEW                                              $19     'IllegalPostedException'
         17        NOP                                                      
         18        FAST_CONCAT                                      ~20     'Illegal+tableNamee%3A+', !2
         19        SEND_VAL_EX                                              ~20
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $19
   29    22    >   IS_IDENTICAL                                             !2, 'book'
         23      > JMPZ                                                     ~22, ->66
   31    24    >   NEW                                              $23     'BookMapper'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !3, $23
   34    27        ASSIGN                                                   !4, <array>
   35    28      > FE_RESET_R                                       $27     !0, ->64
         29    > > FE_FETCH_R                                               $27, !5, ->64
   39    30    >   NEW                                              $28     'Book'
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !6, $28
   40    33        INIT_METHOD_CALL                                         !6, 'fromAry'
         34        SEND_VAR_EX                                              !5
         35        DO_FCALL                                      0          
   41    36        INIT_METHOD_CALL                                         !3, 'editItem'
         37        SEND_VAR_EX                                              !6
         38        DO_FCALL                                      0          
   42    39        ASSIGN_DIM                                               !4
         40        OP_DATA                                                  !6
         41      > JMP                                                      ->56
   43    42  E > > CATCH                                                    'SkipException', ->47
   44    43    >   INIT_METHOD_CALL                                         !7, 'getParsedException'
         44        DO_FCALL                                      0  $34     
         45        ASSIGN                                                   !8, $34
         46      > JMP                                                      ->56
   45    47  E > > CATCH                                                    'IllegalPostedException', ->49
         48    > > JMP                                                      ->52
         49  E > > CATCH                                                    'Exception', ->51
         50    > > JMP                                                      ->52
         51  E > > CATCH                                       last         'Throwable'
   46    52    >   INIT_FCALL_BY_NAME                                       'parse_exception'
         53        SEND_VAR_EX                                              !7
         54        DO_FCALL                                      0  $36     
         55        ASSIGN                                                   !8, $36
   49    56    >   ISSET_ISEMPTY_CV                                         !8
         57      > JMPZ                                                     ~38, ->63
   50    58    >   INIT_FCALL_BY_NAME                                       'save_exception_log'
         59        SEND_VAR_EX                                              !8
         60        DO_FCALL                                      0          
   51    61        ASSIGN_DIM                                               !4
         62        OP_DATA                                                  !8
   35    63    > > JMP                                                      ->29
         64    >   FE_FREE                                                  $27
   29    65      > JMP                                                      ->66
   59    66    >   INIT_METHOD_CALL                                         'adminRender'
   60    67        INIT_ARRAY                                       ~41     !4, 'resItems'
         68        SEND_VAL_EX                                              ~41
   59    69        DO_FCALL                                      0          
   62    70      > RETURN                                                   null

End of function editaction

End of class TableController.

Class BookMapper:
Function edititem:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 45
Branch analysis from position: 45
2 jumps found. (Code = 107) Position 1 = 46, Position 2 = 56
Branch analysis from position: 46
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 56
2 jumps found. (Code = 107) Position 1 = 57, Position 2 = -2
Branch analysis from position: 57
1 jumps found. (Code = 108) Position 1 = -2
Found catch point at position: 56
Branch analysis from position: 56
filename:       /in/YpsZN
function name:  editItem
number of ops:  68
compiled vars:  !0 = $bookInst, !1 = $rowMapperInst, !2 = $combinedBookId, !3 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   RECV                                             !0      
   74     1        FETCH_OBJ_R                                      ~4      'pdo'
          2        INIT_METHOD_CALL                                         ~4, 'beginTransaction'
          3        DO_FCALL                                      0          
   77     4        NEW                                              $6      'CombinedBookRowMapper'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $6
   78     7        INIT_METHOD_CALL                                         !1, 'getIdByUniqueId'
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $9      !0, 'combinedBookUniqueId'
         10        SEND_FUNC_ARG                                            $9
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                                   !2, $10
   79    13        BOOL_NOT                                         ~12     !2
         14      > JMPZ                                                     ~12, ->22
   81    15    >   NEW                                              $13     'NotFoundException'
         16        NOP                                                      
         17        FETCH_OBJ_R                                      ~14     !0, 'combinedBookUniqueId'
         18        FAST_CONCAT                                      ~15     'not+found+uniqueId%3A+', ~14
         19        SEND_VAL_EX                                              ~15
         20        DO_FCALL                                      0          
         21      > THROW                                         0          $13
   84    22    >   INIT_METHOD_CALL                                         !1, 'getIdByUniqueId'
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $18     !0, 'combinedBookUniqueId'
         25        SEND_FUNC_ARG                                            $18
         26        DO_FCALL                                      0  $19     
         27        ASSIGN_OBJ                                               !0, 'combinedBookId'
         28        OP_DATA                                                  $19
   87    29        NEW                                              $20     'BookRowMapper'
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !1, $20
   88    32        INIT_METHOD_CALL                                         !1, 'editByBookInst'
         33        SEND_VAR_EX                                              !0
         34        DO_FCALL                                      0          
   91    35        NEW                                              $24     'CombinedBookTitleRowMapper'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !1, $24
   92    38        INIT_METHOD_CALL                                         !1, 'editByBookInst'
         39        SEND_VAR_EX                                              !0
         40        DO_FCALL                                      0          
   94    41        FETCH_OBJ_R                                      ~28     'pdo'
         42        INIT_METHOD_CALL                                         ~28, 'commit'
         43        DO_FCALL                                      0          
         44      > JMP                                                      ->67
   95    45  E > > CATCH                                                    'SkipException', ->56
   96    46    >   FETCH_OBJ_R                                      ~30     'pdo'
         47        INIT_METHOD_CALL                                         ~30, 'rollBack'
         48        DO_FCALL                                      0          
   97    49        NEW                                              $32     'SkipException'
         50        INIT_METHOD_CALL                                         !3, 'getParsedException'
         51        DO_FCALL                                      0  $33     
         52        SEND_VAR_NO_REF_EX                                       $33
         53        DO_FCALL                                      0          
         54      > THROW                                         0          $32
         55*       JMP                                                      ->67
   98    56  E > > CATCH                                       last         'Exception'
   99    57    >   FETCH_OBJ_R                                      ~35     'pdo'
         58        INIT_METHOD_CALL                                         ~35, 'rollBack'
         59        DO_FCALL                                      0          
  100    60        NEW                                              $37     'SkipException'
         61        INIT_FCALL_BY_NAME                                       'parse_exception'
         62        SEND_VAR_EX                                              !3
         63        DO_FCALL                                      0  $38     
         64        SEND_VAR_NO_REF_EX                                       $38
         65        DO_FCALL                                      0          
         66      > THROW                                         0          $37
  102    67    > > RETURN                                                   null

End of function edititem

End of class BookMapper.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.34 ms | 1028 KiB | 15 Q