Skip to content

feat: add file headers to all PHP files for licensing and attribution#39

Merged
konradmichalik merged 1 commit intomainfrom
file-headers
Jul 20, 2025
Merged

feat: add file headers to all PHP files for licensing and attribution#39
konradmichalik merged 1 commit intomainfrom
file-headers

Conversation

@konradmichalik
Copy link
Copy Markdown
Contributor

@konradmichalik konradmichalik commented Jul 19, 2025

Summary by CodeRabbit

  • Chores

    • Added GPLv3 license headers to all source, test, and fixture files for improved legal compliance and clarity.
    • Updated code style for constructors and method bodies to use concise empty body syntax where applicable.
    • Standardized import and usage of exception classes for consistency.
    • Added a repository-wide code ownership file assigning all files to a specific maintainer.
    • Switched PHP code style configuration to a new package and updated related development dependencies.
  • Style

    • Applied minor formatting improvements, such as adding trailing commas and adjusting whitespace, to enhance code readability and maintain consistency.
  • Documentation

    • Updated file headers and docblocks to reflect licensing and copyright information.
  • Tests

    • Updated test files to align with new code style and import conventions; no changes to test logic or coverage.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 19, 2025

Walkthrough

This 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

Files/Paths Change Summary
All src/, tests/, and fixtures/ files Added GPLv3 license headers to every PHP file for clear licensing.
Many src/ and tests/ files Refactored constructors to concise empty bodies; standardized exception imports and usage; added trailing commas.
.php-cs-fixer.php, composer.json Switched PHP-CS-Fixer config to new package and style; updated dev dependencies accordingly.
CODEOWNERS Added file assigning repository ownership to a specific user.

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
Loading

Possibly related PRs

Poem

In fields of code where licenses grow,
The rabbit hops with GPL in tow.
Constructors trimmed, exceptions neat,
Commas trailing, style complete.
A CODEOWNER now stands guard and true—
This garden’s open, thanks to you!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

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 concrete Application class 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 precede declare(strict_types=1); to satisfy PSR-12
File-level comments/docblocks go directly after the opening <?php and before any declare statement.

 <?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 above declare for 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 and declare
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 named foo.JSON won’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->logger is nullable, yet here the null-safe operator isn’t used. A null logger 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 above

See 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 above

See comment in src/Utility/PathUtility.php.

tests/src/Config/TranslationValidatorConfigTest.php (1)

5-22: Same SPDX remark as above

See comment in src/Utility/PathUtility.php.

tests/src/FileDetector/PrefixFileDetectorTest.php (1)

5-22: Same SPDX remark as above

See comment in src/Utility/PathUtility.php.

tests/src/Result/AbstractValidationResultRendererTest.php (1)

3-22: Same header-ordering note as in previous file
See comment in PathUtilityExtendedTest.php.

tests/src/FileDetector/SuffixFileDetectorTest.php (1)

3-22: Same header-ordering note as in previous file
See comment in PathUtilityExtendedTest.php.

tests/src/PluginExtendedTest.php (1)

3-22: Same header-ordering note as in previous file
See comment in PathUtilityExtendedTest.php.

tests/src/FileDetector/DirectoryFileDetectorTest.php (1)

3-22: Same header-ordering note as in previous file
See comment in PathUtilityExtendedTest.php.

🧹 Nitpick comments (40)
rector.php (1)

5-22: Move license header above declare(strict_types=1) to satisfy PSR-12 ordering

PSR-12 requires the file-level comment block (if present) to appear immediately after the opening <?php tag and before the declare directive.
Placing the header after declare violates 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 declare as per the spec.

tests/Build/console-application.php (1)

5-22: Move the GPL header above the declare statement to stay PSR-12-compliant

PSR-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 header

Several 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 delimiters

For 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 compatibility

Changing 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 nit

Switching 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 header

Consistent 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, and uninstall are required by PluginInterface, 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 detection

Replacing /* … */ 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 unconditional use Normalizer; when ext-intl is optional

Some static analysers flag the import on systems lacking the extension.
Simplest fix: drop the use and keep the fully-qualified call after the class_exists check.

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 nit

For 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.
Using sprintf() (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 checks

Many 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.0

The 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" in composer.json) to avoid installs on unsupported versions.

tests/src/Utility/PathUtilityExtendedTest.php (1)

3-22: Move header block above the declare(strict_types=1); statement

PSR-12 expects the file-level banner (license / doc-block) to come immediately after the opening <?php tag and before declare(strict_types=1);.
Keeping declare as 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 to assertContainsassertContains is still valid; nothing to fix.

src/FileDetector/DirectoryFileDetector.php (1)

5-22: Use a /** … */ block for the file-level doc-comment

Most 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 above

Consider 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 consistency

Same comment as in other files – switch /*/**.

tests/src/Config/ConfigFactoryTest.php (1)

5-22: Prefer /** … */ for the licence header

Keeps tooling happy.

tests/src/Parser/YamlParserTest.php (1)

26-29: Minor import-ordering nitpick

For consistency with PSR-12 you may alphabetically sort the use statements (InvalidArgumentException / RuntimeException should be adjacent).

src/Result/ValidationResultCliRenderer.php (1)

29-34: Group & sort new imports

Now that ReflectionClass and Throwable are imported, consider ordering the use list alphabetically to avoid merge noise later.

tests/src/Parser/PhpParserTest.php (1)

26-29: Minor import-ordering nitpick

Same 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 nitpick

Keep InvalidArgumentException and RuntimeException grouped/alphabetised.

src/Parser/XliffParser.php (2)

31-31: Narrow the $xml property type to SimpleXMLElement

After the constructor guard clause that throws on false, $this->xml can never hold a bool. Keeping bool in 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/finally block 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 $issue parameter 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 explicitly unset() the unused $output / $issues parameters to keep the build clean.


437-439: Ditto for the $issue parameter in this mock.


464-465: Ditto for $output / $issues here.

src/Result/ValidationRun.php (1)

132-134: Consider logging swallowed exceptions for traceability

The catch-all on Throwable silently 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 ReflectionException annotation is misplaced
testValidateWithIssues() does not invoke any reflection API that could throw ReflectionException, 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 @throws on the reflective test
Conversely, testConstructorSetsLogger() actually performs reflection but lacks the corresponding @throws ReflectionException annotation. 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 like config.JSON or config.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().

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
* 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.

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
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.

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines 3 to +22
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/>.
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines +50 to 52
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('File "/non/existent/file.php" does not exist.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Suggested change
$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.

Comment on lines +76 to 78
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('File "/non/existent/file.txt" does not exist.');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@konradmichalik konradmichalik merged commit 9c4bdf5 into main Jul 20, 2025
26 of 28 checks passed
@konradmichalik konradmichalik deleted the file-headers branch July 28, 2025 17:13
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