Detector: ArrayBagDetector
Report:
__unserialize(array $data) and its migrateDiscounts helper are PHP's serialization-protocol boundary: PHP hands __unserialize the raw property bag keyed by property name, and the legacy-session shape is read the same way. String-indexing here is the canonical, unavoidable deserialization parse point (the magic-method signature is dictated by the language) — it cannot be replaced by a value-object parameter. Fixed-source is impossible: this IS where the loose serialized shape is turned into the typed Discount[].
Where: app/Session/WebRegister/SaleItem.php:75
Code (app/Session/WebRegister/SaleItem.php:75):
72 */
73 public function __unserialize(array $data): void
74 {
→ 75 $this->variantId = $data['variantId'];
76 $this->price = $data['price'];
77 $this->quantity = $data['quantity'] ?? 1;
78 $this->taxRate = $data['taxRate'] ?? 21.0;
79 $this->taxId = $data['taxId'] ?? null;
80 $this->discounts = $this->migrateDiscounts($data);
81 }
82
83 public function increaseQuantity(int $quantity = 1): void
84 {
85 $this->quantity += $quantity;
86 }
87
88 public function decreaseQuantity(int $quantity = 1): void
89 {
90 $this->quantity -= $quantity;
91
92 if ($this->quantity < 0)
93 {
94 $this->quantity = 0;
95 }
96 }
97
98 public function setQuantity(int $quantity): void
99 {
Where: app/Session/WebRegister/SaleItem.php:76
Code (app/Session/WebRegister/SaleItem.php:76):
73 public function __unserialize(array $data): void
74 {
75 $this->variantId = $data['variantId'];
→ 76 $this->price = $data['price'];
77 $this->quantity = $data['quantity'] ?? 1;
78 $this->taxRate = $data['taxRate'] ?? 21.0;
79 $this->taxId = $data['taxId'] ?? null;
80 $this->discounts = $this->migrateDiscounts($data);
81 }
82
83 public function increaseQuantity(int $quantity = 1): void
84 {
85 $this->quantity += $quantity;
86 }
87
88 public function decreaseQuantity(int $quantity = 1): void
89 {
90 $this->quantity -= $quantity;
91
92 if ($this->quantity < 0)
93 {
94 $this->quantity = 0;
95 }
96 }
97
98 public function setQuantity(int $quantity): void
99 {
100 if ($quantity < 0)
Where: app/Session/WebRegister/SaleItem.php:77
Code (app/Session/WebRegister/SaleItem.php:77):
74 {
75 $this->variantId = $data['variantId'];
76 $this->price = $data['price'];
→ 77 $this->quantity = $data['quantity'] ?? 1;
78 $this->taxRate = $data['taxRate'] ?? 21.0;
79 $this->taxId = $data['taxId'] ?? null;
80 $this->discounts = $this->migrateDiscounts($data);
81 }
82
83 public function increaseQuantity(int $quantity = 1): void
84 {
85 $this->quantity += $quantity;
86 }
87
88 public function decreaseQuantity(int $quantity = 1): void
89 {
90 $this->quantity -= $quantity;
91
92 if ($this->quantity < 0)
93 {
94 $this->quantity = 0;
95 }
96 }
97
98 public function setQuantity(int $quantity): void
99 {
100 if ($quantity < 0)
101 {
Where: app/Session/WebRegister/SaleItem.php:78
Code (app/Session/WebRegister/SaleItem.php:78):
75 $this->variantId = $data['variantId'];
76 $this->price = $data['price'];
77 $this->quantity = $data['quantity'] ?? 1;
→ 78 $this->taxRate = $data['taxRate'] ?? 21.0;
79 $this->taxId = $data['taxId'] ?? null;
80 $this->discounts = $this->migrateDiscounts($data);
81 }
82
83 public function increaseQuantity(int $quantity = 1): void
84 {
85 $this->quantity += $quantity;
86 }
87
88 public function decreaseQuantity(int $quantity = 1): void
89 {
90 $this->quantity -= $quantity;
91
92 if ($this->quantity < 0)
93 {
94 $this->quantity = 0;
95 }
96 }
97
98 public function setQuantity(int $quantity): void
99 {
100 if ($quantity < 0)
101 {
102 $this->quantity = 0;
Where: app/Session/WebRegister/SaleItem.php:79
Code (app/Session/WebRegister/SaleItem.php:79):
76 $this->price = $data['price'];
77 $this->quantity = $data['quantity'] ?? 1;
78 $this->taxRate = $data['taxRate'] ?? 21.0;
→ 79 $this->taxId = $data['taxId'] ?? null;
80 $this->discounts = $this->migrateDiscounts($data);
81 }
82
83 public function increaseQuantity(int $quantity = 1): void
84 {
85 $this->quantity += $quantity;
86 }
87
88 public function decreaseQuantity(int $quantity = 1): void
89 {
90 $this->quantity -= $quantity;
91
92 if ($this->quantity < 0)
93 {
94 $this->quantity = 0;
95 }
96 }
97
98 public function setQuantity(int $quantity): void
99 {
100 if ($quantity < 0)
101 {
102 $this->quantity = 0;
103 }
Where: app/Session/WebRegister/SaleItem.php:147
Code (app/Session/WebRegister/SaleItem.php:147):
144 */
145 private function migrateDiscounts(array $data): array
146 {
→ 147 if (isset($data['discounts']))
148 {
149 return $data['discounts'];
150 }
151
152 $legacy = (float) ($data['discount'] ?? 0);
153
154 return $legacy > 0 ? [new Discount(PriceAdjustmentType::PERCENTAGE, $legacy)] : [];
155 }
156
157 }
Where: app/Session/WebRegister/SaleItem.php:149
Code (app/Session/WebRegister/SaleItem.php:149):
146 {
147 if (isset($data['discounts']))
148 {
→ 149 return $data['discounts'];
150 }
151
152 $legacy = (float) ($data['discount'] ?? 0);
153
154 return $legacy > 0 ? [new Discount(PriceAdjustmentType::PERCENTAGE, $legacy)] : [];
155 }
156
157 }
Where: app/Session/WebRegister/SaleItem.php:152
Code (app/Session/WebRegister/SaleItem.php:152):
149 return $data['discounts'];
150 }
151
→ 152 $legacy = (float) ($data['discount'] ?? 0);
153
154 return $legacy > 0 ? [new Discount(PriceAdjustmentType::PERCENTAGE, $legacy)] : [];
155 }
156
157 }
Filed via commandments report from a consumer project.
Detector:
ArrayBagDetectorReport:
__unserialize(array $data) and its migrateDiscounts helper are PHP's serialization-protocol boundary: PHP hands __unserialize the raw property bag keyed by property name, and the legacy-session shape is read the same way. String-indexing here is the canonical, unavoidable deserialization parse point (the magic-method signature is dictated by the language) — it cannot be replaced by a value-object parameter. Fixed-source is impossible: this IS where the loose serialized shape is turned into the typed Discount[].
Where:
app/Session/WebRegister/SaleItem.php:75Code (
app/Session/WebRegister/SaleItem.php:75):Where:
app/Session/WebRegister/SaleItem.php:76Code (
app/Session/WebRegister/SaleItem.php:76):Where:
app/Session/WebRegister/SaleItem.php:77Code (
app/Session/WebRegister/SaleItem.php:77):Where:
app/Session/WebRegister/SaleItem.php:78Code (
app/Session/WebRegister/SaleItem.php:78):Where:
app/Session/WebRegister/SaleItem.php:79Code (
app/Session/WebRegister/SaleItem.php:79):Where:
app/Session/WebRegister/SaleItem.php:147Code (
app/Session/WebRegister/SaleItem.php:147):Where:
app/Session/WebRegister/SaleItem.php:149Code (
app/Session/WebRegister/SaleItem.php:149):Where:
app/Session/WebRegister/SaleItem.php:152Code (
app/Session/WebRegister/SaleItem.php:152):Filed via
commandments reportfrom a consumer project.