idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
48,900
public function registerFieldsCollection ( ) { $ this -> app -> bind ( 'fields.collection' , function ( $ app ) { return new FieldsCollection ( $ app [ 'fields.finder' ] ) ; } ) ; $ this -> app -> alias ( 'fields.collection' , FieldsCollection :: class ) ; }
Register fields collection .
48,901
public function registerFieldManager ( ) { $ this -> app -> bind ( 'field.manager' , function ( $ app ) { return new FieldManager ( $ app [ 'hook.factory' ] , $ app [ 'asset.factory' ] , $ app [ 'view' ] , $ app [ 'field.validator' ] ) ; } ) ; $ this -> app -> alias ( 'field.manager' , FieldManager :: class ) ; }
Register field manager .
48,902
public function register ( ) { $ this -> app -> singleton ( 'comment.factory' , function ( $ app ) { return new CommentFactory ( $ app ) ; } ) ; $ this -> app -> alias ( 'comment.factory' , CommentFactory :: class ) ; }
Register comment services .
48,903
public function sanitizeWithCallback ( $ value ) { if ( $ this -> needsSanitization ( ) ) { return call_user_func ( $ this -> getArgument ( 'sanitize' ) , Descend :: whileEmpty ( $ value ) ) ; } return $ value ; }
Run sanitize callback on field value .
48,904
public function setFingerprint ( $ fingerprint = null ) { if ( isset ( $ fingerprint ) ) { $ this -> fingerprint = $ fingerprint ; } else { $ this -> fingerprint = 'assely-' . Str :: random ( ) ; } return $ this ; }
Sets the value of fingerprint .
48,905
public function registerActionsCollection ( ) { $ this -> app -> singleton ( 'ajaxes.collection' , function ( $ app ) { return new ActionsCollection ; } ) ; $ this -> app -> alias ( 'ajaxes.collection' , ActionsCollection :: class ) ; }
Register collection of AJAX actions .
48,906
public function registerDispatcher ( ) { $ this -> app -> singleton ( 'ajax.dispatcher' , function ( $ app ) { return new Dispatcher ( $ app [ 'ajaxes.collection' ] , $ app [ 'router' ] , $ app ) ; } ) ; $ this -> app -> alias ( 'ajax.dispatcher' , Dispatcher :: class ) ; }
Register AJAX actions dispatcher .
48,907
public function make ( Container $ container ) { $ this -> container = $ container ; $ this -> container -> call ( [ $ this , 'dispatch' ] ) ; $ this -> register ( ) ; return $ this ; }
Make repository .
48,908
public function make ( $ currentPage , array $ arguments = [ ] ) { $ this -> currentPage = $ currentPage ? : get_query_var ( 'paged' ) ; $ this -> setArguments ( array_merge ( $ arguments , $ this -> getDefaults ( ) ) ) ; $ this -> setLinks ( $ this -> getPaginationLinks ( ) ) ; return $ this -> generate ( ) ; }
Get pagination .
48,909
public function generateItems ( ) { $ j = 1 ; foreach ( $ this -> getLinks ( ) as $ index => $ link ) { $ item = new PaginationItem ( $ link ) ; if ( $ index === 0 && $ this -> currentPage != 1 ) { $ this -> markAsPrevious ( $ item ) ; continue ; } if ( $ index === $ this -> getLinksCount ( true ) && $ this -> currentPage != $ this -> getLinksCount ( true ) ) { $ this -> markAsNext ( $ item ) ; break ; } $ item -> number = $ j ++ ; $ this -> items [ ] = $ item ; } }
Generate pagination items previous and next .
48,910
public function findActiveItem ( ) { foreach ( $ this -> items as $ index => $ item ) { $ index ++ ; if ( $ item -> number == $ this -> currentPage ) { $ item -> active = true ; } } }
Find and mark current page item .
48,911
public function getLinksCount ( $ zeroBased = false ) { $ count = count ( $ this -> getLinks ( ) ) ; if ( $ zeroBased ) { return $ count - 1 ; } return $ count ; }
Get number of links .
48,912
public function registerRoutesCollection ( ) { $ this -> app -> singleton ( 'routes.collection' , function ( $ app ) { return new RoutesCollection ; } ) ; $ this -> app -> alias ( 'routes.collection' , RoutesCollection :: class ) ; }
Register collection of routes .
48,913
public function registerWordPressConditions ( ) { $ this -> app -> singleton ( 'wpconditions' , function ( $ app ) { return new WordpressConditions ; } ) ; $ this -> app -> alias ( 'wpconditions' , WordpressConditions :: class ) ; }
Register collection of WordPress conditions .
48,914
public function registerRouter ( ) { $ this -> app -> singleton ( 'router' , function ( $ app ) { return new Router ( $ app [ 'routes.collection' ] , $ app [ 'wpconditions' ] , $ app ) ; } ) ; $ this -> app -> alias ( 'router' , Router :: class ) ; }
Register router instance .
48,915
public function assets ( ) { $ assets = $ this -> app -> make ( 'assets.collection' ) -> all ( ) ; if ( ! $ this -> getOption ( 'all' ) ) { $ assets = array_filter ( $ assets , function ( $ asset ) { return $ asset -> getArea ( ) !== 'admin' ; } ) ; } $ headers = [ 'Slug' , 'Type' , 'Path' , 'Area' , 'Placement' , 'Execution' , 'Version' ] ; $ dataset = array_map ( function ( $ asset ) { return [ $ asset -> getSlug ( ) , $ asset -> getType ( ) , $ asset -> getArgument ( 'path' ) , $ asset -> getArea ( ) , $ asset -> getPlacement ( ) , $ asset -> getExecution ( ) , $ asset -> getArgument ( 'version' ) , ] ; } , $ assets ) ; $ this -> table ( $ headers , $ dataset ) ; }
Show registered assets in theme area .
48,916
public function routes ( ) { $ routes = $ this -> app -> make ( 'routes.collection' ) -> getAll ( ) ; $ headers = [ 'Condition' , 'Filter' , 'Action' , 'Parameters' , 'Pattern' , 'Guid' ] ; $ dataset = array_map ( function ( $ route ) { return [ $ route -> getCondition ( ) , $ route -> getFilter ( ) , $ route -> getAction ( ) , $ route -> getParameters ( ) , $ route -> getPattern ( ) , $ route -> getGuid ( ) , ] ; } , $ routes ) ; $ this -> table ( $ headers , $ dataset ) ; }
Show registered routes .
48,917
public function sidebars ( ) { $ sidebars = $ this -> app -> make ( 'sidebars.collection' ) -> all ( ) ; $ headers = [ 'Slug' , 'Title' , 'Description' , 'Has widgets' ] ; $ dataset = array_map ( function ( $ sidebar ) { return [ $ sidebar -> getSlug ( ) , $ sidebar -> getSingular ( ) , $ sidebar -> getArgument ( 'description' ) , $ sidebar -> hasWidgets ( ) ? 'true' : 'false' , ] ; } , $ sidebars ) ; $ this -> table ( $ headers , $ dataset ) ; }
Show registered sidebars .
48,918
public function menus ( ) { $ menus = $ this -> app -> make ( 'menus.collection' ) -> all ( ) ; $ headers = [ 'Slug' , 'Top level items' , 'Active' ] ; $ dataset = array_map ( function ( $ menu ) { return [ $ menu -> getSlug ( ) , count ( $ menu -> items ( ) ) , $ menu -> isActive ( ) ? 'true' : 'false' , ] ; } , $ menus ) ; $ this -> table ( $ headers , $ dataset ) ; }
Show registered menus .
48,919
public function ajaxes ( ) { $ ajaxes = $ this -> app -> make ( 'ajaxes.collection' ) -> all ( ) ; $ headers = [ 'AJAX action' , 'Accessibility' ] ; $ dataset = array_map ( function ( $ action ) { return [ $ action -> getSlug ( ) , $ action -> getArgument ( 'accessibility' ) , ] ; } , $ ajaxes ) ; $ this -> table ( $ headers , $ dataset ) ; }
Show registered ajaxes actions .
48,920
protected function registerColumns ( ) { $ this -> hook -> action ( 'admin_init' , function ( ) { $ this -> getSingularity ( ) -> columns ( $ this -> columns ( ) ) ; } ) -> dispatch ( ) ; }
Register comment columns .
48,921
public function create ( Composer $ composer ) : FileIteratorInterface { $ config = $ composer -> getConfig ( ) ; $ autoloadGenerator = $ composer -> getAutoloadGenerator ( ) ; $ installationManager = $ composer -> getInstallationManager ( ) ; $ package = $ composer -> getPackage ( ) ; $ autoloadGenerator -> setClassMapAuthoritative ( $ config -> get ( 'classmap-authoritative' ) ) ; $ autoloadGenerator -> setDevMode ( false ) ; $ packageMap = $ autoloadGenerator -> buildPackageMap ( $ installationManager , $ package , [ $ package ] ) ; $ directives = $ autoloadGenerator -> parseAutoloads ( $ packageMap , $ package ) ; $ files = new AppendIterator ( ) ; $ files -> append ( $ this -> createClassmapIterator ( $ directives [ 'classmap' ] ?? [ ] , $ directives [ 'exclude-from-classmap' ] ?? [ ] ) ) ; $ files -> append ( $ this -> createFilesIterator ( ... array_values ( $ directives [ 'files' ] ?? [ ] ) ) ) ; $ files -> append ( $ this -> createNamespaceIterator ( $ directives [ 'psr-0' ] ?? [ ] ) ) ; $ files -> append ( $ this -> createNamespaceIterator ( $ directives [ 'psr-4' ] ?? [ ] ) ) ; return new FileIterator ( $ files ) ; }
Get an iterable list of source files for the root package of the given Composer instance .
48,922
private function createFilesIterator ( string ... $ paths ) : Iterator { return new ArrayIterator ( array_map ( function ( string $ path ) : SplFileInfo { return new SplFileInfo ( $ path ) ; } , array_filter ( $ paths , function ( string $ path ) : bool { return is_readable ( $ path ) ; } ) ) ) ; }
Create an iterator for the given file paths .
48,923
private function createNamespaceIterator ( array $ namespaces ) : Iterator { $ files = new AppendIterator ( ) ; foreach ( $ namespaces as $ classmap ) { $ files -> append ( $ this -> createClassmapIterator ( $ classmap ) ) ; } return $ files ; }
Create an iterator for the given namespaces .
48,924
private function createClassmapIterator ( iterable $ classmap , iterable $ exclude = [ ] ) : Iterator { $ files = new AppendIterator ( ) ; foreach ( $ classmap as $ directory ) { if ( ! is_dir ( $ directory ) ) { continue ; } $ files -> append ( new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ directory ) ) ) ; } return new class ( $ files , $ this -> preparePattern ( ... $ exclude ) ) extends FilterIterator { private $ excludePattern ; public function __construct ( Iterator $ iterator , ? string $ excludePattern ) { $ this -> excludePattern = $ excludePattern ; parent :: __construct ( $ iterator ) ; } public function accept ( ) : bool { $ file = $ this -> getInnerIterator ( ) -> current ( ) ; return ( $ file -> isFile ( ) && ( $ this -> excludePattern === null ? : ! preg_match ( $ this -> excludePattern , str_replace ( '\\' , '/' , $ file -> getRealPath ( ) ) ) ) ) ; } } ; }
Create a class map iterator using the given class maps and exclude patterns .
48,925
public function determineViolations ( Composer $ composer ) : ViolationIteratorInterface { $ files = $ this -> sourceFileFactory -> create ( $ composer ) ; $ symbolFilter = $ this -> symbolFilterFactory -> create ( $ composer ) ; $ symbols = $ this -> extractor -> extract ( $ files , $ symbolFilter ) ; $ violations = $ this -> finder -> find ( $ composer , $ symbols ) ; return new ViolationIterator ( ... array_filter ( iterator_to_array ( $ violations ) , $ this -> violationFilterFactory -> create ( $ composer ) ) ) ; }
Determine dependency violations for the given Composer instance .
48,926
public function find ( Composer $ composer , SymbolIteratorInterface $ symbols ) : ViolationIteratorInterface { $ candidates = $ this -> extractor -> extract ( $ composer , $ symbols ) ; return new ViolationIterator ( ... array_merge ( $ this -> determineLockViolations ( $ composer , ... $ candidates ) , $ this -> determineUnusedCodeViolations ( $ composer , ... $ candidates ) ) ) ; }
Find violations for the given Composer instance and symbols .
48,927
private function determineLockViolations ( Composer $ composer , CandidateInterface ... $ candidates ) : array { $ violations = [ ] ; $ lock = $ composer -> getLocker ( ) -> getLockData ( ) ; $ lockedPackages = array_map ( function ( array $ package ) : string { return $ package [ 'name' ] ; } , $ lock [ 'packages' ] ?? [ ] ) ; $ lockedDevPackages = array_map ( function ( array $ package ) : string { return $ package [ 'name' ] ; } , $ lock [ 'packages-dev' ] ?? [ ] ) ; foreach ( $ candidates as $ candidate ) { $ package = $ candidate -> getPackage ( ) -> getName ( ) ; if ( in_array ( $ package , $ lockedDevPackages , true ) ) { $ violations [ ] = new Violation ( sprintf ( 'Code base is dependent on dev package %s.' , $ package ) , $ candidate ) ; continue ; } if ( ! in_array ( $ package , $ lockedPackages , true ) ) { $ violations [ ] = new Violation ( sprintf ( 'Package is not installed: %s.' , $ package ) , $ candidate ) ; } } return $ violations ; }
Get violations for candidates violating the locked state .
48,928
private function determineUnusedCodeViolations ( Composer $ composer , CandidateInterface ... $ candidates ) : array { $ repository = $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) ; $ package = $ composer -> getPackage ( ) ; $ violations = [ ] ; $ installed = [ ] ; $ requirements = array_keys ( $ package -> getRequires ( ) ) ; $ packages = array_map ( function ( CandidateInterface $ candidate ) : string { return $ candidate -> getPackage ( ) -> getName ( ) ; } , $ candidates ) ; foreach ( $ repository -> getPackages ( ) as $ package ) { $ installed [ $ package -> getName ( ) ] = $ package ; } foreach ( $ requirements as $ requirement ) { if ( strpos ( $ requirement , '/' ) === false ) { continue ; } if ( ! array_key_exists ( $ requirement , $ installed ) ) { continue ; } $ package = $ installed [ $ requirement ] ; if ( $ package -> getType ( ) === 'metapackage' ) { continue ; } if ( ! in_array ( $ requirement , $ packages , true ) ) { $ violations [ ] = new Violation ( sprintf ( 'Package "%s" is installed, but never used.' , $ requirement ) , new Candidate ( $ package , new SymbolIterator ( ) ) ) ; } } return $ violations ; }
Determine what packages are installed without having its code be used in the given package .
48,929
public function extract ( Composer $ composer , SymbolIteratorInterface $ symbols ) : iterable { $ repository = $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) ; $ vendorPath = str_replace ( '\\' , '/' , $ composer -> getConfig ( ) -> get ( 'vendor-dir' , 0 ) ) ; $ packages = [ ] ; foreach ( $ symbols as $ symbol ) { $ package = $ this -> extractPackage ( $ vendorPath , $ symbol ) ; if ( $ package === null ) { continue ; } if ( ! array_key_exists ( $ package , $ packages ) ) { $ packages [ $ package ] = [ ] ; } $ packages [ $ package ] [ ] = $ symbol ; } $ installed = $ repository -> getPackages ( ) ; $ candidates = [ ] ; foreach ( $ packages as $ name => $ symbols ) { $ package = $ this -> getPackageByName ( $ installed , $ name ) ; if ( $ package === null ) { continue ; } $ candidates [ ] = new Candidate ( $ package , new SymbolIterator ( ... $ symbols ) ) ; } return $ candidates ; }
Extract violation candidates from the given Composer instance and symbols .
48,930
private function extractPackage ( string $ vendorPath , SymbolInterface $ symbol ) : ? string { static $ packagesPerSymbol = [ ] ; $ name = $ symbol -> getName ( ) ; if ( ! array_key_exists ( $ name , $ packagesPerSymbol ) ) { $ reflection = $ this -> getClassReflection ( $ name ) ; $ file = str_replace ( '\\' , '/' , $ reflection -> getFileName ( ) ) ; if ( strpos ( $ file , $ vendorPath ) !== 0 ) { return null ; } $ structure = explode ( '/' , preg_replace ( sprintf ( '/^%s/' , preg_quote ( $ vendorPath . '/' , '/' ) ) , '' , $ file ) , 3 ) ; if ( count ( $ structure ) < 3 ) { $ packagesPerSymbol [ $ name ] = null ; } [ $ vendor , $ package ] = $ structure ; $ packagesPerSymbol [ $ name ] = sprintf ( '%s/%s' , $ vendor , $ package ) ; } return $ packagesPerSymbol [ $ name ] ?? null ; }
Extract the package name from the given PHP symbol .
48,931
private static function getReflectionEnvironment ( ) : BetterReflection { if ( self :: $ reflectionEnvironment === null ) { self :: $ reflectionEnvironment = new BetterReflection ( ) ; } return self :: $ reflectionEnvironment ; }
Get the current reflection environment .
48,932
public function resolve ( Locker $ locker ) : array { if ( ! $ this -> resolvedLockers -> contains ( $ locker ) ) { $ lockedPackages = $ locker -> getLockedRepository ( ) -> getPackages ( ) ; $ this -> resolvedLockers -> attach ( $ locker , array_map ( function ( array $ packages ) use ( $ lockedPackages ) : array { return array_reduce ( $ lockedPackages , function ( array $ carry , PackageInterface $ package ) use ( $ packages ) : array { if ( in_array ( $ package -> getName ( ) , $ packages , true ) ) { $ carry [ ] = $ package ; } return $ carry ; } , [ ] ) ; } , $ this -> resolveGraph ( ... $ locker -> getLockData ( ) [ 'packages' ] ?? [ ] ) ) ) ; } return $ this -> resolvedLockers -> offsetGet ( $ locker ) ; }
Resolve the dependents graph for the given Composer locker .
48,933
private function resolveGraph ( array ... $ packages ) : array { $ graph = array_reduce ( $ packages , function ( array $ carry , array $ package ) : array { foreach ( array_keys ( $ package [ 'require' ] ?? [ ] ) as $ link ) { if ( ! preg_match ( '/^[^\/]+\/[^\/]+$/' , $ link ) ) { continue ; } if ( ! array_key_exists ( $ link , $ carry ) ) { $ carry [ $ link ] = [ ] ; } if ( ! in_array ( $ package [ 'name' ] , $ carry [ $ link ] , true ) ) { $ carry [ $ link ] [ ] = $ package [ 'name' ] ; } } return $ carry ; } , [ ] ) ; for ( $ previousGraph = [ ] ; $ graph !== $ previousGraph ; ) { $ previousGraph = $ graph ; foreach ( $ graph as $ package => $ dependents ) { $ graph [ $ package ] = array_reduce ( $ dependents , function ( array $ carry , string $ parent ) use ( $ graph ) : array { foreach ( $ graph [ $ parent ] ?? [ ] as $ grandparent ) { if ( ! in_array ( $ grandparent , $ carry , true ) ) { $ carry [ ] = $ grandparent ; } } return $ carry ; } , $ dependents ) ; } } return $ graph ; }
Resolve the dependents graph for the given packages .
48,934
public function create ( Composer $ composer ) : SymbolFilterInterface { $ filters = array_map ( function ( string $ exclusion ) : SymbolFilterInterface { $ filters = [ new ExactSymbolFilter ( $ exclusion ) , new PatternSymbolFilter ( $ exclusion ) ] ; if ( preg_match ( '#\\\\$#' , $ exclusion ) ) { $ filters [ ] = new NamespaceSymbolFilter ( $ exclusion ) ; } return new SymbolFilterChain ( ... $ filters ) ; } , $ this -> getExclusions ( $ composer ) ) ; $ filters [ ] = new UserDefinedSymbolFilter ( ) ; return new SymbolFilterChain ( ... $ filters ) ; }
Create a symbol filter for the given Composer instance .
48,935
public function enterNode ( Node $ node ) : void { $ name = null ; if ( $ node instanceof Name ) { $ name = $ node -> toString ( ) ; } if ( $ name === null || ( array_key_exists ( $ name , $ this -> symbols ) && $ this -> symbols [ $ name ] === false ) ) { return ; } if ( ! $ this -> filter -> __invoke ( $ name ) ) { $ this -> symbols [ $ name ] = false ; return ; } if ( ! array_key_exists ( $ name , $ this -> symbols ) ) { $ this -> symbols [ $ name ] = [ ] ; } $ this -> symbols [ $ name ] [ ] = $ node ; }
Track the given node .
48,936
public function getSymbols ( ) : iterable { return new \ CallbackFilterIterator ( new \ RecursiveIteratorIterator ( new \ RecursiveArrayIterator ( $ this -> symbols , \ RecursiveArrayIterator :: CHILD_ARRAYS_ONLY ) ) , function ( $ each ) : bool { return $ each !== false ; } ) ; }
Get the symbols that are present in the tracker .
48,937
public function extract ( FileIteratorInterface $ files , SymbolFilterInterface $ filter ) : SymbolIteratorInterface { $ symbols = [ ] ; foreach ( $ files as $ file ) { $ parser = clone $ this -> parser ; try { $ size = $ file -> getSize ( ) ; $ handle = $ file -> openFile ( 'rb' ) ; $ contents = $ size > 0 ? $ handle -> fread ( $ size ) : '' ; if ( empty ( $ contents ) ) { continue ; } $ statements = $ parser -> parse ( $ contents ) ; } catch ( Error $ e ) { continue ; } $ tracker = new SymbolTracker ( $ filter ) ; $ traverser = new NodeTraverser ( ) ; $ traverser -> addVisitor ( $ tracker ) ; $ traverser -> traverse ( $ statements ) ; foreach ( $ tracker -> getSymbols ( ) as $ node ) { $ symbols [ ] = new Symbol ( $ file , $ node ) ; } } return new SymbolIterator ( ... $ symbols ) ; }
Extract the PHP symbols from the given files .
48,938
public function create ( Composer $ composer ) : ViolationFilterInterface { $ chain = new ViolationFilterChain ( ... array_merge ( $ this -> getSuggestsFilters ( $ composer ) , $ this -> getIgnoreFilters ( $ composer ) ) ) ; return new ViolationFilterChain ( $ chain , new PackageRequirementsFilter ( $ composer -> getLocker ( ) , $ chain ) ) ; }
Create a violation filter for the given Composer instance .
48,939
private function getSuggestsFilters ( Composer $ composer ) : array { return array_map ( function ( string $ package ) : ViolationFilterInterface { return new ExactPackageFilter ( $ package ) ; } , array_keys ( $ composer -> getPackage ( ) -> getSuggests ( ) ) ) ; }
Exclude packages suggested by the root package from violating dependencies .
48,940
private function getIgnoreFilters ( Composer $ composer ) : array { $ extra = $ composer -> getPackage ( ) -> getExtra ( ) ; return array_map ( function ( string $ rule ) : ViolationFilterInterface { $ filters = [ new ExactPackageFilter ( $ rule ) , new PatternPackageFilter ( $ rule ) ] ; if ( preg_match ( '#/$#' , $ rule ) ) { $ filters [ ] = new VendorFilter ( $ rule ) ; } return new ViolationFilterChain ( ... $ filters ) ; } , $ extra [ 'dependency-guard' ] [ 'ignore' ] ?? [ ] ) ; }
Get the violation filters for the ignore rules in the given Composer instance .
48,941
protected function configure ( ) : void { $ this -> setName ( 'dependency-guard' ) ; $ this -> setDescription ( 'Check Composer dependencies for a --no-dev install.' ) ; $ this -> addOption ( 'format' , 'f' , InputOption :: VALUE_REQUIRED , 'The output format. ' . implode ( ', ' , array_map ( function ( string $ format ) : string { return sprintf ( '<comment>%s</comment>' , $ format ) ; } , $ this -> exporterFactory -> getOutputFormats ( ) ) ) , ViolationExporterFactoryInterface :: DEFAULT_FORMAT ) ; }
Configure the command .
48,942
private function getDependents ( string $ packageName , bool $ returnContext , array $ context = [ ] ) : array { if ( ! isset ( $ context [ $ packageName ] ) ) { $ context [ $ packageName ] = $ this -> repository -> getDependents ( $ packageName , null , false , false ) ; foreach ( $ context [ $ packageName ] as $ key => $ dependent ) { $ dependentContext = $ this -> getDependents ( $ key , true , $ context ) ; $ context = array_merge ( $ context , $ dependentContext ) ; $ context [ $ packageName ] = array_merge ( $ context [ $ packageName ] , $ dependentContext [ $ key ] ) ; } } if ( ! $ returnContext ) { return $ context [ $ packageName ] ; } return $ context ; }
Retrieves the dependents of a package in a recursive way .
48,943
protected function objectToArray ( $ value , $ valueConverter = null ) { if ( $ valueConverter !== null && is_object ( $ value ) ) { $ value = call_user_func ( $ valueConverter , $ value ) ; } return $ value ; }
Converts an object to an array using the given callback function . If the convert callback is null or the value is not an object the value is returned unchanged . The Converter callback is intended for converting the value into an array but may also just leave the value unchanged if it cannot handle it .
48,944
private function preSetElement ( $ index , DiffOp $ value ) : bool { if ( $ this -> isAssociative === false && ( $ value -> getType ( ) !== 'add' && $ value -> getType ( ) !== 'remove' ) ) { throw new InvalidArgumentException ( 'Diff operation with invalid type "' . $ value -> getType ( ) . '" provided.' ) ; } if ( array_key_exists ( $ value -> getType ( ) , $ this -> typePointers ) ) { $ this -> typePointers [ $ value -> getType ( ) ] [ ] = $ index ; } else { throw new InvalidArgumentException ( 'Diff operation with invalid type "' . $ value -> getType ( ) . '" provided.' ) ; } return true ; }
Gets called before a new element is added to the ArrayObject .
48,945
public function count ( ) : int { $ count = 0 ; foreach ( $ this as $ diffOp ) { $ count += $ diffOp -> count ( ) ; } return $ count ; }
Counts the number of atomic operations in the diff . This means the size of a diff with as elements only empty diffs will be 0 . Or that the size of a diff with one atomic operation and one diff that itself holds two atomic operations will be 3 .
48,946
public function hasAssociativeOperations ( ) : bool { return ! empty ( $ this -> typePointers [ 'change' ] ) || ! empty ( $ this -> typePointers [ 'diff' ] ) || ! empty ( $ this -> typePointers [ 'map' ] ) || ! empty ( $ this -> typePointers [ 'list' ] ) ; }
Returns if the diff can be non - associative . This means it does not contain any non - add - non - remove operations .
48,947
public function toArray ( callable $ valueConverter = null ) : array { $ operations = [ ] ; foreach ( $ this -> getOperations ( ) as $ key => $ diffOp ) { $ operations [ $ key ] = $ diffOp -> toArray ( $ valueConverter ) ; } return [ 'type' => $ this -> getType ( ) , 'isassoc' => $ this -> isAssociative , 'operations' => $ operations ] ; }
Returns the Diff in array form where nested DiffOps are also turned into their array form .
48,948
private function getNewOffset ( ) : int { while ( $ this -> offsetExists ( $ this -> indexOffset ) ) { $ this -> indexOffset ++ ; } return $ this -> indexOffset ; }
Finds a new offset for when appending an element . The base class does this so it would be better to integrate but there does not appear to be any way to do this ...
48,949
private function setElement ( $ index , $ value ) { if ( ! ( $ value instanceof DiffOp ) ) { throw new InvalidArgumentException ( 'Can only add DiffOp implementing objects to ' . get_called_class ( ) . '.' ) ; } if ( $ index === null ) { $ index = $ this -> getNewOffset ( ) ; } if ( $ this -> preSetElement ( $ index , $ value ) ) { parent :: offsetSet ( $ index , $ value ) ; } }
Method that actually sets the element and holds all common code needed for set operations including type checking and offset resolving .
48,950
public function newFromArray ( array $ diffOp ) { $ this -> assertHasKey ( 'type' , $ diffOp ) ; if ( $ diffOp [ 'type' ] === 'add' ) { $ this -> assertHasKey ( 'newvalue' , $ diffOp ) ; return new DiffOpAdd ( $ this -> arrayToObject ( $ diffOp [ 'newvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'remove' ) { $ this -> assertHasKey ( 'oldvalue' , $ diffOp ) ; return new DiffOpRemove ( $ this -> arrayToObject ( $ diffOp [ 'oldvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'change' ) { $ this -> assertHasKey ( 'newvalue' , $ diffOp ) ; $ this -> assertHasKey ( 'oldvalue' , $ diffOp ) ; return new DiffOpChange ( $ this -> arrayToObject ( $ diffOp [ 'oldvalue' ] ) , $ this -> arrayToObject ( $ diffOp [ 'newvalue' ] ) ) ; } if ( $ diffOp [ 'type' ] === 'diff' ) { $ this -> assertHasKey ( 'operations' , $ diffOp ) ; $ this -> assertHasKey ( 'isassoc' , $ diffOp ) ; $ operations = [ ] ; foreach ( $ diffOp [ 'operations' ] as $ key => $ operation ) { $ operations [ $ key ] = $ this -> newFromArray ( $ operation ) ; } return new Diff ( $ operations , $ diffOp [ 'isassoc' ] ) ; } throw new InvalidArgumentException ( 'Invalid array provided. Unknown type' ) ; }
Returns an instance of DiffOp constructed from the provided array .
48,951
private function arrayToObject ( $ value ) { if ( $ this -> valueConverter !== null && is_array ( $ value ) ) { $ value = call_user_func ( $ this -> valueConverter , $ value ) ; } return $ value ; }
Converts an array structure to an object using the value converter callback function provided to the constructor if any .
48,952
private function arrayDiffAssoc ( array $ from , array $ to ) : array { $ diff = [ ] ; foreach ( $ from as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ to ) || ! $ this -> valueComparer -> valuesAreEqual ( $ to [ $ key ] , $ value ) ) { $ diff [ $ key ] = $ value ; } } return $ diff ; }
Similar to the native array_diff_assoc function except that it will spot differences between array values . Very weird the native function just ignores these ...
48,953
private static function _log ( $ msgType , $ args ) { if ( ! Config :: getField ( 'project' , 'debug_mode' , 0 ) ) { return ; } if ( count ( $ args ) == 1 ) { $ msg = is_scalar ( $ args [ 0 ] ) ? $ args [ 0 ] : self :: dump ( $ args [ 0 ] ) ; } else { $ msg = self :: dump ( $ args ) ; } if ( self :: $ DEBUG_TRACE ) { $ trace = self :: getTrace ( ) ; } else { $ trace = array ( ) ; } if ( $ msgType == 'debug' ) { Terminal :: drawStr ( $ msg , 'magenta' ) ; } else if ( $ msgType == 'error' ) { Terminal :: drawStr ( $ msg , 'red' ) ; } else if ( $ msgType == 'info' ) { Terminal :: drawStr ( $ msg , 'brown' ) ; } else { Terminal :: drawStr ( $ msg , 'default' ) ; } ! empty ( $ trace ) && Terminal :: drawStr ( "\t" . implode ( " <-- " , $ trace ) . "\n" ) ; }
Send print to terminal .
48,954
public static function drawTable ( $ rows ) { $ pad = array ( ) ; foreach ( $ rows as $ row ) { foreach ( $ row as $ k => $ v ) { if ( substr ( $ k , 0 , 1 ) == '_' ) { continue ; } if ( ! isset ( $ pad [ $ k ] ) || ( strlen ( $ v ) > $ pad [ $ k ] ) ) { $ pad [ $ k ] = strlen ( $ v ) ; } } } foreach ( $ rows as $ row ) { if ( isset ( $ row [ '_color' ] ) ) { self :: setStyle ( $ row [ '_color' ] ) ; } if ( isset ( $ row [ '_bold' ] ) ) { self :: setStyle ( '1' ) ; } if ( isset ( $ row [ '_' ] ) ) { echo $ row [ '_' ] ; } else { $ i = 0 ; foreach ( $ row as $ k => $ v ) { if ( substr ( $ k , 0 , 1 ) == '_' ) { continue ; } if ( $ i > 0 ) { echo "\t" ; } echo str_pad ( $ v , $ pad [ $ k ] ) ; ++ $ i ; } } self :: resetStyle ( ) ; echo "\n" ; } }
Draw a table
48,955
public function make ( $ service ) { $ service = 'Google_Service_' . ucfirst ( $ service ) ; if ( class_exists ( $ service ) ) { $ class = new \ ReflectionClass ( $ service ) ; return $ class -> newInstance ( $ this -> client ) ; } throw new UnknownServiceException ( $ service ) ; }
Getter for the google service .
48,956
protected function useAssertCredentials ( $ userEmail = '' ) { $ serviceJsonUrl = array_get ( $ this -> config , 'service.file' , '' ) ; if ( empty ( $ serviceJsonUrl ) ) { return false ; } $ this -> client -> setAuthConfig ( $ serviceJsonUrl ) ; if ( ! empty ( $ userEmail ) ) { $ this -> client -> setSubject ( $ userEmail ) ; } return true ; }
Determine and use credentials if user has set them .
48,957
public static function parse ( string $ phoneNumber , string $ regionCode = null ) : PhoneNumber { try { return new PhoneNumber ( PhoneNumberUtil :: getInstance ( ) -> parse ( $ phoneNumber , $ regionCode ) ) ; } catch ( NumberParseException $ e ) { throw PhoneNumberParseException :: wrap ( $ e ) ; } }
Parses a string representation of a phone number .
48,958
public function getRegionCode ( ) : ? string { $ regionCode = PhoneNumberUtil :: getInstance ( ) -> getRegionCodeForNumber ( $ this -> phoneNumber ) ; if ( $ regionCode === '001' ) { return null ; } return $ regionCode ; }
Returns the region code of this PhoneNumber .
48,959
public function format ( int $ format ) : string { return PhoneNumberUtil :: getInstance ( ) -> format ( $ this -> phoneNumber , $ format ) ; }
Returns a formatted string representation of this phone number .
48,960
public function formatForCallingFrom ( string $ regionCode ) : string { return PhoneNumberUtil :: getInstance ( ) -> formatOutOfCountryCallingNumber ( $ this -> phoneNumber , $ regionCode ) ; }
Formats this phone number for out - of - country dialing purposes .
48,961
public function bootstrap ( $ appBootstrap , $ appenv , $ debug ) { $ appBootstrap = $ this -> normalizeAppBootstrap ( $ appBootstrap ) ; $ this -> bootstrap = new $ appBootstrap ( ) ; if ( $ this -> bootstrap instanceof ApplicationEnvironmentAwareInterface ) { $ this -> bootstrap -> initialize ( $ appenv , $ debug ) ; } if ( $ this -> bootstrap instanceof BootstrapInterface ) { $ this -> application = $ this -> bootstrap -> getApplication ( ) ; } }
Bootstrap an application implementing the HttpKernelInterface .
48,962
protected function mapRequest ( ServerRequestInterface $ psrRequest ) { $ method = $ psrRequest -> getMethod ( ) ; $ query = $ psrRequest -> getQueryParams ( ) ; $ _COOKIE = [ ] ; foreach ( $ psrRequest -> getHeader ( 'Cookie' ) as $ cookieHeader ) { $ cookies = explode ( ';' , $ cookieHeader ) ; foreach ( $ cookies as $ cookie ) { if ( strpos ( $ cookie , '=' ) == false ) { continue ; } list ( $ name , $ value ) = explode ( '=' , trim ( $ cookie ) ) ; $ _COOKIE [ $ name ] = $ value ; if ( $ name === session_name ( ) ) { session_id ( $ value ) ; } } } $ uploadedFiles = $ psrRequest -> getUploadedFiles ( ) ; $ this -> mapFiles ( $ uploadedFiles ) ; $ post = $ psrRequest -> getParsedBody ( ) ? : [ ] ; if ( $ this -> bootstrap instanceof RequestClassProviderInterface ) { $ class = $ this -> bootstrap -> requestClass ( ) ; } else { $ class = SymfonyRequest :: class ; } $ syRequest = new $ class ( $ query , $ post , $ attributes = [ ] , $ _COOKIE , $ uploadedFiles , $ _SERVER , ( string ) $ psrRequest -> getBody ( ) ) ; $ syRequest -> setMethod ( $ method ) ; if ( $ syRequest instanceof \ Illuminate \ Http \ Request && $ syRequest -> isJson ( ) ) { $ syRequest -> request = $ syRequest -> json ( ) ; } return $ syRequest ; }
Convert React \ Http \ Request to Symfony \ Component \ HttpFoundation \ Request
48,963
protected function reset ( ) { $ this -> user = null ; $ this -> lastAttempted = null ; $ this -> viaRemember = false ; $ this -> loggedOut = false ; $ this -> tokenRetrievalAttempted = false ; $ this -> recallAttempted = false ; }
Reset the state of current class instance .
48,964
public function getApplication ( ) { if ( file_exists ( './vendor/autoload.php' ) ) { $ autoloader = require './vendor/autoload.php' ; } else { $ autoloader = require '../vendor/autoload.php' ; } $ sitePath = 'sites/default' ; Settings :: initialize ( './' , $ sitePath , $ autoloader ) ; $ app = new DrupalKernel ( $ this -> appenv , $ autoloader ) ; $ app -> setSitePath ( $ sitePath ) ; return $ app ; }
Create a Drupal application .
48,965
public function getApplication ( ) { if ( file_exists ( 'bootstrap/autoload.php' ) ) { require_once 'bootstrap/autoload.php' ; } elseif ( file_exists ( 'vendor/autoload.php' ) ) { require_once 'vendor/autoload.php' ; } $ isLaravel = true ; if ( file_exists ( 'bootstrap/app.php' ) ) { $ this -> app = require_once 'bootstrap/app.php' ; if ( substr ( $ this -> app -> version ( ) , 0 , 5 ) === 'Lumen' ) { $ isLaravel = false ; } } if ( file_exists ( 'bootstrap/start.php' ) ) { $ this -> app = require_once 'bootstrap/start.php' ; $ this -> app -> boot ( ) ; return $ this -> app ; } if ( ! $ this -> app ) { throw new \ RuntimeException ( 'Laravel bootstrap file not found' ) ; } $ kernel = $ this -> app -> make ( $ isLaravel ? 'Illuminate\Contracts\Http\Kernel' : 'Laravel\Lumen\Application' ) ; $ this -> app -> afterResolving ( 'auth' , function ( $ auth ) { $ auth -> extend ( 'session' , function ( $ app , $ name , $ config ) { $ provider = $ app [ 'auth' ] -> createUserProvider ( $ config [ 'provider' ] ) ; $ guard = new \ PHPPM \ Laravel \ SessionGuard ( $ name , $ provider , $ app [ 'session.store' ] , null , $ app ) ; if ( method_exists ( $ guard , 'setCookieJar' ) ) { $ guard -> setCookieJar ( $ this -> app [ 'cookie' ] ) ; } if ( method_exists ( $ guard , 'setDispatcher' ) ) { $ guard -> setDispatcher ( $ this -> app [ 'events' ] ) ; } if ( method_exists ( $ guard , 'setRequest' ) ) { $ guard -> setRequest ( $ this -> app -> refresh ( 'request' , $ guard , 'setRequest' ) ) ; } return $ guard ; } ) ; } ) ; $ app = $ this -> app ; $ this -> app -> extend ( 'session.store' , function ( ) use ( $ app ) { $ manager = $ app [ 'session' ] ; return $ manager -> driver ( ) ; } ) ; return $ kernel ; }
Create a Laravel application
48,966
public function getApplication ( ) { $ appAutoLoader = './app/autoload.php' ; if ( file_exists ( $ appAutoLoader ) ) { require $ appAutoLoader ; } else { require $ this -> getVendorDir ( ) . '/autoload.php' ; } if ( ! getenv ( 'APP_ENV' ) && class_exists ( 'Symfony\Component\Dotenv\Dotenv' ) && file_exists ( realpath ( '.env' ) ) ) { ( new \ Symfony \ Component \ Dotenv \ Dotenv ( ) ) -> load ( realpath ( '.env' ) ) ; } $ namespace = getenv ( 'APP_KERNEL_NAMESPACE' ) ? : '\App\\' ; $ fqcn = $ namespace . ( getenv ( 'APP_KERNEL_CLASS_NAME' ) ? : 'Kernel' ) ; $ class = class_exists ( $ fqcn ) ? $ fqcn : '\AppKernel' ; if ( ! class_exists ( $ class ) ) { throw new \ Exception ( "Symfony Kernel class was not found in the configured locations. Given: '$class'" ) ; } $ app = new $ class ( $ this -> appenv , $ this -> debug ) ; Utils :: bindAndCall ( function ( ) use ( $ app ) { $ app -> initializeBundles ( ) ; $ app -> initializeContainer ( ) ; } , $ app ) ; Utils :: bindAndCall ( function ( ) use ( $ app ) { foreach ( $ app -> getBundles ( ) as $ bundle ) { $ bundle -> setContainer ( $ app -> container ) ; $ bundle -> boot ( ) ; } $ app -> booted = true ; } , $ app ) ; if ( $ this -> debug ) { Utils :: bindAndCall ( function ( ) use ( $ app ) { $ container = $ app -> container ; $ containerClassName = substr ( strrchr ( get_class ( $ app -> container ) , "\\" ) , 1 ) ; $ metaName = $ containerClassName . '.php.meta' ; Utils :: bindAndCall ( function ( ) use ( $ container ) { $ container -> publicContainerDir = $ container -> containerDir ; } , $ container ) ; if ( $ container -> publicContainerDir === null ) { return ; } $ metaContent = @ file_get_contents ( $ app -> container -> publicContainerDir . '/../' . $ metaName ) ; if ( $ metaContent === false ) { return ; } $ containerMetadata = unserialize ( $ metaContent ) ; foreach ( $ containerMetadata as $ entry ) { if ( $ entry instanceof FileResource ) { register_file ( $ entry -> __toString ( ) ) ; } } } , $ app ) ; } if ( $ trustedProxies = getenv ( 'TRUSTED_PROXIES' ) ) { Request :: setTrustedProxies ( explode ( ',' , $ trustedProxies ) , Request :: HEADER_X_FORWARDED_ALL ^ Request :: HEADER_X_FORWARDED_HOST ) ; } if ( $ trustedHosts = getenv ( 'TRUSTED_HOSTS' ) ) { Request :: setTrustedHosts ( explode ( ',' , $ trustedHosts ) ) ; } return $ app ; }
Create a Symfony application
48,967
protected function json ( $ data = [ ] , $ bodyFormat = null , $ statusCode = null , $ message = null ) { $ bodyFormat = ( $ bodyFormat !== null ) ? $ bodyFormat : $ this -> bodyFormat ; if ( $ bodyFormat ) { $ data = $ this -> _format ( $ statusCode , $ message , $ data ) ; } else { $ data = is_array ( $ data ) ? $ data : [ $ data ] ; } return $ this -> response -> json ( $ data , $ statusCode ) ; }
Output by JSON format with optinal body format
48,968
protected function _format ( $ statusCode = null , $ message = null , $ body = false ) { $ format = [ ] ; $ format [ 'code' ] = ( $ statusCode ) ? : $ this -> response -> getStatusCode ( ) ; if ( $ message ) { $ format [ 'message' ] = $ message ; } if ( $ body !== false ) { $ format [ 'data' ] = $ body ; } return $ format ; }
Format Response Data
48,969
protected function pack ( $ data , $ statusCode = 200 , $ message = null ) { $ packBody = [ ] ; if ( $ statusCode ) { $ packBody [ 'code' ] = $ statusCode ; } if ( $ message ) { $ packBody [ 'message' ] = $ message ; } if ( is_array ( $ data ) || is_string ( $ data ) ) { $ packBody [ 'data' ] = $ data ; } return $ packBody ; }
Pack array data into body format
48,970
protected function _setBehavior ( $ action , Callable $ function ) { if ( array_key_exists ( $ action , $ this -> behaviors ) ) { $ this -> behaviors [ $ action ] = $ function ; return true ; } return false ; }
Set behavior to a action before route
48,971
private function _action ( $ params ) { $ method = array_shift ( $ params ) ; if ( $ this -> behaviors [ $ method ] ) { $ this -> behaviors [ $ method ] ( ) ; } if ( ! isset ( $ this -> routes [ $ method ] ) ) { $ this -> _defaultAction ( ) ; } $ method = $ this -> routes [ $ method ] ; if ( ! method_exists ( $ this , $ method ) ) { $ this -> _defaultAction ( ) ; } return call_user_func_array ( [ $ this , $ method ] , $ params ) ; }
Action processor for route
48,972
public function setFormat ( $ format ) { $ this -> _format = $ format ; if ( isset ( $ this -> contentTypes [ $ this -> _format ] ) ) { $ this -> ci -> output -> set_content_type ( $ this -> contentTypes [ $ this -> _format ] ) ; } return $ this ; }
Set Response Format into CI_Output
48,973
public function setData ( $ data ) { $ data = $ this -> format ( $ data , $ this -> _format ) ; $ this -> ci -> output -> set_output ( $ data ) ; return $ this ; }
Set Response Data into CI_Output
48,974
public function json ( $ data , $ statusCode = null ) { if ( $ statusCode ) { $ this -> setStatusCode ( $ statusCode ) ; } $ this -> setFormat ( Response :: FORMAT_JSON ) ; if ( ! is_null ( $ data ) ) { $ this -> setData ( $ data ) ; } return $ this -> send ( ) ; }
JSON output shortcut
48,975
public function getAuthCredentialsWithBasic ( ) { if ( isset ( $ _SERVER [ 'PHP_AUTH_USER' ] ) && isset ( $ _SERVER [ 'PHP_AUTH_PW' ] ) ) { return [ $ _SERVER [ 'PHP_AUTH_USER' ] , $ _SERVER [ 'PHP_AUTH_PW' ] ] ; } $ authToken = isset ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) ? $ _SERVER [ 'HTTP_AUTHORIZATION' ] : null ; $ authToken = ( ! $ authToken && isset ( $ _SERVER [ 'REDIRECT_HTTP_AUTHORIZATION' ] ) ) ? $ _SERVER [ 'REDIRECT_HTTP_AUTHORIZATION' ] : $ authToken ; if ( $ authToken !== null && strpos ( strtolower ( $ _SERVER [ 'HTTP_AUTHORIZATION' ] ) , 'basic ' ) === 0 ) { $ parts = array_map ( function ( $ value ) { return strlen ( $ value ) === 0 ? null : $ value ; } , explode ( ':' , base64_decode ( mb_substr ( $ authToken , 6 ) ) , 2 ) ) ; if ( count ( $ parts ) < 2 ) { return [ $ parts [ 0 ] , null ] ; } return $ parts ; } return [ null , null ] ; }
Get Credentials with HTTP Basic Authentication
48,976
public function make ( $ content = '' , $ status = 200 , array $ headers = [ ] ) { respondWith ( response ( ) -> make ( $ content , $ status , $ headers ) ) ; }
Return a new response from the application .
48,977
public function jsonp ( $ callback , $ data = [ ] , $ status = 200 , array $ headers = [ ] , $ options = 0 ) { respondWith ( response ( ) -> jsonp ( $ callback , $ data , $ status , $ headers , $ options ) ) ; }
Return a new JSONP response from the application .
48,978
public function stream ( $ callback , $ status = 200 , array $ headers = [ ] ) { respondWith ( response ( ) -> stream ( $ callback , $ status , $ headers ) ) ; }
Return a new streamed response from the application .
48,979
public function streamDownload ( $ callback , $ name = null , array $ headers = [ ] , $ disposition = 'attachment' ) { respondWith ( response ( ) -> streamDownload ( $ callback , $ name , $ headers , $ disposition ) ) ; }
Return a new streamed response as a file download from the application .
48,980
public static function sgr ( $ string , array $ parameters ) { $ result = '' ; foreach ( $ parameters as $ parameter ) { $ result .= sprintf ( "\e[%sm" , $ parameter ) ; } $ result .= $ string . sprintf ( "\e[%sm" , Sgr :: RESET ) ; return $ result ; }
Select Graphic Rendition
48,981
public static function getSupported ( ) { return [ self :: GET , self :: HEAD , self :: POST , self :: PUT , self :: DELETE , self :: CONNECT , self :: OPTIONS , self :: TRACE ] ; }
Retrieve list of supported HTTP methods .
48,982
final public function start ( ) { try { ErrorHandler :: set ( ) ; register_shutdown_function ( [ $ this , 'shutdown' ] ) ; $ this -> setEnvironmentValue ( ) ; $ this -> date ( ) -> setTimezone ( ) ; return true ; } catch ( \ Throwable $ e ) { $ this -> shutdown ( $ e , true ) ; } catch ( \ Exception $ e ) { $ this -> shutdown ( $ e , true ) ; } }
Starts the execution of the application .
48,983
final public function shutdown ( $ exception = null , $ manual = false , $ statusCode = 0 ) { $ hasError = $ this -> handleErrors ( $ exception ) ; if ( $ hasError ) { $ statusCode = 1 ; } if ( ! $ manual ) { ErrorHandler :: restore ( ) ; } exit ( $ statusCode ) ; }
Finishes the execution of the Application .
48,984
final public function setEnvironmentValue ( ) { $ this -> config ( ) -> setEnv ( trim ( ( string ) file_get_contents ( $ this -> projectPath . '.env' ) ) ) ; return true ; }
Sets the env value from the project . env file .
48,985
final protected function handleErrors ( $ exception = null ) { $ errorInfo = [ 'code' => 0 , 'message' => null , 'file' => null , 'line' => null , 'trace' => null , 'exception' => null , ] ; if ( $ exception instanceof \ Throwable || $ exception instanceof \ Exception ) { $ errorInfo [ 'code' ] = $ exception -> getCode ( ) ; $ errorInfo [ 'message' ] = $ exception -> getMessage ( ) ; $ errorInfo [ 'file' ] = $ exception -> getFile ( ) ; $ errorInfo [ 'line' ] = $ exception -> getLine ( ) ; $ errorInfo [ 'trace' ] = $ exception -> getTrace ( ) ; $ errorInfo [ 'exception' ] = $ exception ; } else { $ last_error = error_get_last ( ) ; if ( ! empty ( $ last_error [ 'message' ] ) ) { $ errorInfo [ 'message' ] = $ last_error [ 'message' ] ; } if ( ! empty ( $ last_error [ 'file' ] ) ) { $ errorInfo [ 'file' ] = $ last_error [ 'file' ] ; } if ( ! empty ( $ last_error [ 'line' ] ) ) { $ errorInfo [ 'line' ] = $ last_error [ 'line' ] ; } } if ( ! empty ( $ errorInfo [ 'message' ] ) ) { return $ this -> halt ( $ errorInfo ) ; } return false ; }
Handle Errors .
48,986
private static function parseSetting ( $ setting ) { if ( is_string ( $ setting ) && false !== strpos ( $ setting , \ WebServCo \ Framework \ Settings :: DIVIDER ) ) { return explode ( \ WebServCo \ Framework \ Settings :: DIVIDER , $ setting ) ; } return $ setting ; }
Parse the setting key to make sure it s a simple string or an array .
48,987
public static function get ( $ storage , $ setting = null , $ defaultValue = false ) { $ setting = self :: parseSetting ( $ setting ) ; if ( empty ( $ setting ) || empty ( $ storage ) ) { return $ defaultValue ; } if ( ! is_array ( $ storage ) ) { return $ defaultValue ; } if ( is_array ( $ setting ) ) { if ( array_key_exists ( 0 , $ setting ) && array_key_exists ( $ setting [ 0 ] , $ storage ) ) { $ key = array_shift ( $ setting ) ; if ( empty ( $ setting ) ) { return false !== $ storage [ $ key ] ? $ storage [ $ key ] : $ defaultValue ; } return self :: get ( $ storage [ $ key ] , $ setting , $ defaultValue ) ; } return $ defaultValue ; } if ( array_key_exists ( $ setting , $ storage ) ) { return $ storage [ $ setting ] ; } return $ defaultValue ; }
Retrieve a value from a storage array .
48,988
public static function set ( $ storage , $ setting , $ value ) { if ( ! is_array ( $ storage ) || empty ( $ setting ) ) { throw new ArrayStorageException ( 'Invalid parameters specified' ) ; } $ setting = self :: parseSetting ( $ setting ) ; if ( is_array ( $ setting ) ) { $ reference = & $ storage ; foreach ( $ setting as $ item ) { if ( ! is_array ( $ reference ) ) { $ reference = [ ] ; } $ reference = & $ reference [ $ item ] ; } $ reference = $ value ; unset ( $ reference ) ; return $ storage ; } $ storage [ $ setting ] = $ value ; return $ storage ; }
Sets a value in a storage array .
48,989
public static function append ( $ storage , $ data = [ ] ) { if ( ! is_array ( $ storage ) || ! is_array ( $ data ) ) { throw new ArrayStorageException ( 'Invalid parameters specified' ) ; } foreach ( $ data as $ setting => $ value ) { if ( array_key_exists ( $ setting , $ storage ) && is_array ( $ storage [ $ setting ] ) && is_array ( $ value ) ) { $ storage [ $ setting ] = self :: append ( $ storage [ $ setting ] , $ value ) ; } else { $ storage [ $ setting ] = $ value ; } } return $ storage ; }
Append data to a storage array .
48,990
public static function remove ( $ storage , $ setting ) { if ( ! is_array ( $ storage ) || empty ( $ setting ) ) { throw new ArrayStorageException ( 'Invalid parameters specified' ) ; } $ setting = self :: parseSetting ( $ setting ) ; if ( empty ( $ setting ) ) { throw new ArrayStorageException ( 'Empty setting' ) ; } if ( is_array ( $ setting ) ) { return self :: removeByIndex ( $ storage , $ setting ) ; } if ( ! array_key_exists ( $ setting , $ storage ) ) { throw new ArrayStorageException ( sprintf ( 'setting "%s" does not exist in storage object' , $ setting ) ) ; } unset ( $ storage [ $ setting ] ) ; return $ storage ; }
Removes a setting from a storage array .
48,991
protected static function removeByIndex ( $ array , $ indices ) { $ a = & $ array ; $ c = count ( $ indices ) - 1 ; for ( $ i = 0 ; $ i <= $ c ; ++ $ i ) { if ( ! array_key_exists ( $ indices [ $ i ] , $ a ) ) { throw new ArrayStorageException ( sprintf ( '"%s" does not exist in storage object' , $ indices [ $ i ] ) ) ; } if ( $ i === $ c ) { unset ( $ a [ $ indices [ $ i ] ] ) ; } elseif ( is_array ( $ a [ $ indices [ $ i ] ] ) ) { $ a = & $ a [ $ indices [ $ i ] ] ; } else { throw new ArrayStorageException ( sprintf ( '"%s" does not exist in storage object' , $ indices [ $ i ] ) ) ; } } return $ array ; }
Remove index from multi - dimensional array .
48,992
public static function throwErrorException ( $ errno , $ errstr , $ errfile , $ errline ) { if ( error_reporting ( ) & $ errno ) { throw new \ ErrorException ( sprintf ( '%s: %s' , self :: getErrorTypeString ( $ errno ) , $ errstr ) , 0 , $ errno , $ errfile , $ errline ) ; } }
Throws ErrorException .
48,993
public function add ( $ setting , $ data ) { $ this -> config = \ WebServCo \ Framework \ ArrayStorage :: append ( $ this -> config , [ $ setting => $ data ] ) ; return true ; }
Add base setting data .
48,994
public function load ( $ setting , $ pathProject ) { $ pathFull = "{$pathProject}config/" . $ this -> getEnv ( ) . "/{$setting}.php" ; if ( ! is_readable ( $ pathFull ) ) { return false ; } $ data = ( include $ pathFull ) ; return is_array ( $ data ) ? $ data : false ; }
Load configuration data from a file .
48,995
public function setEnv ( $ env = null ) { if ( in_array ( $ env , \ WebServCo \ Framework \ Environment :: getOptions ( ) ) ) { $ this -> env = $ env ; } else { $ this -> env = \ WebServCo \ Framework \ Environment :: ENV_DEV ; } return true ; }
Set application environment value .
48,996
final protected function getReloadResponse ( $ removeParameters = [ ] ) { $ url = $ this -> request ( ) -> getUrl ( $ removeParameters ) ; return $ this -> getRedirectUrlResponse ( $ url ) ; }
Redirect to the current URL . This method returns a Response object that needs to be in turn returned to the application .
48,997
private function createImages ( $ output ) { $ image = array ( ) ; foreach ( $ output as $ key => $ singleLine ) { if ( preg_match ( '/\(format/' , $ singleLine ) ) { $ imageInfo = $ singleLine ; $ startPos = strpos ( $ imageInfo , "(" ) + 1 ; $ endPos = strpos ( $ imageInfo , ")" ) ; $ dataStr = substr ( $ imageInfo , $ startPos , $ endPos - $ startPos ) ; $ dataExplode = explode ( "," , $ dataStr ) ; $ contentFormat = explode ( ":" , $ dataExplode [ 0 ] ) ; $ format = $ contentFormat [ 1 ] ; $ contentFormat = explode ( ":" , $ dataExplode [ 1 ] ) ; $ type = $ contentFormat [ 1 ] ; $ imageValue = $ output [ $ key + 2 ] ; $ exploded = explode ( " " , $ singleLine ) ; $ imagePath = array_shift ( $ exploded ) ; $ image [ ] = new ZxingImage ( $ imagePath , $ imageValue , $ format , $ type ) ; } else if ( preg_match ( '/No barcode found/' , $ singleLine ) ) { $ exploded = explode ( " " , $ singleLine ) ; $ imagePath = array_shift ( $ exploded ) ; $ image [ ] = new ZxingBarNotFound ( $ imagePath , 101 , "No barcode found" ) ; } } return $ image ; }
Function creates images array that gives the decoded data in array
48,998
public function decode ( $ image = null ) { try { if ( is_array ( $ image ) ) { $ this -> setArrayImages ( $ image ) ; if ( $ this -> _ARRAY_IMAGES == null ) { throw new \ Exception ( "Nothing to decode" ) ; } } else { if ( ! file_exists ( $ image ) ) { throw new \ Exception ( "File/Folder does not exist" ) ; } $ this -> setSingleImage ( $ image ) ; if ( $ this -> _SINGLE_IMAGE == null ) { throw new \ Exception ( "Nothing to decode" ) ; } } $ image = $ this -> prepare ( ) ; if ( empty ( $ image ) ) { throw new \ Exception ( "Is the java PATH set correctly ? Current Path set is : " . $ this -> getJavaPath ( ) ) ; } if ( count ( $ image ) == 1 ) { return current ( $ image ) ; } return $ image ; } catch ( \ Exception $ e ) { echo $ e -> getMessage ( ) ; } }
Send an image and returns an Object of ZxingImage
48,999
public function loadOptions ( $ options ) { if ( isset ( $ options [ 'css-files' ] ) && count ( $ options [ 'css-files' ] ) > 0 ) { $ this -> css = '' ; foreach ( $ options [ 'css-files' ] as $ file ) { $ this -> css .= file_get_contents ( $ file ) ; } } }
Load the options