feat: add file headers to all PHP files for licensing and attribution#39
feat: add file headers to all PHP files for licensing and attribution#39konradmichalik merged 1 commit intomainfrom
Conversation
WalkthroughThis update adds GPLv3 license headers to all source, test, and fixture files, ensuring consistent open-source licensing. Numerous files are refactored for style: constructors are shortened, exception imports standardized, and trailing commas added for formatting. The PHP-CS-Fixer config is overhauled to use a new package and style. A CODEOWNERS file is introduced. Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer
participant Repo as Repository
participant CodeOwner as Code Owner
Dev->>Repo: Pushes changes (code, config, license headers)
Repo-->>CodeOwner: Notifies for review (via CODEOWNERS)
CodeOwner-->>Repo: Approves or requests changes
Repo-->>Dev: Merges or requests updates
Possibly related PRs
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 9
🔭 Outside diff range comments (7)
tests/Build/console-application.php (1)
24-28: Fix wrong / unused import and simplify instantiation
use Symfony\Component\Console;targets the namespace root and is never used.
Import the concreteApplicationclass instead and rely on the alias:-use Symfony\Component\Console; +use Symfony\Component\Console\Application; … -$application = new Console\Application(); +$application = new Application();Eliminates an unused import and clarifies intent.
tests/src/Fixtures/config/valid.php (1)
1-22: License header must precededeclare(strict_types=1);to satisfy PSR-12
File-level comments/docblocks go directly after the opening<?phpand before anydeclarestatement.<?php -declare(strict_types=1); - -/* +/* * This file is part of the Composer plugin "composer-translation-validator". * … */ + +declare(strict_types=1);src/Validator/ResultType.php (1)
1-22: Move GPL header abovedeclarefor standards compliance
Same ordering issue as in the fixture file – adjust as shown:<?php -declare(strict_types=1); - -/* +/* * This file is part of the Composer plugin "composer-translation-validator". * … */ + +declare(strict_types=1);tests/src/Fixtures/config/auto-detect/translation-validator.php (1)
1-22: Re-order header anddeclare
PSR-12 requires the comment first.<?php -declare(strict_types=1); - -/* +/* * This file is part of the Composer plugin "composer-translation-validator". * … */ + +declare(strict_types=1);tests/src/Parser/ParserCacheTest.php (1)
1-22: Header placement
Apply the same re-ordering fix here to keep every file PSR-12-compatible.<?php -declare(strict_types=1); - -/* +/* * This file is part of the Composer plugin "composer-translation-validator". * … */ + +declare(strict_types=1);src/Parser/ParserRegistry.php (1)
50-60: Make extension comparison case-insensitive
pathinfo()preserves the original casing, so a file namedfoo.JSONwon’t match the lower-case extension lists. Normalise before the lookup:- $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION); + $fileExtension = strtolower(pathinfo($filePath, PATHINFO_EXTENSION));src/Validator/AbstractValidator.php (1)
52-58: Null-safe logger access is inconsistent
$this->loggeris nullable, yet here the null-safe operator isn’t used. Anulllogger would cause a fatal error.- $this->logger->debug( + $this->logger?->debug(
♻️ Duplicate comments (8)
tests/src/Capability/ValidateTranslationCommandProviderTest.php (1)
5-22: Same SPDX remark as aboveSee comment in
src/Utility/PathUtility.php; the same single-line SPDX tag applies here.src/Result/FormatType.php (1)
5-22: Same SPDX remark as aboveSee comment in
src/Utility/PathUtility.php.tests/src/Config/TranslationValidatorConfigTest.php (1)
5-22: Same SPDX remark as aboveSee comment in
src/Utility/PathUtility.php.tests/src/FileDetector/PrefixFileDetectorTest.php (1)
5-22: Same SPDX remark as aboveSee comment in
src/Utility/PathUtility.php.tests/src/Result/AbstractValidationResultRendererTest.php (1)
3-22: Same header-ordering note as in previous file
See comment inPathUtilityExtendedTest.php.tests/src/FileDetector/SuffixFileDetectorTest.php (1)
3-22: Same header-ordering note as in previous file
See comment inPathUtilityExtendedTest.php.tests/src/PluginExtendedTest.php (1)
3-22: Same header-ordering note as in previous file
See comment inPathUtilityExtendedTest.php.tests/src/FileDetector/DirectoryFileDetectorTest.php (1)
3-22: Same header-ordering note as in previous file
See comment inPathUtilityExtendedTest.php.
🧹 Nitpick comments (40)
rector.php (1)
5-22: Move license header abovedeclare(strict_types=1)to satisfy PSR-12 orderingPSR-12 requires the file-level comment block (if present) to appear immediately after the opening
<?phptag and before thedeclaredirective.
Placing the header afterdeclareviolates that ordering rule and may trip automated linters/formatters configured for PSR-12.<?php -declare(strict_types=1); - -/* +/* * This file is part of the Composer plugin "composer-translation-validator". @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ + +declare(strict_types=1);Only one blank line should remain between the comment block and the
declareas per the spec.tests/Build/console-application.php (1)
5-22: Move the GPL header above thedeclarestatement to stay PSR-12-compliantPSR-12 requires that the
declare()directive appears immediately after the opening tag with no blank lines in-between and before any other statements/comment blocks.
Recommend:1 <?php -3 -declare(strict_types=1); -5 /* +/** + * <GPL header …> + */ + +declare(strict_types=1);This keeps the header, removes the superfluous blank line, and avoids style-checker noise.
tests/src/Fixtures/translations/php/laravel/en/messages.php (1)
3-20: GPL-3 header addition LGTM
Header wording and placement are correct and fulfil the PR objective.
Minor nit: consider automating the year (2025) via your header fixer to avoid manual edits in future years.tests/src/Fixtures/translations/php/fail/messages.de.php (1)
3-20: Header inserted correctly
No functional impact on the fixture; same nit about keeping the copyright year in sync automatically.tests/src/Fixtures/translations/php/laravel/de/messages.php (1)
3-20: Consistent GPL header, no issues spotted
Same recommendation to automate the dynamic year token to reduce future churn.tests/src/Fixtures/config/invalid.php (1)
5-22: Consider using a PHP-Doc style block for the license headerSeveral tooling ecosystems (API documentation generators, static analysers, IDEs) look for
/** … */rather than a plain/* … */to recognise file-level docblocks.
Replacing the opening delimiter with/**would improve automatic licence detection without changing the actual content.src/Utility/OutputUtility.php (1)
5-22: Same note as above regarding PHP-Doc delimitersFor consistency and better tool support, you may want to switch the licence comment to
/** … */.tests/src/Utility/OutputUtilityTest.php (1)
5-22: Optional: adopt/**for docblock compatibilityChanging the header to a PHP-Doc block helps IDEs and licence scanners pick it up automatically.
src/Parser/ParserCache.php (1)
5-22: Licence header looks good – minor style nitSwitching to a
/**docblock would align with common PHP conventions and improve tooling support.src/Validator/ValidatorRegistry.php (1)
5-22: Nit: prefer PHP-Doc style for the headerConsistent use of
/**instead of/*enables better licence discovery by static tools.src/Plugin.php (2)
35-39: Silence static-analysis false positives for unused parameters
activate,deactivate, anduninstallare required byPluginInterface, yet their parameters are unused, triggering PHPMD warnings. Add an explicit acknowledgement to keep CI noise down:public function activate(Composer $composer, IOInterface $io): void { // Parameters required by interface – intentionally unused. unset($composer, $io); }(or a per-method suppression annotation).
5-22: Switch to DocBlock header for better tooling detectionReplacing
/* … */with/** … */lets IDEs, licence scanners, and PHP-CS-Fixer reliably treat this as a file header rather than a plain block comment.src/Validator/PlaceholderConsistencyValidator.php (1)
48-52: Leverage PSR-3 placeholders instead of string concatenation$this->logger?->error( 'The source file {file} is not valid.', ['file' => $file->getFileName()], );avoids needless string building when the message is filtered out and reads cleaner.
src/Validator/EncodingValidator.php (2)
32-34: Avoid unconditionaluse Normalizer;whenext-intlis optionalSome static analysers flag the import on systems lacking the extension.
Simplest fix: drop theuseand keep the fully-qualified call after theclass_existscheck.if (!class_exists('Normalizer')) { return false; } $normalized = \Normalizer::normalize($content, \Normalizer::FORM_C);
48-50: Prefer logger placeholders over concatenation$this->logger?->error( 'Could not read file content: {file}', ['file' => $file->getFileName()], );src/Utility/ClassUtility.php (1)
40-48: Minor wording nitFor non-interface types, “must implement %s” may read oddly.
Consider “must be an instance of %s” for broader accuracy.src/Validator/EmptyValuesValidator.php (1)
43-46: Prefer sprintf over string concatenation for log messages.
Usingsprintf()(or context parameters) keeps the call readable and avoids the need for string concatenation.- $this->logger?->error( - 'The source file '.$file->getFileName().' is not valid.', - ); + $this->logger?->error( + sprintf('The source file %s is not valid.', $file->getFileName()), + );tests/src/Utility/ClassUtilityTest.php (1)
86-88: Optional assertion on call count could strengthen tests.
You rely on$loggedMessages[1]existing—adding an explicit assertion on the expected count makes failures clearer:- ClassUtility::instantiate(...); - - $this->assertStringContainsString(... $loggedMessages[0]); - $this->assertStringContainsString(... $loggedMessages[1]); + ClassUtility::instantiate(...); + + $this->assertCount(2, $loggedMessages); + $this->assertStringContainsString(... $loggedMessages[0]); + $this->assertStringContainsString(... $loggedMessages[1]);Also applies to: 100-102
src/Utility/PathUtility.php (1)
5-22: Add an SPDX identifier for easier automated license compliance checksMany scanners & build tools rely on a one-liner SPDX tag instead of heuristically parsing the full header.
Consider inserting the identifier right after the first explanatory line:* This file is part of the Composer plugin "composer-translation-validator". + * + * SPDX-License-Identifier: GPL-3.0-or-later *No functional impact, but it improves tooling compatibility and prevents future CI red flags.
src/Result/Issue.php (1)
31-36: Constructor uses trailing comma → PHP ≥ 8.0The trailing comma after the last promoted property (
$validatorType,) relies on PHP 8.0+. Ensure the package’s platform requirement reflects this (e.g.,"php": ">=8.0"incomposer.json) to avoid installs on unsupported versions.tests/src/Utility/PathUtilityExtendedTest.php (1)
3-22: Move header block above thedeclare(strict_types=1);statementPSR-12 expects the file-level banner (license / doc-block) to come immediately after the opening
<?phptag and beforedeclare(strict_types=1);.
Keepingdeclareas the very first statement avoids some tooling / fixer complaints.-<?php - -declare(strict_types=1); - -/* +<?php + +/* * This file is part of the Composer plugin "composer-translation-validator". * … */ + +declare(strict_types=1);tests/src/FileDetector/FileDetectorRegistryTest.php (1)
57-62: Minor PHPUnit forward-compatibility note
assertContains()is fine for array checks today, but be aware it’s deprecated for string containment in newer PHPUnit versions. No change required now, yet consider swapping toassertContains→assertContainsis still valid; nothing to fix.src/FileDetector/DirectoryFileDetector.php (1)
5-22: Use a/** … */block for the file-level doc-commentMost tools (phpDocumentor, Psalm, IDEs) only treat
/** … */as a PHPDoc block.
Switching from/*to/**keeps the new licence header machine-readable and aligns with common conventions.-/* +/** * This file is part of the Composer plugin "composer-translation-validator". * … */tests/src/Result/ValidationResultRendererFactoryTest.php (1)
5-22: Same PHPDoc remark as aboveConsider turning the file header into a
/** … */doc-comment for tooling consistency.tests/src/Validator/DuplicateKeysValidatorTest.php (1)
5-22: Convert header to PHPDoc style for consistencySame comment as in other files – switch
/*→/**.tests/src/Config/ConfigFactoryTest.php (1)
5-22: Prefer/** … */for the licence headerKeeps tooling happy.
tests/src/Parser/YamlParserTest.php (1)
26-29: Minor import-ordering nitpickFor consistency with PSR-12 you may alphabetically sort the
usestatements (InvalidArgumentException / RuntimeException should be adjacent).src/Result/ValidationResultCliRenderer.php (1)
29-34: Group & sort new importsNow that
ReflectionClassandThrowableare imported, consider ordering theuselist alphabetically to avoid merge noise later.tests/src/Parser/PhpParserTest.php (1)
26-29: Minor import-ordering nitpickSame comment as in the YAML test – aligning imports alphabetically (InvalidArgumentException / RuntimeException contiguous) keeps the diff minimal.
tests/src/Parser/AbstractParserTest.php (1)
26-29: Minor import-ordering nitpickKeep
InvalidArgumentExceptionandRuntimeExceptiongrouped/alphabetised.src/Parser/XliffParser.php (2)
31-31: Narrow the$xmlproperty type toSimpleXMLElementAfter the constructor guard clause that throws on
false,$this->xmlcan never hold abool. Keepingboolin the union type is therefore misleading and may force consumers to handle an impossible branch.- private readonly SimpleXMLElement|bool $xml; + /** @var SimpleXMLElement */ + private readonly SimpleXMLElement $xml;This preserves strict typing without losing any safety and makes static analysers happier.
48-55: Restore previous libxml error handling state to avoid global side-effects
libxml_use_internal_errors(true)is set but never reverted. As this is a global flag, it may leak into unrelated XML parsing elsewhere in the process.- libxml_use_internal_errors(true); + $previous = libxml_use_internal_errors(true); $this->xml = simplexml_load_string($xmlContent); + libxml_use_internal_errors($previous);(You can also wrap this in a
try/finallyblock to guarantee the reset if an exception is thrown.)tests/src/Result/ValidationRunTest.php (4)
368-370: Suppress PHPMD false positives for intentionally unused parameters
addIssue()is a mock stub; the$issueparameter is intentionally unused.
Add a PHPMD suppression to silence the static-analysis noise:+ /** @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function addIssue(Issue $issue): void {}Repeat for the other stub methods flagged below.
385-386: Same nitpick as above – suppress or explicitlyunset()the unused$output/$issuesparameters to keep the build clean.
437-439: Ditto for the$issueparameter in this mock.
464-465: Ditto for$output/$issueshere.src/Result/ValidationRun.php (1)
132-134: Consider logging swallowed exceptions for traceabilityThe catch-all on
Throwablesilently ignores parser failures.
Even a debug-level log would help diagnose malformed files without polluting normal output.} catch (Throwable $e) { $this->logger->debug('Parser error: '.$e->getMessage(), ['file' => $file]); // Skip files that can't be parsed }Purely optional, but improves debuggability.
tests/src/Validator/AbstractValidatorTest.php (2)
160-166:@throws ReflectionExceptionannotation is misplaced
testValidateWithIssues()does not invoke any reflection API that could throwReflectionException, but the preceding test (testConstructorSetsLogger) does. Move the annotation to the correct method or drop it here to avoid misleading static-analysis results.- /** - * @throws ReflectionException - */ + /** + * No exceptions expected. + */
140-148: Missing@throwson the reflective test
Conversely,testConstructorSetsLogger()actually performs reflection but lacks the corresponding@throws ReflectionExceptionannotation. Add it for completeness and to silence tools like PHPStan.public function testConstructorSetsLogger(): void { - $validator = new ConcreteValidator($this->loggerMock); + /** + * @throws ReflectionException + */ + $validator = new ConcreteValidator($this->loggerMock);src/Config/ConfigFileReader.php (1)
54-60: File-extension check is case-sensitive
match ($extension)will fail for files likeconfig.JSONorconfig.Yml. Converting the extension to lowercase makes the matcher robust across platforms.- $extension = pathinfo($configPath, PATHINFO_EXTENSION); + $extension = strtolower(pathinfo($configPath, PATHINFO_EXTENSION));Apply the same adjustment in
readAsConfig().
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Move the license block above declare(strict_types=1) to comply with PSR-12
PSR-12 specifies that the file-level docblock (license/header) must immediately follow the opening <?php tag, and the declare statement comes after that. Current order breaks many tooling/CI checks.
<?php
-declare(strict_types=1);
-
-/*
+/*
* This file is part of the Composer plugin "composer-translation-validator".
* …
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+
+declare(strict_types=1);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| declare(strict_types=1); | |
| /* | |
| * This file is part of the Composer plugin "composer-translation-validator". | |
| * | |
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | |
| * | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| * | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | |
| * | |
| * You should have received a copy of the GNU General Public License | |
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
| */ | |
| <?php | |
| /* | |
| * This file is part of the Composer plugin "composer-translation-validator". | |
| * | |
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | |
| * | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version of the License. | |
| * | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | |
| * | |
| * You should have received a copy of the GNU General Public License | |
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
| */ | |
| declare(strict_types=1); |
🤖 Prompt for AI Agents
In src/Validator/XliffSchemaValidator.php lines 3 to 22, the license block is
placed after the declare(strict_types=1) statement, which violates PSR-12
standards. Move the entire license comment block so that it immediately follows
the opening <?php tag and place the declare(strict_types=1) statement after the
license block to comply with PSR-12 formatting rules.
| @@ -0,0 +1 @@ | |||
| * km@move-elevator.de | |||
There was a problem hiding this comment.
Invalid CODEOWNERS syntax – use GitHub handles or team slugs, not an e-mail address
GitHub ignores e-mail addresses in CODEOWNERS; ownership will therefore not be enforced.
Replace the e-mail with @username or @org/team.
-* km@move-elevator.de
+* @your-github-handle # or @org/team📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| * km@move-elevator.de | |
| * @your-github-handle # or @org/team |
🤖 Prompt for AI Agents
In the CODEOWNERS file at line 1, replace the email address
"km@move-elevator.de" with a valid GitHub handle or team slug, such as
"@username" or "@org/team", because GitHub does not recognize email addresses
for ownership enforcement.
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Move license header above declare to satisfy PSR-12
PSR-12 specifies that a file-level DocBlock MUST appear immediately after the opening <?php tag before the declare(strict_types=1); statement.
Having the header after declare breaks many automated CS/Fixer rules and may fail CI.
<?php
-declare(strict_types=1);
-
-/*
+/*
* This file is part of the Composer plugin "composer-translation-validator".
@@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+
+declare(strict_types=1);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| declare(strict_types=1); | |
| /* | |
| * This file is part of the Composer plugin "composer-translation-validator". | |
| * | |
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | |
| * | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| * | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | |
| * | |
| * You should have received a copy of the GNU General Public License | |
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
| */ | |
| <?php | |
| /* | |
| * This file is part of the Composer plugin "composer-translation-validator". | |
| * | |
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | |
| * | |
| * This program is free software: you can redistribute it and/or modify | |
| * it under the terms of the GNU General Public License as published by | |
| * the Free Software Foundation, either version 3 of the License, or | |
| * (at your option) any later version. | |
| * | |
| * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | |
| * | |
| * You should have received a copy of the GNU General Public License | |
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | |
| */ | |
| declare(strict_types=1); |
🤖 Prompt for AI Agents
In tests/src/PluginTest.php around lines 3 to 22, the license header comment is
placed after the declare(strict_types=1); statement, which violates PSR-12
standards. Move the entire license header block so that it appears immediately
after the opening <?php tag and before the declare(strict_types=1); line to
comply with PSR-12 and avoid issues with automated code style tools and CI.
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Re-order header / declare as per PSR-12
Same issue: the license DocBlock must precede the declare directive.
Apply the same diff pattern shown in the previous comment.
🤖 Prompt for AI Agents
In tests/src/Command/ValidateTranslationCommandConfigTestSimple.php around lines
3 to 22, the file header comment with the license information should be placed
before the declare(strict_types=1) statement to comply with PSR-12 standards.
Move the entire DocBlock comment above the declare directive so that the license
header is the very first thing in the file, followed by the declare statement.
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Header precedes declare
Please move the GPL header above the declare(strict_types=1); line to stay compliant with PSR-12 and keep CS tools quiet.
🤖 Prompt for AI Agents
In src/FileDetector/PrefixFileDetector.php around lines 3 to 22, the GPL header
comment is placed after the declare(strict_types=1); statement, which violates
PSR-12 standards. Move the entire GPL header comment block so that it appears
before the declare(strict_types=1); line to ensure compliance with coding
standards and avoid issues with code style tools.
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Reposition license block before declare
For consistency with the rest of the codebase and PSR-12, place the file-level header right after <?php.
🤖 Prompt for AI Agents
In tests/src/Result/OutputTest.php around lines 3 to 22, the license block is
placed after the declare(strict_types=1) statement, which is inconsistent with
PSR-12 and the rest of the codebase. Move the entire license comment block so
that it appears immediately after the opening <?php tag and before the
declare(strict_types=1) statement to comply with the standard.
| declare(strict_types=1); | ||
|
|
||
| /* | ||
| * This file is part of the Composer plugin "composer-translation-validator". | ||
| * | ||
| * Copyright (C) 2025 Konrad Michalik <km@move-elevator.de> | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Place license DocBlock before declare
As with the other files, move the header above the declare statement to comply with PSR-12.
🤖 Prompt for AI Agents
In src/FileDetector/DetectorInterface.php lines 3 to 22, the license DocBlock is
placed after the declare(strict_types=1) statement. Move the entire license
DocBlock so that it appears before the declare statement to comply with PSR-12
coding standards.
| $this->expectException(InvalidArgumentException::class); | ||
| $this->expectExceptionMessage('File "/non/existent/file.php" does not exist.'); | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use a regex for portable path assertion
Hard-coding the exact Unix style path can break on Windows paths. Prefer a regex:
- $this->expectExceptionMessage('File "/non/existent/file.php" does not exist.');
+ $this->expectExceptionMessageMatches('/File ".*file\.php" does not exist\./');📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $this->expectException(InvalidArgumentException::class); | |
| $this->expectExceptionMessage('File "/non/existent/file.php" does not exist.'); | |
| $this->expectException(InvalidArgumentException::class); | |
| - $this->expectExceptionMessage('File "/non/existent/file.php" does not exist.'); | |
| + $this->expectExceptionMessageMatches('/File ".*file\.php" does not exist\./'); |
🤖 Prompt for AI Agents
In tests/src/Parser/PhpParserTest.php around lines 50 to 52, the test expects an
exact error message with a hard-coded Unix style file path, which can fail on
Windows systems. Replace the exact string match in expectExceptionMessage with
expectExceptionMessageMatches or a similar method that accepts a regex pattern
matching the error message, allowing for platform-independent path formats.
| $this->expectException(InvalidArgumentException::class); | ||
| $this->expectExceptionMessage('File "/non/existent/file.txt" does not exist.'); | ||
|
|
There was a problem hiding this comment.
🛠️ Refactor suggestion
Use regex for portable path assertion
Same portability concern as in PhpParserTest:
- $this->expectExceptionMessage('File "/non/existent/file.txt" does not exist.');
+ $this->expectExceptionMessageMatches('/File ".*file\.txt" does not exist\./');🤖 Prompt for AI Agents
In tests/src/Parser/AbstractParserTest.php around lines 76 to 78, the test
expects an exact exception message containing a file path, which may cause
portability issues across different environments. Replace the exact string match
in expectExceptionMessage with a regex pattern using
expectExceptionMessageMatches to assert the message, allowing for flexible path
formats and improving test portability.
Summary by CodeRabbit
Chores
Style
Documentation
Tests