Skip to content

Commit

Permalink
Merge branch 'release/0.12.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerendir committed Oct 19, 2024
2 parents 2c62614 + 010fbef commit 76ccca7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 188 deletions.
6 changes: 3 additions & 3 deletions .baseline-phan.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
// PhanUndeclaredProperty : 8 occurrences
// PhanTypeMismatchDeclaredReturn : 6 occurrences
// PhanUnreferencedProtectedMethod : 6 occurrences
// PhanTypeMismatchReturnSuperType : 5 occurrences
// PhanTypeMismatchArgumentSuperType : 4 occurrences
// PhanTypeMismatchReturnSuperType : 4 occurrences
// PhanTypeMismatchArgumentNullable : 3 occurrences
// PhanUnusedPublicFinalMethodParameter : 3 occurrences
// PhanWriteOnlyPrivateProperty : 3 occurrences
// PhanCompatibleUnionType : 2 occurrences
// PhanTypeArraySuspicious : 2 occurrences
// PhanTypeMismatchDimAssignment : 2 occurrences
// PhanUndeclaredTypeParameter : 2 occurrences
// PhanUnusedVariable : 2 occurrences
// ConstReferenceClassNotImported : 1 occurrence
// PhanAccessClassInternal : 1 occurrence
// PhanCompatiblePHP7 : 1 occurrence
// PhanCompatibleUnionType : 1 occurrence
// PhanPossiblyNullTypeMismatchProperty : 1 occurrence
// PhanReadOnlyPrivateProperty : 1 occurrence
// PhanTypeInvalidLeftOperandOfNumericOp : 1 occurrence
Expand Down Expand Up @@ -73,7 +73,7 @@
'src/Model/Feature/Subscribed/SubscribedBooleanFeature.php' => ['PhanUnreferencedPrivateProperty'],
'src/Model/Feature/Subscribed/SubscribedCountableFeature.php' => ['ConstReferenceClassNotImported', 'PhanUndeclaredMethod'],
'src/Model/Feature/Subscribed/SubscribedFeaturesCollection.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchDeclaredReturn', 'PhanUnreferencedProtectedMethod'],
'src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php' => ['PhanDeprecatedFunction', 'PhanWriteOnlyPrivateProperty'],
'src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php' => ['PhanCompatibleUnionType', 'PhanTypeMismatchReturnSuperType', 'PhanWriteOnlyPrivateProperty'],
'src/Model/Invoice.php' => ['PhanDeprecatedFunction', 'PhanParamSignatureMismatch', 'PhanTypeArraySuspicious', 'PhanTypeMismatchArgumentInternal', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimAssignment', 'PhanTypeMismatchReturn', 'PhanTypeMismatchReturnNullable'],
'src/Model/InvoiceInterface.php' => ['PhanUnextractableAnnotationElementName', 'PhanUnextractableAnnotationSuffix'],
'src/Model/InvoiceLine.php' => ['PhanPossiblyNullTypeMismatchProperty'],
Expand Down
155 changes: 0 additions & 155 deletions .baseline-phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,6 @@ parameters:
count: 1
path: src/InvoiceDrawer/PlainTextDrawer.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\AbstractFeature\\:\\:__construct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/AbstractFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\AbstractFeaturePack\\:\\:__construct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/AbstractFeaturePack.php

-
message: "#^Cannot clone non\\-object variable \\$element of type mixed\\.$#"
count: 1
path: src/Model/Feature/AbstractFeaturesCollection.php

-
message: "#^Class SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\AbstractFeaturesCollection extends generic class Doctrine\\\\Common\\\\Collections\\\\ArrayCollection but does not specify its types\\: TKey, T$#"
count: 1
path: src/Model/Feature/AbstractFeaturesCollection.php

-
message: "#^Argument of an invalid type array\\|Countable supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down Expand Up @@ -430,11 +410,6 @@ parameters:
count: 1
path: src/Model/Feature/Configured/ConfiguredRechargeableFeaturePack.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\FeatureInterface\\:\\:__construct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/FeatureInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Property\\\\HasRecurringPricesInterface\\:\\:getPrices\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -485,61 +460,6 @@ parameters:
count: 1
path: src/Model/Feature/Subscribed/SubscribedBooleanFeature.php

-
message: "#^Class DateTime is unsafe to use\\. Its methods can return FALSE instead of throwing an exception\\. Please add 'use Safe\\\\DateTime;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library\\.$#"
count: 6
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Instanceof between SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeaturePack and SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Configured\\\\ConfiguredCountableFeaturePack will always evaluate to false\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeature\\:\\:RecurringFeatureConstruct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeature\\:\\:__construct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeature\\:\\:consumedToArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeature\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Property SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedCountableFeature\\:\\:\\$remainedQuantity has no type specified\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Strict comparison using \\=\\=\\= between null and DateTimeInterface will always evaluate to false\\.$#"
count: 2
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Strict comparison using \\=\\=\\= between null and int will always evaluate to false\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedCountableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedFeatureInterface\\:\\:setConfiguredFeature\\(\\) has no return type specified\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedFeatureInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedFeatureInterface\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedFeatureInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedFeaturePack\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -595,26 +515,6 @@ parameters:
count: 1
path: src/Model/Feature/Subscribed/SubscribedFeaturesCollection.php

-
message: "#^Class DateTime is unsafe to use\\. Its methods can return FALSE instead of throwing an exception\\. Please add 'use Safe\\\\DateTime;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library\\.$#"
count: 2
path: src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedRechargeableFeature\\:\\:__construct\\(\\) has parameter \\$details with no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedRechargeableFeature\\:\\:consumedToArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\Feature\\\\Subscribed\\\\SubscribedRechargeableFeature\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php

-
message: "#^Cannot access offset '_header' on SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSection\\.$#"
count: 1
Expand Down Expand Up @@ -695,36 +595,6 @@ parameters:
count: 2
path: src/Model/Invoice.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceInterface\\:\\:getLine\\(\\) has parameter \\$id with no type specified\\.$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceInterface\\:\\:getLines\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceInterface\\:\\:getSections\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceInterface\\:\\:jsonUnserialize\\(\\) has no return type specified\\.$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceInterface\\:\\:setHeader\\(\\) has no return type specified\\.$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^PHPDoc tag @param has invalid value \\(string\\!int \\$id\\)\\: Unexpected token \"\\!\", expected variable at offset 102$#"
count: 1
path: src/Model/InvoiceInterface.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceLine\\:\\:__toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -745,31 +615,6 @@ parameters:
count: 1
path: src/Model/InvoiceLine.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSection\\:\\:getLines\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/InvoiceSection.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSection\\:\\:jsonSerialize\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Model/InvoiceSection.php

-
message: "#^Property SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSection\\:\\:\\$header \\(SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSectionHeader\\) does not accept null\\.$#"
count: 1
path: src/Model/InvoiceSection.php

-
message: "#^Result of && is always false\\.$#"
count: 1
path: src/Model/InvoiceSection.php

-
message: "#^Strict comparison using \\=\\=\\= between false and true will always evaluate to false\\.$#"
count: 1
path: src/Model/InvoiceSection.php

-
message: "#^Method SerendipityHQ\\\\Bundle\\\\FeaturesBundle\\\\Model\\\\InvoiceSectionHeader\\:\\:__toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
19 changes: 0 additions & 19 deletions .baseline-psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
</PossiblyNullReference>
</file>
<file src="src/Form/DataTransformer/BooleanFeatureTransformer.php">
<MethodSignatureMismatch>
<code><![CDATA[BooleanFeatureTransformer]]></code>
<code><![CDATA[BooleanFeatureTransformer]]></code>
</MethodSignatureMismatch>
<MoreSpecificImplementedParamType>
<code><![CDATA[$enabled]]></code>
<code><![CDATA[$feature]]></code>
Expand All @@ -59,10 +55,6 @@
</RedundantCondition>
</file>
<file src="src/Form/DataTransformer/CountableFeatureTransformer.php">
<MethodSignatureMismatch>
<code><![CDATA[CountableFeatureTransformer]]></code>
<code><![CDATA[CountableFeatureTransformer]]></code>
</MethodSignatureMismatch>
<MoreSpecificImplementedParamType>
<code><![CDATA[$feature]]></code>
<code><![CDATA[$pack]]></code>
Expand All @@ -73,10 +65,6 @@
</ParamNameMismatch>
</file>
<file src="src/Form/DataTransformer/FeaturesCollectionTransformer.php">
<MethodSignatureMismatch>
<code><![CDATA[FeaturesCollectionTransformer]]></code>
<code><![CDATA[FeaturesCollectionTransformer]]></code>
</MethodSignatureMismatch>
<MissingTemplateParam>
<code><![CDATA[DataTransformerInterface]]></code>
</MissingTemplateParam>
Expand All @@ -90,10 +78,6 @@
</ParamNameMismatch>
</file>
<file src="src/Form/DataTransformer/RechargeableFeatureTransformer.php">
<MethodSignatureMismatch>
<code><![CDATA[RechargeableFeatureTransformer]]></code>
<code><![CDATA[RechargeableFeatureTransformer]]></code>
</MethodSignatureMismatch>
<MoreSpecificImplementedParamType>
<code><![CDATA[$feature]]></code>
<code><![CDATA[$pack]]></code>
Expand Down Expand Up @@ -534,9 +518,6 @@
<code><![CDATA[$nextRenewOn]]></code>
<code><![CDATA[$renewInterval]]></code>
</ParamNameMismatch>
<ParseError>
<code><![CDATA[array|SubscribedFeaturesCollection|null]]></code>
</ParseError>
<PossiblyInvalidClone>
<code><![CDATA[clone $this->features]]></code>
<code><![CDATA[clone $this->features]]></code>
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<psalm
phpVersion="7.4"
cacheDirectory="./var/cache/psalm"
checkForThrowsDocblock="true"
hideExternalErrors="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function reverseTransform($pack): SubscribedRechargeableFeature

/** @var SubscribedRechargeableFeature $subscribedFeature */
$subscribedFeature = $this->getCurrentTransformingFeature();
$subscribedFeature->setRecharginPack($subscribedPack);
$subscribedFeature->setRechargingPack($subscribedPack);

// Call recharge, so the form can automatically update the feature
$subscribedFeature->recharge();
Expand Down
35 changes: 26 additions & 9 deletions src/Model/Feature/Subscribed/SubscribedRechargeableFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

use function Safe\json_decode;
use function Safe\json_encode;
use function Safe\sprintf;

final class SubscribedRechargeableFeature extends AbstractSubscribedFeature implements SubscribedFeatureInterface, CanBeConsumedInterface
{
Expand All @@ -33,21 +32,29 @@ final class SubscribedRechargeableFeature extends AbstractSubscribedFeature impl
private SubscribedRechargeableFeaturePack $rechargingPack;

/** @var int $remainedQuantity The amount of remained units */
private $remainedQuantity = 0;
private int $remainedQuantity = 0;

public function __construct(string $name, array $details = [])
{
// Set the type
$details[self::FIELD_TYPE] = self::TYPE_RECHARGEABLE;

$this->setRemainedQuantity($details['remained_quantity']);
$this->lastRechargeOn = $details['last_recharge_on'];
$this->lastRechargeQuantity = $details['last_recharge_quantity'];
if (false === array_key_exists('remained_quantity', $details) || null === $details['remained_quantity']) {
throw new \InvalidArgumentException('The key "remained_quantity" is mandatory for a subscribed rechargeable feature. You must provide it.');
}

if (null !== $this->lastRechargeOn && ! $this->lastRechargeOn instanceof \DateTime) {
$this->lastRechargeOn = new \DateTime($this->lastRechargeOn['date'], new \DateTimeZone($this->lastRechargeOn['timezone']));
if (false === array_key_exists('last_recharge_on', $details) || null === $details['last_recharge_on']) {
throw new \InvalidArgumentException('The key "last_recharge_on" is mandatory for a subscribed rechargeable feature. You must provide it.');
}

if (false === array_key_exists('last_recharge_quantity', $details) || null === $details['last_recharge_quantity']) {
throw new \InvalidArgumentException('The key "last_recharge_quantity" is mandatory for a subscribed rechargeable feature. You must provide it.');
}

$this->setRemainedQuantity($details['remained_quantity']);
$this->setLastRechargedOn($details['last_recharge_on']);
$this->lastRechargeQuantity = $details['last_recharge_quantity'];

parent::__construct($name, $details);
}

Expand Down Expand Up @@ -75,7 +82,7 @@ public function getRechargingPack(): SubscribedRechargeableFeaturePack

public function hasRechargingPack(): bool
{
return null !== $this->rechargingPack;
return isset($this->rechargingPack);
}

public function recharge(): SubscribedRechargeableFeature
Expand All @@ -88,7 +95,7 @@ public function recharge(): SubscribedRechargeableFeature
return $this;
}

public function setRecharginPack(SubscribedRechargeableFeaturePack $rechargingPack): SubscribedRechargeableFeature
public function setRechargingPack(SubscribedRechargeableFeaturePack $rechargingPack): SubscribedRechargeableFeature
{
$this->rechargingPack = $rechargingPack;

Expand All @@ -102,4 +109,14 @@ public function toArray(): array
'last_recharge_quantity' => $this->getLastRechargeQuantity(),
], parent::toArray(), $this->consumedToArray());
}

private function setLastRechargedOn(\DateTimeInterface|array $lastRechargeOn): SubscribedRechargeableFeature
{
if (is_array($lastRechargeOn)) {
$lastRechargeOn = new \DateTime($lastRechargeOn['date'], new \DateTimeZone($lastRechargeOn['timezone']));
}
$this->lastRechargeOn = $lastRechargeOn;

return $this;
}
}

0 comments on commit 76ccca7

Please sign in to comment.