diff --git a/src/Compiler/AppendState.php b/src/Compiler/AppendState.php index e5f8ba8..3553786 100644 --- a/src/Compiler/AppendState.php +++ b/src/Compiler/AppendState.php @@ -15,7 +15,5 @@ class AppendState public function __construct(public AbstractNode $node, public int $beforeLineNumber, public int $afterLineNumber, - public string $value) - { - } + public string $value) {} } diff --git a/src/Compiler/Compiler.php b/src/Compiler/Compiler.php index b1756ad..cfa9ef3 100644 --- a/src/Compiler/Compiler.php +++ b/src/Compiler/Compiler.php @@ -147,13 +147,13 @@ class Compiler public function __construct(DocumentParser $parser) { - $this->compilationBuffer = new StringBuffer(); - $this->loopExtractor = new LoopVariablesExtractor(); + $this->compilationBuffer = new StringBuffer; + $this->loopExtractor = new LoopVariablesExtractor; $this->parser = $parser; - $this->rawTransformer = new RawTransformer(); + $this->rawTransformer = new RawTransformer; $this->componentTagCompiler = new ComponentTagCompiler( - new ComponentNodeCompiler(), - new DocumentParser() + new ComponentNodeCompiler, + new DocumentParser ); } diff --git a/src/Compiler/CompilerServices/CoreDirectiveRetriever.php b/src/Compiler/CompilerServices/CoreDirectiveRetriever.php index 2a84f62..4852e1a 100644 --- a/src/Compiler/CompilerServices/CoreDirectiveRetriever.php +++ b/src/Compiler/CompilerServices/CoreDirectiveRetriever.php @@ -41,7 +41,7 @@ public function __construct() public static function instance(): CoreDirectiveRetriever { if (self::$instance == null) { - self::$instance = new CoreDirectiveRetriever(); + self::$instance = new CoreDirectiveRetriever; } return self::$instance; diff --git a/src/Compiler/CompilerServices/LoopVariablesExtractor.php b/src/Compiler/CompilerServices/LoopVariablesExtractor.php index 081585a..b40fd16 100644 --- a/src/Compiler/CompilerServices/LoopVariablesExtractor.php +++ b/src/Compiler/CompilerServices/LoopVariablesExtractor.php @@ -11,7 +11,7 @@ class LoopVariablesExtractor public function __construct() { - $this->splitter = new StringSplitter(); + $this->splitter = new StringSplitter; } /** @@ -21,7 +21,7 @@ public function __construct() */ public function extractDetails(string $value): LoopVariables { - $result = new LoopVariables(); + $result = new LoopVariables; $result->source = $value; $value = StringUtilities::unwrapParentheses($value); diff --git a/src/Compiler/ComponentNodeCompiler.php b/src/Compiler/ComponentNodeCompiler.php index de44bc3..d18348f 100644 --- a/src/Compiler/ComponentNodeCompiler.php +++ b/src/Compiler/ComponentNodeCompiler.php @@ -145,7 +145,7 @@ protected function compileSelfClosingTag(ComponentNode $component): string protected function compileParameterEcho(ParameterNode $node): string { - $compiler = new Compiler(new DocumentParser()); + $compiler = new Compiler(new DocumentParser); $compiler->setCompilationTarget(CompilationTarget::ComponentParameter); $result = $compiler->compileString($node->value); diff --git a/src/Compiler/UnresolvableComponent.php b/src/Compiler/UnresolvableComponent.php index 473bf6a..8c0c646 100644 --- a/src/Compiler/UnresolvableComponent.php +++ b/src/Compiler/UnresolvableComponent.php @@ -7,6 +7,4 @@ * This class is used when the compiler is set to not throw * compilation errors when it encounters unknown components. */ -class UnresolvableComponent -{ -} +class UnresolvableComponent {} diff --git a/src/Document/Document.php b/src/Document/Document.php index ea88eb6..be59b94 100644 --- a/src/Document/Document.php +++ b/src/Document/Document.php @@ -468,12 +468,12 @@ public function getFragments(): Collection return collect($this->fragments); } - $fragmentsParser = new FragmentsDocumentParser(); + $fragmentsParser = new FragmentsDocumentParser; $fragmentsParser->setIgnoreRanges($this->toSkipIndex()); $this->fragments = $fragmentsParser->parse($this->toString()); - $fragmentPositions = new FragmentPositionsAnalyzer(); + $fragmentPositions = new FragmentPositionsAnalyzer; $fragmentPositions->setFragments($this->fragments); foreach ($this->nodes as $node) { diff --git a/src/Document/DocumentCompilerOptions.php b/src/Document/DocumentCompilerOptions.php index 4fe2485..68f5bf7 100644 --- a/src/Document/DocumentCompilerOptions.php +++ b/src/Document/DocumentCompilerOptions.php @@ -19,7 +19,5 @@ public function __construct( public array $appendCallbacks = [], public array $customTagCompilers = [], public bool $compileCoreComponentTags = true, - public array $ignoreDirectives = []) - { - } + public array $ignoreDirectives = []) {} } diff --git a/src/Document/DocumentFactory.php b/src/Document/DocumentFactory.php index a290cde..bb6e293 100644 --- a/src/Document/DocumentFactory.php +++ b/src/Document/DocumentFactory.php @@ -19,6 +19,6 @@ public static function makeDocument(): Document return $methodToCall(); } - return new Document(); + return new Document; } } diff --git a/src/Document/DocumentOptions.php b/src/Document/DocumentOptions.php index f3866e4..ef012cb 100644 --- a/src/Document/DocumentOptions.php +++ b/src/Document/DocumentOptions.php @@ -21,6 +21,5 @@ public function __construct( * @var string[] $ignoreDirectives */ public array $ignoreDirectives = [], - ) { - } + ) {} } diff --git a/src/Document/Structures/Concerns/ConstructsConditions.php b/src/Document/Structures/Concerns/ConstructsConditions.php index 3e639eb..9dfdc69 100644 --- a/src/Document/Structures/Concerns/ConstructsConditions.php +++ b/src/Document/Structures/Concerns/ConstructsConditions.php @@ -21,7 +21,7 @@ protected function constructConditions(array $nodes): void $chainedDirectives = $node->getChainedClosingDirectives(); $chainedDirectives->pop(); // Removes the closing directive. - $condition = new Condition(); + $condition = new Condition; $condition->constructedFrom = $node; $node->isStructure = true; diff --git a/src/Document/Structures/Concerns/ConstructsForElse.php b/src/Document/Structures/Concerns/ConstructsForElse.php index 81533d4..e806f09 100644 --- a/src/Document/Structures/Concerns/ConstructsForElse.php +++ b/src/Document/Structures/Concerns/ConstructsForElse.php @@ -18,7 +18,7 @@ protected function constructForElse(array $nodes): void continue; } - $forElse = new ForElse(); + $forElse = new ForElse; $forElse->constructedFrom = $node; $node->isStructure = true; diff --git a/src/Document/Structures/Concerns/ConstructsSwitchStatements.php b/src/Document/Structures/Concerns/ConstructsSwitchStatements.php index 87188e9..9f16370 100644 --- a/src/Document/Structures/Concerns/ConstructsSwitchStatements.php +++ b/src/Document/Structures/Concerns/ConstructsSwitchStatements.php @@ -20,7 +20,7 @@ protected function constructSwitchStatements(array $nodes): void continue; } - $switchStatement = new SwitchStatement(); + $switchStatement = new SwitchStatement; $switchStatement->constructedFrom = $node; $node->isStructure = true; $node->structure = $switchStatement; diff --git a/src/Document/Structures/StructurePairAnalyzer.php b/src/Document/Structures/StructurePairAnalyzer.php index 6667fd2..69a9aec 100644 --- a/src/Document/Structures/StructurePairAnalyzer.php +++ b/src/Document/Structures/StructurePairAnalyzer.php @@ -148,7 +148,7 @@ public function associate(): void /** @var DirectiveStackItem[] $nodeStack */ $nodeStack = []; - $stackItem = new DirectiveStackItem(); + $stackItem = new DirectiveStackItem; $stackItem->documentNodes = $this->document->getNodes()->all(); $nodeStack[] = $stackItem; diff --git a/src/Errors/Exceptions/DuplicateParameterException.php b/src/Errors/Exceptions/DuplicateParameterException.php index c090f78..848ef2a 100644 --- a/src/Errors/Exceptions/DuplicateParameterException.php +++ b/src/Errors/Exceptions/DuplicateParameterException.php @@ -4,6 +4,4 @@ use InvalidArgumentException; -class DuplicateParameterException extends InvalidArgumentException -{ -} +class DuplicateParameterException extends InvalidArgumentException {} diff --git a/src/Errors/Exceptions/InvalidCastException.php b/src/Errors/Exceptions/InvalidCastException.php index b6f4cbf..3790799 100644 --- a/src/Errors/Exceptions/InvalidCastException.php +++ b/src/Errors/Exceptions/InvalidCastException.php @@ -4,6 +4,4 @@ use Exception; -class InvalidCastException extends Exception -{ -} +class InvalidCastException extends Exception {} diff --git a/src/Errors/Exceptions/InvalidParameterException.php b/src/Errors/Exceptions/InvalidParameterException.php index 123a70e..f5375d8 100644 --- a/src/Errors/Exceptions/InvalidParameterException.php +++ b/src/Errors/Exceptions/InvalidParameterException.php @@ -4,6 +4,4 @@ use InvalidArgumentException; -class InvalidParameterException extends InvalidArgumentException -{ -} +class InvalidParameterException extends InvalidArgumentException {} diff --git a/src/Errors/Exceptions/UnsupportedNodeException.php b/src/Errors/Exceptions/UnsupportedNodeException.php index 19fdd78..e205dda 100644 --- a/src/Errors/Exceptions/UnsupportedNodeException.php +++ b/src/Errors/Exceptions/UnsupportedNodeException.php @@ -4,6 +4,4 @@ use Exception; -class UnsupportedNodeException extends Exception -{ -} +class UnsupportedNodeException extends Exception {} diff --git a/src/Nodes/AbstractNode.php b/src/Nodes/AbstractNode.php index f3ff2db..9fb3e4c 100644 --- a/src/Nodes/AbstractNode.php +++ b/src/Nodes/AbstractNode.php @@ -174,9 +174,7 @@ public function getRootNodes(): NodeCollection return $this->getDirectChildren(); } - public function resolveStructures(): void - { - } + public function resolveStructures(): void {} public function getDirectChildren(): NodeCollection { diff --git a/src/Nodes/ArgumentGroupNode.php b/src/Nodes/ArgumentGroupNode.php index 2e01d88..e00368d 100644 --- a/src/Nodes/ArgumentGroupNode.php +++ b/src/Nodes/ArgumentGroupNode.php @@ -74,7 +74,7 @@ public function getValues(): Collection return collect([$this->innerContent]); } - $results = (new StringSplitter())->split($this->innerContent); + $results = (new StringSplitter)->split($this->innerContent); $lastIndex = count($results) - 1; return collect($results)->map(function ($value, $i) use ($lastIndex) { @@ -93,7 +93,7 @@ public function getArgValues(): Collection return collect([$this->innerContent]); } - return collect((new ArgStringSplitter())->split($this->innerContent)); + return collect((new ArgStringSplitter)->split($this->innerContent)); } public function clone(?DirectiveNode $newOwner = null): ArgumentGroupNode diff --git a/src/Nodes/CommentNode.php b/src/Nodes/CommentNode.php index 87c2443..7e45bc4 100644 --- a/src/Nodes/CommentNode.php +++ b/src/Nodes/CommentNode.php @@ -52,7 +52,7 @@ public function setContent(string $content, bool $preserveOriginalWhitespace = t public function clone(): CommentNode { - $commentNode = new CommentNode(); + $commentNode = new CommentNode; $this->copyBasicDetailsTo($commentNode); $commentNode->innerContent = $this->innerContent; diff --git a/src/Nodes/Components/ComponentNode.php b/src/Nodes/Components/ComponentNode.php index 2ffda68..9ac0c12 100644 --- a/src/Nodes/Components/ComponentNode.php +++ b/src/Nodes/Components/ComponentNode.php @@ -166,7 +166,7 @@ public function getName(): string|ParameterNode public function clone(): ComponentNode { - $component = new ComponentNode(); + $component = new ComponentNode; $this->copyBasicDetailsTo($component); $component->isSelfClosing = $this->isSelfClosing; diff --git a/src/Nodes/Components/Concerns/ManagesComponentParameters.php b/src/Nodes/Components/Concerns/ManagesComponentParameters.php index ffe43b2..b56171b 100644 --- a/src/Nodes/Components/Concerns/ManagesComponentParameters.php +++ b/src/Nodes/Components/Concerns/ManagesComponentParameters.php @@ -19,7 +19,7 @@ public function addParameterFromText(string $parameterContent): void $param = ParameterFactory::parameterFromText($parameterContent); if ($param == null) { - throw new InvalidParameterException(); + throw new InvalidParameterException; } $this->addParameter($param); diff --git a/src/Nodes/Components/ParameterAttribute.php b/src/Nodes/Components/ParameterAttribute.php index e80cec0..f0eb9d9 100644 --- a/src/Nodes/Components/ParameterAttribute.php +++ b/src/Nodes/Components/ParameterAttribute.php @@ -10,7 +10,7 @@ class ParameterAttribute extends BaseNode public function clone(): ParameterAttribute { - $attribute = new ParameterAttribute(); + $attribute = new ParameterAttribute; $this->copyBasicDetailsTo($attribute); $attribute->content = $this->content; diff --git a/src/Nodes/Components/ParameterFactory.php b/src/Nodes/Components/ParameterFactory.php index 267d5ff..0c1e6ca 100644 --- a/src/Nodes/Components/ParameterFactory.php +++ b/src/Nodes/Components/ParameterFactory.php @@ -13,7 +13,7 @@ class ParameterFactory */ public static function fromText(string $parameterContent): array { - $componentParser = new ComponentParser(); + $componentParser = new ComponentParser; return $componentParser->parseOnlyParameters($parameterContent); } diff --git a/src/Nodes/Components/ParameterNode.php b/src/Nodes/Components/ParameterNode.php index ffb2103..fb22e8f 100644 --- a/src/Nodes/Components/ParameterNode.php +++ b/src/Nodes/Components/ParameterNode.php @@ -102,7 +102,7 @@ public function hasValue(): bool public function clone(): ParameterNode { - $parameter = new ParameterNode(); + $parameter = new ParameterNode; $this->copyBasicDetailsTo($parameter); $parameter->nameNode = $this->nameNode?->clone(); diff --git a/src/Nodes/DirectiveNode.php b/src/Nodes/DirectiveNode.php index 0016665..0b1c3f7 100644 --- a/src/Nodes/DirectiveNode.php +++ b/src/Nodes/DirectiveNode.php @@ -279,7 +279,7 @@ public function getValue(): ?string public function clone(): DirectiveNode { - $directive = new DirectiveNode(); + $directive = new DirectiveNode; $this->copyBasicDetailsTo($directive); $directive->isClosingDirective = $this->isClosingDirective; diff --git a/src/Nodes/EchoNode.php b/src/Nodes/EchoNode.php index e04b326..fd8d849 100644 --- a/src/Nodes/EchoNode.php +++ b/src/Nodes/EchoNode.php @@ -73,7 +73,7 @@ public function setInnerContent(string $innerContent): void public function clone(): EchoNode { - $echo = new EchoNode(); + $echo = new EchoNode; $this->copyBasicDetailsTo($echo); $echo->innerContent = $this->innerContent; diff --git a/src/Nodes/Fragments/Fragment.php b/src/Nodes/Fragments/Fragment.php index 1d46625..c0ce81f 100644 --- a/src/Nodes/Fragments/Fragment.php +++ b/src/Nodes/Fragments/Fragment.php @@ -11,6 +11,6 @@ public function __construct() { parent::__construct(); - $this->position = new Position(); + $this->position = new Position; } } diff --git a/src/Nodes/LiteralNode.php b/src/Nodes/LiteralNode.php index a49f5db..b1af412 100644 --- a/src/Nodes/LiteralNode.php +++ b/src/Nodes/LiteralNode.php @@ -46,7 +46,7 @@ public function setContent(string $content, bool $preserveOriginalWhitespace = t public function clone(): LiteralNode { - $literal = new LiteralNode(); + $literal = new LiteralNode; $this->copyBasicDetailsTo($literal); $literal->originalLeadingWhitespace = $this->originalLeadingWhitespace; diff --git a/src/Nodes/PhpBlockNode.php b/src/Nodes/PhpBlockNode.php index 2e7aa46..3772f1e 100644 --- a/src/Nodes/PhpBlockNode.php +++ b/src/Nodes/PhpBlockNode.php @@ -43,7 +43,7 @@ public function setContent(string $content, bool $preserveOriginalWhitespace = t public function clone(): PhpBlockNode { - $phpBlock = new PhpBlockNode(); + $phpBlock = new PhpBlockNode; $this->copyBasicDetailsTo($phpBlock); $phpBlock->originalTrailingWhitespace = $this->originalTrailingWhitespace; $phpBlock->originalLeadingWhitespace = $this->originalLeadingWhitespace; diff --git a/src/Nodes/PhpTagNode.php b/src/Nodes/PhpTagNode.php index dacd4c2..5f7f98a 100644 --- a/src/Nodes/PhpTagNode.php +++ b/src/Nodes/PhpTagNode.php @@ -70,7 +70,7 @@ public function setType(PhpTagType $type, bool $preserveOriginalWhitespace = tru public function clone(): PhpTagNode { - $phpTag = new PhpTagNode(); + $phpTag = new PhpTagNode; $this->copyBasicDetailsTo($phpTag); $phpTag->innerContent = $this->innerContent; $phpTag->originalLeadingWhitespace = $this->originalLeadingWhitespace; diff --git a/src/Nodes/Position.php b/src/Nodes/Position.php index c099907..638a8db 100644 --- a/src/Nodes/Position.php +++ b/src/Nodes/Position.php @@ -58,7 +58,7 @@ public function contains(int $offset): bool public function clone(): Position { - $position = new Position(); + $position = new Position; $position->startOffset = $this->startOffset; $position->startLine = $this->startLine; diff --git a/src/Nodes/Structures/BaseStructureNode.php b/src/Nodes/Structures/BaseStructureNode.php index 343671e..b42e1eb 100644 --- a/src/Nodes/Structures/BaseStructureNode.php +++ b/src/Nodes/Structures/BaseStructureNode.php @@ -26,7 +26,5 @@ public function getNodes(): NodeCollection return $this->constructedFrom->getNodes(); } - public function resolveStructures(): void - { - } + public function resolveStructures(): void {} } diff --git a/src/Nodes/VerbatimNode.php b/src/Nodes/VerbatimNode.php index 0865260..509f47c 100644 --- a/src/Nodes/VerbatimNode.php +++ b/src/Nodes/VerbatimNode.php @@ -43,7 +43,7 @@ public function setContent(string $content, bool $preserveOriginalWhitespace = t public function clone(): VerbatimNode { - $verbatim = new VerbatimNode(); + $verbatim = new VerbatimNode; $this->copyBasicDetailsTo($verbatim); $verbatim->originalTrailingWhitespace = $this->originalTrailingWhitespace; $verbatim->originalLeadingWhitespace = $this->originalLeadingWhitespace; diff --git a/src/Parser/AbstractParser.php b/src/Parser/AbstractParser.php index a5c1b69..ac2f57a 100644 --- a/src/Parser/AbstractParser.php +++ b/src/Parser/AbstractParser.php @@ -110,7 +110,7 @@ public function getOriginalContent(): string protected function makePosition(int $startOffset, int $endOffset): Position { - $position = new Position(); + $position = new Position; $position->startOffset = $startOffset; $position->endOffset = $endOffset; @@ -223,7 +223,7 @@ protected function isStartingMultilinePhpComment(): bool protected function abandonParse(ErrorType $reason): ScanResult { - $result = new ScanResult(); + $result = new ScanResult; $result->abandonReason = $reason; $result->didAbandon = true; $result->abandonedOffset = $this->startLocation + $this->currentIndex; @@ -432,7 +432,7 @@ protected function scanToEndOfComponentTag($location): ?ScanResult if ($this->cur == self::C_ForwardSlash && $this->next == self::C_RightAngleBracket) { $this->advance(); - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -440,7 +440,7 @@ protected function scanToEndOfComponentTag($location): ?ScanResult } if ($this->cur == self::C_RightAngleBracket) { - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -467,7 +467,7 @@ protected function scanToEndOfComment($location): ?ScanResult $this->advance(); $this->advance(); - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -494,7 +494,7 @@ protected function scanToEndOfPhp($location): ?ScanResult $this->currentContent[] = $this->cur; if ($this->cur == self::C_RightAngleBracket && $this->prev == self::C_QuestionMark) { - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -525,7 +525,7 @@ protected function scanToEndOfEcho($location): ?ScanResult $this->currentContent[] = $this->cur; if ($this->cur == self::C_RightCurlyBracket && $this->prev == self::C_RightCurlyBracket) { - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -558,7 +558,7 @@ protected function scanToEndOfTripleEcho($location): ?ScanResult if ($this->cur == self::C_RightCurlyBracket && $this->prev == self::C_RightCurlyBracket && $this->next == self::C_RightCurlyBracket) { $this->advance(); - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -591,7 +591,7 @@ protected function scanToEndOfRawEcho($location): ?ScanResult if ($this->cur == self::C_ExclamationMark && $this->prev == self::C_ExclamationMark && $this->next == self::C_RightCurlyBracket) { $this->advance(); - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->offset = $location; $scanResult->content = implode('', $this->currentContent); @@ -639,7 +639,7 @@ protected function scanToEndOfArgumentGroup($location): ?ScanResult $currentStack -= 1; if ($currentStack <= 0) { - $result = new ScanResult(); + $result = new ScanResult; $result->content = implode('', $this->currentContent); $result->offset = $location; @@ -662,7 +662,7 @@ protected function peekNextNonWhitespaceAt($location): ?ScanResult continue; } - $result = new ScanResult(); + $result = new ScanResult; $result->content = $cur; $result->offset = $this->startIndex + $i; @@ -687,7 +687,7 @@ protected function fetchNextNonWhitespaceAt($location): ?ScanResult continue; } - $result = new ScanResult(); + $result = new ScanResult; $result->content = $this->cur; $result->offset = $this->startIndex + $this->currentIndex; diff --git a/src/Parser/ComponentParser.php b/src/Parser/ComponentParser.php index 8e01fd8..dfc9ac6 100644 --- a/src/Parser/ComponentParser.php +++ b/src/Parser/ComponentParser.php @@ -90,7 +90,7 @@ public function parse(ComponentNode $node) private function parseParameter($content, $containsValue, $startIndex): ParameterNode { $relativeStart = $this->parameterContentStartOffset + $startIndex; - $parameter = new ParameterNode(); + $parameter = new ParameterNode; $parameter->content = $content; $parameter->position = $this->makePosition($relativeStart, mb_strlen($content) + $relativeStart - 1); @@ -99,7 +99,7 @@ private function parseParameter($content, $containsValue, $startIndex): Paramete $name = trim(mb_substr($content, 0, $breakOn)); $parameter->name = $name; - $parameter->nameNode = new ParameterAttribute(); + $parameter->nameNode = new ParameterAttribute; $parameter->nameNode->content = $name; $parameter->nameNode->position = $this->makePosition($relativeStart, $relativeStart + mb_strlen($name) - 1); @@ -111,14 +111,14 @@ private function parseParameter($content, $containsValue, $startIndex): Paramete $valueStart = $relativeStart + $breakOn + $diff; $valueEnd = $valueStart + $valueContentLength - 1; - $parameter->valueNode = new ParameterAttribute(); + $parameter->valueNode = new ParameterAttribute; $parameter->valueNode->content = $valueContent; $parameter->valueNode->position = $this->makePosition($valueStart + 1, $valueEnd + 1); $parameter->value = mb_substr($valueContent, 1, -1); } else { $parameter->name = $content; - $parameter->nameNode = new ParameterAttribute(); + $parameter->nameNode = new ParameterAttribute; $parameter->nameNode->content = $content; $parameter->nameNode->position = $this->makePosition($relativeStart, $relativeStart + mb_strlen($content) - 1); $parameter->type = ParameterType::Attribute; @@ -169,7 +169,7 @@ private function makeEchoParameter(ParameterType $type, int $startIndex): Parame } } - $echoParameter = new ParameterNode(); + $echoParameter = new ParameterNode; $echoParameter->content = $content; // TODO: Add test for this position. $echoParameter->position = $this->makePosition($this->parameterContentStartOffset + $startIndex, $this->parameterContentStartOffset + $this->currentIndex + mb_strlen($content)); @@ -291,7 +291,7 @@ private function extractComponentName(): ?ScanResult $this->currentContent[] = $this->cur; if ($this->next == null || ctype_space($this->next)) { - $scanResult = new ScanResult(); + $scanResult = new ScanResult; $scanResult->content = implode('', $this->currentContent); $scanResult->offset = 0; diff --git a/src/Parser/DocumentParser.php b/src/Parser/DocumentParser.php index ac3eb05..28f913f 100644 --- a/src/Parser/DocumentParser.php +++ b/src/Parser/DocumentParser.php @@ -84,7 +84,7 @@ class DocumentParser extends AbstractParser public function __construct() { - $this->componentParser = new ComponentParser(); + $this->componentParser = new ComponentParser; $this->withCoreDirectives(); } @@ -363,7 +363,7 @@ protected function prepareInput(string $content): void $matchOffset = $candidate[1]; if ($matchText == self::C_BladeCommentStart) { - $commentEntry = new IndexElement(); + $commentEntry = new IndexElement; $commentEntry->type = IndexElementType::BladeComment; $commentEntry->startOffset = $matchOffset; $commentEntry->content = $matchText; @@ -390,7 +390,7 @@ protected function prepareInput(string $content): void continue; } - $directiveEntry = new IndexElement(); + $directiveEntry = new IndexElement; $directiveEntry->type = IndexElementType::Directive; $directiveEntry->content = $content; $directiveEntry->startOffset = $matchOffset; @@ -399,7 +399,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_StartPhp) { - $phpEntry = new IndexElement(); + $phpEntry = new IndexElement; $phpEntry->type = IndexElementType::PhpOpenTag; $phpEntry->content = self::C_StartPhp; $phpEntry->startOffset = $matchOffset; @@ -408,7 +408,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_StartPhpEcho) { - $phpEntry = new IndexElement(); + $phpEntry = new IndexElement; $phpEntry->type = IndexElementType::PhpOpenTagWithEcho; $phpEntry->content = self::C_StartPhpEcho; $phpEntry->startOffset = $matchOffset; @@ -420,7 +420,7 @@ protected function prepareInput(string $content): void // Just ignore these because they will be escaped content. continue; } elseif ($matchText == self::C_BladeRawEcho) { - $bladeEntry = new IndexElement(); + $bladeEntry = new IndexElement; $bladeEntry->type = IndexElementType::BladeRawEcho; $bladeEntry->content = self::C_BladeRawEcho; $bladeEntry->startOffset = $matchOffset; @@ -435,7 +435,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_BladeEchoThree) { - $bladeEntry = new IndexElement(); + $bladeEntry = new IndexElement; $bladeEntry->type = IndexElementType::BladeEchoThree; $bladeEntry->content = self::C_BladeEchoThree; $bladeEntry->startOffset = $matchOffset; @@ -444,7 +444,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_BladeEcho) { - $bladeEntry = new IndexElement(); + $bladeEntry = new IndexElement; $bladeEntry->type = IndexElementType::BladeEcho; $bladeEntry->content = self::C_BladeEcho; $bladeEntry->startOffset = $matchOffset; @@ -453,7 +453,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_BladeComponentStart || $matchText == self::C_BladeComponentStartNamespaced) { - $componentEntry = new IndexElement(); + $componentEntry = new IndexElement; $componentEntry->type = IndexElementType::ComponentOpenTag; $componentEntry->content = $matchText; $componentEntry->startOffset = $matchOffset; @@ -462,7 +462,7 @@ protected function prepareInput(string $content): void continue; } elseif ($matchText == self::C_BladeClosingComponentStart || $matchText == self::C_BladeClosingComponentStartNamespaced) { - $componentEntry = new IndexElement(); + $componentEntry = new IndexElement; $componentEntry->type = IndexElementType::ComponentClosingTag; $componentEntry->content = $matchText; $componentEntry->startOffset = $matchOffset; @@ -471,7 +471,7 @@ protected function prepareInput(string $content): void continue; } elseif (Str::startsWith($matchText, 'isTagCloseCustomComponent($matchText)) { - $customComponentClose = new IndexElement(); + $customComponentClose = new IndexElement; $customComponentClose->type = IndexElementType::CustomComponentClosingTag; $customComponentClose->content = $matchText; $customComponentClose->startOffset = $matchOffset; @@ -480,7 +480,7 @@ protected function prepareInput(string $content): void continue; } elseif (Str::startsWith($matchText, '<') && $this->isTagStartCustomComponent($matchText)) { - $customComponentEntry = new IndexElement(); + $customComponentEntry = new IndexElement; $customComponentEntry->type = IndexElementType::CustomComponentOpenTag; $customComponentEntry->content = $matchText; $customComponentEntry->startOffset = $matchOffset; @@ -518,7 +518,7 @@ private function makeLiteralNode($start, $end): ?LiteralNode } $content = mb_substr($this->content, $start, $end - $start); - $bladeLiteralNode = new LiteralNode(); + $bladeLiteralNode = new LiteralNode; $bladeLiteralNode->position = $this->makePosition($start, $start + mb_strlen($content) - 1); $bladeLiteralNode->content = $content; $bladeLiteralNode->originalLeadingWhitespace = StringUtilities::extractLeadingWhitespace($content); @@ -542,7 +542,7 @@ private function makeCustomComponentNode(string $type, int $startLocation, strin $innerContent = $content; $typeLen = mb_strlen($type); - $componentNode = new ComponentNode(); + $componentNode = new ComponentNode; $componentNode->isCustomComponent = true; $componentNode->componentPrefix = $type; $componentNode->content = $content; @@ -574,7 +574,7 @@ private function makeCustomComponentNode(string $type, int $startLocation, strin private function makeComponentNode(int $startLocation, string $content): ComponentNode { - $componentNode = new ComponentNode(); + $componentNode = new ComponentNode; $componentNode->content = $content; $componentNode->position = $this->makePosition($startLocation, $startLocation + mb_strlen($content) - 1); @@ -666,7 +666,7 @@ public function parse(string $document): array continue; } - $commentNode = new CommentNode(); + $commentNode = new CommentNode; $commentNode->position = $this->makePosition($indexEntry->startOffset, $indexEntry->startOffset + mb_strlen($commentContent->content) - 1); $commentNode->content = $commentContent->content; $commentNode->innerContent = mb_substr($commentNode->content, 4, -4); @@ -739,7 +739,7 @@ public function parse(string $document): array } if ($endVerbatim != null) { - $verbatimNode = new VerbatimNode(); + $verbatimNode = new VerbatimNode; $verbatimNode->position = $this->makePosition($indexEntry->startOffset, $endVerbatim->startOffset + mb_strlen($endVerbatim->content)); $verbatimNode->content = mb_substr($this->content, $indexEntry->startOffset, $verbatimNode->position->endOffset - $indexEntry->startOffset + 1); $verbatimNode->innerContent = mb_substr($verbatimNode->content, 9, -12); @@ -776,7 +776,7 @@ public function parse(string $document): array } if ($endPhpEntry != null) { - $bladePhpNode = new PhpBlockNode(); + $bladePhpNode = new PhpBlockNode; $bladePhpNode->position = $this->makePosition($indexEntry->startOffset, $endPhpEntry->startOffset + mb_strlen($endPhpEntry->content)); $bladePhpNode->content = mb_substr($this->content, $indexEntry->startOffset, $bladePhpNode->position->endOffset - $indexEntry->startOffset + 1); $bladePhpNode->innerContent = mb_substr($bladePhpNode->content, 4, -7); @@ -794,7 +794,7 @@ public function parse(string $document): array } } - $directiveNode = new DirectiveNode(); + $directiveNode = new DirectiveNode; $directiveStart = $indexEntry->startOffset; $directiveNameEnd = $directiveStart + mb_strlen($indexEntry->content); @@ -827,12 +827,12 @@ public function parse(string $document): array continue; } elseif ($indexEntry->type == IndexElementType::PhpOpenTag || $indexEntry->type == IndexElementType::PhpOpenTagWithEcho) { - $phpTagNode = new PhpTagNode(); + $phpTagNode = new PhpTagNode; $phpContent = $this->scanToEndOfPhp($indexEntry->startOffset); // We will just assume that the PHP content continues to the end of the document. if ($phpContent == null) { - $phpContent = new ScanResult(); + $phpContent = new ScanResult; $phpContent->offset = $indexEntry->startOffset; $phpContent->content = mb_substr($this->content, $indexEntry->startOffset); @@ -886,7 +886,7 @@ public function parse(string $document): array continue; } - $echoNode = new EchoNode(); + $echoNode = new EchoNode; $echoNode->type = EchoType::RawEcho; $echoNode->position = $this->makePosition($indexEntry->startOffset, $echoContent->offset + mb_strlen($echoContent->content) - 1); $echoNode->content = $echoContent->content; @@ -909,7 +909,7 @@ public function parse(string $document): array continue; } - $echoNode = new EchoNode(); + $echoNode = new EchoNode; $echoNode->type = EchoType::TripleEcho; $echoNode->position = $this->makePosition($indexEntry->startOffset, $echoContent->offset + mb_strlen($echoContent->content) - 1); $echoNode->content = $echoContent->content; @@ -932,7 +932,7 @@ public function parse(string $document): array continue; } - $echoNode = new EchoNode(); + $echoNode = new EchoNode; $echoNode->type = EchoType::Echo; $echoNode->position = $this->makePosition($indexEntry->startOffset, $echoContent->offset + mb_strlen($echoContent->content) - 1); $echoNode->content = $echoContent->content; diff --git a/src/Parser/HtmlFragments/FragmentAttributeParser.php b/src/Parser/HtmlFragments/FragmentAttributeParser.php index 7b4d99c..4e0327f 100644 --- a/src/Parser/HtmlFragments/FragmentAttributeParser.php +++ b/src/Parser/HtmlFragments/FragmentAttributeParser.php @@ -48,7 +48,7 @@ public function parse(HtmlFragment $fragment): array } foreach ($tempAttributes as $tempAttribute) { - $attribute = new FragmentParameter(); + $attribute = new FragmentParameter; $attribute->content = $tempAttribute[0]; diff --git a/src/Parser/HtmlFragments/FragmentsDocumentParser.php b/src/Parser/HtmlFragments/FragmentsDocumentParser.php index 8056c0b..6c05eb0 100644 --- a/src/Parser/HtmlFragments/FragmentsDocumentParser.php +++ b/src/Parser/HtmlFragments/FragmentsDocumentParser.php @@ -37,7 +37,7 @@ class FragmentsDocumentParser extends BaseFragmentParser public function __construct() { - $this->attributeParser = new FragmentAttributeParser(); + $this->attributeParser = new FragmentAttributeParser; } /** @@ -98,7 +98,7 @@ private function parseFragment(int $index): void return; } - $fragment = new HtmlFragment(); + $fragment = new HtmlFragment; $fragment->position = $this->makePosition($index, $this->position); $fragment->content = $this->buffer; $fragment->isSelfClosing = str($this->buffer)->endsWith('/>'); @@ -139,7 +139,7 @@ private function parseFragment(int $index): void // Create a Fragment representing the name. if (str($fragment->tagName)->trim()->length > 0) { - $fragment->name = new Fragment(); + $fragment->name = new Fragment; $fragment->name->content = $fragment->tagName; $fragment->name->position->startOffset = $fragment->position->startOffset + $documentContentStartOffset; @@ -151,7 +151,7 @@ private function parseFragment(int $index): void $innerContentStart = mb_strpos($fragment->documentContent, ' '); if ($innerContentStart !== false) { - $innerContentFragment = new Fragment(); + $innerContentFragment = new Fragment; $innerContentFragment->content = str($fragment->documentContent)->substr($innerContentStart)->trim(); // Calculate the start and end positions of the @@ -380,7 +380,7 @@ private function fillColumnAndLineNumbers() private function makePosition(int $startOffset, int $endOffset): Position { - $position = new Position(); + $position = new Position; $position->startOffset = $startOffset; $position->endOffset = $endOffset; diff --git a/src/Providers/ValidatorServiceProvider.php b/src/Providers/ValidatorServiceProvider.php index 0a3034a..491e59c 100644 --- a/src/Providers/ValidatorServiceProvider.php +++ b/src/Providers/ValidatorServiceProvider.php @@ -44,7 +44,7 @@ public function register() foreach ($validators as $validator) { $this->app->singleton($validator, function () use ($validator, $availableConfig, $globalIgnoreDirectives, $globalCustomDirectives) { /** @var AbstractNodeValidator $instance */ - $instance = new $validator(); + $instance = new $validator; $options = []; if (array_key_exists($validator, $availableConfig)) { diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 41a3f8e..2102fa6 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -39,7 +39,5 @@ public function boot() }); } - public function register() - { - } + public function register() {} } diff --git a/src/Validation/PhpSyntaxValidator.php b/src/Validation/PhpSyntaxValidator.php index f35cbd4..0142c79 100644 --- a/src/Validation/PhpSyntaxValidator.php +++ b/src/Validation/PhpSyntaxValidator.php @@ -28,7 +28,7 @@ class PhpSyntaxValidator public function __construct() { - $this->compilerOptions = new DocumentCompilerOptions(); + $this->compilerOptions = new DocumentCompilerOptions; $this->compilerOptions->throwExceptionOnUnknownComponentClass = false; $this->compilerOptions->ignoreDirectives = ValidatorServiceProvider::getIgnoreDirectives(); $this->compilerOptions->appendCallbacks[] = function (AppendState $state) { @@ -55,7 +55,7 @@ protected function resetState(): void public function checkDocument(Document $document, ?int $originalLine = null): PhpSyntaxValidationResult { $this->resetState(); - $syntaxResult = new PhpSyntaxValidationResult(); + $syntaxResult = new PhpSyntaxValidationResult; try { $compiled = $document->compile($this->compilerOptions); diff --git a/src/Validation/Validators/Documents/InvalidPhpDocumentValidator.php b/src/Validation/Validators/Documents/InvalidPhpDocumentValidator.php index af7f7aa..b8b3fd5 100644 --- a/src/Validation/Validators/Documents/InvalidPhpDocumentValidator.php +++ b/src/Validation/Validators/Documents/InvalidPhpDocumentValidator.php @@ -16,7 +16,7 @@ class InvalidPhpDocumentValidator extends AbstractDocumentValidator */ public function validate(Document $document): ?ValidationResult { - $syntaxValidator = new PhpSyntaxValidator(); + $syntaxValidator = new PhpSyntaxValidator; $result = $syntaxValidator->checkDocument($document); if (! $result->detectedErrors) { return null; diff --git a/src/Validation/Validators/NodeCompilationValidator.php b/src/Validation/Validators/NodeCompilationValidator.php index 8021d86..32c9cc8 100644 --- a/src/Validation/Validators/NodeCompilationValidator.php +++ b/src/Validation/Validators/NodeCompilationValidator.php @@ -24,8 +24,8 @@ public function validate(AbstractNode $node): ?ValidationResult return null; } - $syntaxValidator = new PhpSyntaxValidator(); - $result = new PhpSyntaxValidationResult(); + $syntaxValidator = new PhpSyntaxValidator; + $result = new PhpSyntaxValidationResult; if ($node instanceof EchoNode) { $result = $syntaxValidator->checkString($node->content, $node->position->startLine); diff --git a/src/Workspaces/Concerns/CompilesWorkspace.php b/src/Workspaces/Concerns/CompilesWorkspace.php index dd1c356..9d09288 100644 --- a/src/Workspaces/Concerns/CompilesWorkspace.php +++ b/src/Workspaces/Concerns/CompilesWorkspace.php @@ -3,7 +3,6 @@ namespace Stillat\BladeParser\Workspaces\Concerns; use Exception; -use Illuminate\Support\Str; use Stillat\BladeParser\Compiler\AppendState; use Stillat\BladeParser\Contracts\PathFormatter; use Stillat\BladeParser\Document\Document; @@ -129,7 +128,7 @@ public function getCompilerOptions(): DocumentCompilerOptions return $this->compilerOptions; } - $options = new DocumentCompilerOptions(); + $options = new DocumentCompilerOptions; $options->throwExceptionOnUnknownComponentClass = false; $options->ignoreDirectives = $this->ignoreDirectives; diff --git a/tests/Compiler/BladeComponentTagCompilerTest.php b/tests/Compiler/BladeComponentTagCompilerTest.php index 4aabfc2..a92f98f 100644 --- a/tests/Compiler/BladeComponentTagCompilerTest.php +++ b/tests/Compiler/BladeComponentTagCompilerTest.php @@ -3,16 +3,16 @@ uses(\Stillat\BladeParser\Tests\ParserTestCase::class); use Illuminate\Container\Container; -use \Stillat\BladeParser\Tests\Compiler\TestProfileComponent; -use \Illuminate\View\Component; -use \Stillat\BladeParser\Tests\Compiler\TestAlertComponent; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; +use Illuminate\View\Component; use Illuminate\View\ComponentAttributeBag; +use Mockery as m; use Stillat\BladeParser\Compiler\CompilerServices\StringUtilities; use Stillat\BladeParser\Contracts\CustomComponentTagCompiler; use Stillat\BladeParser\Nodes\Components\ComponentNode; -use Mockery as m; +use Stillat\BladeParser\Tests\Compiler\TestAlertComponent; +use Stillat\BladeParser\Tests\Compiler\TestProfileComponent; afterEach(function () { m::close(); @@ -797,7 +797,7 @@ $compiler->registerCustomCompiler('custom', (new class implements CustomComponentTagCompiler { - function compile(ComponentNode $component): string + public function compile(ComponentNode $component): string { if ($component->isClosingTag && ! $component->isSelfClosing) { return 'Just a closing tag.'; @@ -835,7 +835,7 @@ function compile(ComponentNode $component): string $compiler->registerCustomCompiler('custom', (new class implements CustomComponentTagCompiler { - function compile(ComponentNode $component): ?string + public function compile(ComponentNode $component): ?string { if ($component->isClosingTag && ! $component->isSelfClosing) { return 'Just a closing tag.'; @@ -869,7 +869,7 @@ function compile(ComponentNode $component): ?string $compiler->registerCustomCompiler('custom', (new class implements CustomComponentTagCompiler { - function compile(ComponentNode $component): ?string + public function compile(ComponentNode $component): ?string { $useDefault = $component->getParameter('use-default')->value; diff --git a/tests/Compiler/BladeComponentsTest.php b/tests/Compiler/BladeComponentsTest.php index 412e609..3289cd2 100644 --- a/tests/Compiler/BladeComponentsTest.php +++ b/tests/Compiler/BladeComponentsTest.php @@ -1,8 +1,8 @@ $template compiler->compileString($blade))->remove([''])); })->with('handlerLogicDataProvider'); diff --git a/tests/Compiler/ComponentStub.php b/tests/Compiler/ComponentStub.php index 984d6c4..e087357 100644 --- a/tests/Compiler/ComponentStub.php +++ b/tests/Compiler/ComponentStub.php @@ -6,8 +6,8 @@ class ComponentStub extends Component { - function render() + public function render() { return ''; } -} \ No newline at end of file +} diff --git a/tests/Compiler/CustomCompiler.php b/tests/Compiler/CustomCompiler.php index b5f08b5..981c5d1 100644 --- a/tests/Compiler/CustomCompiler.php +++ b/tests/Compiler/CustomCompiler.php @@ -7,7 +7,7 @@ class CustomCompiler implements CustomComponentTagCompiler { - function compile(ComponentNode $component): ?string + public function compile(ComponentNode $component): ?string { return 'My custom compilation result!'; } diff --git a/tests/Compiler/CustomTransformer.php b/tests/Compiler/CustomTransformer.php index 9610852..1209ca4 100644 --- a/tests/Compiler/CustomTransformer.php +++ b/tests/Compiler/CustomTransformer.php @@ -7,7 +7,7 @@ class CustomTransformer extends NodeTransformer { - function transformNode($node): ?string + public function transformNode($node): ?string { if (! $node instanceof DirectiveNode || $node->content != 'custom') { return null; @@ -17,4 +17,4 @@ function transformNode($node): ?string return '@include("something-here")'; } -} \ No newline at end of file +} diff --git a/tests/Compiler/InputWithSlot.php b/tests/Compiler/InputWithSlot.php index 87e33dc..04a40f0 100644 --- a/tests/Compiler/InputWithSlot.php +++ b/tests/Compiler/InputWithSlot.php @@ -2,13 +2,11 @@ namespace Stillat\BladeParser\Tests\Compiler; - - use Illuminate\View\Component; class InputWithSlot extends Component { - function render() + public function render() { return 'input'; } diff --git a/tests/Compiler/NodeTransformerTest.php b/tests/Compiler/NodeTransformerTest.php index 01a2fe2..62df22c 100644 --- a/tests/Compiler/NodeTransformerTest.php +++ b/tests/Compiler/NodeTransformerTest.php @@ -1,11 +1,5 @@ title = $title; } - function render() + public function render() { return 'alert'; } -} \ No newline at end of file +} diff --git a/tests/Compiler/TestProfileComponent.php b/tests/Compiler/TestProfileComponent.php index ec41fc8..328b4f6 100644 --- a/tests/Compiler/TestProfileComponent.php +++ b/tests/Compiler/TestProfileComponent.php @@ -2,17 +2,16 @@ namespace Stillat\BladeParser\Tests\Compiler; - use Illuminate\View\Component; class TestProfileComponent extends Component { - function __construct($userId = 'foo') + public function __construct($userId = 'foo') { $this->userId = $userId; } - function render() + public function render() { return 'profile'; } diff --git a/tests/CompilerServices/ArgStringSplitterTest.php b/tests/CompilerServices/ArgStringSplitterTest.php index a87c2e4..9fb382d 100644 --- a/tests/CompilerServices/ArgStringSplitterTest.php +++ b/tests/CompilerServices/ArgStringSplitterTest.php @@ -4,7 +4,7 @@ use Stillat\BladeParser\Compiler\CompilerServices\ArgStringSplitter; beforeEach(function () { - $this->splitter = new ArgStringSplitter(); + $this->splitter = new ArgStringSplitter; }); test('argument string splitting', function () { @@ -77,4 +77,4 @@ '[bar, baz, (1,2,3,4,), "foo, bar, baz"]', '(true == false) ? $this : $that', ]); -}); \ No newline at end of file +}); diff --git a/tests/CompilerServices/LoopVariablesTest.php b/tests/CompilerServices/LoopVariablesTest.php index ba6847d..a238f9e 100644 --- a/tests/CompilerServices/LoopVariablesTest.php +++ b/tests/CompilerServices/LoopVariablesTest.php @@ -4,7 +4,7 @@ use Stillat\BladeParser\Compiler\CompilerServices\LoopVariablesExtractor; beforeEach(function () { - $this->extractor = new LoopVariablesExtractor(); + $this->extractor = new LoopVariablesExtractor; }); test('basic loop variable extraction', function () { @@ -38,4 +38,4 @@ ['as $user'], ['$users as '], ]; -}); \ No newline at end of file +}); diff --git a/tests/CompilerServices/StringSplitterTest.php b/tests/CompilerServices/StringSplitterTest.php index 38134f1..ddc48b8 100644 --- a/tests/CompilerServices/StringSplitterTest.php +++ b/tests/CompilerServices/StringSplitterTest.php @@ -4,7 +4,7 @@ use Stillat\BladeParser\Compiler\CompilerServices\StringSplitter; beforeEach(function () { - $this->splitter = new StringSplitter(); + $this->splitter = new StringSplitter; }); test('basic string splitting', function () { @@ -71,4 +71,4 @@ ]; expect($result)->toBe($expected); -}); \ No newline at end of file +}); diff --git a/tests/Examples/DocumentExampleTest.php b/tests/Examples/DocumentExampleTest.php index 26a31c6..e87b7c8 100644 --- a/tests/Examples/DocumentExampleTest.php +++ b/tests/Examples/DocumentExampleTest.php @@ -2,17 +2,16 @@ uses(\Stillat\BladeParser\Tests\ParserTestCase::class); use Stillat\BladeParser\Document\Document; -use \Stillat\BladeParser\Validation\AbstractNodeValidator; use Stillat\BladeParser\Errors\ConstructContext; use Stillat\BladeParser\Errors\ErrorType; use Stillat\BladeParser\Nodes\AbstractNode; use Stillat\BladeParser\Nodes\DirectiveNode; use Stillat\BladeParser\Nodes\EchoNode; use Stillat\BladeParser\Nodes\LiteralNode; +use Stillat\BladeParser\Validation\AbstractNodeValidator; use Stillat\BladeParser\Validation\ValidationResult; use Stillat\BladeParser\Validation\Validators\InconsistentIndentationLevelValidator; - test('remove node', function () { $template = <<<'BLADE' @@ -717,7 +716,7 @@ test('with validator', function () { $validator = (new class extends AbstractNodeValidator { - function validate(AbstractNode $node): ValidationResult|array|null + public function validate(AbstractNode $node): ValidationResult|array|null { return null; } @@ -747,7 +746,7 @@ function validate(AbstractNode $node): ValidationResult|array|null BLADE; $doc = Document::fromText($template); - $doc->withValidator(new InconsistentIndentationLevelValidator()); + $doc->withValidator(new InconsistentIndentationLevelValidator); $doc->validate(); // Returns: diff --git a/tests/Parser/BasicParserNodesTest.php b/tests/Parser/BasicParserNodesTest.php index 8e9f29e..0cab8bc 100644 --- a/tests/Parser/BasicParserNodesTest.php +++ b/tests/Parser/BasicParserNodesTest.php @@ -1,7 +1,6 @@ compiler = new Compiler( - new DocumentParser() + new DocumentParser ); $this->compiler->resetState(); @@ -71,7 +71,7 @@ protected function registerDirective($directives) protected function parser(): DocumentParser { - $parser = new DocumentParser(); + $parser = new DocumentParser; $parser->setDirectiveNames(array_keys(Blade::getCustomDirectives())); @@ -80,7 +80,7 @@ protected function parser(): DocumentParser protected function parseNodes($template): array { - $parser = new DocumentParser(); + $parser = new DocumentParser; $parser->setDirectiveNames(array_keys(Blade::getCustomDirectives())); @@ -89,7 +89,7 @@ protected function parseNodes($template): array protected function getDocument($template, array $customComponentTags = []): Document { - $parser = new DocumentParser(); + $parser = new DocumentParser; $parser->registerCustomComponentTags($customComponentTags); $parser->setDirectiveNames(array_keys(Blade::getCustomDirectives()))->parse($template); @@ -242,7 +242,7 @@ protected function getWorkspaceDirectory(string $workspace): string protected function getWorkspace(string $workspaceName): Workspace { - $workspace = new Workspace(); + $workspace = new Workspace; $workspace->addDirectory($this->getWorkspaceDirectory($workspaceName)); return $workspace; diff --git a/tests/Pest.php b/tests/Pest.php index edc3c60..93f10d8 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -2,17 +2,17 @@ use Illuminate\Container\Container; use Illuminate\Contracts\View\Factory; +use Mockery as m; use Stillat\BladeParser\Compiler\CompilerServices\CoreDirectiveRetriever; use Stillat\BladeParser\Compiler\ComponentNodeCompiler; use Stillat\BladeParser\Compiler\ComponentTagCompiler; use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Document\DocumentOptions; -use Stillat\BladeParser\Nodes\DirectiveNode; use Stillat\BladeParser\Nodes\AbstractNode; use Stillat\BladeParser\Nodes\Components\ComponentNode; +use Stillat\BladeParser\Nodes\DirectiveNode; use Stillat\BladeParser\Parser\DocumentParser; use Stillat\BladeParser\Tests\Compiler\CustomTransformer; -use Mockery as m; /* |-------------------------------------------------------------------------- @@ -155,14 +155,14 @@ function transformDocument(string $template, bool $withCoreDirectives): string customDirectives: ['custom', 'endcustom'] ))->resolveStructures(); - return (new CustomTransformer())->transformDocument($doc); + return (new CustomTransformer)->transformDocument($doc); } function compiler(array $aliases = [], array $namespaces = []): ComponentTagCompiler { $compiler = new ComponentTagCompiler( - new ComponentNodeCompiler(), - new DocumentParser() + new ComponentNodeCompiler, + new DocumentParser ); $compiler->setAliases($aliases); diff --git a/tests/ScratchTest.php b/tests/ScratchTest.php index dde65a9..8c992a2 100644 --- a/tests/ScratchTest.php +++ b/tests/ScratchTest.php @@ -1,5 +1,4 @@ content)->toBe('if'); $this->assertStringContainsString('Literal Final', $n2->content); }); - diff --git a/tests/Support/PathsTest.php b/tests/Support/PathsTest.php index 019d107..06c8100 100644 --- a/tests/Support/PathsTest.php +++ b/tests/Support/PathsTest.php @@ -2,7 +2,6 @@ use Stillat\BladeParser\Support\Utilities\Paths; - test('null paths return null', function () { expect(Paths::normalizePath(null))->toBeNull(); expect(Paths::normalizePathWithTrailingSlash(null))->toBeNull(); diff --git a/tests/Validation/ComponentParameterNameSpacingTest.php b/tests/Validation/ComponentParameterNameSpacingTest.php index f016bf1..34fb731 100644 --- a/tests/Validation/ComponentParameterNameSpacingTest.php +++ b/tests/Validation/ComponentParameterNameSpacingTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\ComponentParameterNameSpacingValidator; - test('parameter spacing is detected', function () { $template = <<<'BLADE' diff --git a/tests/Validation/ComponentShorthandVariableParameterTest.php b/tests/Validation/ComponentShorthandVariableParameterTest.php index 974d0d8..971957b 100644 --- a/tests/Validation/ComponentShorthandVariableParameterTest.php +++ b/tests/Validation/ComponentShorthandVariableParameterTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\ComponentShorthandVariableParameterValidator; - test('component shorthand validator detects issues', function () { $template = <<<'BLADE' diff --git a/tests/Validation/DebugDirectiveTest.php b/tests/Validation/DebugDirectiveTest.php index 2e56555..682e81c 100644 --- a/tests/Validation/DebugDirectiveTest.php +++ b/tests/Validation/DebugDirectiveTest.php @@ -5,7 +5,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\DebugDirectiveValidator; - test('debug directive validator detects issues', function (string $directive) { $template = "Lead @{$directive}(\$arg) Trail"; diff --git a/tests/Validation/DirectiveArgumentSpacingTest.php b/tests/Validation/DirectiveArgumentSpacingTest.php index 8a8cf6c..e51e1fc 100644 --- a/tests/Validation/DirectiveArgumentSpacingTest.php +++ b/tests/Validation/DirectiveArgumentSpacingTest.php @@ -4,14 +4,13 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\DirectiveArgumentSpacingValidator; - test('directive argument spacing validator detects issues', function () { $template = <<<'BLADE' @if ($something) @endif BLADE; - $spacingValidator = new DirectiveArgumentSpacingValidator(); + $spacingValidator = new DirectiveArgumentSpacingValidator; $spacingValidator->setExpectedSpacing(3); $results = Document::fromText($template) @@ -28,7 +27,7 @@ @endif BLADE; - $spacingValidator = new DirectiveArgumentSpacingValidator(); + $spacingValidator = new DirectiveArgumentSpacingValidator; $spacingValidator->setExpectedSpacing(3); $results = Document::fromText($template) diff --git a/tests/Validation/DirectiveArgumentSpanningLinesTest.php b/tests/Validation/DirectiveArgumentSpanningLinesTest.php index b559f95..4973d96 100644 --- a/tests/Validation/DirectiveArgumentSpanningLinesTest.php +++ b/tests/Validation/DirectiveArgumentSpanningLinesTest.php @@ -4,14 +4,13 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\DirectiveArgumentsSpanningLinesValidator; - test('directive argument spanning lines validator detects issues', function () { $template = <<<'BLADE' @if ($something == $this && 'this' == 'that') BLADE; - $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator(); + $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator; $spanLinesValidator->setMaxLineSpan(2); $results = Document::fromText($template) @@ -28,7 +27,7 @@ == $this && 'this' == 'that') BLADE; - $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator(); + $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator; $spanLinesValidator->setMaxLineSpan(3); $results = Document::fromText($template) @@ -43,7 +42,7 @@ @if ($something 'this' == 'that') BLADE; - $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator(); + $spanLinesValidator = new DirectiveArgumentsSpanningLinesValidator; $spanLinesValidator->setMaxLineSpan(3); $results = Document::fromText($template) diff --git a/tests/Validation/DirectiveSpacingTest.php b/tests/Validation/DirectiveSpacingTest.php index 8d3a1a5..7c20c3e 100644 --- a/tests/Validation/DirectiveSpacingTest.php +++ b/tests/Validation/DirectiveSpacingTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\DirectiveSpacingValidator; - test('directive spacing validator detects issues', function () { $template = 'class="@if @endif"'; $results = Document::fromText($template) diff --git a/tests/Validation/DuplicateConditionExpressionsTest.php b/tests/Validation/DuplicateConditionExpressionsTest.php index 4079196..45a4c3b 100644 --- a/tests/Validation/DuplicateConditionExpressionsTest.php +++ b/tests/Validation/DuplicateConditionExpressionsTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\DuplicateConditionExpressionsValidator; - test('duplicate condition expression validator detects issues', function () { $template = <<<'BLADE' @if ($this == 'that') diff --git a/tests/Validation/EmptyConditionTest.php b/tests/Validation/EmptyConditionTest.php index d1b5271..9a2b8af 100644 --- a/tests/Validation/EmptyConditionTest.php +++ b/tests/Validation/EmptyConditionTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\EmptyConditionValidator; - test('empty condition validator detects issues', function () { $template = <<<'BLADE' @if diff --git a/tests/Validation/ForElseStructureTest.php b/tests/Validation/ForElseStructureTest.php index 264be81..d59567d 100644 --- a/tests/Validation/ForElseStructureTest.php +++ b/tests/Validation/ForElseStructureTest.php @@ -4,7 +4,6 @@ use Stillat\BladeParser\Document\Document; use Stillat\BladeParser\Validation\Validators\ForElseStructureValidator; - test('for else validator detects too many empty directives', function () { $template = <<<'BLADE' @forelse ($users as $user) diff --git a/tests/Validation/InconsistentDirectiveCasingTest.php b/tests/Validation/InconsistentDirectiveCasingTest.php index 761ab49..4cfd3b1 100644 --- a/tests/Validation/InconsistentDirectiveCasingTest.php +++ b/tests/Validation/InconsistentDirectiveCasingTest.php @@ -1,11 +1,9 @@ workspace = $this->getWorkspace('one'); @@ -26,4 +24,4 @@ $this->assertDirectiveContent($directives[0], 'include', "('something')"); $this->assertDirectiveContent($directives[1], 'include', "('something-else')"); $this->assertNotSame($directives[0]->getDocument(), $directives[1]->getDocument()); -}); \ No newline at end of file +}); diff --git a/tests/Workspaces/WorkspaceProxyTest.php b/tests/Workspaces/WorkspaceProxyTest.php index 7a09603..1e90f8f 100644 --- a/tests/Workspaces/WorkspaceProxyTest.php +++ b/tests/Workspaces/WorkspaceProxyTest.php @@ -2,8 +2,6 @@ uses(\Stillat\BladeParser\Tests\ParserTestCase::class); use Stillat\BladeParser\Nodes\LiteralNode; -use Stillat\BladeParser\Workspaces\Workspace; - beforeEach(function () { $this->workspace = $this->getWorkspace('two'); @@ -110,4 +108,4 @@ function getGetComponents() test('get root for else', function () { expect($this->workspace->getRootForElse())->toHaveCount(2); -}); \ No newline at end of file +});