Skip to content

Commit

Permalink
Add type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Sep 29, 2017
1 parent 4e45c1a commit 4fa43fc
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/Application/ComponentsProtectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final public function injectReader(Reader $reader)
/**
* @param ReflectionClass|ReflectionMethod $reflection
*/
public function checkRequirements($reflection)
public function checkRequirements($reflection): void
{
if (
$reflection instanceof ReflectionMethod
Expand Down
2 changes: 1 addition & 1 deletion src/DI/ComponentsProtectionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class ComponentsProtectionExtension extends CompilerExtension
{
public function loadConfiguration()
public function loadConfiguration(): void
{
$builder = $this->getContainerBuilder();

Expand Down
6 changes: 2 additions & 4 deletions src/Rules/ActionsRuleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
class ActionsRuleHandler implements RuleHandlerInterface
{
/**
* @param Actions $rule
* @param Request $request
* @param string|null $component
* @param Actions $rule
*
* @throws VerificationException
*/
public function checkRule(RuleInterface $rule, Request $request, $component = null)
public function checkRule(RuleInterface $rule, Request $request, ?string $component = null): void
{
if (!$rule instanceof Actions) {
throw new InvalidArgumentException(sprintf('Unknown rule "%s" given.', get_class($rule)));
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/src/ActionsRuleHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class ActionsRuleHandlerTest extends Unit
*/
protected $tester;

public function testActionDefault()
public function testActionDefault(): void
{
$this->tester->amOnPage('/article/');
$this->tester->seeResponseCodeIs(200);
$this->tester->see('header');
$this->tester->see('footer');
}

public function testActionDetail()
public function testActionDetail(): void
{
try {
$this->tester->amOnPage('/article/detail/1');
Expand All @@ -35,15 +35,15 @@ public function testActionDetail()
}
}

public function testActionEdit()
public function testActionEdit(): void
{
$this->tester->amOnPage('/article/edit/1');
$this->tester->seeResponseCodeIs(200);
$this->tester->see('header');
$this->tester->dontSee('footer');
}

public function testComponentNotAllowed()
public function testComponentNotAllowed(): void
{
try {
$this->tester->amOnPage('/article/?do=unprotected-signal');
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/src/Classes/ArticlePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ class ArticlePresenter extends Presenter
{
use ComponentsProtectionTrait;

public function actionDefault()
public function actionDefault(): void
{
}

/**
* @param int $id
*/
public function actionDetail($id)
public function actionDetail($id): void
{
}

/**
* @param int $id
*/
public function actionEdit($id)
public function actionEdit($id): void
{
}

Expand All @@ -37,7 +37,7 @@ public function actionEdit($id)
*
* @return BlockControl
*/
protected function createComponentHeader()
protected function createComponentHeader(): BlockControl
{
return new BlockControl();
}
Expand All @@ -50,16 +50,16 @@ protected function createComponentHeader()
*
* @return BlockControl
*/
protected function createComponentFooter()
protected function createComponentFooter(): BlockControl
{
return new BlockControl();
}

protected function createComponentUnprotected()
protected function createComponentUnprotected(): void
{
}

public function formatTemplateFiles()
public function formatTemplateFiles(): array
{
$name = $this->getName();
$presenter = substr($name, strrpos(':'.$name, ':'));
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/src/Classes/BlockControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class BlockControl extends Control
{
public function render()
public function render(): void
{
$this->template->setFile(__DIR__.'/../../templates/block.latte');
$this->template->render();
Expand Down
5 changes: 1 addition & 4 deletions tests/functional/src/Classes/RouterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
*/
class RouterFactory
{
/**
* @return IRouter
*/
public function create()
public function create(): IRouter
{
$router = new RouteList();
$router[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/src/ActionsRuleHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class ActionsRuleHandlerTest extends Unit
*/
private $handler;

protected function _before()
protected function _before(): void
{
$this->handler = new ActionsRuleHandler();
}

public function testAllowedTrue()
public function testAllowedTrue(): void
{
$rule = new Actions();
$rule->actions = ['default'];
Expand All @@ -38,7 +38,7 @@ public function testAllowedTrue()
$this->handler->checkRule($rule, $request);
}

public function testAllowedFalse()
public function testAllowedFalse(): void
{
$rule = new Actions();
$rule->actions = [];
Expand All @@ -54,7 +54,7 @@ public function testAllowedFalse()
}
}

public function testUnknownAnnotation()
public function testUnknownAnnotation(): void
{
$rule = Phony::mock(RuleInterface::class)->get();
$request = new Request('Test', 'GET', []);
Expand Down

0 comments on commit 4fa43fc

Please sign in to comment.