Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 089a0e6

Browse files
committed
[Psalm] Treat PossiblyFalse* as errors
1 parent 8151ca8 commit 089a0e6

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

psalm.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@
137137
<LessSpecificReturnStatement errorLevel="info" />
138138
<TypeCoercion errorLevel="info" />
139139

140-
<PossiblyFalseArgument errorLevel="info" />
141-
<PossiblyFalseIterator errorLevel="info" />
142-
<PossiblyFalseOperand errorLevel="info" />
143-
<PossiblyFalsePropertyAssignmentValue errorLevel="info" />
144-
<PossiblyFalseReference errorLevel="info" />
145140
<PossiblyInvalidArgument errorLevel="info" />
146141
<PossiblyInvalidArrayAccess errorLevel="info" />
147142
<PossiblyInvalidArrayAssignment errorLevel="info" />

src/Sylius/Bundle/CoreBundle/Installer/Requirement/ExtensionsRequirements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function_exists('simplexml_import_dom'),
6161
))
6262
->add(new Requirement(
6363
$translator->trans('sylius.installer.extensions.pcre', []),
64-
defined('PCRE_VERSION') ? ((float) substr(\PCRE_VERSION, 0, strpos(\PCRE_VERSION, ' '))) > 8.0 : false,
64+
defined('PCRE_VERSION') ? ((float) substr(\PCRE_VERSION, 0, (int) strpos(\PCRE_VERSION, ' '))) > 8.0 : false,
6565
true,
6666
$translator->trans('sylius.installer.extensions.help', ['%extension%' => 'PCRE (>=8.0)'])
6767
))

src/Sylius/Component/Core/Model/OrderItem.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,14 @@ public function getDiscountedUnitPrice(): int
123123
return $this->unitPrice;
124124
}
125125

126+
$firstUnit = $this->units->first();
127+
128+
/** @var OrderItemUnitInterface $firstUnit */
129+
Assert::isInstanceOf($firstUnit, OrderItemUnitInterface::class);
130+
126131
return
127132
$this->unitPrice +
128-
$this->units->first()->getAdjustmentsTotal(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)
133+
$firstUnit->getAdjustmentsTotal(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT)
129134
;
130135
}
131136

@@ -135,10 +140,15 @@ public function getFullDiscountedUnitPrice(): int
135140
return $this->unitPrice;
136141
}
137142

143+
$firstUnit = $this->units->first();
144+
145+
/** @var OrderItemUnitInterface $firstUnit */
146+
Assert::isInstanceOf($firstUnit, OrderItemUnitInterface::class);
147+
138148
return
139149
$this->unitPrice +
140-
$this->units->first()->getAdjustmentsTotal(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT) +
141-
$this->units->first()->getAdjustmentsTotal(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)
150+
$firstUnit->getAdjustmentsTotal(AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT) +
151+
$firstUnit->getAdjustmentsTotal(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)
142152
;
143153
}
144154

0 commit comments

Comments
 (0)