Skip to content

Commit

Permalink
Links with return never (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
lulco authored Jul 10, 2023
1 parent 3656491 commit 6817724
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased][unreleased]

### Fixed
- Avoid always terminating calls in links
- Transformed html attributes

## [0.13.1] - 2023-06-12
Expand Down
11 changes: 10 additions & 1 deletion src/Compiler/NodeVisitor/LinkNodeVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
use PhpParser\ConstExprEvaluationException;
use PhpParser\ConstExprEvaluator;
use PhpParser\Node;
use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Stmt\Echo_;
use PhpParser\Node\Stmt\If_;
use PhpParser\NodeVisitorAbstract;
use Throwable;

Expand Down Expand Up @@ -137,7 +142,11 @@ private function prepareNodes(MethodCall $methodCall, array $attributes): ?array
return null;
}

return $expressions;
return [
new If_(new Identical(new FuncCall(new Name('mt_rand')), new LNumber(0)), [
'stmts' => $expressions,
], $attributes),
];
}

private function isMethodCallUiLink(MethodCall $methodCall): bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ public function actionArrayParam(array $ids, bool $option = false): void
{
}

/**
* @return never
*/
public function persistentConflict($persistentConflict)
{
$this->redirect('default');
}

public function handleDelete(string $id): void
/**
* @return never
*/
public function handleDelete(string $id)
{
}
}

0 comments on commit 6817724

Please sign in to comment.