idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
47,200 | public static function show ( array $ config ) : void { $ parts = [ ] ; $ option = [ 'indentDes' => ' ' , ] ; $ config = \ array_merge ( [ 'description' => '' , 'usage' => '' , 'commands' => [ ] , 'arguments' => [ ] , 'options' => [ ] , 'examples' => [ ] , 'extras' => [ ] , '_opts' => [ ] , ] , $ config ) ; if ( isset... | Show console help message |
47,201 | public function packCommand ( $ in , $ out ) : int { $ time = \ microtime ( 1 ) ; $ workDir = $ in -> getPwd ( ) ; $ dir = $ in -> getOpt ( 'dir' ) ? : $ workDir ; $ cpr = $ this -> configCompiler ( $ dir ) ; $ counter = null ; $ refresh = $ in -> boolOpt ( 'refresh' ) ; $ pharFile = $ workDir . '/' . $ in -> sameOpt (... | pack project to a phar package |
47,202 | public function unpackCommand ( $ in , $ out ) : int { if ( ! $ path = $ in -> getSameOpt ( [ 'f' , 'file' ] ) ) { return $ out -> error ( "Please input the phar file path by option '-f|--file'" ) ; } $ basePath = $ in -> getPwd ( ) ; $ file = \ realpath ( $ basePath . '/' . $ path ) ; if ( ! \ file_exists ( $ file ) )... | unpack a phar package to a directory |
47,203 | public function execute ( $ in , $ out ) { if ( ! $ server = $ this -> getOpt ( 'S' ) ) { $ server = $ this -> getSameOpt ( [ 'H' , 'host' ] , '127.0.0.1' ) ; } if ( ! \ strpos ( $ server , ':' ) ) { $ port = $ this -> getSameOpt ( [ 'p' , 'port' ] , 8552 ) ; $ server .= ':' . $ port ; } $ version = \ PHP_VERSION ; $ w... | start a php built - in http server for development |
47,204 | protected function loadInternalFonts ( ) : void { $ path = \ dirname ( __DIR__ ) . '/BuiltIn/Resources/art-fonts/' ; $ group = self :: INTERNAL_GROUP ; foreach ( self :: $ internalFonts as $ font ) { $ this -> fonts [ $ group ] [ $ font ] = $ path . $ font . '%s.txt' ; } $ this -> groups [ $ group ] = $ path ; } | load Internal Fonts |
47,205 | public function showInternal ( string $ name , array $ opts = [ ] ) : int { return $ this -> show ( $ name , self :: INTERNAL_GROUP , $ opts ) ; } | display the internal art font |
47,206 | public function show ( string $ name , string $ group = null , array $ opts = [ ] ) : int { $ opts = array_merge ( [ 'type' => '' , 'indent' => 2 , 'style' => '' , ] , $ opts ) ; $ type = $ opts [ 'type' ] ; $ pfxType = $ type ? '_' . $ type : '' ; $ txt = '' ; $ group = trim ( $ group ) ; $ group = $ group ? : self ::... | display the art font |
47,207 | public function on ( string $ event , callable $ handler , $ once = false ) : void { if ( self :: isSupportedEvent ( $ event ) ) { self :: $ eventHandlers [ $ event ] [ ] = $ handler ; if ( ! isset ( self :: $ events [ $ event ] ) ) { self :: $ events [ $ event ] = ( bool ) $ once ; } } } | register a event handler |
47,208 | public function once ( string $ event , callable $ handler ) : void { $ this -> on ( $ event , $ handler , true ) ; } | register a once event handler |
47,209 | protected function loadDefaultStyles ( ) : void { $ this -> addByArray ( self :: NORMAL , [ 'fg' => 'normal' ] ) -> addByArray ( self :: FAINTLY , [ 'fg' => 'normal' , 'options' => [ 'italic' ] ] ) -> addByArray ( self :: BOLD , [ 'options' => [ 'bold' ] ] ) -> addByArray ( self :: INFO , [ 'fg' => 'green' , ] ) -> add... | Adds predefined color styles to the Color styles default primary success info warning danger |
47,210 | public function apply ( string $ style , string $ text ) : string { return $ this -> format ( self :: wrap ( $ text , $ style ) ) ; } | Process a string use style |
47,211 | public function add ( string $ name , $ fg = '' , $ bg = '' , array $ options = [ ] , bool $ extra = false ) : self { if ( \ is_array ( $ fg ) ) { return $ this -> addByArray ( $ name , $ fg ) ; } if ( \ is_object ( $ fg ) && $ fg instanceof Color ) { $ this -> styles [ $ name ] = $ fg ; } else { $ this -> styles [ $ n... | Add a style . |
47,212 | public function addByArray ( string $ name , array $ styleConfig ) : self { $ style = [ 'fg' => '' , 'bg' => '' , 'extra' => false , 'options' => [ ] ] ; $ config = \ array_merge ( $ style , $ styleConfig ) ; [ $ fg , $ bg , $ extra , $ options ] = \ array_values ( $ config ) ; $ this -> styles [ $ name ] = Color :: ma... | Add a style by an array config |
47,213 | public static function show ( array $ data , array $ opts = [ ] ) : void { $ stringList = [ ] ; $ ignoreEmpty = $ opts [ 'ignoreEmpty' ] ?? true ; $ lastNewline = true ; $ opts [ 'returned' ] = true ; if ( isset ( $ opts [ 'lastNewline' ] ) ) { $ lastNewline = $ opts [ 'lastNewline' ] ; unset ( $ opts [ 'lastNewline' ]... | Format and render multi list |
47,214 | public function setForeground ( $ color = null ) { if ( null === $ color ) { $ this -> foreground = null ; return ; } if ( ! isset ( static :: $ availableForegroundColors [ $ color ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid foreground color specified: "%s". Expected one of (%s)' , $ color , implo... | Sets style foreground color . |
47,215 | public function setBackground ( $ color = null ) { if ( null === $ color ) { $ this -> background = null ; return ; } if ( ! isset ( static :: $ availableBackgroundColors [ $ color ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid background color specified: "%s". Expected one of (%s)' , $ color , implo... | Sets style background color . |
47,216 | public function setOption ( $ option ) { if ( ! isset ( static :: $ availableOptions [ $ option ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid option specified: "%s". Expected one of (%s)' , $ option , implode ( ', ' , array_keys ( static :: $ availableOptions ) ) ) ) ; } if ( ! in_array ( static :: ... | Sets some specific style option . |
47,217 | public function unsetOption ( $ option ) { if ( ! isset ( static :: $ availableOptions [ $ option ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid option specified: "%s". Expected one of (%s)' , $ option , implode ( ', ' , array_keys ( static :: $ availableOptions ) ) ) ) ; } $ pos = array_search ( sta... | Unsets some specific style option . |
47,218 | public static function readln ( $ message = null , $ nl = false , array $ opts = [ ] ) : string { if ( $ message ) { Console :: write ( $ message , $ nl ) ; } $ stream = $ opts [ 'stream' ] ?? \ STDIN ; return \ trim ( fgets ( $ stream ) ) ; } | read line from CLI input |
47,219 | public static function question ( string $ question , string $ default = '' , \ Closure $ validator = null ) : string { return Question :: ask ( $ question , $ default , $ validator ) ; } | Ask a question ask for results ; return the result of the input |
47,220 | public static function limitedAsk ( string $ question , string $ default = '' , \ Closure $ validator = null , int $ times = 3 ) : string { return LimitedAsk :: ask ( $ question , $ default , $ validator , $ times ) ; } | Ask a question ask for a limited number of times |
47,221 | private function packFile ( \ Phar $ phar , \ SplFileInfo $ file ) : void { if ( ! \ file_exists ( $ file ) ) { $ this -> reportError ( "File $file is not exists!" ) ; return ; } $ this -> counter ++ ; $ path = $ this -> getRelativeFilePath ( $ file ) ; $ strip = $ this -> stripComments ; $ content = \ file_get_content... | Add a file to the Phar . |
47,222 | private function collectInformation ( ) : void { if ( ! $ this -> collectVersionInfo ) { return ; } $ basePath = $ this -> basePath ; [ $ code , $ ret , ] = Sys :: run ( 'git log --pretty="%H" -n1 HEAD' , $ basePath ) ; if ( $ code !== 0 ) { throw new \ RuntimeException ( 'Can\'t run git log. You must ensure to run com... | auto collect project information by git log |
47,223 | public function on ( string $ event , \ Closure $ closure ) : void { $ this -> events [ $ event ] = $ closure ; } | add event handler |
47,224 | protected function registerErrorHandle ( ) : void { \ set_error_handler ( [ $ this , 'handleError' ] ) ; \ set_exception_handler ( [ $ this , 'handleException' ] ) ; \ register_shutdown_function ( function ( ) { if ( $ e = \ error_get_last ( ) ) { $ this -> handleError ( $ e [ 'type' ] , $ e [ 'message' ] , $ e [ 'file... | register error handle |
47,225 | public function getParser ( string $ section , bool $ throwException = false ) { if ( ! self :: $ parsers ) { self :: $ parsers = self :: loadDefaultParsers ( ) ; } if ( isset ( self :: $ parsers [ $ section ] ) ) { return self :: $ parsers [ $ section ] ; } if ( $ throwException ) { throw new \ RuntimeException ( "The... | get section Parser |
47,226 | public function getCompleteChar ( ) : string { if ( null === $ this -> completeChar ) { return $ this -> maxSteps ? '=' : $ this -> completeChar ; } return $ this -> completeChar ; } | Gets the complete bar character . |
47,227 | protected function defArgConfigure ( ) : void { $ this -> createDefinition ( ) -> setDescription ( 'the command arg/opt config use defined configure, it like symfony console: argument define by position' ) -> addArgument ( 'name' , Input :: ARG_REQUIRED , "description for the argument 'name'" ) -> addOption ( 'yes' , '... | command defArgCommand config |
47,228 | public function subRunCommand ( ) : void { $ this -> writeln ( 'hello this is: ' . __METHOD__ ) ; $ this -> getApp ( ) -> subRun ( 'test' , $ this -> input , $ this -> output ) ; } | will run other command in the command . |
47,229 | public function colorCheckCommand ( ) : void { $ this -> output -> aList ( [ 'basic color output?' => Cli :: isSupportColor ( ) ? '<info>Y</info>' : 'N' , 'ansi char output?' => Cli :: isAnsiSupport ( ) ? 'Y' : 'N' , '256 color output?' => Cli :: isSupport256Color ( ) ? 'Y' : 'N' , 'font symbol output?' => Cli :: isSup... | check color support for current env . |
47,230 | public function artFontCommand ( ) : int { $ name = $ this -> input -> getLongOpt ( 'font' , '404' ) ; if ( ! ArtFont :: isInternalFont ( $ name ) ) { return $ this -> output -> liteError ( "Your input font name: $name, is not exists. Please use '-h' see allowed." ) ; } ArtFont :: create ( ) -> show ( $ name , ArtFont ... | output art font text |
47,231 | public function progressBarCommand ( ) : void { $ i = 0 ; $ total = 120 ; $ bar = new ProgressBar ( ) ; $ bar -> start ( 120 ) ; while ( $ i <= $ total ) { $ bar -> advance ( ) ; usleep ( 50000 ) ; $ i ++ ; } $ bar -> finish ( ) ; } | a progress bar example show by class ProgressBar |
47,232 | public function useArgCommand ( ) : void { $ this -> write ( 'input arguments:' ) ; $ this -> output -> dump ( $ this -> input -> getArgs ( ) ) ; $ this -> write ( 'input options:' ) ; $ this -> output -> dump ( $ this -> input -> getOpts ( ) ) ; $ this -> write ( 'raw argv:' ) ; $ this -> output -> dump ( $ this -> in... | a example for use arguments on command |
47,233 | public function envCommand ( ) : void { $ info = [ 'phpVersion' => PHP_VERSION , 'env' => 'test' , 'debug' => true , ] ; Show :: panel ( $ info ) ; echo Php :: printVars ( $ _SERVER ) ; } | output current env info |
47,234 | public function downCommand ( ) : int { $ url = $ this -> input -> getArg ( 'url' ) ; if ( ! $ url ) { $ this -> output -> liteError ( 'Please input you want to downloaded file url, use: url=[url]' , 1 ) ; } $ saveAs = $ this -> input -> getArg ( 'saveAs' ) ; $ type = $ this -> input -> getArg ( 'type' , 'text' ) ; if ... | This is a demo for download a file to local |
47,235 | public static function ask ( string $ question , bool $ default = true ) : bool { if ( ! $ question = \ trim ( $ question ) ) { Show :: warning ( 'Please provide a question message!' , 1 ) ; return false ; } $ defText = $ default ? 'yes' : 'no' ; $ question = \ ucfirst ( \ trim ( $ question , '?' ) ) ; $ message = "<co... | Send a message request confirmation |
47,236 | public function cursorCommand ( ) : void { $ this -> write ( 'hello, this in ' . __METHOD__ ) ; $ this -> write ( 'this is a message text.' , false ) ; sleep ( 1 ) ; Terminal :: make ( ) -> cursor ( Terminal :: CUR_BACKWARD , 6 ) ; sleep ( 1 ) ; Terminal :: make ( ) -> cursor ( Terminal :: CUR_FORWARD , 3 ) ; sleep ( 1... | This is a demo for show cursor move on the Terminal screen |
47,237 | public static function wrapText ( $ text , $ indent = 0 , $ width = 0 ) : string { if ( ! $ text ) { return $ text ; } if ( ( int ) $ width <= 0 ) { $ size = Sys :: getScreenSize ( ) ; if ( $ size === false || $ size [ 0 ] <= $ indent ) { return $ text ; } $ width = $ size [ 0 ] ; } $ pad = \ str_repeat ( ' ' , $ inden... | Word wrap text with indentation to fit the screen size |
47,238 | public static function howLongAgo ( int $ secs ) : string { static $ timeFormats = [ [ 0 , '< 1 sec' ] , [ 1 , '1 sec' ] , [ 2 , 'secs' , 1 ] , [ 60 , '1 min' ] , [ 120 , 'mins' , 60 ] , [ 3600 , '1 hr' ] , [ 7200 , 'hrs' , 3600 ] , [ 86400 , '1 day' ] , [ 172800 , 'days' , 86400 ] , ] ; foreach ( $ timeFormats as $ in... | format timestamp to how long ago |
47,239 | public static function gen ( int $ total , array $ opts = [ ] ) : \ Generator { $ current = 0 ; $ finished = false ; $ tplPrefix = Cli :: isSupportColor ( ) ? "\x0D\x1B[2K" : "\x0D\r" ; $ opts = \ array_merge ( [ 'doneChar' => '=' , 'waitChar' => ' ' , 'signChar' => '>' , 'msg' => '' , 'doneMsg' => '' , ] , $ opts ) ; ... | Render a simple progress bar by yield |
47,240 | public function addArg ( string $ name , int $ mode = null , string $ description = '' , $ default = null ) : self { return $ this -> addArgument ( $ name , $ mode , $ description , $ default ) ; } | alias of the addArgument |
47,241 | public function setOptions ( array $ options = [ ] ) : void { $ this -> options = $ this -> shortcuts = [ ] ; $ this -> addOptions ( $ options ) ; } | Sets the options |
47,242 | public function addOptions ( array $ options = [ ] ) : void { foreach ( $ options as $ name => $ opt ) { $ opt = $ this -> mergeArgOptConfig ( $ opt ) ; $ this -> addOption ( $ name , $ opt [ 'mode' ] , $ opt [ 'description' ] , $ opt [ 'default' ] ) ; } } | Adds an array of option |
47,243 | public function getSynopsis ( bool $ short = false ) : array { $ elements = $ args = $ opts = [ ] ; if ( $ short && $ this -> options ) { $ elements [ ] = '[options]' ; } elseif ( ! $ short ) { foreach ( $ this -> options as $ name => $ option ) { $ value = '' ; if ( $ this -> optionIsAcceptValue ( $ option [ 'mode' ] ... | Gets the synopsis . |
47,244 | public static function show ( $ data , string $ title = '' , array $ opts = [ ] ) { $ string = '' ; $ opts = \ array_merge ( [ 'leftChar' => ' ' , 'keyStyle' => 'info' , 'keyMinWidth' => 8 , 'titleStyle' => 'comment' , 'returned' => false , 'lastNewline' => true , ] , $ opts ) ; if ( $ title ) { $ title = \ ucwords ( ... | Format and render a single list |
47,245 | protected function get ( string $ path , array $ parameters = [ ] ) : object { $ url = $ this -> buildApiUrl ( $ path , $ parameters ) ; $ request = $ this -> requestFactory -> createRequest ( 'GET' , $ url ) ; $ response = $ this -> httpClient -> sendRequest ( $ request ) ; $ body = json_decode ( ( string ) $ response... | Send a get request . |
47,246 | protected function buildApiUrl ( string $ path , array $ parameters ) : string { $ parameters = array_merge ( [ 'access_token' => $ this -> accessToken , ] , $ parameters ) ; $ query = http_build_query ( $ parameters , '' , '&' ) ; return 'https://api.instagram.com/v1/' . $ path . '?' . $ query ; } | Add access token and escape parameters . |
47,247 | public function post_type ( $ args , $ assoc_args ) { if ( strlen ( $ args [ 0 ] ) > 20 ) { WP_CLI :: error ( 'Post type slugs cannot exceed 20 characters in length.' ) ; } $ defaults = array ( 'textdomain' => '' , 'dashicon' => 'admin-post' , ) ; $ templates = array ( 'post_type.mustache' , 'post_type_extended.mustach... | Generates PHP code for registering a custom post type . |
47,248 | public function taxonomy ( $ args , $ assoc_args ) { $ defaults = array ( 'textdomain' => '' , 'post_types' => "'post'" , ) ; if ( isset ( $ assoc_args [ 'post_types' ] ) ) { $ assoc_args [ 'post_types' ] = $ this -> quote_comma_list_elements ( $ assoc_args [ 'post_types' ] ) ; } $ templates = array ( 'taxonomy.mustach... | Generates PHP code for registering a custom taxonomy . |
47,249 | public function block ( $ args , $ assoc_args ) { $ slug = $ args [ 0 ] ; if ( ! preg_match ( '/^[a-z][a-z0-9\-]*$/' , $ slug ) ) { WP_CLI :: error ( 'Invalid block slug specified. Block slugs can contain only lowercase alphanumeric characters or dashes, and start with a letter.' ) ; } $ defaults = array ( 'title' => s... | Generates PHP JS and CSS code for registering a Gutenberg block for a plugin or theme . |
47,250 | public function child_theme ( $ args , $ assoc_args ) { $ theme_slug = $ args [ 0 ] ; if ( in_array ( $ theme_slug , array ( '.' , '..' ) , true ) ) { WP_CLI :: error ( "Invalid theme slug specified. The slug cannot be '.' or '..'." ) ; } $ defaults = array ( 'theme_name' => ucfirst ( $ theme_slug ) , 'author' => 'Me' ... | Generates child theme based on an existing theme . |
47,251 | private function extract_dashicon ( $ assoc_args ) { $ dashicon = \ WP_CLI \ Utils \ get_flag_value ( $ assoc_args , 'dashicon' ) ; if ( ! $ dashicon ) { return null ; } return preg_replace ( '/dashicon(-|s-)/' , '' , $ dashicon ) ; } | Extracts dashicon name when provided or return null otherwise . |
47,252 | private function get_textdomain ( $ textdomain , $ args ) { if ( strlen ( $ textdomain ) ) { return $ textdomain ; } if ( $ args [ 'theme' ] ) { return $ this -> get_theme_name ( $ args [ 'theme' ] ) ; } if ( $ args [ 'plugin' ] && true !== $ args [ 'plugin' ] ) { return $ args [ 'plugin' ] ; } return 'YOUR-TEXTDOMAIN'... | If you re writing your files to your theme directory your textdomain also needs to be the same as your theme . Same goes for when plugin is being used . |
47,253 | public function prepend ( $ content ) { $ this -> requireUnlocked ( ) ; $ this -> body = $ content . $ this -> body ; return $ this ; } | Prepend a string to the response s content body |
47,254 | public function sendHeaders ( $ cookies_also = true , $ override = false ) { if ( headers_sent ( ) && ! $ override ) { return $ this ; } header ( $ this -> httpStatusLine ( ) ) ; foreach ( $ this -> headers as $ key => $ value ) { header ( $ key . ': ' . $ value , false ) ; } if ( $ cookies_also ) { $ this -> sendCooki... | Send our HTTP headers |
47,255 | public function sendCookies ( $ override = false ) { if ( headers_sent ( ) && ! $ override ) { return $ this ; } foreach ( $ this -> cookies as $ cookie ) { setcookie ( $ cookie -> getName ( ) , $ cookie -> getValue ( ) , $ cookie -> getExpire ( ) , $ cookie -> getPath ( ) , $ cookie -> getDomain ( ) , $ cookie -> getS... | Send our HTTP response cookies |
47,256 | public function cookie ( $ key , $ value = '' , $ expiry = null , $ path = '/' , $ domain = null , $ secure = false , $ httponly = false ) { if ( null === $ expiry ) { $ expiry = time ( ) + ( 3600 * 24 * 30 ) ; } $ this -> cookies -> set ( $ key , new ResponseCookie ( $ key , $ value , $ expiry , $ path , $ domain , $ ... | Sets a response cookie |
47,257 | public function getFormattedString ( ) { $ string = ( string ) $ this -> code ; if ( null !== $ this -> message ) { $ string = $ string . ' ' . $ this -> message ; } return $ string ; } | Get a string representation of our HTTP status |
47,258 | protected function parseLooseArgumentOrder ( array $ args ) { $ callback = array_pop ( $ args ) ; $ path = array_pop ( $ args ) ; $ method = array_pop ( $ args ) ; return array ( 'method' => $ method , 'path' => $ path , 'callback' => $ callback , ) ; } | Parse our extremely loose argument order of our respond method and its aliases |
47,259 | public function respond ( $ method , $ path = '*' , $ callback = null ) { extract ( $ this -> parseLooseArgumentOrder ( func_get_args ( ) ) , EXTR_OVERWRITE ) ; $ route = $ this -> route_factory -> build ( $ callback , $ path , $ method ) ; $ this -> routes -> add ( $ route ) ; return $ route ; } | Add a new route to be matched on dispatch |
47,260 | public function with ( $ namespace , $ routes ) { $ previous = $ this -> route_factory -> getNamespace ( ) ; $ this -> route_factory -> appendNamespace ( $ namespace ) ; if ( is_callable ( $ routes ) ) { if ( is_string ( $ routes ) ) { $ routes ( $ this ) ; } else { call_user_func ( $ routes , $ this ) ; } } else { req... | Collect a set of routes under a common namespace |
47,261 | protected function compileRoute ( $ route ) { $ route = preg_replace_callback ( static :: ROUTE_ESCAPE_REGEX , function ( $ match ) { return preg_quote ( $ match [ 0 ] ) ; } , $ route ) ; $ match_types = $ this -> match_types ; $ route = preg_replace_callback ( static :: ROUTE_COMPILE_REGEX , function ( $ match ) use (... | Compiles a route string to a regular expression |
47,262 | private function validateRegularExpression ( $ regex ) { $ error_string = null ; set_error_handler ( function ( $ errno , $ errstr ) use ( & $ error_string ) { $ error_string = $ errstr ; } , E_NOTICE | E_WARNING ) ; if ( false === preg_match ( $ regex , null ) || ! empty ( $ error_string ) ) { restore_error_handler ( ... | Validate a regular expression |
47,263 | public function getPathFor ( $ route_name , array $ params = null , $ flatten_regex = true ) { $ route = $ this -> routes -> get ( $ route_name ) ; if ( null === $ route ) { throw new OutOfBoundsException ( 'No such route with name: ' . $ route_name ) ; } $ path = $ route -> getPath ( ) ; $ reversed_path = preg_replace... | Get the path for a given route |
47,264 | protected function handleRouteCallback ( Route $ route , RouteCollection $ matched , array $ methods_matched ) { $ returned = call_user_func ( $ route -> getCallback ( ) , $ this -> request , $ this -> response , $ this -> service , $ this -> app , $ this , $ matched , $ methods_matched ) ; if ( $ returned instanceof A... | Handle a route s callback |
47,265 | protected function error ( $ err ) { $ type = get_class ( $ err ) ; $ msg = $ err -> getMessage ( ) ; try { if ( ! $ this -> error_callbacks -> isEmpty ( ) ) { foreach ( $ this -> error_callbacks as $ callback ) { if ( is_callable ( $ callback ) ) { if ( is_string ( $ callback ) ) { $ callback ( $ this , $ msg , $ type... | Routes an exception through the error callbacks |
47,266 | protected function httpError ( HttpExceptionInterface $ http_exception , RouteCollection $ matched , $ methods_matched ) { if ( ! $ this -> response -> isLocked ( ) ) { $ this -> response -> code ( $ http_exception -> getCode ( ) ) ; } if ( ! $ this -> http_error_callbacks -> isEmpty ( ) ) { foreach ( $ this -> http_er... | Handles an HTTP error exception through our HTTP error callbacks |
47,267 | protected function callAfterDispatchCallbacks ( ) { try { foreach ( $ this -> after_filter_callbacks as $ callback ) { if ( is_callable ( $ callback ) ) { if ( is_string ( $ callback ) ) { $ callback ( $ this ) ; } else { call_user_func ( $ callback , $ this ) ; } } } } catch ( Throwable $ e ) { $ this -> error ( $ e )... | Runs through and executes the after dispatch callbacks |
47,268 | public function dump ( $ obj ) { if ( is_array ( $ obj ) || is_object ( $ obj ) ) { $ obj = print_r ( $ obj , true ) ; } $ this -> append ( '<pre>' . htmlentities ( $ obj , ENT_QUOTES ) . "</pre><br />\n" ) ; return $ this ; } | Dump a variable |
47,269 | public function register ( $ name , $ closure ) { if ( isset ( $ this -> services [ $ name ] ) ) { throw new DuplicateServiceException ( 'A service is already registered under ' . $ name ) ; } $ this -> services [ $ name ] = function ( ) use ( $ closure ) { static $ instance ; if ( null === $ instance ) { $ instance = ... | Register a lazy service |
47,270 | public function addRoute ( Route $ route ) { $ name = spl_object_hash ( $ route ) ; return $ this -> set ( $ name , $ route ) ; } | Add a route instance to the collection |
47,271 | public function prepareNamed ( ) { $ prepared = new static ( ) ; foreach ( $ this as $ key => $ route ) { $ route_name = $ route -> getName ( ) ; if ( null !== $ route_name ) { $ prepared -> set ( $ route_name , $ route ) ; } else { $ prepared -> add ( $ route ) ; } } $ this -> replace ( $ prepared -> all ( ) ) ; retur... | Prepare the named routes in the collection |
47,272 | public function id ( $ hash = true ) { if ( null === $ this -> id ) { $ this -> id = uniqid ( ) ; if ( $ hash ) { $ this -> id = sha1 ( $ this -> id ) ; } } return $ this -> id ; } | Gets a unique ID for the request |
47,273 | public function pathname ( ) { $ uri = $ this -> uri ( ) ; $ uri = strstr ( $ uri , '?' , true ) ? : $ uri ; return $ uri ; } | Get the request s pathname |
47,274 | public function query ( $ key , $ value = null ) { $ query = array ( ) ; parse_str ( $ this -> server ( ) -> get ( 'QUERY_STRING' ) , $ query ) ; if ( is_array ( $ key ) ) { $ query = array_merge ( $ query , $ key ) ; } else { $ query [ $ key ] = $ value ; } $ request_uri = $ this -> uri ( ) ; if ( strpos ( $ request_u... | Adds to or modifies the current query string |
47,275 | public static function createFromRoute ( Route $ route , $ previous = null ) { $ error = ( null !== $ previous ) ? $ previous -> getMessage ( ) : null ; $ code = ( null !== $ previous ) ? $ previous -> getCode ( ) : null ; $ message = sprintf ( static :: MESSAGE_FORMAT , $ route -> getPath ( ) ) ; $ message .= ' ' . sp... | Create a RoutePathCompilationException from a route and an optional previous exception |
47,276 | public function setCallback ( $ callback ) { if ( ! is_callable ( $ callback ) ) { throw new InvalidArgumentException ( 'Expected a callable. Got an uncallable ' . gettype ( $ callback ) ) ; } $ this -> callback = $ callback ; return $ this ; } | Set the callback |
47,277 | public function setMethod ( $ method ) { if ( null !== $ method && ! is_array ( $ method ) && ! is_string ( $ method ) ) { throw new InvalidArgumentException ( 'Expected an array or string. Got a ' . gettype ( $ method ) ) ; } $ this -> method = $ method ; return $ this ; } | Set the method |
47,278 | protected function preprocessPathString ( $ path ) { $ path = ( null === $ path ) ? static :: NULL_PATH_VALUE : ( string ) $ path ; if ( $ this -> namespace && ( isset ( $ path [ 0 ] ) && $ path [ 0 ] === '@' ) || ( isset ( $ path [ 0 ] ) && $ path [ 0 ] === '!' && isset ( $ path [ 1 ] ) && $ path [ 1 ] === '@' ) ) { i... | Pre - process a path string |
47,279 | public function build ( $ callback , $ path = null , $ method = null , $ count_match = true , $ name = null ) { return new Route ( $ callback , $ this -> preprocessPathString ( $ path ) , $ method , $ this -> shouldPathStringCauseRouteMatch ( $ path ) ) ; } | Build a Route instance |
47,280 | public function bind ( Request $ request = null , AbstractResponse $ response = null ) { $ this -> request = $ request ? : $ this -> request ; $ this -> response = $ response ? : $ this -> response ; return $ this ; } | Bind object instances to this service |
47,281 | public static function markdown ( $ str , $ args = null ) { $ md = array ( '/\[([^\]]++)\]\(([^\)]++)\)/' => '<a href="$2">$1</a>' , '/\*\*([^\*]++)\*\*/' => '<strong>$1</strong>' , '/\*([^\*]++)\*/' => '<em>$1</em>' ) ; $ args = func_get_args ( ) ; $ str = array_shift ( $ args ) ; if ( isset ( $ args [ 0 ] ) && is_arr... | Render a text string as markdown |
47,282 | public function back ( ) { $ referer = $ this -> request -> server ( ) -> get ( 'HTTP_REFERER' ) ; if ( null !== $ referer ) { $ this -> response -> redirect ( $ referer ) ; } else { $ this -> refresh ( ) ; } return $ this ; } | Redirects the request back to the referrer |
47,283 | public function render ( $ view , array $ data = array ( ) ) { $ original_view = $ this -> view ; if ( ! empty ( $ data ) ) { $ this -> shared_data -> merge ( $ data ) ; } $ this -> view = $ view ; if ( null === $ this -> layout ) { $ this -> yieldView ( ) ; } else { require $ this -> layout ; } if ( false !== $ this -... | Renders a view + optional layout |
47,284 | public function partial ( $ view , array $ data = array ( ) ) { $ layout = $ this -> layout ; $ this -> layout = null ; $ this -> render ( $ view , $ data ) ; $ this -> layout = $ layout ; } | Renders a view without a layout |
47,285 | public function validateParam ( $ param , $ err = null ) { return $ this -> validate ( $ this -> request -> param ( $ param ) , $ err ) ; } | Start a validator chain for the specified parameter |
47,286 | public function keys ( $ mask = null , $ fill_with_nulls = true ) { if ( null !== $ mask ) { if ( ! is_array ( $ mask ) ) { $ mask = func_get_args ( ) ; } if ( $ fill_with_nulls ) { $ keys = $ mask ; } else { $ keys = array ( ) ; } return array_intersect ( array_keys ( $ this -> attributes ) , $ mask ) + $ keys ; } ret... | Returns all of the key names in the collection |
47,287 | public function merge ( array $ attributes = array ( ) , $ hard = false ) { if ( ! empty ( $ attributes ) ) { if ( $ hard ) { $ this -> attributes = array_replace ( $ this -> attributes , $ attributes ) ; } else { $ this -> attributes = array_merge ( $ this -> attributes , $ attributes ) ; } } return $ this ; } | Merge attributes with the collection s attributes |
47,288 | public function get ( $ key , $ default_val = null ) { $ key = $ this -> normalizeKey ( $ key ) ; return parent :: get ( $ key , $ default_val ) ; } | Get a header |
47,289 | protected function normalizeKey ( $ key ) { if ( $ this -> normalization & static :: NORMALIZE_TRIM ) { $ key = trim ( $ key ) ; } if ( $ this -> normalization & static :: NORMALIZE_DELIMITERS ) { $ key = static :: normalizeKeyDelimiters ( $ key ) ; } if ( $ this -> normalization & static :: NORMALIZE_CASE ) { $ key = ... | Normalize a header key based on our set normalization style |
47,290 | public static function canonicalizeKey ( $ key ) { $ words = explode ( '-' , strtolower ( $ key ) ) ; foreach ( $ words as & $ word ) { $ word = ucfirst ( $ word ) ; } return implode ( '-' , $ words ) ; } | Canonicalize a header key |
47,291 | public static function normalizeName ( $ name , $ make_lowercase = true ) { trigger_error ( 'Use the normalization options and the other normalization methods instead.' , E_USER_DEPRECATED ) ; if ( $ make_lowercase ) { $ name = strtolower ( $ name ) ; } return str_replace ( array ( ' ' , '_' ) , '-' , trim ( $ name ) )... | Normalize a header name by formatting it in a standard way |
47,292 | public static function addDefault ( ) { static :: $ methods [ 'null' ] = function ( $ str ) { return $ str === null || $ str === '' ; } ; static :: $ methods [ 'len' ] = function ( $ str , $ min , $ max = null ) { $ len = strlen ( $ str ) ; return null === $ max ? $ len === $ min : $ len >= $ min && $ len <= $ max ; } ... | Adds default validators on first use |
47,293 | public function attr ( $ attr = null , $ to_str = false ) { $ k = key ( $ this -> ids ) ; if ( null === $ k ) { reset ( $ this -> ids ) ; $ k = key ( $ this -> ids ) ; } return isset ( $ k ) ? $ this -> doc ( ) -> get_attr_byId ( $ k , $ attr , $ to_str ) : null ; } | Get and attribute or all attributes of first element in the collection . |
47,294 | public function dl ( $ dt_sel = 'dt' , $ dd_sel = 'dd' , $ dw = null , $ key = null ) { $ oneKey = isset ( $ key ) ; $ dl = $ oneKey ? null : array ( ) ; if ( $ dw ) { $ l = $ this -> find ( $ dw ) ; if ( $ l ) { foreach ( $ l as $ i => $ w ) { if ( $ dt_sel ) { $ dte = $ w -> find ( $ dt_sel ) -> first ( ) ; $ dt = $ ... | Definition list parser |
47,295 | protected function _sub_ids ( $ eq = false ) { $ ret = array ( ) ; $ ce = reset ( $ this -> ids ) ; $ cb = key ( $ this -> ids ) ; $ doc = $ this -> doc ( ) ; foreach ( $ doc -> ids as $ b => $ e ) { if ( $ b < $ cb || ! $ eq && $ b == $ cb ) { continue ; } if ( $ b < $ ce ) { $ ret [ $ b ] = $ e ; } else { $ ce = next... | Get all ids from inside of this element |
47,296 | public static function text_parse_dl ( $ dl , $ sep = ':' , $ key = null ) { if ( $ dl instanceof self ) { if ( count ( $ dl ) > 1 ) { $ ln = array ( ) ; foreach ( $ dl as $ o ) { $ ln [ ] = $ o -> text ( ) ; } $ dl = implode ( "\n" , $ ln ) ; } else { $ dl = $ dl -> text ( ) ; } } $ dl = trim ( $ dl ) ; $ oneKey = iss... | Textual definition list parser |
47,297 | public static function html_selector2struc ( $ sel ) { $ sc = '#.:' ; $ n = null ; $ a = array ( ) ; $ def = array ( 'n' => $ n , 'i' => $ n , 'c' => $ a , 'p' => $ a ) ; $ sel = rtrim ( trim ( preg_replace ( '/\\s*(>|,)\\s*/' , '$1' , $ sel ) , " \t\n\r,>" ) , $ sc ) ; $ sel = explode ( ',' , $ sel ) ; foreach ( $ sel... | Parse a selector string into an array structure . |
47,298 | public function slice ( $ idx , $ len = null ) { $ c = $ this -> count ( ) ; if ( $ idx < $ c ) { $ ids = array ( ) ; } elseif ( isset ( $ len ) ) { if ( 0 == $ idx && $ len == $ c ) { return $ this ; $ ids = $ this -> ids ; } $ ids = array_slice ( $ this -> ids , $ idx , $ len , true ) ; } else { if ( 0 == $ idx ) { r... | Get a slice of current node collection . |
47,299 | public function parent ( ) { $ p = $ this -> _parent ( ) ; return $ p ? new self ( $ this -> doc , $ p ) : null ; } | Get parent nodes for this collection of nodes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.