@vituum/vite-plugin-latte 2.0.0-next.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.js +4 -2
- package/package.json +11 -9
- package/types/index.d.ts +1 -1
- package/vendor/autoload.php +1 -4
- package/vendor/composer/InstalledVersions.php +36 -2
- package/vendor/composer/autoload_classmap.php +14 -15
- package/vendor/composer/autoload_psr4.php +2 -0
- package/vendor/composer/autoload_static.php +38 -15
- package/vendor/composer/installed.json +32 -22
- package/vendor/composer/installed.php +12 -12
- package/vendor/composer/platform_check.php +4 -5
- package/vendor/latte/latte/bin/latte-lint +10 -3
- package/vendor/latte/latte/composer.json +16 -6
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +13 -38
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +9 -7
- package/vendor/latte/latte/src/Bridges/Tracy/TracyExtension.php +2 -4
- package/vendor/latte/latte/src/Bridges/Tracy/dist/panel.phtml +94 -0
- package/vendor/latte/latte/src/Bridges/Tracy/dist/tab.phtml +10 -0
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +67 -86
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +16 -6
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +25 -12
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AreaNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +8 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +7 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/BogusTagNode.php +4 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/CommentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +37 -67
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ExpressionAttributeNode.php +60 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/TagNode.php +70 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/NopNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +4 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ClosureUseNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ComplexTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayAccessNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +6 -22
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +18 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +18 -7
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +5 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/BinaryOpNode.php +38 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CastNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/CloneNode.php +12 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +10 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/EmptyNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FilterCallNode.php +10 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallNode.php +14 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/InstanceofNode.php +14 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MatchNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallNode.php +18 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/NewNode.php +14 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +14 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallNode.php +14 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TernaryNode.php +16 -11
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php +19 -9
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/VariableNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/FilterNode.php +33 -8
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/InterpolatedStringPartNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/IntersectionTypeNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/MatchArmNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +29 -41
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NameNode.php +9 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/NullableTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/OperatorNode.php +27 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ParameterNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/BooleanNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/FloatNode.php +9 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/IntegerNode.php +8 -6
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +9 -5
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/NullNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/StringNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ScalarNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/SuperiorTypeNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/UnionTypeNode.php +6 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/VarLikeIdentifierNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/{Expression/NotNode.php → VariadicPlaceholderNode.php} +9 -9
- package/vendor/latte/latte/src/Latte/{Essential → Compiler}/Nodes/PrintNode.php +9 -15
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/StatementNode.php +7 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TemplateNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/TextNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +32 -18
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +7 -7
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +72 -104
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +17 -16
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +11 -8
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +28 -23
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +360 -336
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +49 -38
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +37 -12
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +35 -21
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +121 -71
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +79 -70
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +21 -14
- package/vendor/latte/latte/src/Latte/ContentType.php +4 -3
- package/vendor/latte/latte/src/Latte/Engine.php +147 -188
- package/vendor/latte/latte/src/Latte/Essential/AuxiliaryIterator.php +5 -7
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +5 -4
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +155 -127
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +99 -44
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +14 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CustomFunctionCallNode.php +46 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DebugbreakNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +10 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DoNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DumpNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +8 -9
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +3 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +4 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +6 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +7 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +7 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +11 -11
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ImportNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +26 -27
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeFileNode.php +7 -10
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +4 -8
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NAttrNode.php +35 -47
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NClassNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +69 -34
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +9 -33
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ParametersNode.php +7 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RawPhpNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +9 -7
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplatePrintNode.php +4 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TemplateTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TraceNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +4 -5
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarNode.php +10 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarPrintNode.php +2 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/VarTypeNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +5 -5
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +82 -21
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +2 -4
- package/vendor/latte/latte/src/Latte/Essential/RollbackException.php +1 -3
- package/vendor/latte/latte/src/Latte/Essential/Tracer.php +24 -28
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +14 -14
- package/vendor/latte/latte/src/Latte/Extension.php +12 -6
- package/vendor/latte/latte/src/Latte/Feature.php +24 -0
- package/vendor/latte/latte/src/Latte/Helpers.php +65 -15
- package/vendor/latte/latte/src/Latte/Loader.php +1 -9
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +11 -17
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +7 -21
- package/vendor/latte/latte/src/Latte/Policy.php +4 -3
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +2 -4
- package/vendor/latte/latte/src/Latte/Runtime/Cache.php +143 -0
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +5 -6
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +11 -11
- package/vendor/latte/latte/src/Latte/Runtime/FunctionExecutor.php +5 -6
- package/vendor/latte/latte/src/Latte/Runtime/Helpers.php +91 -0
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +3 -5
- package/vendor/latte/latte/src/Latte/Runtime/HtmlHelpers.php +374 -0
- package/vendor/latte/latte/src/Latte/Runtime/HtmlStringable.php +1 -3
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +162 -182
- package/vendor/latte/latte/src/Latte/Runtime/XmlHelpers.php +108 -0
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +12 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +15 -5
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/PropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +5 -6
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallNode.php +14 -4
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticPropertyFetchNode.php +4 -3
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +8 -6
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +16 -12
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +18 -16
- package/vendor/latte/latte/src/Latte/attributes.php +7 -3
- package/vendor/latte/latte/src/Latte/exceptions.php +52 -6
- package/vendor/latte/latte/src/Tools/Linter.php +74 -28
- package/vendor/latte/latte/src/Tools/LinterExtension.php +176 -0
- package/vendor/nette/utils/composer.json +15 -5
- package/vendor/nette/utils/readme.md +1 -1
- package/vendor/nette/utils/src/HtmlStringable.php +4 -1
- package/vendor/nette/utils/src/Iterators/CachingIterator.php +10 -25
- package/vendor/nette/utils/src/Iterators/Mapper.php +2 -3
- package/vendor/nette/utils/src/SmartObject.php +3 -0
- package/vendor/nette/utils/src/StaticClass.php +1 -11
- package/vendor/nette/utils/src/Translator.php +1 -1
- package/vendor/nette/utils/src/Utils/ArrayHash.php +6 -10
- package/vendor/nette/utils/src/Utils/ArrayList.php +8 -12
- package/vendor/nette/utils/src/Utils/Arrays.php +38 -18
- package/vendor/nette/utils/src/Utils/Callback.php +13 -8
- package/vendor/nette/utils/src/Utils/DateTime.php +95 -26
- package/vendor/nette/utils/src/Utils/FileInfo.php +6 -7
- package/vendor/nette/utils/src/Utils/FileSystem.php +10 -5
- package/vendor/nette/utils/src/Utils/Finder.php +31 -12
- package/vendor/nette/utils/src/Utils/Floats.php +1 -0
- package/vendor/nette/utils/src/Utils/Helpers.php +22 -2
- package/vendor/nette/utils/src/Utils/Html.php +130 -127
- package/vendor/nette/utils/src/Utils/Image.php +80 -60
- package/vendor/nette/utils/src/Utils/ImageColor.php +5 -0
- package/vendor/nette/utils/src/Utils/ImageType.php +2 -0
- package/vendor/nette/utils/src/Utils/Iterables.php +41 -7
- package/vendor/nette/utils/src/Utils/Json.php +2 -0
- package/vendor/nette/utils/src/Utils/ObjectHelpers.php +2 -0
- package/vendor/nette/utils/src/Utils/Paginator.php +10 -43
- package/vendor/nette/utils/src/Utils/Random.php +2 -0
- package/vendor/nette/utils/src/Utils/Reflection.php +22 -15
- package/vendor/nette/utils/src/Utils/ReflectionMethod.php +6 -1
- package/vendor/nette/utils/src/Utils/Strings.php +62 -57
- package/vendor/nette/utils/src/Utils/Type.php +91 -42
- package/vendor/nette/utils/src/Utils/Validators.php +9 -7
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.panel.phtml +0 -101
- package/vendor/latte/latte/src/Bridges/Tracy/templates/LattePanel.tab.phtml +0 -15
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +0 -129
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ErrorSuppressNode.php +0 -36
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/FunctionCallableNode.php +0 -39
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/MethodCallableNode.php +0 -42
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/StaticMethodCallableNode.php +0 -57
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +0 -47
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +0 -283
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallableNode.php +0 -29
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallableNode.php +0 -30
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/StaticMethodCallableNode.php +0 -30
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<?php declare(strict_types=1);
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the Latte (https://latte.nette.org)
|
|
5
|
+
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
namespace Latte\Tools;
|
|
9
|
+
|
|
10
|
+
use Latte;
|
|
11
|
+
use Latte\Compiler\Node;
|
|
12
|
+
use Latte\Compiler\Nodes\Php;
|
|
13
|
+
use Latte\Compiler\Nodes\Php\Expression;
|
|
14
|
+
use Latte\Compiler\Nodes\TemplateNode;
|
|
15
|
+
use Latte\Compiler\NodeTraverser;
|
|
16
|
+
use function defined;
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Linter extension for validating filters, functions, classes, methods, constants and more.
|
|
21
|
+
*/
|
|
22
|
+
final class LinterExtension extends Latte\Extension
|
|
23
|
+
{
|
|
24
|
+
private ?Latte\Engine $engine = null;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
public function beforeCompile(Latte\Engine $engine): void
|
|
28
|
+
{
|
|
29
|
+
$this->engine = $engine;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
public function getPasses(): array
|
|
34
|
+
{
|
|
35
|
+
return [
|
|
36
|
+
'linter' => $this->linterPass(...),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
private function linterPass(TemplateNode $node): void
|
|
42
|
+
{
|
|
43
|
+
(new NodeTraverser)->traverse($node, function (Node $node) {
|
|
44
|
+
if ($node instanceof Php\FilterNode) {
|
|
45
|
+
$this->validateFilter($node);
|
|
46
|
+
|
|
47
|
+
} elseif ($node instanceof Expression\FunctionCallNode && $node->name instanceof Php\NameNode) {
|
|
48
|
+
$this->validateFunction($node);
|
|
49
|
+
|
|
50
|
+
} elseif ($node instanceof Expression\NewNode && $node->class instanceof Php\NameNode) {
|
|
51
|
+
$this->validateNewObject($node);
|
|
52
|
+
|
|
53
|
+
} elseif ($node instanceof Expression\StaticMethodCallNode
|
|
54
|
+
&& $node->class instanceof Php\NameNode
|
|
55
|
+
&& $node->name instanceof Php\IdentifierNode
|
|
56
|
+
) {
|
|
57
|
+
$this->validateStaticMethod($node);
|
|
58
|
+
|
|
59
|
+
} elseif ($node instanceof Expression\ClassConstantFetchNode
|
|
60
|
+
&& $node->class instanceof Php\NameNode
|
|
61
|
+
&& $node->name instanceof Php\IdentifierNode
|
|
62
|
+
) {
|
|
63
|
+
$node->name->name === 'class'
|
|
64
|
+
? $this->validateClassType($node->class)
|
|
65
|
+
: $this->validateClassConstant($node);
|
|
66
|
+
|
|
67
|
+
} elseif ($node instanceof Expression\ConstantFetchNode) {
|
|
68
|
+
$this->validateConstant($node);
|
|
69
|
+
|
|
70
|
+
} elseif ($node instanceof Expression\InstanceofNode && $node->class instanceof Php\NameNode) {
|
|
71
|
+
$this->validateInstanceof($node);
|
|
72
|
+
|
|
73
|
+
} elseif ($node instanceof Expression\StaticPropertyFetchNode
|
|
74
|
+
&& $node->class instanceof Php\NameNode
|
|
75
|
+
&& $node->name instanceof Php\VarLikeIdentifierNode
|
|
76
|
+
) {
|
|
77
|
+
$this->validateStaticProperty($node);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
private function validateFilter(Php\FilterNode $node): void
|
|
84
|
+
{
|
|
85
|
+
$name = $node->name->name;
|
|
86
|
+
assert($this->engine !== null);
|
|
87
|
+
$filters = $this->engine->getFilters();
|
|
88
|
+
if (!isset($filters[$name])) {
|
|
89
|
+
trigger_error("Unknown filter |$name $node->position", E_USER_WARNING);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
private function validateFunction(Expression\FunctionCallNode $node): void
|
|
95
|
+
{
|
|
96
|
+
assert($node->name instanceof Php\NameNode);
|
|
97
|
+
$name = (string) $node->name;
|
|
98
|
+
if (!function_exists($name)) {
|
|
99
|
+
trigger_error("Unknown function $name() $node->position", E_USER_WARNING);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
private function validateNewObject(Expression\NewNode $node): void
|
|
105
|
+
{
|
|
106
|
+
assert($node->class instanceof Php\NameNode);
|
|
107
|
+
$className = (string) $node->class;
|
|
108
|
+
if (!class_exists($className)) {
|
|
109
|
+
trigger_error("Unknown class $className $node->position", E_USER_WARNING);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
private function validateStaticMethod(Expression\StaticMethodCallNode $node): void
|
|
115
|
+
{
|
|
116
|
+
assert($node->class instanceof Php\NameNode);
|
|
117
|
+
assert($node->name instanceof Php\IdentifierNode);
|
|
118
|
+
$className = (string) $node->class;
|
|
119
|
+
$methodName = $node->name->name;
|
|
120
|
+
if (!method_exists($className, $methodName)) {
|
|
121
|
+
trigger_error("Unknown method $className::$methodName() $node->position", E_USER_WARNING);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
private function validateClassType(Php\NameNode $node): void
|
|
127
|
+
{
|
|
128
|
+
$className = (string) $node;
|
|
129
|
+
if (!class_exists($className) && !interface_exists($className) && !trait_exists($className)) {
|
|
130
|
+
trigger_error("Unknown class $className $node->position", E_USER_WARNING);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
private function validateClassConstant(Expression\ClassConstantFetchNode $node): void
|
|
136
|
+
{
|
|
137
|
+
assert($node->class instanceof Php\NameNode);
|
|
138
|
+
assert($node->name instanceof Php\IdentifierNode);
|
|
139
|
+
$name = "{$node->class}::{$node->name->name}";
|
|
140
|
+
if (!defined($name)) {
|
|
141
|
+
trigger_error("Unknown class constant $name $node->position", E_USER_WARNING);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
private function validateConstant(Expression\ConstantFetchNode $node): void
|
|
147
|
+
{
|
|
148
|
+
$magic = ['__LINE__' => 1, '__FILE__' => 1, '__DIR__' => 1];
|
|
149
|
+
$name = (string) $node->name;
|
|
150
|
+
if (!defined($name) && !isset($magic[$name])) {
|
|
151
|
+
trigger_error("Unknown constant $name $node->position", E_USER_WARNING);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
private function validateInstanceof(Expression\InstanceofNode $node): void
|
|
157
|
+
{
|
|
158
|
+
assert($node->class instanceof Php\NameNode);
|
|
159
|
+
$className = (string) $node->class;
|
|
160
|
+
if (!class_exists($className) && !interface_exists($className)) {
|
|
161
|
+
trigger_error("Unknown class $className in instanceof $node->position", E_USER_WARNING);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
private function validateStaticProperty(Expression\StaticPropertyFetchNode $node): void
|
|
167
|
+
{
|
|
168
|
+
assert($node->class instanceof Php\NameNode);
|
|
169
|
+
assert($node->name instanceof Php\VarLikeIdentifierNode);
|
|
170
|
+
$className = (string) $node->class;
|
|
171
|
+
$propertyName = $node->name->name;
|
|
172
|
+
if (!property_exists($className, $propertyName)) {
|
|
173
|
+
trigger_error("Unknown static property $className::\$$propertyName $node->position", E_USER_WARNING);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -15,13 +15,15 @@
|
|
|
15
15
|
}
|
|
16
16
|
],
|
|
17
17
|
"require": {
|
|
18
|
-
"php": "8.
|
|
18
|
+
"php": "8.2 - 8.5"
|
|
19
19
|
},
|
|
20
20
|
"require-dev": {
|
|
21
21
|
"nette/tester": "^2.5",
|
|
22
22
|
"tracy/tracy": "^2.9",
|
|
23
|
-
"phpstan/phpstan": "^1
|
|
24
|
-
"
|
|
23
|
+
"phpstan/phpstan": "^2.1@stable",
|
|
24
|
+
"phpstan/extension-installer": "^1.4@stable",
|
|
25
|
+
"nette/phpstan-rules": "^1.0",
|
|
26
|
+
"jetbrains/phpstorm-attributes": "^1.2"
|
|
25
27
|
},
|
|
26
28
|
"conflict": {
|
|
27
29
|
"nette/finder": "<3",
|
|
@@ -36,7 +38,10 @@
|
|
|
36
38
|
"ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()"
|
|
37
39
|
},
|
|
38
40
|
"autoload": {
|
|
39
|
-
"classmap": ["src/"]
|
|
41
|
+
"classmap": ["src/"],
|
|
42
|
+
"psr-4": {
|
|
43
|
+
"Nette\\": "src"
|
|
44
|
+
}
|
|
40
45
|
},
|
|
41
46
|
"minimum-stability": "dev",
|
|
42
47
|
"scripts": {
|
|
@@ -45,7 +50,12 @@
|
|
|
45
50
|
},
|
|
46
51
|
"extra": {
|
|
47
52
|
"branch-alias": {
|
|
48
|
-
"dev-master": "4.
|
|
53
|
+
"dev-master": "4.1-dev"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"config": {
|
|
57
|
+
"allow-plugins": {
|
|
58
|
+
"phpstan/extension-installer": true
|
|
49
59
|
}
|
|
50
60
|
}
|
|
51
61
|
}
|
|
@@ -10,10 +10,13 @@ declare(strict_types=1);
|
|
|
10
10
|
namespace Nette;
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Represents object convertible to HTML string.
|
|
15
|
+
*/
|
|
13
16
|
interface HtmlStringable
|
|
14
17
|
{
|
|
15
18
|
/**
|
|
16
|
-
* Returns string in HTML format
|
|
19
|
+
* Returns string in HTML format.
|
|
17
20
|
*/
|
|
18
21
|
function __toString(): string;
|
|
19
22
|
}
|
|
@@ -13,16 +13,19 @@ use Nette;
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Enhanced caching iterator with first/last/counter tracking.
|
|
17
17
|
*
|
|
18
|
+
* @template TKey
|
|
19
|
+
* @template TValue
|
|
20
|
+
* @extends \CachingIterator<TKey, TValue, \Iterator<TKey, TValue>>
|
|
18
21
|
* @property-read bool $first
|
|
19
22
|
* @property-read bool $last
|
|
20
23
|
* @property-read bool $empty
|
|
21
24
|
* @property-read bool $odd
|
|
22
25
|
* @property-read bool $even
|
|
23
26
|
* @property-read int $counter
|
|
24
|
-
* @property-read
|
|
25
|
-
* @property-read
|
|
27
|
+
* @property-read TKey $nextKey
|
|
28
|
+
* @property-read TValue $nextValue
|
|
26
29
|
*/
|
|
27
30
|
class CachingIterator extends \CachingIterator implements \Countable
|
|
28
31
|
{
|
|
@@ -31,10 +34,11 @@ class CachingIterator extends \CachingIterator implements \Countable
|
|
|
31
34
|
private int $counter = 0;
|
|
32
35
|
|
|
33
36
|
|
|
37
|
+
/** @param iterable<TKey, TValue>|\stdClass $iterable */
|
|
34
38
|
public function __construct(iterable|\stdClass $iterable)
|
|
35
39
|
{
|
|
36
40
|
$iterable = $iterable instanceof \stdClass
|
|
37
|
-
? new \ArrayIterator($iterable)
|
|
41
|
+
? new \ArrayIterator((array) $iterable)
|
|
38
42
|
: Nette\Utils\Iterables::toIterator($iterable);
|
|
39
43
|
parent::__construct($iterable, 0);
|
|
40
44
|
}
|
|
@@ -58,45 +62,30 @@ class CachingIterator extends \CachingIterator implements \Countable
|
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
|
|
61
|
-
/**
|
|
62
|
-
* Is the iterator empty?
|
|
63
|
-
*/
|
|
64
65
|
public function isEmpty(): bool
|
|
65
66
|
{
|
|
66
67
|
return $this->counter === 0;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
|
|
70
|
-
/**
|
|
71
|
-
* Is the counter odd?
|
|
72
|
-
*/
|
|
73
71
|
public function isOdd(): bool
|
|
74
72
|
{
|
|
75
73
|
return $this->counter % 2 === 1;
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
|
|
79
|
-
/**
|
|
80
|
-
* Is the counter even?
|
|
81
|
-
*/
|
|
82
77
|
public function isEven(): bool
|
|
83
78
|
{
|
|
84
79
|
return $this->counter % 2 === 0;
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
|
|
88
|
-
/**
|
|
89
|
-
* Returns the counter.
|
|
90
|
-
*/
|
|
91
83
|
public function getCounter(): int
|
|
92
84
|
{
|
|
93
85
|
return $this->counter;
|
|
94
86
|
}
|
|
95
87
|
|
|
96
88
|
|
|
97
|
-
/**
|
|
98
|
-
* Returns the count of elements.
|
|
99
|
-
*/
|
|
100
89
|
public function count(): int
|
|
101
90
|
{
|
|
102
91
|
$inner = $this->getInnerIterator();
|
|
@@ -131,18 +120,14 @@ class CachingIterator extends \CachingIterator implements \Countable
|
|
|
131
120
|
}
|
|
132
121
|
|
|
133
122
|
|
|
134
|
-
/**
|
|
135
|
-
* Returns the next key.
|
|
136
|
-
*/
|
|
123
|
+
/** @return TKey */
|
|
137
124
|
public function getNextKey(): mixed
|
|
138
125
|
{
|
|
139
126
|
return $this->getInnerIterator()->key();
|
|
140
127
|
}
|
|
141
128
|
|
|
142
129
|
|
|
143
|
-
/**
|
|
144
|
-
* Returns the next element.
|
|
145
|
-
*/
|
|
130
|
+
/** @return TValue */
|
|
146
131
|
public function getNextValue(): mixed
|
|
147
132
|
{
|
|
148
133
|
return $this->getInnerIterator()->current();
|
|
@@ -15,14 +15,13 @@ namespace Nette\Iterators;
|
|
|
15
15
|
*/
|
|
16
16
|
class Mapper extends \IteratorIterator
|
|
17
17
|
{
|
|
18
|
-
|
|
19
|
-
private $callback;
|
|
18
|
+
private \Closure $callback;
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
public function __construct(\Traversable $iterator, callable $callback)
|
|
23
22
|
{
|
|
24
23
|
parent::__construct($iterator);
|
|
25
|
-
$this->callback = $callback;
|
|
24
|
+
$this->callback = $callback(...);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
|
|
@@ -22,6 +22,7 @@ use Nette\Utils\ObjectHelpers;
|
|
|
22
22
|
trait SmartObject
|
|
23
23
|
{
|
|
24
24
|
/**
|
|
25
|
+
* @param mixed[] $args
|
|
25
26
|
* @return mixed
|
|
26
27
|
* @throws MemberAccessException
|
|
27
28
|
*/
|
|
@@ -47,6 +48,8 @@ trait SmartObject
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
/**
|
|
51
|
+
* @param mixed[] $args
|
|
52
|
+
* @return never
|
|
50
53
|
* @throws MemberAccessException
|
|
51
54
|
*/
|
|
52
55
|
public static function __callStatic(string $name, array $args)
|
|
@@ -11,7 +11,7 @@ namespace Nette;
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Prevents instantiation.
|
|
15
15
|
*/
|
|
16
16
|
trait StaticClass
|
|
17
17
|
{
|
|
@@ -21,14 +21,4 @@ trait StaticClass
|
|
|
21
21
|
private function __construct()
|
|
22
22
|
{
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Call to undefined static method.
|
|
28
|
-
* @throws MemberAccessException
|
|
29
|
-
*/
|
|
30
|
-
public static function __callStatic(string $name, array $args): mixed
|
|
31
|
-
{
|
|
32
|
-
Utils\ObjectHelpers::strictStaticCall(static::class, $name);
|
|
33
|
-
}
|
|
34
24
|
}
|
|
@@ -10,10 +10,11 @@ declare(strict_types=1);
|
|
|
10
10
|
namespace Nette\Utils;
|
|
11
11
|
|
|
12
12
|
use Nette;
|
|
13
|
+
use function count, is_array, is_scalar, sprintf;
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Array-like object with property access.
|
|
17
18
|
* @template T
|
|
18
19
|
* @implements \IteratorAggregate<array-key, T>
|
|
19
20
|
* @implements \ArrayAccess<array-key, T>
|
|
@@ -38,7 +39,6 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator
|
|
|
38
39
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
|
-
* Returns an iterator over all items.
|
|
42
42
|
* @return \Iterator<array-key, T>
|
|
43
43
|
*/
|
|
44
44
|
public function &getIterator(): \Iterator
|
|
@@ -49,9 +49,6 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Returns items count.
|
|
54
|
-
*/
|
|
55
52
|
public function count(): int
|
|
56
53
|
{
|
|
57
54
|
return count((array) $this);
|
|
@@ -59,7 +56,7 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator
|
|
|
59
56
|
|
|
60
57
|
|
|
61
58
|
/**
|
|
62
|
-
* Replaces or appends
|
|
59
|
+
* Replaces or appends an item.
|
|
63
60
|
* @param array-key $key
|
|
64
61
|
* @param T $value
|
|
65
62
|
*/
|
|
@@ -74,19 +71,18 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator
|
|
|
74
71
|
|
|
75
72
|
|
|
76
73
|
/**
|
|
77
|
-
* Returns
|
|
74
|
+
* Returns an item.
|
|
78
75
|
* @param array-key $key
|
|
79
76
|
* @return T
|
|
80
77
|
*/
|
|
81
|
-
|
|
82
|
-
public function offsetGet($key)
|
|
78
|
+
public function offsetGet($key): mixed
|
|
83
79
|
{
|
|
84
80
|
return $this->$key;
|
|
85
81
|
}
|
|
86
82
|
|
|
87
83
|
|
|
88
84
|
/**
|
|
89
|
-
* Determines whether
|
|
85
|
+
* Determines whether an item exists.
|
|
90
86
|
* @param array-key $key
|
|
91
87
|
*/
|
|
92
88
|
public function offsetExists($key): bool
|
|
@@ -10,18 +10,18 @@ declare(strict_types=1);
|
|
|
10
10
|
namespace Nette\Utils;
|
|
11
11
|
|
|
12
12
|
use Nette;
|
|
13
|
+
use function array_slice, array_splice, count, is_int;
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Generic list with integer indices.
|
|
17
18
|
* @template T
|
|
18
19
|
* @implements \IteratorAggregate<int, T>
|
|
19
20
|
* @implements \ArrayAccess<int, T>
|
|
20
21
|
*/
|
|
21
22
|
class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
22
23
|
{
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
/** @var list<T> */
|
|
25
25
|
private array $list = [];
|
|
26
26
|
|
|
27
27
|
|
|
@@ -42,7 +42,6 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Returns an iterator over all items.
|
|
46
45
|
* @return \Iterator<int, T>
|
|
47
46
|
*/
|
|
48
47
|
public function &getIterator(): \Iterator
|
|
@@ -53,9 +52,6 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
53
52
|
}
|
|
54
53
|
|
|
55
54
|
|
|
56
|
-
/**
|
|
57
|
-
* Returns items count.
|
|
58
|
-
*/
|
|
59
55
|
public function count(): int
|
|
60
56
|
{
|
|
61
57
|
return count($this->list);
|
|
@@ -63,8 +59,8 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
63
59
|
|
|
64
60
|
|
|
65
61
|
/**
|
|
66
|
-
* Replaces or appends
|
|
67
|
-
* @param int
|
|
62
|
+
* Replaces or appends an item.
|
|
63
|
+
* @param ?int $index
|
|
68
64
|
* @param T $value
|
|
69
65
|
* @throws Nette\OutOfRangeException
|
|
70
66
|
*/
|
|
@@ -83,7 +79,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
83
79
|
|
|
84
80
|
|
|
85
81
|
/**
|
|
86
|
-
* Returns
|
|
82
|
+
* Returns an item.
|
|
87
83
|
* @param int $index
|
|
88
84
|
* @return T
|
|
89
85
|
* @throws Nette\OutOfRangeException
|
|
@@ -99,7 +95,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
99
95
|
|
|
100
96
|
|
|
101
97
|
/**
|
|
102
|
-
* Determines whether
|
|
98
|
+
* Determines whether an item exists.
|
|
103
99
|
* @param int $index
|
|
104
100
|
*/
|
|
105
101
|
public function offsetExists($index): bool
|
|
@@ -124,7 +120,7 @@ class ArrayList implements \ArrayAccess, \Countable, \IteratorAggregate
|
|
|
124
120
|
|
|
125
121
|
|
|
126
122
|
/**
|
|
127
|
-
* Prepends
|
|
123
|
+
* Prepends an item.
|
|
128
124
|
* @param T $value
|
|
129
125
|
*/
|
|
130
126
|
public function prepend(mixed $value): void
|