Skip to content

feat: Add dual PSR-7 version support and related documentation#8

Merged
code-cfernandes merged 2 commits into
mainfrom
7-bug-compatibilidade-psr-7
Jul 9, 2025
Merged

feat: Add dual PSR-7 version support and related documentation#8
code-cfernandes merged 2 commits into
mainfrom
7-bug-compatibilidade-psr-7

Conversation

@code-cfernandes
Copy link
Copy Markdown
Member

  • Introduced compatibility for both PSR-7 v1.x and v2.x in PivotPHP.
  • Added scripts for switching between PSR-7 versions and checking the current version.
  • Updated composer.json to enforce PSR-7 v2.0 as the default while allowing v1.x.
  • Enhanced README.md with instructions for version switching and compatibility details.
  • Created detailed implementation summary and PSR-7 compatibility status documentation.
  • Implemented Psr7VersionDetector for automatic version detection.
  • Added Psr7V1CompatibilityTrait for PHPDoc annotations to support v1.x.
  • Refactored HTTP components to maintain compliance with both PSR-7 versions.
  • Improved testing and validation scripts for both PSR-7 versions.

Pull Request Template

📋 Descrição

Descreva resumidamente as mudanças feitas neste PR.

🎯 Tipo de Mudança

  • 🐛 Bug fix (mudança que corrige um bug)
  • ✨ Nova feature (mudança que adiciona funcionalidade)
  • 💥 Breaking change (mudança que causa incompatibilidade)
  • 📚 Documentação (mudanças apenas na documentação)
  • 🧹 Refactoring (mudanças que não corrigem bug nem adicionam feature)
  • ⚡ Performance (mudanças que melhoram a performance)
  • 🧪 Testes (adição ou correção de testes)

🧪 Como foi testado?

Descreva os testes que você executou para verificar suas mudanças.

  • Testes unitários passando
  • Testes funcionais passando
  • Testado manualmente
  • Exemplos funcionando

📝 Checklist

  • Meu código segue as diretrizes de estilo do projeto
  • Eu fiz uma auto-revisão do meu código
  • Comentei meu código, especialmente em partes difíceis de entender
  • Fiz mudanças correspondentes na documentação
  • Minhas mudanças não geram novos warnings
  • Adicionei testes que provam que minha correção é eficaz ou que minha feature funciona
  • Testes unitários novos e existentes passam localmente com minhas mudanças

🔗 Issues Relacionadas

Fixes #7

- Introduced compatibility for both PSR-7 v1.x and v2.x in PivotPHP.
- Added scripts for switching between PSR-7 versions and checking the current version.
- Updated composer.json to enforce PSR-7 v2.0 as the default while allowing v1.x.
- Enhanced README.md with instructions for version switching and compatibility details.
- Created detailed implementation summary and PSR-7 compatibility status documentation.
- Implemented Psr7VersionDetector for automatic version detection.
- Added Psr7V1CompatibilityTrait for PHPDoc annotations to support v1.x.
- Refactored HTTP components to maintain compliance with both PSR-7 versions.
- Improved testing and validation scripts for both PSR-7 versions.
@code-cfernandes code-cfernandes self-assigned this Jul 9, 2025
Copilot AI review requested due to automatic review settings July 9, 2025 00:06
@code-cfernandes code-cfernandes linked an issue Jul 9, 2025 that may be closed by this pull request

This comment was marked as outdated.

@code-cfernandes code-cfernandes requested a review from Copilot July 9, 2025 00:09

This comment was marked as outdated.

@code-cfernandes code-cfernandes requested a review from Copilot July 9, 2025 00:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for both PSR-7 v1.x and v2.x in PivotPHP by introducing automatic detection, version-switching scripts, updated composer constraints, PHPDoc compatibility traits, and extensive documentation updates.

  • Implemented a Psr7VersionDetector for runtime PSR-7 version detection.
  • Added scripts (switch-psr7-version.php, adapt-psr7-v1.php) to toggle return-type signatures and update composer requirements.
  • Updated documentation (docs/technical/*) and composer.json for dual PSR-7 compatibility.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Http/Psr7/* (multiple) Removed/added return types on PSR-7 methods for v1/v2 compatibility
src/Http/Psr7/Factory/Psr7VersionDetector.php Added version detection logic
src/Http/Psr7/Psr7V1CompatibilityTrait.php Introduced PHPDoc stubs for v1.x
scripts/switch-psr7-version.php Script to switch between PSR-7 versions
scripts/adapt-psr7-v1.php Script to strip return types for v1.x
composer.json Adjusted PSR-7 requirement
docs/technical/http/README.md Expanded HTTP component docs with PSR-7 dual-support section
docs/technical/compatibility/psr7-*.md New compatibility guides
Comments suppressed due to low confidence (5)

README.md:150

  • The README mentions a --check flag, but the switch script only accepts 1 or 2; update the documentation or implement support for --check in the script to avoid confusion.
php scripts/switch-psr7-version.php --check

docs/technical/http/README.md:125

  • The example references withHeaderStrict, which is not defined in the PSR-7 implementation; either remove this call or provide its implementation details.
   $response = $response->withHeaderStrict('X-Custom', $value);

src/Http/Psr7/Uri.php:66

  • [nitpick] When targeting PSR-7 v1.x (no native return types), consider adding @return string to the docblock of getScheme() (and similar methods) to maintain IDE and static analysis support.
    public function getScheme()

src/Http/Psr7/Factory/Psr7VersionDetector.php:22

  • Add unit tests for Psr7VersionDetector::getVersion(), isV1(), and isV2() to validate correct detection across environments and to ensure the version cache reset works as expected.
    public static function getVersion(): string

composer.json:42

  • The composer constraint now only allows PSR-7 v1.x; to match the PR description and support both versions (or default to v2.x), restore the constraint to "^1.1|^2.0" or set a default of "^2.0" while allowing "^1.1".
        "psr/http-message": "^1.1",

@code-cfernandes code-cfernandes merged commit 465f806 into main Jul 9, 2025
5 checks passed
@code-cfernandes code-cfernandes deleted the 7-bug-compatibilidade-psr-7 branch July 9, 2025 00:16
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.

[BUG] Compatibilidade PSR-7

2 participants