idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
21,700
private function supports ( string $ class ) : bool { $ class = new \ ReflectionClass ( $ class ) ; do { foreach ( $ class -> getProperties ( ) as $ property ) { if ( ! $ property -> isStatic ( ) ) { return true ; } } } while ( $ class = $ class -> getParentClass ( ) ) ; return false ; }
Checks if the given class has any non - static property .
21,701
public static function validateName ( $ name ) { if ( null !== $ name && ! \ is_string ( $ name ) && ! \ is_int ( $ name ) ) { throw new UnexpectedTypeException ( $ name , 'string, integer or null' ) ; } if ( ! self :: isValidName ( $ name ) ) { throw new InvalidArgumentException ( sprintf ( 'The name "%s" contains ill...
Validates whether the given variable is a valid form name .
21,702
public function registerClasses ( Definition $ prototype , $ namespace , $ resource , $ exclude = null ) { if ( '\\' !== substr ( $ namespace , - 1 ) ) { throw new InvalidArgumentException ( sprintf ( 'Namespace prefix must end with a "\\": %s.' , $ namespace ) ) ; } if ( ! preg_match ( '/^(?:[a-zA-Z_\x7f-\xff][a-zA-Z0...
Registers a set of classes as services using PSR - 4 for discovery .
21,703
protected function setDefinition ( $ id , Definition $ definition ) { $ this -> container -> removeBindings ( $ id ) ; if ( $ this -> isLoadingInstanceof ) { if ( ! $ definition instanceof ChildDefinition ) { throw new InvalidArgumentException ( sprintf ( 'Invalid type definition "%s": ChildDefinition expected, "%s" gi...
Registers a definition in the container with its instanceof - conditionals .
21,704
private function checkHost ( string $ host ) : bool { return '' !== $ host && ( $ this -> checkMX ( $ host ) || ( checkdnsrr ( $ host , 'A' ) || checkdnsrr ( $ host , 'AAAA' ) ) ) ; }
Check if one of MX A or AAAA DNS RR exists .
21,705
public function load ( $ resource , $ type = null ) { if ( ! preg_match ( '/^[^\:]+(?:::?(?:[^\:]+))?$/' , $ resource ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method...
Calls the service that will load the routes .
21,706
private function validateObject ( $ object , $ propertyPath , array $ groups , $ traversalStrategy , ExecutionContextInterface $ context ) { try { $ classMetadata = $ this -> metadataFactory -> getMetadataFor ( $ object ) ; if ( ! $ classMetadata instanceof ClassMetadataInterface ) { throw new UnsupportedMetadataExcept...
Validates an object against the constraints defined for its class .
21,707
private function validateEachObjectIn ( $ collection , $ propertyPath , array $ groups , ExecutionContextInterface $ context ) { foreach ( $ collection as $ key => $ value ) { if ( \ is_array ( $ value ) ) { $ this -> validateEachObjectIn ( $ value , $ propertyPath . '[' . $ key . ']' , $ groups , $ context ) ; continu...
Validates each object in a collection against the constraints defined for their classes .
21,708
private function validateGenericNode ( $ value , $ object , $ cacheKey , MetadataInterface $ metadata = null , $ propertyPath , array $ groups , $ cascadedGroups , $ traversalStrategy , ExecutionContextInterface $ context ) { $ context -> setNode ( $ value , $ object , $ metadata , $ propertyPath ) ; foreach ( $ groups...
Validates a node that is not a class node .
21,709
private function stepThroughGroupSequence ( $ value , $ object , $ cacheKey , MetadataInterface $ metadata = null , $ propertyPath , $ traversalStrategy , GroupSequence $ groupSequence , $ cascadedGroup , ExecutionContextInterface $ context ) { $ violationCount = \ count ( $ context -> getViolations ( ) ) ; $ cascadedG...
Sequentially validates a node s value in each group of a group sequence .
21,710
private function validateInGroup ( $ value , $ cacheKey , MetadataInterface $ metadata , $ group , ExecutionContextInterface $ context ) { $ context -> setGroup ( $ group ) ; foreach ( $ metadata -> findConstraints ( $ group ) as $ constraint ) { if ( null !== $ cacheKey ) { $ constraintHash = spl_object_hash ( $ const...
Validates a node s value against all constraints in the given group .
21,711
public static function getRequestParameterValue ( Request $ request , $ path ) { if ( false === $ pos = strpos ( $ path , '[' ) ) { return $ request -> get ( $ path ) ; } $ root = substr ( $ path , 0 , $ pos ) ; if ( null === $ value = $ request -> get ( $ root ) ) { return ; } if ( null === self :: $ propertyAccessor ...
Returns a request parameter value .
21,712
public function getOption ( $ key ) { if ( ! \ array_key_exists ( $ key , $ this -> options ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The Router does not support the "%s" option.' , $ key ) ) ; } $ this -> checkDeprecatedOption ( $ key ) ; return $ this -> options [ $ key ] ; }
Gets an option value .
21,713
public function getGenerator ( ) { if ( null !== $ this -> generator ) { return $ this -> generator ; } $ compiled = is_a ( $ this -> options [ 'generator_class' ] , CompiledUrlGenerator :: class , true ) && UrlGenerator :: class === $ this -> options [ 'generator_base_class' ] ; if ( null === $ this -> options [ 'cach...
Gets the UrlGenerator instance associated with this Router .
21,714
public function setEvents ( array $ events ) { foreach ( $ events as $ event ) { $ event -> ensureStopped ( ) ; } $ this -> data [ 'events' ] = $ events ; }
Sets the request events .
21,715
public function getDuration ( ) { if ( ! isset ( $ this -> data [ 'events' ] [ '__section__' ] ) ) { return 0 ; } $ lastEvent = $ this -> data [ 'events' ] [ '__section__' ] ; return $ lastEvent -> getOrigin ( ) + $ lastEvent -> getDuration ( ) - $ this -> getStartTime ( ) ; }
Gets the request elapsed time .
21,716
protected function configureOptions ( OptionsResolver $ resolver ) { $ resolver -> setDefaults ( [ 'host' => 'localhost' , 'version' => 3 , 'connection_string' => null , 'encryption' => 'none' , 'options' => [ ] , ] ) ; $ resolver -> setDefault ( 'port' , function ( Options $ options ) { return 'ssl' === $ options [ 'e...
Configures the adapter s options .
21,717
protected function configureRoute ( Route $ route , \ ReflectionClass $ class , \ ReflectionMethod $ method , $ annot ) { if ( '__invoke' === $ method -> getName ( ) ) { $ route -> setDefault ( '_controller' , $ class -> getName ( ) ) ; } else { $ route -> setDefault ( '_controller' , $ class -> getName ( ) . '::' . $ ...
Configures the _controller default parameter of a given Route instance .
21,718
private function getType ( \ ReflectionParameter $ parameter , \ ReflectionFunctionAbstract $ function ) { if ( ! $ type = $ parameter -> getType ( ) ) { return ; } $ name = $ type -> getName ( ) ; $ lcName = strtolower ( $ name ) ; if ( 'self' !== $ lcName && 'parent' !== $ lcName ) { return $ name ; } if ( ! $ functi...
Returns an associated type to the given parameter if available .
21,719
private function decideAffirmative ( TokenInterface $ token , array $ attributes , $ object = null ) { $ deny = 0 ; foreach ( $ this -> voters as $ voter ) { $ result = $ voter -> vote ( $ token , $ object , $ attributes ) ; switch ( $ result ) { case VoterInterface :: ACCESS_GRANTED : return true ; case VoterInterface...
Grants access if any voter returns an affirmative response .
21,720
public function stop ( ) { if ( ! \ count ( $ this -> started ) ) { throw new \ LogicException ( 'stop() called but start() has not been called before.' ) ; } $ this -> periods [ ] = new StopwatchPeriod ( array_pop ( $ this -> started ) , $ this -> getNow ( ) , $ this -> morePrecision ) ; return $ this ; }
Stops the last started event period .
21,721
public function setCollectors ( array $ collectors ) { $ this -> collectors = [ ] ; foreach ( $ collectors as $ collector ) { $ this -> addCollector ( $ collector ) ; } }
Sets the Collectors associated with this profile .
21,722
public function setPattern ( $ pattern ) { if ( null === $ pattern ) { $ pattern = $ this -> getDefaultPattern ( ) ; } $ this -> pattern = $ pattern ; return true ; }
Set the formatter s pattern .
21,723
public function setTimeZoneId ( $ timeZoneId ) { if ( null === $ timeZoneId ) { $ timeZoneId = date_default_timezone_get ( ) ; $ this -> uninitializedTimeZoneId = true ; } $ timeZone = $ timeZoneId ; if ( 'GMT' !== $ timeZoneId && 0 === strpos ( $ timeZoneId , 'GMT' ) ) { try { $ timeZoneId = DateFormat \ TimezoneTrans...
Set the formatter s timezone identifier .
21,724
protected function createDateTime ( $ timestamp ) { $ dateTime = new \ DateTime ( ) ; $ dateTime -> setTimestamp ( $ timestamp ) ; $ dateTime -> setTimezone ( $ this -> dateTimeZone ) ; return $ dateTime ; }
Create and returns a DateTime object with the specified timestamp and with the current time zone .
21,725
protected function getDefaultPattern ( ) { $ patternParts = [ ] ; if ( self :: NONE !== $ this -> datetype ) { $ patternParts [ ] = $ this -> defaultDateFormats [ $ this -> datetype ] ; } if ( self :: NONE !== $ this -> timetype ) { $ patternParts [ ] = $ this -> defaultTimeFormats [ $ this -> timetype ] ; } return imp...
Returns a pattern string based in the datetype and timetype values .
21,726
public function process ( ContainerBuilder $ container ) { do { $ this -> repeat = false ; foreach ( $ this -> passes as $ pass ) { $ pass -> process ( $ container ) ; } } while ( $ this -> repeat ) ; }
Process the repeatable passes that run more than once .
21,727
protected function getNextTransport ( ) : ? TransportInterface { $ cursor = $ this -> cursor ; while ( true ) { $ transport = $ this -> transports [ $ cursor ] ; if ( ! $ this -> isTransportDead ( $ transport ) ) { break ; } if ( ( microtime ( true ) - $ this -> deadTransports [ $ transport ] ) > $ this -> retryPeriod ...
Rotates the transport list around and returns the first instance .
21,728
public function isDisabled ( ) { if ( parent :: isDisabled ( ) && 'select' === $ this -> type ) { return true ; } foreach ( $ this -> options as $ option ) { if ( $ option [ 'value' ] == $ this -> value && $ option [ 'disabled' ] ) { return true ; } } return false ; }
Check if the current selected option is disabled .
21,729
public function addChoice ( \ DOMElement $ node ) { if ( ! $ this -> multiple && 'radio' !== $ this -> type ) { throw new \ LogicException ( sprintf ( 'Unable to add a choice for "%s" as it is not multiple or is not a radio button.' , $ this -> name ) ) ; } $ option = $ this -> buildOptionValue ( $ node ) ; $ this -> o...
Adds a choice to the current ones .
21,730
public function containsOption ( $ optionValue , $ options ) { if ( $ this -> validationDisabled ) { return true ; } foreach ( $ options as $ option ) { if ( $ option [ 'value' ] == $ optionValue ) { return true ; } } return false ; }
Checks whether given value is in the existing options .
21,731
public function setDisplayOptions ( array $ displayOptions ) { $ this -> headerIsDumped = false ; $ this -> displayOptions = $ displayOptions + $ this -> displayOptions ; }
Configures display options .
21,732
private static function getValidationGroups ( FormInterface $ form ) { $ clickedButton = null ; if ( method_exists ( $ form , 'getClickedButton' ) ) { $ clickedButton = $ form -> getClickedButton ( ) ; } if ( null !== $ clickedButton ) { $ groups = $ clickedButton -> getConfig ( ) -> getOption ( 'validation_groups' ) ;...
Returns the validation groups of the given form .
21,733
private static function resolveValidationGroups ( $ groups , FormInterface $ form ) { if ( ! \ is_string ( $ groups ) && \ is_callable ( $ groups ) ) { $ groups = $ groups ( $ form ) ; } if ( $ groups instanceof GroupSequence ) { return $ groups ; } return ( array ) $ groups ; }
Post - processes the validation groups option for a given form .
21,734
private function writeData ( array $ data , array $ options ) { $ this -> write ( json_encode ( $ data , isset ( $ options [ 'json_encoding' ] ) ? $ options [ 'json_encoding' ] : 0 ) ) ; }
Writes data as json .
21,735
public function load ( $ file , $ type = null ) { $ path = $ this -> locator -> locate ( $ file ) ; $ collection = new RouteCollection ( ) ; if ( $ class = $ this -> findClass ( $ path ) ) { $ refl = new \ ReflectionClass ( $ class ) ; if ( $ refl -> isAbstract ( ) ) { return ; } $ collection -> addResource ( new FileR...
Loads from annotations from a file .
21,736
protected function findClass ( $ file ) { $ class = false ; $ namespace = false ; $ tokens = token_get_all ( file_get_contents ( $ file ) ) ; if ( 1 === \ count ( $ tokens ) && T_INLINE_HTML === $ tokens [ 0 ] [ 0 ] ) { throw new \ InvalidArgumentException ( sprintf ( 'The file "%s" does not contain PHP code. Did you f...
Returns the full class name for the first class in the file .
21,737
public function encodeString ( string $ address ) : string { $ i = strrpos ( $ address , '@' ) ; if ( false !== $ i ) { $ local = substr ( $ address , 0 , $ i ) ; $ domain = substr ( $ address , $ i + 1 ) ; if ( preg_match ( '/[^\x00-\x7F]/' , $ local ) ) { throw new AddressEncoderException ( sprintf ( 'Non-ASCII chara...
Encodes the domain part of an address using IDN .
21,738
private function handle ( $ message ) { if ( ! $ this -> messageBus instanceof MessageBusInterface ) { throw new LogicException ( sprintf ( 'You must provide a "%s" instance in the "%s::$messageBus" property, "%s" given.' , MessageBusInterface :: class , \ get_class ( $ this ) , \ is_object ( $ this -> messageBus ) ? \...
Dispatches the given message expecting to be handled by a single handler and returns the result from the handler returned value . This behavior is useful for both synchronous command & query buses the last one usually returning the handler result .
21,739
private function parseDefaultsConfig ( \ DOMElement $ element , $ path ) { if ( $ this -> isElementValueNull ( $ element ) ) { return ; } foreach ( $ element -> childNodes as $ child ) { if ( ! $ child instanceof \ DOMElement ) { continue ; } if ( self :: NAMESPACE_URI !== $ child -> namespaceURI ) { continue ; } retur...
Parses the default elements .
21,740
private function parseDefaultNode ( \ DOMElement $ node , $ path ) { if ( $ this -> isElementValueNull ( $ node ) ) { return ; } switch ( $ node -> localName ) { case 'bool' : return 'true' === trim ( $ node -> nodeValue ) || '1' === trim ( $ node -> nodeValue ) ; case 'int' : return ( int ) trim ( $ node -> nodeValue ...
Recursively parses the value of a default element .
21,741
protected function setMappingDriverAlias ( $ mappingConfig , $ mappingName ) { if ( isset ( $ mappingConfig [ 'alias' ] ) ) { $ this -> aliasMap [ $ mappingConfig [ 'alias' ] ] = $ mappingConfig [ 'prefix' ] ; } else { $ this -> aliasMap [ $ mappingName ] = $ mappingConfig [ 'prefix' ] ; } }
Register the alias for this mapping driver .
21,742
protected function setMappingDriverConfig ( array $ mappingConfig , $ mappingName ) { $ mappingDirectory = $ mappingConfig [ 'dir' ] ; if ( ! is_dir ( $ mappingDirectory ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Doctrine mapping path given. Cannot load Doctrine mapping/bundle named "%s".' , $ mapp...
Register the mapping driver configuration for later use with the object managers metadata driver chain .
21,743
protected function registerMappingDrivers ( $ objectManager , ContainerBuilder $ container ) { if ( $ container -> hasDefinition ( $ this -> getObjectManagerElementName ( $ objectManager [ 'name' ] . '_metadata_driver' ) ) ) { $ chainDriverDef = $ container -> getDefinition ( $ this -> getObjectManagerElementName ( $ o...
Register all the collected mapping information with the object manager by registering the appropriate mapping drivers .
21,744
protected function assertValidMappingConfiguration ( array $ mappingConfig , $ objectManagerName ) { if ( ! $ mappingConfig [ 'type' ] || ! $ mappingConfig [ 'dir' ] || ! $ mappingConfig [ 'prefix' ] ) { throw new \ InvalidArgumentException ( sprintf ( 'Mapping definitions for Doctrine manager "%s" require at least the...
Assertion if the specified mapping information is valid .
21,745
protected function detectMetadataDriver ( $ dir , ContainerBuilder $ container ) { $ configPath = $ this -> getMappingResourceConfigDirectory ( ) ; $ extension = $ this -> getMappingResourceExtension ( ) ; if ( glob ( $ dir . '/' . $ configPath . '/*.' . $ extension . '.xml' ) ) { $ driver = 'xml' ; } elseif ( glob ( $...
Detects what metadata driver to use for the supplied directory .
21,746
private function validateAutoMapping ( array $ managerConfigs ) { $ autoMappedManager = null ; foreach ( $ managerConfigs as $ name => $ manager ) { if ( ! $ manager [ 'auto_mapping' ] ) { continue ; } if ( null !== $ autoMappedManager ) { throw new \ LogicException ( sprintf ( 'You cannot enable "auto_mapping" on more...
Search for a manager that is declared as auto_mapping = true .
21,747
public function registerListener ( $ key , $ logoutPath , $ csrfTokenId , $ csrfParameter , CsrfTokenManagerInterface $ csrfTokenManager = null , string $ context = null ) { $ this -> listeners [ $ key ] = [ $ logoutPath , $ csrfTokenId , $ csrfParameter , $ csrfTokenManager , $ context ] ; }
Registers a firewall s LogoutListener allowing its URL to be generated .
21,748
private function generateLogoutUrl ( $ key , $ referenceType ) { list ( $ logoutPath , $ csrfTokenId , $ csrfParameter , $ csrfTokenManager ) = $ this -> getListener ( $ key ) ; if ( null === $ logoutPath ) { throw new \ LogicException ( 'Unable to generate the logout URL without a path.' ) ; } $ parameters = null !== ...
Generates the logout URL for the firewall .
21,749
public function addAttributeValues ( Entry $ entry , string $ attribute , array $ values ) { $ con = $ this -> getConnectionResource ( ) ; if ( ! @ ldap_mod_add ( $ con , $ entry -> getDn ( ) , [ $ attribute => $ values ] ) ) { throw new LdapException ( sprintf ( 'Could not add values to entry "%s", attribute %s: %s.' ...
Adds values to an entry s multi - valued attribute from the LDAP server .
21,750
public function removeAttributeValues ( Entry $ entry , string $ attribute , array $ values ) { $ con = $ this -> getConnectionResource ( ) ; if ( ! @ ldap_mod_del ( $ con , $ entry -> getDn ( ) , [ $ attribute => $ values ] ) ) { throw new LdapException ( sprintf ( 'Could not remove values from entry "%s", attribute %...
Removes values from an entry s multi - valued attribute from the LDAP server .
21,751
public function move ( Entry $ entry , string $ newParent ) { $ con = $ this -> getConnectionResource ( ) ; $ rdn = $ this -> parseRdnFromEntry ( $ entry ) ; if ( ! @ ldap_rename ( $ con , $ entry -> getDn ( ) , $ rdn , $ newParent , true ) ) { throw new LdapException ( sprintf ( 'Could not move entry "%s" to "%s": %s....
Moves an entry on the Ldap server .
21,752
private function parseFile ( $ file ) { try { $ dom = XmlUtils :: loadFile ( $ file , __DIR__ . '/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd' ) ; } catch ( \ Exception $ e ) { throw new MappingException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return simplexml_import_dom ( $ dom ) ; }
Parses a XML File .
21,753
private static function writeRequest ( self $ response , array $ options , ResponseInterface $ mock ) { $ onProgress = $ options [ 'on_progress' ] ?? static function ( ) { } ; $ response -> info += $ mock -> getInfo ( ) ? : [ ] ; if ( isset ( $ response -> info [ 'size_upload' ] ) ) { $ response -> info [ 'size_upload'...
Simulates sending the request .
21,754
private static function readResponse ( self $ response , array $ options , ResponseInterface $ mock , int & $ offset ) { $ onProgress = $ options [ 'on_progress' ] ?? static function ( ) { } ; $ info = $ mock -> getInfo ( ) ? : [ ] ; $ response -> info [ 'http_code' ] = ( $ info [ 'http_code' ] ?? 0 ) ? : $ mock -> get...
Simulates reading the response .
21,755
public function remove ( $ offset , $ length = 1 ) { if ( ! isset ( $ this -> elements [ $ offset ] ) ) { throw new OutOfBoundsException ( sprintf ( 'The offset %s is not within the property path' , $ offset ) ) ; } $ this -> resize ( $ offset , $ length , 0 ) ; }
Removes elements from the current path .
21,756
public function replaceByIndex ( $ offset , $ name = null ) { if ( ! isset ( $ this -> elements [ $ offset ] ) ) { throw new OutOfBoundsException ( sprintf ( 'The offset %s is not within the property path' , $ offset ) ) ; } if ( null !== $ name ) { $ this -> elements [ $ offset ] = $ name ; } $ this -> isIndex [ $ off...
Replaces a property element by an index element .
21,757
public function replaceByProperty ( $ offset , $ name = null ) { if ( ! isset ( $ this -> elements [ $ offset ] ) ) { throw new OutOfBoundsException ( sprintf ( 'The offset %s is not within the property path' , $ offset ) ) ; } if ( null !== $ name ) { $ this -> elements [ $ offset ] = $ name ; } $ this -> isIndex [ $ ...
Replaces an index element by a property element .
21,758
public function getId ( $ service ) : ? string { if ( $ this -> serviceContainer === $ service ) { return 'service_container' ; } if ( null === $ id = ( $ this -> getServiceId ) ( $ service ) ) { return null ; } if ( $ this -> serviceContainer -> has ( $ id ) || $ this -> reversibleLocator -> has ( $ id ) ) { return $ ...
Returns the id of the passed object when it exists as a service .
21,759
public function current ( ) { if ( null === $ subPathname = $ this -> subPath ) { $ subPathname = $ this -> subPath = ( string ) $ this -> getSubPath ( ) ; } if ( '' !== $ subPathname ) { $ subPathname .= $ this -> directorySeparator ; } $ subPathname .= $ this -> getFilename ( ) ; return new SplFileInfo ( $ this -> ro...
Return an instance of SplFileInfo with support for relative paths .
21,760
public function start ( Request $ request , AuthenticationException $ authException = null ) { $ url = $ this -> getLoginUrl ( ) ; return new RedirectResponse ( $ url ) ; }
Override to control what happens when the user hits a secure page but isn t logged in yet .
21,761
private function findAndSortTags ( $ tagName , ContainerBuilder $ container ) { $ sortedTags = [ ] ; foreach ( $ container -> findTaggedServiceIds ( $ tagName , true ) as $ serviceId => $ tags ) { foreach ( $ tags as $ attributes ) { $ priority = isset ( $ attributes [ 'priority' ] ) ? $ attributes [ 'priority' ] : 0 ;...
Finds and orders all service tags with the given name by their priority .
21,762
public function updateFromSetCookie ( array $ setCookies , $ uri = null ) { $ cookies = [ ] ; foreach ( $ setCookies as $ cookie ) { foreach ( explode ( ',' , $ cookie ) as $ i => $ part ) { if ( 0 === $ i || preg_match ( '/^(?P<token>\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/' , $ part ) ) { $ cookies [ ] = ltrim ( $ p...
Updates the cookie jar from a response Set - Cookie headers .
21,763
public function updateFromResponse ( Response $ response , $ uri = null ) { $ this -> updateFromSetCookie ( $ response -> getHeader ( 'Set-Cookie' , false ) , $ uri ) ; }
Updates the cookie jar from a Response object .
21,764
public function flushExpiredCookies ( ) { foreach ( $ this -> cookieJar as $ domain => $ pathCookies ) { foreach ( $ pathCookies as $ path => $ namedCookies ) { foreach ( $ namedCookies as $ name => $ cookie ) { if ( $ cookie -> isExpired ( ) ) { unset ( $ this -> cookieJar [ $ domain ] [ $ path ] [ $ name ] ) ; } } } ...
Removes all expired cookies .
21,765
public function hasPostMaxSizeBeenExceeded ( ) { $ contentLength = $ this -> getContentLength ( ) ; $ maxContentLength = $ this -> getPostMaxSize ( ) ; return $ maxContentLength && $ contentLength > $ maxContentLength ; }
Returns true if the POST max size has been exceeded in the request .
21,766
public function getPostMaxSize ( ) { $ iniMax = strtolower ( $ this -> getNormalizedIniPostMaxSize ( ) ) ; if ( '' === $ iniMax ) { return ; } $ max = ltrim ( $ iniMax , '+' ) ; if ( 0 === strpos ( $ max , '0x' ) ) { $ max = \ intval ( $ max , 16 ) ; } elseif ( 0 === strpos ( $ max , '0' ) ) { $ max = \ intval ( $ max ...
Returns maximum post size in bytes .
21,767
public function getContentLength ( ) { if ( null !== $ this -> requestStack && null !== $ request = $ this -> requestStack -> getCurrentRequest ( ) ) { return $ request -> server -> get ( 'CONTENT_LENGTH' ) ; } return isset ( $ _SERVER [ 'CONTENT_LENGTH' ] ) ? ( int ) $ _SERVER [ 'CONTENT_LENGTH' ] : null ; }
Returns the content length of the request .
21,768
protected function newConstraint ( $ name , $ options = null ) { if ( false !== strpos ( $ name , '\\' ) && class_exists ( $ name ) ) { $ className = ( string ) $ name ; } elseif ( false !== strpos ( $ name , ':' ) ) { list ( $ prefix , $ className ) = explode ( ':' , $ name , 2 ) ; if ( ! isset ( $ this -> namespaces ...
Creates a new constraint instance for the given constraint name .
21,769
protected function parseNodes ( array $ nodes ) { $ values = [ ] ; foreach ( $ nodes as $ name => $ childNodes ) { if ( is_numeric ( $ name ) && \ is_array ( $ childNodes ) && 1 === \ count ( $ childNodes ) ) { $ options = current ( $ childNodes ) ; if ( \ is_array ( $ options ) ) { $ options = $ this -> parseNodes ( $...
Parses a collection of YAML nodes .
21,770
private function parseFile ( $ path ) { try { $ classes = $ this -> yamlParser -> parseFile ( $ path , Yaml :: PARSE_CONSTANT ) ; } catch ( ParseException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'The file "%s" does not contain valid YAML.' , $ path ) , 0 , $ e ) ; } if ( null === $ classes ) { return [...
Loads the YAML class descriptions from the given file .
21,771
public function addConstraint ( Constraint $ constraint ) { if ( $ constraint instanceof Traverse ) { throw new ConstraintDefinitionException ( sprintf ( 'The constraint "%s" can only be put on classes. Please use "Symfony\Component\Validator\Constraints\Valid" instead.' , \ get_class ( $ constraint ) ) ) ; } if ( $ co...
Adds a constraint .
21,772
private function cleanupQuery ( string $ uri ) : string { if ( false !== $ pos = strpos ( $ uri , '?' ) ) { return substr ( $ uri , 0 , $ pos ) ; } return $ uri ; }
Remove the query string from the uri .
21,773
private function cleanupAnchor ( string $ uri ) : string { if ( false !== $ pos = strpos ( $ uri , '#' ) ) { return substr ( $ uri , 0 , $ pos ) ; } return $ uri ; }
Remove the anchor from the uri .
21,774
public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! $ value instanceof \ DateInterval ) { throw new UnexpectedTypeException ( $ value , '\DateInterval' ) ; } return $ value -> format ( $ this -> format ) ; }
Transforms a DateInterval object into a date string with the configured format .
21,775
public function reverseTransform ( $ value ) { if ( null === $ value ) { return ; } if ( ! \ is_string ( $ value ) ) { throw new UnexpectedTypeException ( $ value , 'string' ) ; } if ( '' === $ value ) { return ; } if ( ! $ this -> isISO8601 ( $ value ) ) { throw new TransformationFailedException ( 'Non ISO 8601 date s...
Transforms a date string in the configured format into a DateInterval object .
21,776
public function clear ( int $ lines = null ) { if ( empty ( $ this -> content ) || ! $ this -> isDecorated ( ) ) { return ; } if ( $ lines ) { \ array_splice ( $ this -> content , - ( $ lines * 2 ) ) ; } else { $ lines = $ this -> lines ; $ this -> content = [ ] ; } $ this -> lines -= $ lines ; parent :: doWrite ( $ th...
Clears previous output for this section .
21,777
private function popStreamContentUntilCurrentSection ( int $ numberOfLinesToClearFromCurrentSection = 0 ) : string { $ numberOfLinesToClear = $ numberOfLinesToClearFromCurrentSection ; $ erasedContent = [ ] ; foreach ( $ this -> sections as $ section ) { if ( $ section === $ this ) { break ; } $ numberOfLinesToClear +=...
At initial stage cursor is at the end of stream output . This method makes cursor crawl upwards until it hits current section . Then it erases content it crawled through . Optionally it erases part of current section too .
21,778
private function getRelativePath ( string $ domain , string $ locale ) : string { return strtr ( $ this -> relativePathTemplate , [ '%domain%' => $ domain , '%locale%' => $ locale , '%extension%' => $ this -> getExtension ( ) , ] ) ; }
Gets the relative file path using the template .
21,779
public static function toRegex ( string $ gitignoreFileContent ) : string { $ gitignoreFileContent = preg_replace ( '/^[^\\\\]*#.*/' , '' , $ gitignoreFileContent ) ; $ gitignoreLines = preg_split ( '/\r\n|\r|\n/' , $ gitignoreFileContent ) ; $ gitignoreLines = array_map ( 'trim' , $ gitignoreLines ) ; $ gitignoreLines...
Returns a regexp which is the equivalent of the gitignore pattern .
21,780
private function parseShortOptionSet ( $ name ) { $ len = \ strlen ( $ name ) ; for ( $ i = 0 ; $ i < $ len ; ++ $ i ) { if ( ! $ this -> definition -> hasShortcut ( $ name [ $ i ] ) ) { $ encoding = mb_detect_encoding ( $ name , null , true ) ; throw new RuntimeException ( sprintf ( 'The "-%s" option does not exist.' ...
Parses a short option set .
21,781
private function parseLongOption ( $ token ) { $ name = substr ( $ token , 2 ) ; if ( false !== $ pos = strpos ( $ name , '=' ) ) { if ( 0 === \ strlen ( $ value = substr ( $ name , $ pos + 1 ) ) ) { array_unshift ( $ this -> parsed , $ value ) ; } $ this -> addLongOption ( substr ( $ name , 0 , $ pos ) , $ value ) ; }...
Parses a long option .
21,782
private function parseArgument ( $ token ) { $ c = \ count ( $ this -> arguments ) ; if ( $ this -> definition -> hasArgument ( $ c ) ) { $ arg = $ this -> definition -> getArgument ( $ c ) ; $ this -> arguments [ $ arg -> getName ( ) ] = $ arg -> isArray ( ) ? [ $ token ] : $ token ; } elseif ( $ this -> definition ->...
Parses an argument .
21,783
public static function canonicalize ( $ locale ) { $ locale = ( string ) $ locale ; if ( '' === $ locale || '.' === $ locale [ 0 ] ) { return self :: getDefault ( ) ; } if ( ! preg_match ( '/^([a-z]{2})[-_]([a-z]{2})(?:([a-z]{2})(?:[-_]([a-z]{2}))?)?(?:\..*)?$/i' , $ locale , $ m ) ) { return $ locale ; } if ( ! empty ...
Returns a canonicalized locale string .
21,784
public function setMultiselect ( $ multiselect ) { $ this -> multiselect = $ multiselect ; $ this -> setValidator ( $ this -> getDefaultValidator ( ) ) ; return $ this ; }
Sets multiselect option .
21,785
public function setErrorMessage ( $ errorMessage ) { $ this -> errorMessage = $ errorMessage ; $ this -> setValidator ( $ this -> getDefaultValidator ( ) ) ; return $ this ; }
Sets the error message for invalid values .
21,786
public function getCompiledRoutes ( bool $ forDump = false ) : array { $ matchHost = false ; $ routes = new StaticPrefixCollection ( ) ; foreach ( $ this -> getRoutes ( ) -> all ( ) as $ name => $ route ) { if ( $ host = $ route -> getHost ( ) ) { $ matchHost = true ; $ host = '/' . strtr ( strrev ( $ host ) , '}.{' , ...
Generates the arrays for CompiledUrlMatcher s constructor .
21,787
public function createTable ( ) { $ conn = $ this -> getConnection ( ) ; if ( $ conn instanceof Connection ) { $ types = [ 'mysql' => 'binary' , 'sqlite' => 'text' , 'pgsql' => 'string' , 'oci' => 'string' , 'sqlsrv' => 'string' , ] ; if ( ! isset ( $ types [ $ this -> driver ] ) ) { throw new \ DomainException ( sprin...
Creates the table to store cache items which can be called once for setup .
21,788
public function onKernelResponse ( FilterResponseEvent $ event ) { if ( ! $ event -> isMasterRequest ( ) ) { return ; } if ( ! preg_match ( static :: USER_AGENT_REGEX , $ event -> getRequest ( ) -> headers -> get ( 'User-Agent' ) ) ) { $ this -> sendHeaders = false ; $ this -> headers = [ ] ; return ; } $ this -> respo...
Adds the headers to the response once it s created .
21,789
private function writeResourceBundle ( $ file , $ bundleName , $ value , $ fallback ) { fwrite ( $ file , $ bundleName ) ; $ this -> writeTable ( $ file , $ value , 0 , $ fallback ) ; fwrite ( $ file , "\n" ) ; }
Writes a resourceBundle node .
21,790
private function writeResource ( $ file , $ value , $ indentation , $ requireBraces = true ) { if ( \ is_int ( $ value ) ) { $ this -> writeInteger ( $ file , $ value ) ; return ; } if ( $ value instanceof \ Traversable ) { $ value = iterator_to_array ( $ value ) ; } if ( \ is_array ( $ value ) ) { $ intValues = \ coun...
Writes a resource node .
21,791
private function writeIntVector ( $ file , array $ value , $ indentation ) { fwrite ( $ file , ":intvector{\n" ) ; foreach ( $ value as $ int ) { fprintf ( $ file , "%s%d,\n" , str_repeat ( ' ' , $ indentation + 1 ) , $ int ) ; } fprintf ( $ file , '%s}' , str_repeat ( ' ' , $ indentation ) ) ; }
Writes an intvector node .
21,792
private function writeString ( $ file , $ value , $ requireBraces = true ) { if ( $ requireBraces ) { fprintf ( $ file , '{"%s"}' , $ value ) ; return ; } fprintf ( $ file , '"%s"' , $ value ) ; }
Writes a string node .
21,793
private function writeArray ( $ file , array $ value , $ indentation ) { fwrite ( $ file , "{\n" ) ; foreach ( $ value as $ entry ) { fwrite ( $ file , str_repeat ( ' ' , $ indentation + 1 ) ) ; $ this -> writeResource ( $ file , $ entry , $ indentation + 1 , false ) ; fwrite ( $ file , ",\n" ) ; } fprintf ( $ file ...
Writes an array node .
21,794
private function writeTable ( $ file , $ value , $ indentation , $ fallback = true ) { if ( ! \ is_array ( $ value ) && ! $ value instanceof \ Traversable ) { throw new UnexpectedTypeException ( $ value , 'array or \Traversable' ) ; } if ( ! $ fallback ) { fwrite ( $ file , ':table(nofallback)' ) ; } fwrite ( $ file , ...
Writes a table node .
21,795
public function canTransition ( $ subject , $ transitionName , $ name = null ) { return $ this -> workflowRegistry -> get ( $ subject , $ name ) -> can ( $ subject , $ transitionName ) ; }
Returns true if the transition is enabled .
21,796
public function getEnabledTransitions ( $ subject , $ name = null ) { return $ this -> workflowRegistry -> get ( $ subject , $ name ) -> getEnabledTransitions ( $ subject ) ; }
Returns all enabled transitions .
21,797
public function hasMarkedPlace ( $ subject , $ placeName , $ name = null ) { return $ this -> workflowRegistry -> get ( $ subject , $ name ) -> getMarking ( $ subject ) -> has ( $ placeName ) ; }
Returns true if the place is marked .
21,798
public function getMarkedPlaces ( $ subject , $ placesNameOnly = true , $ name = null ) { $ places = $ this -> workflowRegistry -> get ( $ subject , $ name ) -> getMarking ( $ subject ) -> getPlaces ( ) ; if ( $ placesNameOnly ) { return array_keys ( $ places ) ; } return $ places ; }
Returns marked places .
21,799
public function getMetadata ( $ subject , string $ key , $ metadataSubject = null , string $ name = null ) : ? string { return $ this -> workflowRegistry -> get ( $ subject , $ name ) -> getMetadataStore ( ) -> getMetadata ( $ key , $ metadataSubject ) ; }
Returns the metadata for a specific subject .