idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
44,200
public function stream_metadata ( string $ path , int $ option , $ var ) : bool { $ path = $ this -> resolvePath ( vfsStream :: path ( $ path ) ) ; $ content = $ this -> getContent ( $ path ) ; switch ( $ option ) { case STREAM_META_TOUCH : if ( null === $ content ) { $ content = $ this -> createFile ( $ path , null , ...
sets metadata like owner user or permissions
44,201
private function doPermChange ( string $ path , vfsStreamAbstractContent $ content , callable $ change ) : bool { if ( ! $ content -> isOwnedByUser ( vfsStream :: getCurrentUser ( ) ) ) { return false ; } if ( self :: $ root -> getName ( ) !== $ path ) { $ names = $ this -> splitPath ( $ path ) ; $ parent = $ this -> g...
executes given permission change when necessary rights allow such a change
44,202
public function stream_stat ( ) : array { $ fileStat = [ 'dev' => 0 , 'ino' => 0 , 'mode' => $ this -> content -> getType ( ) | $ this -> content -> getPermissions ( ) , 'nlink' => 0 , 'uid' => $ this -> content -> getUser ( ) , 'gid' => $ this -> content -> getGroup ( ) , 'rdev' => 0 , 'size' => $ this -> content -> s...
returns status of stream
44,203
public function stream_lock ( int $ operation ) : bool { if ( ( LOCK_NB & $ operation ) == LOCK_NB ) { $ operation = $ operation - LOCK_NB ; } return $ this -> content -> lock ( $ this , $ operation ) ; }
set lock status for stream
44,204
public function stream_set_option ( int $ option , $ arg1 , $ arg2 ) { switch ( $ option ) { case STREAM_OPTION_BLOCKING : case STREAM_OPTION_READ_TIMEOUT : case STREAM_OPTION_WRITE_BUFFER : default : } return false ; }
sets options on the stream
44,205
protected function doUnlink ( string $ path ) : bool { if ( self :: $ root -> getName ( ) === $ path ) { self :: $ root = null ; clearstatcache ( ) ; return true ; } $ names = $ this -> splitPath ( $ path ) ; $ content = $ this -> getContent ( $ names [ 'dirname' ] ) ; if ( ! $ content -> isWritable ( vfsStream :: getC...
removes a path
44,206
public function rename ( string $ path_from , string $ path_to ) : bool { $ srcRealPath = $ this -> resolvePath ( vfsStream :: path ( $ path_from ) ) ; $ dstRealPath = $ this -> resolvePath ( vfsStream :: path ( $ path_to ) ) ; $ srcContent = $ this -> getContent ( $ srcRealPath ) ; if ( null === $ srcContent ) { trigg...
rename from one path to another
44,207
public function mkdir ( string $ path , int $ mode , int $ options ) : bool { $ umask = vfsStream :: umask ( ) ; if ( 0 < $ umask ) { $ permissions = $ mode & ~ $ umask ; } else { $ permissions = $ mode ; } $ path = $ this -> resolvePath ( vfsStream :: path ( $ path ) ) ; if ( null !== $ this -> getContent ( $ path ) )...
creates a new directory
44,208
public function rmdir ( string $ path , int $ options ) : bool { $ path = $ this -> resolvePath ( vfsStream :: path ( $ path ) ) ; $ child = $ this -> getContentOfType ( $ path , vfsStreamContent :: TYPE_DIR ) ; if ( null === $ child ) { return false ; } if ( count ( $ child -> getChildren ( ) ) > 0 ) { return false ; ...
removes a directory
44,209
public function dir_opendir ( string $ path , int $ options ) : bool { $ path = $ this -> resolvePath ( vfsStream :: path ( $ path ) ) ; $ this -> dir = null ; $ dir = $ this -> getContentOfType ( $ path , vfsStreamContent :: TYPE_DIR ) ; if ( null === $ dir ) { return false ; } $ this -> dir = $ dir ; if ( ! $ this ->...
opens a directory
44,210
public function dir_readdir ( ) { $ dir = $ this -> dirIterator -> current ( ) ; if ( null === $ dir ) { return false ; } $ this -> dirIterator -> next ( ) ; return $ dir -> getName ( ) ; }
reads directory contents
44,211
public function setDirectory ( $ directory ) { $ this -> directory = $ directory . DIRECTORY_SEPARATOR . $ this -> id ; if ( file_exists ( $ this -> directory ) === false ) { mkdir ( $ this -> directory , $ this -> fileMode , true ) ; } }
sets the directory
44,212
public static function withViolationsAndMessage ( ParamInterface $ parameter , ConstraintViolationListInterface $ violations , $ message ) { $ exception = new self ( $ message ) ; $ exception -> parameter = $ parameter ; $ exception -> violations = $ violations ; return $ exception ; }
Do not use this method . It will be removed in 2 . 0 .
44,213
protected function redirectView ( $ url , $ statusCode = Response :: HTTP_FOUND , array $ headers = [ ] ) { return View :: createRedirect ( $ url , $ statusCode , $ headers ) ; }
Creates a Redirect view .
44,214
protected function routeRedirectView ( $ route , array $ parameters = [ ] , $ statusCode = Response :: HTTP_CREATED , array $ headers = [ ] ) { return View :: createRouteRedirect ( $ route , $ parameters , $ statusCode , $ headers ) ; }
Creates a Route Redirect View .
44,215
public function transform ( $ object ) { if ( null === $ object ) { return '' ; } return current ( array_values ( $ this -> om -> getClassMetadata ( $ this -> entityName ) -> getIdentifierValues ( $ object ) ) ) ; }
Do nothing .
44,216
public function reverseTransform ( $ idObject ) { if ( ! is_array ( $ idObject ) ) { return ; } $ identifier = current ( array_values ( $ this -> om -> getClassMetadata ( $ this -> entityName ) -> getIdentifier ( ) ) ) ; $ id = $ idObject [ $ identifier ] ; $ object = $ this -> om -> getRepository ( $ this -> entityNam...
Transforms an array including an identifier to an object .
44,217
protected function checkNotIncompatibleParams ( ParamInterface $ param ) { if ( null === $ param -> getValue ( $ this -> getRequest ( ) , null ) ) { return ; } $ params = $ this -> getParams ( ) ; foreach ( $ param -> getIncompatibilities ( ) as $ incompatibleParamName ) { if ( ! array_key_exists ( $ incompatibleParamN...
Check if current param is not in conflict with other parameters according to the incompatibles field .
44,218
protected function getExceptionMessage ( \ Exception $ exception , $ statusCode = null ) { $ showMessage = $ this -> messagesMap -> resolveException ( $ exception ) ; if ( $ showMessage || $ this -> debug ) { return $ exception -> getMessage ( ) ; } return array_key_exists ( $ statusCode , Response :: $ statusTexts ) ?...
Extracts the exception message .
44,219
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; foreach ( $ this -> requestMatchers as $ requestMatcher ) { if ( $ requestMatcher -> matches ( $ request ) ) { $ request -> attributes -> set ( FOSRestBundle :: ZONE_ATTRIBUTE , true ) ; return ; } } $ request -> attr...
Adds an optional _fos_rest_zone request attribute to be checked for existence by other listeners .
44,220
protected function getStatusCode ( \ Exception $ exception ) { if ( $ statusCode = $ this -> exceptionCodes -> resolveException ( $ exception ) ) { return $ statusCode ; } if ( $ exception instanceof HttpExceptionInterface ) { return $ exception -> getStatusCode ( ) ; } return 500 ; }
Determines the status code to use for the response .
44,221
private function getTemplateData ( $ currentContent , $ code , \ Exception $ exception , DebugLoggerInterface $ logger = null ) { return [ 'exception' => FlattenException :: create ( $ exception ) , 'status' => 'error' , 'status_code' => $ code , 'status_text' => array_key_exists ( $ code , Response :: $ statusTexts ) ...
Determines the template parameters to pass to the view layer .
44,222
private function isParamFetcherType ( \ ReflectionParameter $ controllerParam ) { $ type = $ controllerParam -> getClass ( ) ; if ( null === $ type ) { return false ; } return $ type -> implementsInterface ( ParamFetcherInterface :: class ) ; }
Returns true if the given controller parameter is type - hinted as an instance of ParamFetcher .
44,223
private function isNotAnEmptyDeleteRequestWithNoSetContentType ( $ method , $ content , $ contentType ) { return false === ( 'DELETE' === $ method && empty ( $ content ) && empty ( $ contentType ) ) ; }
Check if the Request is not a DELETE with no content and no Content - Type .
44,224
private function isFormRequest ( Request $ request ) { $ contentTypeParts = explode ( ';' , $ request -> headers -> get ( 'Content-Type' ) ) ; if ( isset ( $ contentTypeParts [ 0 ] ) ) { return in_array ( $ contentTypeParts [ 0 ] , [ 'multipart/form-data' , 'application/x-www-form-urlencoded' ] ) ; } return false ; }
Check if the content type indicates a form submission .
44,225
public function addGroup ( $ group ) { if ( null === $ this -> groups ) { $ this -> groups = [ ] ; } if ( ! in_array ( $ group , $ this -> groups ) ) { $ this -> groups [ ] = $ group ; } return $ this ; }
Adds a normalization group .
44,226
public function setMaxDepth ( $ maxDepth ) { if ( 1 === func_num_args ( ) || func_get_arg ( 1 ) ) { @ trigger_error ( sprintf ( '%s is deprecated since version 2.1 and will be removed in 3.0. Use %s::enableMaxDepth() and %s::disableMaxDepth() instead.' , __METHOD__ , __CLASS__ , __CLASS__ ) , E_USER_DEPRECATED ) ; } $ ...
Sets the normalization max depth .
44,227
public function getMaxDepth ( ) { if ( 0 === func_num_args ( ) || func_get_arg ( 0 ) ) { @ trigger_error ( sprintf ( '%s is deprecated since version 2.1 and will be removed in 3.0. Use %s::isMaxDepthEnabled() instead.' , __METHOD__ , __CLASS__ ) , E_USER_DEPRECATED ) ; } return $ this -> maxDepth ; }
Gets the normalization max depth .
44,228
public function prependRouteControllersWithPrefix ( $ prefix ) { foreach ( parent :: all ( ) as $ route ) { $ route -> setDefault ( '_controller' , $ prefix . $ route -> getDefault ( '_controller' ) ) ; } }
Adds controller prefix to all collection routes .
44,229
public function setDefaultFormat ( $ format ) { foreach ( parent :: all ( ) as $ route ) { if ( ! $ route -> getDefault ( '_format' ) ) { $ route -> setDefault ( '_format' , $ format ) ; } } }
Sets default format of routes .
44,230
public function all ( ) { $ regex = '/' . '(_|^)' . '(get|post|put|delete|patch|head|options|mkcol|propfind|proppatch|lock|unlock|move|copy|link|unlink)_' . '/i' ; $ routes = parent :: all ( ) ; $ customMethodRoutes = [ ] ; foreach ( $ routes as $ routeName => $ route ) { if ( ! preg_match ( $ regex , $ routeName ) ) {...
Returns routes sorted by custom HTTP methods first .
44,231
private function doResolveClass ( $ class ) { foreach ( $ this -> map as $ mapClass => $ value ) { if ( ! $ value ) { continue ; } if ( $ class === $ mapClass || is_subclass_of ( $ class , $ mapClass ) ) { return $ value ; } } return false ; }
Resolves the value corresponding to an exception class .
44,232
protected function getStatusCode ( View $ view , $ content = null ) { $ form = $ this -> getFormFromView ( $ view ) ; if ( $ form && $ form -> isSubmitted ( ) && ! $ form -> isValid ( ) ) { return $ this -> failedValidationCode ; } $ statusCode = $ view -> getStatusCode ( ) ; if ( null !== $ statusCode ) { return $ sta...
Gets a response HTTP status code from a View instance .
44,233
protected function getSerializationContext ( View $ view ) { $ context = $ view -> getContext ( ) ; $ groups = $ context -> getGroups ( ) ; if ( empty ( $ groups ) && $ this -> exclusionStrategyGroups ) { $ context -> setGroups ( $ this -> exclusionStrategyGroups ) ; } if ( null === $ context -> getVersion ( ) && $ thi...
Gets or creates a JMS \ Serializer \ SerializationContext and initializes it with the view exclusion strategies groups & versions if a new context is created .
44,234
public function handle ( View $ view , Request $ request = null ) { if ( null === $ request ) { $ request = $ this -> requestStack -> getCurrentRequest ( ) ; } $ format = $ view -> getFormat ( ) ? : $ request -> getRequestFormat ( ) ; if ( ! $ this -> supports ( $ format ) ) { $ msg = "Format '$format' not supported, h...
Handles a request with the proper handler .
44,235
public function createRedirectResponse ( View $ view , $ location , $ format ) { $ content = null ; if ( ( Response :: HTTP_CREATED === $ view -> getStatusCode ( ) || Response :: HTTP_ACCEPTED === $ view -> getStatusCode ( ) ) && null !== $ view -> getData ( ) ) { $ response = $ this -> initResponse ( $ view , $ format...
Creates the Response from the view .
44,236
public function renderTemplate ( View $ view , $ format ) { if ( null === $ this -> templating ) { throw new \ LogicException ( sprintf ( 'An instance of %s must be injected in %s to render templates.' , EngineInterface :: class , __CLASS__ ) ) ; } $ data = $ this -> prepareTemplateParameters ( $ view ) ; $ template = ...
Renders the view data with the given template .
44,237
public function prepareTemplateParameters ( View $ view ) { $ data = $ view -> getData ( ) ; if ( $ data instanceof FormInterface ) { $ data = [ $ view -> getTemplateVar ( ) => $ data -> getData ( ) , 'form' => $ data ] ; } elseif ( empty ( $ data ) || ! is_array ( $ data ) || is_numeric ( ( key ( $ data ) ) ) ) { $ da...
Prepares view data for use by templating engine .
44,238
private function initResponse ( View $ view , $ format ) { $ content = null ; if ( $ this -> isFormatTemplating ( $ format ) ) { $ content = $ this -> renderTemplate ( $ view , $ format ) ; } elseif ( $ this -> serializeNull || null !== $ view -> getData ( ) ) { $ data = $ this -> getDataFromView ( $ view ) ; if ( $ da...
Initializes a response object that represents the view and holds the view s status code .
44,239
protected function getFormFromView ( View $ view ) { $ data = $ view -> getData ( ) ; if ( $ data instanceof FormInterface ) { return $ data ; } if ( is_array ( $ data ) && isset ( $ data [ 'form' ] ) && $ data [ 'form' ] instanceof FormInterface ) { return $ data [ 'form' ] ; } return false ; }
Returns the form from the given view if present false otherwise .
44,240
private function getDataFromView ( View $ view ) { $ form = $ this -> getFormFromView ( $ view ) ; if ( false === $ form ) { return $ view -> getData ( ) ; } return $ form ; }
Returns the data from a view .
44,241
public function reset ( ) { $ this -> exclusionStrategyGroups = $ this -> options [ 'exclusionStrategyGroups' ] ; $ this -> exclusionStrategyVersion = $ this -> options [ 'exclusionStrategyVersion' ] ; $ this -> serializeNullStrategy = $ this -> options [ 'serializeNullStrategy' ] ; }
Resets internal object state at the end of the request .
44,242
public static function createRedirect ( $ url , $ statusCode = Response :: HTTP_FOUND , array $ headers = [ ] ) { $ view = static :: create ( null , $ statusCode , $ headers ) ; $ view -> setLocation ( $ url ) ; return $ view ; }
Convenience method to allow for a fluent interface while creating a redirect to a given url .
44,243
public static function createRouteRedirect ( $ route , array $ parameters = [ ] , $ statusCode = Response :: HTTP_FOUND , array $ headers = [ ] ) { $ view = static :: create ( null , $ statusCode , $ headers ) ; $ view -> setRoute ( $ route ) ; $ view -> setRouteParameters ( $ parameters ) ; return $ view ; }
Convenience method to allow for a fluent interface while creating a redirect to a given route .
44,244
public function setTemplate ( $ template ) { if ( ! ( is_string ( $ template ) || $ template instanceof TemplateReferenceInterface ) ) { throw new \ InvalidArgumentException ( 'The template should be a string or implement TemplateReferenceInterface' ) ; } $ this -> template = $ template ; return $ this ; }
Sets template to use for the encoding .
44,245
private function normalizeArray ( array & $ data ) { $ normalizedData = array ( ) ; foreach ( $ data as $ key => $ val ) { $ normalizedKey = $ this -> normalizeString ( $ key ) ; if ( $ normalizedKey !== $ key ) { if ( array_key_exists ( $ normalizedKey , $ normalizedData ) ) { throw new NormalizationException ( sprint...
Normalizes an array .
44,246
protected function normalizeString ( $ string ) { if ( false === strpos ( $ string , '_' ) ) { return $ string ; } return preg_replace_callback ( '/_([a-zA-Z0-9])/' , function ( $ matches ) { return strtoupper ( $ matches [ 1 ] ) ; } , $ string ) ; }
Normalizes a string .
44,247
public function createResponse ( ViewHandler $ handler , View $ view , Request $ request ) { try { $ content = $ this -> createFeed ( $ view -> getData ( ) ) ; $ code = Response :: HTTP_OK ; } catch ( \ Exception $ e ) { if ( $ this -> logger ) { $ this -> logger -> error ( $ e ) ; } $ content = sprintf ( '%s:<br/><pre...
Converts the viewdata to a RSS feed . Modify to suit your datastructure .
44,248
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; if ( ! $ request -> attributes -> get ( FOSRestBundle :: ZONE_ATTRIBUTE , true ) ) { return ; } try { $ format = $ request -> getRequestFormat ( null ) ; if ( null === $ format ) { $ accept = $ this -> formatNegotiato...
Determines and sets the Request format .
44,249
public function createResponse ( ViewHandler $ handler , View $ view , Request $ request , $ format ) { $ response = $ handler -> createResponse ( $ view , $ request , 'json' ) ; if ( $ response -> isSuccessful ( ) ) { $ callback = $ this -> getCallback ( $ request ) ; $ response -> setContent ( sprintf ( '/**/%s(%s)' ...
Handles wrapping a JSON response into a JSONP response .
44,250
protected function normalizeString ( $ string ) { if ( false === strpos ( $ string , '_' ) ) { return $ string ; } $ offset = strspn ( $ string , '_' ) ; if ( $ offset ) { $ underscorePrefix = substr ( $ string , 0 , $ offset ) ; $ string = substr ( $ string , $ offset ) ; } else { $ underscorePrefix = '' ; } return $ ...
Normalizes a string while leaving leading underscores unchanged .
44,251
public function read ( \ ReflectionClass $ reflectionClass ) { $ collection = new RestRouteCollection ( ) ; $ collection -> addResource ( new FileResource ( $ reflectionClass -> getFileName ( ) ) ) ; if ( $ annotation = $ this -> annotationReader -> getClassAnnotation ( $ reflectionClass , Annotations \ Prefix :: class...
Reads controller routes .
44,252
private function includeFormatIfNeeded ( & $ path , & $ requirements ) { if ( true === $ this -> includeFormat ) { $ path .= '.{_format}' ; if ( ! isset ( $ requirements [ '_format' ] ) && ! empty ( $ this -> formats ) ) { $ requirements [ '_format' ] = implode ( '|' , array_keys ( $ this -> formats ) ) ; } } }
Include the format in the path and requirements if its enabled .
44,253
private function isMethodReadable ( \ ReflectionMethod $ method ) { if ( '_' === substr ( $ method -> getName ( ) , 0 , 1 ) ) { return false ; } $ hasNoRouteMethod = ( bool ) $ this -> readMethodAnnotation ( $ method , 'NoRoute' ) ; $ hasNoRouteClass = ( bool ) $ this -> readClassAnnotation ( $ method -> getDeclaringCl...
Checks whether provided method is readable .
44,254
private function getHttpMethodAndResourcesFromMethod ( \ ReflectionMethod $ method , $ resource ) { if ( ! preg_match ( '/([a-z][_a-z0-9]+)(.*)Action/' , $ method -> getName ( ) , $ matches ) ) { return false ; } $ httpMethod = strtolower ( $ matches [ 1 ] ) ; $ resources = preg_split ( '/([A-Z][^A-Z]*)/' , $ matches [...
Returns HTTP method and resources list from method signature .
44,255
private function getMethodArguments ( \ ReflectionMethod $ method ) { $ params = $ this -> paramReader -> getParamsFromMethod ( $ method ) ; $ ignoreParameters = [ ] ; if ( class_exists ( ParamConverter :: class ) ) { $ ignoreParameters = array_map ( function ( $ annotation ) { return $ annotation instanceof ParamConve...
Returns readable arguments from method .
44,256
private function generateResourceName ( $ resource ) { if ( false === $ this -> pluralize ) { return $ resource ; } return $ this -> inflector -> pluralize ( $ resource ) ; }
Generates final resource name .
44,257
private function generateRouteName ( array $ resources ) { $ routeName = '' ; foreach ( $ resources as $ resource ) { if ( null !== $ resource ) { $ routeName .= '_' . basename ( $ resource ) ; } } return $ routeName ; }
Generates route name from resources list .
44,258
private function generateUrlParts ( array $ resources , array $ arguments , $ httpMethod ) { $ urlParts = [ ] ; foreach ( $ resources as $ i => $ resource ) { if ( ! empty ( $ this -> routePrefix ) && $ i === count ( $ this -> parents ) ) { $ urlParts [ ] = $ this -> routePrefix ; } if ( isset ( $ arguments [ $ i ] ) )...
Generates URL parts for route from resources list .
44,259
private function getCustomHttpMethod ( $ httpMethod , array $ resources , array $ arguments ) { if ( in_array ( $ httpMethod , $ this -> availableConventionalActions ) ) { return 'get' ; } if ( count ( $ arguments ) < count ( $ resources ) ) { return 'get' ; } return 'patch' ; }
Returns custom HTTP method for provided list of resources arguments method .
44,260
private function readRouteAnnotation ( \ ReflectionMethod $ reflectionMethod ) { $ annotations = [ ] ; if ( $ newAnnotations = $ this -> readMethodAnnotations ( $ reflectionMethod , 'Route' ) ) { $ annotations = array_merge ( $ annotations , $ newAnnotations ) ; } return $ annotations ; }
Returns first route annotation for method .
44,261
private function readClassAnnotation ( \ ReflectionClass $ reflectionClass , $ annotationName ) { $ annotationClass = "FOS\\RestBundle\\Controller\\Annotations\\$annotationName" ; if ( $ annotation = $ this -> annotationReader -> getClassAnnotation ( $ reflectionClass , $ annotationClass ) ) { return $ annotation ; } }
Reads class annotations .
44,262
public function addParentNamePrefix ( RouteCollection $ collection , $ namePrefix ) { if ( ! isset ( $ namePrefix ) || '' === ( $ namePrefix = trim ( $ namePrefix ) ) ) { return $ collection ; } $ iterator = $ collection -> getIterator ( ) ; foreach ( $ iterator as $ key1 => $ route1 ) { $ collection -> add ( $ namePre...
Adds a name prefix to the route name of all collection routes .
44,263
public function importResource ( LoaderInterface $ loader , $ resource , array $ parents = [ ] , $ routePrefix = null , $ namePrefix = null , $ type = null , $ currentDir = null ) { $ loader = $ loader -> resolve ( $ resource , $ type ) ; if ( $ loader instanceof FileLoader && null !== $ currentDir ) { $ resource = $ l...
Import & return routes collection from a resource .
44,264
private function getControllerLocator ( $ controller ) { $ class = null ; $ prefix = null ; if ( 0 === strpos ( $ controller , '@' ) ) { $ file = $ this -> locator -> locate ( $ controller ) ; $ controllerClass = ClassUtils :: findClassInFile ( $ file ) ; if ( false === $ controllerClass ) { throw new \ InvalidArgument...
Returns controller locator by it s id .
44,265
protected function getViewHandler ( ) { if ( ! $ this -> viewhandler instanceof ViewHandlerInterface ) { $ this -> viewhandler = $ this -> container -> get ( 'fos_rest.view_handler' ) ; } return $ this -> viewhandler ; }
Get the ViewHandler .
44,266
public function getFiles ( $ root = null ) { $ root = $ root ? : __DIR__ . '/../../../../' ; $ root = realpath ( $ root ) ; if ( $ this -> files == null ) { $ files = scandir ( $ root ) ; foreach ( $ files as $ i => $ file ) { if ( is_dir ( "$root/$file" ) ) { $ files [ $ i ] .= "/" ; } } $ this -> files = $ files ; } ...
Get list of files and directories previously set or generate from parent project .
44,267
public static function create ( $ payload , Exception $ exception , Resque_Worker $ worker , $ queue ) { $ backend = self :: getBackend ( ) ; new $ backend ( $ payload , $ exception , $ worker , $ queue ) ; }
Create a new failed job on the backend .
44,268
public static function all ( ) { $ workers = Resque :: redis ( ) -> smembers ( 'workers' ) ; if ( ! is_array ( $ workers ) ) { $ workers = array ( ) ; } $ instances = array ( ) ; foreach ( $ workers as $ workerId ) { $ instances [ ] = self :: find ( $ workerId ) ; } return $ instances ; }
Return all workers known to Resque as instantiated instances .
44,269
private function parseToken ( array $ parsedTokens , TokenParserInterface $ parser , Token $ token ) : array { $ parsedToken = $ parser -> parse ( $ token ) ; if ( $ parsedToken instanceof FunctionCallValue ) { $ lastParsedToken = end ( $ parsedTokens ) ; if ( $ lastParsedToken instanceof FixtureReferenceValue ) { $ pa...
Parses the given token . If the value returned is a ListValue its values will be merged to the list of parsed tokens instead of adding the value itself . Another check is done to ensure that successive string tokens are merged .
44,270
public function mergeInclude ( array $ data , array $ includeData ) : array { foreach ( $ data as $ class => $ fixtures ) { $ includeData [ $ class ] = ( array_key_exists ( $ class , $ includeData ) && is_array ( $ includeData [ $ class ] ) && is_array ( $ fixtures ) ) ? array_merge ( $ includeData [ $ class ] , $ fixt...
Merges a parsed file data with another . If some data overlaps the existent data is kept i . e . the included data is discarded .
44,271
private function buildTree ( string $ originalValue , array $ tokens ) : array { $ tree = [ ] ; $ functions = [ ] ; foreach ( $ tokens as $ key => $ value ) { if ( $ this -> tokenizer -> isOpeningToken ( $ value ) ) { $ functions [ $ key ] = null ; continue ; } if ( $ this -> tokenizer -> isClosingToken ( $ value ) ) {...
Regroup tokens together by detecting when the function starts closes or when it is nested .
44,272
public function resolve ( TemplatingFixture $ fixture , FixtureBag $ unresolvedFixtures , TemplatingFixtureBag $ resolvedFixtures , ResolvingContext $ context ) : TemplatingFixtureBag { $ context -> checkForCircularReference ( $ fixture -> getId ( ) ) ; if ( false === $ fixture -> extendsFixtures ( ) ) { return $ resol...
Resolves a given fixture . The resolution of a fixture may result in the resolution of several fixtures .
44,273
public function instantiate ( FixtureInterface $ fixture , ResolvedFixtureSet $ fixtureSet , GenerationContext $ context ) : ResolvedFixtureSet { list ( $ fixture , $ fixtureSet ) = $ this -> resolveFixtureConstructor ( $ fixture , $ fixtureSet , $ context ) ; return $ this -> instantiator -> instantiate ( $ fixture , ...
Resolves the fixture constructor arguments before instantiating it .
44,274
public function mergeWith ( self $ specs ) : self { $ clone = clone $ this ; if ( null === $ clone -> constructor ) { $ clone -> constructor = $ specs -> constructor ; } $ clone -> properties = $ this -> properties -> mergeWith ( $ specs -> properties ) ; $ clone -> calls = $ this -> calls -> mergeWith ( $ specs -> cal...
Creates a new instance to which the given specs have been merged . In case of conflicts the existing values are kept .
44,275
private function denormalizeTemporaryFixture ( FixtureBag $ builtFixtures , string $ className , array $ specs , FlagBag $ flags ) : array { $ tempFixtureId = uniqid ( 'temporary_id' ) ; $ builtFixtures = $ this -> denormalizer -> denormalize ( $ builtFixtures , $ className , $ tempFixtureId , $ specs , $ flags ) ; $ t...
Helper method which uses the denormalizer to denormalize a fixture with the given properties but with a random ID . The ID used and with the fixtures are returned .
44,276
private function getSuitableIds ( FixtureMatchReferenceValue $ value , ResolvedFixtureSet $ fixtureSet , GenerationContext $ context ) : array { $ pattern = $ value -> getValue ( ) ; try { $ cache = $ context -> getCachedValue ( self :: IDS_BY_PATTERN_CACHE_KEY ) ; } catch ( CachedValueNotFound $ exception ) { $ cache ...
Gets all the fixture IDs suitable for the given value .
44,277
public function with ( ObjectInterface $ object ) : self { $ clone = clone $ this ; $ clone -> objects [ $ object -> getId ( ) ] = $ object ; $ clone -> array [ $ object -> getId ( ) ] = $ object -> getInstance ( ) ; return $ clone ; }
Creates a new instance which will contain the given object . If an object with the same reference already exists it will be overridden by the new object .
44,278
public function mergeWith ( self $ objects ) : self { $ clone = clone $ this ; foreach ( $ objects -> objects as $ reference => $ object ) { $ clone -> objects [ $ reference ] = $ object ; $ clone -> array [ $ reference ] = $ object -> getInstance ( ) ; } return $ clone ; }
Creates a new instance with the new objects . If objects with the same reference already exists they will be overridden by the new ones .
44,279
private function loadConfig ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ processedConfiguration = $ this -> processConfiguration ( $ configuration , $ configs ) ; foreach ( $ processedConfiguration as $ key => $ value ) { $ container -> setParameter ( $ this -> getAli...
Loads alice configuration and add the configuration values to the application parameters .
44,280
private function loadServices ( ContainerBuilder $ container ) { $ loader = new XmlFileLoader ( $ container , new FileLocator ( self :: SERVICES_DIR ) ) ; $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( self :: SERVICES_DIR ) ; foreach ( $ finder as $ file ) { $ loader -> load ( $ file -> getRelativePathname ...
Loads all the services declarations .
44,281
public static function createFrom ( self $ resolving = null , string $ key ) : self { $ instance = null === $ resolving ? new self ( ) : $ resolving ; if ( false === $ instance -> has ( $ key ) ) { $ instance -> add ( $ key ) ; } return $ instance ; }
Returns the existing instance if is an object or create a new one otherwise . It also ensure that the key will be added also it won t increment the counter if already present .
44,282
public function tokenize ( string $ value ) : array { $ value = preg_replace ( '/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/' , sprintf ( '$1%1$sFUNCTION_START__$2__%1$s$3' , self :: DELIMITER ) , $ value ) ; $ value = preg_replace ( '/<\(/' , sprintf ( '%1$sIDENTITY_START%1$s' , self :: DELIMITER ) , $ value ) ; $ va...
Replaces the function delimiters by tokens to easily identify them in the future and return the value splat into tokens .
44,283
public function detokenize ( string $ value ) : string { $ count = 1 ; while ( $ count !== 0 ) { $ value = preg_replace ( '/FUNCTION_START__(.*?)__/' , '<$1(' , $ value , 1 , $ count ) ; } $ value = preg_replace ( '/IDENTITY_START/' , '<(' , $ value ) ; $ value = preg_replace ( '/IDENTITY_OR_FUNCTION_END/' , ')>' , $ v...
Replaces the tokens by their original values .
44,284
public function parse ( string $ value ) { $ parsedValue = $ this -> parser -> parse ( $ value ) ; if ( false === $ parsedValue instanceof ListValue ) { return $ parsedValue ; } $ mergedValues = array_reduce ( $ parsedValue -> getValue ( ) , [ $ this , 'mergeStrings' ] , $ initial = [ ] ) ; return ( 1 === count ( $ mer...
Uses the decorated parser to parse the value and then walk through the list of values to merge two successive strings .
44,285
public function resolve ( Parameter $ parameter , ParameterBag $ unresolvedParameters , ParameterBag $ resolvedParameters , ResolvingContext $ context = null , ParameterBag $ previousResult = null , int $ counter = 1 ) : ParameterBag { if ( null === $ previousResult ) { $ result = $ this -> resolver -> resolve ( $ para...
Resolves a parameter two times and if a different result is obtained will resolve the parameter again until two successive resolution give the same result .
44,286
public function parse ( string $ file ) : array { foreach ( $ this -> parsers as $ parser ) { if ( $ parser -> canParse ( $ file ) ) { return $ parser -> parse ( $ file ) ; } } throw ParseExceptionFactory :: createForParserNoFoundForFile ( $ file ) ; }
Looks for the first suitable parser to parse the file .
44,287
private function tryToMarkObjectAsComplete ( FixtureInterface $ fixture , ResolvedFixtureSet $ set , GenerationContext $ context ) : ResolvedFixtureSet { $ object = $ set -> getObjects ( ) -> get ( $ fixture ) ; if ( $ object instanceof CompleteObject || false === $ this -> isObjectComplete ( $ fixture , $ set , $ cont...
I however see no way to do that while still complying with the BC break policy hence for 4 . 0 .
44,288
public function with ( Parameter $ parameter ) : self { $ key = $ parameter -> getKey ( ) ; $ clone = clone $ this ; if ( false === $ clone -> has ( $ key ) ) { $ clone -> parameters [ $ key ] = $ parameter -> getValue ( ) ; } return $ clone ; }
Returns a new instance which will include the passed parameter . If a parameter with that key already exist it WILL NOT be overridden .
44,289
public function withFlag ( FlagInterface $ flag ) : self { $ clone = clone ( $ this ) ; $ clone -> flags [ $ flag -> __toString ( ) ] = deep_clone ( $ flag ) ; return $ clone ; }
Creates a new instance of the bag with the given flag . If a flag with the same identifier already exists the existing value will be replaced .
44,290
public function mergeWith ( self $ flags , bool $ override = true ) : self { if ( $ override ) { $ clone = clone ( $ this ) ; foreach ( $ flags as $ stringFlag => $ flag ) { $ clone -> flags [ $ flag -> __toString ( ) ] = clone ( $ flag ) ; } } else { $ clone = clone ( $ flags ) ; $ clone -> key = $ this -> key ; forea...
Creates a new instance with the two bags merged together .
44,291
public function check ( JWT $ jwt , int $ index , array $ mandatoryHeaderParameters = [ ] ) { foreach ( $ this -> tokenTypes as $ tokenType ) { if ( $ tokenType -> supports ( $ jwt ) ) { $ protected = [ ] ; $ unprotected = [ ] ; $ tokenType -> retrieveTokenHeaders ( $ jwt , $ index , $ protected , $ unprotected ) ; $ t...
This method checks all the header parameters passed as argument . All header parameters are checked against the header parameter checkers . If one fails the InvalidHeaderException is thrown .
44,292
public static function generate ( string $ Z , string $ algorithm , int $ encryption_key_size , string $ apu = '' , string $ apv = '' ) : string { $ apu = ! empty ( $ apu ) ? Base64Url :: decode ( $ apu ) : '' ; $ apv = ! empty ( $ apv ) ? Base64Url :: decode ( $ apv ) : '' ; $ encryption_segments = [ self :: toInt32Bi...
Key Derivation Function .
44,293
private function add ( JWESerializer $ serializer ) : self { $ this -> serializers [ $ serializer -> name ( ) ] = $ serializer ; return $ this ; }
Adds a serializer to the manager .
44,294
public function serialize ( string $ name , JWE $ jws , ? int $ recipientIndex = null ) : string { if ( ! \ array_key_exists ( $ name , $ this -> serializers ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Unsupported serializer "%s".' , $ name ) ) ; } return ( $ this -> serializers [ $ name ] ) -> serialize ...
Converts a JWE into a string . Throws an exception if none of the serializer was able to convert the input .
44,295
public function unserialize ( string $ input , ? string & $ name = null ) : JWE { foreach ( $ this -> serializers as $ serializer ) { try { $ jws = $ serializer -> unserialize ( $ input ) ; $ name = $ serializer -> name ( ) ; return $ jws ; } catch ( \ InvalidArgumentException $ e ) { continue ; } } throw new \ Invalid...
Loads data and return a JWE object . Throws an exception if none of the serializer was able to convert the input .
44,296
public function create ( array $ names ) : JWESerializerManager { $ serializers = [ ] ; foreach ( $ names as $ name ) { if ( ! \ array_key_exists ( $ name , $ this -> serializers ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Unsupported serializer "%s".' , $ name ) ) ; } $ serializers [ ] = $ this -> serial...
Creates a serializer manager factory using the given serializers .
44,297
public static function exponentiate ( self $ key , BigInteger $ c ) : BigInteger { if ( $ c -> compare ( BigInteger :: createFromDecimal ( 0 ) ) < 0 || $ c -> compare ( $ key -> getModulus ( ) ) > 0 ) { throw new \ RuntimeException ( ) ; } if ( $ key -> isPublic ( ) || empty ( $ key -> getPrimes ( ) ) || empty ( $ key ...
Exponentiate with or without Chinese Remainder Theorem . Operation with primes p and q is appox . 2x faster .
44,298
public function create ( array $ keyEncryptionAlgorithms , array $ contentEncryptionAlgorithms , array $ compressionMethods ) : JWEDecrypter { $ keyEncryptionAlgorithmManager = $ this -> algorithmManagerFactory -> create ( $ keyEncryptionAlgorithms ) ; $ contentEncryptionAlgorithmManager = $ this -> algorithmManagerFac...
Creates a JWE Decrypter object using the given key encryption algorithms content encryption algorithms and compression methods .
44,299
public static function createOctKey ( int $ size , array $ values = [ ] ) : JWK { if ( 0 !== $ size % 8 ) { throw new InvalidArgumentException ( 'Invalid key size.' ) ; } $ values = \ array_merge ( $ values , [ 'kty' => 'oct' , 'k' => Base64Url :: encode ( \ random_bytes ( $ size / 8 ) ) , ] ) ; return new JWK ( $ valu...
Creates a octet key with the given key size and additional values .