Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 18, 2022
1 parent ee666c6 commit b185e1c
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/Latte/Essential/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public function printVars(array $vars): void
*/
public function addProperties(Php\ClassType $class, array $props): void
{
$printer = new Php\Printer;
foreach ($props as $name => $value) {
$type = Php\Type::getType($value);
$prop = $class->addProperty($name);
Expand All @@ -88,7 +87,6 @@ public function addProperties(Php\ClassType $class, array $props): void
*/
public function addFunctions(Php\ClassType $class, array $funcs): void
{
$printer = new Php\Printer;
foreach ($funcs as $name => $func) {
$method = (new Php\Factory)->fromCallable($func);
$type = $this->printType($method->getReturnType(), $method->isReturnNullable(), $class->getNamespace()) ?: 'mixed';
Expand Down
4 changes: 4 additions & 0 deletions src/Latte/Essential/Nodes/DefineNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ private function printDynamic(PrintContext $context): string
public function &getIterator(): \Generator
{
yield $this->block->name;
foreach ($this->block->parameters as &$param) {
yield $param;
}

yield $this->content;
}
}
4 changes: 2 additions & 2 deletions src/Latte/Essential/Nodes/ForNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public function print(PrintContext $context): string

public function &getIterator(): \Generator
{
foreach ($this->init as $item) {
foreach ($this->init as &$item) {
yield $item;
}

if ($this->condition) {
yield $this->condition;
}

foreach ($this->next as $item) {
foreach ($this->next as &$item) {
yield $item;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Latte/Essential/Nodes/ParametersNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function print(PrintContext $context): string

public function &getIterator(): \Generator
{
foreach ($this->parameters as $param) {
foreach ($this->parameters as &$param) {
yield $param;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Latte/Essential/Nodes/VarNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function print(PrintContext $context): string

public function &getIterator(): \Generator
{
foreach ($this->assignments as $assign) {
foreach ($this->assignments as &$assign) {
yield $assign;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Latte/Runtime/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Latte\ContentType;
use Latte\RuntimeException;
use Nette;
use Stringable;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Latte/Runtime/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Html implements HtmlStringable
private string $value;


public function __construct(string|\Stringable|int|float|null $value)
public function __construct($value)
{
$this->value = (string) $value;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/tags/define.nodes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ Assert::match(<<<'XX'
Define:
String:
value: test
Assign:
Variable:
name: a
Null:
Assign:
Variable:
name: b
New:
Name:
parts: ['Foo']
Fragment:
Text:
content: '...'
Expand Down

0 comments on commit b185e1c

Please sign in to comment.