Skip to content

HQD-142: Add deprecated() / isDeprecated() to PriceTypeDefinitionInterface#119

Merged
SilverFire merged 2 commits into
hiqdev:masterfrom
VadymHrechukha:HQD-142_update_the_power_consumption_data_source_and_appearance
Jun 12, 2026
Merged

HQD-142: Add deprecated() / isDeprecated() to PriceTypeDefinitionInterface#119
SilverFire merged 2 commits into
hiqdev:masterfrom
VadymHrechukha:HQD-142_update_the_power_consumption_data_source_and_appearance

Conversation

@VadymHrechukha

@VadymHrechukha VadymHrechukha commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added support for marking price types as deprecated. Deprecated price types maintain full compatibility with existing invoices and billing data while being excluded from selection in new tariff configurations. This enables seamless deprecation and phasing out of pricing structures without disrupting current operations.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a fluent deprecated() method to PriceTypeDefinition and its interface contract. The method marks a price type as deprecated for backward-compatible invoice regeneration and prevents it from appearing in new tariff configurations. The implementation enforces non-locked state before returning the instance.

Changes

Deprecated state support for price types

Layer / File(s) Summary
Deprecated method interface and implementation
src/product/price/PriceTypeDefinitionInterface.php, src/product/price/PriceTypeDefinition.php
PriceTypeDefinitionInterface declares deprecated(): static with docblock describing backward-compatibility and prevention of appearance in new tariff configurations. PriceTypeDefinition implements the fluent method to guard state change with ensureNotLocked() and return the current instance.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 A fluent method hops along,
deprecated() joins the throng,
Locks are checked with care,
Backward-compatible flair! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions adding isDeprecated() method, but the summary only shows deprecated() method being added without evidence of isDeprecated() implementation. Update the PR title to accurately reflect the actual changes, either to 'Add deprecated() to PriceTypeDefinitionInterface' or implement the missing isDeprecated() method.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bad8e3d and 451fd1a.

📒 Files selected for processing (2)
  • src/product/price/PriceTypeDefinition.php
  • src/product/price/PriceTypeDefinitionInterface.php

Comment on lines +239 to +244
public function deprecated(): static
{
$this->ensureNotLocked();

return $this;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

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.

@SilverFire SilverFire merged commit 3ebe910 into hiqdev:master Jun 12, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants