idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
48,000 | protected function cleanPackets ( array $ packets = [ ] ) { $ packetCount = count ( $ packets ) ; for ( $ i = 0 , $ x = $ packetCount ; $ i < $ x - 1 ; $ i ++ ) { $ fst = substr ( $ packets [ $ i ] , 0 , - 1 ) ; $ snd = $ packets [ $ i + 1 ] ; $ fstvar = substr ( $ fst , strrpos ( $ fst , "\x00" ) + 1 ) ; $ snd = subst... | Handles cleaning up packets since the responses can be a bit dirty |
48,001 | public function read ( $ length = 1 ) { if ( ( $ length + $ this -> index ) > $ this -> length ) { throw new Exception ( "Unable to read length={$length} from buffer. Bad protocol format or return?" ) ; } $ string = substr ( $ this -> data , $ this -> index , $ length ) ; $ this -> index += $ length ; return $ string ... | Read from the buffer |
48,002 | public function readLast ( ) { $ len = strlen ( $ this -> data ) ; $ string = $ this -> data { strlen ( $ this -> data ) - 1 } ; $ this -> data = substr ( $ this -> data , 0 , $ len - 1 ) ; $ this -> length -= 1 ; return $ string ; } | Read the last character from the buffer |
48,003 | public function readString ( $ delim = "\x00" ) { $ len = strpos ( $ this -> data , $ delim , min ( $ this -> index , $ this -> length ) ) ; if ( $ len === false ) { return $ this -> read ( strlen ( $ this -> data ) - $ this -> index ) ; } $ string = $ this -> read ( $ len - $ this -> index ) ; ++ $ this -> index ; ret... | Read from buffer until delimiter is reached |
48,004 | public function readPascalString ( $ offset = 0 , $ read_offset = false ) { $ len = $ this -> readInt8 ( ) ; $ offset = max ( $ len - $ offset , 0 ) ; if ( $ read_offset ) { return $ this -> read ( $ offset ) ; } else { return substr ( $ this -> read ( $ len ) , 0 , $ offset ) ; } } | Reads a pascal string from the buffer |
48,005 | public function readStringMulti ( $ delims , & $ delimfound = null ) { $ pos = [ ] ; foreach ( $ delims as $ delim ) { if ( $ p = strpos ( $ this -> data , $ delim , min ( $ this -> index , $ this -> length ) ) ) { $ pos [ ] = $ p ; } } if ( empty ( $ pos ) ) { return $ this -> read ( strlen ( $ this -> data ) - $ this... | Read from buffer until any of the delimiters is reached |
48,006 | public function readInt16 ( ) { switch ( $ this -> number_type ) { case self :: NUMBER_TYPE_BIGENDIAN : $ type = 'nint' ; break ; case self :: NUMBER_TYPE_LITTLEENDIAN : $ type = 'vint' ; break ; default : $ type = 'Sint' ; } $ int = unpack ( $ type , $ this -> read ( 2 ) ) ; return $ int [ 'int' ] ; } | Read a 16 - bit unsigned integer |
48,007 | public function readInt16Signed ( ) { $ string = $ this -> read ( 2 ) ; if ( $ this -> number_type == self :: NUMBER_TYPE_BIGENDIAN ) { $ string = strrev ( $ string ) ; } $ int = unpack ( 'sint' , $ string ) ; unset ( $ string ) ; return $ int [ 'int' ] ; } | Read a 16 - bit signed integer |
48,008 | public function readInt64 ( ) { if ( version_compare ( PHP_VERSION , '5.6.3' ) >= 0 && PHP_INT_SIZE == 8 ) { switch ( $ this -> number_type ) { case self :: NUMBER_TYPE_BIGENDIAN : $ type = 'Jint' ; break ; case self :: NUMBER_TYPE_LITTLEENDIAN : $ type = 'Pint' ; break ; default : $ type = 'Qint' ; } $ int64 = unpack ... | Read a 64 - bit unsigned integer |
48,009 | public function readFloat32 ( ) { $ string = $ this -> read ( 4 ) ; if ( $ this -> number_type == self :: NUMBER_TYPE_BIGENDIAN ) { $ string = strrev ( $ string ) ; } $ float = unpack ( 'ffloat' , $ string ) ; unset ( $ string ) ; return $ float [ 'float' ] ; } | Read a 32 - bit float |
48,010 | protected function parsePlayers ( Buffer & $ buffer , Result & $ result ) { $ players = 0 ; while ( ( $ id = $ buffer -> readInt8 ( ) ) != 32 ) { $ result -> addPlayer ( 'id' , $ id ) ; $ result -> addPlayer ( 'ping' , $ buffer -> readInt16 ( ) ) ; $ result -> addPlayer ( 'name' , $ buffer -> readString ( ) ) ; $ resul... | Parse players out of the status ex response |
48,011 | protected function parsePlayersExtra ( Buffer & $ buffer , Result & $ result ) { while ( ( $ id = $ buffer -> readInt8 ( ) ) != 32 ) { $ result -> addPlayer ( 'total_xp' , $ buffer -> readFloat32 ( ) ) ; $ result -> addPlayer ( 'teamname' , $ buffer -> readString ( ) ) ; $ result -> addPlayer ( 'total_kills' , $ buffer... | Handle parsing extra player data |
48,012 | public function processResponse ( ) { $ result = parent :: processResponse ( ) ; $ this -> renameResult ( $ result , 'OwningPlayerName' , 'hostname' ) ; $ this -> renameResult ( $ result , 'p1073741825' , 'mapname' ) ; $ this -> renameResult ( $ result , 'p1073741826' , 'gametype' ) ; $ this -> renameResult ( $ result ... | Overload the response process so we can make some changes |
48,013 | protected function renameResult ( array & $ result , $ old , $ new ) { if ( isset ( $ result [ $ old ] ) ) { $ result [ $ new ] = $ result [ $ old ] ; unset ( $ result [ $ old ] ) ; } } | Dirty hack to rename result entries into something more useful |
48,014 | protected function decode ( Buffer $ buffer ) { $ items = [ ] ; $ itemCount = $ buffer -> readInt32 ( ) ; for ( $ i = 0 ; $ i < $ itemCount ; $ i ++ ) { $ buffer -> readInt32 ( ) ; $ items [ $ i ] = $ buffer -> readString ( ) ; } return $ items ; } | Decode the buffer into a usable format |
48,015 | protected function processDetails ( Buffer $ buffer ) { $ items = $ this -> decode ( $ buffer ) ; $ result = new Result ( ) ; $ result -> add ( 'dedicated' , 1 ) ; $ result -> add ( 'hostname' , $ items [ 1 ] ) ; $ result -> add ( 'num_players' , ( int ) $ items [ 2 ] ) ; $ result -> add ( 'max_players' , ( int ) $ ite... | Process the server details |
48,016 | protected function processVersion ( Buffer $ buffer ) { $ items = $ this -> decode ( $ buffer ) ; $ result = new Result ( ) ; $ result -> add ( 'version' , $ items [ 2 ] ) ; unset ( $ buffer , $ items ) ; return $ result -> fetch ( ) ; } | Process the server version |
48,017 | protected function processPlayers ( Buffer $ buffer ) { $ items = $ this -> decode ( $ buffer ) ; $ result = new Result ( ) ; $ numTags = $ items [ 1 ] ; $ tags = array_slice ( $ items , 2 , $ numTags ) ; $ playerCount = $ items [ $ numTags + 2 ] ; for ( $ i = 0 , $ x = $ numTags + 3 ; $ i < $ playerCount ; $ i ++ , $ ... | Process the players |
48,018 | protected function decryptPackets ( array $ packets = [ ] ) { $ decrypted = [ ] ; foreach ( $ packets as $ packet ) { $ header = substr ( $ packet , 0 , 20 ) ; $ header_items = [ ] ; $ header_key = unpack ( "n1" , $ header ) ; $ key = array_shift ( $ header_key ) ; $ chars = unpack ( "C*" , substr ( $ header , 2 ) ) ; ... | Decrypt the incoming packets |
48,019 | public function addFilter ( $ filterName , $ options = [ ] ) { $ filterHash = sprintf ( '%s_%s' , strtolower ( $ filterName ) , md5 ( json_encode ( $ options ) ) ) ; $ this -> options [ 'filters' ] [ $ filterHash ] = [ 'filter' => strtolower ( $ filterName ) , 'options' => $ options , ] ; unset ( $ filterHash ) ; retur... | Add a filter to the processing list |
48,020 | public function removeFilter ( $ filterHash ) { $ filterHash = strtolower ( $ filterHash ) ; if ( array_key_exists ( $ filterHash , $ this -> options [ 'filters' ] ) ) { unset ( $ this -> options [ 'filters' ] [ $ filterHash ] ) ; } unset ( $ filterHash ) ; return $ this ; } | Remove an added filter |
48,021 | public function process ( ) { $ class = new \ ReflectionClass ( $ this -> queryLibrary ) ; $ this -> query = $ class -> newInstance ( ) ; unset ( $ class ) ; $ results = [ ] ; $ this -> doChallenges ( ) ; $ this -> doQueries ( ) ; foreach ( $ this -> servers as $ server ) { $ result = $ this -> doParseResponse ( $ serv... | Main method used to actually process all of the added servers and return the information |
48,022 | protected function doChallenges ( ) { $ sockets = [ ] ; $ server_challenge = false ; foreach ( $ this -> servers as $ server_id => $ server ) { if ( $ server -> protocol ( ) -> hasChallenge ( ) ) { $ server_challenge = true ; $ socket = clone $ this -> query ; $ socket -> set ( $ server -> protocol ( ) -> transport ( )... | Do server challenges where required |
48,023 | protected function doParseResponse ( Server $ server ) { try { if ( ! is_null ( $ this -> capture_packets_file ) ) { file_put_contents ( $ this -> capture_packets_file , implode ( PHP_EOL . '||' . PHP_EOL , $ server -> protocol ( ) -> packetResponse ( ) ) ) ; } $ results = $ server -> protocol ( ) -> processResponse ( ... | Parse the response for a specific server |
48,024 | protected function doApplyFilters ( array $ results , Server $ server ) { foreach ( $ this -> options [ 'filters' ] as $ filterOptions ) { try { $ class = new \ ReflectionClass ( sprintf ( 'GameQ\\Filters\\%s' , ucfirst ( $ filterOptions [ 'filter' ] ) ) ) ; $ filter = $ class -> newInstanceArgs ( [ $ filterOptions [ '... | Apply any filters to the results |
48,025 | protected function processChannelsAndUsers ( array $ data , Result & $ result ) { foreach ( $ data as $ key => $ value ) { if ( in_array ( $ key , [ 'channels' , 'users' ] ) ) { continue ; } $ result -> addTeam ( $ key , $ value ) ; } foreach ( $ data [ 'users' ] as $ user ) { foreach ( $ user as $ key => $ value ) { $... | Handles processing the the channels and user info |
48,026 | protected function processAll ( Buffer $ buffer ) { $ result = new Result ( ) ; $ result -> add ( 'dedicated' , 1 ) ; $ result -> add ( 'version' , $ buffer -> readString ( ) ) ; $ result -> add ( 'hostname' , $ buffer -> readString ( ) ) ; $ result -> add ( 'map' , $ buffer -> readString ( ) ) ; $ result -> add ( 'gam... | Handle processing all of the data returned |
48,027 | protected function processPackets ( $ packet_id , array $ packets = [ ] ) { $ this -> source_engine = self :: GOLDSOURCE_ENGINE ; $ packs = parent :: processPackets ( $ packet_id , $ packets ) ; $ this -> source_engine = self :: SOURCE_ENGINE ; return $ packs ; } | In the case of cs 1 . 6 we offload split packets here because the split packet response for rules is in the old gold source format |
48,028 | public function processResponse ( ) { $ processed = [ ] ; foreach ( $ this -> packets_response as $ response ) { if ( ( $ match = preg_match ( "#^(.*)\\\\queryid\\\\([^\\\\]+)(\\\\|$)#" , $ response , $ matches ) ) === false || $ match != 1 ) { throw new Exception ( __METHOD__ . " An error occurred while parsing the pa... | Process the response for this protocol |
48,029 | protected function processStatus ( Buffer $ buffer ) { $ result = new Result ( ) ; $ result -> add ( 'dedicated' , 1 ) ; if ( $ buffer -> lookAhead ( 1 ) == '\\' ) { $ buffer -> skip ( 1 ) ; } $ data = explode ( '\\' , $ buffer -> getBuffer ( ) ) ; unset ( $ buffer ) ; $ numPlayers = 0 ; $ numTeams = 0 ; $ itemCount = ... | Handle processing the status buffer |
48,030 | public function addSub ( $ sub , $ key , $ value ) { if ( ! isset ( $ this -> result [ $ sub ] ) or ! is_array ( $ this -> result [ $ sub ] ) ) { $ this -> result [ $ sub ] = [ ] ; } $ found = false ; for ( $ i = 0 ; $ i != count ( $ this -> result [ $ sub ] ) ; $ i ++ ) { if ( ! isset ( $ this -> result [ $ sub ] [ $ ... | Add a variable to a category |
48,031 | public function processResponse ( ) { $ xmlString = implode ( '' , $ this -> packets_response ) ; if ( ( $ xmlDoc = @ simplexml_load_string ( $ xmlString ) ) === false ) { throw new Exception ( __METHOD__ . " Unable to load XML string." ) ; } $ result = new Result ( ) ; $ result -> add ( 'dedicated' , 1 ) ; foreach ( [... | Process the response for the Tibia server |
48,032 | protected function check ( $ section , $ data ) { $ normalized = [ ] ; if ( isset ( $ this -> normalize [ $ section ] ) && ! empty ( $ this -> normalize [ $ section ] ) ) { foreach ( $ this -> normalize [ $ section ] as $ property => $ raw ) { $ value = null ; if ( is_array ( $ raw ) ) { foreach ( $ raw as $ check ) { ... | Check a section for normalization |
48,033 | protected function processStatus ( Buffer $ buffer ) { $ results = $ this -> processServerInfo ( new Buffer ( $ buffer -> readString ( "\x0A" ) ) ) ; $ results = array_merge_recursive ( $ results , $ this -> processPlayers ( new Buffer ( $ buffer -> getBuffer ( ) ) ) ) ; unset ( $ buffer ) ; return $ results ; } | Process the status response |
48,034 | protected function processPlayers ( Buffer $ buffer ) { $ playerCount = 0 ; $ result = new Result ( ) ; while ( $ buffer -> getLength ( ) ) { $ playerInfo = new Buffer ( $ buffer -> readString ( "\x0A" ) ) ; $ result -> addPlayer ( 'frags' , $ playerInfo -> readString ( "\x20" ) ) ; $ result -> addPlayer ( 'ping' , $ p... | Handle processing of player data |
48,035 | public function set ( $ transport , $ ip , $ port , $ timeout = 3 , $ blocking = false ) { $ this -> transport = $ transport ; $ this -> ip = $ ip ; $ this -> port = $ port ; $ this -> timeout = $ timeout ; $ this -> blocking = $ blocking ; } | Set the connection information for the socket |
48,036 | public function reset ( ) { $ this -> transport = null ; $ this -> ip = null ; $ this -> port = null ; $ this -> timeout = 3 ; $ this -> blocking = false ; } | Reset this instance s properties |
48,037 | public function hasChallenge ( ) { return ( isset ( $ this -> packets [ self :: PACKET_CHALLENGE ] ) && ! empty ( $ this -> packets [ self :: PACKET_CHALLENGE ] ) ) ; } | Determine whether or not this protocol has a challenge needed before querying |
48,038 | protected function challengeApply ( $ challenge_string ) { foreach ( $ this -> packets as $ packet_type => $ packet ) { $ this -> packets [ $ packet_type ] = sprintf ( $ packet , $ challenge_string ) ; } return true ; } | Apply the challenge string to all the packets that need it . |
48,039 | protected function processRules ( Buffer $ buffer ) { $ result = new Result ( ) ; $ buffer -> skip ( 1 ) ; while ( $ buffer -> getLength ( ) ) { $ key = $ buffer -> readString ( ) ; if ( strstr ( $ key , "Map:" ) ) { $ result -> addSub ( "maplist" , "name" , $ buffer -> readString ( ) ) ; } else { $ result -> add ( $ k... | Handle processing the server rules |
48,040 | protected function shouldMinify ( $ value ) { if ( $ this -> force ) { return true ; } return ! $ this -> containsBadHtml ( $ value ) && ! $ this -> containsBadComments ( $ value ) ; } | Determine if the blade should be minified . |
48,041 | protected function containsBadHtml ( $ value ) { return preg_match ( '/<(code|pre|textarea)/' , $ value ) || preg_match ( '/<script[^\??>]*>[^<\/script>]/' , $ value ) || preg_match ( '/<!--[\s]+skip\.minification[\s]+ , $ value ) || preg_match ( '/value=("|\')(.*)([ ]{2,})(.*)("|\')/' , $ value ) ; } | Does the code contain bad html? |
48,042 | protected function containsBadComments ( $ value ) { foreach ( token_get_all ( $ value ) as $ token ) { if ( ! is_array ( $ token ) || ! isset ( $ token [ 0 ] ) || $ token [ 0 ] !== T_COMMENT ) { continue ; } if ( substr ( $ token [ 1 ] , 0 , 2 ) === '//' ) { return true ; } } return false ; } | Does the code contain bad comments? |
48,043 | public function compileMinify ( $ value ) { if ( $ this -> ignoredPaths ) { $ path = str_replace ( '\\' , '/' , $ this -> getPath ( ) ) ; foreach ( $ this -> ignoredPaths as $ ignoredPath ) { if ( strpos ( $ path , $ ignoredPath ) !== false ) { return $ value ; } } } return $ this -> blade -> render ( $ value ) ; } | Minifies the output before saving it . |
48,044 | protected function enableBladeOptimisations ( ) { $ app = $ this -> app ; $ app -> view -> getEngineResolver ( ) -> register ( 'blade' , function ( ) use ( $ app ) { $ compiler = $ app [ 'htmlmin.compiler' ] ; return new CompilerEngine ( $ compiler ) ; } ) ; $ app -> view -> addExtension ( 'blade.php' , 'blade' ) ; } | Enable blade optimisations . |
48,045 | protected function registerHtmlMinifier ( ) { $ this -> app -> singleton ( 'htmlmin.html' , function ( Container $ app ) { $ css = $ app [ 'htmlmin.css' ] ; $ js = $ app [ 'htmlmin.js' ] ; return new HtmlMinifier ( $ css , $ js ) ; } ) ; $ this -> app -> alias ( 'htmlmin.html' , HtmlMinifier :: class ) ; } | Register the html minifier class . |
48,046 | protected function registerBladeMinifier ( ) { $ this -> app -> singleton ( 'htmlmin.blade' , function ( Container $ app ) { $ force = $ app -> config -> get ( 'htmlmin.force' , false ) ; return new BladeMinifier ( $ force ) ; } ) ; $ this -> app -> alias ( 'htmlmin.blade' , BladeMinifier :: class ) ; } | Register the blade minifier class . |
48,047 | protected function registerMinifyCompiler ( ) { $ this -> app -> singleton ( 'htmlmin.compiler' , function ( Container $ app ) { $ blade = $ app [ 'htmlmin.blade' ] ; $ files = $ app [ 'files' ] ; $ storagePath = $ app -> config -> get ( 'view.compiled' ) ; $ ignoredPaths = $ app -> config -> get ( 'htmlmin.ignore' , [... | Register the minify compiler class . |
48,048 | protected function registerHTMLMin ( ) { $ this -> app -> singleton ( 'htmlmin' , function ( Container $ app ) { $ blade = $ app [ 'htmlmin.blade' ] ; $ css = $ app [ 'htmlmin.css' ] ; $ js = $ app [ 'htmlmin.js' ] ; $ html = $ app [ 'htmlmin.html' ] ; return new HTMLMin ( $ blade , $ css , $ js , $ html ) ; } ) ; $ th... | Register the htmlmin class . |
48,049 | protected function isAnHtmlResponse ( Response $ response ) { $ type = $ response -> headers -> get ( 'Content-Type' ) ; return strtolower ( strtok ( $ type , ';' ) ) === 'text/html' ; } | Check if the content type header is html . |
48,050 | private function mergeConfigs ( $ key ) { $ mergedConfig = [ ] ; $ userConfig = key ( $ this -> configs ) ; foreach ( $ this -> configs as $ config ) { $ mergedConfig = array_merge ( isset ( $ config [ $ key ] ) ? $ config [ $ key ] : [ ] , $ mergedConfig ) ; } $ this -> configs [ $ userConfig ] [ $ key ] = $ mergedCon... | right now it cannot be used for report because it would path would return invalid file |
48,051 | public function addAssets ( ) { $ js = $ this -> assetRepository -> createAsset ( 'Ho_Templatehints::js/hints.js' ) ; $ this -> assetCollection -> add ( 'Ho_Templatehints::js/hints.js' , $ js ) ; $ css = $ this -> assetRepository -> createAsset ( 'Ho_Templatehints::css/hints.css' ) ; $ this -> assetCollection -> add ( ... | Add assets to the header required for the initialisation of the scripts |
48,052 | public function isHintEnabled ( ) { $ isParamPresent = $ this -> _request -> getParam ( 'ath' , false ) === '1' ; if ( $ isParamPresent ) { $ applicationMode = $ this -> appState -> getMode ( ) ; $ storeId = $ this -> storeManager -> getStore ( ) -> getId ( ) ; if ( $ applicationMode === AppState :: MODE_DEVELOPER || $... | Check if the hints can be displayed . |
48,053 | private function getBlockInfo ( \ Magento \ Framework \ View \ Element \ AbstractBlock $ block ) { $ result = self :: filterEscapeEncode ( [ 'info' => [ 'nameInLayout' => $ block -> getNameInLayout ( ) , 'moduleName' => $ block -> getModuleName ( ) , 'phpClass' => $ this -> getBlockClass ( $ block ) , ] , 'extra' => [ ... | Returns the blockInfo as a json encoded array |
48,054 | private static function filterEscape ( $ data ) { return array_filter ( array_map ( function ( $ elem ) { if ( is_array ( $ elem ) ) { return self :: filterEscape ( $ elem ) ; } return addslashes ( $ elem ) ; } , $ data ) ) ; } | Filter and escape the complete array . |
48,055 | public function modify ( $ name , Closure $ callback ) { $ menu = collect ( $ this -> menus ) -> filter ( function ( $ menu ) use ( $ name ) { return $ menu -> getName ( ) == $ name ; } ) -> first ( ) ; $ callback ( $ menu ) ; } | Modify a specific menu . |
48,056 | protected static function setIconAttribute ( array $ properties ) { $ icon = array_get ( $ properties , 'attributes.icon' ) ; if ( ! is_null ( $ icon ) ) { $ properties [ 'icon' ] = $ icon ; array_forget ( $ properties , 'attributes.icon' ) ; return $ properties ; } return $ properties ; } | Set the icon property when the icon is defined in the link attributes . |
48,057 | public function fill ( $ attributes ) { foreach ( $ attributes as $ key => $ value ) { if ( in_array ( $ key , $ this -> fillable ) ) { $ this -> { $ key } = $ value ; } } } | Fill the attributes . |
48,058 | public function addDivider ( $ order = null ) { $ item = static :: make ( array ( 'name' => 'divider' , 'order' => $ order ) ) ; $ this -> childs [ ] = $ item ; return $ item ; } | Add new divider . |
48,059 | public function getAttributes ( ) { $ attributes = $ this -> attributes ? $ this -> attributes : [ ] ; array_forget ( $ attributes , [ 'active' , 'icon' ] ) ; return HTML :: attributes ( $ attributes ) ; } | Get HTML attribute data . |
48,060 | public function inactive ( ) { $ inactive = $ this -> getInactiveAttribute ( ) ; if ( is_bool ( $ inactive ) ) { return $ inactive ; } if ( $ inactive instanceof \ Closure ) { return call_user_func ( $ inactive ) ; } return false ; } | Get inactive state . |
48,061 | public function whereTitle ( $ title , callable $ callback = null ) { $ item = $ this -> findBy ( 'title' , $ title ) ; if ( is_callable ( $ callback ) ) { return call_user_func ( $ callback , $ item ) ; } return $ item ; } | Find menu item by given its title . |
48,062 | public function style ( $ name ) { if ( $ this -> hasStyle ( $ name ) ) { $ this -> setPresenter ( $ this -> getStyle ( $ name ) ) ; } return $ this ; } | Set new presenter class by given style name . |
48,063 | public function resolve ( $ key ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ key [ $ k ] = $ this -> resolve ( $ v ) ; } } elseif ( is_string ( $ key ) ) { $ matches = array ( ) ; preg_match_all ( '/{[\s]*?([^\s]+)[\s]*?}/i' , $ key , $ matches , PREG_SET_ORDER ) ; foreach ( $ matches as $ match ... | Resolves a key from the bindings array . |
48,064 | public function getOrderedItems ( ) { if ( config ( 'menus.ordering' ) || $ this -> ordering ) { return $ this -> toCollection ( ) -> sortBy ( function ( $ item ) { return $ item -> order ; } ) -> all ( ) ; } return $ this -> items ; } | Get menu items and order it by order key . |
48,065 | public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'parser... | Handles the knp_markdown configuration . |
48,066 | public function execute ( callable $ code ) { $ this -> looping = true ; $ deadline = microtime ( true ) + $ this -> timeout ; $ result = null ; for ( $ i = 0 ; $ this -> looping && microtime ( true ) < $ deadline ; $ i ++ ) { $ result = $ code ( ) ; if ( ! $ this -> looping ) { break ; } $ usecRemaining = \ intval ( (... | Repeats executing a code until it was successful . |
48,067 | private function hasLzfCompression ( $ redis ) : bool { if ( ! \ defined ( 'Redis::COMPRESSION_LZF' ) ) { return false ; } return Redis :: COMPRESSION_LZF === $ redis -> getOption ( Redis :: OPT_COMPRESSION ) ; } | Determines if lzf compression is enabled for the given connection . |
48,068 | public function then ( callable $ code ) { if ( ! call_user_func ( $ this -> check ) ) { return false ; } return $ this -> mutex -> synchronized ( function ( ) use ( $ code ) { if ( ! call_user_func ( $ this -> check ) ) { return false ; } return $ code ( ) ; } ) ; } | Executes a code only if a check is true . |
48,069 | public function timeBoxed ( callable $ code ) { $ existingHandler = pcntl_signal_get_handler ( SIGALRM ) ; $ signal = pcntl_signal ( SIGALRM , function ( ) : void { throw new DeadlineException ( sprintf ( "Timebox hit deadline of %d seconds" , $ this -> timeout ) ) ; } ) ; if ( ! $ signal ) { throw new LockAcquireExcep... | Runs the code and would eventually time out . |
48,070 | private static function checkAutocommit ( \ PDO $ pdo ) : void { $ vendor = $ pdo -> getAttribute ( \ PDO :: ATTR_DRIVER_NAME ) ; if ( $ vendor == "mysql" ) { return ; } try { if ( $ pdo -> getAttribute ( \ PDO :: ATTR_AUTOCOMMIT ) ) { throw new \ InvalidArgumentException ( "PDO::ATTR_AUTOCOMMIT should be disabled." ) ... | Checks that the AUTOCOMMIT mode is turned off . |
48,071 | public function synchronized ( callable $ code ) { return $ this -> loop -> execute ( function ( ) use ( $ code ) { try { $ this -> pdo -> beginTransaction ( ) ; } catch ( \ PDOException $ e ) { throw new LockAcquireException ( "Could not begin transaction." , 0 , $ e ) ; } try { $ result = $ code ( ) ; $ this -> pdo -... | Executes the critical code within a transaction . |
48,072 | private static function hasPDOException ( \ Exception $ exception ) { if ( $ exception instanceof \ PDOException ) { return true ; } if ( $ exception -> getPrevious ( ) === null ) { return false ; } return self :: hasPDOException ( $ exception -> getPrevious ( ) ) ; } | Checks if an exception or any of its previous exceptions is a PDOException . |
48,073 | public function getStart ( ) : int { $ child = $ this -> getChildNodesAndTokens ( ) -> current ( ) ; if ( $ child instanceof Node ) { return $ child -> getStart ( ) ; } elseif ( $ child instanceof Token ) { return $ child -> start ; } throw new \ Exception ( "Unknown type in AST" ) ; } | Gets start position of Node not including leading comments and whitespace . |
48,074 | public function getFullStart ( ) : int { foreach ( $ this :: CHILD_NAMES as $ name ) { if ( ( $ child = $ this -> $ name ) !== null ) { if ( \ is_array ( $ child ) ) { if ( ! isset ( $ child [ 0 ] ) ) { continue ; } $ child = $ child [ 0 ] ; } if ( $ child instanceof Node ) { return $ child -> getFullStart ( ) ; } if (... | Gets start position of Node including leading comments and whitespace |
48,075 | public function getFirstAncestor ( ... $ classNames ) { $ ancestor = $ this ; while ( ( $ ancestor = $ ancestor -> parent ) !== null ) { foreach ( $ classNames as $ className ) { if ( $ ancestor instanceof $ className ) { return $ ancestor ; } } } return null ; } | Gets first ancestor that is an instance of one of the provided classes . Returns null if there is no match . |
48,076 | public function getFirstChildNode ( ... $ classNames ) { foreach ( $ this :: CHILD_NAMES as $ name ) { $ val = $ this -> $ name ; foreach ( $ classNames as $ className ) { if ( \ is_array ( $ val ) ) { foreach ( $ val as $ child ) { if ( $ child instanceof $ className ) { return $ child ; } } continue ; } elseif ( $ va... | Gets first child that is an instance of one of the provided classes . Returns null if there is no match . |
48,077 | public function getFirstDescendantNode ( ... $ classNames ) { foreach ( $ this -> getDescendantNodes ( ) as $ descendant ) { foreach ( $ classNames as $ className ) { if ( $ descendant instanceof $ className ) { return $ descendant ; } } } return null ; } | Gets first descendant node that is an instance of one of the provided classes . Returns null if there is no match . |
48,078 | public function getDescendantNodes ( callable $ shouldDescendIntoChildrenFn = null ) { foreach ( $ this -> getChildNodes ( ) as $ child ) { yield $ child ; if ( $ shouldDescendIntoChildrenFn === null || $ shouldDescendIntoChildrenFn ( $ child ) ) { yield from $ child -> getDescendantNodes ( $ shouldDescendIntoChildrenF... | Gets a generator containing all descendant Nodes . |
48,079 | public function getDescendantTokens ( callable $ shouldDescendIntoChildrenFn = null ) { foreach ( $ this -> getChildNodesAndTokens ( ) as $ child ) { if ( $ child instanceof Node ) { if ( $ shouldDescendIntoChildrenFn == null || $ shouldDescendIntoChildrenFn ( $ child ) ) { yield from $ child -> getDescendantTokens ( $... | Gets generator containing all descendant Tokens . |
48,080 | public function getLeadingCommentAndWhitespaceText ( ) : string { $ fileContents = $ this -> getFileContents ( ) ; foreach ( $ this -> getDescendantTokens ( ) as $ token ) { return $ token -> getLeadingCommentsAndWhitespaceText ( $ fileContents ) ; } } | Gets string representing Node s leading comment and whitespace text . |
48,081 | public function getEndPosition ( ) { for ( $ i = \ count ( $ childKeys = $ this :: CHILD_NAMES ) - 1 ; $ i >= 0 ; $ i -- ) { $ lastChildKey = $ childKeys [ $ i ] ; $ lastChild = $ this -> $ lastChildKey ; if ( \ is_array ( $ lastChild ) ) { $ lastChild = \ end ( $ lastChild ) ; } if ( $ lastChild instanceof Token ) { r... | Get the end index of a Node . |
48,082 | public function getDescendantNodeAtPosition ( int $ pos ) { foreach ( $ this -> getChildNodes ( ) as $ child ) { if ( $ child -> containsPosition ( $ pos ) ) { $ node = $ child -> getDescendantNodeAtPosition ( $ pos ) ; if ( ! is_null ( $ node ) ) { return $ node ; } } } return $ this ; } | Searches descendants to find a Node at the given position . |
48,083 | private function containsPosition ( int $ pos ) : bool { return $ this -> getStart ( ) <= $ pos && $ pos <= $ this -> getEndPosition ( ) ; } | Returns true if the given Node or Token contains the given position . |
48,084 | public function getNamespaceDefinition ( ) { $ namespaceDefinition = $ this instanceof NamespaceDefinition ? $ this : $ this -> getFirstAncestor ( NamespaceDefinition :: class , SourceFileNode :: class ) ; if ( $ namespaceDefinition instanceof NamespaceDefinition && ! ( $ namespaceDefinition -> parent instanceof Source... | Gets corresponding NamespaceDefinition for Node . Returns null if in global namespace . |
48,085 | private function addToImportTable ( $ alias , $ functionOrConst , $ namespaceNameParts , $ contents , & $ namespaceImportTable , & $ functionImportTable , & $ constImportTable ) : array { if ( $ alias !== null ) { if ( $ functionOrConst === null ) { $ namespaceImportTable [ $ alias ] = ResolvedName :: buildName ( $ nam... | Add the alias and resolved name to the corresponding namespace function or const import table . If the alias already exists it will get replaced by the most recent using . |
48,086 | public static function initTokenKindToText ( ) { self :: $ tokenKindToText = \ array_flip ( \ array_merge ( TokenStringMaps :: OPERATORS_AND_PUNCTUATORS , TokenStringMaps :: KEYWORDS , TokenStringMaps :: RESERVED_WORDS ) ) ; } | This is called when this class is loaded at the bottom of this file . |
48,087 | public static function getDiagnostics ( Node $ n ) : array { $ diagnostics = [ ] ; $ n -> walkDescendantNodesAndTokens ( function ( $ node ) use ( & $ diagnostics ) { if ( ( $ diagnostic = self :: checkDiagnostics ( $ node ) ) !== null ) { $ diagnostics [ ] = $ diagnostic ; } } ) ; return $ diagnostics ; } | Traverses AST to generate diagnostics . |
48,088 | public function parseSourceFile ( string $ fileContents , string $ uri = null ) : SourceFileNode { $ this -> lexer = TokenStreamProviderFactory :: GetTokenStreamProvider ( $ fileContents ) ; $ this -> reset ( ) ; $ sourceFile = new SourceFileNode ( ) ; $ this -> sourceFile = $ sourceFile ; $ sourceFile -> fileContents ... | Generates AST from source file contents . Returns an instance of SourceFileNode which is always the top - most Node - type of the tree . |
48,089 | private function parseList ( $ parentNode , int $ listParseContext ) { $ savedParseContext = $ this -> currentParseContext ; $ this -> currentParseContext |= 1 << $ listParseContext ; $ parseListElementFn = $ this -> getParseListElementFn ( $ listParseContext ) ; $ nodeArray = array ( ) ; while ( ! $ this -> isListTerm... | Parse a list of elements for a given ParseContext until a list terminator associated with that ParseContext is reached . Additionally abort parsing when an element is reached that is invalid in the current context but valid in an enclosing context . If an element is invalid in both current and enclosing contexts genera... |
48,090 | private function isCurrentTokenValidInEnclosingContexts ( ) { for ( $ contextKind = 0 ; $ contextKind < ParseContext :: Count ; $ contextKind ++ ) { if ( $ this -> isInParseContext ( $ contextKind ) ) { if ( $ this -> isValidListElement ( $ contextKind , $ this -> getCurrentToken ( ) ) || $ this -> isListTerminator ( $... | Aborts parsing list when one of the parent contexts understands something |
48,091 | private function eat ( ... $ kinds ) { $ token = $ this -> token ; if ( \ is_array ( $ kinds [ 0 ] ) ) { $ kinds = $ kinds [ 0 ] ; } foreach ( $ kinds as $ kind ) { if ( $ token -> kind === $ kind ) { $ this -> token = $ this -> lexer -> scanNextToken ( ) ; return $ token ; } } return new MissingToken ( $ kinds [ 0 ] ,... | Retrieve the current token and check that it s of the expected TokenKind . If so advance and return the token . Otherwise return a MissingToken for the expected token . |
48,092 | private function parseConfiguredServers ( array $ servers ) : Collection { $ result = new Collection ( ) ; foreach ( $ servers as $ server ) { if ( is_array ( $ server ) ) { if ( ! empty ( array_except ( $ server , [ 'host' , 'port' , 'timeout' ] ) ) ) { throw new InvalidConfigurationException ( 'Servers in array notat... | Parses an array of servers which can be given in different formats . Unifies the format for the resulting collection . |
48,093 | public function boundaries ( ) : ? Period { $ period = reset ( $ this -> intervals ) ; if ( false === $ period ) { return null ; } return $ period -> merge ( ... $ this -> intervals ) ; } | Returns the sequence boundaries as a Period instance . |
48,094 | public function gaps ( ) : self { $ sequence = new self ( ) ; $ interval = null ; foreach ( $ this -> sorted ( [ $ this , 'sortByStartDate' ] ) as $ period ) { if ( null === $ interval ) { $ interval = $ period ; continue ; } if ( ! $ interval -> overlaps ( $ period ) && ! $ interval -> abuts ( $ period ) ) { $ sequenc... | Returns the gaps inside the instance . |
48,095 | private function sortByStartDate ( Period $ interval1 , Period $ interval2 ) : int { return $ interval1 -> getStartDate ( ) <=> $ interval2 -> getStartDate ( ) ; } | Sorts two Interval instance using their start datepoint . |
48,096 | public function intersections ( ) : self { $ sequence = new self ( ) ; $ current = null ; $ isPreviouslyContained = false ; foreach ( $ this -> sorted ( [ $ this , 'sortByStartDate' ] ) as $ period ) { if ( null === $ current ) { $ current = $ period ; continue ; } $ isContained = $ current -> contains ( $ period ) ; i... | Returns the intersections inside the instance . |
48,097 | public function unions ( ) : self { $ sequence = $ this -> sorted ( [ $ this , 'sortByStartDate' ] ) -> reduce ( [ $ this , 'calculateUnion' ] , new self ( ) ) ; if ( $ sequence -> intervals === $ this -> intervals ) { return $ this ; } return $ sequence ; } | Returns the unions inside the instance . |
48,098 | private function calculateUnion ( Sequence $ sequence , Period $ period ) : Sequence { if ( $ sequence -> isEmpty ( ) ) { $ sequence -> push ( $ period ) ; return $ sequence ; } $ index = $ sequence -> count ( ) - 1 ; $ interval = $ sequence -> get ( $ index ) ; if ( $ interval -> overlaps ( $ period ) || $ interval ->... | Iteratively calculate the union sequence . |
48,099 | public function substract ( Sequence $ sequence ) : self { if ( $ this -> isEmpty ( ) ) { return $ this ; } $ new = $ sequence -> reduce ( [ $ this , 'substractOne' ] , $ this ) ; if ( $ new -> intervals === $ this -> intervals ) { return $ this ; } return $ new ; } | Substract a Sequence from the current instance . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.