-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use PHP 7.4 syntax in Sylius components #13012
Conversation
ee33acb
to
79fbdf6
Compare
|
||
/** @var string */ | ||
protected $type = TextAttributeType::TYPE; | ||
protected ?string $type = TextAttributeType::TYPE; | ||
|
||
/** @var array */ | ||
protected $configuration = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $configuration = []; | |
protected array $configuration = []; |
|
||
/** @var string */ | ||
protected $type = TextAttributeType::TYPE; | ||
protected ?string $type = TextAttributeType::TYPE; | ||
|
||
/** @var array */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var array */ |
|
||
/** @var RequestStack */ | ||
private $requestStack; | ||
private RequestStack $requestStack; | ||
|
||
/** @var \SplObjectStorage<Request, ChannelInterface> */ | ||
private $requestToChannelMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private $requestToChannelMap; | |
private \SplObjectStorage $requestToChannelMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also private \SplObjectStorage $requestToExceptionMap;
below, but can't suggest a change there...
|
||
/** @var ChannelInterface */ | ||
private $channel; | ||
private ?ChannelInterface $channel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private ?ChannelInterface $channel; | |
private ChannelInterface $channel; |
|
||
/** @var OrderInterface|null */ | ||
private $cart; | ||
private ?\Sylius\Component\Core\Model\OrderInterface $cart = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private ?\Sylius\Component\Core\Model\OrderInterface $cart = null; | |
private ?OrderInterface $cart = null; |
@@ -22,8 +22,7 @@ | |||
*/ | |||
final class SalesDataProvider implements SalesDataProviderInterface | |||
{ | |||
/** @var EntityRepository */ | |||
private $orderRepository; | |||
private EntityRepository $orderRepository; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated, but why an interface is not used here and in the constructor?
@@ -15,20 +15,15 @@ | |||
|
|||
class ChannelPricing implements ChannelPricingInterface | |||
{ | |||
/** @var int|null */ | |||
protected $id; | |||
protected ?int $id = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected ?int $id = null; | |
protected $id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert and change /** @var int|null */
to /** @var mixed */
|
||
/** | ||
* @var Collection|AddressInterface[] | ||
* | ||
* @psalm-var Collection<array-key, AddressInterface> | ||
*/ | ||
protected $addresses; | ||
protected Collection $addresses; | ||
|
||
/** @var ShopUserInterface|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var ShopUserInterface|null */ |
|
||
/** | ||
* @var Collection|AddressInterface[] | ||
* | ||
* @psalm-var Collection<array-key, AddressInterface> | ||
*/ | ||
protected $addresses; | ||
protected Collection $addresses; | ||
|
||
/** @var ShopUserInterface|null */ | ||
protected $user; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $user; | |
protected ?ShopUserInterface $user = null; |
@@ -15,24 +15,17 @@ | |||
|
|||
abstract class Image implements ImageInterface | |||
{ | |||
/** @var mixed */ | |||
protected $id; | |||
/** @var mixed|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var mixed|null */ | |
/** @var mixed*/ |
/** @var mixed */ | ||
protected $id; | ||
/** @var mixed|null */ | ||
protected $id = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is null
here necessary if there's no type-hint?
@@ -35,56 +35,47 @@ class Order extends BaseOrder implements OrderInterface | |||
/** @var ChannelInterface|null */ | |||
protected $channel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $channel; | |
protected ?ChannelInterface $channel = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also missed the $customer
above.
Looks like it ignores the cases when the class/interface is not explicitly imported because it's in the same namespace.
|
||
/** @var string|null */ | ||
protected $localeCode; | ||
protected ?string $localeCode = null; | ||
|
||
/** @var BaseCouponInterface|null */ | ||
protected $promotionCoupon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $promotionCoupon; | |
protected ?BaseCouponInterface $promotionCoupon = null; |
|
||
/** @var string|null */ | ||
protected $localeCode; | ||
protected ?string $localeCode = null; | ||
|
||
/** @var BaseCouponInterface|null */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var BaseCouponInterface|null */ |
|
||
/** @var BaseTaxonInterface */ | ||
protected $mainTaxon; | ||
protected ?\Sylius\Component\Core\Model\TaxonInterface $mainTaxon = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected ?\Sylius\Component\Core\Model\TaxonInterface $mainTaxon = null; | |
protected ?TaxonInterface $mainTaxon = null; |
@Zales0123 is it useful or shall I stop? 😄 |
/** @var string */ | ||
protected $firstName; | ||
protected ?string $firstName = null; | ||
|
||
/** @var string */ | ||
protected $lastName; | ||
protected ?string $lastName = null; | ||
|
||
/** @var string */ | ||
protected $localeCode; | ||
protected ?string $localeCode = null; | ||
|
||
/** @var ImageInterface */ | ||
protected $avatar; | ||
protected ?ImageInterface $avatar = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no null before (in annotation) but now you are adding it. May I ask why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no null before (in annotation) but now you are adding it. May I ask why?
@arti0090 The annotation was wrong. Both the getter and the setter allow null values, it's not initialized in the constructor and there's no default value, therefore it can be null in a lot of scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The truth is, these fields were nullable due to setters definition
|
||
/** | ||
* @var Collection|ReviewInterface[] | ||
* | ||
* @psalm-var Collection<array-key, ReviewInterface> | ||
*/ | ||
protected $reviews; | ||
protected Collection $reviews; | ||
|
||
/** @var float */ | ||
protected $averageRating = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $averageRating = 0; | |
protected float $averageRating = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setter doesn't allow null values, but the getter has ?float
as return type, so I'm not sure if it should be nullable.
|
||
/** @var int */ | ||
protected $onHold = 0; | ||
protected ?int $onHold = 0; | ||
|
||
/** @var int */ | ||
protected $onHand = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $onHand = 0; | |
protected ?int $onHand = 0; |
|
||
/** @var int */ | ||
protected $onHold = 0; | ||
protected ?int $onHold = 0; | ||
|
||
/** @var int */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var int */ |
|
||
/** @var Collection */ | ||
protected $channelPricings; | ||
protected Collection $channelPricings; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably have a @psalm-var Collection<array-key, ChannelPricingInterface>
annotation
@@ -15,26 +15,19 @@ | |||
|
|||
class ShopBillingData implements ShopBillingDataInterface | |||
{ | |||
/** @var int|null */ | |||
protected $id; | |||
protected ?int $id = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert and change annotation to mixed
.
|
||
/** @var string */ | ||
protected $calculator; | ||
protected ?string $calculator = null; | ||
|
||
/** @var array */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var array */ |
|
||
/** @var string */ | ||
protected $calculator; | ||
protected ?string $calculator = null; | ||
|
||
/** @var array */ | ||
protected $configuration = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $configuration = []; | |
protected array $configuration = []; |
@@ -21,14 +21,12 @@ class ShippingMethodRule implements ShippingMethodRuleInterface | |||
/** @var mixed */ | |||
protected $id; | |||
|
|||
/** @var string */ | |||
protected $type; | |||
protected ?string $type = null; | |||
|
|||
/** @var array */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var array */ |
@@ -21,14 +21,12 @@ class ShippingMethodRule implements ShippingMethodRuleInterface | |||
/** @var mixed */ | |||
protected $id; | |||
|
|||
/** @var string */ | |||
protected $type; | |||
protected ?string $type = null; | |||
|
|||
/** @var array */ | |||
protected $configuration = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $configuration = []; | |
protected array $configuration = []; |
|
||
/** @var \DateTimeInterface|null */ | ||
protected $credentialsExpireAt; | ||
protected ?\DateTimeInterface $credentialsExpireAt = null; | ||
|
||
/** | ||
* We need at least one role to be able to authenticate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this one.
*/ | ||
protected $code; | ||
protected ?string $code = null; | ||
|
||
/** | ||
* @var Collection|ProvinceInterface[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @var Collection|ProvinceInterface[] |
/** @var string */ | ||
protected $firstName; | ||
protected ?string $firstName = null; | ||
|
||
/** @var string */ | ||
protected $lastName; | ||
protected ?string $lastName = null; | ||
|
||
/** @var string */ | ||
protected $localeCode; | ||
protected ?string $localeCode = null; | ||
|
||
/** @var ImageInterface */ | ||
protected $avatar; | ||
protected ?ImageInterface $avatar = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The truth is, these fields were nullable due to setters definition
|
||
/** | ||
* @var Collection|ReviewInterface[] | ||
* | ||
* @psalm-var Collection<array-key, ReviewInterface> | ||
*/ | ||
protected $reviews; | ||
protected Collection $reviews; | ||
|
||
/** @var float */ | ||
protected $averageRating = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $averageRating = 0; | |
protected float $averageRating = 0; |
|
||
/** | ||
* @var Collection|ReviewInterface[] | ||
* | ||
* @psalm-var Collection<array-key, ReviewInterface> | ||
*/ | ||
protected $reviews; | ||
protected Collection $reviews; | ||
|
||
/** @var float */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var float */ |
/** @var int */ | ||
protected $onHand = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var int */ | |
protected $onHand = 0; | |
protected ?int $onHand = 0; |
/** | ||
* @var Collection|ChannelInterface[] | ||
* | ||
* @psalm-var Collection<array-key, ChannelInterface> | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* @var Collection|ChannelInterface[] | |
* | |
* @psalm-var Collection<array-key, ChannelInterface> | |
*/ | |
/** @psalm-var Collection<array-key, ChannelInterface> */ |
/** @var array */ | ||
protected $configuration = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var array */ | |
protected $configuration = []; | |
protected array $configuration = []; |
* @var Collection|ShipmentUnitInterface[] | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @var Collection|ShipmentUnitInterface[] | |
* |
/** @var array */ | ||
protected $configuration = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var array */ | |
protected $configuration = []; | |
protected array $configuration = []; |
* @var Collection|TaxRateInterface[] | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @var Collection|TaxRateInterface[] | |
* |
* @var Collection|TaxonInterface[] | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @var Collection|TaxonInterface[] | |
* |
Thank you @vvasiloi for the review! I would never believe someone would be determined enough to take a look at it. I'm impressed 👏 I've fixed (hopefully) most of the comments, I've just left those about collection type hints, as I'm not 100% sure how the IDE would handle these types without them 🤷 . Still, can be improved later 🖖 Thank you! 🎉 |
Thanks, Mateusz! 🥇 |
I know, it's probably unreviewable (but bundles will be worse 😄). In tests we trust 🖖 🚀