idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
13,200
private function parseHostAndPath ( array $ locationParts ) : void { $ path = $ locationParts [ 'path' ] ?? '' ; $ host = $ locationParts [ 'host' ] ?? '' ; if ( $ this -> getScheme ( ) === 'file' ) { $ this -> path = $ host . $ path ; } else { $ this -> host = $ host ; $ this -> path = $ path ; } }
Validates and sets the host and path properties
13,201
private function parsePort ( array $ locationParts ) : void { if ( ! isset ( $ locationParts [ 'port' ] ) ) { if ( $ this -> getScheme ( ) === 'git+http' ) { $ this -> port = 80 ; } elseif ( $ this -> getScheme ( ) === 'git+https' ) { $ this -> port = 443 ; } else { $ this -> port = 0 ; } } else { $ this -> port = ( int ) $ locationParts [ 'port' ] ; } }
Validates and sets the port property
13,202
private function parseQuery ( array $ locationParts ) : void { if ( isset ( $ locationParts [ 'query' ] ) ) { $ queryParts = explode ( '&' , $ locationParts [ 'query' ] ) ; foreach ( $ queryParts as $ part ) { $ option = $ this -> splitKeyValuePair ( $ part ) ; $ this -> query [ $ option [ 0 ] ] = $ option [ 1 ] ; } } }
validates and sets the query property
13,203
private function parseParameters ( array $ dsnParts ) : void { foreach ( $ dsnParts as $ part ) { $ option = $ this -> splitKeyValuePair ( $ part ) ; $ this -> parameters [ $ option [ 0 ] ] = $ option [ 1 ] ; } }
validates and sets the parameters property
13,204
private function splitKeyValuePair ( string $ pair ) : array { $ option = explode ( '=' , $ pair ) ; if ( count ( $ option ) !== 2 ) { throw new InvalidArgumentException ( sprintf ( '"%s" is not a valid query or parameter.' , $ pair ) ) ; } return $ option ; }
Splits a key - value pair
13,205
public function find ( $ object , $ query ) { if ( $ query ) { $ node = $ this -> walkObjectTree ( $ object , $ query ) ; if ( ! is_array ( $ node ) && ( ! $ node instanceof \ Traversable ) ) { $ node = [ $ node ] ; } return $ node ; } return [ $ object ] ; }
Combines the query and an object to retrieve a list of nodes that are to be used as node - point in a template .
13,206
public function setTarget ( string $ target ) : void { $ path = realpath ( $ target ) ; if ( false === $ path ) { if ( @ mkdir ( $ target , 0755 , true ) ) { $ path = realpath ( $ target ) ; } else { throw new InvalidArgumentException ( 'Target directory (' . $ target . ') does not exist and could not be created' ) ; } } if ( ! is_dir ( $ path ) || ! is_writable ( $ path ) ) { throw new InvalidArgumentException ( 'Given target (' . $ target . ') is not a writable directory' ) ; } $ this -> target = $ path ; }
Sets the target location where to output the artifacts .
13,207
public function setOption ( string $ name , string $ value ) : void { $ this -> options [ $ name ] = $ value ; }
Sets an option with the given name .
13,208
protected function getDestinationFilename ( Metadata \ TableOfContents \ File $ file ) : string { return $ this -> definition -> getOutputFormat ( ) -> convertFilename ( $ file -> getRealPath ( ) ) ; }
Returns the filename used for the output path .
13,209
public function getInheritedElement ( ) { $ associatedClass = $ this -> getParent ( ) ; if ( ( $ associatedClass instanceof ClassDescriptor || $ associatedClass instanceof InterfaceDescriptor ) && ( $ associatedClass -> getParent ( ) instanceof ClassDescriptor || $ associatedClass -> getParent ( ) instanceof InterfaceDescriptor ) ) { $ parentClass = $ associatedClass -> getParent ( ) ; return $ parentClass -> getProperties ( ) -> get ( $ this -> getName ( ) ) ; } return null ; }
Returns the property from which this one should inherit if any .
13,210
public function fromDefaultLocations ( ) : Configuration { foreach ( $ this -> defaultFiles as $ file ) { try { return $ this -> fromUri ( new Uri ( $ file ) ) ; } catch ( \ InvalidArgumentException $ e ) { continue ; } } return new Configuration ( $ this -> applyMiddleware ( Version3 :: buildDefault ( ) ) ) ; }
Attempts to load a configuration from the default locations for phpDocumentor
13,211
public function fromUri ( Uri $ uri ) : Configuration { $ filename = ( string ) $ uri ; if ( ! file_exists ( $ filename ) ) { throw new \ InvalidArgumentException ( sprintf ( 'File %s could not be found' , $ filename ) ) ; } $ xml = new \ SimpleXMLElement ( $ filename , 0 , true ) ; foreach ( $ this -> strategies as $ strategy ) { if ( $ strategy -> supports ( $ xml ) !== true ) { continue ; } return new Configuration ( $ this -> applyMiddleware ( $ strategy -> convert ( $ xml ) ) ) ; } throw new RuntimeException ( 'No supported configuration files were found' ) ; }
Converts the phpDocumentor configuration xml to an array .
13,212
private function applyMiddleware ( array $ configuration ) : array { foreach ( $ this -> middlewares as $ middleware ) { $ configuration = $ middleware ( $ configuration ) ; } return $ configuration ; }
Applies all middleware callbacks onto the configuration .
13,213
protected function addClasses ( array $ classes , FileDescriptor $ fileDescriptor ) : void { foreach ( $ classes as $ class ) { $ classDescriptor = $ this -> getBuilder ( ) -> buildDescriptor ( $ class ) ; if ( $ classDescriptor ) { $ classDescriptor -> setLocation ( $ fileDescriptor , $ class -> getLocation ( ) -> getLineNumber ( ) ) ; if ( count ( $ classDescriptor -> getTags ( ) -> get ( 'package' , new Collection ( ) ) ) === 0 ) { $ classDescriptor -> getTags ( ) -> set ( 'package' , $ fileDescriptor -> getTags ( ) -> get ( 'package' , new Collection ( ) ) ) ; } $ fileDescriptor -> getClasses ( ) -> set ( ( string ) ( $ classDescriptor -> getFullyQualifiedStructuralElementName ( ) ) , $ classDescriptor ) ; } } }
Registers the child classes with the generated File Descriptor .
13,214
public function isVisibilityAllowed ( $ visibility ) { $ visibilityAllowed = $ this -> getSettings ( ) ? $ this -> getSettings ( ) -> getVisibility ( ) : Settings :: VISIBILITY_DEFAULT ; return ( bool ) ( $ visibilityAllowed & $ visibility ) ; }
Checks whether the Project supports the given visibility .
13,215
public function get ( $ input_format , $ output_format ) { return new Definition ( $ this -> format_collection [ $ input_format ] , $ this -> format_collection [ $ output_format ] ) ; }
Creates a definition of the given input and output formats .
13,216
public function setParent ( $ parent ) { if ( ! $ parent instanceof ClassDescriptor && ! $ parent instanceof InterfaceDescriptor && $ parent !== null ) { throw new \ InvalidArgumentException ( 'Constants can only have an interface or class as parent' ) ; } $ fqsen = $ parent !== null ? $ parent -> getFullyQualifiedStructuralElementName ( ) . '::' . $ this -> getName ( ) : $ this -> getName ( ) ; $ this -> setFullyQualifiedStructuralElementName ( $ fqsen ) ; $ this -> parent = $ parent ; }
Registers a parent class or interface with this constant .
13,217
public function register ( callable $ matcher , AssemblerInterface $ assembler ) : void { $ this -> assemblers [ ] = new AssemblerMatcher ( $ matcher , $ assembler ) ; }
Registers an assembler instance to this factory .
13,218
public function registerFallback ( callable $ matcher , AssemblerInterface $ assembler ) : void { $ this -> fallbackAssemblers [ ] = new AssemblerMatcher ( $ matcher , $ assembler ) ; }
Registers an assembler instance to this factory that is to be executed after all other assemblers have been checked .
13,219
protected function addVariadicArgument ( Method $ data , MethodDescriptor $ methodDescriptor ) : void { if ( ! $ data -> getDocBlock ( ) ) { return ; } $ paramTags = $ data -> getDocBlock ( ) -> getTagsByName ( 'param' ) ; $ lastParamTag = end ( $ paramTags ) ; if ( ! $ lastParamTag ) { return ; } if ( $ lastParamTag -> isVariadic ( ) && array_key_exists ( $ lastParamTag -> getVariableName ( ) , $ methodDescriptor -> getArguments ( ) -> getAll ( ) ) ) { $ types = $ lastParamTag -> getType ( ) ; $ argument = new ArgumentDescriptor ( ) ; $ argument -> setName ( $ lastParamTag -> getVariableName ( ) ) ; $ argument -> setType ( $ types ) ; $ argument -> setDescription ( $ lastParamTag -> getDescription ( ) ) ; $ argument -> setLine ( $ methodDescriptor -> getLine ( ) ) ; $ argument -> setVariadic ( true ) ; $ methodDescriptor -> getArguments ( ) -> set ( $ argument -> getName ( ) , $ argument ) ; } }
Checks if there is a variadic argument in the
13,220
public function offsetSet ( $ index , $ newval ) { if ( ! $ newval instanceof WriterAbstract ) { throw new \ InvalidArgumentException ( 'The Writer Collection may only contain objects descending from WriterAbstract' ) ; } if ( ! preg_match ( '/^[a-zA-Z0-9\-\_\/]{3,}$/' , $ index ) ) { throw new \ InvalidArgumentException ( 'The name of a Writer may only contain alphanumeric characters, one or more hyphens, underscores and ' . 'forward slashes and must be at least three characters wide' ) ; } if ( $ newval instanceof Routable ) { $ newval -> setRouters ( $ this -> routers ) ; } parent :: offsetSet ( $ index , $ newval ) ; }
Registers a writer with a given name .
13,221
public function offsetGet ( $ index ) { if ( ! $ this -> offsetExists ( $ index ) ) { throw new \ InvalidArgumentException ( 'Writer "' . $ index . '" does not exist' ) ; } return parent :: offsetGet ( $ index ) ; }
Retrieves a writer from the collection .
13,222
public function logStats ( $ fatal , Logger $ logger ) { if ( ! $ this -> getErrors ( ) && ! $ fatal ) { return ; } foreach ( $ this -> getErrors ( ) as $ error ) { $ logger -> warning ( ' ' . $ error -> getMessage ( ) ) ; } if ( $ fatal ) { $ logger -> error ( ' ' . $ fatal -> getMessage ( ) ) ; } }
Sends the errors of the given Rst document to the logger as a block .
13,223
protected function appendPhpdocStatsElement ( \ DOMDocument $ document ) { $ stats = $ document -> createElement ( 'phpdoc-stats' ) ; $ stats -> setAttribute ( 'version' , Application :: VERSION ( ) ) ; $ document -> appendChild ( $ stats ) ; return $ document ; }
Append phpdoc - stats element to the document .
13,224
protected function appendStatElement ( \ DOMDocument $ document , ProjectDescriptor $ project , $ date ) { $ stat = $ document -> createDocumentFragment ( ) ; $ stat -> appendXML ( <<<STAT<stat date="${date}"> <counters> <files>{$this->getFilesCounter($project)}</files> <deprecated>{$this->getDeprecatedCounter($project)}</deprecated> <errors>{$this->getErrorCounter($project)}</errors> <markers>{$this->getMarkerCounter($project)}</markers> </counters></stat>STAT ) ; $ document -> documentElement -> appendChild ( $ stat ) ; return $ document ; }
Appends a stat fragment .
13,225
protected function getErrorCounter ( ProjectDescriptor $ project ) { $ errorCounter = 0 ; foreach ( $ project -> getFiles ( ) -> getAll ( ) as $ fileDescriptor ) { $ errorCounter += count ( $ fileDescriptor -> getAllErrors ( ) -> getAll ( ) ) ; } return $ errorCounter ; }
Get number of errors .
13,226
protected function getMarkerCounter ( ProjectDescriptor $ project ) { $ markerCounter = 0 ; foreach ( $ project -> getFiles ( ) -> getAll ( ) as $ fileDescriptor ) { $ markerCounter += $ fileDescriptor -> getMarkers ( ) -> count ( ) ; } return $ markerCounter ; }
Get number of markers .
13,227
public function convert ( \ DOMElement $ parent , PropertyDescriptor $ property ) { $ fullyQualifiedNamespaceName = $ property -> getNamespace ( ) instanceof NamespaceDescriptor ? $ property -> getNamespace ( ) -> getFullyQualifiedStructuralElementName ( ) : $ parent -> getAttribute ( 'namespace' ) ; $ child = new \ DOMElement ( 'property' ) ; $ parent -> appendChild ( $ child ) ; $ child -> setAttribute ( 'static' , var_export ( $ property -> isStatic ( ) , true ) ) ; $ child -> setAttribute ( 'visibility' , $ property -> getVisibility ( ) ) ; $ child -> setAttribute ( 'namespace' , $ fullyQualifiedNamespaceName ) ; $ child -> setAttribute ( 'line' , ( string ) $ property -> getLine ( ) ) ; $ child -> appendChild ( new \ DOMElement ( 'name' , '$' . $ property -> getName ( ) ) ) ; $ child -> appendChild ( new \ DOMElement ( 'full_name' , ( string ) $ property -> getFullyQualifiedStructuralElementName ( ) ) ) ; $ child -> appendChild ( new \ DOMElement ( 'default' ) ) -> appendChild ( new \ DOMText ( ( string ) $ property -> getDefault ( ) ) ) ; $ this -> docBlockConverter -> convert ( $ child , $ property ) ; return $ child ; }
Export the given reflected property definition to the provided parent element .
13,228
public function setProcessorParameters ( TransformationObject $ transformation , $ proc ) { foreach ( $ this -> xsl_variables as $ key => $ variable ) { if ( ( strpos ( $ variable , '"' ) !== false ) && ( ( strpos ( $ variable , "'" ) !== false ) ) ) { $ this -> logger -> warning ( 'XSLT does not allow both double and single quotes in ' . 'a variable; transforming single quotes to a character ' . 'encoded version in variable: ' . $ key ) ; $ variable = str_replace ( "'" , '&#39;' , $ variable ) ; } $ proc -> setParameter ( '' , $ key , $ variable ) ; } $ parameters = $ transformation -> getParameters ( ) ; if ( isset ( $ parameters [ 'variables' ] ) ) { foreach ( $ parameters [ 'variables' ] as $ key => $ value ) { $ proc -> setParameter ( '' , $ key , $ value ) ; } } }
Sets the parameters of the XSLT processor .
13,229
private function getArtifactPath ( Transformation $ transformation ) { return $ transformation -> getArtifact ( ) ? $ transformation -> getTransformer ( ) -> getTarget ( ) . DIRECTORY_SEPARATOR . $ transformation -> getArtifact ( ) : null ; }
Returns the path to the location where the artifact should be written or null to automatically detect the location using the router .
13,230
protected function setValueAndCheckIfModified ( $ propertyName , $ value ) { if ( $ this -> { $ propertyName } !== $ value ) { $ this -> isModified = true ; } $ this -> { $ propertyName } = $ value ; }
Sets a property s value and if it differs from the previous then mark these settings as modified .
13,231
public function load ( $ nameOrPath ) { $ template = $ this -> factory -> get ( $ nameOrPath ) ; foreach ( $ template as $ transformation ) { $ writer = $ this -> writerCollection [ $ transformation -> getWriter ( ) ] ; if ( $ writer ) { $ writer -> checkRequirements ( ) ; } } $ this [ $ template -> getName ( ) ] = $ template ; }
Loads a template with the given name or file path .
13,232
public function getTransformations ( ) { $ result = [ ] ; foreach ( $ this as $ template ) { foreach ( $ template as $ transformation ) { $ result [ ] = $ transformation ; } } return $ result ; }
Returns a list of all transformations contained in the templates of this collection .
13,233
public function filter ( $ value ) { if ( $ value instanceof VisibilityInterface && ! $ this -> builder -> isVisibilityAllowed ( $ value -> getVisibility ( ) ) ) { return null ; } return $ value ; }
Filter Descriptor with based on visibility .
13,234
protected function addConstants ( array $ constants , ClassDescriptor $ classDescriptor ) : void { foreach ( $ constants as $ constant ) { $ constantDescriptor = $ this -> getBuilder ( ) -> buildDescriptor ( $ constant ) ; if ( $ constantDescriptor instanceof ConstantDescriptor ) { $ constantDescriptor -> setParent ( $ classDescriptor ) ; $ classDescriptor -> getConstants ( ) -> set ( $ constantDescriptor -> getName ( ) , $ constantDescriptor ) ; } } }
Registers the child constants with the generated Class Descriptor .
13,235
private function constructExamplePath ( string $ directory , string $ file ) : string { return rtrim ( $ directory , '\\/' ) . DIRECTORY_SEPARATOR . $ file ; }
Returns a path to the example file in the given directory ..
13,236
private function getExamplePathFromSource ( string $ file ) : string { return sprintf ( '%s%s%s' , trim ( $ this -> getSourceDirectory ( ) , '\\/' ) , DIRECTORY_SEPARATOR , trim ( $ file , '"' ) ) ; }
Get example filepath based on sourcecode .
13,237
public function match ( $ node ) { foreach ( clone $ this as $ router ) { $ rule = $ router -> match ( $ node ) ; if ( $ rule ) { return $ rule ; } } return null ; }
Tries to match the given node with a rule defined in one of the routers .
13,238
protected function addTags ( \ DOMElement $ docBlock , $ descriptor ) { foreach ( $ descriptor -> getTags ( ) as $ tagGroup ) { if ( ! $ tagGroup ) { continue ; } foreach ( $ tagGroup as $ tag ) { $ this -> tagConverter -> convert ( $ docBlock , $ tag ) ; } } }
Adds each tag to the XML Node representing the DocBlock .
13,239
public function getAllNames ( ) { $ files = new \ DirectoryIterator ( $ this -> getTemplatePath ( ) ) ; $ template_names = [ ] ; while ( $ files -> valid ( ) ) { $ name = $ files -> getBasename ( ) ; if ( ! $ files -> isDir ( ) || in_array ( $ name , [ '.' , '..' ] , true ) ) { $ files -> next ( ) ; continue ; } $ template_names [ ] = $ name ; $ files -> next ( ) ; } return $ template_names ; }
Returns a list of all template names .
13,240
protected function createTemplateFromXml ( $ xml ) { $ template = $ this -> serializer -> deserialize ( $ xml , 'phpDocumentor\Transformer\Template' , 'xml' ) ; $ template -> propagateParameters ( ) ; return $ template ; }
Creates and returns a template object based on the provided template definition .
13,241
private function forceRebuildIfSettingsHaveModified ( ProjectDescriptorBuilder $ builder ) { if ( $ builder -> getProjectDescriptor ( ) -> getSettings ( ) -> isModified ( ) ) { $ this -> setForced ( true ) ; $ this -> log ( 'One of the project\'s settings have changed, forcing a complete rebuild' , LogLevel :: NOTICE ) ; } }
Checks if the settings of the project have changed and forces a complete rebuild if they have .
13,242
private function logAfterParsingAllFiles ( ) { if ( ! $ this -> stopwatch ) { return ; } $ event = $ this -> stopwatch -> stop ( 'parser.parse' ) ; $ this -> log ( 'Elapsed time to parse all files: ' . round ( $ event -> getDuration ( ) / 1000 , 2 ) . 's' ) ; $ this -> log ( 'Peak memory usage: ' . round ( $ event -> getMemory ( ) / 1024 / 1024 , 2 ) . 'M' ) ; }
Writes the complete parsing cycle to log .
13,243
public function filter ( $ value ) { if ( $ value ) { $ namespace = $ value -> getNamespace ( ) === '' ? '\\' . $ this -> namespacePrefix : $ value -> getNamespace ( ) ; $ value -> setNamespace ( $ this -> namespaceFromLegacyNamespace ( $ namespace , $ value -> getName ( ) ) ) ; $ value -> setName ( $ this -> classNameFromLegacyNamespace ( $ value -> getName ( ) ) ) ; } return $ value ; }
Overrides the name and namespace of an element with a separated version of the class name .
13,244
private function namespaceFromLegacyNamespace ( $ namespace , $ className ) { $ qcn = str_replace ( '_' , '\\' , $ className ) ; $ lastBackslash = strrpos ( $ qcn , '\\' ) ; if ( $ lastBackslash ) { $ namespace = rtrim ( $ namespace , '\\' ) . '\\' . substr ( $ qcn , 0 , $ lastBackslash ) ; } return $ namespace ; }
Extracts the namespace from the class name .
13,245
private function classNameFromLegacyNamespace ( $ className ) { $ lastUnderscore = strrpos ( $ className , '_' ) ; if ( $ lastUnderscore ) { $ className = substr ( $ className , $ lastUnderscore + 1 ) ; } return $ className ; }
Extracts the class name without prefix from the full class name .
13,246
public function execute ( ProjectDescriptor $ project ) : void { $ this -> elementCollection = $ project -> getIndexes ( ) -> get ( 'elements' ) ; foreach ( $ this -> elementCollection as $ descriptor ) { $ this -> resolveSeeAndLinkTags ( $ descriptor ) ; } }
Iterates through each element in the project and replaces its inline
13,247
private function resolveElement ( DescriptorAbstract $ element , $ link , ? string $ description = null ) : string { $ rule = $ this -> router -> match ( $ element ) ; if ( $ rule ) { $ url = '..' . $ rule -> generate ( $ element ) ; $ link = $ this -> generateMarkdownLink ( $ url , $ description ? : ( string ) $ link ) ; } return $ link ; }
Generates a Markdown link to the given Descriptor or returns the link text if no route to the Descriptor could be matched .
13,248
private function getLinkText ( Tag $ tagReflector ) : ? string { if ( $ tagReflector instanceof See ) { return ( string ) $ tagReflector -> getReference ( ) ; } if ( $ tagReflector instanceof Link ) { return ( string ) $ tagReflector -> getLink ( ) ; } return null ; }
Returns the link for the given reflector .
13,249
public function isVisibilityAllowed ( $ visibility ) { switch ( $ visibility ) { case 'public' : $ visibility = Settings :: VISIBILITY_PUBLIC ; break ; case 'protected' : $ visibility = Settings :: VISIBILITY_PROTECTED ; break ; case 'private' : $ visibility = Settings :: VISIBILITY_PRIVATE ; break ; case 'internal' : $ visibility = Settings :: VISIBILITY_INTERNAL ; break ; } return $ this -> getProjectDescriptor ( ) -> isVisibilityAllowed ( $ visibility ) ; }
Verifies whether the given visibility is allowed to be included in the Descriptors .
13,250
public static function getInstance ( string $ name = 'default' ) : self { if ( ! isset ( self :: $ instances [ $ name ] ) ) { self :: setInstance ( $ name , new self ( ) ) ; } return self :: $ instances [ $ name ] ; }
Returns a named instance of the Event Dispatcher .
13,251
public static function setInstance ( string $ name , self $ instance ) : void { self :: $ instances [ $ name ] = $ instance ; }
Sets a names instance of the Event Dispatcher .
13,252
public function transform ( ProjectDescriptor $ project , Transformation $ transformation ) : void { $ template_path = $ this -> getTemplatePath ( $ transformation ) ; $ finder = new Pathfinder ( ) ; $ nodes = $ finder -> find ( $ project , $ transformation -> getQuery ( ) ) ; foreach ( $ nodes as $ node ) { if ( ! $ node ) { continue ; } $ destination = $ this -> getDestinationPath ( $ node , $ transformation ) ; if ( $ destination === false ) { continue ; } $ environment = $ this -> initializeEnvironment ( $ project , $ transformation , $ destination ) ; $ environment -> addGlobal ( 'node' , $ node ) ; $ html = $ environment -> render ( substr ( $ transformation -> getSource ( ) , strlen ( $ template_path ) ) ) ; file_put_contents ( $ destination , $ html ) ; } }
This method combines the ProjectDescriptor and the given target template and creates a static html page at the artifact location .
13,253
protected function initializeEnvironment ( ProjectDescriptor $ project , Transformation $ transformation , string $ destination ) : Twig_Environment { $ callingTemplatePath = $ this -> getTemplatePath ( $ transformation ) ; $ baseTemplatesPath = $ transformation -> getTransformer ( ) -> getTemplates ( ) -> getTemplatesPath ( ) ; $ templateFolders = [ $ baseTemplatesPath . '/..' . DIRECTORY_SEPARATOR . $ callingTemplatePath , $ baseTemplatesPath , ] ; foreach ( $ transformation -> getTransformer ( ) -> getTemplates ( ) as $ template ) { $ path = $ baseTemplatesPath . DIRECTORY_SEPARATOR . $ template -> getName ( ) ; array_unshift ( $ templateFolders , $ path ) ; } $ env = clone $ this -> twig ; $ env -> setLoader ( new Twig_Loader_Filesystem ( $ templateFolders ) ) ; $ this -> addPhpDocumentorExtension ( $ project , $ transformation , $ destination , $ env ) ; $ this -> addExtensionsFromTemplateConfiguration ( $ transformation , $ project , $ env ) ; return $ env ; }
Initializes the Twig environment with the template base extension and additionally defined extensions .
13,254
protected function addPhpDocumentorExtension ( ProjectDescriptor $ project , Transformation $ transformation , string $ destination , Twig_Environment $ twigEnvironment ) : void { $ base_extension = new Extension ( $ project , $ transformation ) ; $ base_extension -> setDestination ( substr ( $ destination , strlen ( $ transformation -> getTransformer ( ) -> getTarget ( ) ) + 1 ) ) ; $ base_extension -> setRouters ( $ this -> routers ) ; $ twigEnvironment -> addExtension ( $ base_extension ) ; }
Adds the phpDocumentor base extension to the Twig Environment .
13,255
protected function getTemplatePath ( Transformation $ transformation ) : string { $ parts = preg_split ( '[\\\\|/]' , $ transformation -> getSource ( ) ) ; return $ parts [ 0 ] . DIRECTORY_SEPARATOR . $ parts [ 1 ] ; }
Returns the path belonging to the template .
13,256
public function convert ( \ DOMElement $ parent , MethodDescriptor $ method ) { $ fullyQualifiedNamespaceName = $ method -> getNamespace ( ) instanceof NamespaceDescriptor ? $ method -> getNamespace ( ) -> getFullyQualifiedStructuralElementName ( ) : $ parent -> getAttribute ( 'namespace' ) ; $ child = new \ DOMElement ( 'method' ) ; $ parent -> appendChild ( $ child ) ; $ child -> setAttribute ( 'final' , var_export ( $ method -> isFinal ( ) , true ) ) ; $ child -> setAttribute ( 'abstract' , var_export ( $ method -> isAbstract ( ) , true ) ) ; $ child -> setAttribute ( 'static' , var_export ( $ method -> isStatic ( ) , true ) ) ; $ child -> setAttribute ( 'visibility' , $ method -> getVisibility ( ) ) ; $ child -> setAttribute ( 'namespace' , $ fullyQualifiedNamespaceName ) ; $ child -> setAttribute ( 'line' , ( string ) $ method -> getLine ( ) ) ; $ child -> appendChild ( new \ DOMElement ( 'name' , $ method -> getName ( ) ) ) ; $ child -> appendChild ( new \ DOMElement ( 'full_name' , $ method -> getFullyQualifiedStructuralElementName ( ) ) ) ; $ this -> docBlockConverter -> convert ( $ child , $ method ) ; foreach ( $ method -> getArguments ( ) as $ argument ) { $ this -> argumentConverter -> convert ( $ child , $ argument ) ; } return $ child ; }
Export the given reflected method definition to the provided parent element .
13,257
public function getAllErrors ( ) { $ errors = $ this -> getErrors ( ) ; $ types = $ this -> getClasses ( ) -> merge ( $ this -> getInterfaces ( ) ) -> merge ( $ this -> getTraits ( ) ) ; $ elements = $ this -> getFunctions ( ) -> merge ( $ this -> getConstants ( ) ) -> merge ( $ types ) ; foreach ( $ elements as $ element ) { if ( ! $ element ) { continue ; } $ errors = $ errors -> merge ( $ element -> getErrors ( ) ) ; } foreach ( $ types as $ element ) { if ( ! $ element ) { continue ; } foreach ( $ element -> getMethods ( ) as $ item ) { if ( ! $ item ) { continue ; } $ errors = $ errors -> merge ( $ item -> getErrors ( ) ) ; } if ( method_exists ( $ element , 'getConstants' ) ) { foreach ( $ element -> getConstants ( ) as $ item ) { if ( ! $ item ) { continue ; } $ errors = $ errors -> merge ( $ item -> getErrors ( ) ) ; } } if ( method_exists ( $ element , 'getProperties' ) ) { foreach ( $ element -> getProperties ( ) as $ item ) { if ( ! $ item ) { continue ; } $ errors = $ errors -> merge ( $ item -> getErrors ( ) ) ; } } } return $ errors ; }
Returns a list of all errors in this file and all its child elements .
13,258
protected function configure ( ) { $ this -> addOption ( 'target' , 't' , InputOption :: VALUE_OPTIONAL , 'target location for output' , 'build' ) -> addOption ( 'input-format' , 'i' , InputOption :: VALUE_OPTIONAL , 'which input format does the documentation sources have?' , 'rst' ) -> addOption ( 'title' , null , InputOption :: VALUE_OPTIONAL , 'The title of this document' , 'Scrybe' ) -> addOption ( 'template' , null , InputOption :: VALUE_OPTIONAL , 'which template should be used to generate the documentation?' , 'default' ) -> addArgument ( 'source' , InputArgument :: IS_ARRAY | InputArgument :: REQUIRED , 'One or more files or directories to fetch files from' ) ; $ this -> setHelp ( <<<DESCRIPTIONGenerates reference documentation as {$this->output_format}.You can define the type of files use as input using the <info>--input-format</info>of <info>-i</info> option.DESCRIPTION ) ; }
Configures the options and default help text .
13,259
protected function getTemplate ( InputInterface $ input ) { $ template = $ this -> getTemplateFactory ( ) -> get ( 'twig' ) ; $ template -> setName ( $ input -> getOption ( 'template' ) ) ; return $ template ; }
Returns a template object based off the human - readable template name .
13,260
protected function getConverter ( InputInterface $ input ) { return $ this -> getConverterFactory ( ) -> get ( $ input -> getOption ( 'input-format' ) , $ this -> output_format ) ; }
Returns the converter for this operation .
13,261
protected function visitSection ( \ DOMNode $ root , \ ezcDocumentRstNode $ node ) { if ( $ node instanceof ezcDocumentRstSectionNode || $ node instanceof ezcDocumentRstDocumentNode ) { if ( $ node -> depth === 1 ) { $ toc = $ this -> getTableOfContents ( ) ; $ file = $ toc [ $ this -> getFilenameWithoutExtension ( ) ] ; $ file -> setName ( $ this -> nodeToString ( $ node -> title ) ) ; } else { $ parent_depth = $ node -> depth - 1 ; while ( ! isset ( $ this -> entry_pointers [ $ parent_depth ] ) && $ parent_depth > 0 ) { -- $ parent_depth ; } $ parent = $ this -> entry_pointers [ $ parent_depth ] ; $ heading = new TableOfContents \ Heading ( $ parent ) ; $ heading -> setName ( $ this -> nodeToString ( $ node -> title ) ) ; $ heading -> setSlug ( $ node -> reference ) ; $ parent -> addChild ( $ heading ) ; $ this -> last_heading = $ heading ; array_splice ( $ this -> entry_pointers , $ parent_depth + 1 , count ( $ this -> entry_pointers ) , [ $ heading ] ) ; } } parent :: visitSection ( $ root , $ node ) ; }
Visitor for the section heading used to populate the TableOfContents .
13,262
public function addFileToLastHeading ( TableOfContents \ File $ file ) { $ this -> last_heading -> addChild ( $ file ) ; $ file -> setParent ( $ this -> last_heading ) ; }
Adds a TableOfContents File object to the last heading that was discovered .
13,263
protected function addProperties ( array $ properties , TraitDescriptor $ traitDescriptor ) : void { foreach ( $ properties as $ property ) { $ propertyDescriptor = $ this -> getBuilder ( ) -> buildDescriptor ( $ property ) ; if ( $ propertyDescriptor instanceof PropertyDescriptor ) { $ propertyDescriptor -> setParent ( $ traitDescriptor ) ; $ traitDescriptor -> getProperties ( ) -> set ( $ propertyDescriptor -> getName ( ) , $ propertyDescriptor ) ; } } }
Registers the child properties with the generated Trait Descriptor .
13,264
public function setVersion ( string $ version ) { if ( ! preg_match ( '/^\d+\.\d+\.\d+$/' , $ version ) ) { throw new \ InvalidArgumentException ( 'Version number is invalid; ' . $ version . ' does not match ' . 'x.x.x (where x is a number)' ) ; } $ this -> version = $ version ; }
Sets the version number for this template .
13,265
public function offsetSet ( $ offset , $ value ) { if ( ! $ value instanceof Transformation ) { throw new \ InvalidArgumentException ( '\phpDocumentor\Transformer\Template may only contain items of ' . 'type \phpDocumentor\Transformer\Transformation' ) ; } $ this -> transformations [ $ offset ] = $ value ; }
Sets a transformation at the given offset .
13,266
public function propagateParameters ( ) { foreach ( $ this -> transformations as $ transformation ) { $ transformation -> setParameters ( array_merge ( $ transformation -> getParameters ( ) , $ this -> getParameters ( ) ) ) ; } }
Pushes the parameters of this template into the transformations .
13,267
public function get ( string $ input_format , string $ output_format ) : ConverterInterface { $ definition = $ this -> definition_factory -> get ( $ input_format , $ output_format ) ; foreach ( $ this -> converters as $ class => $ formats ) { if ( [ $ input_format , $ output_format ] === $ formats ) { $ assets = new Metadata \ Assets ( ) ; $ assets -> setLogger ( $ this -> logger ) ; $ toc = new Metadata \ TableOfContents ( ) ; $ glossary = new Metadata \ Glossary ( ) ; $ converter = new $ class ( $ definition , $ assets , $ toc , $ glossary ) ; $ converter -> setLogger ( $ this -> logger ) ; return $ converter ; } } throw new ConverterNotFoundException ( 'No converter could be found to convert from ' . $ input_format . ' to ' . $ output_format ) ; }
Retrieves a new instance of the converter necessary to convert the give input format to the given output format .
13,268
public function getSupportedInputFormats ( string $ given_output_format ) : array { $ result = [ ] ; foreach ( $ this -> converters as $ formats ) { list ( $ input_format , $ output_format ) = $ formats ; if ( $ given_output_format === $ output_format ) { $ result [ ] = $ input_format ; } } return $ result ; }
Returns a list of supported input formats for the given output format .
13,269
public function getSourceAsPath ( ) : string { if ( $ this -> getParameter ( 'template_path' ) !== null ) { $ path = rtrim ( $ this -> getParameter ( 'template_path' ) -> getValue ( ) , '/\\' ) ; if ( file_exists ( $ path . DIRECTORY_SEPARATOR . $ this -> source ) ) { return $ path . DIRECTORY_SEPARATOR . $ this -> source ; } } if ( strpos ( $ this -> source , 'templates/' ) !== 0 ) { $ this -> source = 'templates/abstract/' . $ this -> source ; trigger_error ( 'Using shared assets in a template is deprecated and will be removed in version 3.0' , E_USER_DEPRECATED ) ; } if ( file_exists ( __DIR__ . '/../../../' . $ this -> source ) ) { return __DIR__ . '/../../../' . $ this -> source ; } if ( file_exists ( __DIR__ . '/../../../../templates' ) ) { return __DIR__ . '/../../../../' . $ this -> source ; } $ file = __DIR__ . '/../../../data/' . $ this -> source ; if ( ! file_exists ( $ file ) ) { throw new Exception ( 'The source path does not exist: ' . $ file ) ; } return $ file ; }
Returns the source as a path instead of a regular value .
13,270
public function save ( ProjectDescriptor $ projectDescriptor ) : void { $ keys = [ ] ; $ cache = $ this -> getCache ( ) ; foreach ( $ cache as $ key ) { $ keys [ ] = $ key ; } $ cache -> setItem ( self :: KEY_SETTINGS , $ projectDescriptor -> getSettings ( ) ) ; $ usedKeys = [ self :: KEY_SETTINGS ] ; foreach ( $ projectDescriptor -> getFiles ( ) as $ file ) { $ key = self :: FILE_PREFIX . md5 ( $ file -> getPath ( ) ) ; $ usedKeys [ ] = $ key ; $ cache -> setItem ( $ key , $ file ) ; } $ invalidatedKeys = array_diff ( $ keys , $ usedKeys ) ; if ( $ invalidatedKeys ) { $ cache -> removeItems ( $ invalidatedKeys ) ; } if ( $ cache instanceof OptimizableInterface ) { $ cache -> optimize ( ) ; } }
Stores a Project Descriptor in the Cache .
13,271
public function toDocbook ( \ DOMDocument $ document , \ DOMElement $ root ) { $ this -> storeAsset ( ) ; parent :: toDocbook ( $ document , $ root ) ; }
Converts the Image directive to aDocBook image tag .
13,272
protected function storeAsset ( ) { if ( ! $ this -> visitor instanceof Discover ) { return ; } $ assets = $ this -> getAssetManager ( ) ; $ project_root = $ assets -> getProjectRoot ( ) ; $ asset_path = trim ( $ this -> node -> parameters ) ; $ file_path = $ this -> visitor -> getDocument ( ) -> getFile ( ) -> getRealPath ( ) ; $ source = ( $ asset_path [ 0 ] !== '/' ) ? dirname ( $ file_path ) . '/' . $ asset_path : $ project_root . $ asset_path ; $ destination = ( $ asset_path [ 0 ] !== '/' ) ? substr ( dirname ( $ file_path ) . '/' . $ asset_path , strlen ( $ project_root ) ) : substr ( $ asset_path , 1 ) ; $ assets -> set ( $ source , $ destination ) ; }
Stores the asset in the asset manager .
13,273
public function execute ( ProjectDescriptor $ project ) : void { $ markerTerms = $ project -> getSettings ( ) -> getMarkers ( ) ; foreach ( $ project -> getFiles ( ) as $ file ) { $ marker_data = [ ] ; $ matches = [ ] ; preg_match_all ( '~//[\s]*(' . implode ( '|' , $ markerTerms ) . ')\:?[\s]*(.*)~' , $ file -> getSource ( ) , $ matches , PREG_SET_ORDER | PREG_OFFSET_CAPTURE ) ; foreach ( $ matches as $ match ) { list ( $ before ) = str_split ( $ file -> getSource ( ) , $ match [ 1 ] [ 1 ] ) ; $ line_number = strlen ( $ before ) - strlen ( str_replace ( "\n" , '' , $ before ) ) + 1 ; $ marker_data [ ] = [ 'type' => trim ( $ match [ 1 ] [ 0 ] , '@' ) , 'line' => $ line_number , $ match [ 2 ] [ 0 ] ] ; } $ file -> setMarkers ( new Collection ( $ marker_data ) ) ; } }
Scans the files for markers and records them in the markers property of a file .
13,274
public function transform ( ProjectDescriptor $ project , Transformation $ transformation ) { $ artifact = $ this -> getDestinationPath ( $ transformation ) ; $ this -> checkForSpacesInPath ( $ artifact ) ; $ this -> xml = new \ DOMDocument ( '1.0' , 'utf-8' ) ; $ this -> xml -> formatOutput = true ; $ document_element = new \ DOMElement ( 'project' ) ; $ this -> xml -> appendChild ( $ document_element ) ; $ document_element -> setAttribute ( 'title' , $ project -> getName ( ) ) ; $ document_element -> setAttribute ( 'version' , Application :: VERSION ( ) ) ; $ this -> buildPartials ( $ document_element , $ project ) ; $ transformer = $ transformation -> getTransformer ( ) ; foreach ( $ project -> getFiles ( ) as $ file ) { $ this -> buildFile ( $ document_element , $ file , $ transformer ) ; } $ this -> finalize ( $ project ) ; file_put_contents ( $ artifact , $ this -> xml -> saveXML ( ) ) ; }
This method generates the AST output
13,275
protected function finalize ( ProjectDescriptor $ projectDescriptor ) { $ behaviour = new AuthorTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new CoversTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new IgnoreTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new InternalTag ( $ projectDescriptor -> isVisibilityAllowed ( ProjectDescriptor \ Settings :: VISIBILITY_INTERNAL ) ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new LicenseTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new MethodTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new ParamTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new PropertyTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new ReturnTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new UsesTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ behaviour = new VarTag ( ) ; $ behaviour -> process ( $ this -> xml ) ; $ this -> buildPackageTree ( $ this -> xml ) ; $ this -> buildNamespaceTree ( $ this -> xml ) ; $ this -> buildDeprecationList ( $ this -> xml ) ; }
Finalizes the processing and executing all post - processing actions .
13,276
protected function buildDeprecationList ( \ DOMDocument $ dom ) { $ nodes = $ this -> getNodeListForTagBasedQuery ( $ dom , 'deprecated' ) ; $ node = new \ DOMElement ( 'deprecated' ) ; $ dom -> documentElement -> appendChild ( $ node ) ; $ node -> setAttribute ( 'count' , ( string ) $ nodes -> length ) ; }
Adds a node to the xml for deprecations and the count value
13,277
protected function getNodeListForTagBasedQuery ( $ dom , $ marker ) { $ xpath = new \ DOMXPath ( $ dom ) ; $ query = '/project/file/markers/' . $ marker . '|' ; $ query .= '/project/file/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/class/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/class/*/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/interface/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/interface/*/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/function/docblock/tag[@name="' . $ marker . '"]|' ; $ query .= '/project/file/constant/docblock/tag[@name="' . $ marker . '"]' ; return $ xpath -> query ( $ query ) ; }
Build a tag based query string and return result
13,278
protected function configureConverterFromInputOptions ( $ converter , $ input ) { if ( ! $ converter instanceof ToLatexInterface ) { throw new \ InvalidArgumentException ( 'The converter used to process ' . $ input -> getOption ( 'input-format' ) . ' should implement the ' . 'phpDocumentor\Plugin\Scrybe\Converter\ToPdfInterface' ) ; } $ converter -> setTitle ( $ input -> getOption ( 'title' ) ) ; $ converter -> setAuthor ( $ input -> getOption ( 'author' ) ) ; $ converter -> setCoverLogo ( $ input -> getOption ( 'cover-logo' ) ) ; $ converter -> setTableOfContents ( $ input -> getOption ( 'toc' ) !== 'false' ) ; }
Configures the converter with the options provided by the Input options .
13,279
public function create ( array $ paths , array $ ignore , array $ extensions ) : SpecificationInterface { $ pathSpec = null ; foreach ( $ paths as $ path ) { $ pathSpec = $ this -> orSpec ( $ this -> inPath ( $ path ) , $ pathSpec ) ; } $ ignoreSpec = null ; if ( isset ( $ ignore [ 'paths' ] ) ) { foreach ( $ ignore [ 'paths' ] as $ path ) { $ ignoreSpec = $ this -> orSpec ( $ this -> inPath ( $ path ) , $ ignoreSpec ) ; } } if ( isset ( $ ignore [ 'hidden' ] ) && $ ignore [ 'hidden' ] === true ) { $ ignoreSpec = $ this -> orSpec ( new IsHidden ( ) , $ ignoreSpec ) ; } return $ this -> andSpec ( $ pathSpec , $ this -> andSpec ( new HasExtension ( $ extensions ) , $ this -> notSpec ( $ ignoreSpec ) ) ) ; }
Creates a SpecificationInterface object based on the ignore and extension parameters .
13,280
private function buildVersion ( SimpleXMLElement $ version ) : array { $ apis = [ ] ; $ guides = [ ] ; foreach ( $ version -> children ( ) as $ child ) { switch ( $ child -> getName ( ) ) { case 'api' : $ apis [ ] = $ this -> buildApi ( $ child ) ; break ; case 'guide' : $ guides [ ] = $ this -> buildGuide ( $ child ) ; break ; default : break ; } } $ version = [ 'folder' => ( string ) $ version -> folder , ] ; if ( count ( $ apis ) > 0 ) { $ version [ 'api' ] = $ apis ; } if ( count ( $ guides ) > 0 ) { $ version [ 'guide' ] = $ guides ; } return $ version ; }
Builds the versions part of the array from the configuration xml .
13,281
private function buildApi ( SimpleXMLElement $ api ) : array { $ extensions = [ ] ; foreach ( $ api -> extensions -> children ( ) as $ extension ) { if ( ( string ) $ extension !== '' ) { $ extensions [ ] = ( string ) $ extension ; } } $ ignoreHidden = filter_var ( $ api -> ignore -> attributes ( ) -> hidden , FILTER_VALIDATE_BOOLEAN ) ; return [ 'format' => ( ( string ) $ api -> attributes ( ) -> format ) ? : 'php' , 'source' => [ 'dsn' => ( ( string ) $ api -> source -> attributes ( ) -> dsn ) ? : 'file://.' , 'paths' => ( ( array ) $ api -> source -> path ) ? : [ '.' ] , ] , 'ignore' => [ 'hidden' => $ ignoreHidden , 'paths' => ( array ) $ api -> ignore -> path , ] , 'extensions' => $ extensions , 'visibility' => ( array ) $ api -> visibility , 'default-package-name' => ( ( string ) $ api -> { 'default-package-name' } ) ? : 'Default' , 'markers' => ( array ) $ api -> markers -> children ( ) -> marker , ] ; }
Builds the api part of the array from the configuration xml .
13,282
private function buildGuide ( SimpleXMLElement $ guide ) : array { return [ 'format' => ( ( string ) $ guide -> attributes ( ) -> format ) ? : 'rst' , 'source' => [ 'dsn' => ( ( string ) $ guide -> source -> attributes ( ) -> dsn ) ? : 'file://.' , 'paths' => ( ( array ) $ guide -> source -> path ) ? : [ '' ] , ] , ] ; }
Builds the guide part of the array from the configuration xml .
13,283
private function validate ( SimpleXMLElement $ phpDocumentor ) : void { libxml_clear_errors ( ) ; $ priorSetting = libxml_use_internal_errors ( true ) ; $ dom = new \ DOMDocument ( ) ; $ domElement = dom_import_simplexml ( $ phpDocumentor ) ; $ domElement = $ dom -> importNode ( $ domElement , true ) ; $ dom -> appendChild ( $ domElement ) ; $ dom -> schemaValidate ( $ this -> schemaPath ) ; $ error = libxml_get_last_error ( ) ; if ( $ error !== false ) { throw new InvalidArgumentException ( trim ( $ error -> message ) ) ; } libxml_use_internal_errors ( $ priorSetting ) ; }
Validates the configuration xml structure against the schema defined in the schemaPath .
13,284
public function get ( $ index , $ valueIfEmpty = null ) { if ( ! $ this -> offsetExists ( $ index ) && $ valueIfEmpty !== null ) { $ this -> offsetSet ( $ index , $ valueIfEmpty ) ; } return $ this -> offsetGet ( $ index ) ; }
Retrieves a specific item from the Collection with its index .
13,285
public function offsetSet ( $ offset , $ value ) { if ( $ offset === '' || $ offset === null ) { throw new \ InvalidArgumentException ( 'The key of a collection must always be set' ) ; } $ this -> items [ $ offset ] = $ value ; }
Sets an item at the given index .
13,286
public function copyTo ( $ destination ) { foreach ( $ this as $ source_path => $ asset_path ) { if ( ! is_readable ( $ source_path ) ) { if ( $ this -> logger ) { $ this -> logger -> error ( 'Asset "' . $ source_path . '" could not be found or is not readable' ) ; } continue ; } $ destination_path = $ destination . '/' . $ asset_path ; if ( ! file_exists ( dirname ( $ destination_path ) ) ) { mkdir ( dirname ( $ destination_path ) , 0777 , true ) ; } copy ( $ source_path , $ destination_path ) ; } }
Copies all assets in this collection to their given destination location .
13,287
public function filter ( $ value ) { $ isInternalAllowed = $ this -> builder -> isVisibilityAllowed ( Settings :: VISIBILITY_INTERNAL ) ; if ( $ isInternalAllowed ) { $ value -> setDescription ( preg_replace ( '/\{@internal\s(.+?)\}\}/' , '$1' , $ value -> getDescription ( ) ) ) ; return $ value ; } $ value -> setDescription ( preg_replace ( '/\{@internal\s(.+?)\}\}/' , '' , $ value -> getDescription ( ) ) ) ; if ( $ value -> getTags ( ) -> get ( 'internal' ) ) { return null ; } return $ value ; }
If the ProjectDescriptor s settings allow internal tags then return the Descriptor otherwise null to filter it .
13,288
public function getFilename ( ) { $ converter = $ this -> getDocument ( ) -> getConverter ( ) ; return $ converter -> getDestinationFilenameRelativeToProjectRoot ( $ this -> getDocument ( ) -> getFile ( ) ) ; }
Returns the filename for this visitor .
13,289
public function getFilenameWithoutExtension ( ) { $ filename = $ this -> getDocument ( ) -> getFile ( ) -> getFilename ( ) ; return substr ( $ filename , 0 , strrpos ( $ filename , '.' ) ) ; }
Returns the filename for this visitor without an extension .
13,290
public function convertToRootPath ( $ relative_path ) : ? string { $ path_parts = explode ( DIRECTORY_SEPARATOR , $ this -> getDestination ( ) ) ; $ path_to_root = ( count ( $ path_parts ) > 1 ) ? implode ( '/' , array_fill ( 0 , count ( $ path_parts ) - 1 , '..' ) ) . '/' : '' ; if ( is_string ( $ relative_path ) && ( $ relative_path [ 0 ] !== '@' ) ) { return $ path_to_root . ltrim ( $ relative_path , '/' ) ; } $ rule = $ this -> routers -> match ( $ relative_path ) ; if ( ! $ rule ) { return null ; } $ generatedPath = $ rule -> generate ( $ relative_path ) ; return $ generatedPath ? $ path_to_root . ltrim ( $ generatedPath , '/' ) : null ; }
Converts the given path to be relative to the root of the documentation target directory .
13,291
protected function renderASeriesOfLinks ( $ value , $ presentation ) : array { if ( $ value instanceof Collection ) { $ value = $ value -> getAll ( ) ; } $ result = [ ] ; foreach ( $ value as $ path ) { $ result [ ] = $ this -> render ( $ path , $ presentation ) ; } return $ result ; }
Returns a series of anchors and strings for the given collection of routable items .
13,292
protected function renderTypeCollection ( $ value , $ presentation ) { $ baseType = $ this -> render ( $ value -> getBaseType ( ) , $ presentation ) ; $ keyTypes = $ this -> render ( $ value -> getKeyTypes ( ) , $ presentation ) ; $ types = $ this -> render ( $ value -> getTypes ( ) , $ presentation ) ; $ arguments = [ ] ; if ( $ keyTypes ) { $ arguments [ ] = implode ( '|' , $ keyTypes ) ; } $ arguments [ ] = implode ( '|' , $ types ) ; if ( $ value -> getName ( ) === 'array' && count ( $ value -> getKeyTypes ( ) ) === 0 ) { $ typeString = ( count ( $ types ) > 1 ) ? '(' . reset ( $ arguments ) . ')' : reset ( $ arguments ) ; $ collection = $ typeString . '[]' ; } else { $ collection = ( $ baseType ? : $ value -> getName ( ) ) . '&lt;' . implode ( ',' , $ arguments ) . '&gt;' ; } return $ collection ; }
Renders the view representation for an array or collection .
13,293
public function create ( Dsn $ dsn ) { $ dsnId = hash ( 'md5' , ( string ) $ dsn ) ; try { $ filesystem = $ this -> mountManager -> getFilesystem ( $ dsnId ) ; } catch ( LogicException $ e ) { if ( $ dsn -> getScheme ( ) === 'file' ) { $ path = $ dsn -> getPath ( ) ; $ filesystem = new Filesystem ( new Local ( $ path , LOCK_EX , Local :: SKIP_LINKS ) ) ; } else { throw new \ InvalidArgumentException ( 'http and https are not supported yet' ) ; } $ this -> mountManager -> mountFilesystem ( $ dsnId , $ filesystem ) ; } $ filesystem -> addPlugin ( new Finder ( ) ) ; return $ filesystem ; }
Returns a Filesystem instance based on the scheme of the provided Dsn
13,294
protected function getSubElements ( DescriptorAbstract $ element ) : array { $ subElements = [ ] ; if ( $ element instanceof ClassInterface ) { $ subElements = array_merge ( $ element -> getMethods ( ) -> getAll ( ) , $ element -> getConstants ( ) -> getAll ( ) , $ element -> getProperties ( ) -> getAll ( ) ) ; } if ( $ element instanceof InterfaceInterface ) { $ subElements = array_merge ( $ element -> getMethods ( ) -> getAll ( ) , $ element -> getConstants ( ) -> getAll ( ) ) ; } if ( $ element instanceof TraitInterface ) { $ subElements = array_merge ( $ element -> getMethods ( ) -> getAll ( ) , $ element -> getProperties ( ) -> getAll ( ) ) ; } return $ subElements ; }
Returns any sub - elements for the given element .
13,295
protected function addElementsToIndexes ( $ elements , array $ indexes ) : void { if ( ! is_array ( $ elements ) ) { $ elements = [ $ elements ] ; } foreach ( $ elements as $ element ) { foreach ( $ indexes as $ collection ) { $ collection -> set ( $ this -> getIndexKey ( $ element ) , $ element ) ; } } }
Adds a series of descriptors to the given list of collections .
13,296
protected function defineIniSettings ( ) : void { $ this -> setTimezone ( ) ; ini_set ( 'memory_limit' , '-1' ) ; if ( extension_loaded ( 'Zend OPcache' ) && ini_get ( 'opcache.enable' ) && ini_get ( 'opcache.enable_cli' ) ) { if ( ini_get ( 'opcache.save_comments' ) ) { ini_set ( 'opcache.load_comments' , '1' ) ; } else { ini_set ( 'opcache.enable' , '0' ) ; } } if ( extension_loaded ( 'Zend Optimizer+' ) && ini_get ( 'zend_optimizerplus.save_comments' ) === 0 ) { throw new RuntimeException ( 'Please enable zend_optimizerplus.save_comments in php.ini.' ) ; } }
Adjust php . ini settings .
13,297
protected function addArgumentsToFunctionDescriptor ( array $ arguments , FunctionDescriptor $ functionDescriptor ) : void { foreach ( $ arguments as $ argument ) { $ this -> addArgumentDescriptorToFunction ( $ functionDescriptor , $ this -> createArgumentDescriptor ( $ functionDescriptor , $ argument ) ) ; } }
Converts each argument reflector to an argument descriptor and adds it to the function descriptor .
13,298
protected function addArgumentDescriptorToFunction ( FunctionDescriptor $ functionDescriptor , ArgumentDescriptor $ argumentDescriptor ) : void { $ functionDescriptor -> getArguments ( ) -> set ( $ argumentDescriptor -> getName ( ) , $ argumentDescriptor ) ; }
Adds the given argument to the function .
13,299
public function fromNamespace ( $ fqnn ) { $ name = str_replace ( '\\' , '.' , ltrim ( ( string ) $ fqnn , '\\' ) ) ; if ( $ name === '' ) { $ name = 'default' ; } return $ name ; }
Converts the provided FQCN into a file name by replacing all slashes with dots .