Skip to content

Adding rector commands in composer.json and fixing issues found by rector#445

Merged
armanist merged 1 commit intosoftberg:masterfrom
armanist:master
Apr 3, 2026
Merged

Adding rector commands in composer.json and fixing issues found by rector#445
armanist merged 1 commit intosoftberg:masterfrom
armanist:master

Conversation

@armanist
Copy link
Copy Markdown
Member

@armanist armanist commented Apr 3, 2026

Summary by CodeRabbit

  • Chores

    • Updated development scripts to include code quality commands.
  • Refactor

    • Added stricter type declarations across internal components for improved code type safety and consistency.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

📝 Walkthrough

Walkthrough

The pull request enhances type safety across the codebase by introducing stricter parameter typing to class methods, adding a strict types declaration, and improving callback type annotations. Additionally, Rector build commands are integrated into composer.json for code quality automation.

Changes

Cohort / File(s) Summary
Build Configuration
composer.json
Added two Rector script commands: rector:check and rector:fix for automated code quality checks and fixes.
Type Safety & Strict Types
src/Environment/Server.php, src/Mailer/Adapters/SmtpAdapter.php, src/Service/Factories/ServiceFactory.php
Added string type constraints to Server::get() and Server::set() parameters, restricted PHPMailer debug callback to accept string parameter, and added declare(strict_types=1) declaration to ServiceFactory.
Helper Function Update
src/App/Helpers/misc.php
Modified array parameter placeholder substitution callback to explicitly return string, with fallback to empty string when parameters are exhausted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops of type and safety bright,
Stricter parameters set just right,
Rector commands dance in code,
PHP's road grows less unload,
Callbacks now know what they say! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: adding rector commands to composer.json and addressing rector-identified issues across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.58%. Comparing base (3d207c4) to head (7d27f7a).
⚠️ Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/Mailer/Adapters/SmtpAdapter.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master     #445   +/-   ##
=========================================
  Coverage     82.58%   82.58%           
  Complexity     2831     2831           
=========================================
  Files           243      243           
  Lines          7545     7545           
=========================================
  Hits           6231     6231           
  Misses         1314     1314           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/App/Helpers/misc.php (1)

25-26: Silence the unused callback parameter warning.

Line 25 currently triggers an unused-parameter warning. Consider marking it intentionally unused.

♻️ Proposed tweak
-        return preg_replace_callback('/{%\d+}/', function (array $matches) use (&$params): string {
+        return preg_replace_callback('/{%\d+}/', function (array $_matches) use (&$params): string {
             return array_shift($params) ?? '';
         }, $subject) ?? $subject;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/App/Helpers/misc.php` around lines 25 - 26, The anonymous callback passed
to preg_replace_callback in misc.php has an unused parameter $matches causing
warnings; mark it intentionally unused by renaming the parameter (e.g., to $_ or
$_matches) or otherwise discarding it so the linter knows it's
intentional—update the callback signature in the preg_replace_callback call that
currently reads function (array $matches) use (&$params): string { ... } to use
an underscore-prefixed name or a single underscore parameter while leaving the
body returning array_shift($params) ?? ''.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/App/Helpers/misc.php`:
- Around line 25-26: The anonymous callback passed to preg_replace_callback in
misc.php has an unused parameter $matches causing warnings; mark it
intentionally unused by renaming the parameter (e.g., to $_ or $_matches) or
otherwise discarding it so the linter knows it's intentional—update the callback
signature in the preg_replace_callback call that currently reads function (array
$matches) use (&$params): string { ... } to use an underscore-prefixed name or a
single underscore parameter while leaving the body returning
array_shift($params) ?? ''.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a995fffe-f82b-4e5f-9030-65ddac5315ba

📥 Commits

Reviewing files that changed from the base of the PR and between 6e35193 and 7d27f7a.

📒 Files selected for processing (5)
  • composer.json
  • src/App/Helpers/misc.php
  • src/Environment/Server.php
  • src/Mailer/Adapters/SmtpAdapter.php
  • src/Service/Factories/ServiceFactory.php

@armanist armanist merged commit 7f2d119 into softberg:master Apr 3, 2026
6 of 7 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.

1 participant