@vituum/vite-plugin-latte 1.0.0 → 1.1.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/index.js +2 -2
- package/package.json +10 -11
- package/vendor/autoload.php +19 -1
- package/vendor/bin/latte-lint +16 -4
- package/vendor/composer/ClassLoader.php +72 -65
- package/vendor/composer/InstalledVersions.php +21 -12
- package/vendor/composer/autoload_classmap.php +12 -8
- package/vendor/composer/autoload_namespaces.php +1 -1
- package/vendor/composer/autoload_psr4.php +1 -1
- package/vendor/composer/autoload_real.php +7 -26
- package/vendor/composer/autoload_static.php +13 -9
- package/vendor/composer/installed.json +8 -8
- package/vendor/composer/installed.php +10 -10
- package/vendor/latte/latte/bin/latte-lint +8 -2
- package/vendor/latte/latte/composer.json +1 -1
- package/vendor/latte/latte/readme.md +6 -6
- package/vendor/latte/latte/src/Bridges/Tracy/BlueScreenPanel.php +1 -0
- package/vendor/latte/latte/src/Bridges/Tracy/LattePanel.php +3 -2
- package/vendor/latte/latte/src/Latte/Compiler/Block.php +0 -3
- package/vendor/latte/latte/src/Latte/Compiler/Escaper.php +103 -88
- package/vendor/latte/latte/src/Latte/Compiler/ExpressionBuilder.php +2 -1
- package/vendor/latte/latte/src/Latte/Compiler/Node.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/NodeHelpers.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/NodeTraverser.php +0 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/AuxiliaryNode.php +11 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/FragmentNode.php +10 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/AttributeNode.php +22 -4
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/ElementNode.php +35 -12
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArgumentNode.php +6 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php +12 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.php +4 -31
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignNode.php +15 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/AuxiliaryNode.php +42 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClassConstantFetchNode.php +2 -2
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ClosureNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/ConstantFetchNode.php +8 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/IssetNode.php +15 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PostOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/PreOpNode.php +11 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/{StaticCallNode.php → StaticMethodCallNode.php} +11 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/{StaticCallableNode.php → StaticMethodCallableNode.php} +11 -1
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Expression/TemporaryNode.php +38 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ExpressionNode.php +24 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListItemNode.php +48 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ListNode.php +56 -0
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/ModifierNode.php +3 -3
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Php/Scalar/InterpolatedStringNode.php +1 -8
- package/vendor/latte/latte/src/Latte/Compiler/PhpHelpers.php +30 -0
- package/vendor/latte/latte/src/Latte/Compiler/Position.php +4 -8
- package/vendor/latte/latte/src/Latte/Compiler/PrintContext.php +14 -7
- package/vendor/latte/latte/src/Latte/Compiler/Tag.php +13 -14
- package/vendor/latte/latte/src/Latte/Compiler/TagLexer.php +3 -7
- package/vendor/latte/latte/src/Latte/Compiler/TagParser.php +52 -3
- package/vendor/latte/latte/src/Latte/Compiler/TagParserData.php +354 -322
- package/vendor/latte/latte/src/Latte/Compiler/TemplateGenerator.php +6 -5
- package/vendor/latte/latte/src/Latte/Compiler/TemplateLexer.php +95 -176
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParser.php +40 -33
- package/vendor/latte/latte/src/Latte/Compiler/TemplateParserHtml.php +182 -126
- package/vendor/latte/latte/src/Latte/Compiler/Token.php +5 -9
- package/vendor/latte/latte/src/Latte/Compiler/TokenStream.php +6 -22
- package/vendor/latte/latte/src/Latte/Engine.php +37 -8
- package/vendor/latte/latte/src/Latte/Essential/Blueprint.php +0 -2
- package/vendor/latte/latte/src/Latte/Essential/CachingIterator.php +0 -4
- package/vendor/latte/latte/src/Latte/Essential/CoreExtension.php +14 -3
- package/vendor/latte/latte/src/Latte/Essential/Filters.php +8 -6
- package/vendor/latte/latte/src/Latte/Essential/Nodes/BlockNode.php +1 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/CaptureNode.php +2 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ContentTypeNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/DefineNode.php +1 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/EmbedNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ExtendsNode.php +0 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/FirstLastSepNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/ForeachNode.php +4 -13
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfChangedNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfContentNode.php +4 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IfNode.php +5 -3
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IncludeBlockNode.php +5 -2
- package/vendor/latte/latte/src/Latte/Essential/Nodes/IterateWhileNode.php +6 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/JumpNode.php +26 -23
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NElseNode.php +88 -0
- package/vendor/latte/latte/src/Latte/Essential/Nodes/NTagNode.php +20 -28
- package/vendor/latte/latte/src/Latte/Essential/Nodes/PrintNode.php +7 -12
- package/vendor/latte/latte/src/Latte/Essential/Nodes/RollbackNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SpacelessNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/SwitchNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TranslateNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Nodes/TryNode.php +3 -4
- package/vendor/latte/latte/src/Latte/Essential/Nodes/WhileNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Essential/Passes.php +9 -11
- package/vendor/latte/latte/src/Latte/Essential/RawPhpExtension.php +0 -2
- package/vendor/latte/latte/src/Latte/Essential/TranslatorExtension.php +6 -1
- package/vendor/latte/latte/src/Latte/Loaders/FileLoader.php +0 -2
- package/vendor/latte/latte/src/Latte/Loaders/StringLoader.php +0 -2
- package/vendor/latte/latte/src/Latte/PositionAwareException.php +1 -1
- package/vendor/latte/latte/src/Latte/Runtime/Block.php +0 -4
- package/vendor/latte/latte/src/Latte/Runtime/FilterExecutor.php +43 -51
- package/vendor/latte/latte/src/Latte/Runtime/FilterInfo.php +0 -2
- package/vendor/latte/latte/src/Latte/Runtime/Filters.php +64 -30
- package/vendor/latte/latte/src/Latte/Runtime/Html.php +0 -4
- package/vendor/latte/latte/src/Latte/Runtime/Template.php +2 -2
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/FunctionCallNode.php +2 -1
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/MethodCallNode.php +1 -1
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/SandboxNode.php +3 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/{StaticCallNode.php → StaticMethodCallNode.php} +3 -3
- package/vendor/latte/latte/src/Latte/Sandbox/Nodes/{StaticCallableNode.php → StaticMethodCallableNode.php} +2 -2
- package/vendor/latte/latte/src/Latte/Sandbox/RuntimeChecker.php +0 -2
- package/vendor/latte/latte/src/Latte/Sandbox/SandboxExtension.php +11 -9
- package/vendor/latte/latte/src/Latte/Sandbox/SecurityPolicy.php +0 -2
- package/vendor/latte/latte/src/Latte/exceptions.php +2 -11
- package/vendor/latte/latte/src/Tools/Linter.php +13 -37
- package/vendor/latte/latte/src/Latte/Compiler/Nodes/Html/QuotedValue.php +0 -53
- package/vendor/latte/latte/src/Latte/Strict.php +0 -101
|
@@ -19,8 +19,6 @@ use Latte\Engine;
|
|
|
19
19
|
*/
|
|
20
20
|
class Template
|
|
21
21
|
{
|
|
22
|
-
use Latte\Strict;
|
|
23
|
-
|
|
24
22
|
public const
|
|
25
23
|
LayerTop = 0,
|
|
26
24
|
LayerSnippet = 'snippet',
|
|
@@ -28,6 +26,8 @@ class Template
|
|
|
28
26
|
|
|
29
27
|
public const ContentType = Latte\ContentType::Html;
|
|
30
28
|
|
|
29
|
+
public const Source = null;
|
|
30
|
+
|
|
31
31
|
public const Blocks = [];
|
|
32
32
|
|
|
33
33
|
/** global accumulators for intermediate results */
|
|
@@ -25,6 +25,7 @@ class FunctionCallNode extends Expression\FunctionCallNode
|
|
|
25
25
|
{
|
|
26
26
|
return '$this->global->sandbox->call('
|
|
27
27
|
. $context->memberAsString($this->name) . ', '
|
|
28
|
-
.
|
|
28
|
+
. $context->argumentsAsArray($this->args) . ')';
|
|
29
|
+
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -26,7 +26,7 @@ class MethodCallNode extends Expression\MethodCallNode
|
|
|
26
26
|
return '$this->global->sandbox->callMethod('
|
|
27
27
|
. $this->object->print($context) . ', '
|
|
28
28
|
. $context->memberAsString($this->name) . ', '
|
|
29
|
-
.
|
|
29
|
+
. $context->argumentsAsArray($this->args)
|
|
30
30
|
. ', ' . var_export($this->nullsafe, true) . ')';
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -44,15 +44,15 @@ class SandboxNode extends StatementNode
|
|
|
44
44
|
ob_start(fn() => '');
|
|
45
45
|
try {
|
|
46
46
|
$this->createTemplate(%node, %node, 'sandbox')->renderToContentType(%dump) %line;
|
|
47
|
-
echo ob_get_clean();
|
|
48
47
|
} catch (\Throwable $ʟ_e) {
|
|
49
48
|
if (isset($this->global->coreExceptionHandler)) {
|
|
50
|
-
|
|
49
|
+
ob_clean();
|
|
51
50
|
($this->global->coreExceptionHandler)($ʟ_e, $this);
|
|
52
51
|
} else {
|
|
53
|
-
echo ob_get_clean();
|
|
54
52
|
throw $ʟ_e;
|
|
55
53
|
}
|
|
54
|
+
} finally {
|
|
55
|
+
echo ob_get_clean();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
|
package/vendor/latte/latte/src/Latte/Sandbox/Nodes/{StaticCallNode.php → StaticMethodCallNode.php}
RENAMED
|
@@ -13,9 +13,9 @@ use Latte\Compiler\Nodes\Php\Expression;
|
|
|
13
13
|
use Latte\Compiler\PrintContext;
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class StaticMethodCallNode extends Expression\StaticMethodCallNode
|
|
17
17
|
{
|
|
18
|
-
public function __construct(Expression\
|
|
18
|
+
public function __construct(Expression\StaticMethodCallNode $from)
|
|
19
19
|
{
|
|
20
20
|
parent::__construct($from->class, $from->name, $from->args, $from->position);
|
|
21
21
|
}
|
|
@@ -26,6 +26,6 @@ class StaticCallNode extends Expression\StaticCallNode
|
|
|
26
26
|
return '$this->global->sandbox->call(['
|
|
27
27
|
. $context->memberAsString($this->class) . ', '
|
|
28
28
|
. $context->memberAsString($this->name) . '], '
|
|
29
|
-
.
|
|
29
|
+
. $context->argumentsAsArray($this->args) . ')';
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -13,9 +13,9 @@ use Latte\Compiler\Nodes\Php\Expression;
|
|
|
13
13
|
use Latte\Compiler\PrintContext;
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class StaticMethodCallableNode extends Expression\StaticMethodCallableNode
|
|
17
17
|
{
|
|
18
|
-
public function __construct(Expression\
|
|
18
|
+
public function __construct(Expression\StaticMethodCallableNode $from)
|
|
19
19
|
{
|
|
20
20
|
parent::__construct($from->class, $from->name, $from->position);
|
|
21
21
|
}
|
|
@@ -10,12 +10,12 @@ declare(strict_types=1);
|
|
|
10
10
|
namespace Latte\Sandbox;
|
|
11
11
|
|
|
12
12
|
use Latte;
|
|
13
|
-
use Latte\Compiler\ExpressionBuilder;
|
|
14
13
|
use Latte\Compiler\Node;
|
|
15
14
|
use Latte\Compiler\Nodes\Php;
|
|
16
15
|
use Latte\Compiler\Nodes\Php\Expression;
|
|
17
16
|
use Latte\Compiler\Nodes\TemplateNode;
|
|
18
17
|
use Latte\Compiler\NodeTraverser;
|
|
18
|
+
use Latte\Compiler\PrintContext;
|
|
19
19
|
use Latte\Engine;
|
|
20
20
|
use Latte\Runtime\Template;
|
|
21
21
|
use Latte\SecurityViolationException;
|
|
@@ -26,8 +26,6 @@ use Latte\SecurityViolationException;
|
|
|
26
26
|
*/
|
|
27
27
|
final class SandboxExtension extends Latte\Extension
|
|
28
28
|
{
|
|
29
|
-
use Latte\Strict;
|
|
30
|
-
|
|
31
29
|
private ?Latte\Policy $policy;
|
|
32
30
|
|
|
33
31
|
|
|
@@ -95,8 +93,10 @@ final class SandboxExtension extends Latte\Extension
|
|
|
95
93
|
throw new SecurityViolationException("Function $node->name() is not allowed.", $node->position);
|
|
96
94
|
|
|
97
95
|
} elseif ($node->args) {
|
|
98
|
-
$arg =
|
|
99
|
-
->
|
|
96
|
+
$arg = new Expression\AuxiliaryNode(
|
|
97
|
+
fn(PrintContext $context, ...$args) => '$this->global->sandbox->args(' . $context->implode($args) . ')',
|
|
98
|
+
$node->args,
|
|
99
|
+
);
|
|
100
100
|
$node->args = [new Php\ArgumentNode($arg, unpack: true)];
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -108,8 +108,10 @@ final class SandboxExtension extends Latte\Extension
|
|
|
108
108
|
throw new SecurityViolationException("Filter |$name is not allowed.", $node->position);
|
|
109
109
|
|
|
110
110
|
} elseif ($node->args) {
|
|
111
|
-
$arg =
|
|
112
|
-
->
|
|
111
|
+
$arg = new Expression\AuxiliaryNode(
|
|
112
|
+
fn(PrintContext $context, ...$args) => '$this->global->sandbox->args(' . $context->implode($args) . ')',
|
|
113
|
+
$node->args,
|
|
114
|
+
);
|
|
113
115
|
$node->args = [new Php\ArgumentNode($arg, unpack: true)];
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -121,8 +123,8 @@ final class SandboxExtension extends Latte\Extension
|
|
|
121
123
|
|| $node instanceof Expression\FunctionCallableNode
|
|
122
124
|
|| $node instanceof Expression\MethodCallNode
|
|
123
125
|
|| $node instanceof Expression\MethodCallableNode
|
|
124
|
-
|| $node instanceof Expression\
|
|
125
|
-
|| $node instanceof Expression\
|
|
126
|
+
|| $node instanceof Expression\StaticMethodCallNode
|
|
127
|
+
|| $node instanceof Expression\StaticMethodCallableNode
|
|
126
128
|
) {
|
|
127
129
|
$class = namespace\Nodes::class . strrchr($node::class, '\\');
|
|
128
130
|
return new $class($node);
|
|
@@ -37,14 +37,10 @@ class CompileException extends \Exception implements Exception
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* The exception
|
|
40
|
+
* The exception occurred during template rendering.
|
|
41
41
|
*/
|
|
42
|
-
class
|
|
42
|
+
class RuntimeException extends \RuntimeException implements Exception
|
|
43
43
|
{
|
|
44
|
-
public function __construct()
|
|
45
|
-
{
|
|
46
|
-
parent::__construct(preg_last_error_msg(), preg_last_error());
|
|
47
|
-
}
|
|
48
44
|
}
|
|
49
45
|
|
|
50
46
|
|
|
@@ -62,8 +58,3 @@ class SecurityViolationException extends \Exception implements Exception
|
|
|
62
58
|
$this->generateMessage();
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
class RuntimeException extends \RuntimeException implements Exception
|
|
68
|
-
{
|
|
69
|
-
}
|
|
@@ -15,11 +15,10 @@ use Nette;
|
|
|
15
15
|
|
|
16
16
|
final class Linter
|
|
17
17
|
{
|
|
18
|
-
use Latte\Strict;
|
|
19
|
-
|
|
20
18
|
public function __construct(
|
|
21
19
|
private ?Latte\Engine $engine = null,
|
|
22
20
|
private bool $debug = false,
|
|
21
|
+
private bool $strict = false,
|
|
23
22
|
) {
|
|
24
23
|
}
|
|
25
24
|
|
|
@@ -31,10 +30,6 @@ final class Linter
|
|
|
31
30
|
echo "Scanning $path\n";
|
|
32
31
|
|
|
33
32
|
$files = $this->getFiles($path);
|
|
34
|
-
|
|
35
|
-
$this->engine ??= $this->createEngine();
|
|
36
|
-
$this->engine->setLoader(new Latte\Loaders\StringLoader);
|
|
37
|
-
|
|
38
33
|
$counter = 0;
|
|
39
34
|
$errors = 0;
|
|
40
35
|
foreach ($files as $file) {
|
|
@@ -53,6 +48,8 @@ final class Linter
|
|
|
53
48
|
private function createEngine(): Latte\Engine
|
|
54
49
|
{
|
|
55
50
|
$engine = new Latte\Engine;
|
|
51
|
+
$engine->enablePhpLinter(PHP_BINARY);
|
|
52
|
+
$engine->setStrictParsing($this->strict);
|
|
56
53
|
$engine->addExtension(new Latte\Essential\TranslatorExtension(null));
|
|
57
54
|
|
|
58
55
|
if (class_exists(Nette\Bridges\ApplicationLatte\UIExtension::class)) {
|
|
@@ -71,6 +68,13 @@ final class Linter
|
|
|
71
68
|
}
|
|
72
69
|
|
|
73
70
|
|
|
71
|
+
public function getEngine(): Latte\Engine
|
|
72
|
+
{
|
|
73
|
+
$this->engine ??= $this->createEngine();
|
|
74
|
+
return $this->engine;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
74
78
|
public function lintLatte(string $file): bool
|
|
75
79
|
{
|
|
76
80
|
set_error_handler(function (int $severity, string $message) use ($file) {
|
|
@@ -91,7 +95,9 @@ final class Linter
|
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
try {
|
|
94
|
-
$
|
|
98
|
+
$this->getEngine()
|
|
99
|
+
->setLoader(new Latte\Loaders\StringLoader)
|
|
100
|
+
->compile($s);
|
|
95
101
|
|
|
96
102
|
} catch (Latte\CompileException $e) {
|
|
97
103
|
if ($this->debug) {
|
|
@@ -106,40 +112,10 @@ final class Linter
|
|
|
106
112
|
restore_error_handler();
|
|
107
113
|
}
|
|
108
114
|
|
|
109
|
-
if ($error = $this->lintPHP($code)) {
|
|
110
|
-
fwrite(STDERR, "[ERROR] $file $error\n");
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
115
|
return true;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
|
|
118
|
-
private function lintPHP(string $code): ?string
|
|
119
|
-
{
|
|
120
|
-
$php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
|
|
121
|
-
$stdin = tmpfile();
|
|
122
|
-
fwrite($stdin, $code);
|
|
123
|
-
fseek($stdin, 0);
|
|
124
|
-
$process = proc_open(
|
|
125
|
-
$php . ' -l -d display_errors=1',
|
|
126
|
-
[$stdin, ['pipe', 'w'], ['pipe', 'w']],
|
|
127
|
-
$pipes,
|
|
128
|
-
null,
|
|
129
|
-
null,
|
|
130
|
-
['bypass_shell' => true],
|
|
131
|
-
);
|
|
132
|
-
if (!is_resource($process)) {
|
|
133
|
-
return 'Unable to lint PHP code';
|
|
134
|
-
}
|
|
135
|
-
$error = stream_get_contents($pipes[1]);
|
|
136
|
-
if (proc_close($process)) {
|
|
137
|
-
return strip_tags(explode("\n", $error)[1]);
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
119
|
private function initialize(): void
|
|
144
120
|
{
|
|
145
121
|
if (function_exists('pcntl_signal')) {
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<?php
|
|
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
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
|
-
namespace Latte\Compiler\Nodes\Html;
|
|
11
|
-
|
|
12
|
-
use Latte\Compiler\Nodes\AreaNode;
|
|
13
|
-
use Latte\Compiler\Nodes\FragmentNode;
|
|
14
|
-
use Latte\Compiler\Position;
|
|
15
|
-
use Latte\Compiler\PrintContext;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class QuotedValue extends AreaNode
|
|
19
|
-
{
|
|
20
|
-
public function __construct(
|
|
21
|
-
public AreaNode $value,
|
|
22
|
-
public string $quote,
|
|
23
|
-
public ?Position $position = null,
|
|
24
|
-
) {
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
public function print(PrintContext $context): string
|
|
29
|
-
{
|
|
30
|
-
$res = 'echo ' . var_export($this->quote, true) . ';';
|
|
31
|
-
$escaper = $context->beginEscape();
|
|
32
|
-
$escaper->enterHtmlAttributeQuote($this->quote);
|
|
33
|
-
|
|
34
|
-
if ($this->value instanceof FragmentNode && $escaper->export() === 'html/attr/url') {
|
|
35
|
-
foreach ($this->value->children as $child) {
|
|
36
|
-
$res .= $child->print($context);
|
|
37
|
-
$escaper->enterHtmlAttribute(null, $this->quote);
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
$res .= $this->value->print($context);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
$res .= 'echo ' . var_export($this->quote, true) . ';';
|
|
44
|
-
$context->restoreEscape();
|
|
45
|
-
return $res;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
public function &getIterator(): \Generator
|
|
50
|
-
{
|
|
51
|
-
yield $this->value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<?php
|
|
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
|
-
declare(strict_types=1);
|
|
9
|
-
|
|
10
|
-
namespace Latte;
|
|
11
|
-
|
|
12
|
-
use LogicException;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Better OOP experience.
|
|
17
|
-
*/
|
|
18
|
-
trait Strict
|
|
19
|
-
{
|
|
20
|
-
/**
|
|
21
|
-
* Call to undefined method.
|
|
22
|
-
* @param mixed[] $args
|
|
23
|
-
* @throws LogicException
|
|
24
|
-
*/
|
|
25
|
-
public function __call(string $name, array $args): mixed
|
|
26
|
-
{
|
|
27
|
-
$class = method_exists($this, $name) ? 'parent' : static::class;
|
|
28
|
-
$items = (new \ReflectionClass($this))->getMethods(\ReflectionMethod::IS_PUBLIC);
|
|
29
|
-
$items = array_map(fn($item) => $item->getName(), $items);
|
|
30
|
-
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
31
|
-
? ", did you mean $t()?"
|
|
32
|
-
: '.';
|
|
33
|
-
throw new LogicException("Call to undefined method $class::$name()$hint");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Call to undefined static method.
|
|
39
|
-
* @param mixed[] $args
|
|
40
|
-
* @throws LogicException
|
|
41
|
-
*/
|
|
42
|
-
public static function __callStatic(string $name, array $args): mixed
|
|
43
|
-
{
|
|
44
|
-
$rc = new \ReflectionClass(static::class);
|
|
45
|
-
$items = array_filter($rc->getMethods(\ReflectionMethod::IS_STATIC), fn($m) => $m->isPublic());
|
|
46
|
-
$items = array_map(fn($item) => $item->getName(), $items);
|
|
47
|
-
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
48
|
-
? ", did you mean $t()?"
|
|
49
|
-
: '.';
|
|
50
|
-
throw new LogicException("Call to undefined static method $rc->name::$name()$hint");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Access to undeclared property.
|
|
56
|
-
* @throws LogicException
|
|
57
|
-
*/
|
|
58
|
-
public function &__get(string $name): mixed
|
|
59
|
-
{
|
|
60
|
-
$rc = new \ReflectionClass($this);
|
|
61
|
-
$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($p) => !$p->isStatic());
|
|
62
|
-
$items = array_map(fn($item) => $item->getName(), $items);
|
|
63
|
-
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
64
|
-
? ", did you mean $$t?"
|
|
65
|
-
: '.';
|
|
66
|
-
throw new LogicException("Attempt to read undeclared property $rc->name::$$name$hint");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Access to undeclared property.
|
|
72
|
-
* @throws LogicException
|
|
73
|
-
*/
|
|
74
|
-
public function __set(string $name, mixed $value): void
|
|
75
|
-
{
|
|
76
|
-
$rc = new \ReflectionClass($this);
|
|
77
|
-
$items = array_filter($rc->getProperties(\ReflectionProperty::IS_PUBLIC), fn($p) => !$p->isStatic());
|
|
78
|
-
$items = array_map(fn($item) => $item->getName(), $items);
|
|
79
|
-
$hint = ($t = Helpers::getSuggestion($items, $name))
|
|
80
|
-
? ", did you mean $$t?"
|
|
81
|
-
: '.';
|
|
82
|
-
throw new LogicException("Attempt to write to undeclared property $rc->name::$$name$hint");
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
public function __isset(string $name): bool
|
|
87
|
-
{
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Access to undeclared property.
|
|
94
|
-
* @throws LogicException
|
|
95
|
-
*/
|
|
96
|
-
public function __unset(string $name): void
|
|
97
|
-
{
|
|
98
|
-
$class = static::class;
|
|
99
|
-
throw new LogicException("Attempt to unset undeclared property $class::$$name.");
|
|
100
|
-
}
|
|
101
|
-
}
|