idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
21,400 | protected function parseDateInterval ( $ delay ) { if ( $ delay instanceof DateInterval ) { $ delay = Carbon :: now ( ) -> add ( $ delay ) ; } return $ delay ; } | If the given value is an interval convert it to a DateTime instance . |
21,401 | protected function createPdoResolver ( array $ config ) { return array_key_exists ( 'host' , $ config ) ? $ this -> createPdoResolverWithHosts ( $ config ) : $ this -> createPdoResolverWithoutHosts ( $ config ) ; } | Create a new Closure that resolves to a PDO instance . |
21,402 | protected function parseHosts ( array $ config ) { $ hosts = Arr :: wrap ( $ config [ 'host' ] ) ; if ( empty ( $ hosts ) ) { throw new InvalidArgumentException ( 'Database hosts array is empty.' ) ; } return $ hosts ; } | Parse the hosts configuration item into an array . |
21,403 | public static function prepend ( $ array , $ value , $ key = null ) { if ( is_null ( $ key ) ) { array_unshift ( $ array , $ value ) ; } else { $ array = [ $ key => $ value ] + $ array ; } return $ array ; } | Push an item onto the beginning of an array . |
21,404 | public function queue ( MailableContract $ mailable ) { $ mailable = $ this -> fill ( $ mailable ) ; if ( isset ( $ mailable -> delay ) ) { return $ this -> mailer -> later ( $ mailable -> delay , $ mailable ) ; } return $ this -> mailer -> queue ( $ mailable ) ; } | Push the given mailable onto the queue . |
21,405 | public function forget ( $ name , $ path = null , $ domain = null ) { return $ this -> make ( $ name , null , - 2628000 , $ path , $ domain ) ; } | Expire the given cookie . |
21,406 | protected function setItems ( $ items ) { $ this -> items = $ items instanceof Collection ? $ items : Collection :: make ( $ items ) ; $ this -> hasMore = $ this -> items -> count ( ) > $ this -> perPage ; $ this -> items = $ this -> items -> slice ( 0 , $ this -> perPage ) ; } | Set the items for the paginator . |
21,407 | public function create ( Event $ event , DateTimeInterface $ time ) { return $ this -> cache -> store ( $ this -> store ) -> add ( $ event -> mutexName ( ) . $ time -> format ( 'Hi' ) , true , 3600 ) ; } | Attempt to obtain a scheduling mutex for the given event . |
21,408 | public function exists ( Event $ event , DateTimeInterface $ time ) { return $ this -> cache -> store ( $ this -> store ) -> has ( $ event -> mutexName ( ) . $ time -> format ( 'Hi' ) ) ; } | Determine if a scheduling mutex exists for the given event . |
21,409 | public function attempts ( ) { $ stats = $ this -> pheanstalk -> statsJob ( $ this -> job ) ; return ( int ) $ stats -> reserves ; } | Get the number of times the job has been attempted . |
21,410 | public function orOn ( $ first , $ operator = null , $ second = null ) { return $ this -> on ( $ first , $ operator , $ second , 'or' ) ; } | Add an or on clause to the join . |
21,411 | public function __isset ( $ name ) { if ( is_object ( $ this -> value ) ) { return isset ( $ this -> value -> { $ name } ) ; } if ( is_array ( $ this -> value ) || $ this -> value instanceof ArrayObject ) { return isset ( $ this -> value [ $ name ] ) ; } return false ; } | Dynamically check a property exists on the underlying object . |
21,412 | public static function safe_float_2 ( $ object , $ key1 , $ key2 , $ default_value = null ) { $ value = static :: safe_float ( $ object , $ key1 ) ; return isset ( $ value ) ? $ value : static :: safe_float ( $ object , $ key2 , $ default_value ) ; } | we re not using safe_float_3 either because those cases are too rare to deserve their own optimization |
21,413 | public function throttle ( ) { $ now = $ this -> milliseconds ( ) ; $ elapsed = $ now - $ this -> lastRestRequestTimestamp ; if ( $ elapsed < $ this -> rateLimit ) { $ delay = $ this -> rateLimit - $ elapsed ; usleep ( ( int ) ( $ delay * 1000.0 ) ) ; } } | this method is experimental |
21,414 | public function write ( $ input ) { if ( null === $ input ) { return ; } if ( $ this -> isClosed ( ) ) { throw new RuntimeException ( sprintf ( '%s is closed' , static :: class ) ) ; } $ this -> input [ ] = ProcessUtils :: validateInput ( __METHOD__ , $ input ) ; } | Appends an input to the write buffer . |
21,415 | public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; foreach ( $ this -> formats as $ format => $ mimeTypes ) { $ request -> setFormat ( $ format , $ mimeTypes ) ; } } | Adds request formats . |
21,416 | private function extractFromConstructor ( string $ class , string $ property ) : ? array { try { $ reflectionClass = new \ ReflectionClass ( $ class ) ; } catch ( \ ReflectionException $ e ) { return null ; } $ constructor = $ reflectionClass -> getConstructor ( ) ; if ( ! $ constructor ) { return null ; } foreach ( $ ... | Tries to extract type information from constructor . |
21,417 | private function getAccessorMethod ( string $ class , string $ property ) : ? array { $ ucProperty = ucfirst ( $ property ) ; foreach ( $ this -> accessorPrefixes as $ prefix ) { try { $ reflectionMethod = new \ ReflectionMethod ( $ class , $ prefix . $ ucProperty ) ; if ( $ reflectionMethod -> isStatic ( ) ) { continu... | Gets the accessor method . |
21,418 | private function getMutatorMethod ( string $ class , string $ property ) : ? array { $ ucProperty = ucfirst ( $ property ) ; $ ucSingulars = ( array ) Inflector :: singularize ( $ ucProperty ) ; foreach ( $ this -> mutatorPrefixes as $ prefix ) { $ names = [ $ ucProperty ] ; if ( \ in_array ( $ prefix , $ this -> array... | Returns an array with a the instance of \ ReflectionMethod as first key and the prefix of the method as second or null if not found . |
21,419 | public function onVoterVote ( VoteEvent $ event ) { $ this -> traceableAccessDecisionManager -> addVoterVote ( $ event -> getVoter ( ) , $ event -> getAttributes ( ) , $ event -> getVote ( ) ) ; } | Event dispatched by a voter during access manager decision . |
21,420 | public static function register ( $ mode = 0 ) { if ( self :: $ isRegistered ) { return ; } self :: $ utilPrefix = class_exists ( 'PHPUnit_Util_ErrorHandler' ) ? 'PHPUnit_Util_' : 'PHPUnit\Util\\' ; $ handler = new self ( ) ; $ oldErrorHandler = set_error_handler ( [ $ handler , 'handleError' ] ) ; if ( null !== $ oldE... | Registers and configures the deprecation handler . |
21,421 | private static function hasColorSupport ( ) { if ( ! \ defined ( 'STDOUT' ) ) { return false ; } if ( 'Hyper' === getenv ( 'TERM_PROGRAM' ) ) { return true ; } if ( \ DIRECTORY_SEPARATOR === '\\' ) { return ( \ function_exists ( 'sapi_windows_vt100_support' ) && sapi_windows_vt100_support ( STDOUT ) ) || false !== gete... | Returns true if STDOUT is defined and supports colorization . |
21,422 | public function removeCookie ( $ name , $ path = '/' , $ domain = null ) { if ( null === $ path ) { $ path = '/' ; } unset ( $ this -> cookies [ $ domain ] [ $ path ] [ $ name ] ) ; if ( empty ( $ this -> cookies [ $ domain ] [ $ path ] ) ) { unset ( $ this -> cookies [ $ domain ] [ $ path ] ) ; if ( empty ( $ this -> ... | Removes a cookie from the array but does not unset it in the browser . |
21,423 | public function getCookies ( $ format = self :: COOKIES_FLAT ) { if ( ! \ in_array ( $ format , [ self :: COOKIES_FLAT , self :: COOKIES_ARRAY ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Format "%s" invalid (%s).' , $ format , implode ( ', ' , [ self :: COOKIES_FLAT , self :: COOKIES_ARRAY ] ) ) ) ; } if ... | Returns an array with all cookies . |
21,424 | protected function computeCacheControlValue ( ) { if ( ! $ this -> cacheControl && ! $ this -> has ( 'ETag' ) && ! $ this -> has ( 'Last-Modified' ) && ! $ this -> has ( 'Expires' ) ) { return 'no-cache, private' ; } if ( ! $ this -> cacheControl ) { return 'private, must-revalidate' ; } $ header = $ this -> getCacheCo... | Returns the calculated value of the cache - control header . |
21,425 | protected static function getPattern ( $ currency ) { if ( ! $ currency ) { return '{{ widget }}' ; } $ locale = \ Locale :: getDefault ( ) ; if ( ! isset ( self :: $ patterns [ $ locale ] ) ) { self :: $ patterns [ $ locale ] = [ ] ; } if ( ! isset ( self :: $ patterns [ $ locale ] [ $ currency ] ) ) { $ format = new ... | Returns the pattern for this locale in UTF - 8 . |
21,426 | private static function computeRegexp ( array $ tokens , int $ index , int $ firstOptional ) : string { $ token = $ tokens [ $ index ] ; if ( 'text' === $ token [ 0 ] ) { return preg_quote ( $ token [ 1 ] , self :: REGEX_DELIMITER ) ; } else { if ( 0 === $ index && 0 === $ firstOptional ) { return sprintf ( '%s(?P<%s>%... | Computes the regexp used to match a specific token . It can be static text or a subpattern . |
21,427 | public static function instantiate ( string $ class , array $ properties = [ ] , array $ privateProperties = [ ] ) { $ reflector = Registry :: $ reflectors [ $ class ] ?? Registry :: getClassReflector ( $ class ) ; if ( Registry :: $ cloneable [ $ class ] ) { $ wrappedInstance = [ clone Registry :: $ prototypes [ $ cla... | Creates an object and sets its properties without calling its constructor nor any other methods . |
21,428 | public function tokenize ( Reader $ reader ) { $ stream = new TokenStream ( ) ; while ( ! $ reader -> isEOF ( ) ) { foreach ( $ this -> handlers as $ handler ) { if ( $ handler -> handle ( $ reader , $ stream ) ) { continue 2 ; } } $ stream -> push ( new Token ( Token :: TYPE_DELIMITER , $ reader -> getSubstring ( 1 ) ... | Tokenize selector source code . |
21,429 | public static function getPlaceholderFormatterDefinition ( string $ name ) : ? callable { if ( ! self :: $ formatters ) { self :: $ formatters = self :: initPlaceholderFormatters ( ) ; } return isset ( self :: $ formatters [ $ name ] ) ? self :: $ formatters [ $ name ] : null ; } | Gets the placeholder formatter for a given name . |
21,430 | public static function getFormatDefinition ( string $ name ) : ? string { if ( ! self :: $ formats ) { self :: $ formats = self :: initFormats ( ) ; } return isset ( self :: $ formats [ $ name ] ) ? self :: $ formats [ $ name ] : null ; } | Gets the format for a given name . |
21,431 | public function iterate ( iterable $ iterable , ? int $ max = null ) : iterable { $ this -> start ( $ max ?? ( \ is_countable ( $ iterable ) ? \ count ( $ iterable ) : 0 ) ) ; foreach ( $ iterable as $ key => $ value ) { yield $ key => $ value ; $ this -> advance ( ) ; } $ this -> finish ( ) ; } | Returns an iterator that will automatically update the progress bar when iterated . |
21,432 | public function clear ( ) : void { if ( ! $ this -> overwrite ) { return ; } if ( null === $ this -> format ) { $ this -> setRealFormat ( $ this -> internalFormat ? : $ this -> determineBestFormat ( ) ) ; } $ this -> overwrite ( '' ) ; } | Removes the progress bar from the current line . |
21,433 | protected function loadUser ( $ username , Entry $ entry ) { $ password = null ; if ( null !== $ this -> passwordAttribute ) { $ password = $ this -> getAttributeValue ( $ entry , $ this -> passwordAttribute ) ; } return new User ( $ username , $ password , $ this -> defaultRoles ) ; } | Loads a user from an LDAP entry . |
21,434 | private function getAttributeValue ( Entry $ entry , $ attribute ) { if ( ! $ entry -> hasAttribute ( $ attribute ) ) { throw new InvalidArgumentException ( sprintf ( 'Missing attribute "%s" for user "%s".' , $ attribute , $ entry -> getDn ( ) ) ) ; } $ values = $ entry -> getAttribute ( $ attribute ) ; if ( 1 !== \ co... | Fetches a required unique attribute value from an LDAP entry . |
21,435 | private function flushMemorySpool ( ) { $ mailerTransport = $ this -> mailer -> getTransport ( ) ; if ( ! $ mailerTransport instanceof \ Swift_Transport_SpoolTransport ) { return ; } $ spool = $ mailerTransport -> getSpool ( ) ; if ( ! $ spool instanceof \ Swift_MemorySpool ) { return ; } if ( null === $ this -> transp... | Flushes the mail queue if a memory spool is used . |
21,436 | public function createLock ( $ resource , $ ttl = 300.0 , $ autoRelease = true ) { $ lock = new Lock ( new Key ( $ resource ) , $ this -> store , $ ttl , $ autoRelease ) ; $ lock -> setLogger ( $ this -> logger ) ; return $ lock ; } | Creates a lock for the given resource . |
21,437 | private function tokensToString ( array $ tokens ) : string { $ lineCount = 0 ; $ headerLines = [ ] ; $ headerLines [ ] = $ this -> name . ': ' ; $ currentLine = & $ headerLines [ $ lineCount ++ ] ; foreach ( $ tokens as $ i => $ token ) { if ( ( "\r\n" === $ token ) || ( $ i > 0 && \ strlen ( $ currentLine . $ token )... | Takes an array of tokens which appear in the header and turns them into an RFC 2822 compliant string adding FWSP where needed . |
21,438 | public function setMaxRedirects ( $ maxRedirects ) { $ this -> maxRedirects = $ maxRedirects < 0 ? - 1 : $ maxRedirects ; $ this -> followRedirects = - 1 != $ this -> maxRedirects ; } | Sets the maximum number of redirects that crawler can follow . |
21,439 | public function getCrawler ( ) { if ( null === $ this -> crawler ) { @ trigger_error ( sprintf ( 'Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.' , \ get_class ( $ this ) . '::' . __FUNCTION__ ) , E_USER_DEPRECATED ) ; } return $ this -> crawler ... | Returns the current Crawler instance . |
21,440 | public function getInternalResponse ( ) { if ( null === $ this -> internalResponse ) { @ trigger_error ( sprintf ( 'Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.' , \ get_class ( $ this ) . '::' . __FUNCTION__ ) , E_USER_DEPRECATED ) ; } return ... | Returns the current BrowserKit Response instance . |
21,441 | public function getResponse ( ) { if ( null === $ this -> response ) { @ trigger_error ( sprintf ( 'Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.' , \ get_class ( $ this ) . '::' . __FUNCTION__ ) , E_USER_DEPRECATED ) ; } return $ this -> respon... | Returns the current origin response instance . |
21,442 | public function getInternalRequest ( ) { if ( null === $ this -> internalRequest ) { @ trigger_error ( sprintf ( 'Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.' , \ get_class ( $ this ) . '::' . __FUNCTION__ ) , E_USER_DEPRECATED ) ; } return $ ... | Returns the current BrowserKit Request instance . |
21,443 | public function getRequest ( ) { if ( null === $ this -> request ) { @ trigger_error ( sprintf ( 'Calling the "%s()" method before the "request()" one is deprecated since Symfony 4.1 and will throw an exception in 5.0.' , \ get_class ( $ this ) . '::' . __FUNCTION__ ) , E_USER_DEPRECATED ) ; } return $ this -> request ... | Returns the current origin Request instance . |
21,444 | public function submit ( Form $ form , array $ values = [ ] ) { if ( \ func_num_args ( ) < 3 && __CLASS__ !== \ get_class ( $ this ) && __CLASS__ !== ( new \ ReflectionMethod ( $ this , __FUNCTION__ ) ) -> getDeclaringClass ( ) -> getName ( ) && ! $ this instanceof \ PHPUnit \ Framework \ MockObject \ MockObject && ! $... | Submits a form . |
21,445 | public function submitForm ( string $ button , array $ fieldValues = [ ] , string $ method = 'POST' , array $ serverParameters = [ ] ) : Crawler { if ( null === $ this -> crawler ) { throw new BadMethodCallException ( sprintf ( 'The "request()" method must be called before "%s()".' , __METHOD__ ) ) ; } $ buttonNode = $... | Finds the first form that contains a button with the given content and uses it to submit the given form field values . |
21,446 | protected function createCrawlerFromContent ( $ uri , $ content , $ type ) { if ( ! class_exists ( 'Symfony\Component\DomCrawler\Crawler' ) ) { return ; } $ crawler = new Crawler ( null , $ uri ) ; $ crawler -> addContent ( $ content , $ type ) ; return $ crawler ; } | Creates a crawler . |
21,447 | public function back ( ) { do { $ request = $ this -> history -> back ( ) ; } while ( \ array_key_exists ( serialize ( $ request ) , $ this -> redirects ) ) ; return $ this -> requestFromRequest ( $ request , false ) ; } | Goes back in the browser history . |
21,448 | protected function getAbsoluteUri ( $ uri ) { if ( 0 === strpos ( $ uri , 'http://' ) || 0 === strpos ( $ uri , 'https://' ) ) { return $ uri ; } if ( ! $ this -> history -> isEmpty ( ) ) { $ currentUri = $ this -> history -> current ( ) -> getUri ( ) ; } else { $ currentUri = sprintf ( 'http%s://%s/' , isset ( $ this ... | Takes a URI and converts it to absolute if it is not already absolute . |
21,449 | protected function requestFromRequest ( Request $ request , $ changeHistory = true ) { return $ this -> request ( $ request -> getMethod ( ) , $ request -> getUri ( ) , $ request -> getParameters ( ) , $ request -> getFiles ( ) , $ request -> getServer ( ) , $ request -> getContent ( ) , $ changeHistory ) ; } | Makes a request from a Request object directly . |
21,450 | public function setOutput ( $ output ) { $ prev = null !== $ this -> outputStream ? $ this -> outputStream : $ this -> lineDumper ; if ( \ is_callable ( $ output ) ) { $ this -> outputStream = null ; $ this -> lineDumper = $ output ; } else { if ( \ is_string ( $ output ) ) { $ output = fopen ( $ output , 'wb' ) ; } $ ... | Sets the output destination of the dumps . |
21,451 | public function setCharset ( $ charset ) { $ prev = $ this -> charset ; $ charset = strtoupper ( $ charset ) ; $ charset = null === $ charset || 'UTF-8' === $ charset || 'UTF8' === $ charset ? 'CP1252' : $ charset ; $ this -> charset = $ charset ; return $ prev ; } | Sets the default character encoding to use for non - UTF8 strings . |
21,452 | public function dump ( Data $ data , $ output = null ) { $ this -> decimalPoint = localeconv ( ) ; $ this -> decimalPoint = $ this -> decimalPoint [ 'decimal_point' ] ; if ( $ locale = $ this -> flags & ( self :: DUMP_COMMA_SEPARATOR | self :: DUMP_TRAILING_COMMA ) ? setlocale ( LC_NUMERIC , 0 ) : null ) { setlocale ( ... | Dumps a Data object . |
21,453 | protected function dumpLine ( $ depth ) { ( $ this -> lineDumper ) ( $ this -> line , $ depth , $ this -> indentPad ) ; $ this -> line = '' ; } | Dumps the current line . |
21,454 | protected function utf8Encode ( $ s ) { if ( preg_match ( '//u' , $ s ) ) { return $ s ; } if ( ! \ function_exists ( 'iconv' ) ) { throw new \ RuntimeException ( 'Unable to convert a non-UTF-8 string to UTF-8: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.' ) ; } if (... | Converts a non - UTF - 8 string to UTF - 8 . |
21,455 | private function appendDocument ( \ DOMNode $ parentNode , \ DOMNode $ importedParent ) { foreach ( $ importedParent -> childNodes as $ childNode ) { $ parentNode -> appendChild ( $ parentNode -> ownerDocument -> importNode ( $ childNode , true ) ) ; } } | Appends document children to parent node . |
21,456 | private function writeDocument ( \ DOMDocument $ dom ) { $ dom -> formatOutput = true ; $ this -> write ( $ dom -> saveXML ( ) ) ; } | Writes DOM document . |
21,457 | public function join ( string $ combiner , self $ expr ) : self { $ path = $ this -> __toString ( ) . $ combiner ; if ( '*/' !== $ expr -> path ) { $ path .= $ expr -> path ; } $ this -> path = $ path ; $ this -> element = $ expr -> element ; $ this -> condition = $ expr -> condition ; return $ this ; } | Joins another XPathExpr with a combiner . |
21,458 | private static function getProxy ( ? string $ proxy , array $ url ) : ? array { if ( null === $ proxy ) { $ proxy = $ _SERVER [ 'http_proxy' ] ?? ( \ in_array ( \ PHP_SAPI , [ 'cli' , 'phpdbg' ] , true ) ? $ _SERVER [ 'HTTP_PROXY' ] ?? null : null ) ?? $ _SERVER [ 'all_proxy' ] ?? $ _SERVER [ 'ALL_PROXY' ] ?? null ; if... | Loads proxy configuration from the same environment variables as curl when no proxy is explicitly set . |
21,459 | private static function dnsResolve ( array $ url , NativeClientState $ multi , array & $ info , ? \ Closure $ onProgress ) : array { if ( $ port = parse_url ( $ url [ 'authority' ] , PHP_URL_PORT ) ? : '' ) { $ info [ 'primary_port' ] = $ port ; $ port = ':' . $ port ; } else { $ info [ 'primary_port' ] = 'http:' === $... | Resolves the IP of the host using the local DNS cache if possible . |
21,460 | public static function substr ( $ string , $ from , $ length = null ) { if ( false === $ encoding = mb_detect_encoding ( $ string , null , true ) ) { return substr ( $ string , $ from , $ length ) ; } return mb_substr ( $ string , $ from , $ length , $ encoding ) ; } | Returns the subset of a string using mb_substr if it is available . |
21,461 | protected function templateExists ( $ template ) { $ template = ( string ) $ template ; $ loader = $ this -> twig -> getLoader ( ) ; if ( $ loader instanceof ExistsLoaderInterface || method_exists ( $ loader , 'exists' ) ) { return $ loader -> exists ( $ template ) ; } try { $ loader -> getSourceContext ( $ template ) ... | to be removed when the minimum required version of Twig is > = 3 . 0 |
21,462 | private function addMessage ( array & $ messages , array $ item ) { if ( \ is_array ( $ item [ 'translated' ] ) ) { $ messages [ stripcslashes ( $ item [ 'ids' ] [ 'singular' ] ) ] = stripcslashes ( $ item [ 'translated' ] [ 0 ] ) ; if ( isset ( $ item [ 'ids' ] [ 'plural' ] ) ) { $ plurals = $ item [ 'translated' ] ; ... | Save a translation item to the messages . |
21,463 | private function buildId ( FormInterface $ form ) { $ id = $ form -> getName ( ) ; if ( null !== $ form -> getParent ( ) ) { $ id = $ this -> buildId ( $ form -> getParent ( ) ) . '_' . $ id ; } return $ id ; } | Recursively builds an HTML ID for a form . |
21,464 | private function getDecoder ( string $ format , array $ context ) : DecoderInterface { if ( isset ( $ this -> decoderByFormat [ $ format ] ) && isset ( $ this -> decoders [ $ this -> decoderByFormat [ $ format ] ] ) ) { return $ this -> decoders [ $ this -> decoderByFormat [ $ format ] ] ; } foreach ( $ this -> decoder... | Gets the decoder supporting the format . |
21,465 | protected function parseController ( $ controller ) { if ( \ is_string ( $ controller ) && false !== strpos ( $ controller , '::' ) ) { $ controller = explode ( '::' , $ controller ) ; } if ( \ is_array ( $ controller ) ) { try { $ r = new \ ReflectionMethod ( $ controller [ 0 ] , $ controller [ 1 ] ) ; return [ 'class... | Parse a controller . |
21,466 | protected function deliver ( Response $ response ) { if ( ! $ response -> isSuccessful ( ) ) { throw new \ RuntimeException ( sprintf ( 'Error when rendering "%s" (Status code is %s).' , $ this -> requestStack -> getCurrentRequest ( ) -> getUri ( ) , $ response -> getStatusCode ( ) ) ) ; } if ( ! $ response instanceof ... | Delivers the Response as a string . |
21,467 | private function evaluate ( string $ script , string $ resource , array $ args ) { if ( $ this -> redis instanceof \ Redis || $ this -> redis instanceof \ RedisCluster || $ this -> redis instanceof RedisProxy || $ this -> redis instanceof RedisClusterProxy ) { return $ this -> redis -> eval ( $ script , array_merge ( [... | Evaluates a script in the corresponding redis client . |
21,468 | private function readIndex ( $ zval , $ index ) { if ( ! $ zval [ self :: VALUE ] instanceof \ ArrayAccess && ! \ is_array ( $ zval [ self :: VALUE ] ) ) { throw new NoSuchIndexException ( sprintf ( 'Cannot read index "%s" from object of type "%s" because it doesn\'t implement \ArrayAccess.' , $ index , \ get_class ( $... | Reads a key from an array - like structure . |
21,469 | private function readProperty ( $ zval , $ property , bool $ ignoreInvalidProperty = false ) { if ( ! \ is_object ( $ zval [ self :: VALUE ] ) ) { throw new NoSuchPropertyException ( sprintf ( 'Cannot read property "%s" from an array. Maybe you intended to write the property path as "[%1$s]" instead.' , $ property ) ) ... | Reads the a property from an object . |
21,470 | private function writeIndex ( $ zval , $ index , $ value ) { if ( ! $ zval [ self :: VALUE ] instanceof \ ArrayAccess && ! \ is_array ( $ zval [ self :: VALUE ] ) ) { throw new NoSuchIndexException ( sprintf ( 'Cannot modify index "%s" in object of type "%s" because it doesn\'t implement \ArrayAccess.' , $ index , \ ge... | Sets the value of an index in a given array - accessible value . |
21,471 | private function writeProperty ( $ zval , $ property , $ value ) { if ( ! \ is_object ( $ zval [ self :: VALUE ] ) ) { throw new NoSuchPropertyException ( sprintf ( 'Cannot write property "%s" to an array. Maybe you should write the property path as "[%1$s]" instead?' , $ property ) ) ; } $ object = $ zval [ self :: VA... | Sets the value of a property in the given object . |
21,472 | private function isPropertyWritable ( $ object , string $ property ) : bool { if ( ! \ is_object ( $ object ) ) { return false ; } $ access = $ this -> getWriteAccessInfo ( \ get_class ( $ object ) , $ property , [ ] ) ; $ isWritable = self :: ACCESS_TYPE_METHOD === $ access [ self :: ACCESS_TYPE ] || self :: ACCESS_TY... | Returns whether a property is writable in the given object . |
21,473 | private function getPropertyPath ( $ propertyPath ) : PropertyPath { if ( $ propertyPath instanceof PropertyPathInterface ) { return $ propertyPath ; } if ( isset ( $ this -> propertyPathCache [ $ propertyPath ] ) ) { return $ this -> propertyPathCache [ $ propertyPath ] ; } if ( $ this -> cacheItemPool ) { $ item = $ ... | Gets a PropertyPath instance and caches it . |
21,474 | public static function createCache ( $ namespace , $ defaultLifetime , $ version , LoggerInterface $ logger = null ) { if ( ! class_exists ( 'Symfony\Component\Cache\Adapter\ApcuAdapter' ) ) { throw new \ LogicException ( sprintf ( 'The Symfony Cache component must be installed to use %s().' , __METHOD__ ) ) ; } if ( !... | Creates the APCu adapter if applicable . |
21,475 | public function pop ( OutputFormatterStyleInterface $ style = null ) { if ( empty ( $ this -> styles ) ) { return $ this -> emptyStyle ; } if ( null === $ style ) { return array_pop ( $ this -> styles ) ; } foreach ( array_reverse ( $ this -> styles , true ) as $ index => $ stackedStyle ) { if ( $ style -> apply ( '' )... | Pops a style from the stack . |
21,476 | public function getCurrent ( ) { if ( empty ( $ this -> styles ) ) { return $ this -> emptyStyle ; } return $ this -> styles [ \ count ( $ this -> styles ) - 1 ] ; } | Computes current style with stacks top codes . |
21,477 | private function getDebugLogger ( ) { foreach ( $ this -> processors as $ processor ) { if ( $ processor instanceof DebugLoggerInterface ) { return $ processor ; } } foreach ( $ this -> handlers as $ handler ) { if ( $ handler instanceof DebugLoggerInterface ) { return $ handler ; } } } | Returns a DebugLoggerInterface instance if one is registered with this logger . |
21,478 | public static function getErrorName ( $ errorCode ) { if ( ! isset ( static :: $ errorNames [ $ errorCode ] ) ) { throw new InvalidArgumentException ( sprintf ( 'The error code "%s" does not exist for constraint of type "%s".' , $ errorCode , \ get_called_class ( ) ) ) ; } return static :: $ errorNames [ $ errorCode ] ... | Returns the name of the given error code . |
21,479 | public function addImplicitGroupName ( $ group ) { if ( \ in_array ( self :: DEFAULT_GROUP , $ this -> groups ) && ! \ in_array ( $ group , $ this -> groups ) ) { $ this -> groups [ ] = $ group ; } } | Adds the given group if this constraint is in the Default group . |
21,480 | public function createRedirectResponse ( Request $ request , $ path , $ status = 302 ) { if ( null !== $ this -> secureDomainRegexp && 'https' === $ this -> urlMatcher -> getContext ( ) -> getScheme ( ) && preg_match ( '#^https?:[/\\\\]{2,}+[^/]++#i' , $ path , $ host ) && ! preg_match ( sprintf ( $ this -> secureDomai... | Creates a redirect Response . |
21,481 | public function createRequest ( Request $ request , $ path ) { $ newRequest = Request :: create ( $ this -> generateUri ( $ request , $ path ) , 'get' , [ ] , $ request -> cookies -> all ( ) , [ ] , $ request -> server -> all ( ) ) ; static $ setSession ; if ( null === $ setSession ) { $ setSession = \ Closure :: bind ... | Creates a Request . |
21,482 | public function checkRequestPath ( Request $ request , $ path ) { if ( '/' !== $ path [ 0 ] ) { try { if ( $ this -> urlMatcher instanceof RequestMatcherInterface ) { $ parameters = $ this -> urlMatcher -> matchRequest ( $ request ) ; } else { $ parameters = $ this -> urlMatcher -> match ( $ request -> getPathInfo ( ) ... | Checks that a given path matches the Request . |
21,483 | public function generateUri ( $ request , $ path ) { if ( 0 === strpos ( $ path , 'http' ) || ! $ path ) { return $ path ; } if ( '/' === $ path [ 0 ] ) { return $ request -> getUriForPath ( $ path ) ; } if ( null === $ this -> urlGenerator ) { throw new \ LogicException ( 'You must provide a UrlGeneratorInterface inst... | Generates a URI based on the given path or absolute URL . |
21,484 | public function getDefaultValue ( ) { if ( ! $ this -> hasDefaultValue ) { throw new \ LogicException ( sprintf ( 'Argument $%s does not have a default value. Use %s::hasDefaultValue() to avoid this exception.' , $ this -> name , __CLASS__ ) ) ; } return $ this -> defaultValue ; } | Returns the default value of the argument . |
21,485 | public function cleanup ( ) { foreach ( $ this -> locks as $ lock ) { flock ( $ lock , LOCK_UN ) ; fclose ( $ lock ) ; } $ this -> locks = [ ] ; } | Cleanups storage . |
21,486 | public function lock ( Request $ request ) { $ key = $ this -> getCacheKey ( $ request ) ; if ( ! isset ( $ this -> locks [ $ key ] ) ) { $ path = $ this -> getPath ( $ key ) ; if ( ! file_exists ( \ dirname ( $ path ) ) && false === @ mkdir ( \ dirname ( $ path ) , 0777 , true ) && ! is_dir ( \ dirname ( $ path ) ) ) ... | Tries to lock the cache for a given Request without blocking . |
21,487 | private function requestsMatch ( $ vary , $ env1 , $ env2 ) { if ( empty ( $ vary ) ) { return true ; } foreach ( preg_split ( '/[\s,]+/' , $ vary ) as $ header ) { $ key = str_replace ( '_' , '-' , strtolower ( $ header ) ) ; $ v1 = isset ( $ env1 [ $ key ] ) ? $ env1 [ $ key ] : null ; $ v2 = isset ( $ env2 [ $ key ]... | Determines whether two Request HTTP header sets are non - varying based on the vary response header value provided . |
21,488 | private function load ( $ key ) { $ path = $ this -> getPath ( $ key ) ; return file_exists ( $ path ) ? file_get_contents ( $ path ) : false ; } | Loads data for the given key . |
21,489 | private function save ( $ key , $ data ) { $ path = $ this -> getPath ( $ key ) ; if ( isset ( $ this -> locks [ $ key ] ) ) { $ fp = $ this -> locks [ $ key ] ; @ ftruncate ( $ fp , 0 ) ; @ fseek ( $ fp , 0 ) ; $ len = @ fwrite ( $ fp , $ data ) ; if ( \ strlen ( $ data ) !== $ len ) { @ ftruncate ( $ fp , 0 ) ; retur... | Save data for the given key . |
21,490 | private function getCacheKey ( Request $ request ) { if ( isset ( $ this -> keyCache [ $ request ] ) ) { return $ this -> keyCache [ $ request ] ; } return $ this -> keyCache [ $ request ] = $ this -> generateCacheKey ( $ request ) ; } | Returns a cache key for the given Request . |
21,491 | private function persistResponse ( Response $ response ) { $ headers = $ response -> headers -> all ( ) ; $ headers [ 'X-Status' ] = [ $ response -> getStatusCode ( ) ] ; return $ headers ; } | Persists the Response HTTP headers . |
21,492 | private function restoreResponse ( $ headers , $ body = null ) { $ status = $ headers [ 'X-Status' ] [ 0 ] ; unset ( $ headers [ 'X-Status' ] ) ; if ( null !== $ body ) { $ headers [ 'X-Body-File' ] = [ $ body ] ; } return new Response ( $ body , $ status , $ headers ) ; } | Restores a Response from the HTTP headers and body . |
21,493 | public function addRoute ( string $ prefix , $ route ) { list ( $ prefix , $ staticPrefix ) = $ this -> getCommonPrefix ( $ prefix , $ prefix ) ; for ( $ i = \ count ( $ this -> items ) - 1 ; 0 <= $ i ; -- $ i ) { $ item = $ this -> items [ $ i ] ; list ( $ commonPrefix , $ commonStaticPrefix ) = $ this -> getCommonPre... | Adds a route to a group . |
21,494 | public function populateCollection ( RouteCollection $ routes ) : RouteCollection { foreach ( $ this -> items as $ route ) { if ( $ route instanceof self ) { $ route -> populateCollection ( $ routes ) ; } else { $ routes -> add ( ... $ route ) ; } } return $ routes ; } | Linearizes back a set of nested routes into a collection . |
21,495 | private function encodeByteSequence ( array $ bytes , int & $ size ) : string { $ ret = '' ; $ size = 0 ; foreach ( $ bytes as $ b ) { if ( isset ( $ this -> safeMap [ $ b ] ) ) { $ ret .= $ this -> safeMap [ $ b ] ; ++ $ size ; } else { $ ret .= self :: $ qpMap [ $ b ] ; $ size += 3 ; } } return $ ret ; } | Encode the given byte array into a verbatim QP form . |
21,496 | private function extract ( iterable $ extractors , string $ method , array $ arguments ) { foreach ( $ extractors as $ extractor ) { if ( null !== $ value = $ extractor -> { $ method } ( ... $ arguments ) ) { return $ value ; } } } | Iterates over registered extractors and return the first value found . |
21,497 | public function buildForm ( FormBuilderInterface $ builder , array $ options ) { if ( ! $ options [ 'csrf_protection' ] ) { return ; } $ builder -> addEventSubscriber ( new CsrfValidationListener ( $ options [ 'csrf_field_name' ] , $ options [ 'csrf_token_manager' ] , $ options [ 'csrf_token_id' ] ? : ( $ builder -> ge... | Adds a CSRF field to the form when the CSRF protection is enabled . |
21,498 | public function finishView ( FormView $ view , FormInterface $ form , array $ options ) { if ( $ options [ 'csrf_protection' ] && ! $ view -> parent && $ options [ 'compound' ] ) { $ factory = $ form -> getConfig ( ) -> getFormFactory ( ) ; $ tokenId = $ options [ 'csrf_token_id' ] ? : ( $ form -> getName ( ) ? : \ get... | Adds a CSRF field to the root form view . |
21,499 | public function onCommand ( ConsoleCommandEvent $ event ) { $ output = $ event -> getOutput ( ) ; if ( $ output instanceof ConsoleOutputInterface ) { $ output = $ output -> getErrorOutput ( ) ; } $ this -> setOutput ( $ output ) ; } | Before a command is executed the handler gets activated and the console output is set in order to know where to write the logs . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.