idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
46,000 | public function sendFile ( $ file , $ status = 200 , array $ headers = [ ] , $ contentDisposition = null ) { return new BinaryFileResponse ( $ file , $ status , $ headers , true , $ contentDisposition ) ; } | Sends a file . |
46,001 | public function convert ( $ variable , $ callback ) { $ converters = $ this -> getOption ( '_converters' ) ; $ converters [ $ variable ] = $ callback ; $ this -> setOption ( '_converters' , $ converters ) ; return $ this ; } | Sets a converter for a route variable . |
46,002 | public function before ( $ callback ) { $ callbacks = $ this -> getOption ( '_before_middlewares' ) ; $ callbacks [ ] = $ callback ; $ this -> setOption ( '_before_middlewares' , $ callbacks ) ; return $ this ; } | Sets a callback to handle before triggering the route callback . |
46,003 | public function after ( $ callback ) { $ callbacks = $ this -> getOption ( '_after_middlewares' ) ; $ callbacks [ ] = $ callback ; $ this -> setOption ( '_after_middlewares' , $ callbacks ) ; return $ this ; } | Sets a callback to handle after the route callback . |
46,004 | protected function logRequest ( Request $ request ) { $ this -> logger -> log ( LogLevel :: DEBUG , '> ' . $ request -> getMethod ( ) . ' ' . $ request -> getRequestUri ( ) ) ; } | Logs a request . |
46,005 | protected function logResponse ( Response $ response ) { $ message = '< ' . $ response -> getStatusCode ( ) ; if ( $ response instanceof RedirectResponse ) { $ message .= ' ' . $ response -> getTargetUrl ( ) ; } $ this -> logger -> log ( LogLevel :: DEBUG , $ message ) ; } | Logs a response . |
46,006 | public function isValid ( $ name ) { return is_string ( $ name ) && ( preg_match ( static :: SERVICE_PATTERN , $ name ) || isset ( $ this -> app [ $ name ] ) ) ; } | Returns true if the string is a valid service method representation . |
46,007 | public function onKernelController ( FilterControllerEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ route = $ this -> routes -> get ( $ request -> attributes -> get ( '_route' ) ) ; if ( $ route && $ converters = $ route -> getOption ( '_converters' ) ) { foreach ( $ converters as $ name => $ callback ) { ... | Handles converters . |
46,008 | public function onKernelView ( GetResponseForControllerResultEvent $ event ) { $ response = $ event -> getControllerResult ( ) ; if ( ! ( null === $ response || is_array ( $ response ) || $ response instanceof Response || ( is_object ( $ response ) && ! method_exists ( $ response , '__toString' ) ) ) ) { $ event -> set... | Handles string responses . |
46,009 | public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ routeName = $ request -> attributes -> get ( '_route' ) ; if ( ! $ route = $ this -> app [ 'routes' ] -> get ( $ routeName ) ) { return ; } foreach ( ( array ) $ route -> getOption ( '_before_middlewares' ) as $ cal... | Runs before filters . |
46,010 | public function onKernelResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ routeName = $ request -> attributes -> get ( '_route' ) ; if ( ! $ route = $ this -> app [ 'routes' ] -> get ( $ routeName ) ) { return ; } foreach ( ( array ) $ route -> getOption ( '_after_middlewares' ) as $ ... | Runs after filters . |
46,011 | public function flush ( ) { if ( null === $ this -> routesFactory ) { $ routes = new RouteCollection ( ) ; } else { $ routes = $ this -> routesFactory ; } return $ this -> doFlush ( '' , $ routes ) ; } | Persists and freezes staged controllers . |
46,012 | public function bind ( $ routeName ) { if ( $ this -> isFrozen ) { throw new ControllerFrozenException ( sprintf ( 'Calling %s on frozen %s instance.' , __METHOD__ , __CLASS__ ) ) ; } $ this -> routeName = $ routeName ; return $ this ; } | Sets the controller s route . |
46,013 | protected function registerCommand ( ) { $ this -> app -> singleton ( 'command.laroute.generate' , function ( $ app ) { $ config = $ app [ 'config' ] ; $ routes = new Routes ( $ app [ 'router' ] -> getRoutes ( ) , $ config -> get ( 'laroute.filter' , 'all' ) , $ config -> get ( 'laroute.action_namespace' , '' ) ) ; $ g... | Register the command |
46,014 | public function compile ( $ templatePath , Array $ templateData , $ filePath ) { $ template = $ this -> filesystem -> get ( $ templatePath ) ; $ compiled = $ this -> compiler -> compile ( $ template , $ templateData ) ; $ this -> makeDirectory ( dirname ( $ filePath ) ) ; $ this -> filesystem -> put ( $ filePath , $ co... | Compile the template . |
46,015 | protected function getTemplateData ( ) { $ namespace = $ this -> getOptionOrConfig ( 'namespace' ) ; $ routes = $ this -> routes -> toJSON ( ) ; $ absolute = $ this -> config -> get ( 'laroute.absolute' , false ) ; $ rootUrl = $ this -> config -> get ( 'app.url' , '' ) ; $ prefix = $ this -> config -> get ( 'laroute.pr... | Get the data for the template . |
46,016 | protected function getOptionOrConfig ( $ key ) { if ( $ option = $ this -> option ( $ key ) ) { return $ option ; } return $ this -> config -> get ( "laroute.{$key}" ) ; } | Get an option value either from console input or the config files . |
46,017 | protected function parseRoutes ( RouteCollection $ routes , $ filter , $ namespace ) { $ this -> guardAgainstZeroRoutes ( $ routes ) ; $ results = [ ] ; foreach ( $ routes as $ route ) { $ results [ ] = $ this -> getRouteInformation ( $ route , $ filter , $ namespace ) ; } return array_values ( array_filter ( $ results... | Parse the routes into a jsonable output . |
46,018 | public function compile ( $ template , $ data ) { foreach ( $ data as $ key => $ value ) { $ key = strtoupper ( $ key ) ; if ( is_bool ( $ value ) ) $ value = $ value ? 'true' : 'false' ; $ template = preg_replace ( "#\\$$key\\$#i" , $ value , $ template ) ; } return $ template ; } | Compile a template with given data . |
46,019 | protected function isWhiteListed ( $ content ) { if ( isset ( $ this -> functionWhitelist ) === false ) { return false ; } if ( \ is_string ( $ this -> functionWhitelist ) === true ) { if ( strpos ( $ this -> functionWhitelist , ',' ) !== false ) { $ this -> functionWhitelist = explode ( ',' , $ this -> functionWhiteli... | Is the current function being checked whitelisted ? |
46,020 | private function couldBeBinaryInteger ( $ tokens , $ stackPtr ) { $ token = $ tokens [ $ stackPtr ] ; if ( $ token [ 'code' ] !== \ T_LNUMBER ) { return false ; } if ( $ this -> isLowPHPVersion === false ) { return ( preg_match ( '`^0b[0-1]+$`D' , $ token [ 'content' ] ) === 1 ) ; } else { return ( $ token [ 'content' ... | Could the current token an potentially be a binary integer ? |
46,021 | private function isInvalidBinaryInteger ( $ tokens , $ stackPtr ) { if ( $ this -> couldBeBinaryInteger ( $ tokens , $ stackPtr ) === false ) { return false ; } if ( $ this -> isLowPHPVersion === false ) { return ( $ tokens [ $ stackPtr + 1 ] [ 'code' ] === \ T_LNUMBER ) ; } else { return ( preg_match ( '`^b[0-1]+$`D' ... | Is the current token an invalid binary integer ? |
46,022 | private function getBinaryInteger ( File $ phpcsFile , $ tokens , $ stackPtr ) { $ length = 2 ; if ( $ this -> isLowPHPVersion === false ) { $ i = $ stackPtr ; while ( $ tokens [ $ i ] [ 'code' ] === \ T_LNUMBER ) { $ i ++ ; } $ length = ( $ i - $ stackPtr ) ; } return $ phpcsFile -> getTokensAsString ( $ stackPtr , $ ... | Retrieve the content of the tokens which together look like a binary integer . |
46,023 | private function isInvalidOctalInteger ( $ tokens , $ stackPtr ) { $ token = $ tokens [ $ stackPtr ] ; if ( $ token [ 'code' ] === \ T_LNUMBER && preg_match ( '`^0[0-7]*[8-9]+[0-9]*$`D' , $ token [ 'content' ] ) === 1 ) { return true ; } return false ; } | Is the current token an invalid octal integer ? |
46,024 | private function isHexidecimalNumericString ( $ tokens , $ stackPtr ) { $ token = $ tokens [ $ stackPtr ] ; if ( $ token [ 'code' ] === \ T_CONSTANT_ENCAPSED_STRING && preg_match ( '`^0x[a-f0-9]+$`iD' , $ this -> stripQuotes ( $ token [ 'content' ] ) ) === 1 ) { return true ; } return false ; } | Is the current token a hexidecimal numeric string ? |
46,025 | protected function addWarningOnInvalidValue ( File $ phpcsFile , $ stackPtr , $ directive ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ value = $ tokens [ $ stackPtr ] [ 'content' ] ; if ( isset ( Tokens :: $ stringTokens [ $ tokens [ $ stackPtr ] [ 'code' ] ] ) === true ) { $ value = $ this -> stripQuotes ( $ value ... | Generates a error or warning for this sniff . |
46,026 | protected function validEncoding ( $ value ) { static $ encodings ; if ( isset ( $ encodings ) === false && function_exists ( 'mb_list_encodings' ) ) { $ encodings = mb_list_encodings ( ) ; } if ( empty ( $ encodings ) || \ is_array ( $ encodings ) === false ) { return true ; } return \ in_array ( $ value , $ encodings... | Check whether a value is a valid encoding . |
46,027 | private function processSingularToken ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ FQClassName = '' ; if ( $ tokens [ $ stackPtr ] [ 'type' ] === 'T_NEW' ) { $ FQClassName = $ this -> getFQClassNameFromNewToken ( $ phpcsFile , $ stackPtr ) ; } elseif ( $ tokens [ $ stackPtr ] [ 'type'... | Processes this test for when a token resulting in a singular class name is encountered . |
46,028 | private function processFunctionToken ( File $ phpcsFile , $ stackPtr ) { $ typeHints = $ this -> getTypeHintsFromFunctionDeclaration ( $ phpcsFile , $ stackPtr ) ; if ( empty ( $ typeHints ) || \ is_array ( $ typeHints ) === false ) { return ; } foreach ( $ typeHints as $ hint ) { $ typeHintLc = strtolower ( $ hint ) ... | Processes this test for when a function token is encountered . |
46,029 | private function processCatchToken ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] [ 'parenthesis_opener' ] , $ tokens [ $ stackPtr ] [ 'parenthesis_closer' ] ) === false ) { return ; } $ opener = $ tokens [ $ stackPtr ] [ 'parenthesis_opener' ] ; $ clo... | Processes this test for when a catch token is encountered . |
46,030 | private function processReturnTypeToken ( File $ phpcsFile , $ stackPtr ) { $ returnTypeHint = $ this -> getReturnTypeHintName ( $ phpcsFile , $ stackPtr ) ; $ returnTypeHint = ltrim ( $ returnTypeHint , '\\' ) ; $ returnTypeHintLc = strtolower ( $ returnTypeHint ) ; if ( isset ( $ this -> newClasses [ $ returnTypeHint... | Processes this test for when a return type token is encountered . |
46,031 | protected function addError ( File $ phpcsFile , $ stackPtr , $ content , $ data ) { $ error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)" ; $ errorCode = $ this -> stringToErrorCode ( $ content ) . 'Found' ; $ phpcsFile -> addError ( $ error , $ stac... | Add the error message . |
46,032 | protected function processFunctionDeclaration ( File $ phpcsFile , $ stackPtr ) { $ params = PHPCSHelper :: getMethodParameters ( $ phpcsFile , $ stackPtr ) ; if ( empty ( $ params ) === false && \ is_array ( $ params ) ) { foreach ( $ params as $ param ) { if ( $ param [ 'nullable_type' ] === true ) { $ phpcsFile -> a... | Process this test for function tokens . |
46,033 | protected function processReturnType ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'code' ] ) === false ) { return ; } $ previous = $ phpcsFile -> findPrevious ( Tokens :: $ emptyTokens , ( $ stackPtr - 1 ) , null , true ) ; if ( $ tokens [ ... | Process this test for return type tokens . |
46,034 | private function isTCoalesceEqual ( $ tokens , $ stackPtr ) { if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_EQUAL || isset ( $ tokens [ ( $ stackPtr - 1 ) ] ) === false ) { return false ; } if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'type' ] === 'T_COALESCE' ) { return true ; } if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'typ... | Callback function to determine whether a T_EQUAL token is really a T_COALESCE_EQUAL token . |
46,035 | private function isTCoalesce ( $ tokens , $ stackPtr ) { if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_INLINE_THEN || isset ( $ tokens [ ( $ stackPtr - 1 ) ] ) === false ) { return false ; } if ( $ tokens [ ( $ stackPtr - 1 ) ] [ 'code' ] === \ T_INLINE_THEN ) { if ( isset ( $ tokens [ ( $ stackPtr + 1 ) ] ) === fals... | Callback function to determine whether a T_INLINE_THEN token is really a T_COALESCE token . |
46,036 | protected function isClosureStatic ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ prevToken = $ phpcsFile -> findPrevious ( Tokens :: $ emptyTokens , ( $ stackPtr - 1 ) , null , true , null , true ) ; return ( $ prevToken !== false && $ tokens [ $ prevToken ] [ 'code' ] === \ T_STATIC )... | Check whether the closure is declared as static . |
46,037 | protected function isValidAssignment ( File $ phpcsFile , $ stackPtr , $ end ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ next = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ( $ stackPtr + 1 ) , $ end , true ) ; if ( $ next === false || $ tokens [ $ next ] [ 'code' ] !== \ T_EQUAL ) { return true ; } return $... | Is a value declared and is the value declared valid pre - PHP 5 . 6 ? |
46,038 | protected function throwError ( File $ phpcsFile , $ stackPtr , $ type , $ content = '' ) { $ error = static :: ERROR_PHRASE ; $ phrase = '' ; $ errorCode = 'Found' ; if ( isset ( $ this -> errorPhrases [ $ type ] ) === true ) { $ errorCode = $ this -> stringToErrorCode ( $ type ) . 'Found' ; $ phrase = $ this -> error... | Throw an error if a scalar expression is found . |
46,039 | public function supportsAbove ( $ phpVersion ) { $ testVersion = $ this -> getTestVersion ( ) ; $ testVersion = $ testVersion [ 1 ] ; if ( \ is_null ( $ testVersion ) || version_compare ( $ testVersion , $ phpVersion ) >= 0 ) { return true ; } else { return false ; } } | Check whether a specific PHP version is equal to or higher than the maximum supported PHP version as provided by the user in testVersion . |
46,040 | public function addMessage ( File $ phpcsFile , $ message , $ stackPtr , $ isError , $ code = 'Found' , $ data = array ( ) ) { if ( $ isError === true ) { $ phpcsFile -> addError ( $ message , $ stackPtr , $ code , $ data ) ; } else { $ phpcsFile -> addWarning ( $ message , $ stackPtr , $ code , $ data ) ; } } | Add a PHPCS message to the output stack as either a warning or an error . |
46,041 | public function stripVariables ( $ string ) { if ( strpos ( $ string , '$' ) === false ) { return $ string ; } return preg_replace ( self :: REGEX_COMPLEX_VARS , '' , $ string ) ; } | Strip variables from an arbitrary double quoted string . |
46,042 | public function doesFunctionCallHaveParameters ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return false ; } if ( \ in_array ( $ tokens [ $ stackPtr ] [ 'code' ] , array ( \ T_STRING , \ T_ARRAY , \ T_OPEN_SHORT_ARRAY , \ T_VARIABLE )... | Checks if a function call has parameters . |
46,043 | public function getFunctionCallParameterCount ( File $ phpcsFile , $ stackPtr ) { if ( $ this -> doesFunctionCallHaveParameters ( $ phpcsFile , $ stackPtr ) === false ) { return 0 ; } return \ count ( $ this -> getFunctionCallParameters ( $ phpcsFile , $ stackPtr ) ) ; } | Count the number of parameters a function call has been passed . |
46,044 | public function getFunctionCallParameter ( File $ phpcsFile , $ stackPtr , $ paramOffset ) { $ parameters = $ this -> getFunctionCallParameters ( $ phpcsFile , $ stackPtr ) ; if ( isset ( $ parameters [ $ paramOffset ] ) === false ) { return false ; } else { return $ parameters [ $ paramOffset ] ; } } | Get information on a specific parameter passed to a function call . |
46,045 | public function tokenHasScope ( File $ phpcsFile , $ stackPtr , $ validScopes = null ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return false ; } if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) ) { return false ; } if ( isset ( $ validScopes ) === false ) {... | Verify whether a token is within a scoped condition . |
46,046 | public function inClassScope ( File $ phpcsFile , $ stackPtr , $ strict = true ) { $ validScopes = array ( \ T_CLASS ) ; if ( \ defined ( 'T_ANON_CLASS' ) === true ) { $ validScopes [ ] = \ T_ANON_CLASS ; } if ( $ strict === false ) { $ validScopes [ ] = \ T_INTERFACE ; $ validScopes [ ] = \ T_TRAIT ; } return $ phpcsF... | Verify whether a token is within a class scope . |
46,047 | public function getFQClassNameFromNewToken ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return '' ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_NEW ) { return '' ; } $ start = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ... | Returns the fully qualified class name for a new class instantiation . |
46,048 | public function getFQExtendedClassName ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return '' ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_CLASS && $ tokens [ $ stackPtr ] [ 'type' ] !== 'T_ANON_CLASS' && $ tokens [ $ stackPtr ... | Returns the fully qualified name of the class that the specified class extends . |
46,049 | public function getFQClassNameFromDoubleColonToken ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return '' ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_DOUBLE_COLON ) { return '' ; } if ( $ tokens [ $ stackPtr - 1 ] [ 'code' ] =... | Returns the class name for the static usage of a class . This can be a call to a method the use of a property or constant . |
46,050 | public function determineNamespace ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return '' ; } if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) === false ) { $ namespacePtr = $ phpcsFile -> getCondition ( $ stackPtr , \ T_NAMESP... | Determine the namespace name an arbitrary token lives in . |
46,051 | public function getDeclaredNamespaceName ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( $ stackPtr === false || isset ( $ tokens [ $ stackPtr ] ) === false ) { return false ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_NAMESPACE ) { return false ; } if ( $ tokens [ ( $ stackPtr... | Get the complete namespace name for a namespace declaration . |
46,052 | public function getReturnTypeHintToken ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( \ defined ( 'T_RETURN_TYPE' ) && $ tokens [ $ stackPtr ] [ 'code' ] === \ T_RETURN_TYPE ) { return $ stackPtr ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_FUNCTION && $ tokens [ $ stackPtr ] ... | Get the stack pointer for a return type token for a given function . |
46,053 | public function getReturnTypeHintName ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ colon = $ phpcsFile -> findPrevious ( array ( \ T_COLON , \ T_INLINE_ELSE , \ T_FUNCTION , \ T_CLOSE_PARENTHESIS ) , ( $ stackPtr - 1 ) ) ; if ( $ colon === false || ( $ tokens [ $ colon ] [ 'code' ] !=... | Get the complete return type declaration for a given function . |
46,054 | public function isClassProperty ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false || $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_VARIABLE ) { return false ; } $ validScopes = array ( 'T_CLASS' => true , 'T_ANON_CLASS' => true , 'T_TRAIT' => tru... | Check whether a T_VARIABLE token is a class property declaration . |
46,055 | public function isClassConstant ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false || $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_CONST ) { return false ; } $ validScopes = array ( 'T_CLASS' => true , 'T_ANON_CLASS' => true , 'T_INTERFACE' => tr... | Check whether a T_CONST token is a class constant declaration . |
46,056 | protected function validDirectScope ( File $ phpcsFile , $ stackPtr , $ validScopes ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( empty ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) === true ) { return false ; } $ conditions = array_keys ( $ tokens [ $ stackPtr ] [ 'conditions' ] ) ; $ ptr = array_pop ( $ condition... | Check whether the direct wrapping scope of a token is within a limited set of acceptable tokens . |
46,057 | public function getTypeHintsFromFunctionDeclaration ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_FUNCTION && $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_CLOSURE ) { return array ( ) ; } $ parameters = PHPCSHelper :: getMethodParameters ( $ ... | Get an array of just the type hints from a function declaration . |
46,058 | public function getHashAlgorithmParameter ( File $ phpcsFile , $ stackPtr ) { $ tokens = $ phpcsFile -> getTokens ( ) ; if ( isset ( $ tokens [ $ stackPtr ] ) === false ) { return false ; } if ( $ tokens [ $ stackPtr ] [ 'code' ] !== \ T_STRING ) { return false ; } $ functionName = $ tokens [ $ stackPtr ] [ 'content' ]... | Get the hash algorithm name from the parameter in a hash function call . |
46,059 | protected function isValidAssignment ( File $ phpcsFile , $ stackPtr , $ end ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ next = $ phpcsFile -> findNext ( Tokens :: $ emptyTokens , ( $ stackPtr + 1 ) , $ end , true ) ; if ( $ next === false || $ tokens [ $ next ] [ 'code' ] !== \ T_EQUAL ) { return true ; } return (... | Is a value declared and does the declared value not contain an heredoc ? |
46,060 | protected function filterErrorData ( array $ data , array $ itemInfo , array $ errorInfo ) { array_shift ( $ data ) ; array_unshift ( $ data , $ itemInfo [ 'name' ] , $ errorInfo [ 'paramName' ] ) ; return $ data ; } | Allow for concrete child classes to filter the error data before it s passed to PHPCS . |
46,061 | private function processClassToken ( File $ phpcsFile , $ stackPtr ) { $ interfaces = PHPCSHelper :: findImplementedInterfaceNames ( $ phpcsFile , $ stackPtr ) ; if ( \ is_array ( $ interfaces ) === false || $ interfaces === array ( ) ) { return ; } $ tokens = $ phpcsFile -> getTokens ( ) ; $ checkMethods = false ; if ... | Processes this test for when a class token is encountered . |
46,062 | protected function examineList ( File $ phpcsFile , $ opener , $ closer ) { $ start = $ opener ; while ( ( $ start = $ this -> hasTargetInList ( $ phpcsFile , $ start , $ closer ) ) !== false ) { $ phpcsFile -> addError ( 'Specifying keys in list constructs is not supported in PHP 7.0 or earlier.' , $ start , 'Found' )... | Examine the contents of a list construct to determine whether an error needs to be thrown . |
46,063 | protected function hasTargetInList ( File $ phpcsFile , $ start , $ closer ) { $ tokens = $ phpcsFile -> getTokens ( ) ; for ( $ i = ( $ start + 1 ) ; $ i < $ closer ; $ i ++ ) { if ( isset ( $ this -> allTargets [ $ tokens [ $ i ] [ 'code' ] ] ) === false ) { continue ; } if ( isset ( $ this -> targetsInList [ $ token... | Check whether a certain target token exists within a list construct . |
46,064 | protected function getSnippet ( $ content , $ startAt = '' , $ length = 25 ) { $ startPos = 0 ; if ( $ startAt !== '' ) { $ startPos = strpos ( $ content , $ startAt ) ; if ( $ startPos !== false ) { $ startPos += \ strlen ( $ startAt ) ; } } $ snippet = substr ( $ content , $ startPos , $ length ) ; if ( ( \ strlen ( ... | Get a snippet from a HTML token . |
46,065 | public static function setConfigData ( $ key , $ value , $ temp = false ) { if ( method_exists ( '\PHP_CodeSniffer\Config' , 'setConfigData' ) ) { \ PHP_CodeSniffer \ Config :: setConfigData ( $ key , $ value , $ temp ) ; } else { \ PHP_CodeSniffer :: setConfigData ( $ key , $ value , $ temp ) ; } } | Pass config data to PHPCS . |
46,066 | public static function findStartOfStatement ( File $ phpcsFile , $ start , $ ignore = null ) { if ( version_compare ( self :: getVersion ( ) , '2.7.1' , '>=' ) === true ) { return $ phpcsFile -> findStartOfStatement ( $ start , $ ignore ) ; } $ tokens = $ phpcsFile -> getTokens ( ) ; $ endTokens = Tokens :: $ blockOpen... | Returns the position of the first non - whitespace token in a statement . |
46,067 | protected function isCallTimePassByReferenceParam ( File $ phpcsFile , $ parameter , $ nestingLevel ) { $ tokens = $ phpcsFile -> getTokens ( ) ; $ searchStartToken = $ parameter [ 'start' ] - 1 ; $ searchEndToken = $ parameter [ 'end' ] + 1 ; $ nextVariable = $ searchStartToken ; do { $ nextVariable = $ phpcsFile -> f... | Determine whether a parameter is passed by reference . |
46,068 | private static function sortByWeights ( array & $ array ) { uasort ( $ array , function ( $ a , $ b ) { $ a_weight = isset ( $ a [ 'weight' ] ) ? $ a [ 'weight' ] : 0 ; $ b_weight = isset ( $ b [ 'weight' ] ) ? $ b [ 'weight' ] : 0 ; if ( $ a_weight == $ b_weight ) { return ( $ a [ 'label' ] > $ b [ 'label' ] ) ? 1 : -... | Returns a sorting function to sort an array by weights . |
46,069 | protected function execute ( array $ migration_ids , $ method_name ) { array_walk ( $ migration_ids , function ( $ migration_id ) use ( $ method_name ) { if ( ! $ migration = $ this -> manager -> createInstance ( $ migration_id ) ) { throw new PluginNotFoundException ( $ migration_id ) ; } $ migrate_executable = ( new ... | Import or remove content from migrations . |
46,070 | public function onRouteBuildAlter ( RouteBuildEvent $ event ) { $ collection = $ event -> getRouteCollection ( ) ; array_walk ( static :: $ disabledRoutes , function ( $ disabledRouteName ) use ( $ collection ) { if ( $ route = $ collection -> get ( $ disabledRouteName ) ) { $ route -> setRequirement ( '_access' , 'FAL... | Hides routes by denying access to them . |
46,071 | protected function getUserResponse ( ) { $ response = new $ this -> options [ 'user_response_class' ] ( ) ; if ( $ response instanceof PathUserResponse ) { $ response -> setPaths ( $ this -> paths ) ; } return $ response ; } | Get the response object to return . |
46,072 | protected function getResponseContent ( ResponseInterface $ rawResponse ) { $ content = ( string ) $ rawResponse -> getBody ( ) ; if ( ! $ content ) { return [ ] ; } $ response = json_decode ( $ content , true ) ; if ( JSON_ERROR_NONE !== json_last_error ( ) ) { parse_str ( $ content , $ response ) ; } return $ respons... | Get the parsed content based on the response headers . |
46,073 | protected function createResourceOwnerMap ( ContainerBuilder $ container , $ id , array $ config ) { $ definitionClassname = $ this -> getDefinitionClassname ( ) ; $ resourceOwnersMap = [ ] ; foreach ( $ config [ 'resource_owners' ] as $ name => $ checkPath ) { $ resourceOwnersMap [ $ name ] = $ checkPath ; } $ contain... | Creates a resource owner map for the given configuration . |
46,074 | public function createResourceOwnerService ( ContainerBuilder $ container , $ name , array $ options ) { $ definitionClassname = $ this -> getDefinitionClassname ( ) ; if ( isset ( $ options [ 'service' ] ) ) { $ container -> setAlias ( 'hwi_oauth.resource_owner.' . $ name , new Alias ( $ options [ 'service' ] , true )... | Creates a resource owner service . |
46,075 | private function createConnectIntegration ( ContainerBuilder $ container , array $ config ) { $ definitionClassname = $ this -> getDefinitionClassname ( ) ; if ( isset ( $ config [ 'connect' ] ) ) { $ container -> setParameter ( 'hwi_oauth.connect' , true ) ; if ( isset ( $ config [ 'fosub' ] ) ) { $ container -> setPa... | Check of the connect controllers etc should be enabled . |
46,076 | protected function generateKey ( ResourceOwnerInterface $ resourceOwner , $ key , $ type ) { return sprintf ( '_hwi_oauth.%s.%s.%s.%s' , $ resourceOwner -> getName ( ) , $ resourceOwner -> getOption ( 'client_id' ) , $ type , $ key ) ; } | Key to for fetching or saving a token . |
46,077 | protected function getUniqueUserName ( $ name ) { $ i = 0 ; $ testName = $ name ; do { $ user = $ this -> userManager -> findUserByUsername ( $ testName ) ; } while ( null !== $ user && $ i < $ this -> iterations && $ testName = $ name . ++ $ i ) ; return null !== $ user ? '' : $ testName ; } | Attempts to get a unique username for the user . |
46,078 | protected function setUserInformation ( UserInterface $ user , UserResponseInterface $ userInformation ) { $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; $ accessor -> setValue ( $ user , 'username' , $ this -> getUniqueUserName ( $ userInformation -> getNickname ( ) ) ) ; if ( method_exists ( $ accessor ,... | Set user information from form . |
46,079 | public function disconnect ( UserInterface $ user , UserResponseInterface $ response ) { $ property = $ this -> getProperty ( $ response ) ; $ this -> accessor -> setValue ( $ user , $ property , null ) ; $ this -> userManager -> updateUser ( $ user ) ; } | Disconnects a user . |
46,080 | protected function getProperty ( UserResponseInterface $ response ) { $ resourceOwnerName = $ response -> getResourceOwner ( ) -> getName ( ) ; if ( ! isset ( $ this -> properties [ $ resourceOwnerName ] ) ) { throw new \ RuntimeException ( sprintf ( "No property defined for entity for resource owner '%s'." , $ resourc... | Gets the property for the response . |
46,081 | public static function isResourceOwnerSupported ( $ resourceOwner ) { $ resourceOwner = strtolower ( $ resourceOwner ) ; if ( 'oauth1' === $ resourceOwner || 'oauth2' === $ resourceOwner ) { return true ; } if ( \ in_array ( $ resourceOwner , static :: $ resourceOwners [ 'oauth1' ] , true ) ) { return true ; } return \... | Checks that given resource owner is supported by this bundle . |
46,082 | protected function getValueForPath ( $ path ) { $ data = $ this -> data ; if ( ! $ data ) { return null ; } $ steps = $ this -> getPath ( $ path ) ; if ( ! $ steps ) { return null ; } if ( \ is_array ( $ steps ) ) { if ( 1 === \ count ( $ steps ) ) { return $ this -> getValue ( current ( $ steps ) , $ data ) ; } $ valu... | Extracts a value from the response for a given path . |
46,083 | public function connectAction ( Request $ request ) { $ connect = $ this -> container -> getParameter ( 'hwi_oauth.connect' ) ; $ hasUser = $ this -> getUser ( ) ? $ this -> isGranted ( $ this -> container -> getParameter ( 'hwi_oauth.grant_rule' ) ) : false ; $ error = $ this -> getErrorForRequest ( $ request ) ; if (... | Action that handles the login form . If connecting is enabled the user will be redirected to the appropriate login urls or registration forms . |
46,084 | public function connectServiceAction ( Request $ request , $ service ) { $ connect = $ this -> container -> getParameter ( 'hwi_oauth.connect' ) ; if ( ! $ connect ) { throw new NotFoundHttpException ( ) ; } $ hasUser = $ this -> isGranted ( $ this -> container -> getParameter ( 'hwi_oauth.grant_rule' ) ) ; if ( ! $ ha... | Connects a user to a given account if the user is logged in and connect is enabled . |
46,085 | protected function getErrorForRequest ( Request $ request ) { $ authenticationErrorKey = Security :: AUTHENTICATION_ERROR ; if ( $ request -> attributes -> has ( $ authenticationErrorKey ) ) { return $ request -> attributes -> get ( $ authenticationErrorKey ) ; } $ session = $ request -> getSession ( ) ; if ( null !== ... | Get the security error for a given request . |
46,086 | protected function getResourceOwnerByName ( $ name ) { foreach ( $ this -> container -> getParameter ( 'hwi_oauth.firewall_names' ) as $ firewall ) { $ id = 'hwi_oauth.resource_ownermap.' . $ firewall ; if ( ! $ this -> container -> has ( $ id ) ) { continue ; } $ ownerMap = $ this -> container -> get ( $ id ) ; if ( $... | Get a resource owner by name . |
46,087 | protected function authenticateUser ( Request $ request , UserInterface $ user , $ resourceOwnerName , $ accessToken , $ fakeLogin = true ) { try { $ this -> container -> get ( 'hwi_oauth.user_checker' ) -> checkPreAuth ( $ user ) ; $ this -> container -> get ( 'hwi_oauth.user_checker' ) -> checkPostAuth ( $ user ) ; }... | Authenticate a user with Symfony Security . |
46,088 | public static function signRequest ( $ method , $ url , $ parameters , $ clientSecret , $ tokenSecret = '' , $ signatureMethod = self :: SIGNATURE_METHOD_HMAC ) { foreach ( [ 'oauth_consumer_key' , 'oauth_timestamp' , 'oauth_nonce' , 'oauth_version' , 'oauth_signature_method' ] as $ parameter ) { if ( ! isset ( $ param... | Sign the request parameters . |
46,089 | public static function create ( $ body = '' ) : StreamInterface { if ( $ body instanceof StreamInterface ) { return $ body ; } if ( \ is_string ( $ body ) ) { $ resource = \ fopen ( 'php://temp' , 'rw+' ) ; \ fwrite ( $ resource , $ body ) ; $ body = $ resource ; } if ( \ is_resource ( $ body ) ) { $ new = new self ( )... | Creates a new PSR - 7 stream . |
46,090 | protected function registerDigitalOceanFactory ( ) { $ this -> app -> singleton ( 'digitalocean.factory' , function ( Container $ app ) { $ adapter = $ app [ 'digitalocean.adapterfactory' ] ; return new DigitalOceanFactory ( $ adapter ) ; } ) ; $ this -> app -> alias ( 'digitalocean.factory' , DigitalOceanFactory :: cl... | Register the digitalocean factory class . |
46,091 | public function camelize ( ) { $ encoding = $ this -> encoding ; $ stringy = $ this -> trim ( ) -> lowerCaseFirst ( ) ; $ stringy -> str = preg_replace ( '/^[-_]+/' , '' , $ stringy -> str ) ; $ stringy -> str = preg_replace_callback ( '/[-_\s]+(.)?/u' , function ( $ match ) use ( $ encoding ) { if ( isset ( $ match [ ... | Returns a camelCase version of the string . Trims surrounding spaces capitalizes letters following digits spaces dashes and underscores and removes spaces dashes as well as underscores . |
46,092 | public function chars ( ) { $ chars = [ ] ; for ( $ i = 0 , $ l = $ this -> length ( ) ; $ i < $ l ; $ i ++ ) { $ chars [ ] = $ this -> at ( $ i ) -> str ; } return $ chars ; } | Returns an array consisting of the characters in the string . |
46,093 | public function lines ( ) { $ array = $ this -> split ( '[\r\n]{1,2}' , $ this -> str ) ; for ( $ i = 0 ; $ i < count ( $ array ) ; $ i ++ ) { $ array [ $ i ] = static :: create ( $ array [ $ i ] , $ this -> encoding ) ; } return $ array ; } | Splits on newlines and carriage returns returning an array of Stringy objects corresponding to the lines in the string . |
46,094 | public function offsetExists ( $ offset ) { $ length = $ this -> length ( ) ; $ offset = ( int ) $ offset ; if ( $ offset >= 0 ) { return ( $ length > $ offset ) ; } return ( $ length >= abs ( $ offset ) ) ; } | Returns whether or not a character exists at an index . Offsets may be negative to count from the last character in the string . Implements part of the ArrayAccess interface . |
46,095 | public function toTitleCase ( ) { $ str = \ mb_convert_case ( $ this -> str , \ MB_CASE_TITLE , $ this -> encoding ) ; return static :: create ( $ str , $ this -> encoding ) ; } | Converts the first character of each word in the string to uppercase . |
46,096 | protected function elementNotFound ( $ type , $ selector = null , $ locator = null ) { @ trigger_error ( sprintf ( 'The method %s is deprecated as of 1.7 and will be removed in 2.0' , __METHOD__ ) , E_USER_DEPRECATED ) ; return new ElementNotFoundException ( $ this -> driver , $ type , $ selector , $ locator ) ; } | Builds an ElementNotFoundException . |
46,097 | public function clickLink ( $ locator ) { $ link = $ this -> findLink ( $ locator ) ; if ( null === $ link ) { throw new ElementNotFoundException ( $ this -> getDriver ( ) , 'link' , 'id|title|alt|text' , $ locator ) ; } $ link -> click ( ) ; } | Clicks link with specified locator . |
46,098 | public function hasCheckedField ( $ locator ) { $ field = $ this -> findField ( $ locator ) ; return null !== $ field && $ field -> isChecked ( ) ; } | Checks whether element has a checkbox with specified locator which is checked . |
46,099 | public function hasUncheckedField ( $ locator ) { $ field = $ this -> findField ( $ locator ) ; return null !== $ field && ! $ field -> isChecked ( ) ; } | Checks whether element has a checkbox with specified locator which is unchecked . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.