diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index ab9ce65..e431fde 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.0.5","version":"3.0.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}},"single_trait_insert_per_statement":true},"hashes":{"src\/ComponentNode.php":495735954,"src\/SlotTokenParser.php":1705137408,"src\/Setup.php":2590804620,"src\/SlotBag.php":2813959692,"src\/ComponentTagCompiler.php":1655642996,"src\/ComponentTokenParser.php":1300987293,"src\/ComponentExtension.php":1906178892,"src\/SlotNode.php":3498435644,"src\/ComponentLexer.php":1680794890,"src\/AttributesBag.php":2838536753,"tests\/ComponentTest.php":1692604728}} \ No newline at end of file +{"php":"8.0.10","version":"3.1.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"method":"one"}},"single_trait_insert_per_statement":true},"hashes":{"src\/SlotBag.php":2813959692,"src\/ComponentLexer.php":1680794890,"src\/SlotTokenParser.php":1705137408,"src\/SlotNode.php":3498435644,"src\/ComponentNode.php":495735954,"src\/ComponentExtension.php":1906178892,"src\/ComponentTokenParser.php":291316121,"src\/AttributesBag.php":2838536753,"src\/Setup.php":2590804620,"src\/ComponentTagCompiler.php":1655642996,"tests\/ComponentTest.php":586052960}} \ No newline at end of file diff --git a/src/ComponentTokenParser.php b/src/ComponentTokenParser.php index a56a845..0fbf794 100644 --- a/src/ComponentTokenParser.php +++ b/src/ComponentTokenParser.php @@ -26,9 +26,10 @@ public function __construct(string $path) public function getComponentPath(string $name) { - if (strpos( $name, '@' ) === 0) { + if (strpos($name, '@') === 0) { return $name . '.twig'; } + return rtrim($this->path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $name . '.twig'; } @@ -75,9 +76,9 @@ public function parseComponentName(): string $name = $this->getNameSection(); - if ( $stream->nextIf(Token::PUNCTUATION_TYPE, ':') ) { + if ($stream->nextIf(Token::PUNCTUATION_TYPE, ':')) { $path[] = '@' . $name; - $name = $this->getNameSection(); + $name = $this->getNameSection(); } $path[] = $name; @@ -89,14 +90,15 @@ public function parseComponentName(): string return implode('/', $path); } - public function getNameSection(): string { + public function getNameSection(): string + { $stream = $this->parser->getStream(); $name = $stream->next()->getValue(); while ($stream->nextIf(Token::OPERATOR_TYPE, '-')) { $token = $stream->nextIf(Token::NAME_TYPE); - if (! is_null( $token )) { + if (! is_null($token)) { $name .= '-' . $token->getValue(); } }