HQD-142: Add deprecated() / isDeprecated() to PriceTypeDefinitionInterface#119
Conversation
📝 WalkthroughWalkthroughThe PR adds a fluent ChangesDeprecated state support for price types
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/product/price/PriceTypeDefinition.php`:
- Around line 239-244: The deprecated() method in PriceTypeDefinition currently
does not change any state; modify PriceTypeDefinition::deprecated() to set a
persistent boolean property (e.g. $deprecated = true) after calling
ensureNotLocked(), then return $this; add isDeprecated(): bool to
PriceTypeDefinitionInterface and implement it in PriceTypeDefinition to return
that property; finally, update the tariff-configuration assembly point that
builds new configurations (where priceTypes() consumers run) to filter out
deprecated price types by calling isDeprecated() so deprecated types are
excluded.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0464ee53-92ef-43c5-8d44-21e0851a4c2a
📒 Files selected for processing (2)
src/product/price/PriceTypeDefinition.phpsrc/product/price/PriceTypeDefinitionInterface.php
| public function deprecated(): static | ||
| { | ||
| $this->ensureNotLocked(); | ||
|
|
||
| return $this; | ||
| } |
There was a problem hiding this comment.
deprecated() does not persist deprecation state (Line 239), so the new contract is ineffective.
This method currently returns $this without mutating any state, so deprecated price types remain indistinguishable and still flow through existing priceTypes() consumers.
💡 Proposed fix
class PriceTypeDefinition implements PriceTypeDefinitionInterface
{
use HasLock;
+ private bool $deprecated = false;
@@
public function deprecated(): static
{
$this->ensureNotLocked();
+ $this->deprecated = true;
return $this;
}
+
+ public function isDeprecated(): bool
+ {
+ return $this->deprecated;
+ }
}Then expose isDeprecated(): bool in PriceTypeDefinitionInterface and apply filtering at the tariff-configuration boundary where new configurations are assembled.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/product/price/PriceTypeDefinition.php` around lines 239 - 244, The
deprecated() method in PriceTypeDefinition currently does not change any state;
modify PriceTypeDefinition::deprecated() to set a persistent boolean property
(e.g. $deprecated = true) after calling ensureNotLocked(), then return $this;
add isDeprecated(): bool to PriceTypeDefinitionInterface and implement it in
PriceTypeDefinition to return that property; finally, update the
tariff-configuration assembly point that builds new configurations (where
priceTypes() consumers run) to filter out deprecated price types by calling
isDeprecated() so deprecated types are excluded.
Summary by CodeRabbit