Tightened 'DrupalDriverInterface' contract and 'DrupalDriver' visibility.#358
Tightened 'DrupalDriverInterface' contract and 'DrupalDriver' visibility.#358AlexSkrypnyk merged 1 commit intomasterfrom
Conversation
📝 WalkthroughWalkthroughThis PR refactors the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Code coverage (threshold: 95%) Per-class coverage |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Drupal/Driver/DrupalDriver.php`:
- Around line 143-145: The setCore(CoreInterface $core) method currently
replaces $this->core without resetting the driver's bootstrapped flag; update
setCore to assign the new core and also set $this->bootstrapped = false (and
clear any related bootstrap-specific state if present) so the driver will re-run
bootstrap for the new core; modify the setCore function in DrupalDriver to reset
the bootstrapped property after assigning $this->core.
🪄 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: 3ae51423-2b22-48ec-ade6-3e2928e7cc6a
📒 Files selected for processing (4)
src/Drupal/Driver/DrupalDriver.phpsrc/Drupal/Driver/DrupalDriverInterface.phptests/Drupal/Tests/Driver/Unit/CoreLookupTest.phptests/Drupal/Tests/Driver/Unit/DrupalDriverDelegationTest.php
| public function setCore(CoreInterface $core): void { | ||
| $this->core = $core; | ||
| } |
There was a problem hiding this comment.
Reset bootstrapped state when replacing core.
On Line 143-144, replacing the core without resetting bootstrapped can leave the driver in an inconsistent state (new core, old bootstrap flag), causing bootstrap to be skipped incorrectly.
Proposed fix
public function setCore(CoreInterface $core): void {
$this->core = $core;
+ $this->bootstrapped = FALSE;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/Drupal/Driver/DrupalDriver.php` around lines 143 - 145, The
setCore(CoreInterface $core) method currently replaces $this->core without
resetting the driver's bootstrapped flag; update setCore to assign the new core
and also set $this->bootstrapped = false (and clear any related
bootstrap-specific state if present) so the driver will re-run bootstrap for the
new core; modify the setCore function in DrupalDriver to reset the bootstrapped
property after assigning $this->core.
Summary
Tightens the
DrupalDriverInterfacecontract so consumers can type-hint against the interface and callgetCore(),setCore(), andgetDrupalVersion()without downcasting to the concrete class. Makes$coreand$versiononDrupalDriverprotectedso subclasses retain access while outside callers are directed through the public API. Corrects the@throws BootstrapExceptionannotation ongetDrupalVersion()- the exception is raised during construction insidedetectMajorVersion(), not by the getter itself.Stack
This PR is #1 of 4 in a stacked series:
feature/driver-interface→masterfeature/field-classifier→feature/driver-interfacefeature/field-coverage→feature/field-classifierfeature/ext-smoke-ci→feature/field-coverageMerge PRs in order. Each PR's base will rebase to
masterautomatically as its predecessor merges.Changes
getCore(),setCore(), andgetDrupalVersion()onDrupalDriverInterfaceso the full driver contract is visible at the interface level.$coreand$versionpropertiesprotectedonDrupalDriver; subclasses can read them, but external callers must use the public methods.@throws BootstrapExceptionannotation ongetDrupalVersion(): the exception originates indetectMajorVersion()at construction time, not in the getter. The updated docblock on the interface makes this distinction clear.Before / After
Summary by CodeRabbit
Refactor
Tests