idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
56,300
public function rightJoin ( $ table , $ localKey , $ operator = null , $ referenceKey = null ) { return $ this -> join ( $ table , $ localKey , $ operator , $ referenceKey , 'right' ) ; }
Alias of the join method with join type right .
56,301
public function innerJoin ( $ table , $ localKey , $ operator = null , $ referenceKey = null ) { return $ this -> join ( $ table , $ localKey , $ operator , $ referenceKey , 'inner' ) ; }
Alias of the join method with join type inner .
56,302
public function outerJoin ( $ table , $ localKey , $ operator = null , $ referenceKey = null ) { return $ this -> join ( $ table , $ localKey , $ operator , $ referenceKey , 'outer' ) ; }
Alias of the join method with join type outer .
56,303
public function get ( ) { $ results = $ this -> executeResultFetcher ( ) ; if ( ! is_array ( $ results ) || empty ( $ results ) ) { $ results = array ( ) ; } if ( ( ! empty ( $ results ) ) && $ this -> forwardKey !== false && is_string ( $ this -> forwardKey ) ) { $ rawResults = $ results ; $ results = array ( ) ; if (...
Executes the executeResultFetcher callback and handles the results .
56,304
public function column ( $ column ) { $ result = $ this -> fields ( $ column ) -> one ( ) ; if ( is_array ( $ result ) ) { return reset ( $ result ) ; } }
Just get a single value from the result
56,305
public function count ( $ field = null ) { if ( is_null ( $ field ) ) { $ field = new Expression ( '*' ) ; } return ( int ) $ this -> column ( new Func ( 'count' , $ field ) ) ; }
Just return the number of results
56,306
public function exists ( ) { $ existsQuery = new Exists ( $ this ) ; $ existsQuery -> setSelect ( $ this ) ; $ result = $ existsQuery -> executeResultFetcher ( ) ; if ( isset ( $ result [ 0 ] [ 'exists' ] ) ) { return ( bool ) $ result [ 0 ] [ 'exists' ] ; } return false ; }
Do any results of this query exist?
56,307
public function translate ( BaseQuery $ query ) { $ this -> attributes = $ query -> attributes ( ) ; if ( $ query instanceof Select ) { $ queryString = $ this -> translateSelect ( ) ; } elseif ( $ query instanceof Replace ) { $ queryString = $ this -> translateInsert ( 'replace' ) ; } elseif ( $ query instanceof Insert...
Translate the given query object and return the results as argument array
56,308
protected function escapeFunction ( $ function ) { $ buffer = $ function -> name ( ) . '(' ; $ arguments = $ function -> arguments ( ) ; foreach ( $ arguments as & $ argument ) { $ argument = $ this -> escape ( $ argument ) ; } return $ buffer . implode ( ', ' , $ arguments ) . ')' ; }
Escapes an sql function object
56,309
protected function escapeTable ( $ allowAlias = true ) { $ table = $ this -> attr ( 'table' ) ; $ database = $ this -> attr ( 'database' ) ; $ buffer = '' ; if ( ! is_null ( $ database ) ) { $ buffer .= $ this -> escape ( $ database ) . '.' ; } if ( is_array ( $ table ) ) { reset ( $ table ) ; if ( $ table [ key ( $ ta...
get and escape the table name
56,310
protected function translateInsert ( $ key ) { $ build = ( $ this -> attr ( 'ignore' ) ? $ key . ' ignore' : $ key ) ; $ build .= ' into ' . $ this -> escapeTable ( false ) . ' ' ; if ( ! $ valueCollection = $ this -> attr ( 'values' ) ) { throw new Exception ( 'Cannot build insert query without values.' ) ; } $ build ...
Translate the current query to an SQL insert statement
56,311
protected function translateUpdate ( ) { $ build = 'update ' . $ this -> escapeTable ( ) . ' set ' ; foreach ( $ this -> attr ( 'values' ) as $ key => $ value ) { $ build .= $ this -> escape ( $ key ) . ' = ' . $ this -> param ( $ value ) . ', ' ; } $ build = substr ( $ build , 0 , - 2 ) ; if ( $ wheres = $ this -> att...
Translate the current query to an SQL update statement
56,312
protected function translateDelete ( ) { $ build = 'delete from ' . $ this -> escapeTable ( false ) ; if ( $ wheres = $ this -> attr ( 'wheres' ) ) { $ build .= $ this -> translateWhere ( $ wheres ) ; } if ( $ this -> attr ( 'limit' ) ) { $ build .= $ this -> translateLimit ( ) ; } return $ build ; }
Translate the current query to an SQL delete statement
56,313
protected function translateSelect ( ) { $ build = ( $ this -> attr ( 'distinct' ) ? 'select distinct' : 'select' ) . ' ' ; $ fields = $ this -> attr ( 'fields' ) ; if ( ! empty ( $ fields ) ) { foreach ( $ fields as $ key => $ field ) { list ( $ column , $ alias ) = $ field ; if ( ! is_null ( $ alias ) ) { $ build .= ...
Translate the current query to an SQL select statement
56,314
protected function translateWhere ( $ wheres ) { $ build = '' ; foreach ( $ wheres as $ where ) { if ( ! isset ( $ where [ 2 ] ) && isset ( $ where [ 1 ] ) && $ where [ 1 ] instanceof BaseQuery ) { $ subAttributes = $ where [ 1 ] -> attributes ( ) ; $ build .= ' ' . $ where [ 0 ] . ' ( ' . substr ( $ this -> translateW...
Translate the where statements into sql
56,315
protected function translateJoins ( ) { $ build = '' ; foreach ( $ this -> attr ( 'joins' ) as $ join ) { $ type = $ join [ 0 ] ; $ table = $ join [ 1 ] ; if ( is_array ( $ table ) ) { reset ( $ table ) ; if ( $ table [ key ( $ table ) ] instanceof Select ) { $ translator = new static ; list ( $ subQuery , $ subQueryPa...
Build the sql join statements
56,316
protected function translateExists ( ) { $ translator = new static ; list ( $ subQuery , $ subQueryParameters ) = $ translator -> translate ( $ this -> attr ( 'select' ) ) ; foreach ( $ subQueryParameters as $ parameter ) { $ this -> addParameter ( $ parameter ) ; } return 'select exists(' . $ subQuery . ') as `exists`...
Translate the exists querry
56,317
public function on ( $ localKey , $ operator , $ referenceKey , $ type = 'and' ) { $ this -> ons [ ] = array ( $ type , $ localKey , $ operator , $ referenceKey ) ; return $ this ; }
Add an on condition to the join object
56,318
public function orOn ( $ localKey , $ operator , $ referenceKey ) { $ this -> on ( $ localKey , $ operator , $ referenceKey , 'or' ) ; return $ this ; }
Add an or on condition to the join object
56,319
public function andOn ( $ localKey , $ operator , $ referenceKey ) { $ this -> on ( $ localKey , $ operator , $ referenceKey , 'and' ) ; return $ this ; }
Add an and on condition to the join object
56,320
public function set ( $ param1 , $ param2 = null ) { if ( empty ( $ param1 ) ) { return $ this ; } if ( ! is_null ( $ param2 ) ) { $ param1 = array ( $ param1 => $ param2 ) ; } $ this -> values = array_merge ( $ this -> values , $ param1 ) ; return $ this ; }
Add set values to the update query
56,321
public static function extend ( $ grammarKey , $ queryBuilder , $ queryTranslator ) { if ( isset ( static :: $ grammar [ $ grammarKey ] ) ) { throw new Exception ( 'Cannot overwrite Hydrahon grammar.' ) ; } static :: $ grammar [ $ grammarKey ] = array ( $ queryBuilder , $ queryTranslator ) ; }
Extend the query builder by a new grammar
56,322
public function executeQuery ( BaseQuery $ query ) { return call_user_func_array ( $ this -> executionCallback , array_merge ( array ( $ query ) , $ this -> translateQuery ( $ query ) ) ) ; }
Translate a query and run the current execution callback
56,323
public function table ( $ table = null , $ alias = null ) { $ query = new Table ( $ this ) ; return $ query -> table ( $ table , $ alias ) ; }
Create a new table instance
56,324
final public function attributes ( ) { $ excluded = array ( 'resultFetcher' , 'macros' ) ; $ attributes = get_object_vars ( $ this ) ; foreach ( $ excluded as $ key ) { if ( isset ( $ attributes [ $ key ] ) ) { unset ( $ attributes [ $ key ] ) ; } } return $ attributes ; }
Returns all avaialbe attribute data The result fetcher callback is excluded
56,325
final public function overwriteAttributes ( $ attributes ) { foreach ( $ attributes as $ key => $ attribute ) { if ( isset ( $ this -> { $ key } ) ) { $ this -> { $ key } = $ attribute ; } } return $ attributes ; }
Overwrite the query attributes
56,326
public function limit ( $ limit , $ limit2 = null ) { if ( ! is_null ( $ limit2 ) ) { $ this -> offset = ( int ) $ limit ; $ this -> limit = ( int ) $ limit2 ; } else { $ this -> limit = ( int ) $ limit ; } return $ this ; }
Set the query limit
56,327
public function page ( $ page , $ size = 25 ) { if ( ( $ page = ( int ) $ page ) < 0 ) { $ page = 0 ; } $ this -> limit = ( int ) $ size ; $ this -> offset = ( int ) $ size * $ page ; return $ this ; }
Create an query limit based on a page and a page size
56,328
public function fromSqlBoolean ( $ sqlBoolean , Provider $ provider = null ) { $ this -> setParameterProvider ( $ provider ) ; return $ provider -> convertFromSqlBoolean ( $ sqlBoolean ) ; }
Converts an SQL boolean to a PHP boolean
56,329
public function fromSqlDate ( $ sqlDate , Provider $ provider = null ) { if ( $ sqlDate === null ) { return null ; } $ this -> setParameterProvider ( $ provider ) ; $ phpDate = DateTime :: createFromFormat ( '!' . $ provider -> getDateFormat ( ) , $ sqlDate ) ; if ( $ phpDate === false ) { $ phpDate = $ this -> parseUn...
Converts an SQL date to a PHP date time
56,330
public function fromSqlJson ( $ json , Provider $ provider = null ) : array { if ( $ json === null ) { return [ ] ; } return json_decode ( $ json , true ) ; }
Converts an SQL JSON string to a PHP array
56,331
public function fromSqlTimeWithTimeZone ( $ sqlTime , Provider $ provider = null ) { if ( $ sqlTime === null ) { return null ; } $ this -> setParameterProvider ( $ provider ) ; $ phpTime = DateTime :: createFromFormat ( $ provider -> getTimeWithTimeZoneFormat ( ) , $ sqlTime ) ; if ( $ phpTime === false ) { $ phpTime =...
Converts an SQL time with time zone to a PHP date time
56,332
public function fromSqlTimeWithoutTimeZone ( $ sqlTime , Provider $ provider = null ) { if ( $ sqlTime === null ) { return null ; } $ this -> setParameterProvider ( $ provider ) ; $ phpTime = DateTime :: createFromFormat ( $ provider -> getTimeWithoutTimeZoneFormat ( ) , $ sqlTime ) ; if ( $ phpTime === false ) { $ php...
Converts an SQL time without time zone to a PHP date time
56,333
public function fromSqlTimestampWithTimeZone ( $ sqlTimestamp , Provider $ provider = null ) { if ( $ sqlTimestamp === null ) { return null ; } $ this -> setParameterProvider ( $ provider ) ; $ phpTimestamp = DateTime :: createFromFormat ( $ provider -> getTimestampWithTimeZoneFormat ( ) , $ sqlTimestamp ) ; if ( $ php...
Converts an SQL timestamp with time zone to a PHP date time
56,334
public function fromSqlTimestampWithoutTimeZone ( $ sqlTimestamp , Provider $ provider = null ) { if ( $ sqlTimestamp === null ) { return null ; } $ this -> setParameterProvider ( $ provider ) ; $ phpTimestamp = DateTime :: createFromFormat ( $ provider -> getTimestampWithoutTimeZoneFormat ( ) , $ sqlTimestamp ) ; if (...
Converts an SQL timestamp without time zone to a PHP date time
56,335
public function toSqlBoolean ( bool $ boolean , Provider $ provider = null ) { $ this -> setParameterProvider ( $ provider ) ; return $ provider -> convertToSqlBoolean ( $ boolean ) ; }
Converts a PHP boolean to an SQL boolean
56,336
public function toSqlDate ( DateTimeInterface $ date , Provider $ provider = null ) : string { $ this -> setParameterProvider ( $ provider ) ; return $ date -> format ( $ provider -> getDateFormat ( ) ) ; }
Converts a PHP date time to an SQL date
56,337
public function toSqlTimeWithTimeZone ( DateTimeInterface $ time , Provider $ provider = null ) : string { $ this -> setParameterProvider ( $ provider ) ; return $ time -> format ( $ provider -> getTimeWithTimeZoneFormat ( ) ) ; }
Converts a PHP date time with time zone to an SQL time
56,338
public function toSqlTimeWithoutTimeZone ( DateTimeInterface $ time , Provider $ provider = null ) : string { $ this -> setParameterProvider ( $ provider ) ; return $ time -> format ( $ provider -> getTimeWithoutTimeZoneFormat ( ) ) ; }
Converts a PHP date time without time zone to an SQL time
56,339
public function toSqlTimestampWithTimeZone ( DateTimeInterface $ timestamp , Provider $ provider = null ) : string { $ this -> setParameterProvider ( $ provider ) ; return $ timestamp -> format ( $ provider -> getTimestampWithTimeZoneFormat ( ) ) ; }
Converts a PHP date time to an SQL timestamp with time zone
56,340
public function toSqlTimestampWithoutTimeZone ( DateTimeInterface $ timestamp , Provider $ provider = null ) : string { $ this -> setParameterProvider ( $ provider ) ; return $ timestamp -> format ( $ provider -> getTimestampWithoutTimeZoneFormat ( ) ) ; }
Converts a PHP date time to an SQL timestamp without time zone
56,341
protected function setParameterProvider ( Provider & $ provider = null ) { if ( $ provider === null ) { if ( $ this -> provider === null ) { throw new RuntimeException ( 'No provider specified' ) ; } $ provider = $ this -> provider ; } }
Checks to see that at least the object s provider is set or the input provider is set If the input provider is not set then it is set by reference to the object s provider
56,342
public function handle ( $ input , IResponse $ response = null ) : int { if ( $ response === null ) { $ response = new ConsoleResponse ( new Compiler ( new Lexer ( ) , new Parser ( ) ) ) ; } try { $ request = $ this -> requestParser -> parse ( $ input ) ; if ( $ this -> isInvokingHelpCommand ( $ request ) ) { $ compile...
Handles a console command
56,343
private function getCompiledHelpCommand ( IRequest $ request ) : ICommand { $ helpCommand = new HelpCommand ( new CommandFormatter ( ) , new PaddingFormatter ( ) ) ; $ commandName = null ; if ( $ request -> getCommandName ( ) === 'help' ) { $ compiledHelpCommand = $ this -> commandCompiler -> compile ( $ helpCommand , ...
Gets the compiled help command
56,344
private function isInvokingHelpCommand ( IRequest $ request ) : bool { return $ request -> getCommandName ( ) === 'help' || $ request -> optionIsSet ( 'h' ) || $ request -> optionIsSet ( 'help' ) ; }
Gets whether or not the input is invoking the help command
56,345
protected function loadEntities ( array $ entityIds ) { if ( count ( $ entityIds ) === 0 ) { return null ; } $ entities = [ ] ; foreach ( $ entityIds as $ entityId ) { $ hash = $ this -> getEntityHashById ( $ entityId ) ; if ( $ hash === null ) { return null ; } $ entities [ ] = $ this -> loadEntity ( $ hash ) ; } retu...
Loads multiple entities from their Ids
56,346
private function convertRawStringToRegex ( ParsedRoute $ parsedRoute , string $ rawString ) : string { if ( empty ( $ rawString ) ) { return '#^.*$#' ; } $ this -> variableNames = [ ] ; $ bracketDepth = 0 ; $ this -> cursor = 0 ; $ rawStringLength = mb_strlen ( $ rawString ) ; $ regex = '' ; while ( $ this -> cursor < ...
Converts a raw string with variables to a regex
56,347
private function getVarRegex ( ParsedRoute $ parsedRoute , string $ segment ) : string { if ( preg_match ( self :: $ variableMatchingRegex , $ segment , $ matches ) !== 1 ) { throw new RouteException ( "Variable name can't be empty" ) ; } $ variableName = $ matches [ 1 ] ; $ defaultValue = $ matches [ 2 ] ?? '' ; if ( ...
Parses a variable and returns the regex
56,348
protected function getAuthority ( IContainer $ container ) : IAuthority { $ permissionRegistry = $ this -> getPermissionRegistry ( $ container ) ; $ container -> bindInstance ( IPermissionRegistry :: class , $ permissionRegistry ) ; $ container -> bindInstance ( IRoles :: class , $ this -> getRoles ( $ container ) ) ; ...
Gets the authority
56,349
protected function getRoles ( IContainer $ container ) : IRoles { $ roleRepository = $ this -> getRoleRepository ( $ container ) ; $ roleMembershipRepository = $ this -> getRoleMembershipRepository ( $ container ) ; $ container -> bindInstance ( IRoleRepository :: class , $ roleRepository ) ; $ container -> bindInstanc...
Gets the roles
56,350
protected function updateComposer ( string $ currName , string $ newName ) { $ rootPath = Config :: get ( 'paths' , 'root' ) ; $ currComposerContents = $ this -> fileSystem -> read ( "$rootPath/composer.json" ) ; $ updatedComposerContents = str_replace ( "$currName\\\\" , "$newName\\\\" , $ currComposerContents ) ; $ t...
Updates the Composer config
56,351
protected function updateConfigs ( string $ currName , string $ newName ) { $ configFiles = $ this -> fileSystem -> getFiles ( Config :: get ( 'paths' , 'config' ) , true ) ; foreach ( $ configFiles as $ file ) { $ currentContents = $ this -> fileSystem -> read ( $ file ) ; $ updatedContents = str_replace ( "$currName\...
Updates any class names that appear in configs
56,352
protected function updateNamespaces ( string $ currName , string $ newName ) { $ paths = [ Config :: get ( 'paths' , 'src' ) , Config :: get ( 'paths' , 'tests' ) ] ; foreach ( $ paths as $ pathToUpdate ) { $ files = $ this -> fileSystem -> getFiles ( $ pathToUpdate , true ) ; foreach ( $ files as $ file ) { $ currCont...
Updates the namespaces
56,353
public function registerElements ( ICompiler $ compiler ) { $ compiler -> registerElement ( 'success' , new Style ( Colors :: BLACK , Colors :: GREEN ) ) ; $ compiler -> registerElement ( 'info' , new Style ( Colors :: GREEN ) ) ; $ compiler -> registerElement ( 'error' , new Style ( Colors :: BLACK , Colors :: YELLOW ...
Registers the Apex elements
56,354
public function removeSlave ( Server $ slave ) { $ slaveHashId = spl_object_hash ( $ slave ) ; if ( isset ( $ this -> servers [ 'slaves' ] [ $ slaveHashId ] ) ) { unset ( $ this -> servers [ 'slaves' ] [ $ slaveHashId ] ) ; } }
Removes the input slave if it is in the list of slaves
56,355
public function move ( string $ targetDirectory , string $ name = null ) { if ( $ this -> hasErrors ( ) ) { throw new UploadException ( 'Cannot move file with errors' ) ; } if ( ! is_dir ( $ targetDirectory ) ) { if ( ! mkdir ( $ targetDirectory , 0777 , true ) ) { throw new UploadException ( 'Could not create director...
Moves the file to the target path
56,356
public function format ( array $ rows , callable $ callback ) : string { foreach ( $ rows as & $ row ) { $ row = ( array ) $ row ; } $ maxLengths = $ this -> normalizeColumns ( $ rows ) ; $ paddingType = $ this -> padAfter ? STR_PAD_RIGHT : STR_PAD_LEFT ; foreach ( $ rows as & $ row ) { foreach ( $ row as $ index => & ...
Formats rows of text so that each column is the same width
56,357
public function normalizeColumns ( array & $ rows ) : array { $ maxNumColumns = 0 ; foreach ( $ rows as $ row ) { $ maxNumColumns = max ( $ maxNumColumns , count ( $ row ) ) ; } $ maxLengths = array_pad ( [ ] , $ maxNumColumns , 0 ) ; foreach ( $ rows as & $ row ) { $ row = array_pad ( $ row , $ maxNumColumns , '' ) ; ...
Normalizes the number of columns in each row
56,358
private function createStageCallback ( ) : Closure { return function ( $ stages , $ stage ) { return function ( $ input ) use ( $ stages , $ stage ) { if ( $ stage instanceof Closure ) { return $ stage ( $ input , $ stages ) ; } else { if ( $ this -> methodToCall === null ) { throw new PipelineException ( 'Method must ...
Creates a callback for an individual stage
56,359
protected function getFromDataMapper ( string $ functionName , array $ args = [ ] ) { $ entities = $ this -> dataMapper -> $ functionName ( ... $ args ) ; if ( is_array ( $ entities ) ) { foreach ( $ entities as & $ entity ) { if ( $ entity !== null ) { $ this -> unitOfWork -> getEntityRegistry ( ) -> registerEntity ( ...
Performs a get query on the data mapper and adds any results as managed entities to the unit of work
56,360
private function getArgumentText ( ) : string { if ( count ( $ this -> command -> getArguments ( ) ) === 0 ) { return ' No arguments' ; } $ argumentTexts = [ ] ; foreach ( $ this -> command -> getArguments ( ) as $ argument ) { $ argumentTexts [ ] = [ $ argument -> getName ( ) , $ argument -> getDescription ( ) ] ; } ...
Converts the command arguments to text
56,361
private function getOptionNames ( Option $ option ) : string { $ optionNames = "--{$option->getName()}" ; if ( $ option -> getShortName ( ) !== null ) { $ optionNames .= "|-{$option->getShortName()}" ; } return $ optionNames ; }
Gets the option names as a formatted string
56,362
private function getOptionText ( ) : string { if ( count ( $ this -> command -> getOptions ( ) ) === 0 ) { return ' No options' ; } $ optionTexts = [ ] ; foreach ( $ this -> command -> getOptions ( ) as $ option ) { $ optionTexts [ ] = [ $ this -> getOptionNames ( $ option ) , $ option -> getDescription ( ) ] ; } retu...
Gets the options as text
56,363
private function flushExpressionBuffer ( ) { if ( $ this -> expressionBuffer !== '' ) { $ this -> tokens [ ] = new Token ( TokenTypes :: T_EXPRESSION , $ this -> expressionBuffer , $ this -> line ) ; $ this -> line += substr_count ( $ this -> expressionBuffer , "\n" ) ; $ this -> expressionBuffer = '' ; } }
Flushes the expression buffer
56,364
private function getStatementLexingMethods ( ) : array { $ statements = [ $ this -> directiveDelimiters [ 0 ] => 'lexDirectiveStatement' , $ this -> sanitizedTagDelimiters [ 0 ] => 'lexSanitizedTagStatement' , $ this -> unsanitizedTagDelimiters [ 0 ] => 'lexUnsanitizedTagStatement' , $ this -> commentDelimiters [ 0 ] =...
Gets a sorted mapping of opening statement delimiters to the lexing methods to call on a match
56,365
private function getStream ( int $ cursor = null , int $ length = null ) : string { if ( $ cursor === null ) { $ cursor = $ this -> cursor ; } if ( $ this -> streamCache [ 'length' ] !== $ length || $ this -> streamCache [ 'cursor' ] > $ cursor ) { $ this -> streamCache [ 'cursor' ] = $ cursor ; $ this -> streamCache [...
Gets the stream of input that has not yet been lexed
56,366
private function initializeVars ( IView $ view ) { $ this -> directiveDelimiters = $ view -> getDelimiters ( IView :: DELIMITER_TYPE_DIRECTIVE ) ; $ this -> sanitizedTagDelimiters = $ view -> getDelimiters ( IView :: DELIMITER_TYPE_SANITIZED_TAG ) ; $ this -> unsanitizedTagDelimiters = $ view -> getDelimiters ( IView :...
Initializes instance variables for lexing
56,367
private function lexCommentStatement ( ) { $ this -> lexDelimitedExpressionStatement ( TokenTypes :: T_COMMENT_OPEN , $ this -> commentDelimiters [ 0 ] , TokenTypes :: T_COMMENT_CLOSE , $ this -> commentDelimiters [ 1 ] , false ) ; }
Lexes a comment statement
56,368
private function lexDelimitedExpression ( string $ closeDelimiter ) { $ expressionBuffer = '' ; $ newLinesAfterExpression = 0 ; while ( ! $ this -> matches ( $ closeDelimiter , false ) && ! $ this -> atEof ( ) ) { $ currentChar = $ this -> getCurrentChar ( ) ; if ( $ currentChar === "\n" ) { if ( trim ( $ expressionBuf...
Lexes an expression that is delimited with tags
56,369
private function lexDelimitedExpressionStatement ( string $ openTokenType , string $ openDelimiter , string $ closeTokenType , string $ closeDelimiter , bool $ closeDelimiterOptional ) { $ this -> flushExpressionBuffer ( ) ; $ this -> tokens [ ] = new Token ( $ openTokenType , $ openDelimiter , $ this -> line ) ; $ thi...
Lexes a statement that is comprised of a delimited statement
56,370
private function lexDirectiveName ( ) { $ name = '' ; $ newLinesAfterName = 0 ; do { $ currentChar = $ this -> getCurrentChar ( ) ; if ( $ currentChar === "\n" ) { if ( trim ( $ name ) === '' ) { $ this -> line ++ ; } else { $ newLinesAfterName ++ ; } } $ name .= $ currentChar ; $ this -> cursor ++ ; } while ( preg_mat...
Lexes a directive name
56,371
private function lexExpression ( ) { $ statementMethods = $ this -> getStatementLexingMethods ( ) ; while ( ! $ this -> atEof ( ) ) { reset ( $ statementMethods ) ; $ matchedStatement = false ; while ( list ( $ statementOpenDelimiter , $ methodName ) = each ( $ statementMethods ) ) { if ( $ this -> matches ( $ statemen...
Lexes an expression
56,372
private function lexSanitizedTagStatement ( ) { $ this -> lexDelimitedExpressionStatement ( TokenTypes :: T_SANITIZED_TAG_OPEN , $ this -> sanitizedTagDelimiters [ 0 ] , TokenTypes :: T_SANITIZED_TAG_CLOSE , $ this -> sanitizedTagDelimiters [ 1 ] , false ) ; }
Lexes a sanitized tag statement
56,373
private function lexUnsanitizedTagStatement ( ) { $ this -> lexDelimitedExpressionStatement ( TokenTypes :: T_UNSANITIZED_TAG_OPEN , $ this -> unsanitizedTagDelimiters [ 0 ] , TokenTypes :: T_UNSANITIZED_TAG_CLOSE , $ this -> unsanitizedTagDelimiters [ 1 ] , false ) ; }
Lexes an unsanitized tag statement
56,374
private function matches ( string $ expected , bool $ shouldConsume = true , int $ cursor = null ) : bool { $ stream = $ this -> getStream ( $ cursor ) ; $ expectedLength = strlen ( $ expected ) ; if ( substr ( $ stream , 0 , $ expectedLength ) == $ expected ) { if ( $ shouldConsume ) { $ this -> cursor += $ expectedLe...
Gets whether or not the input at the cursor matches an expected value
56,375
private function replaceViewFunctionCalls ( string $ expression ) : string { $ phpTokens = token_get_all ( '<?php ' . $ expression . ' ?>' ) ; $ opulenceTokens = [ ] ; while ( list ( $ index , $ token ) = each ( $ phpTokens ) ) { if ( is_string ( $ token ) ) { $ opulenceTokens [ ] = [ T_STRING , $ token , 0 ] ; continu...
Replaces view function calls with valid PHP calls
56,376
public function sendHeaders ( ) { if ( ! $ this -> headersAreSent ( ) ) { header ( sprintf ( 'HTTP/%s %s %s' , $ this -> httpVersion , $ this -> statusCode , $ this -> statusText ) , true , $ this -> statusCode ) ; foreach ( $ this -> headers -> getAll ( ) as $ name => $ values ) { foreach ( $ values as $ value ) { hea...
Sends the headers if they haven t already been sent
56,377
public function deleteCookie ( string $ name , string $ path = '/' , string $ domain = '' , bool $ isSecure = false , bool $ isHttpOnly = true ) { $ this -> setCookie ( new Cookie ( $ name , '' , 0 , $ path , $ domain , $ isSecure , $ isHttpOnly ) ) ; }
Deletes a cookie in the response header
56,378
public function getCookies ( bool $ includeDeletedCookies = false ) : array { $ cookies = [ ] ; foreach ( $ this -> cookies as $ domain => $ cookiesByDomain ) { foreach ( $ cookiesByDomain as $ path => $ cookiesByPath ) { foreach ( $ cookiesByPath as $ name => $ cookie ) { if ( $ includeDeletedCookies || $ cookie -> ge...
Gets a list of all the active cookies
56,379
public static function get ( string $ category , string $ setting , $ default = null ) { if ( ! isset ( self :: $ settings [ $ category ] [ $ setting ] ) ) { return $ default ; } return self :: $ settings [ $ category ] [ $ setting ] ; }
Gets a setting
56,380
public static function has ( string $ category , string $ setting ) : bool { return isset ( self :: $ settings [ $ category ] ) && isset ( self :: $ settings [ $ category ] [ $ setting ] ) ; }
Gets whether or not a setting has a value
56,381
public function createSigner ( string $ algorithm , $ publicKey , $ privateKey = null ) : ISigner { if ( ! is_string ( $ publicKey ) && ! is_resource ( $ publicKey ) ) { throw new InvalidArgumentException ( 'Public key must either be a string or a resource' ) ; } if ( $ this -> algorithmIsSymmetric ( $ algorithm ) ) { ...
Creates a signer with the input algorithm
56,382
private function algorithmIsSymmetric ( string $ algorithm ) : bool { return in_array ( $ algorithm , [ Algorithms :: SHA256 , Algorithms :: SHA384 , Algorithms :: SHA512 ] ) ; }
Gets whether or not an algorithm is symmetric
56,383
protected function getExtension ( IView $ view ) : string { foreach ( array_keys ( $ this -> compilers ) as $ extension ) { $ lengthDifference = strlen ( $ view -> getPath ( ) ) - strlen ( $ extension ) ; if ( $ lengthDifference >= 0 && strpos ( $ view -> getPath ( ) , $ extension , $ lengthDifference ) !== false ) { r...
Gets the extension for a view
56,384
public function add ( string $ name , $ value ) { if ( in_array ( $ name , [ 'exp' , 'nbf' , 'iat' ] ) && is_int ( $ value ) ) { $ value = DateTimeImmutable :: createFromFormat ( 'U' , $ value ) ; } $ this -> claims [ $ name ] = $ value ; }
Adds an extra claim
56,385
public function get ( string $ name ) { $ claims = $ this -> getAll ( ) ; if ( ! array_key_exists ( $ name , $ claims ) ) { return null ; } return $ claims [ $ name ] ; }
Gets the value for a claim
56,386
public function getAll ( ) : array { $ convertedClaims = [ ] ; $ timeFields = [ 'exp' , 'nbf' , 'iat' ] ; foreach ( $ this -> claims as $ name => $ value ) { if ( $ value !== null && in_array ( $ name , $ timeFields ) ) { $ value = $ value -> getTimestamp ( ) ; } $ convertedClaims [ $ name ] = $ value ; } if ( ! isset ...
Gets the value for all the claims
56,387
protected function normalizeName ( string $ name ) : string { $ name = parent :: normalizeName ( $ name ) ; if ( strpos ( $ name , 'http-' ) === 0 ) { $ name = substr ( $ name , 5 ) ; } return $ name ; }
Removes the http - from the name
56,388
private function getSelectedAssociativeChoices ( array $ answers ) : array { $ selectedChoices = [ ] ; foreach ( $ answers as $ answer ) { if ( array_key_exists ( $ answer , $ this -> choices ) ) { $ selectedChoices [ ] = $ this -> choices [ $ answer ] ; } } return $ selectedChoices ; }
Gets the list of selected associative choices from a list of answers
56,389
private function getSelectedIndexChoices ( array $ answers ) : array { $ selectedChoices = [ ] ; foreach ( $ answers as $ answer ) { if ( ! ctype_digit ( $ answer ) ) { throw new InvalidArgumentException ( 'Answer is not an integer' ) ; } $ answer = ( int ) $ answer ; if ( $ answer < 1 || $ answer > count ( $ this -> c...
Gets the list of selected indexed choices from a list of answers
56,390
public function registerViewFunctions ( ITranspiler $ transpiler ) { $ transpiler -> registerViewFunction ( 'charset' , function ( $ charset ) { return '<meta charset="' . $ charset . '">' ; } ) ; $ transpiler -> registerViewFunction ( 'css' , function ( $ paths ) { $ callback = function ( $ path ) { return '<link href...
Registers the built - in view functions
56,391
private function getSurroundingText ( array $ charArray , int $ position ) : string { if ( count ( $ charArray ) <= 3 ) { return implode ( '' , $ charArray ) ; } if ( $ position <= 3 ) { return implode ( '' , array_slice ( $ charArray , 0 , 4 ) ) ; } return implode ( '' , array_slice ( $ charArray , $ position - 3 , 4 ...
Gets text around a certain position for use in exceptions
56,392
private function lookBehind ( array $ charArray , int $ currPosition ) { if ( $ currPosition === 0 || count ( $ charArray ) === 0 ) { return null ; } return $ charArray [ $ currPosition - 1 ] ; }
Looks back at the previous character in the string
56,393
private function peek ( array $ charArray , int $ currPosition ) { $ charArrayLength = count ( $ charArray ) ; if ( $ charArrayLength === 0 || $ charArrayLength === $ currPosition + 1 ) { return null ; } return $ charArray [ $ currPosition + 1 ] ; }
Peeks at the next character in the string
56,394
public function getClient ( string $ name = 'default' ) { if ( ! isset ( $ this -> clients [ $ name ] ) ) { throw new InvalidArgumentException ( "No client with name \"$name\"" ) ; } return $ this -> clients [ $ name ] ; }
Gets the client with the input name
56,395
public function verify ( SignedJwt $ jwt , VerificationContext $ verificationContext , array & $ errors ) : bool { $ verifiers = [ new SignatureVerifier ( $ verificationContext -> getSigner ( ) ) , new AudienceVerifier ( $ verificationContext -> getAudience ( ) ) , new ExpirationVerifier ( ) , new NotBeforeVerifier ( )...
Verifies a token
56,396
private function compileNode ( Node $ node ) : string { if ( $ node -> isLeaf ( ) ) { if ( $ node -> isTag ( ) ) { return '' ; } return $ node -> getValue ( ) ? : '' ; } else { $ output = '' ; foreach ( $ node -> getChildren ( ) as $ childNode ) { if ( $ node -> isTag ( ) ) { if ( ! isset ( $ this -> elements [ $ node ...
Recursively compiles a node and its children
56,397
private function executeRollBacks ( array $ migrations ) : void { $ this -> connection -> beginTransaction ( ) ; foreach ( $ migrations as $ migration ) { $ migration -> down ( ) ; $ this -> executedMigrations -> delete ( get_class ( $ migration ) ) ; } $ this -> connection -> commit ( ) ; }
Executes the roll backs on a list of migrations
56,398
private function resolveManyMigrations ( array $ migrationClasses ) : array { $ migrations = [ ] ; foreach ( $ migrationClasses as $ migrationClass ) { $ migrations [ ] = $ this -> migrationResolver -> resolve ( $ migrationClass ) ; } return $ migrations ; }
Resolves many migrations at once
56,399
public function ask ( IQuestion $ question , IResponse $ response ) { $ response -> write ( "<question>{$question->getText()}</question>" ) ; if ( $ question instanceof MultipleChoice ) { $ response -> writeln ( '' ) ; $ choicesAreAssociative = $ question -> choicesAreAssociative ( ) ; $ choiceTexts = [ ] ; foreach ( $...
Prompts the user to answer a question