3v4l.org

run code in 300+ PHP versions simultaneously
<?php class EmailSendingErrorException extends RuntimeException { public $message = 'Impossible d\'envoyer l\'email.'; } class NotificationSendingErrorException extends RuntimeException { public $message = 'Impossible d\'envoyer la notification.'; } class ShortText extends RuntimeException { public $message = 'Le texte fourni est trop court.'; } /** * @var string $text le contenu du message * @return bool true en cas de succès * @throw Exception on error */ function sendEmail(string $text): bool { if (/*envoie du message échoue*/ true) { throw new EmailSendingErrorException(); } return true; } /** * @var string $text le contenu du message * @return bool true en cas de succès * @throw Exception on error */ function sendNotification(string $text): bool { if (/*envoie de notification échoue*/ true) { throw new NotificationSendingErrorException(); } return true; } /** * @var string $text le contenu du message * @return bool true en cas de succès * @throw Exception on error */ function sendMessage(string $text): bool { if (10 > strlen($text)) { throw new ShortTextException(); } try { sendNotification($text); } catch (NotificationSendingErrorException $e) { // Envoyez vous une alerte // pour vous prévenir que les notifications ne marche pas ;) } finally { // finally permet d'exécuter du code quoi qu'il arrive :) sendEmail($text); // si une exception est jetée par sendEmail, // Le return n'est jamais exécuté return true; } } try { sendMessage('Hello, ici Greg "pappy" Boyington'); } catch (ShortTextException $e) { echo $e->message; } catch (EmailSendingErrorException $e) { echo 'Une erreur est survenue lors de l\'envoie du message, nos équipes ont été prévenues, veuillez réessayer plus tard'; } catch (Exception $e) { echo 'Une erreur inattendue est survenue, nos équipes ont été prévenues, veuillez réessayer plus tard'; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 4
Branch analysis from position: 4
2 jumps found. (Code = 107) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 8
2 jumps found. (Code = 107) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 8
Branch analysis from position: 8
Found catch point at position: 11
Branch analysis from position: 11
filename:       /in/PPGVp
function name:  (null)
number of ops:  14
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   73     0  E >   INIT_FCALL                                               'sendmessage'
          1        SEND_VAL                                                 'Hello%2C+ici+Greg+%22pappy%22+Boyington'
          2        DO_FCALL                                      0          
          3      > JMP                                                      ->13
   74     4  E > > CATCH                                                    'ShortTextException', ->8
   75     5    >   FETCH_OBJ_R                                      ~2      !0, 'message'
          6        ECHO                                                     ~2
          7      > JMP                                                      ->13
   76     8  E > > CATCH                                                    'EmailSendingErrorException', ->11
   77     9    >   ECHO                                                     'Une+erreur+est+survenue+lors+de+l%27envoie+du+message%2C+nos+%C3%A9quipes+ont+%C3%A9t%C3%A9+pr%C3%A9venues%2C+veuillez+r%C3%A9essayer+plus+tard'
         10      > JMP                                                      ->13
   78    11  E > > CATCH                                       last         'Exception'
   79    12    >   ECHO                                                     'Une+erreur+inattendue+est+survenue%2C+nos+%C3%A9quipes+ont+%C3%A9t%C3%A9+pr%C3%A9venues%2C+veuillez+r%C3%A9essayer+plus+tard'
   80    13    > > RETURN                                                   1

Function sendemail:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PPGVp
function name:  sendEmail
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1      > JMPZ                                                     <true>, ->5
   27     2    >   NEW                                              $1      'EmailSendingErrorException'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
   30     5    > > RETURN                                                   <true>
   31     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function sendemail

Function sendnotification:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 5
Branch analysis from position: 2
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PPGVp
function name:  sendNotification
number of ops:  8
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   39     1      > JMPZ                                                     <true>, ->5
   41     2    >   NEW                                              $1      'NotificationSendingErrorException'
          3        DO_FCALL                                      0          
          4      > THROW                                         0          $1
   44     5    > > RETURN                                                   <true>
   45     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function sendnotification

Function sendmessage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
2 jumps found. (Code = 162) Position 1 = 14, Position 2 = 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 11
Branch analysis from position: 11
2 jumps found. (Code = 107) Position 1 = 12, Position 2 = -2
Branch analysis from position: 12
filename:       /in/PPGVp
function name:  sendMessage
number of ops:  22
compiled vars:  !0 = $text, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
   54     1        STRLEN                                           ~2      !0
          2        IS_SMALLER                                               ~2, 10
          3      > JMPZ                                                     ~3, ->7
   55     4    >   NEW                                              $4      'ShortTextException'
          5        DO_FCALL                                      0          
          6      > THROW                                         0          $4
   59     7    >   INIT_FCALL                                               'sendnotification'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0          
         10      > JMP                                                      ->12
   60    11  E > > CATCH                                       last         'NotificationSendingErrorException'
   63    12    > > FAST_CALL                                                ->14
         13    > > JMP                                                      ->20
   65    14    >   INIT_FCALL                                               'sendemail'
         15        SEND_VAR                                                 !0
         16        DO_FCALL                                      0          
   68    17        DISCARD_EXCEPTION                                        
         18      > RETURN                                                   <true>
         19*       FAST_RET                                                 
   70    20    >   VERIFY_RETURN_TYPE                                       
         21      > RETURN                                                   null

End of function sendmessage

Class EmailSendingErrorException: [no user functions]
Class NotificationSendingErrorException: [no user functions]
Class ShortText: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.64 ms | 1455 KiB | 16 Q