Skip to content

Commit

Permalink
refactor #13012 Use PHP 7.4 syntax in Sylius components (Zales0123)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.10 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.10
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | related to #12891
| License         | MIT

I know, it's probably unreviewable (but bundles will be worse 😄). In tests we trust 🖖 🚀 

Commits
-------

79fbdf6 Use PHP 7.4 syntax in Sylius components
b3776ba After review fixes
  • Loading branch information
GSadee committed Sep 3, 2021
2 parents 7e7721e + b3776ba commit e4b7c8a
Show file tree
Hide file tree
Showing 208 changed files with 606 additions and 1,119 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@
"mikey179/vfsstream": "^1.6",
"mockery/mockery": "^1.4",
"phpspec/phpspec": "^7.0",
"phpstan/phpstan": "0.12.82",
"phpstan/phpstan": "0.12.96",
"phpstan/phpstan-doctrine": "0.12.33",
"phpunit/phpunit": "^8.5",
"psalm/plugin-mockery": "0.7.0",
"psr/event-dispatcher": "^1.0",
"rector/rector": "^0.11.51",
"stripe/stripe-php": "^6.43",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.2",
Expand Down
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);
};
6 changes: 2 additions & 4 deletions src/Sylius/Component/Addressing/Factory/ZoneFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

final class ZoneFactory implements ZoneFactoryInterface
{
/** @var FactoryInterface */
private $factory;
private FactoryInterface $factory;

/** @var FactoryInterface */
private $zoneMemberFactory;
private FactoryInterface $zoneMemberFactory;

public function __construct(FactoryInterface $factory, FactoryInterface $zoneMemberFactory)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Sylius/Component/Addressing/Matcher/ZoneMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

final class ZoneMatcher implements ZoneMatcherInterface
{
/** @var RepositoryInterface */
private $zoneRepository;
private RepositoryInterface $zoneRepository;

/**
* @var array
Expand Down
30 changes: 10 additions & 20 deletions src/Sylius/Component/Addressing/Model/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,25 @@ class Address implements AddressInterface
/** @var mixed */
protected $id;

/** @var string|null */
protected $firstName;
protected ?string $firstName = null;

/** @var string|null */
protected $lastName;
protected ?string $lastName = null;

/** @var string|null */
protected $phoneNumber;
protected ?string $phoneNumber = null;

/** @var string|null */
protected $company;
protected ?string $company = null;

/** @var string|null */
protected $countryCode;
protected ?string $countryCode = null;

/** @var string|null */
protected $provinceCode;
protected ?string $provinceCode = null;

/** @var string|null */
protected $provinceName;
protected ?string $provinceName = null;

/** @var string|null */
protected $street;
protected ?string $street = null;

/** @var string|null */
protected $city;
protected ?string $city = null;

/** @var string|null */
protected $postcode;
protected ?string $postcode = null;

public function __construct()
{
Expand Down
6 changes: 2 additions & 4 deletions src/Sylius/Component/Addressing/Model/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ class Country implements CountryInterface

/**
* Country code ISO 3166-1 alpha-2.
*
* @var string|null
*/
protected $code;
protected ?string $code = null;

/**
* @var Collection|ProvinceInterface[]
*
* @psalm-var Collection<array-key, ProvinceInterface>
*/
protected $provinces;
protected Collection $provinces;

public function __construct()
{
Expand Down
12 changes: 4 additions & 8 deletions src/Sylius/Component/Addressing/Model/Province.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ class Province implements ProvinceInterface
/** @var mixed */
protected $id;

/** @var string|null */
protected $code;
protected ?string $code = null;

/** @var string|null */
protected $name;
protected ?string $name = null;

/** @var string|null */
protected $abbreviation;
protected ?string $abbreviation = null;

/** @var CountryInterface|null */
protected $country;
protected ?CountryInterface $country = null;

public function __toString(): string
{
Expand Down
14 changes: 5 additions & 9 deletions src/Sylius/Component/Addressing/Model/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,20 @@ class Zone implements ZoneInterface
/** @var mixed */
protected $id;

/** @var string|null */
protected $code;
protected ?string $code = null;

/** @var string|null */
protected $name;
protected ?string $name = null;

/** @var string|null */
protected $type;
protected ?string $type = null;

/** @var string|null */
protected $scope = Scope::ALL;
protected ?string $scope = Scope::ALL;

/**
* @var Collection|ZoneMemberInterface[]
*
* @psalm-var Collection<array-key, ZoneMemberInterface>
*/
protected $members;
protected Collection $members;

public function __construct()
{
Expand Down
6 changes: 2 additions & 4 deletions src/Sylius/Component/Addressing/Model/ZoneMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ class ZoneMember implements ZoneMemberInterface
/** @var mixed */
protected $id;

/** @var string|null */
protected $code;
protected ?string $code = null;

/** @var ZoneInterface|null */
protected $belongsTo;
protected ?ZoneInterface $belongsTo = null;

public function getId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@

class ProvinceNamingProvider implements ProvinceNamingProviderInterface
{
/** @var RepositoryInterface */
private $provinceRepository;
private RepositoryInterface $provinceRepository;

public function __construct(RepositoryInterface $provinceRepository)
{
Expand Down
6 changes: 2 additions & 4 deletions src/Sylius/Component/Attribute/Factory/AttributeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

final class AttributeFactory implements AttributeFactoryInterface
{
/** @var FactoryInterface */
private $factory;
private FactoryInterface $factory;

/** @var ServiceRegistryInterface */
private $attributeTypesRegistry;
private ServiceRegistryInterface $attributeTypesRegistry;

public function __construct(FactoryInterface $factory, ServiceRegistryInterface $attributeTypesRegistry)
{
Expand Down
18 changes: 6 additions & 12 deletions src/Sylius/Component/Attribute/Model/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,17 @@ class Attribute implements AttributeInterface
/** @var mixed */
protected $id;

/** @var string */
protected $code;
protected ?string $code = null;

/** @var string */
protected $type = TextAttributeType::TYPE;
protected ?string $type = TextAttributeType::TYPE;

/** @var array */
protected $configuration = [];
protected array $configuration = [];

/** @var string */
protected $storageType;
protected ?string $storageType = null;

/** @var int */
protected $position;
protected ?int $position = null;

/** @var bool */
protected $translatable = true;
protected bool $translatable = true;

public function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class AttributeTranslation extends AbstractTranslation implements AttributeTrans
/** @var mixed */
protected $id;

/** @var string|null */
protected $name;
protected ?string $name = null;

public function getId()
{
Expand Down
30 changes: 10 additions & 20 deletions src/Sylius/Component/Attribute/Model/AttributeValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,25 @@ class AttributeValue implements AttributeValueInterface
/** @var mixed */
protected $id;

/** @var AttributeSubjectInterface|null */
protected $subject;
protected ?AttributeSubjectInterface $subject = null;

/** @var AttributeInterface|null */
protected $attribute;
protected ?AttributeInterface $attribute = null;

/** @var string|null */
protected $localeCode;
protected ?string $localeCode = null;

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

/** @var bool|null */
private $boolean;
private ?bool $boolean = null;

/** @var int|null */
private $integer;
private ?int $integer = null;

/** @var float|null */
private $float;
private ?float $float = null;

/** @var \DateTimeInterface|null */
private $datetime;
private ?\DateTimeInterface $datetime = null;

/** @var \DateTimeInterface|null */
private $date;
private ?\DateTimeInterface $date = null;

/** @var array|null */
private $json;
private ?array $json = null;

public function getId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@

final class CachedPerRequestChannelContext implements ChannelContextInterface
{
/** @var ChannelContextInterface */
private $decoratedChannelContext;
private ChannelContextInterface $decoratedChannelContext;

/** @var RequestStack */
private $requestStack;
private RequestStack $requestStack;

/** @var \SplObjectStorage<Request, ChannelInterface> */
private $requestToChannelMap;
private \SplObjectStorage $requestToChannelMap;

/** @var \SplObjectStorage<Request, ChannelNotFoundException> */
private $requestToExceptionMap;
private \SplObjectStorage $requestToExceptionMap;

public function __construct(ChannelContextInterface $decoratedChannelContext, RequestStack $requestStack)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class CompositeChannelContext implements ChannelContextInterface
*
* @psalm-var PriorityQueue<ChannelContextInterface>
*/
private $channelContexts;
private PriorityQueue $channelContexts;

public function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

final class ChannelContext implements ChannelContextInterface
{
/** @var RequestResolverInterface */
private $requestResolver;
private RequestResolverInterface $requestResolver;

/** @var RequestStack */
private $requestStack;
private RequestStack $requestStack;

public function __construct(RequestResolverInterface $requestResolver, RequestStack $requestStack)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class CompositeRequestResolver implements RequestResolverInterface
*
* @psalm-var PriorityQueue<RequestResolverInterface>
*/
private $requestResolvers;
private PriorityQueue $requestResolvers;

public function __construct()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

final class HostnameBasedRequestResolver implements RequestResolverInterface
{
/** @var ChannelRepositoryInterface */
private $channelRepository;
private ChannelRepositoryInterface $channelRepository;

public function __construct(ChannelRepositoryInterface $channelRepository)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

final class SingleChannelContext implements ChannelContextInterface
{
/** @var ChannelRepositoryInterface */
private $channelRepository;
private ChannelRepositoryInterface $channelRepository;

public function __construct(ChannelRepositoryInterface $channelRepository)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Sylius/Component/Channel/Factory/ChannelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

final class ChannelFactory implements ChannelFactoryInterface
{
/** @var FactoryInterface */
private $defaultFactory;
private FactoryInterface $defaultFactory;

public function __construct(FactoryInterface $defaultFactory)
{
Expand Down

0 comments on commit e4b7c8a

Please sign in to comment.