3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Bundle\TwigBundle\Controller; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** * ExceptionController. * * @author Fabien Potencier <fabien@symfony.com> */ class ExceptionController { protected $twig; protected $debug; public function __construct(\Twig_Environment $twig, $debug) { $this->twig = $twig; $this->debug = $debug; } /** * Converts an Exception to a Response. * * @param Request $request The request * @param FlattenException $exception A FlattenException instance * @param DebugLoggerInterface $logger A DebugLoggerInterface instance * @param string $_format The format to use for rendering (html, xml, ...) * * @return Response * * @throws \InvalidArgumentException When the exception template does not exist */ public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html') { $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $code = $exception->getStatusCode(); return new Response($this->twig->render( $this->findTemplate($request, $_format, $code, $this->debug), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, ) )); } /** * @param integer $startObLevel * * @return string */ protected function getAndCleanOutputBuffering($startObLevel) { // ob_get_level() never returns 0 on some Windows configurations, so if // the level is the same two times in a row, the loop should be stopped. $previousObLevel = null; $currentContent = ''; while (($obLevel = ob_get_level()) > $startObLevel && $obLevel !== $previousObLevel) { $previousObLevel = $obLevel; $currentContent .= ob_get_clean(); } return $currentContent; } /** * @param Request $request * @param string $format * @param integer $code An HTTP response status code * @param Boolean $debug * * @return TemplateReference */ protected function findTemplate(Request $request, $format, $code, $debug) { $name = $debug ? 'exception' : 'error'; if ($debug && 'html' == $format) { $name = 'exception_full'; } // when not in debug, try to find a template for the specific HTTP status code and format if (!$debug) { $template = new TemplateReference('TwigBundle', 'Exception', $name.$code, $format, 'twig'); if ($this->templateExists($template)) { return $template; } } // try to find a template for the given format $template = new TemplateReference('TwigBundle', 'Exception', $name, $format, 'twig'); if ($this->templateExists($template)) { return $template; } // default to a generic HTML exception $request->setRequestFormat('html'); return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig'); } // to be removed when the minimum required version of Twig is >= 2.0 protected function templateExists($template) { $loader = $this->twig->getLoader(); if ($loader instanceof \Twig_ExistsLoaderInterface) { return $loader->exists($template); } try { $loader->getSource($template); return true; } catch (\Twig_Error_Loader $e) { } return false; } } class ExceptionController2 extends ExceptionController { /** * Converts an Exception to a Response. * * @param Request $request The request * @param FlattenException $exception A FlattenException instance * @param DebugLoggerInterface $logger A DebugLoggerInterface instance * @param string $_format The format to use for rendering (html, xml, ...) * * @return Response * * @throws \InvalidArgumentException When the exception template does not exist */ public function showAction(Request $request, Symfony\Component\HttpKernel\Exception\FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html') { $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1)); $code = $exception->getStatusCode(); return new Response($this->twig->render( $this->findTemplate($request, $_format, $code, $this->debug), array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, 'logger' => $logger, 'currentContent' => $currentContent, ) )); } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2qNdW
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  141     0  E >   DECLARE_CLASS                                            'symfony%5Cbundle%5Ctwigbundle%5Ccontroller%5Cexceptioncontroller2', 'symfony%5Cbundle%5Ctwigbundle%5Ccontroller%5Cexceptioncontroller'
  174     1      > RETURN                                                   1

Class Symfony\Bundle\TwigBundle\Controller\ExceptionController:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2qNdW
function name:  __construct
number of ops:  7
compiled vars:  !0 = $twig, !1 = $debug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        ASSIGN_OBJ                                               'twig'
          3        OP_DATA                                                  !0
   33     4        ASSIGN_OBJ                                               'debug'
          5        OP_DATA                                                  !1
   34     6      > RETURN                                                   null

End of function __construct

Function showaction:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2qNdW
function name:  showAction
number of ops:  47
compiled vars:  !0 = $request, !1 = $exception, !2 = $logger, !3 = $_format, !4 = $currentContent, !5 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      'html'
   50     4        INIT_METHOD_CALL                                         'getAndCleanOutputBuffering'
          5        FETCH_OBJ_R                                      ~6      !0, 'headers'
          6        INIT_METHOD_CALL                                         ~6, 'get'
          7        SEND_VAL_EX                                              'X-Php-Ob-Level'
          8        SEND_VAL_EX                                              -1
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR_NO_REF_EX                                       $7
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !4, $8
   52    13        INIT_METHOD_CALL                                         !1, 'getStatusCode'
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                                   !5, $10
   54    16        NEW                                              $12     'Symfony%5CComponent%5CHttpFoundation%5CResponse'
         17        FETCH_OBJ_R                                      ~13     'twig'
         18        INIT_METHOD_CALL                                         ~13, 'render'
   55    19        INIT_METHOD_CALL                                         'findTemplate'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !3
         22        SEND_VAR_EX                                              !5
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $14     'debug'
         25        SEND_FUNC_ARG                                            $14
         26        DO_FCALL                                      0  $15     
         27        SEND_VAR_NO_REF_EX                                       $15
   57    28        INIT_ARRAY                                       ~16     !5, 'status_code'
   58    29        FETCH_STATIC_PROP_IS                             ~17     'statusTexts', 'Symfony%5CComponent%5CHttpFoundation%5CResponse'
         30        ISSET_ISEMPTY_DIM_OBJ                         0          ~17, !5
         31      > JMPZ                                                     ~18, ->36
         32    >   FETCH_STATIC_PROP_R          unknown             ~19     'statusTexts'
         33        FETCH_DIM_R                                      ~20     ~19, !5
         34        QM_ASSIGN                                        ~21     ~20
         35      > JMP                                                      ->37
         36    >   QM_ASSIGN                                        ~21     ''
         37    >   ADD_ARRAY_ELEMENT                                ~16     ~21, 'status_text'
   59    38        ADD_ARRAY_ELEMENT                                ~16     !1, 'exception'
   60    39        ADD_ARRAY_ELEMENT                                ~16     !2, 'logger'
   61    40        ADD_ARRAY_ELEMENT                                ~16     !4, 'currentContent'
         41        SEND_VAL_EX                                              ~16
         42        DO_FCALL                                      0  $22     
         43        SEND_VAR_NO_REF_EX                                       $22
         44        DO_FCALL                                      0          
         45      > RETURN                                                   $12
   64    46*     > RETURN                                                   null

End of function showaction

Function getandcleanoutputbuffering:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
Branch analysis from position: 15
Branch analysis from position: 15
filename:       /in/2qNdW
function name:  getAndCleanOutputBuffering
number of ops:  18
compiled vars:  !0 = $startObLevel, !1 = $previousObLevel, !2 = $currentContent, !3 = $obLevel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   71     0  E >   RECV                                             !0      
   75     1        ASSIGN                                                   !1, null
   76     2        ASSIGN                                                   !2, ''
   78     3      > JMP                                                      ->8
   79     4    >   ASSIGN                                                   !1, !3
   80     5        INIT_NS_FCALL_BY_NAME                                    'Symfony%5CBundle%5CTwigBundle%5CController%5Cob_get_clean'
          6        DO_FCALL                                      0  $7      
          7        ASSIGN_OP                                     8          !2, $7
   78     8    >   INIT_NS_FCALL_BY_NAME                                    'Symfony%5CBundle%5CTwigBundle%5CController%5Cob_get_level'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                           ~10     !3, $9
         11        IS_SMALLER                                       ~11     !0, ~10
         12      > JMPZ_EX                                          ~11     ~11, ->15
         13    >   IS_NOT_IDENTICAL                                 ~12     !3, !1
         14        BOOL                                             ~11     ~12
         15    > > JMPNZ                                                    ~11, ->4
   83    16    > > RETURN                                                   !2
   84    17*     > RETURN                                                   null

End of function getandcleanoutputbuffering

Function findtemplate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 30
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 14
Branch analysis from position: 12
Branch analysis from position: 7
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
Branch analysis from position: 12
filename:       /in/2qNdW
function name:  findTemplate
number of ops:  55
compiled vars:  !0 = $request, !1 = $format, !2 = $code, !3 = $debug, !4 = $name, !5 = $template
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   94     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   96     4      > JMPZ                                                     !3, ->7
          5    >   QM_ASSIGN                                        ~6      'exception'
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~6      'error'
          8    >   ASSIGN                                                   !4, ~6
   97     9      > JMPZ_EX                                          ~8      !3, ->12
         10    >   IS_EQUAL                                         ~9      !1, 'html'
         11        BOOL                                             ~8      ~9
         12    > > JMPZ                                                     ~8, ->14
   98    13    >   ASSIGN                                                   !4, 'exception_full'
  102    14    >   BOOL_NOT                                         ~11     !3
         15      > JMPZ                                                     ~11, ->30
  103    16    >   NEW                                              $12     'Symfony%5CBundle%5CFrameworkBundle%5CTemplating%5CTemplateReference'
         17        SEND_VAL_EX                                              'TwigBundle'
         18        SEND_VAL_EX                                              'Exception'
         19        CONCAT                                           ~13     !4, !2
         20        SEND_VAL_EX                                              ~13
         21        SEND_VAR_EX                                              !1
         22        SEND_VAL_EX                                              'twig'
         23        DO_FCALL                                      0          
         24        ASSIGN                                                   !5, $12
  104    25        INIT_METHOD_CALL                                         'templateExists'
         26        SEND_VAR_EX                                              !5
         27        DO_FCALL                                      0  $16     
         28      > JMPZ                                                     $16, ->30
  105    29    > > RETURN                                                   !5
  110    30    >   NEW                                              $17     'Symfony%5CBundle%5CFrameworkBundle%5CTemplating%5CTemplateReference'
         31        SEND_VAL_EX                                              'TwigBundle'
         32        SEND_VAL_EX                                              'Exception'
         33        SEND_VAR_EX                                              !4
         34        SEND_VAR_EX                                              !1
         35        SEND_VAL_EX                                              'twig'
         36        DO_FCALL                                      0          
         37        ASSIGN                                                   !5, $17
  111    38        INIT_METHOD_CALL                                         'templateExists'
         39        SEND_VAR_EX                                              !5
         40        DO_FCALL                                      0  $20     
         41      > JMPZ                                                     $20, ->43
  112    42    > > RETURN                                                   !5
  116    43    >   INIT_METHOD_CALL                                         !0, 'setRequestFormat'
         44        SEND_VAL_EX                                              'html'
         45        DO_FCALL                                      0          
  118    46        NEW                                              $22     'Symfony%5CBundle%5CFrameworkBundle%5CTemplating%5CTemplateReference'
         47        SEND_VAL_EX                                              'TwigBundle'
         48        SEND_VAL_EX                                              'Exception'
         49        SEND_VAR_EX                                              !4
         50        SEND_VAL_EX                                              'html'
         51        SEND_VAL_EX                                              'twig'
         52        DO_FCALL                                      0          
         53      > RETURN                                                   $22
  119    54*     > RETURN                                                   null

End of function findtemplate

Function templateexists:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 16
Branch analysis from position: 16
2 jumps found. (Code = 107) Position 1 = 17, Position 2 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2qNdW
function name:  templateExists
number of ops:  19
compiled vars:  !0 = $template, !1 = $loader, !2 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  122     0  E >   RECV                                             !0      
  124     1        FETCH_OBJ_R                                      ~3      'twig'
          2        INIT_METHOD_CALL                                         ~3, 'getLoader'
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
  125     5        INSTANCEOF                                               !1, 'Twig_ExistsLoaderInterface'
          6      > JMPZ                                                     ~6, ->11
  126     7    >   INIT_METHOD_CALL                                         !1, 'exists'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $7      
         10      > RETURN                                                   $7
  130    11    >   INIT_METHOD_CALL                                         !1, 'getSource'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
  132    14      > RETURN                                                   <true>
         15*       JMP                                                      ->17
  133    16  E > > CATCH                                       last         'Twig_Error_Loader'
  136    17    > > RETURN                                                   <false>
  137    18*     > RETURN                                                   null

End of function templateexists

End of class Symfony\Bundle\TwigBundle\Controller\ExceptionController.

Class Symfony\Bundle\TwigBundle\Controller\ExceptionController2:
Function showaction:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 36
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2qNdW
function name:  showAction
number of ops:  47
compiled vars:  !0 = $request, !1 = $exception, !2 = $logger, !3 = $_format, !4 = $currentContent, !5 = $code
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  156     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      'html'
  158     4        INIT_METHOD_CALL                                         'getAndCleanOutputBuffering'
          5        FETCH_OBJ_R                                      ~6      !0, 'headers'
          6        INIT_METHOD_CALL                                         ~6, 'get'
          7        SEND_VAL_EX                                              'X-Php-Ob-Level'
          8        SEND_VAL_EX                                              -1
          9        DO_FCALL                                      0  $7      
         10        SEND_VAR_NO_REF_EX                                       $7
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !4, $8
  160    13        INIT_METHOD_CALL                                         !1, 'getStatusCode'
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                                   !5, $10
  162    16        NEW                                              $12     'Symfony%5CComponent%5CHttpFoundation%5CResponse'
         17        FETCH_OBJ_R                                      ~13     'twig'
         18        INIT_METHOD_CALL                                         ~13, 'render'
  163    19        INIT_METHOD_CALL                                         'findTemplate'
         20        SEND_VAR_EX                                              !0
         21        SEND_VAR_EX                                              !3
         22        SEND_VAR_EX                                              !5
         23        CHECK_FUNC_ARG                                           
         24        FETCH_OBJ_FUNC_ARG                               $14     'debug'
         25        SEND_FUNC_ARG                                            $14
         26        DO_FCALL                                      0  $15     
         27        SEND_VAR_NO_REF_EX                                       $15
  165    28        INIT_ARRAY                                       ~16     !5, 'status_code'
  166    29        FETCH_STATIC_PROP_IS                             ~17     'statusTexts', 'Symfony%5CComponent%5CHttpFoundation%5CResponse'
         30        ISSET_ISEMPTY_DIM_OBJ                         0          ~17, !5
         31      > JMPZ                                                     ~18, ->36
         32    >   FETCH_STATIC_PROP_R          unknown             ~19     'statusTexts'
         33        FETCH_DIM_R                                      ~20     ~19, !5
         34        QM_ASSIGN                                        ~21     ~20
         35      > JMP                                                      ->37
         36    >   QM_ASSIGN                                        ~21     ''
         37    >   ADD_ARRAY_ELEMENT                                ~16     ~21, 'status_text'
  167    38        ADD_ARRAY_ELEMENT                                ~16     !1, 'exception'
  168    39        ADD_ARRAY_ELEMENT                                ~16     !2, 'logger'
  169    40        ADD_ARRAY_ELEMENT                                ~16     !4, 'currentContent'
         41        SEND_VAL_EX                                              ~16
         42        DO_FCALL                                      0  $22     
         43        SEND_VAR_NO_REF_EX                                       $22
         44        DO_FCALL                                      0          
         45      > RETURN                                                   $12
  172    46*     > RETURN                                                   null

End of function showaction

End of class Symfony\Bundle\TwigBundle\Controller\ExceptionController2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.82 ms | 1416 KiB | 17 Q