LogMessage fatals against Tool API ≥ 1.0.0-beta4: $logger property type conflicts with ToolBase's injected logger
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3616000. -->
Reported by: [michaellander](https://www.drupal.org/user/636494)
Related to !16
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Tool API is adding an injected logger channel to <code>ToolBase</code> as a promoted constructor property named <code>$logger</code>, typed <code>LoggerChannelInterface</code> (<a href="https://www.drupal.org/project/tool/issues/3582986">tool#3582986</a>). Because <code>ToolBase::__construct()</code> is final, subclasses inject services by declaring a property and overriding <code>create()</code> — and two tool_belt tools use that pattern with the name <code>$logger</code>:</p>
<ul>
<li><code>LogMessage</code> declares <code>protected LoggerInterface $logger</code>. The type differs from the parent's declaration, which is a compile-time PHP fatal (property redeclaration with a mismatched type), so the tool fatals on instantiation against Tool API ≥ 1.0.0-beta4.</li>
<li><code>WorkspaceCreateAndSwitch</code> declares <code>protected LoggerChannelInterface $logger</code> for its own <code>tool_belt_workspace</code> channel. This is an exact type match, which is a legal redeclaration — no change needed; its <code>create()</code> keeps assigning its own channel over the parent's, which the parent's documented contract explicitly allows.</li>
</ul>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ol>
<li>Install tool 1.0.x-dev at or after the tool#3582986 commit (or 1.0.0-beta4 once tagged) with tool_belt enabled.</li>
<li>Instantiate the <code>log_message</code> tool (Tool Explorer listing, drush <code>tool:info log_message</code>, or any invoker).</li>
<li>PHP fatal: the <code>$logger</code> property type must be <code>LoggerChannelInterface</code>.</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Delete <code>LogMessage</code>'s own <code>$logger</code> property and its <code>create()</code> override entirely: the parent now injects the same <code>tool</code> channel the tool was constructing for itself, so the override is redundant rather than merely conflicting. The tool's logging calls keep working unchanged through the inherited property.</p>
<p>Verified: the file lints, <code>log_message</code> instantiates through the plugin manager against the tool#3582986 branch, and the site responds normally.</p>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Merge after tool#3582986 lands (this change requires the parent-injected logger; before it, the current code is what works).</li>
<li>Set the tool dependency floor to the release containing tool#3582986 (1.0.0-beta4) in tool_belt's requirements.</li>
</ul>
<h3 id="summary-ui-changes">User interface changes</h3>
<p>None.</p>
<h3 id="summary-api-changes">API changes</h3>
<p>None — <code>LogMessage</code> loses a protected property and a <code>create()</code> override; behavior is identical.</p>
<h3 id="summary-data-model-changes">Data model changes</h3>
<p>None.</p>
<h3 id="summary-ai-usage">AI usage (if applicable)</h3>
<ul>
<li>[x] <strong>AI Assisted Issue:</strong> This issue was generated with AI assistance, but was reviewed and refined by the creator.</li>
<li>[x] <strong>AI Assisted Code:</strong> This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.</li>
<li>[ ] <strong>AI Generated Code:</strong> This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.</li>
<li>[ ] <strong>Vibe Coded:</strong> This code was generated by an AI and has only been functionally tested.</li>
</ul>
issue
GitLab AI Context
Project: project/tool_belt
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/tool_belt/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/tool_belt
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD