idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
52,200
public function work_running ( $ bucket = self :: DEFAULT_BUCKET ) { $ results = array ( ) ; foreach ( $ this -> forked_children as $ pid => $ child ) { if ( $ child [ 'status' ] != self :: STOPPED && $ child [ 'bucket' ] === $ bucket ) { $ results [ $ pid ] = $ child ; } } return $ results ; }
Return array of currently running children
52,201
public function bucket_list ( $ include_default_bucket = true ) { $ bucket_list = array ( ) ; foreach ( $ this -> buckets as $ bucket_id ) { if ( ( $ include_default_bucket === false ) && ( $ bucket_id === self :: DEFAULT_BUCKET ) ) { continue ; } $ bucket_list [ ] = $ bucket_id ; } return $ bucket_list ; }
Return a list of the buckets which have been created
52,202
public function work_sets_count ( $ bucket = self :: DEFAULT_BUCKET , $ process_all_buckets = false ) { if ( $ process_all_buckets === true ) { $ count = 0 ; foreach ( $ this -> buckets as $ bucket_slot ) { $ count += count ( $ this -> work_units [ $ bucket_slot ] ) ; } return $ count ; } return count ( $ this -> work_units [ $ bucket ] ) ; }
Return the number of work sets queued
52,203
public function children_running ( $ bucket = self :: DEFAULT_BUCKET , $ show_pending = false ) { $ this -> signal_handler_sigchild ( SIGCHLD ) ; if ( $ bucket == self :: DEFAULT_BUCKET ) { return ( $ show_pending ? count ( $ this -> forked_children ) : $ this -> forked_children_count ) ; } $ count = 0 ; foreach ( $ this -> forked_children as $ child ) { if ( $ show_pending ) { if ( $ child [ 'bucket' ] == $ bucket ) { $ count ++ ; } } else if ( ( $ child [ 'bucket' ] == $ bucket ) && ( $ child [ 'status' ] != self :: STOPPED ) ) { $ count ++ ; } } return $ count ; }
Return the number of children running
52,204
public function children_pending ( $ bucket = self :: DEFAULT_BUCKET ) { return $ this -> children_running ( $ bucket , true ) + $ this -> work_sets_count ( $ bucket ) ; }
Returns the number of pending child items including running children and work sets that have not been allocated . Children running includes those that have not had their results retrieved yet .
52,205
public function safe_kill ( $ pid , $ signal , $ log_message = '' , $ log_level = self :: LOG_LEVEL_INFO ) { if ( ! array_key_exists ( $ pid , $ this -> forked_children ) ) { return false ; } $ stat_pid_file = '/proc/' . $ pid . '/stat' ; if ( ! file_exists ( $ stat_pid_file ) ) { $ this -> log ( 'Unable to find info for PID ' . $ pid . ' from ' . $ stat_pid_file , self :: LOG_LEVEL_DEBUG ) ; return false ; } $ stat_pid_info = file_get_contents ( $ stat_pid_file ) ; if ( $ stat_pid_info === false ) { $ this -> log ( 'Unable to get info for PID ' . $ pid , self :: LOG_LEVEL_DEBUG ) ; return false ; } $ stat_pid_info = explode ( ' ' , $ stat_pid_info ) ; if ( ! array_key_exists ( 3 , $ stat_pid_info ) ) { $ this -> log ( 'Unable to find parent PID for PID ' . $ pid , self :: LOG_LEVEL_DEBUG ) ; return false ; } if ( $ stat_pid_info [ 3 ] == getmypid ( ) ) { if ( $ log_message ) { $ this -> log ( $ log_message , $ log_level ) ; } posix_kill ( $ pid , $ signal ) ; return true ; } $ this -> log ( 'Failed to kill PID ' . $ pid . ' with signal ' . $ signal , self :: LOG_LEVEL_WARN ) ; return false ; }
Try to kill a given process and make sure it is safe to kill
52,206
public function helper_process_spawn ( $ function_name , array $ arguments = array ( ) , $ identifier = '' , $ respawn = true ) { if ( ( is_array ( $ function_name ) && method_exists ( $ function_name [ 0 ] , $ function_name [ 1 ] ) ) || function_exists ( $ function_name ) ) { list ( $ socket_child , $ socket_parent ) = $ this -> ipc_init ( ) ; pcntl_async_signals ( false ) ; $ pid = pcntl_fork ( ) ; if ( $ pid == - 1 ) { die ( "Forking error!\n" ) ; } elseif ( $ pid == 0 ) { $ this -> child_bucket = self :: DEFAULT_BUCKET ; pcntl_async_signals ( true ) ; socket_close ( $ socket_child ) ; $ result = call_user_func_array ( $ function_name , $ arguments ) ; self :: socket_send ( $ socket_parent , $ result ) ; exit ( 0 ) ; } else { pcntl_async_signals ( true ) ; $ this -> log ( 'Spawned new helper process with pid ' . $ pid , self :: LOG_LEVEL_INFO ) ; socket_close ( $ socket_parent ) ; $ this -> forked_children [ $ pid ] = array ( 'ctime' => time ( ) , 'identifier' => $ identifier , 'status' => self :: HELPER , 'bucket' => self :: DEFAULT_BUCKET , 'respawn' => $ respawn , 'function' => $ function_name , 'arguments' => $ arguments , 'socket' => $ socket_child , 'last_active' => microtime ( true ) , ) ; $ this -> forked_children_count ++ ; } } else { $ this -> log ( "Unable to spawn undefined helper function '" . $ function_name . "'" , self :: LOG_LEVEL_CRIT ) ; } }
Spawns a helper process
52,207
public function helper_process_respawn ( $ identifier ) { if ( $ identifier == '' ) { return false ; } foreach ( $ this -> forked_children as $ pid => $ child ) { if ( $ child [ 'status' ] == self :: HELPER && $ child [ 'identifier' ] == $ identifier ) { $ this -> safe_kill ( $ pid , SIGKILL , 'Forcing helper process \'' . $ identifier . '\' with pid ' . $ pid . ' to respawn' , self :: LOG_LEVEL_INFO ) ; } } }
Forces a helper process to respawn
52,208
public function process_work ( $ blocking = true , $ bucket = self :: DEFAULT_BUCKET , $ process_all_buckets = false ) { $ this -> housekeeping_check ( ) ; if ( $ process_all_buckets === true ) { foreach ( $ this -> buckets as $ bucket_slot ) { $ this -> process_work ( $ blocking , $ bucket_slot , false ) ; } return true ; } if ( $ blocking === true ) { while ( $ this -> work_sets_count ( $ bucket ) > 0 ) { while ( $ this -> children_running ( $ bucket ) >= $ this -> max_children [ $ bucket ] ) { $ this -> housekeeping_check ( ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; sleep ( 1 ) ; } $ this -> process_work_unit ( $ bucket ) ; } while ( $ this -> children_running ( $ bucket ) > 0 ) { sleep ( 1 ) ; $ this -> housekeeping_check ( ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; } $ this -> invoke_callback ( $ this -> parent_function_exit , array ( self :: $ parent_pid ) , true ) ; } else { while ( $ this -> children_running ( $ bucket ) < $ this -> max_children [ $ bucket ] ) { if ( ! $ this -> child_persistent_mode [ $ bucket ] && $ this -> work_sets_count ( $ bucket ) == 0 ) { return true ; } $ this -> process_work_unit ( $ bucket ) ; } } return true ; }
Process work on the work queue
52,209
public function get_result ( $ bucket = self :: DEFAULT_BUCKET ) { $ this -> post_results ( $ bucket ) ; if ( ! $ this -> has_result ( $ bucket ) ) { return null ; } return array_shift ( $ this -> results [ $ bucket ] ) ; }
Returns the first result available from the bucket . This will run a non - blocking poll of the children for updated results .
52,210
public function get_all_results ( $ bucket = self :: DEFAULT_BUCKET ) { $ this -> post_results ( $ bucket ) ; if ( ! $ this -> has_result ( $ bucket ) ) { return array ( ) ; } $ results = $ this -> results [ $ bucket ] ; $ this -> results [ $ bucket ] = array ( ) ; return $ results ; }
Returns all the results currently in the results queue . This will run a non - blocking poll of the children for updated results .
52,211
public function has_result ( $ bucket = self :: DEFAULT_BUCKET ) { $ this -> post_results ( $ bucket ) ; return ( ! empty ( $ this -> results [ $ bucket ] ) ) ; }
Checks if there is a result on the bucket . Before checking runs a non - blocking poll of the children for updated results .
52,212
protected function get_changed_sockets ( $ bucket = self :: DEFAULT_BUCKET , $ timeout = 0 ) { $ write_dummy = null ; $ exception_dummy = null ; $ sockets = array ( ) ; foreach ( $ this -> forked_children as $ pid => $ child ) { if ( $ child [ 'bucket' ] == $ bucket ) { $ sockets [ $ pid ] = $ child [ 'socket' ] ; } } if ( ! empty ( $ sockets ) ) { $ result = @ socket_select ( $ sockets , $ write_dummy , $ exception_dummy , $ timeout ) ; if ( $ result !== false && $ result > 0 ) { return $ sockets ; } } return null ; }
Checks if any changed child sockets are in the bucket .
52,213
protected function post_results ( $ bucket = self :: DEFAULT_BUCKET ) { $ results = $ this -> fetch_results ( false , 0 , $ bucket ) ; if ( is_array ( $ results ) && empty ( $ results ) ) { return true ; } if ( ! empty ( $ this -> parent_function_results [ $ bucket ] ) ) { if ( $ this -> invoke_callback ( $ this -> parent_function_results [ $ bucket ] , array ( $ results ) , true ) === false ) { return false ; } } elseif ( $ this -> store_result === true ) { $ this -> results [ $ bucket ] += $ results ; } return true ; }
Posts any new results to a callback function if one is available or stores them to the internal results storage if not . This does not block and will post any results that are available so call while children are running to check and post more results .
52,214
protected function process_work_unit ( $ bucket = self :: DEFAULT_BUCKET ) { $ child_work_units = array_splice ( $ this -> work_units [ $ bucket ] , 0 , $ this -> max_work_per_child [ $ bucket ] ) ; if ( $ this -> child_persistent_mode [ $ bucket ] ) { $ data = isset ( $ this -> child_persistent_mode_data [ $ bucket ] ) ? $ this -> child_persistent_mode_data [ $ bucket ] : null ; $ this -> fork_work_unit ( $ data , '' , $ bucket ) ; } elseif ( count ( $ child_work_units ) > 0 ) { if ( $ this -> child_single_work_item [ $ bucket ] ) { $ child_identifier = key ( $ child_work_units ) ; $ child_work_unit = current ( $ child_work_units ) ; next ( $ child_work_units ) ; if ( strpos ( $ child_identifier , 'id-' ) === 0 ) { $ child_identifier = substr ( $ child_identifier , 3 ) ; } $ this -> fork_work_unit ( array ( $ child_work_unit , $ child_identifier ) , $ child_identifier , $ bucket ) ; } else { $ this -> fork_work_unit ( array ( $ child_work_units ) , '' , $ bucket ) ; } } $ this -> post_results ( $ bucket ) ; }
Pulls items off the work queue for processing
52,215
protected function fork_work_unit ( array $ work_unit , $ identifier = '' , $ bucket = self :: DEFAULT_BUCKET ) { foreach ( $ this -> parent_function_prefork as $ function ) { $ this -> invoke_callback ( $ function , array ( ) , true ) ; } list ( $ socket_child , $ socket_parent ) = $ this -> ipc_init ( ) ; pcntl_async_signals ( false ) ; $ pid = pcntl_fork ( ) ; if ( $ pid == - 1 ) { $ this -> log ( 'failed to fork' , self :: LOG_LEVEL_CRIT ) ; return false ; } elseif ( $ pid ) { $ this -> forked_children [ $ pid ] = array ( 'ctime' => time ( ) , 'identifier' => $ identifier , 'bucket' => $ bucket , 'status' => self :: WORKER , 'socket' => $ socket_child , 'last_active' => microtime ( true ) , ) ; $ this -> forked_children_count ++ ; pcntl_async_signals ( true ) ; socket_close ( $ socket_parent ) ; $ this -> log ( 'forking child ' . $ pid . ' for bucket ' . $ bucket , self :: LOG_LEVEL_DEBUG ) ; $ this -> invoke_callback ( $ this -> parent_function_fork [ $ bucket ] , array ( $ pid , $ identifier ) , true ) ; } else { $ this -> work_units = null ; $ this -> forked_children = null ; $ this -> results = null ; $ this -> child_bucket = $ bucket ; pcntl_async_signals ( true ) ; socket_close ( $ socket_child ) ; srand ( ) ; mt_srand ( ) ; $ result = $ this -> invoke_callback ( $ this -> child_function_run [ $ bucket ] , $ work_unit , false ) ; self :: socket_send ( $ socket_parent , $ result ) ; usleep ( 500 ) ; exit ; } return $ pid ; }
Fork one child with one unit of work
52,216
protected function housekeeping_check ( ) { if ( ( time ( ) - $ this -> housekeeping_last_check ) >= $ this -> housekeeping_check_interval ) { $ this -> kill_maxtime_violators ( ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; $ this -> housekeeping_last_check = time ( ) ; } }
Performs house keeping every housekeeping_check_interval seconds
52,217
protected function kill_maxtime_violators ( ) { foreach ( $ this -> forked_children as $ pid => $ pid_info ) { if ( $ pid_info [ 'status' ] == self :: STOPPED ) { continue ; } if ( $ this -> child_max_run_time [ $ pid_info [ 'bucket' ] ] >= 0 && ( time ( ) - $ pid_info [ 'ctime' ] ) > $ this -> child_max_run_time [ $ pid_info [ 'bucket' ] ] ) { $ this -> log ( 'Force kill ' . $ pid . ' has run too long' , self :: LOG_LEVEL_INFO ) ; $ this -> invoke_callback ( $ this -> child_function_timeout { $ pid_info [ 'bucket' ] } , array ( $ pid , $ pid_info [ 'identifier' ] ) , true ) ; $ this -> safe_kill ( $ pid , SIGKILL ) ; sleep ( 3 ) ; $ this -> signal_handler_sigchild ( SIGCHLD ) ; } } }
Kills any children that have been running for too long .
52,218
protected function invoke_callback ( $ function_name , array $ parameters , $ optional = false ) { if ( is_callable ( $ function_name ) ) { if ( ! is_array ( $ parameters ) ) { $ parameters = array ( $ parameters ) ; } return call_user_func_array ( $ function_name , $ parameters ) ; } elseif ( is_array ( $ function_name ) && method_exists ( $ function_name [ 0 ] , $ function_name [ 1 ] ) ) { if ( ! is_array ( $ parameters ) ) { $ parameters = array ( $ parameters ) ; } return call_user_func_array ( $ function_name , $ parameters ) ; } elseif ( method_exists ( $ this , $ function_name ) ) { if ( ! is_array ( $ parameters ) ) { $ parameters = array ( $ parameters ) ; } return call_user_func_array ( $ this -> $ function_name , $ parameters ) ; } else if ( function_exists ( $ function_name ) ) { if ( ! is_array ( $ parameters ) ) { $ parameters = array ( $ parameters ) ; } return call_user_func_array ( $ function_name , $ parameters ) ; } else { if ( $ optional === false ) { $ this -> log ( "Error there are no functions declared in scope to handle callback for function '" . $ function_name . "'" , self :: LOG_LEVEL_CRIT ) ; } } }
Invoke a call back function with parameters
52,219
protected function ipc_init ( ) { $ domain = strtoupper ( substr ( PHP_OS , 0 , 3 ) ) == 'WIN' ? AF_INET : AF_UNIX ; $ sockets = array ( ) ; if ( socket_create_pair ( $ domain , SOCK_STREAM , 0 , $ sockets ) === false ) { $ this -> log ( 'socket_create_pair failed: ' . socket_strerror ( socket_last_error ( ) ) , self :: LOG_LEVEL_CRIT ) ; return false ; } return $ sockets ; }
Initialize interprocess communication by setting up a pair of sockets and returning them as an array .
52,220
protected function socket_send ( $ socket , $ message ) { $ serialized_message = @ serialize ( $ message ) ; if ( $ serialized_message == false ) { $ this -> log ( 'socket_send failed to serialize message' , self :: LOG_LEVEL_CRIT ) ; return false ; } $ header = pack ( 'N' , strlen ( $ serialized_message ) ) ; $ data = $ header . $ serialized_message ; $ bytes_left = strlen ( $ data ) ; while ( $ bytes_left > 0 ) { $ bytes_sent = @ socket_write ( $ socket , $ data ) ; if ( $ bytes_sent === false ) { $ this -> log ( 'socket_send error: ' . socket_strerror ( socket_last_error ( ) ) , self :: LOG_LEVEL_CRIT ) ; return false ; } $ bytes_left -= $ bytes_sent ; $ data = substr ( $ data , $ bytes_sent ) ; } return true ; }
Sends a serializable message to the socket .
52,221
protected function socket_receive ( $ socket ) { $ bytes_total = self :: SOCKET_HEADER_SIZE ; $ bytes_read = 0 ; $ have_header = false ; $ socket_message = '' ; while ( $ bytes_read < $ bytes_total ) { $ read = @ socket_read ( $ socket , $ bytes_total - $ bytes_read ) ; if ( $ read === false ) { $ this -> log ( 'socket_receive error: ' . socket_strerror ( socket_last_error ( ) ) , self :: LOG_LEVEL_CRIT ) ; return false ; } if ( $ read == '' ) { break ; } $ bytes_read += strlen ( $ read ) ; $ socket_message .= $ read ; if ( ! $ have_header && $ bytes_read >= self :: SOCKET_HEADER_SIZE ) { $ have_header = true ; list ( $ bytes_total ) = array_values ( unpack ( 'N' , $ socket_message ) ) ; $ bytes_read = 0 ; $ socket_message = '' ; } } $ message = @ unserialize ( $ socket_message ) ; return $ message ; }
Receives a serialized message from the socket .
52,222
protected function processCopyrights ( $ errorPos ) { $ copyrights = $ this -> commentParser -> getCopyrights ( ) ; $ copyright = $ copyrights [ 0 ] ; if ( $ copyright !== null ) { $ content = $ copyright -> getContent ( ) ; if ( empty ( $ content ) === true ) { $ error = 'Content missing for @copyright tag in file comment' ; $ this -> currentFile -> addError ( $ error , $ errorPos , 'MissingCopyright' ) ; } else if ( preg_match ( '/^([0-9]{4})(-[0-9]{4})? (\.*\)$/' , $ content ) === 0 ) { $ error = 'Expected "xxxx-xxxx Barracuda Networks, Inc." for copyright declaration' ; $ this -> currentFile -> addError ( $ error , $ errorPos , 'IncorrectCopyright' ) ; } } }
Copyright tag must be in the form xxxx - xxxx Barracuda Networks Inc . .
52,223
public function createClient ( $ url = null ) { if ( $ url === null ) { $ url = 'unix:///var/run/docker.sock' ; } $ browser = $ this -> browser ; if ( substr ( $ url , 0 , 7 ) === 'unix://' ) { $ browser = $ this -> browser -> withSender ( Sender :: createFromLoopUnix ( $ this -> loop , $ url ) ) ; $ url = 'http://localhost/' ; } return new Client ( $ browser -> withBase ( $ url ) ) ; }
Creates a new Client instance and helps with constructing the right Browser object for the given remote URL
52,224
public function parseJsonStream ( PromiseInterface $ promise ) { $ in = $ this -> parsePlainStream ( $ promise ) ; $ out = new ReadableStream ( ) ; if ( ! $ in -> isReadable ( ) ) { $ out -> close ( ) ; return $ out ; } $ parser = new StreamingJsonParser ( ) ; $ in -> on ( 'data' , function ( $ data ) use ( $ parser , $ out ) { $ objects = $ parser -> push ( $ data ) ; foreach ( $ objects as $ object ) { if ( isset ( $ object [ 'error' ] ) ) { $ out -> emit ( 'error' , array ( new JsonProgressException ( $ object ) , $ out ) ) ; $ out -> close ( ) ; return ; } $ out -> emit ( 'progress' , array ( $ object , $ out ) ) ; } } ) ; $ in -> on ( 'error' , function ( $ error ) use ( $ out ) { $ out -> emit ( 'error' , array ( $ error , $ out ) ) ; $ out -> close ( ) ; } ) ; $ in -> on ( 'close' , array ( $ out , 'close' ) ) ; $ out -> on ( 'close' , array ( $ in , 'close' ) ) ; return $ out ; }
Returns a readable JSON stream for the given ResponseInterface
52,225
public function parsePlainStream ( PromiseInterface $ promise ) { return Stream \ unwrapReadable ( $ promise -> then ( function ( ResponseInterface $ response ) { return $ response -> getBody ( ) ; } ) ) ; }
Returns a readable plain text stream for the given ResponseInterface
52,226
public function deferredStream ( ReadableStreamInterface $ stream , $ progressEventName ) { $ deferred = new Deferred ( function ( ) use ( $ stream ) { $ stream -> close ( ) ; throw new RuntimeException ( 'Cancelled' ) ; } ) ; if ( $ stream -> isReadable ( ) ) { $ buffered = array ( ) ; $ stream -> on ( $ progressEventName , function ( $ data ) use ( & $ buffered ) { $ buffered [ ] = $ data ; } ) ; $ stream -> on ( 'error' , function ( $ error ) use ( $ deferred ) { $ deferred -> reject ( $ error ) ; } ) ; $ stream -> on ( 'close' , function ( ) use ( $ deferred , & $ buffered ) { $ deferred -> resolve ( $ buffered ) ; } ) ; } else { $ deferred -> reject ( new RuntimeException ( 'Stream already ended, looks like it could not be opened' ) ) ; } return $ deferred -> promise ( ) ; }
Returns a promise which resolves with an array of all progress events
52,227
public function containerCreate ( $ config , $ name = null ) { return $ this -> postJson ( $ this -> uri -> expand ( '/containers/create{?name}' , array ( 'name' => $ name ) ) , $ config ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Create a container
52,228
public function containerInspect ( $ container ) { return $ this -> browser -> get ( $ this -> uri -> expand ( '/containers/{container}/json' , array ( 'container' => $ container ) ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Return low - level information on the container id
52,229
public function containerTop ( $ container , $ ps_args = null ) { return $ this -> browser -> get ( $ this -> uri -> expand ( '/containers/{container}/top{?ps_args}' , array ( 'container' => $ container , 'ps_args' => $ ps_args ) ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
List processes running inside the container id
52,230
public function containerExportStream ( $ container ) { return $ this -> streamingParser -> parsePlainStream ( $ this -> browser -> withOptions ( array ( 'streaming' => true ) ) -> get ( $ this -> uri -> expand ( '/containers/{container}/export' , array ( 'container' => $ container ) ) ) ) ; }
Export the contents of container id
52,231
public function containerResize ( $ container , $ w , $ h ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/containers/{container}/resize{?w,h}' , array ( 'container' => $ container , 'w' => $ w , 'h' => $ h , ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Resize the TTY of container id
52,232
public function containerStart ( $ container , $ config = array ( ) ) { return $ this -> postJson ( $ this -> uri -> expand ( '/containers/{container}/start' , array ( 'container' => $ container ) ) , $ config ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Start the container id
52,233
public function containerStop ( $ container , $ t = null ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/containers/{container}/stop{?t}' , array ( 'container' => $ container , 't' => $ t ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Stop the container id
52,234
public function containerKill ( $ container , $ signal = null ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/containers/{container}/kill{?signal}' , array ( 'container' => $ container , 'signal' => $ signal ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Kill the container id
52,235
public function containerRename ( $ container , $ name ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/containers/{container}/rename{?name}' , array ( 'container' => $ container , 'name' => $ name ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Rename the container id
52,236
public function containerPause ( $ container ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/containers/{container}/pause' , array ( 'container' => $ container ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Pause the container id
52,237
public function containerRemove ( $ container , $ v = false , $ force = false ) { return $ this -> browser -> delete ( $ this -> uri -> expand ( '/containers/{container}{?v,force}' , array ( 'container' => $ container , 'v' => $ this -> boolArg ( $ v ) , 'force' => $ this -> boolArg ( $ force ) ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Remove the container id from the filesystem
52,238
public function imageInspect ( $ image ) { return $ this -> browser -> get ( $ this -> uri -> expand ( '/images/{image}/json' , array ( 'image' => $ image ) ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Return low - level information on the image name
52,239
public function imageTag ( $ image , $ repo , $ tag = null , $ force = false ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/images/{image}/tag{?repo,tag,force}' , array ( 'image' => $ image , 'repo' => $ repo , 'tag' => $ tag , 'force' => $ this -> boolArg ( $ force ) ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Tag the image name into a repository
52,240
public function imageRemove ( $ image , $ force = false , $ noprune = false ) { return $ this -> browser -> delete ( $ this -> uri -> expand ( '/images/{image}{?force,noprune}' , array ( 'image' => $ image , 'force' => $ this -> boolArg ( $ force ) , 'noprune' => $ this -> boolArg ( $ noprune ) ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Remove the image name from the filesystem
52,241
public function imageSearch ( $ term ) { return $ this -> browser -> get ( $ this -> uri -> expand ( '/images/search{?term}' , array ( 'term' => $ term ) ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Search for an image on Docker Hub .
52,242
public function execCreate ( $ container , $ cmd , $ tty = false , $ stdin = false , $ stdout = true , $ stderr = true , $ user = '' , $ privileged = false ) { if ( ! is_array ( $ cmd ) ) { $ cmd = array ( 'sh' , '-c' , ( string ) $ cmd ) ; } return $ this -> postJson ( $ this -> uri -> expand ( '/containers/{container}/exec' , array ( 'container' => $ container ) ) , array ( 'Cmd' => $ cmd , 'Tty' => ! ! $ tty , 'AttachStdin' => ! ! $ stdin , 'AttachStdout' => ! ! $ stdout , 'AttachStderr' => ! ! $ stderr , 'User' => $ user , 'Privileged' => ! ! $ privileged , ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Sets up an exec instance in a running container id
52,243
public function execResize ( $ exec , $ w , $ h ) { return $ this -> browser -> post ( $ this -> uri -> expand ( '/exec/{exec}/resize{?w,h}' , array ( 'exec' => $ exec , 'w' => $ w , 'h' => $ h ) ) ) -> then ( array ( $ this -> parser , 'expectEmpty' ) ) ; }
Resizes the tty session used by the exec command id .
52,244
public function execInspect ( $ exec ) { return $ this -> browser -> get ( $ this -> uri -> expand ( '/exec/{exec}/json' , array ( 'exec' => $ exec ) ) ) -> then ( array ( $ this -> parser , 'expectJson' ) ) ; }
Returns low - level information about the exec command id .
52,245
private function authHeaders ( $ registryAuth ) { $ headers = array ( ) ; if ( $ registryAuth !== null ) { $ headers [ 'X-Registry-Auth' ] = base64_encode ( $ this -> json ( $ registryAuth ) ) ; } return $ headers ; }
Helper function to send an AuthConfig object via the X - Registry - Auth header
52,246
public function push ( $ chunk ) { $ this -> buffer .= $ chunk ; while ( $ this -> buffer !== '' ) { if ( ! isset ( $ this -> buffer [ 7 ] ) ) { break ; } $ header = unpack ( 'Cstream/x/x/x/Nlength' , substr ( $ this -> buffer , 0 , 8 ) ) ; if ( ! isset ( $ this -> buffer [ 7 + $ header [ 'length' ] ] ) ) { break ; } $ payload = substr ( $ this -> buffer , 8 , $ header [ 'length' ] ) ; $ this -> buffer = ( string ) substr ( $ this -> buffer , 8 + $ header [ 'length' ] ) ; $ this -> emit ( ( $ header [ 'stream' ] === 2 ) ? $ this -> stderrEvent : 'data' , array ( $ payload ) ) ; } }
push the given stream chunk into the parser buffer and try to extract all frames
52,247
public function fetchAll ( ApiInterface $ api , $ method , array $ parameters = [ ] ) { $ perPage = $ api -> getPerPage ( ) ; $ api -> setPerPage ( 100 ) ; try { $ result = $ this -> fetch ( $ api , $ method , $ parameters ) [ 'values' ] ; while ( $ this -> hasNext ( ) ) { $ next = $ this -> fetchNext ( ) ; $ result = array_merge ( $ result , $ next [ 'values' ] ) ; } } finally { $ api -> setPerPage ( $ perPage ) ; } return $ result ; }
Fetch all results from an api call .
52,248
public function postFetch ( ) { if ( $ response = $ this -> client -> getLastResponse ( ) ) { $ this -> pagination = ResponseMediator :: getPagination ( $ response ) ; } else { $ this -> pagination = null ; } }
Method that performs the actual work to refresh the pagination property .
52,249
public static function getContent ( ResponseInterface $ response ) { if ( $ response -> getStatusCode ( ) === 204 ) { return [ ] ; } $ body = ( string ) $ response -> getBody ( ) ; if ( ! $ body ) { return [ ] ; } if ( strpos ( $ response -> getHeaderLine ( 'Content-Type' ) , 'application/json' ) !== 0 ) { throw new DecodingFailedException ( 'The content type header was not application/json.' ) ; } return self :: jsonDecode ( $ body ) ; }
Get the decoded response content .
52,250
private static function jsonDecode ( string $ body ) { $ content = json_decode ( $ body , true ) ; if ( json_last_error ( ) !== JSON_ERROR_NONE ) { $ msg = json_last_error_msg ( ) ; throw new DecodingFailedException ( 'Failed to decode the json response body.' . ( $ msg ? " {$msg}." : '' ) ) ; } if ( ! is_array ( $ content ) ) { throw new DecodingFailedException ( 'Failed to decode the json response body. Expected to decode to an array.' ) ; } return $ content ; }
Decode the given JSON string to an array .
52,251
public static function getPagination ( ResponseInterface $ response ) { try { return array_filter ( static :: getContent ( $ response ) , function ( $ key ) { return in_array ( $ key , [ 'size' , 'page' , 'pagelen' , 'next' , 'previous' ] , true ) ; } , ARRAY_FILTER_USE_KEY ) ; } catch ( DecodingFailedException $ e ) { return [ ] ; } }
Get the pagination data from the response .
52,252
protected function buildAttachmentsPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'issues' , $ this -> issue , 'attachments' , ... $ parts ) ; }
Build the attachments path from the given parts .
52,253
private static function handleError ( int $ status , string $ message = null ) { if ( $ status === 400 ) { throw new BadRequestException ( $ message , $ status ) ; } if ( $ status === 422 ) { throw new ValidationFailedException ( $ message , $ status ) ; } if ( $ status === 429 ) { throw new ApiLimitExceededException ( $ message , $ status ) ; } if ( $ status < 500 ) { throw new ClientErrorException ( $ message , $ status ) ; } throw new ServerErrorException ( $ message , $ status ) ; }
Handle an error response .
52,254
private static function getMessage ( ResponseInterface $ response ) { try { if ( $ error = ResponseMediator :: getContent ( $ response ) [ 'error' ] ?? null ) { if ( $ message = $ error [ 'message' ] ?? null ) { if ( $ detail = $ error [ 'detail' ] ?? null ) { return sprintf ( '%s: %s' , $ message , strtok ( $ detail , "\n" ) ) ; } else { return $ message ; } } } } catch ( DecodingFailedException $ e ) { } }
Get the error message from the response if present .
52,255
protected function buildChangesPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'issues' , $ this -> issue , 'changes' , ... $ parts ) ; }
Build the changes path from the given parts .
52,256
protected function buildPatchPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'pullrequests' , $ this -> pr , 'patch' , ... $ parts ) ; }
Build the patch path from the given parts .
52,257
protected function buildWatchingPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'issues' , $ this -> issue , 'watch' , ... $ parts ) ; }
Build the watching path from the given parts .
52,258
protected function buildCommitsPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'pullrequests' , $ this -> pr , 'commits' , ... $ parts ) ; }
Build the commits path from the given parts .
52,259
protected function buildDiffPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'pullrequests' , $ this -> pr , 'diff' , ... $ parts ) ; }
Build the diff path from the given parts .
52,260
protected function buildExecutionsPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'pipelines_config' , 'schedules' , $ this -> schedule , 'executions' , ... $ parts ) ; }
Build the executions path from the given parts .
52,261
protected function buildStepsPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'pipelines' , $ this -> pipeline , 'steps' , ... $ parts ) ; }
Build the steps path from the given parts .
52,262
protected function buildBuildPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'commit' , $ this -> commit , 'statuses' , 'build' , ... $ parts ) ; }
Build the build path from the given parts .
52,263
protected function post ( string $ path , array $ params = [ ] , array $ headers = [ ] ) { $ body = self :: createJsonBody ( $ params ) ; if ( $ body ) { $ headers = self :: addJsonContentType ( $ headers ) ; } return $ this -> postRaw ( $ path , $ body , $ headers ) ; }
Send a POST request with JSON - encoded params .
52,264
protected function put ( string $ path , array $ params = [ ] , array $ headers = [ ] ) { $ body = self :: createJsonBody ( $ params ) ; if ( $ body ) { $ headers = self :: addJsonContentType ( $ headers ) ; } return $ this -> putRaw ( $ path , $ body , $ headers ) ; }
Send a PUT request with JSON - encoded params .
52,265
protected function delete ( string $ path , array $ params = [ ] , array $ headers = [ ] ) { $ body = self :: createJsonBody ( $ params ) ; if ( $ body ) { $ headers = self :: addJsonContentType ( $ headers ) ; } return $ this -> deleteRaw ( $ path , $ body , $ headers ) ; }
Send a DELETE request with JSON - encoded params .
52,266
protected static function buildPath ( string ... $ parts ) { $ parts = array_map ( function ( string $ part ) { if ( ! $ part ) { throw new InvalidArgumentException ( 'Missing required parameter.' ) ; } return self :: urlEncode ( $ part ) ; } , $ parts ) ; return implode ( '/' , $ parts ) ; }
Build a URL path from the given parts .
52,267
protected function buildPatchesPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , $ this -> repo , 'patch' , ... $ parts ) ; }
Build the patches path from the given parts .
52,268
protected function buildVotingPath ( string ... $ parts ) { return static :: buildPath ( 'repositories' , $ this -> username , $ this -> repo , 'issues' , $ this -> issue , 'vote' , ... $ parts ) ; }
Build the voting path from the given parts .
52,269
protected function parseFunction ( FunctionLike $ node , FunctionModelInterface $ function ) : void { foreach ( $ node -> getParams ( ) as $ param ) { $ this -> parameterNodeParser -> invoke ( $ param , $ function ) ; } $ return = new ReturnModel ( ) ; $ return -> setParentNode ( $ function ) ; if ( $ node -> getReturnType ( ) !== null ) { $ this -> typeNodeParser -> invoke ( $ node -> getReturnType ( ) , $ return ) ; } $ function -> setReturn ( $ return ) ; }
Parse a function like node to update a function model .
52,270
public function invoke ( DocumentationInterface $ parent , string $ documentation ) : void { try { $ this -> tokenConsumer -> initialize ( ) ; $ this -> annotationLexer -> setInput ( $ documentation ) ; $ this -> annotationLexer -> moveNext ( ) ; $ this -> annotationLexer -> moveNext ( ) ; while ( $ this -> annotationLexer -> token ) { $ this -> parse ( $ this -> annotationLexer -> token [ 'type' ] , $ this -> annotationLexer -> token [ 'value' ] ) ; $ this -> annotationLexer -> moveNext ( ) ; $ this -> annotationLexer -> moveNext ( ) ; } $ this -> tokenConsumer -> finalize ( ) ; $ this -> annotationRegister -> invoke ( $ parent , $ this -> tokenConsumer -> getParsedAnnotations ( ) ) ; } catch ( AnnotationParseException $ exception ) { throw new AnnotationParseException ( $ exception -> getMessage ( ) ) ; } }
Parse a documentation to add annotations to parent .
52,271
private function parse ( int $ type , string $ value ) : void { switch ( $ type ) { case AnnotationLexer :: T_ANNOTATION : $ this -> tokenConsumer -> consumeAnnotationToken ( $ value ) ; break ; case AnnotationLexer :: T_O_PARENTHESIS : $ this -> tokenConsumer -> consumeOpeningParenthesisToken ( ) ; $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; break ; case AnnotationLexer :: T_C_PARENTHESIS : $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; $ this -> tokenConsumer -> consumeClosingParenthesisToken ( ) ; break ; case AnnotationLexer :: T_SINGLE_QUOTE : case AnnotationLexer :: T_DOUBLE_QUOTE : $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; $ this -> tokenConsumer -> consumeQuoteToken ( $ type ) ; break ; case AnnotationLexer :: T_ASTERISK : if ( $ this -> tokenConsumer -> hasOpenedString ( ) ) { $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; } break ; case AnnotationLexer :: T_LINE_BREAK : $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; $ this -> tokenConsumer -> increaseLine ( ) ; break ; case AnnotationLexer :: T_BACKSLASH : case AnnotationLexer :: T_WHITESPACE : case AnnotationLexer :: T_OTHER : $ this -> tokenConsumer -> addTokenToContent ( $ value ) ; break ; default : throw new AnnotationParseException ( sprintf ( 'A token of value "%s" has an invalid type' , $ value ) ) ; } $ this -> tokenConsumer -> afterConsume ( $ type ) ; }
Parse a token with a value and type and consume it depending on type .
52,272
private function getClassType ( $ node , TypeInterface $ parent ) : string { $ phpFile = RootRetrieverHelper :: getRoot ( $ parent ) ; switch ( true ) { case $ node instanceof Node \ Identifier : case $ node -> isRelative ( ) : case $ node -> isUnqualified ( ) : $ name = $ this -> getUnqualifiedClassType ( $ node , $ phpFile ) ; break ; case $ node -> isFullyQualified ( ) : $ name = $ node -> toString ( ) ; break ; case $ node -> isQualified ( ) : $ name = $ this -> getQualifiedClassType ( $ node , $ phpFile ) ; break ; default : return TypeInterface :: UNKNOWN_CUSTOM ; } $ nameArray = explode ( '\\' , $ name ) ; $ lastPart = end ( $ nameArray ) ; $ phpFile -> addConcreteUse ( $ name , $ lastPart ) ; return $ lastPart ; }
Get the class type hint as a string .
52,273
private function getUnqualifiedClassType ( $ node , PhpFileModelInterface $ phpFile ) : string { $ name = $ node -> toString ( ) ; if ( $ phpFile -> hasUse ( $ name ) ) { return $ phpFile -> getUse ( $ name ) ; } $ namespace = $ phpFile -> getNamespaceString ( ) ; if ( $ namespace !== null ) { $ namespace = $ namespace . '\\' ; } return $ namespace . $ name ; }
Retrieve the class type hint when it is unqualified .
52,274
private function getQualifiedClassType ( Node \ Name $ node , PhpFileModelInterface $ phpFile ) : string { $ path = $ node -> toString ( ) ; $ firstPart = $ node -> getFirst ( ) ; if ( $ phpFile -> hasUse ( $ firstPart ) ) { return str_replace ( $ firstPart , $ phpFile -> getUse ( $ firstPart ) , $ path ) ; } if ( $ phpFile -> getNamespace ( ) !== null && $ firstPart === $ phpFile -> getNamespace ( ) [ count ( $ phpFile -> getNamespace ( ) ) - 1 ] ) { return str_replace ( $ firstPart , $ phpFile -> getNamespaceString ( ) , $ path ) ; } return $ phpFile -> getNamespaceString ( ) . '\\' . $ path ; }
Retrieve the class type hint when it is qualified .
52,275
public static function decode ( $ string ) { if ( ! is_string ( $ string ) ) { throw new JsonException ( 'Json decode parameter must be a string' ) ; } $ result = json_decode ( $ string , true ) ; if ( $ result === null ) { throw new JsonException ( 'Json decode error' ) ; } return $ result ; }
Decode a Json string to return an array content .
52,276
protected function hasNodeParser ( string $ class ) : bool { if ( Validator :: key ( $ class , Validator :: instance ( NodeParserInterface :: class ) ) -> validate ( $ this -> nodeParsers ) ) { return true ; } return false ; }
Check if this node parser instance has a node parser .
52,277
public function invoke ( string $ name , int $ line ) : AnnotationInterface { $ name = preg_replace ( '/@(?i)(PhpUnitGen|Pug)\\\\/' , '' , $ name ) ; switch ( true ) { case strcasecmp ( $ name , 'get' ) === 0 : $ annotation = new GetAnnotation ( ) ; break ; case strcasecmp ( $ name , 'set' ) === 0 : $ annotation = new SetAnnotation ( ) ; break ; case strcasecmp ( $ name , 'construct' ) === 0 : $ annotation = new ConstructAnnotation ( ) ; break ; case strcasecmp ( $ name , 'mock' ) === 0 : $ annotation = new MockAnnotation ( ) ; break ; case strcasecmp ( $ name , 'params' ) === 0 : $ annotation = new ParamsAnnotation ( ) ; break ; case strcasecmp ( substr ( $ name , 0 , 6 ) , 'assert' ) === 0 : $ annotation = new AssertAnnotation ( ) ; break ; default : throw new AnnotationParseException ( sprintf ( 'Annotation of name "%s" is unknown' , $ name ) ) ; } $ annotation -> setName ( $ name ) ; $ annotation -> setLine ( $ line ) ; return $ annotation ; }
Build an annotation from a name and a content .
52,278
public static function getName ( Node \ Stmt \ ClassLike $ node ) : string { if ( $ node -> name === null ) { return NameInterface :: UNKNOWN_NAME ; } return $ node -> name ; }
Get the name of a node .
52,279
public function set ( string $ id , string $ class = null ) : void { $ this -> autoResolvable [ $ id ] = $ class ?? $ id ; }
Add to available services a class which can be construct by the container resolve method .
52,280
private function resolveInstance ( string $ id ) { if ( Validator :: key ( $ id ) -> validate ( $ this -> instances ) ) { return $ this -> instances [ $ id ] ; } return $ this -> resolveAutomaticResolvable ( $ id ) ; }
Try to retrieve a service instance from the instances array .
52,281
private function resolveAutomaticResolvable ( string $ id ) { if ( Validator :: key ( $ id ) -> validate ( $ this -> autoResolvable ) ) { return $ this -> instances [ $ id ] = $ this -> autoResolve ( $ this -> autoResolvable [ $ id ] ) ; } return $ this -> autoResolve ( $ id ) ; }
Try to retrieve a service instance from the automatic resolvable array .
52,282
private function autoResolve ( string $ class ) { try { $ reflection = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ exception ) { throw new ContainerException ( sprintf ( 'Class "%s" does not exists' , $ class ) ) ; } if ( ! $ reflection -> isInstantiable ( ) ) { throw new ContainerException ( sprintf ( 'Class "%s" is not instantiable' , $ class ) ) ; } return $ this -> buildInstance ( $ reflection ) ; }
Try to automatically create a service .
52,283
private function buildInstance ( \ ReflectionClass $ reflection ) { if ( ( $ constructor = $ reflection -> getConstructor ( ) ) === null ) { return $ reflection -> newInstance ( ) ; } $ constructorParameters = [ ] ; foreach ( $ constructor -> getParameters ( ) as $ parameter ) { if ( ( $ parameterClass = $ parameter -> getClass ( ) ) === null ) { throw new ContainerException ( sprintf ( 'Class "%s" constructor has a scalar / callable / array type parameter' , $ reflection -> getName ( ) ) ) ; } $ constructorParameters [ ] = $ this -> get ( $ parameterClass -> getName ( ) ) ; } return $ reflection -> newInstanceArgs ( $ constructorParameters ) ; }
Build a new instance of a class from reflection class and auto - resolved constructor arguments .
52,284
protected function doRunParent ( InputInterface $ input , OutputInterface $ output ) : int { return parent :: doRun ( $ input , $ output ) ; }
Run the doRun from parent .
52,285
private function validateType ( int $ type ) : bool { return $ type === Node \ Stmt \ Use_ :: TYPE_NORMAL || $ type === Node \ Stmt \ Use_ :: TYPE_UNKNOWN ; }
Validate a use type .
52,286
public function invoke ( DocumentationInterface $ parent , array $ annotations ) : void { foreach ( $ annotations as $ annotation ) { if ( $ parent instanceof FunctionModelInterface ) { $ this -> saveFunctionAnnotation ( $ parent , $ annotation ) ; } if ( $ parent instanceof InterfaceModelInterface ) { $ this -> saveClassLikeAnnotation ( $ parent , $ annotation ) ; } } }
Register all annotations in the parent depending on annotation type .
52,287
private function saveFunctionAnnotation ( FunctionModelInterface $ parent , AnnotationInterface $ annotation ) : void { if ( ! $ parent -> isGlobal ( ) && $ parent -> isPublic ( ) ) { if ( $ annotation -> getType ( ) !== AnnotationInterface :: TYPE_CONSTRUCT ) { $ annotation -> setParentNode ( $ parent ) ; $ parent -> addAnnotation ( $ annotation ) ; $ annotation -> compile ( ) ; } } else { if ( Validator :: contains ( $ annotation -> getType ( ) ) -> validate ( AnnotationRegister :: ALLOWED_ON_GLOBAL_OR_PRIVATE ) ) { $ annotation -> setParentNode ( $ parent ) ; $ parent -> addAnnotation ( $ annotation ) ; $ annotation -> compile ( ) ; } } }
Register an annotation for a function .
52,288
private function saveClassLikeAnnotation ( InterfaceModelInterface $ parent , AnnotationInterface $ annotation ) : void { if ( $ annotation -> getType ( ) === AnnotationInterface :: TYPE_MOCK ) { $ parent = $ parent -> getParentNode ( ) ; $ annotation -> setParentNode ( $ parent ) ; $ parent -> addAnnotation ( $ annotation ) ; $ annotation -> compile ( ) ; } else { if ( $ annotation -> getType ( ) === AnnotationInterface :: TYPE_CONSTRUCT ) { $ annotation -> setParentNode ( $ parent ) ; $ parent -> addAnnotation ( $ annotation ) ; $ annotation -> compile ( ) ; } } }
Register an annotation for an interface a trait or a class .
52,289
public function hasFunction ( string $ name ) : bool { return $ this -> functions -> exists ( function ( int $ key , FunctionModelInterface $ function ) use ( $ name ) { return $ function -> getName ( ) === $ name ; } ) ; }
Check if a function exists .
52,290
public function getFunction ( string $ name ) : ? FunctionModelInterface { $ functions = $ this -> functions -> filter ( function ( FunctionModelInterface $ function ) use ( $ name ) { return $ function -> getName ( ) === $ name ; } ) ; if ( $ functions -> isEmpty ( ) ) { return null ; } return $ functions -> first ( ) ; }
Get a function if the function exists .
52,291
private function executeOnDirectories ( ) : void { foreach ( $ this -> config -> getDirectories ( ) as $ source => $ target ) { try { $ this -> directoryExecutor -> invoke ( $ source , $ target ) ; $ this -> report -> increaseParsedDirectoryNumber ( ) ; } catch ( Exception $ exception ) { $ this -> exceptionCatcher -> catch ( $ exception , $ source ) ; } } }
Execute PhpUnitGen tasks on directories .
52,292
private function executeOnFiles ( ) : void { foreach ( $ this -> config -> getFiles ( ) as $ source => $ target ) { try { $ name = pathinfo ( $ target ) [ 'filename' ] ; $ this -> fileExecutor -> invoke ( $ source , $ target , $ name ) ; } catch ( Exception $ exception ) { $ this -> exceptionCatcher -> catch ( $ exception , $ source ) ; } } }
Execute PhpUnitGen tasks on files .
52,293
private function validateBooleans ( $ config ) : void { if ( ! Validator :: key ( 'overwrite' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"overwrite" parameter must be set as a boolean.' ) ; } if ( ! Validator :: key ( 'backup' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"backup" parameter must be set as a boolean.' ) ; } if ( ! Validator :: key ( 'ignore' , Validator :: boolType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"ignore" parameter must be set as a boolean.' ) ; } }
Validate all boolean attributes contained in configuration .
52,294
private function validateIncludeRegex ( $ config ) : void { if ( ! Validator :: key ( 'include' , Validator :: stringType ( ) ) -> validate ( $ config ) && ! Validator :: key ( 'include' , Validator :: nullType ( ) ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"include" parameter must be set as a string or a null value.' ) ; } }
Validate the include regex .
52,295
private function validateDirs ( $ config ) : void { if ( ! Validator :: key ( 'dirs' ) -> validate ( $ config ) ) { throw new InvalidConfigException ( '"dirs" parameter is not an array.' ) ; } if ( $ config [ 'dirs' ] === null ) { $ this -> config [ 'dirs' ] = $ config [ 'dirs' ] = [ ] ; } if ( ! Validator :: arrayVal ( ) -> each ( Validator :: stringType ( ) , Validator :: stringType ( ) ) -> validate ( $ config [ 'dirs' ] ) ) { throw new InvalidConfigException ( 'Some directories in "dirs" parameter are not strings.' ) ; } }
Validate directories contained in configuration .
52,296
public function reset ( ) : void { $ this -> currentAnnotation = null ; $ this -> currentAnnotationContent = null ; $ this -> openedStringToken = null ; $ this -> currentlyEscaping = false ; $ this -> openedParenthesis = 0 ; }
Reset an annotation parsing .
52,297
public function finalize ( ) : void { if ( $ this -> currentAnnotation !== null ) { if ( $ this -> currentAnnotationContent === null ) { $ this -> parsedAnnotations [ ] = $ this -> currentAnnotation ; } else { throw new AnnotationParseException ( 'An annotation content is not closed (you probably forget to close a parenthesis or a quote)' ) ; } } }
Finalize the documentation parsing process .
52,298
public function consumeOpeningParenthesisToken ( ) : void { if ( $ this -> currentAnnotation !== null && $ this -> openedStringToken === null ) { if ( $ this -> currentAnnotationContent === null ) { if ( $ this -> currentAnnotation -> getLine ( ) === $ this -> currentLine ) { $ this -> currentAnnotationContent = '' ; $ this -> openedParenthesis ++ ; } } else { $ this -> openedParenthesis ++ ; } } }
Consume an opening parenthesis token .
52,299
public function consumeClosingParenthesisToken ( ) : void { if ( $ this -> currentAnnotationContent !== null && $ this -> openedStringToken === null ) { if ( $ this -> openedParenthesis > 0 ) { $ this -> openedParenthesis -- ; if ( $ this -> openedParenthesis === 0 ) { $ this -> currentAnnotation -> setStringContent ( substr ( $ this -> currentAnnotationContent , 1 , strlen ( $ this -> currentAnnotationContent ) - 2 ) ) ; $ this -> parsedAnnotations [ ] = $ this -> currentAnnotation ; $ this -> reset ( ) ; } } } }
Consume an closing parenthesis token .