Skip to content

Commit

Permalink
used typed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
konecnyjakub committed Sep 5, 2020
1 parent 646ddd2 commit 15249ad
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
Version 2.3.0-dev
- raised minimal version of PHP to 7.4
- used typed properties (possible BC break)

Version 2.2.0
- raised minimal version of PHP to 7.3
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -23,7 +23,7 @@
"nette/application": "^3.0",
"nette/utils": "^3.0",
"latte/latte": "^2.5 || ^3.0",
"nexendrie/utils": "^1.7",
"nexendrie/utils": "^1.8",
"symfony/polyfill-php80": "^1.18"
},
"require-dev": {
Expand Down
14 changes: 5 additions & 9 deletions src/BookControl.php
Expand Up @@ -14,18 +14,14 @@
* @method void onRender(BookControl $book, string $page)
*/
class BookControl extends \Nette\Application\UI\Control {
/** @var string */
private $presenterName;
/** @var string */
private $folder;
private string $presenterName;
private string $folder;
/** @var callable|BookPagesStorage */
protected $pages;
/** @var string */
protected $indexTemplate = __DIR__ . "/bookIndex.latte";
/** @var string */
protected $pageTemplate = __DIR__ . "/bookPage.latte";
protected string $indexTemplate = __DIR__ . "/bookIndex.latte";
protected string $pageTemplate = __DIR__ . "/bookPage.latte";
/** @var callable[] */
public $onRender = [];
public array $onRender = [];

public function __construct(string $presenterName, string $folder) {
$this->presenterName = $presenterName;
Expand Down
8 changes: 3 additions & 5 deletions src/BookPage.php
Expand Up @@ -11,12 +11,10 @@
*/
class BookPage {
use \Nette\SmartObject;
/** @var string */
protected $slug;
/** @var string */
protected $title;
protected string $slug;
protected string $title;
/** @var array of [IBookPageCondition, string] */
protected $conditions = [];
protected array $conditions = [];

public function __construct(string $slug, string $title) {
$this->slug = $slug;
Expand Down
6 changes: 2 additions & 4 deletions src/BookPagesStorage.php
Expand Up @@ -9,10 +9,8 @@
* @author Jakub Konečný
*/
final class BookPagesStorage extends Collection {
/** @var string */
protected $class = BookPage::class;
/** @var string */
protected $uniqueProperty = "slug";
protected string $class = BookPage::class;
protected ?string $uniqueProperty = "slug";

public function hasPage(string $slug): bool {
return $this->hasItems(["slug" => $slug, "allowed" => true]);
Expand Down
3 changes: 1 addition & 2 deletions tests/Nexendrie/BookComponent/BookControlTest.phpt
Expand Up @@ -15,8 +15,7 @@ require __DIR__ . "/../../bootstrap.php";
* @testCase
*/
final class BookControlTest extends \Tester\TestCase {
/** @var BookControl */
private $control;
private BookControl $control;

use \Testbench\TComponent;
use \Testbench\TCompiledContainer;
Expand Down
3 changes: 1 addition & 2 deletions tests/Nexendrie/BookComponent/BookPageTest.phpt
Expand Up @@ -14,8 +14,7 @@ require __DIR__ . "/../../bootstrap.php";
* @testCase
*/
final class BookPageTest extends \Tester\TestCase {
/** @var BookPage */
private $page;
private BookPage $page;

protected function setUp() {
$this->page = new BookPage("slug", "title");
Expand Down
3 changes: 1 addition & 2 deletions tests/Nexendrie/BookComponent/BookPagesStorageTest.phpt
Expand Up @@ -14,8 +14,7 @@ require __DIR__ . "/../../bootstrap.php";
* @testCase
*/
final class BookPagesStorageTest extends \Tester\TestCase {
/** @var BookPagesStorage */
private $storage;
private BookPagesStorage $storage;

protected function setUp() {
$this->storage = new BookPagesStorage();
Expand Down
5 changes: 2 additions & 3 deletions tests/Nexendrie/BookComponent/ConditionCallbackTest.phpt
Expand Up @@ -13,9 +13,8 @@ require __DIR__ . "/../../bootstrap.php";
*/
final class ConditionCallbackTest extends \Tester\TestCase {
use \Testbench\TCompiledContainer;

/** @var ConditionCallback */
protected $condition;

protected ConditionCallback $condition;

public function setUp() {
$this->condition = $this->getService(ConditionCallback::class);
Expand Down
5 changes: 2 additions & 3 deletions tests/Nexendrie/BookComponent/ConditionPermissionTest.phpt
Expand Up @@ -13,9 +13,8 @@ require __DIR__ . "/../../bootstrap.php";
*/
final class ConditionPermissionTest extends \Tester\TestCase {
use \Testbench\TCompiledContainer;

/** @var ConditionPermission */
protected $condition;

protected ConditionPermission $condition;

public function setUp() {
$this->condition = $this->getService(ConditionPermission::class);
Expand Down
5 changes: 2 additions & 3 deletions tests/Nexendrie/BookComponent/ConditionUserInRoleTest.phpt
Expand Up @@ -14,9 +14,8 @@ require __DIR__ . "/../../bootstrap.php";
*/
final class ConditionUserInRoleTest extends \Tester\TestCase {
use \Testbench\TCompiledContainer;

/** @var ConditionUserInRole */
protected $condition;

protected ConditionUserInRole $condition;

public function setUp() {
$this->condition = $this->getService(ConditionUserInRole::class);
Expand Down
5 changes: 2 additions & 3 deletions tests/Nexendrie/BookComponent/ConditionUserLoggedInTest.phpt
Expand Up @@ -13,9 +13,8 @@ require __DIR__ . "/../../bootstrap.php";
*/
final class ConditionUserLoggedInTest extends \Tester\TestCase {
use \Testbench\TCompiledContainer;

/** @var ConditionUserLoggedIn */
protected $condition;

protected ConditionUserLoggedIn $condition;

public function setUp() {
$this->condition = $this->getService(ConditionUserLoggedIn::class);
Expand Down

0 comments on commit 15249ad

Please sign in to comment.