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_...
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 ( $ th...
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 f...
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 ) ...
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 \...
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 tr...
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' ] ; } } ...
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 -> par...
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 ] ...
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...
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 [ $ p...
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_nam...
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 :...
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 =...
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...
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 com...
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://loca...
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 , ...
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 ( $ progressEvent...
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 ( ...
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 ...
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 ( ...
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...
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 ; } $...
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 = ...
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 De...
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 ( $ con...
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 ) {...
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 (...
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 ,...
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 -> getReturn...
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 -> annotationL...
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 -> tokenCons...
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 , $ p...
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...
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 ( $ ph...
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 ...
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 ( ...
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 ->...
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 -> saveCl...
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 -> ...
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 ( $ annota...
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 -> ...
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 ( $ except...
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...
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 s...
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 ...
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 pare...
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 = '' ; $...
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 ( ...
Consume an closing parenthesis token .