File
extends AbstractFactory
in package
Strategy to create File element from the provided filename.
This class supports extra middle wares to add extra steps to the creation process.
Table of Contents
Constants
- SKIPPED_NODE_TYPES = [\PhpParser\Node\Stmt\Declare_::class, \PhpParser\Node\Stmt\InlineHTML::class]
Properties
- $docBlockFactory : DocBlockFactoryInterface
- $reducers : iterable<string|int, mixed>
- $middlewareChain : callable
- $nodesFactory : NodesFactory
Methods
- __construct() : mixed
- Initializes the object.
- create() : void
- Creates an Element out of the given object.
- matches() : bool
- Returns true when the strategy is able to handle the object.
- createDocBlock() : DocBlock|null
- createFileDocBlock() : DocBlock|null
- doCreate() : object|null
- Creates an File out of the given object.
- createElements() : void
- createFile() : File
Constants
SKIPPED_NODE_TYPES
private
mixed
SKIPPED_NODE_TYPES
= [\PhpParser\Node\Stmt\Declare_::class, \PhpParser\Node\Stmt\InlineHTML::class]
Properties
$docBlockFactory read-only
protected
DocBlockFactoryInterface
$docBlockFactory
$reducers read-only
protected
iterable<string|int, mixed>
$reducers
= []
$middlewareChain
private
callable
$middlewareChain
$nodesFactory read-only
private
NodesFactory
$nodesFactory
Methods
__construct()
Initializes the object.
public
__construct(DocBlockFactoryInterface $docBlockFactory, NodesFactory $nodesFactory[, array<string|int, Middleware> $middleware = [] ]) : mixed
Parameters
- $docBlockFactory : DocBlockFactoryInterface
- $nodesFactory : NodesFactory
- $middleware : array<string|int, Middleware> = []
create()
Creates an Element out of the given object.
public
create(ContextStack $context, object $object, StrategyContainer $strategies) : void
Since an object might contain other objects that need to be converted the $stategies are passed so it can be used to create nested Elements. The passed ContextStack contains a stack of upstream created Elements that can be manipulated by factories. This allows the factory to also impact on parent objects of earlier created elements.
Parameters
- $context : ContextStack
-
context to set the factory result.
- $object : object
-
object to convert to an Element
- $strategies : StrategyContainer
-
used to convert nested objects.
Attributes
- #[Override]
matches()
Returns true when the strategy is able to handle the object.
public
matches(ContextStack $context, object $object) : bool
Parameters
- $context : ContextStack
- $object : object
-
object to check.
Attributes
- #[Override]
Return values
boolcreateDocBlock()
protected
createDocBlock([Doc|null $docBlock = null ][, Context|null $context = null ]) : DocBlock|null
Parameters
- $docBlock : Doc|null = null
- $context : Context|null = null
Return values
DocBlock|nullcreateFileDocBlock()
protected
createFileDocBlock([Context|null $context = null ][, array<string|int, Node> $nodes = [] ]) : DocBlock|null
Parameters
- $context : Context|null = null
- $nodes : array<string|int, Node> = []
Return values
DocBlock|nulldoCreate()
Creates an File out of the given object.
protected
doCreate(ContextStack $context, File $object, StrategyContainer $strategies) : object|null
Since an object might contain other objects that need to be converted the $factory is passed so it can be used to create nested Elements.
Parameters
- $context : ContextStack
-
used to convert nested objects.
- $object : File
-
path to the file to convert to an File object.
- $strategies : StrategyContainer
-
used to convert nested objects.
Attributes
- #[Override]
Return values
object|nullcreateElements()
private
createElements(ContextStack $contextStack, array<string|int, Node> $nodes, StrategyContainer $strategies) : void
Parameters
- $contextStack : ContextStack
- $nodes : array<string|int, Node>
- $strategies : StrategyContainer
createFile()
private
createFile(CreateCommand $command) : File
Parameters
- $command : CreateCommand