3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace J7mbo\SeleniumGrid2Api; use J7mbo\SeleniumGrid2Api\Entity\CapabilityFactory, J7mbo\SeleniumGrid2Api\Entity\NodeFactory, GuzzleHttp\Client as HttpClient, GuzzleHttp\Message\Response; /** * Class SeleniumGrid2Api * * @package J7mbo\SeleniumGrid2Api */ class SeleniumGrid2Api { /** * @var int The timeout for the request */ const REQUEST_TIMEOUT = 5; /** * @var HttpClient */ protected $httpClient; /** * @var JsonValidator */ protected $jsonValidator; /** * @var CapabilityFactory */ protected $capabilityFactory; /** * @var NodeFactory */ protected $nodeFactory; /** * @constructor * * @param HttpClient $httpClient * @param JsonValidator $jsonValidator * @param CapabilityFactory $capabilityFactory * @param NodeFactory $nodeFactory */ public function __construct( HttpClient $httpClient, JsonValidator $jsonValidator, CapabilityFactory $capabilityFactory, NodeFactory $nodeFactory ) { $this->httpClient = $httpClient; $this->jsonValidator = $jsonValidator; $this->capabilityFactory = $capabilityFactory; $this->nodeFactory = $nodeFactory; } /** * Get a Node entity representing the running node * * @param string $host * @param int $port * * @throws NotFoundException * * @return Entity\Node */ public function getNode($host = 'localhost', $port = 5555) { $uri = sprintf('http://%s:%d', $host, $port); $request = $this->httpClient->createRequest('GET', sprintf(Endpoints::NODE_STATUS), $uri, [ 'timeout' => self::REQUEST_TIMEOUT ]); try { /** @var Response $response */ /** @noinspection PhpVoidFunctionResultUsedInspection */ $response = $this->httpClient->send($request); if (($status = $response->getStatusCode()) !== 200) { throw new NotFoundException(sprintf('Status code for: %s returned %d', $uri, $status)); } if ($this->jsonValidator->isJson($response->getBody())) { throw new NotFoundException(sprintf('Invalid json returned from: %s', $uri)); } $data = json_decode($response->getBody(), true); $capabilities = []; foreach($data['request']['capabilities'] as $capability) { if ($capability['seleniumProtocol'] === 'WebDriver') { $capabilities[] = $this->capabilityFactory->build( $capability['browsername'], $capability['maxInstances'], $capability['platform'] ); } } return $this->nodeFactory->build($capabilities, $host, $port); } catch (\Exception $e) { throw new NotFoundException($e->getMessage()); } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qh70Q
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  117     0  E > > RETURN                                                   1

Class J7mbo\SeleniumGrid2Api\SeleniumGrid2Api:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qh70Q
function name:  __construct
number of ops:  13
compiled vars:  !0 = $httpClient, !1 = $jsonValidator, !2 = $capabilityFactory, !3 = $nodeFactory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   57     4        ASSIGN_OBJ                                               'httpClient'
          5        OP_DATA                                                  !0
   58     6        ASSIGN_OBJ                                               'jsonValidator'
          7        OP_DATA                                                  !1
   59     8        ASSIGN_OBJ                                               'capabilityFactory'
          9        OP_DATA                                                  !2
   60    10        ASSIGN_OBJ                                               'nodeFactory'
         11        OP_DATA                                                  !3
   61    12      > RETURN                                                   null

End of function __construct

Function getnode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 39
Branch analysis from position: 30
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 54
Branch analysis from position: 46
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 54
2 jumps found. (Code = 77) Position 1 = 65, Position 2 = 84
Branch analysis from position: 65
2 jumps found. (Code = 78) Position 1 = 66, Position 2 = 84
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 83
Branch analysis from position: 69
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 83
Branch analysis from position: 84
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 84
Found catch point at position: 93
Branch analysis from position: 93
2 jumps found. (Code = 107) Position 1 = 94, Position 2 = -2
Branch analysis from position: 94
1 jumps found. (Code = 108) Position 1 = -2
filename:       /in/qh70Q
function name:  getNode
number of ops:  101
compiled vars:  !0 = $host, !1 = $port, !2 = $uri, !3 = $request, !4 = $response, !5 = $status, !6 = $data, !7 = $capabilities, !8 = $capability, !9 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   73     0  E >   RECV_INIT                                        !0      'localhost'
          1        RECV_INIT                                        !1      5555
   75     2        INIT_NS_FCALL_BY_NAME                                    'J7mbo%5CSeleniumGrid2Api%5Csprintf'
          3        SEND_VAL_EX                                              'http%3A%2F%2F%25s%3A%25d'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $10     
          7        ASSIGN                                                   !2, $10
   76     8        FETCH_OBJ_R                                      ~12     'httpClient'
          9        INIT_METHOD_CALL                                         ~12, 'createRequest'
         10        SEND_VAL_EX                                              'GET'
         11        INIT_NS_FCALL_BY_NAME                                    'J7mbo%5CSeleniumGrid2Api%5Csprintf'
         12        FETCH_CLASS_CONSTANT                             ~13     'J7mbo%5CSeleniumGrid2Api%5CEndpoints', 'NODE_STATUS'
         13        SEND_VAL_EX                                              ~13
         14        DO_FCALL                                      0  $14     
         15        SEND_VAR_NO_REF_EX                                       $14
         16        SEND_VAR_EX                                              !2
   77    17        SEND_VAL_EX                                              <array>
   76    18        DO_FCALL                                      0  $15     
         19        ASSIGN                                                   !3, $15
   84    20        FETCH_OBJ_R                                      ~17     'httpClient'
         21        INIT_METHOD_CALL                                         ~17, 'send'
         22        SEND_VAR_EX                                              !3
         23        DO_FCALL                                      0  $18     
         24        ASSIGN                                                   !4, $18
   86    25        INIT_METHOD_CALL                                         !4, 'getStatusCode'
         26        DO_FCALL                                      0  $20     
         27        ASSIGN                                           ~21     !5, $20
         28        IS_NOT_IDENTICAL                                         ~21, 200
         29      > JMPZ                                                     ~22, ->39
   88    30    >   NEW                                              $23     'J7mbo%5CSeleniumGrid2Api%5CNotFoundException'
         31        INIT_NS_FCALL_BY_NAME                                    'J7mbo%5CSeleniumGrid2Api%5Csprintf'
         32        SEND_VAL_EX                                              'Status+code+for%3A+%25s+returned+%25d'
         33        SEND_VAR_EX                                              !2
         34        SEND_VAR_EX                                              !5
         35        DO_FCALL                                      0  $24     
         36        SEND_VAR_NO_REF_EX                                       $24
         37        DO_FCALL                                      0          
         38      > THROW                                         0          $23
   91    39    >   FETCH_OBJ_R                                      ~26     'jsonValidator'
         40        INIT_METHOD_CALL                                         ~26, 'isJson'
         41        INIT_METHOD_CALL                                         !4, 'getBody'
         42        DO_FCALL                                      0  $27     
         43        SEND_VAR_NO_REF_EX                                       $27
         44        DO_FCALL                                      0  $28     
         45      > JMPZ                                                     $28, ->54
   93    46    >   NEW                                              $29     'J7mbo%5CSeleniumGrid2Api%5CNotFoundException'
         47        INIT_NS_FCALL_BY_NAME                                    'J7mbo%5CSeleniumGrid2Api%5Csprintf'
         48        SEND_VAL_EX                                              'Invalid+json+returned+from%3A+%25s'
         49        SEND_VAR_EX                                              !2
         50        DO_FCALL                                      0  $30     
         51        SEND_VAR_NO_REF_EX                                       $30
         52        DO_FCALL                                      0          
         53      > THROW                                         0          $29
   96    54    >   INIT_NS_FCALL_BY_NAME                                    'J7mbo%5CSeleniumGrid2Api%5Cjson_decode'
         55        INIT_METHOD_CALL                                         !4, 'getBody'
         56        DO_FCALL                                      0  $32     
         57        SEND_VAR_NO_REF_EX                                       $32
         58        SEND_VAL_EX                                              <true>
         59        DO_FCALL                                      0  $33     
         60        ASSIGN                                                   !6, $33
   98    61        ASSIGN                                                   !7, <array>
  100    62        FETCH_DIM_R                                      ~36     !6, 'request'
         63        FETCH_DIM_R                                      ~37     ~36, 'capabilities'
         64      > FE_RESET_R                                       $38     ~37, ->84
         65    > > FE_FETCH_R                                               $38, !8, ->84
  102    66    >   FETCH_DIM_R                                      ~39     !8, 'seleniumProtocol'
         67        IS_IDENTICAL                                             ~39, 'WebDriver'
         68      > JMPZ                                                     ~40, ->83
  104    69    >   FETCH_OBJ_R                                      ~42     'capabilityFactory'
         70        INIT_METHOD_CALL                                         ~42, 'build'
         71        CHECK_FUNC_ARG                                           
  105    72        FETCH_DIM_FUNC_ARG                               $43     !8, 'browsername'
         73        SEND_FUNC_ARG                                            $43
         74        CHECK_FUNC_ARG                                           
         75        FETCH_DIM_FUNC_ARG                               $44     !8, 'maxInstances'
         76        SEND_FUNC_ARG                                            $44
         77        CHECK_FUNC_ARG                                           
         78        FETCH_DIM_FUNC_ARG                               $45     !8, 'platform'
         79        SEND_FUNC_ARG                                            $45
  104    80        DO_FCALL                                      0  $46     
         81        ASSIGN_DIM                                               !7
  105    82        OP_DATA                                                  $46
  100    83    > > JMP                                                      ->65
         84    >   FE_FREE                                                  $38
  110    85        FETCH_OBJ_R                                      ~47     'nodeFactory'
         86        INIT_METHOD_CALL                                         ~47, 'build'
         87        SEND_VAR_EX                                              !7
         88        SEND_VAR_EX                                              !0
         89        SEND_VAR_EX                                              !1
         90        DO_FCALL                                      0  $48     
         91      > RETURN                                                   $48
         92*       JMP                                                      ->100
  112    93  E > > CATCH                                       last         'Exception'
  114    94    >   NEW                                              $49     'J7mbo%5CSeleniumGrid2Api%5CNotFoundException'
         95        INIT_METHOD_CALL                                         !9, 'getMessage'
         96        DO_FCALL                                      0  $50     
         97        SEND_VAR_NO_REF_EX                                       $50
         98        DO_FCALL                                      0          
         99      > THROW                                         0          $49
  116   100*     > RETURN                                                   null

End of function getnode

End of class J7mbo\SeleniumGrid2Api\SeleniumGrid2Api.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.25 ms | 1012 KiB | 15 Q