Skip to content

refactor(autoload): add initial PSR-4 support - #1610

Merged
JohnVillalovos merged 1 commit into
developfrom
jlvillal/psr4
Jul 26, 2026
Merged

refactor(autoload): add initial PSR-4 support#1610
JohnVillalovos merged 1 commit into
developfrom
jlvillal/psr4

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

Establish a Composer PSR-4 autoload mapping for the LibreBooking namespace rooted at the new src/ directory and migrate the first component: the Microsoft OAuth callback handler.

  • Map LibreBooking\ to src/ in composer.json, leaving the legacy lib/ tree on the existing include system so the gradual migration passes composer dump-autoload --optimize --strict-psr.
  • Split MicrosoftOAuthCallback, MicrosoftOAuthCallbackResult, and MicrosoftOAuthCallbackOutcome into one file per type under src/Application/Authentication/ and delete the legacy file.
  • Keep the lib/Common/namespace.php bootstrap in Web/microsoft-auth.php alongside vendor/autoload.php so Log's dependencies and the global exception handler keep working; dropping it caused OAuth error callbacks to fatal with "Class 'Configuration' not found" in an earlier attempt (PR Adding PSR-4 support #1552).
  • Add an entry-point regression test that runs Web/microsoft-auth.php in a subprocess to catch missing-class fatals in the bootstrap.
  • Map LibreBooking\Tests\ to tests/src/ via autoload-dev and move the handler test there as a namespaced class; the strict CI autoload check now enforces that test names match their paths. Add a "src" PHPUnit testsuite for running these tests in isolation.
  • Add src to both PHPStan configurations.
  • Document the migration policy in AGENTS.md: what belongs in src/, the one-type-per-file and namespace rules, the test location and naming convention, and the entry-point bootstrap requirements.

Related: #1501

Assisted-by: Claude:claude-fable-5

Copilot AI review requested due to automatic review settings July 26, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 establishes initial PSR-4 autoloading for the LibreBooking\ namespace via Composer, introduces the first migrated src/ component (Microsoft OAuth callback handler and related types), and adds a subprocess regression test to ensure the web entry point can execute without missing-class fatals while still relying on the legacy bootstrap.

Changes:

  • Add Composer PSR-4 autoload (LibreBooking\src/) and autoload-dev mapping for LibreBooking\Tests\tests/src/.
  • Migrate Microsoft OAuth callback handler/types into src/Application/Authentication/ with one-type-per-file and update the web entry point to use Composer autoloading.
  • Add a subprocess test for Web/microsoft-auth.php and a dedicated PHPUnit src testsuite; include src/ in PHPStan configs; document migration rules in AGENTS.md.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Web/microsoft-auth.php Switch callback handler loading to Composer autoload while retaining legacy bootstrap.
tests/Web/MicrosoftAuthEntryPointTest.php Add subprocess regression test to catch entry-point bootstrap fatals.
tests/src/Application/Authentication/MicrosoftOAuthCallbackTest.php Move handler unit tests under PSR-4 test namespace/path.
src/Application/Authentication/MicrosoftOAuthCallback.php Introduce namespaced handler under src/ with log-sanitization.
src/Application/Authentication/MicrosoftOAuthCallbackOutcome.php Split outcome enum into its own PSR-4-compliant file.
src/Application/Authentication/MicrosoftOAuthCallbackResult.php Split result DTO into its own PSR-4-compliant file.
phpunit.xml.dist Add src testsuite for isolating PSR-4 tests.
phpstan.neon Add src/ to PHPStan analysis paths.
phpstan_next.neon Add src/ to PHPStan-next analysis paths.
composer.json Add PSR-4 autoload/autoload-dev mappings for src/ and tests/src/.
AGENTS.md Document PSR-4 migration policy, placement rules, and testing conventions.

Comment thread src/Application/Authentication/MicrosoftOAuthCallbackResult.php
Comment thread tests/Web/MicrosoftAuthEntryPointTest.php
@JohnVillalovos
JohnVillalovos force-pushed the jlvillal/psr4 branch 2 times, most recently from 3423852 to 4cb58ac Compare July 26, 2026 02:28
Establish a Composer PSR-4 autoload mapping for the LibreBooking
namespace rooted at the new src/ directory and migrate the first
component: the Microsoft OAuth callback handler.

- Map LibreBooking\ to src/ in composer.json, leaving the legacy lib/
  tree on the existing include system so the gradual migration passes
  `composer dump-autoload --optimize --strict-psr`.
- Split MicrosoftOAuthCallback, MicrosoftOAuthCallbackResult, and
  MicrosoftOAuthCallbackOutcome into one file per type under
  src/Application/Authentication/ and delete the legacy file.
- Keep the lib/Common/namespace.php bootstrap in Web/microsoft-auth.php
  alongside vendor/autoload.php so Log's dependencies and the global
  exception handler keep working; dropping it caused OAuth error
  callbacks to fatal with "Class 'Configuration' not found" in an
  earlier attempt (PR #1552).
- Add an entry-point regression test that runs Web/microsoft-auth.php
  in a subprocess to catch missing-class fatals in the bootstrap.
- Map LibreBooking\Tests\ to tests/src/ via autoload-dev and move the
  handler test there as a namespaced class; the strict CI autoload
  check now enforces that test names match their paths. Add a "src"
  PHPUnit testsuite for running these tests in isolation.
- Add src to both PHPStan configurations.
- Document the migration policy in AGENTS.md: what belongs in src/,
  the one-type-per-file and namespace rules, the test location and
  naming convention, and the entry-point bootstrap requirements.
- Add src to the PHPUnit coverage source filter and PHPDocumentor scan
  paths.

Also update `commitlint.config.cjs` as the `footer-leading-blank` check
is broken.

Related: #1501
Co-authored-by: barakiva <barakiva1@gmail.com>
Assisted-by: Claude:claude-fable-5
@JohnVillalovos
JohnVillalovos merged commit 125c9ea into develop Jul 26, 2026
17 checks passed
@JohnVillalovos
JohnVillalovos deleted the jlvillal/psr4 branch July 26, 2026 02:36
@barakiva

Copy link
Copy Markdown
Contributor

@JohnVillalovos thank you for the help!

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.

3 participants