Skip to content

Commit

Permalink
fixes after PHP upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
clash82 committed Jun 26, 2024
1 parent 43dc2b8 commit 7ee2553
Show file tree
Hide file tree
Showing 32 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This repository is a home for `Pstryk` gallery framework.
![phpstan](https://github.com/clash82/pstryk/actions/workflows/phpstan.yaml/badge.svg)
![phpunit](https://github.com/clash82/pstryk/actions/workflows/phpunit.yaml/badge.svg)

App was built on top of PHP 8.0 and Symfony 5.4 framework.
App was built on top of PHP 8.2 and Symfony 5.4 framework.

Refer to the included [how-to](docs/how-to.md) to get details about installation and deployment.

Expand Down
2 changes: 1 addition & 1 deletion public_html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
Request::setTrustedProxies(explode(',', (string) $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
Expand Down
6 changes: 3 additions & 3 deletions src/Command/RebuildImagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class RebuildImagesCommand extends Command
protected static $defaultName = 'app:rebuild-images';

public function __construct(
private ImageConverter $imageConverter,
private ItemProvider $itemProvider,
private AlbumProvider $albumProvider
private readonly ImageConverter $imageConverter,
private readonly ItemProvider $itemProvider,
private readonly AlbumProvider $albumProvider
) {
parent::__construct();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class AdminController extends AbstractController
{
public function __construct(private ItemProvider $itemProvider, private ItemManager $itemManager, private AlbumProvider $albumProvider, private ParametersHelper $parametersHelper, private RedirectHelper $redirectHelper, private AdminSettingsProvider $adminSettingsProvider, private AdminSettingsManager $adminSettingsManager)
public function __construct(private readonly ItemProvider $itemProvider, private readonly ItemManager $itemManager, private readonly AlbumProvider $albumProvider, private readonly ParametersHelper $parametersHelper, private readonly RedirectHelper $redirectHelper, private readonly AdminSettingsProvider $adminSettingsProvider, private readonly AdminSettingsManager $adminSettingsManager)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class AlbumController extends AbstractController
{
public function __construct(private ItemProvider $itemProvider, private AlbumProvider $albumProvider, private DomainHelper $domainHelper, private CounterHelper $counterHelper)
public function __construct(private readonly ItemProvider $itemProvider, private readonly AlbumProvider $albumProvider, private readonly DomainHelper $domainHelper, private readonly CounterHelper $counterHelper)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/FeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class FeedController extends AbstractController
{
public function __construct(private ItemProvider $itemProvider, private AlbumProvider $albumProvider, private DomainHelper $domainHelper)
public function __construct(private readonly ItemProvider $itemProvider, private readonly AlbumProvider $albumProvider, private readonly DomainHelper $domainHelper)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Helper/DomainHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class DomainHelper extends AbstractController
{
public function __construct(private AlbumProvider $albumProvider)
public function __construct(private readonly AlbumProvider $albumProvider)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/RobotsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class RobotsController extends AbstractController
{
public function __construct(private DomainHelper $domainHelper, private Packages $packages)
public function __construct(private readonly DomainHelper $domainHelper, private readonly Packages $packages)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SecurityController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function login(AuthenticationUtils $authenticationUtils): Response
/**
* @Route("/zaplecze/logout", name="app_admin_logout")
*/
public function logout(): void
public function logout(): never
{
throw new LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class SitemapController extends AbstractController
{
public function __construct(private ItemProvider $itemProvider, private DomainHelper $domainHelper)
public function __construct(private readonly ItemProvider $itemProvider, private readonly DomainHelper $domainHelper)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/DataFixtures/ImageFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class ImageFixtures extends Fixture implements DependentFixtureInterface
private bool $populateImages = true;

public function __construct(
private AlbumProvider $albumProvider,
private StoragePathProvider $storagePathProvider,
private ImageConverter $imageConverter,
private readonly AlbumProvider $albumProvider,
private readonly StoragePathProvider $storagePathProvider,
private readonly ImageConverter $imageConverter,
ParameterBagInterface $parameterBag
) {
if ('test' === $parameterBag->get('kernel.environment')) {
Expand Down
6 changes: 3 additions & 3 deletions src/DataFixtures/ItemFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@

class ItemFixtures extends Fixture
{
public const ITEM_REFERENCE = '%s_item_%d';
public const ITEM_LIMIT = 12;
final public const ITEM_REFERENCE = '%s_item_%d';
final public const ITEM_LIMIT = 12;

private const DEFAULT_TITLE = '%s item title %d';
private const DEFAULT_DESCRIPTION = '%s description for item %d';
private const DEFAULT_SLUG = '%s-item-slug-%d';
private const DEFAULT_LATITUDE = 50.31406826596857;
private const DEFAULT_LONGITUDE = 19.119177460670475;

public function __construct(private AlbumProvider $albumProvider)
public function __construct(private readonly AlbumProvider $albumProvider)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/DataFixtures/UserFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UserFixtures extends Fixture
private const DEFAULT_PASSWORD = 'admin';
private const DEFAULT_ROLE = 'ROLE_ADMIN';

public function __construct(private UserPasswordEncoderInterface $passwordEncoder)
public function __construct(private readonly UserPasswordEncoderInterface $passwordEncoder)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/EventListener/EntityListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EntityListener
{
private array $filesToDelete = [];

public function __construct(private StoragePathProvider $storagePathProvider, private ImageConverter $imageConverter, private AlbumProvider $albumProvider)
public function __construct(private readonly StoragePathProvider $storagePathProvider, private readonly ImageConverter $imageConverter, private readonly AlbumProvider $albumProvider)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Form/ItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ItemType extends AbstractType
{
private array $albums = [];

private ?string $defaultAlbum;
private readonly ?string $defaultAlbum;

public function __construct(AlbumProvider $albumProvider, AdminSettingsProvider $adminSettingsProvider)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Image/ImageConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class ImageConverter
{
use UnsharpMaskTrait;

public const JPEG_QUALITY = 93;
final public const JPEG_QUALITY = 93;

private ?Album $album = null;

private bool $applyUnsharpMask = true;

private array $watermark = [];

public function __construct(private ParameterBagInterface $parameterBag, private Packages $packages)
public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly Packages $packages)
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/Manager/ItemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class ItemManager
{
public function __construct(private ItemRepository $itemRepository)
public function __construct(private readonly ItemRepository $itemRepository)
{
}

Expand Down
10 changes: 5 additions & 5 deletions src/Provider/AdminSettingsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

class AdminSettingsProvider
{
public const ITEM_FILTER_OPTIONS_ITEMS_PER_PAGE = 'itemsPerPage';
public const ITEM_FILTER_OPTIONS_ITEMS_SORT = 'itemsSort';
public const ITEM_FILTER_OPTIONS_ITEMS_SORT_DIRECTION = 'itemsSortDirection';
public const ITEM_FILTER_OPTIONS_ALBUM = 'album';
final public const ITEM_FILTER_OPTIONS_ITEMS_PER_PAGE = 'itemsPerPage';
final public const ITEM_FILTER_OPTIONS_ITEMS_SORT = 'itemsSort';
final public const ITEM_FILTER_OPTIONS_ITEMS_SORT_DIRECTION = 'itemsSortDirection';
final public const ITEM_FILTER_OPTIONS_ALBUM = 'album';

private ?Request $request;
private readonly ?Request $request;

public function __construct(RequestStack $requestStack)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Provider/ItemProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

class ItemProvider
{
public const DEFAULT_PAGE_LIMIT = 10;
public const DEFAULT_SORT_COLUMN = 'date';
public const DEFAULT_SORT_DIRECTION = 'desc';
final public const DEFAULT_PAGE_LIMIT = 10;
final public const DEFAULT_SORT_COLUMN = 'date';
final public const DEFAULT_SORT_DIRECTION = 'desc';

public function __construct(private ItemRepository $itemRepository)
public function __construct(private readonly ItemRepository $itemRepository)
{
}

Expand Down
14 changes: 7 additions & 7 deletions src/Provider/StoragePathProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

class StoragePathProvider
{
public const PATH_RAW = 0;
public const PATH_IMAGES = 1;
public const PATH_THUMBS = 2;
final public const PATH_RAW = 0;
final public const PATH_IMAGES = 1;
final public const PATH_THUMBS = 2;

public const RELATIVE_PATH_PATTERN = '%s/../../public_html/%s';
final public const RELATIVE_PATH_PATTERN = '%s/../../public_html/%s';

private string $storageImagesPath;
private readonly string $storageImagesPath;

private string $storageThumbsPath;
private readonly string $storageThumbsPath;

private string $storageRawPath;
private readonly string $storageRawPath;

public function __construct(ParameterBagInterface $parameterBag)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/ItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class ItemRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry, private PaginatorInterface $paginator)
public function __construct(ManagerRegistry $registry, private readonly PaginatorInterface $paginator)
{
parent::__construct($registry, Item::class);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Security/LoginFormAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class LoginFormAuthenticator extends AbstractFormLoginAuthenticator implements P
{
use TargetPathTrait;

public const LOGIN_ROUTE = 'app_admin_login';
final public const LOGIN_ROUTE = 'app_admin_login';

public function __construct(private EntityManagerInterface $entityManager, private UrlGeneratorInterface $urlGenerator, private CsrfTokenManagerInterface $csrfTokenManager, private UserPasswordEncoderInterface $passwordEncoder)
public function __construct(private readonly EntityManagerInterface $entityManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly CsrfTokenManagerInterface $csrfTokenManager, private readonly UserPasswordEncoderInterface $passwordEncoder)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/ControllerActionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function __construct(protected RequestStack $requestStack)
public function getFunctions(): array
{
return [
new TwigFunction('getControllerName', [$this, 'getControllerName']),
new TwigFunction('getActionName', [$this, 'getActionName']),
new TwigFunction('getControllerName', $this->getControllerName(...)),
new TwigFunction('getActionName', $this->getActionName(...)),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/MatomoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

class MatomoExtension extends AbstractExtension
{
public function __construct(private MatomoHelper $matomoHelper)
public function __construct(private readonly MatomoHelper $matomoHelper)
{
}

public function getFunctions(): array
{
return [
new TwigFunction('getMatomoCode', [$this, 'getCode']),
new TwigFunction('getMatomoCode', $this->getCode(...)),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/RouteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public function __construct(RequestStack $requestStack)
public function getFunctions(): array
{
return [
new TwigFunction('getRoute', [$this, 'getRoute']),
new TwigFunction('getRouteWithPagination', [$this, 'getRouteWithPagination']),
new TwigFunction('getRoute', $this->getRoute(...)),
new TwigFunction('getRouteWithPagination', $this->getRouteWithPagination(...)),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/VersionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class VersionExtension extends AbstractExtension
public function getFunctions(): array
{
return [
new TwigFunction('getPhpVersion', [$this, 'getPhpVersion']),
new TwigFunction('getSymfonyVersion', [$this, 'getSymfonyVersion']),
new TwigFunction('getPhpVersion', $this->getPhpVersion(...)),
new TwigFunction('getSymfonyVersion', $this->getSymfonyVersion(...)),
];
}

Expand Down
28 changes: 14 additions & 14 deletions src/Value/Album.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,33 @@

class Album
{
private string $title;
private readonly string $title;

private string $description;
private readonly string $description;

private int $paginationLimit;
private readonly int $paginationLimit;

private int $feedLimit;
private readonly int $feedLimit;

private string $feedUrl;
private readonly string $feedUrl;

private bool $sitemap;
private readonly bool $sitemap;

private Domains $domains;
private readonly Domains $domains;

private Tags $tags;
private readonly Tags $tags;

private Watermark $watermark;
private readonly Watermark $watermark;

private int $imageHorizontalMaxWidth;
private readonly int $imageHorizontalMaxWidth;

private int $imageVerticalMaxHeight;
private readonly int $imageVerticalMaxHeight;

private int $thumbHorizontalMaxWidth;
private readonly int $thumbHorizontalMaxWidth;

private int $thumbVerticalMaxHeight;
private readonly int $thumbVerticalMaxHeight;

public function __construct(private string $slug, array $album = [])
public function __construct(private readonly string $slug, array $album = [])
{
if (!isset($album['title'])) {
/* @noinspection PhpUnhandledExceptionInspection */
Expand Down
8 changes: 4 additions & 4 deletions src/Value/Enum/WatermarkPosition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class WatermarkPosition
{
public const POSITION_TOP_LEFT = 0;
public const POSITION_TOP_RIGHT = 1;
public const POSITION_BOTTOM_LEFT = 2;
public const POSITION_BOTTOM_RIGHT = 3;
final public const POSITION_TOP_LEFT = 0;
final public const POSITION_TOP_RIGHT = 1;
final public const POSITION_BOTTOM_LEFT = 2;
final public const POSITION_BOTTOM_RIGHT = 3;
}
2 changes: 1 addition & 1 deletion src/Value/FilePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class FilePath
{
public function __construct(private StoragePathProvider $storagePathProvider, private string $filename, private string $extension)
public function __construct(private readonly StoragePathProvider $storagePathProvider, private readonly string $filename, private readonly string $extension)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/Value/ImageDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

class ImageDetails
{
public const ATTR_WIDTH = 'width';
public const ATTR_HEIGHT = 'height';
final public const ATTR_WIDTH = 'width';
final public const ATTR_HEIGHT = 'height';

private array $cache = [];

public function __construct(private FilePath $filePath)
public function __construct(private readonly FilePath $filePath)
{
}

Expand Down
Loading

0 comments on commit 7ee2553

Please sign in to comment.