Skip to content

Commit

Permalink
Merge pull request #39 from haltuf/master
Browse files Browse the repository at this point in the history
fix compatibility with PHP < 8
  • Loading branch information
hrach authored Dec 7, 2022
2 parents 63c7481 + 752ad93 commit 49ffce9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SecuredLinksPresenterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ public function createSecuredLink(Component $component, string $link, string $de
$method = $component->formatSignalMethod($signal);
$signalReflection = $reflection->getMethod($method);

if (!$signalReflection->hasAnnotation('secured') && count($signalReflection->getAttributes(Secured::class)) === 0) {
if (!$signalReflection->hasAnnotation('secured')) {
break;
}
if (method_exists($signalReflection, 'getAttributes') && count($signalReflection->getAttributes(Secured::class)) === 0) {
break;
}

Expand Down
5 changes: 5 additions & 0 deletions tests/cases/SecuredLinksTest.php7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class TestPresenter extends Presenter
$this->redirect('this');
}

public function handleCancel(bool $value)
{
$this->redirect('this');
}
}


Expand All @@ -57,6 +61,7 @@ $presenter->injectPrimary(NULL, NULL, $router, $httpRequest, $httpResponse, $ses
$presenter->run($request);

Assert::same('/index.php?value=0&action=default&do=pay&presenter=Test&_sec=JqCasYHU', $presenter->link('pay!', [FALSE]));
Assert::same('/index.php?value=0&action=default&do=cancel&presenter=Test', $presenter->link('cancel!', [FALSE]));

$presenter->run(new Request('Test', 'GET', [
'action' => 'default',
Expand Down

0 comments on commit 49ffce9

Please sign in to comment.