idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
53,500 | public static function set_readable ( $ filename , $ readable = true ) { $ stat = @ stat ( $ filename ) ; if ( $ stat === false ) { return false ; } if ( strncasecmp ( PHP_OS , 'WIN' , 3 ) === 0 ) { return true ; } list ( $ myuid , $ mygid ) = array ( posix_geteuid ( ) , posix_getgid ( ) ) ; if ( $ readable ) { if ( $ ... | Set the readable bit on a file to the minimum value that allows the user running PHP to read to it . |
53,501 | public static function set_executable ( $ filename , $ executable = true ) { $ stat = @ stat ( $ filename ) ; if ( $ stat === false ) { return false ; } if ( strncasecmp ( PHP_OS , 'WIN' , 3 ) === 0 ) { return true ; } list ( $ myuid , $ mygid ) = array ( posix_geteuid ( ) , posix_getgid ( ) ) ; if ( $ executable ) { i... | Set the executable bit on a file to the minimum value that allows the user running PHP to read to it . |
53,502 | public function decoded ( ) : ? string { if ( null === $ this -> user ) { return null ; } $ userInfo = $ this -> getUser ( ) ; if ( null === $ this -> pass ) { return $ userInfo ; } return $ userInfo . ':' . $ this -> getPass ( ) ; } | Returns the decoded component . |
53,503 | public function getUser ( ) : ? string { return $ this -> encodeComponent ( $ this -> user , self :: NO_ENCODING , self :: REGEXP_USERINFO_ENCODING ) ; } | Retrieve the user component of the URI User Info part . |
53,504 | public function getPass ( ) : ? string { return $ this -> encodeComponent ( $ this -> pass , self :: NO_ENCODING , self :: REGEXP_USERINFO_ENCODING ) ; } | Retrieve the pass component of the URI User Info part . |
53,505 | public function withUserInfo ( $ user , $ pass = null ) : self { $ user = $ this -> validateComponent ( $ user ) ; $ pass = $ this -> validateComponent ( $ pass ) ; if ( null === $ user || '' === $ user ) { $ pass = null ; } if ( $ user === $ this -> user && $ pass === $ this -> pass ) { return $ this ; } $ clone = clo... | Return an instance with the specified user . |
53,506 | private function validate ( $ scheme ) : ? string { $ scheme = $ this -> filterComponent ( $ scheme ) ; if ( null === $ scheme ) { return $ scheme ; } if ( 1 === preg_match ( self :: REGEXP_SCHEME , $ scheme ) ) { return strtolower ( $ scheme ) ; } throw new SyntaxError ( sprintf ( "The scheme '%s' is invalid" , $ sche... | Validate a scheme . |
53,507 | public static function createFromParams ( $ params , string $ separator = '&' ) : self { if ( $ params instanceof self ) { return new self ( http_build_query ( $ params -> toParams ( ) , '' , $ separator , PHP_QUERY_RFC3986 ) , PHP_QUERY_RFC3986 , $ separator ) ; } if ( $ params instanceof Traversable ) { $ params = it... | Returns a new instance from the result of PHP s parse_str . |
53,508 | public function has ( string $ key ) : bool { return isset ( array_flip ( array_column ( $ this -> pairs , 0 ) ) [ $ key ] ) ; } | Tell whether a parameter with a specific name exists . |
53,509 | public function get ( string $ key ) { foreach ( $ this -> pairs as $ pair ) { if ( $ key === $ pair [ 0 ] ) { return $ pair [ 1 ] ; } } return null ; } | Returns the first value associated to the given parameter . |
53,510 | public function getAll ( string $ key ) : array { $ filter = static function ( array $ pair ) use ( $ key ) : bool { return $ key === $ pair [ 0 ] ; } ; return array_column ( array_filter ( $ this -> pairs , $ filter ) , 1 ) ; } | Returns all the values associated to the given parameter as an array or all the instance pairs . |
53,511 | public function withSeparator ( string $ separator ) : self { if ( $ separator === $ this -> separator ) { return $ this ; } $ clone = clone $ this ; $ clone -> separator = $ this -> filterSeparator ( $ separator ) ; return $ clone ; } | Returns an instance with a different separator . |
53,512 | public function sort ( ) : self { if ( count ( $ this -> pairs ) === count ( array_count_values ( array_column ( $ this -> pairs , 0 ) ) ) ) { return $ this ; } $ pairs = array_merge ( ... array_values ( array_reduce ( $ this -> pairs , [ $ this , 'reducePairs' ] , [ ] ) ) ) ; if ( $ pairs === $ this -> pairs ) { retur... | Sort the query string by offset maintaining offset to data correlations . |
53,513 | private function reducePairs ( array $ pairs , array $ pair ) : array { $ pairs [ $ pair [ 0 ] ] = $ pairs [ $ pair [ 0 ] ] ?? [ ] ; $ pairs [ $ pair [ 0 ] ] [ ] = $ pair ; return $ pairs ; } | Reduce pairs to help sorting them according to their keys . |
53,514 | private function removeDuplicates ( array $ pairs , array $ pair ) : array { if ( ! in_array ( $ pair , $ pairs , true ) ) { $ pairs [ ] = $ pair ; } return $ pairs ; } | Adds a query pair only if it is not already present in a given array . |
53,515 | public function withoutNumericIndices ( ) : self { $ pairs = array_map ( [ $ this , 'encodeNumericIndices' ] , $ this -> pairs ) ; if ( $ pairs === $ this -> pairs ) { return $ this ; } $ clone = clone $ this ; $ clone -> pairs = $ pairs ; return $ clone ; } | Returns an instance where numeric indices associated to PHP s array like key are removed . |
53,516 | public function merge ( $ query ) : self { $ pairs = $ this -> pairs ; foreach ( QueryString :: parse ( $ this -> filterComponent ( $ query ) , $ this -> separator , PHP_QUERY_RFC3986 ) as $ pair ) { $ pairs = $ this -> addPair ( $ pairs , $ pair ) ; } if ( $ pairs === $ this -> pairs ) { return $ this ; } $ clone = cl... | Returns an instance with the new pairs set to it . |
53,517 | private function filterPair ( $ value ) { if ( null === $ value || is_scalar ( $ value ) ) { return $ value ; } if ( $ value instanceof UriComponentInterface ) { return $ value -> getContent ( ) ; } if ( method_exists ( $ value , '__toString' ) ) { return ( string ) $ value ; } throw new TypeError ( 'The submitted valu... | Validate the given pair . |
53,518 | public function withoutPair ( string $ key , string ... $ keys ) : self { $ keys [ ] = $ key ; $ keys_to_remove = array_intersect ( $ keys , array_column ( $ this -> pairs , 0 ) ) ; if ( [ ] === $ keys_to_remove ) { return $ this ; } $ filter = static function ( array $ pair ) use ( $ keys_to_remove ) : bool { return !... | Returns an instance without the specified keys . |
53,519 | public function append ( $ query ) : self { if ( $ query instanceof UriComponentInterface ) { $ query = $ query -> getContent ( ) ; } $ pairs = array_merge ( $ this -> pairs , QueryString :: parse ( $ query , $ this -> separator , PHP_QUERY_RFC3986 ) ) ; if ( $ pairs === $ this -> pairs ) { return $ this ; } $ clone = ... | Returns an instance with the new pairs appended to it . |
53,520 | public function withoutParam ( string $ offset , string ... $ offsets ) : self { $ offsets [ ] = $ offset ; $ mapper = static function ( string $ offset ) : string { return preg_quote ( $ offset , ',' ) . '(\[.*\].*)?' ; } ; $ regexp = ',^(' . implode ( '|' , array_map ( $ mapper , $ offsets ) ) . ')?$,' ; $ filter = s... | Returns an instance without the specified params . |
53,521 | public function get ( int $ offset ) : ? string { if ( $ offset < 0 ) { $ offset += count ( $ this -> labels ) ; } return $ this -> labels [ $ offset ] ?? null ; } | Retrieves a single host label . |
53,522 | public function prepend ( $ label ) : self { $ label = $ this -> filterComponent ( $ label ) ; if ( null === $ label ) { return $ this ; } return new self ( $ label . self :: SEPARATOR . $ this -> getContent ( ) ) ; } | Prepends a label to the host . |
53,523 | public function append ( $ label ) : self { $ label = $ this -> filterComponent ( $ label ) ; if ( null === $ label ) { return $ this ; } return new self ( $ this -> getContent ( ) . self :: SEPARATOR . $ label ) ; } | Appends a label to the host . |
53,524 | public function withoutRootLabel ( ) : self { if ( '' !== reset ( $ this -> labels ) ) { return $ this ; } $ labels = $ this -> labels ; array_shift ( $ labels ) ; return self :: createFromLabels ( $ labels ) ; } | Returns an instance without its Root label . |
53,525 | public function withLabel ( int $ key , $ label ) : self { $ nb_labels = count ( $ this -> labels ) ; if ( $ key < - $ nb_labels - 1 || $ key > $ nb_labels ) { throw new OffsetOutOfBounds ( sprintf ( 'no label can be added with the submitted key : `%s`' , $ key ) ) ; } if ( 0 > $ key ) { $ key += $ nb_labels ; } if ( $... | Returns an instance with the modified label . |
53,526 | public function withoutLabel ( int $ key , int ... $ keys ) : self { array_unshift ( $ keys , $ key ) ; $ nb_labels = count ( $ this -> labels ) ; foreach ( $ keys as & $ key ) { if ( - $ nb_labels > $ key || $ nb_labels - 1 < $ key ) { throw new OffsetOutOfBounds ( sprintf ( 'no label can be removed with the submitted... | Returns an instance without the specified label . |
53,527 | protected function validateComponent ( $ component ) : ? string { $ component = $ this -> filterComponent ( $ component ) ; if ( null === $ component ) { return $ component ; } return $ this -> decodeComponent ( $ component ) ; } | Validate the component content . |
53,528 | protected static function filterComponent ( $ component ) : ? string { if ( $ component instanceof UriComponentInterface ) { return $ component -> getContent ( ) ; } if ( null === $ component ) { return $ component ; } if ( ! is_scalar ( $ component ) && ! method_exists ( $ component , '__toString' ) ) { throw new Type... | Filter the input component . |
53,529 | protected function decodeMatches ( array $ matches ) : string { if ( 1 === preg_match ( static :: REGEXP_PREVENTS_DECODING , $ matches [ 0 ] ) ) { return strtoupper ( $ matches [ 0 ] ) ; } return rawurldecode ( $ matches [ 0 ] ) ; } | Decodes Matches sequence . |
53,530 | protected function encodeComponent ( $ str , int $ enc_type , string $ regexp ) : ? string { if ( self :: NO_ENCODING === $ enc_type || null === $ str || 1 !== preg_match ( self :: REGEXP_NO_ENCODING , $ str ) ) { return $ str ; } return preg_replace_callback ( $ regexp , [ $ this , 'encodeMatches' ] , $ str ) ?? rawur... | Returns the component as converted for RFC3986 or RFC1738 . |
53,531 | public function decoded ( ) : ? string { return $ this -> encodeComponent ( $ this -> fragment , self :: NO_ENCODING , self :: REGEXP_FRAGMENT_ENCODING ) ; } | Returns the decoded query . |
53,532 | private function parse ( ? string $ authority ) : array { $ components = [ 'user' => null , 'pass' => null , 'host' => null , 'port' => null ] ; if ( null === $ authority ) { return $ components ; } if ( '' === $ authority ) { $ components [ 'host' ] = '' ; return $ components ; } $ parts = explode ( '@' , $ authority ... | Extracts the authority parts from a given string . |
53,533 | private function validate ( $ port ) : ? int { $ port = $ this -> filterComponent ( $ port ) ; if ( null === $ port ) { return null ; } $ fport = filter_var ( $ port , FILTER_VALIDATE_INT , [ 'options' => [ 'min_range' => 0 ] ] ) ; if ( false !== $ fport ) { return $ fport ; } throw new SyntaxError ( sprintf ( 'Expecte... | Validate a port . |
53,534 | public static function createFromPath ( string $ path , $ context = null ) : self { $ file_args = [ $ path , false ] ; $ mime_args = [ $ path , FILEINFO_MIME ] ; if ( null !== $ context ) { $ file_args [ ] = $ context ; $ mime_args [ ] = $ context ; } $ content = @ file_get_contents ( ... $ file_args ) ; if ( false ===... | Create a new instance from a file path . |
53,535 | private function filterPath ( ? string $ path ) : string { if ( null === $ path ) { throw new SyntaxError ( 'The path can not be null' ) ; } if ( '' === $ path || ',' === $ path ) { return 'text/plain;charset=us-ascii,' ; } if ( 1 === preg_match ( self :: REGEXP_DATAPATH , $ path ) ) { $ path = substr ( $ path , 0 , - ... | Filter the data path . |
53,536 | private function filterMimeType ( string $ mimetype ) : string { if ( '' == $ mimetype ) { return static :: DEFAULT_MIMETYPE ; } if ( 1 === preg_match ( static :: REGEXP_MIMETYPE , $ mimetype ) ) { return $ mimetype ; } throw new SyntaxError ( sprintf ( 'invalid mimeType, `%s`' , $ mimetype ) ) ; } | Filter the mimeType property . |
53,537 | private function filterParameters ( string $ parameters , bool & $ is_binary_data ) : array { if ( '' === $ parameters ) { return [ static :: DEFAULT_PARAMETER ] ; } if ( 1 === preg_match ( ',(;|^)' . static :: BINARY_PARAMETER . '$,' , $ parameters , $ matches ) ) { $ parameters = substr ( $ parameters , 0 , - strlen ... | Extract and set the binary flag from the parameters if it exists . |
53,538 | private function validateParameter ( string $ parameter ) : bool { $ properties = explode ( '=' , $ parameter ) ; return 2 != count ( $ properties ) || strtolower ( $ properties [ 0 ] ) === static :: BINARY_PARAMETER ; } | Validate mediatype parameter . |
53,539 | private function validateDocument ( ) : void { if ( ! $ this -> is_binary_data ) { return ; } $ res = base64_decode ( $ this -> document , true ) ; if ( false === $ res || $ this -> document !== base64_encode ( $ res ) ) { throw new SyntaxError ( sprintf ( 'invalid document, `%s`' , $ this -> document ) ) ; } } | Validate the path document string representation . |
53,540 | private function formatComponent ( string $ mimetype , string $ parameters , bool $ is_binary_data , string $ data ) : string { if ( '' != $ parameters ) { $ parameters = ';' . $ parameters ; } if ( $ is_binary_data ) { $ parameters .= ';base64' ; } $ path = $ mimetype . $ parameters . ',' . $ data ; return preg_replac... | Format the DataURI string . |
53,541 | public static function appendQuery ( $ uri , $ query ) { return $ uri -> withQuery ( ( string ) ( new Query ( self :: filterUri ( $ uri ) -> getQuery ( ) ) ) -> append ( $ query ) ) ; } | Add the new query data to the existing URI query . |
53,542 | public static function mergeQuery ( $ uri , $ query ) { return $ uri -> withQuery ( ( string ) ( new Query ( self :: filterUri ( $ uri ) -> getQuery ( ) ) ) -> merge ( $ query ) ) ; } | Merge a new query with the existing URI query . |
53,543 | public static function sortQuery ( $ uri ) { return $ uri -> withQuery ( ( string ) ( new Query ( self :: filterUri ( $ uri ) -> getQuery ( ) ) ) -> sort ( ) ) ; } | Sort the URI query by keys . |
53,544 | public static function addRootLabel ( $ uri ) { return $ uri -> withHost ( ( string ) ( new Domain ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> withRootLabel ( ) ) ; } | Add the root label to the URI . |
53,545 | public static function appendLabel ( $ uri , $ label ) { $ host = new Host ( self :: filterUri ( $ uri ) -> getHost ( ) ) ; if ( $ host -> isDomain ( ) ) { return $ uri -> withHost ( ( string ) ( new Domain ( $ host ) ) -> append ( $ label ) ) ; } if ( $ host -> isIpv4 ( ) ) { $ label = ltrim ( ( string ) new Host ( $ ... | Append a label or a host to the current URI host . |
53,546 | public static function hostToAscii ( $ uri ) { return $ uri -> withHost ( ( string ) ( new Host ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) ) ; } | Convert the URI host part to its ascii value . |
53,547 | public static function hostToUnicode ( $ uri ) { return $ uri -> withHost ( ( string ) ( new Host ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> toUnicode ( ) ) ; } | Convert the URI host part to its unicode value . |
53,548 | public static function prependLabel ( $ uri , $ label ) { $ host = new Host ( self :: filterUri ( $ uri ) -> getHost ( ) ) ; if ( $ host -> isDomain ( ) ) { return $ uri -> withHost ( ( string ) ( new Domain ( $ host ) ) -> prepend ( $ label ) ) ; } if ( $ host -> isIpv4 ( ) ) { $ label = rtrim ( ( string ) new Host ( ... | Prepend a label or a host to the current URI host . |
53,549 | public static function removeLabels ( $ uri , int $ key , int ... $ keys ) { return $ uri -> withHost ( ( string ) ( new Domain ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> withoutLabel ( $ key , ... $ keys ) ) ; } | Remove host labels according to their offset . |
53,550 | public static function removeRootLabel ( $ uri ) { return $ uri -> withHost ( ( string ) ( new Domain ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> withoutRootLabel ( ) ) ; } | Remove the root label to the URI . |
53,551 | public static function removeZoneId ( $ uri ) { return $ uri -> withHost ( ( string ) ( new Host ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> withoutZoneIdentifier ( ) ) ; } | Remove the host zone identifier . |
53,552 | public static function replaceLabel ( $ uri , int $ offset , $ host ) { return $ uri -> withHost ( ( string ) ( new Domain ( self :: filterUri ( $ uri ) -> getHost ( ) ) ) -> withLabel ( $ offset , $ host ) ) ; } | Replace a label of the current URI host . |
53,553 | public static function addBasepath ( $ uri , $ path ) { self :: filterUri ( $ uri ) ; $ currentpath = $ uri -> getPath ( ) ; if ( '' !== $ currentpath && '/' !== $ currentpath [ 0 ] ) { $ currentpath = '/' . $ currentpath ; } $ path = ( new HierarchicalPath ( $ path ) ) -> withLeadingSlash ( ) ; if ( 0 === strpos ( $ c... | Add a new basepath to the URI path . |
53,554 | public static function addLeadingSlash ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; $ path = $ uri -> getPath ( ) ; if ( '/' !== ( $ path [ 0 ] ?? '' ) ) { $ path = '/' . $ path ; } return self :: normalizePath ( $ uri , $ path ) ; } | Add a leading slash to the URI path . |
53,555 | private static function normalizePath ( $ uri , $ path = null ) { if ( $ path instanceof PathInterface ) { $ path = $ path -> getContent ( ) ; } $ path = $ path ?? $ uri -> getPath ( ) ; $ path = ( string ) $ path ; if ( null !== $ uri -> getAuthority ( ) && '' !== $ uri -> getAuthority ( ) && '' !== $ path && '/' != (... | Normalize a URI path . |
53,556 | public static function addTrailingSlash ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; $ path = $ uri -> getPath ( ) ; if ( '/' !== substr ( $ path , - 1 ) ) { $ path .= '/' ; } return self :: normalizePath ( $ uri , $ path ) ; } | Add a trailing slash to the URI path . |
53,557 | public static function appendSegment ( $ uri , string $ segment ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> append ( $ segment ) ) ; } | Append an new segment or a new path to the URI path . |
53,558 | public static function datapathToAscii ( $ uri ) { return $ uri -> withPath ( ( string ) ( new DataPath ( self :: filterUri ( $ uri ) -> getPath ( ) ) ) -> toAscii ( ) ) ; } | Convert the Data URI path to its ascii form . |
53,559 | public static function prependSegment ( $ uri , $ segment ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> prepend ( $ segment ) ) ; } | Prepend an new segment or a new path to the URI path . |
53,560 | public static function removeBasepath ( $ uri , $ path ) { $ uri = self :: normalizePath ( self :: filterUri ( $ uri ) ) ; $ basepath = ( new HierarchicalPath ( $ path ) ) -> withLeadingSlash ( ) ; if ( '/' === ( string ) $ basepath ) { return $ uri ; } $ currentpath = $ uri -> getPath ( ) ; if ( 0 !== strpos ( $ curre... | Remove a basepath from the URI path . |
53,561 | public static function removeDotSegments ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new Path ( $ uri -> getPath ( ) ) ) -> withoutDotSegments ( ) ) ; } | Remove dot segments from the URI path . |
53,562 | public static function removeEmptySegments ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withoutEmptySegments ( ) ) ; } | Remove empty segments from the URI path . |
53,563 | public static function removeLeadingSlash ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; $ path = $ uri -> getPath ( ) ; if ( '' !== $ path && '/' === $ path [ 0 ] ) { $ path = substr ( $ path , 1 ) ; } return self :: normalizePath ( $ uri , $ path ) ; } | Remove the leading slash from the URI path . |
53,564 | public static function removeTrailingSlash ( $ uri ) { $ uri = self :: filterUri ( $ uri ) ; $ path = $ uri -> getPath ( ) ; if ( '' !== $ path && '/' === substr ( $ path , - 1 ) ) { $ path = substr ( $ path , 0 , - 1 ) ; } return self :: normalizePath ( $ uri , $ path ) ; } | Remove the trailing slash from the URI path . |
53,565 | public static function removeSegments ( $ uri , int $ key , int ... $ keys ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withoutSegment ( $ key , ... $ keys ) ) ; } | Remove path segments from the URI path according to their offsets . |
53,566 | public static function replaceBasename ( $ uri , $ path ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withBasename ( $ path ) ) ; } | Replace the URI path basename . |
53,567 | public static function replaceDataUriParameters ( $ uri , string $ parameters ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new DataPath ( $ uri -> getPath ( ) ) ) -> withParameters ( $ parameters ) ) ; } | Replace the data URI path parameters . |
53,568 | public static function replaceDirname ( $ uri , $ path ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withDirname ( $ path ) ) ; } | Replace the URI path dirname . |
53,569 | public static function replaceExtension ( $ uri , $ extension ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withExtension ( $ extension ) ) ; } | Replace the URI path basename extension . |
53,570 | public static function replaceSegment ( $ uri , int $ offset , $ segment ) { $ uri = self :: filterUri ( $ uri ) ; return self :: normalizePath ( $ uri , ( new HierarchicalPath ( $ uri -> getPath ( ) ) ) -> withSegment ( $ offset , $ segment ) ) ; } | Replace a segment from the URI path according its offset . |
53,571 | private function buildBasename ( string $ extension , string $ ext , string $ param = null ) : string { $ length = strrpos ( $ ext , '.' . pathinfo ( $ ext , PATHINFO_EXTENSION ) ) ; if ( false !== $ length ) { $ ext = substr ( $ ext , 0 , $ length ) ; } if ( null !== $ param && '' !== $ param ) { $ param = ';' . $ par... | Creates a new basename with a new extension . |
53,572 | public static function createFromIp ( string $ ip , string $ version = '' ) { if ( '' !== $ version ) { return new self ( '[v' . $ version . '.' . $ ip . ']' ) ; } if ( filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ) { return new self ( $ ip ) ; } if ( filter_var ( $ ip , FILTER_VALIDATE_IP , FILTER_FLAG_... | Returns a host from an IP address . |
53,573 | private function isValidIpv6Hostname ( string $ host ) : bool { [ $ ipv6 , $ scope ] = explode ( '%' , $ host , 2 ) + [ 1 => null ] ; if ( null === $ scope ) { return ( bool ) filter_var ( $ ipv6 , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ; } $ scope = rawurldecode ( '%' . $ scope ) ; return 1 !== preg_match ( self :: R... | Validates an Ipv6 as Host . |
53,574 | public function withoutZoneIdentifier ( ) : self { if ( ! $ this -> has_zone_identifier ) { return $ this ; } [ $ ipv6 , ] = explode ( '%' , substr ( ( string ) $ this -> host , 1 , - 1 ) ) ; return static :: createFromIp ( $ ipv6 ) ; } | Returns an host without its zone identifier according to RFC6874 . |
53,575 | public function prepare ( $ name = null , $ queryRemotes = true ) { $ this -> addCommandName ( self :: GIT_REMOTE_SHOW ) ; if ( $ name ) { $ this -> addCommandSubject ( $ name ) ; } if ( ! $ queryRemotes ) { $ this -> addCommandArgument ( '-n' ) ; } return $ this ; } | build show sub command |
53,576 | public function addCmdValueOptions ( ) { return array ( self :: GIT_REMOTE_ADD_OPTION_TRACK => self :: GIT_REMOTE_ADD_OPTION_TRACK , self :: GIT_REMOTE_ADD_OPTION_MIRROR => self :: GIT_REMOTE_ADD_OPTION_MIRROR , self :: GIT_REMOTE_ADD_OPTION_SETHEAD => self :: GIT_REMOTE_ADD_OPTION_SETHEAD , ) ; } | Valid options for remote command that require an associated value |
53,577 | public function addCmdSwitchOptions ( ) { return array ( self :: GIT_REMOTE_ADD_OPTION_TAGS => self :: GIT_REMOTE_ADD_OPTION_TAGS , self :: GIT_REMOTE_ADD_OPTION_NOTAGS => self :: GIT_REMOTE_ADD_OPTION_NOTAGS , self :: GIT_REMOTE_ADD_OPTION_FETCH => self :: GIT_REMOTE_ADD_OPTION_FETCH , ) ; } | switch only options for the add subcommand |
53,578 | public function prepare ( $ name , $ url , $ options = array ( ) ) { $ options = $ this -> normalizeOptions ( $ options , $ this -> addCmdSwitchOptions ( ) , $ this -> addCmdValueOptions ( ) ) ; $ this -> addCommandName ( self :: GIT_REMOTE_ADD ) ; $ this -> addCommandSubject ( $ name ) ; $ this -> addCommandSubject ( ... | build add sub command |
53,579 | public function rootDiff ( Commit $ commit ) { if ( ! $ commit -> isRoot ( ) ) { throw new \ InvalidArgumentException ( 'rootDiff method accepts only root commits' ) ; } $ this -> clearAll ( ) ; $ this -> addCommandName ( static :: DIFF_TREE_COMMAND ) ; $ this -> addCommandArgument ( '--cc' ) ; $ this -> addCommandArgu... | get a diff of a root commit with the empty repository |
53,580 | public static function create ( Repository $ repository , string $ name , $ startPoint = null , string $ message = null ) { $ repository -> getCaller ( ) -> execute ( TagCommand :: getInstance ( $ repository ) -> create ( $ name , $ startPoint , $ message ) ) ; return $ repository -> getTag ( $ name ) ; } | Creates a new tag on the repository and returns it |
53,581 | public function delete ( ) { $ this -> repository -> getCaller ( ) -> execute ( TagCommand :: getInstance ( $ this -> getRepository ( ) ) -> delete ( $ this ) ) ; } | deletes the tag |
53,582 | public function clearAll ( ) { $ this -> commandName = null ; $ this -> configs = array ( ) ; $ this -> commandArguments = array ( ) ; $ this -> commandSubject = null ; $ this -> commandSubject2 = null ; $ this -> path = null ; $ this -> binaryVersion = null ; } | Clear all previous variables |
53,583 | protected function addGlobalConfigs ( $ configs ) { if ( ! empty ( $ configs ) ) { foreach ( $ configs as $ config => $ value ) { $ this -> globalConfigs [ $ config ] = $ value ; } } } | Set global configs |
53,584 | protected function addGlobalOptions ( $ options ) { if ( ! empty ( $ options ) ) { foreach ( $ options as $ name => $ value ) { $ this -> globalOptions [ $ name ] = $ value ; } } } | Set global option |
53,585 | public function normalizeOptions ( array $ options = array ( ) , array $ switchOptions = array ( ) , $ valueOptions = array ( ) ) { $ normalizedOptions = array ( ) ; foreach ( $ options as $ option ) { if ( array_key_exists ( $ option , $ switchOptions ) ) { $ normalizedOptions [ $ switchOptions [ $ option ] ] = $ swit... | Normalize any valid option to its long name an provide a structure that can be more intelligently handled by other routines |
53,586 | public function getCommand ( ) { if ( is_null ( $ this -> commandName ) ) { throw new \ RuntimeException ( "You should pass a commandName to execute a command" ) ; } $ command = '' ; $ command .= $ this -> getCLIConfigs ( ) ; $ command .= $ this -> getCLIGlobalOptions ( ) ; $ command .= $ this -> getCLICommandName ( ) ... | Get the current command |
53,587 | private function getCLICommandArguments ( ) { $ command = '' ; $ combinedArguments = array_merge ( $ this -> globalCommandArguments , $ this -> commandArguments ) ; if ( count ( $ combinedArguments ) > 0 ) { $ command .= ' ' . implode ( ' ' , array_map ( 'escapeshellarg' , $ combinedArguments ) ) ; } return $ command ;... | get a string of CLI - formatted command arguments |
53,588 | private function getCLIConfigs ( ) { $ command = '' ; $ combinedConfigs = array_merge ( $ this -> globalConfigs , $ this -> configs ) ; if ( count ( $ combinedConfigs ) ) { foreach ( $ combinedConfigs as $ config => $ value ) { $ command .= sprintf ( ' %s %s=%s' , escapeshellarg ( '-c' ) , escapeshellarg ( $ config ) ,... | get a string of CLI - formatted configs |
53,589 | private function getCLIGlobalOptions ( ) { $ command = '' ; if ( count ( $ this -> globalOptions ) > 0 ) { foreach ( $ this -> globalOptions as $ name => $ value ) { $ command .= sprintf ( ' %s=%s' , escapeshellarg ( $ name ) , escapeshellarg ( $ value ) ) ; } } return $ command ; } | get a string of CLI - formatted global options |
53,590 | private function getCLIPath ( ) { $ command = '' ; if ( ! is_null ( $ this -> path ) ) { $ command .= sprintf ( ' -- %s' , escapeshellarg ( $ this -> path ) ) ; } return $ command ; } | get a string of CLI - formatted path |
53,591 | private function getCLISubjects ( ) { $ command = '' ; if ( ! is_null ( $ this -> commandSubject ) ) { $ command .= ' ' ; if ( $ this -> commandSubject instanceof SubCommandCommand ) { $ command .= $ this -> commandSubject -> getCommand ( ) ; } else { if ( is_array ( $ this -> commandSubject ) ) { $ command .= implode ... | get a string of CLI - formatted subjects |
53,592 | public function getTagCommit ( Tag $ tag ) { $ this -> clearAll ( ) ; $ this -> addCommandName ( static :: GIT_REVLIST ) ; $ this -> addCommandArgument ( '-n1' ) ; $ this -> addCommandSubject ( $ tag -> getFullRef ( ) ) ; return $ this -> getCommand ( ) ; } | get tag commit command via rev - list |
53,593 | public function commitPath ( Commit $ commit , $ max = 1000 ) { $ this -> clearAll ( ) ; $ this -> addCommandName ( static :: GIT_REVLIST ) ; $ this -> addCommandArgument ( sprintf ( '--max-count=%s' , $ max ) ) ; $ this -> addCommandSubject ( $ commit -> getSha ( ) ) ; return $ this -> getCommand ( ) ; } | get the commits path to the passed commit . Useful to count commits in a repo |
53,594 | private function parseOutputLines ( array $ outputLines ) { foreach ( $ outputLines as $ line ) { $ this -> parseLine ( $ line ) ; } usort ( $ this -> children , [ $ this , 'sortChildren' ] ) ; $ this -> scanPathsForBlob ( $ outputLines ) ; } | parse the output of a git command showing a ls - tree |
53,595 | public function getParent ( ) { if ( $ this -> isRoot ( ) ) { return null ; } return substr ( $ this -> subject -> getFullPath ( ) , 0 , strrpos ( $ this -> subject -> getFullPath ( ) , '/' ) ) ; } | get the current tree parent null if root |
53,596 | public function getBinaryData ( ) { $ cmd = CatFileCommand :: getInstance ( $ this -> getRepository ( ) ) -> content ( $ this -> getSubject ( ) , $ this -> ref ) ; return $ this -> getCaller ( ) -> execute ( $ cmd ) -> getRawOutput ( ) ; } | get binary data |
53,597 | private function scanPathsForBlob ( array $ outputLines ) { if ( count ( $ this -> children ) > 0 ) { return ; } if ( $ this -> isRoot ( ) ) { return ; } if ( 1 === count ( $ outputLines ) ) { $ treeObject = NodeObject :: createFromOutputLine ( $ this -> repository , $ outputLines [ 0 ] ) ; if ( $ treeObject -> getSha ... | check if the path is equals to a fullPath to tell if it s a blob |
53,598 | private function parseLine ( $ line ) { if ( $ line == '' ) { return ; } $ slices = NodeObject :: getLineSlices ( $ line ) ; if ( $ this -> isBlob ( ) ) { $ this -> pathChildren [ ] = $ this -> blob -> getName ( ) ; } else { if ( $ this -> isRoot ( ) ) { $ pattern = '/(\w+)\/(.*)/' ; $ replacement = '$1' ; } else { $ a... | Parse a single line into pieces |
53,599 | public function getLastCommit ( $ ref = 'master' ) { if ( $ this -> isRoot ( ) ) { return $ this -> getRepository ( ) -> getCommit ( $ ref ) ; } $ log = $ this -> repository -> getObjectLog ( $ this -> getObject ( ) , $ ref ) ; return $ log [ 0 ] ; } | get the last commit for a given treeish for the actual tree |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.