Skip to content

Commit

Permalink
Use php 8 native property types
Browse files Browse the repository at this point in the history
  • Loading branch information
foxycode committed Oct 9, 2022
1 parent aebd7d3 commit 6fff37a
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 66 deletions.
17 changes: 6 additions & 11 deletions src/AbstractMenuItemsContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
abstract class AbstractMenuItemsContainer implements IMenuItemsContainer
{

/** @var IMenu */
protected $menu;
protected IMenu $menu;

/** @var ILinkGenerator */
protected $linkGenerator;
protected ILinkGenerator $linkGenerator;

/** @var Translator */
protected $translator;
protected Translator $translator;

/** @var IAuthorizator */
protected $authorizator;
protected IAuthorizator $authorizator;

/** @var IMenuItemFactory */
protected $menuItemFactory;
protected IMenuItemFactory $menuItemFactory;

/** @var IMenuItem[] */
private $items = [];
private array $items = [];

public function __construct(
IMenu $menu,
Expand Down
5 changes: 2 additions & 3 deletions src/Config/MenuItemAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
final class MenuItemAction
{

/** @var string */
public $target;
public string $target;

/** @var array<string, string> */
public $parameters = [];
public array $parameters = [];

/**
* @param array<string, mixed> $array
Expand Down
9 changes: 3 additions & 6 deletions src/Config/MenuVisibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
final class MenuVisibility
{

/** @var bool */
public $menu = true;
public bool $menu = true;

/** @var bool */
public $breadcrumbs = true;
public bool $breadcrumbs = true;

/** @var bool */
public $sitemap = true;
public bool $sitemap = true;

}
15 changes: 3 additions & 12 deletions src/Config/TemplatePaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@
final class TemplatePaths
{

/**
* @var string
*/
public $menu = __DIR__ . '/../UI/templates/menu.latte';
public string $menu = __DIR__ . '/../UI/templates/menu.latte';

/**
* @var string
*/
public $breadcrumbs = __DIR__ . '/../UI/templates/breadcrumbs.latte';
public string $breadcrumbs = __DIR__ . '/../UI/templates/breadcrumbs.latte';

/**
* @var string
*/
public $sitemap = __DIR__ . '/../UI/templates/sitemap.latte';
public string $sitemap = __DIR__ . '/../UI/templates/sitemap.latte';

}
6 changes: 2 additions & 4 deletions src/LinkGenerator/NetteLinkGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
final class NetteLinkGenerator implements ILinkGenerator
{

/** @var IRequest */
private $httpRequest;
private IRequest $httpRequest;

/** @var LinkGenerator */
private $linkGenerator;
private LinkGenerator $linkGenerator;

public function __construct(IRequest $httpRequest, LinkGenerator $linkGenerator)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Loaders/DefaultMenuLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class DefaultMenuLoader implements IMenuLoader
{

/** @var array<string, stdClass> */
private $items;
private array $items;

/**
* @param array<string, stdClass> $items
Expand Down
12 changes: 4 additions & 8 deletions src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
final class Menu extends AbstractMenuItemsContainer implements IMenu
{

/** @var IMenuLoader */
private $loader;
private IMenuLoader $loader;

/** @var string */
private $name;
private string $name;

/** @var TemplatePaths */
private $templateConfig;
private TemplatePaths $templateConfig;

/** @var Presenter */
private $activePresenter;
private Presenter $activePresenter;

public function __construct(
ILinkGenerator $linkGenerator,
Expand Down
2 changes: 1 addition & 1 deletion src/MenuContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ final class MenuContainer
{

/** @var IMenu[] */
private $menus = [];
private array $menus = [];

public function getMenu(string $name): IMenu
{
Expand Down
14 changes: 5 additions & 9 deletions src/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ final class MenuItem extends AbstractMenuItemsContainer implements IMenuItem
use MenuItemData;
use MenuItemVisibility;

/** @var string */
private $title;
private string $title;

/** @var MenuItemAction|null */
private $action;
private ?MenuItemAction $action = null;

/** @var string|null */
private $link;
private ?string $link = null;

/** @var bool */
private $active;
private ?bool $active = null;

/** @var string[] */
private $include = [];
private array $include = [];

public function __construct(
IMenu $menu,
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/MenuItemData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ trait MenuItemData
{

/** @var array<string, string> */
private $data = [];
private array $data = [];

/**
* @return array<string, string>
Expand Down
3 changes: 1 addition & 2 deletions src/Traits/MenuItemVisibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
trait MenuItemVisibility
{

/** @var MenuVisibility */
private $visibility;
private MenuVisibility $visibility;

public function isVisibleOnMenu(): bool
{
Expand Down
3 changes: 1 addition & 2 deletions src/UI/MenuComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
final class MenuComponent extends Control
{

/** @var IMenu */
private $menu;
private IMenu $menu;

public function __construct(IMenu $menu)
{
Expand Down
3 changes: 1 addition & 2 deletions src/UI/MenuComponentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
final class MenuComponentFactory
{

/** @var MenuContainer */
private $menuContainer;
private MenuContainer $menuContainer;

public function __construct(MenuContainer $menuContainer)
{
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/Presenters/CategoryPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
final class CategoryPresenter extends Presenter
{

/** @var MenuComponentFactory */
private $menuFactory;
private MenuComponentFactory $menuFactory;

public function injectMenuComponentFactory(MenuComponentFactory $menuFactory): void
{
Expand Down
3 changes: 1 addition & 2 deletions tests/fixtures/Presenters/HomepagePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
final class HomepagePresenter extends Presenter
{

/** @var MenuComponentFactory */
private $menuFactory;
private MenuComponentFactory $menuFactory;

public function injectMenuComponentFactory(MenuComponentFactory $menuFactory): void
{
Expand Down

0 comments on commit 6fff37a

Please sign in to comment.