Skip to content

Commit

Permalink
refactor #210 Use PHP7.4 syntax (Zales0123)
Browse files Browse the repository at this point in the history
This PR was merged into the stable branch.

Discussion
----------

Related to Sylius/Sylius#12891

Commits
-------

8e0f789 Install rector
02cfbad Use PHP 7.4 syntax
  • Loading branch information
lchrusciel committed Oct 27, 2021
2 parents 86de981 + 02cfbad commit 570f49c
Show file tree
Hide file tree
Showing 12 changed files with 529 additions and 1,412 deletions.
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
"phpspec/phpspec": "^7.0",
"phpunit/phpunit": "^8.5",
"stripe/stripe-php": "^4.1",
"sylius-labs/coding-standard": "^2.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/intl": "^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"symfony/web-server-bundle": "^4.4 || ^5.2"
"symfony/web-server-bundle": "^4.4 || ^5.2",
"rector/rector": "^0.11.57"
},
"prefer-stable": true,
"autoload": {
Expand Down
1,788 changes: 470 additions & 1,318 deletions composer.lock

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void
{
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::IMPORT_SHORT_CLASSES, false);

$services = $containerConfigurator->services();
$services->set(TypedPropertyRector::class);
};
16 changes: 2 additions & 14 deletions src/EventListener/AdminListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,13 @@

final class AdminListener
{
/**
* @var Session
*/
private $session;

/**
* @param Session $session
*/
private Session $session;

public function __construct(Session $session)
{
$this->session = $session;
}

/**
* @param GenericEvent $event
*/
public function preDelete(GenericEvent $event): void
{
$subject = $subject = $event->getSubject();
Expand All @@ -39,9 +30,6 @@ public function preDelete(GenericEvent $event): void
}
}

/**
* @param GenericEvent $event
*/
public function preUpdate(GenericEvent $event): void
{
$subject = $subject = $event->getSubject();
Expand Down
20 changes: 4 additions & 16 deletions src/EventListener/ChannelListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,16 @@

final class ChannelListener
{
/**
* @var Session
*/
private $session;

/**
* @var Router
*/
private $router;

/**
* @param Session $session
*/
private Session $session;

private Router $router;

public function __construct(Session $session, Router $router)
{
$this->session = $session;
$this->router = $router;
}

/**
* @param GetResponseEvent $event
*/
public function preCreate(GetResponseEvent $event): void
{
if ('sylius_admin_channel_create' === $event->getRequest()->get('_route')) {
Expand Down
21 changes: 4 additions & 17 deletions src/EventListener/UserRegistrationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,10 @@

final class UserRegistrationListener
{
/**
* @var Session
*/
private $session;

/**
* @var FlashMessageGeneratorInterface
*/
private $flashMessageGenerator;

/**
* @param Session $session
* @param FlashMessageGeneratorInterface $flashMessageGenerator
*/
private Session $session;

private FlashMessageGeneratorInterface $flashMessageGenerator;

public function __construct(
Session $session,
FlashMessageGeneratorInterface $flashMessageGenerator
Expand All @@ -41,9 +31,6 @@ public function __construct(
$this->flashMessageGenerator = $flashMessageGenerator;
}

/**
* @param GenericEvent $event
*/
public function addVerificationLink(GenericEvent $event): void
{
/** @var UserInterface $subject */
Expand Down
5 changes: 0 additions & 5 deletions src/Generator/FlashMessageGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,5 @@

interface FlashMessageGeneratorInterface
{
/**
* @param string $token
*
* @return string
*/
public function generate(string $token): string;
}
21 changes: 4 additions & 17 deletions src/Generator/VerificationFlashMessageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,10 @@

final class VerificationFlashMessageGenerator implements FlashMessageGeneratorInterface
{
/**
* @var UrlGeneratorInterface
*/
private $urlGenerator;

/**
* @var TranslatorInterface
*/
private $translator;

/**
* @param UrlGeneratorInterface $urlGenerator
* @param TranslatorInterface $translator
*/
private UrlGeneratorInterface $urlGenerator;

private TranslatorInterface $translator;

public function __construct(
UrlGeneratorInterface $urlGenerator,
TranslatorInterface $translator
Expand All @@ -38,9 +28,6 @@ public function __construct(
$this->translator = $translator;
}

/**
* {@inheritdoc}
*/
public function generate(string $token): string
{
$url = $this
Expand Down
9 changes: 9 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"container-interop/container-interop": {
"version": "1.2.0"
},
"dealerdirect/phpcodesniffer-composer-installer": {
"version": "v0.7.1"
},
"doctrine/annotations": {
"version": "1.0",
"recipe": {
Expand Down Expand Up @@ -350,6 +353,9 @@
"phpstan/phpdoc-parser": {
"version": "0.3"
},
"phpstan/phpstan": {
"version": "0.12.99"
},
"phpunit/php-code-coverage": {
"version": "5.3.2"
},
Expand Down Expand Up @@ -401,6 +407,9 @@
"ramsey/uuid": {
"version": "3.8.0"
},
"rector/rector": {
"version": "0.11.57"
},
"sebastian/code-unit-reverse-lookup": {
"version": "1.0.1"
},
Expand Down
15 changes: 6 additions & 9 deletions tests/Behat/Context/Ui/Admin/ManagingAdministratorsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@

final class ManagingAdministratorsContext implements Context
{
/** @var NotificationCheckerInterface */
private $notificationChecker;
private ?NotificationCheckerInterface $notificationChecker;

/** @var RepositoryInterface */
private $adminUserRepository;
private ?RepositoryInterface $adminUserRepository;

/** @var UpdatePageInterface */
private $adminUserUpdatePage;
private ?UpdatePageInterface $adminUserUpdatePage;

public function __construct(
NotificationCheckerInterface $notificationChecker,
RepositoryInterface $adminUserRepository,
UpdatePageInterface $adminUserUpdatePage
?NotificationCheckerInterface $notificationChecker,
?RepositoryInterface $adminUserRepository,
?UpdatePageInterface $adminUserUpdatePage
) {
$this->notificationChecker = $notificationChecker;
$this->adminUserRepository = $adminUserRepository;
Expand Down
8 changes: 3 additions & 5 deletions tests/Behat/Context/Ui/Admin/ManagingChannelsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

final class ManagingChannelsContext implements Context
{
/** @var CreatePageInterface */
private $channelCreatePage;
private ?CreatePageInterface $channelCreatePage;

/** @var NotificationCheckerInterface */
private $notificationChecker;
private ?NotificationCheckerInterface $notificationChecker;

public function __construct(CreatePageInterface $channelCreatePage, NotificationCheckerInterface $notificationChecker)
public function __construct(?CreatePageInterface $channelCreatePage, ?NotificationCheckerInterface $notificationChecker)
{
$this->channelCreatePage = $channelCreatePage;
$this->notificationChecker = $notificationChecker;
Expand Down
15 changes: 6 additions & 9 deletions tests/Behat/Context/Ui/Shop/RegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@

final class RegistrationContext implements Context
{
/** @var NotificationCheckerInterface */
private $notificationChecker;
private ?NotificationCheckerInterface $notificationChecker;

/** @var UrlGeneratorInterface */
private $urlGenerator;
private ?UrlGeneratorInterface $urlGenerator;

/** @var RepositoryInterface */
private $shopUserRepository;
private ?RepositoryInterface $shopUserRepository;

public function __construct(
NotificationCheckerInterface $notificationChecker,
UrlGeneratorInterface $urlGenerator,
RepositoryInterface $shopUserRepository
?NotificationCheckerInterface $notificationChecker,
?UrlGeneratorInterface $urlGenerator,
?RepositoryInterface $shopUserRepository
) {
$this->notificationChecker = $notificationChecker;
$this->urlGenerator = $urlGenerator;
Expand Down

0 comments on commit 570f49c

Please sign in to comment.