refactor(autoload): add initial PSR-4 support - #1610
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 forLibreBooking\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.phpand a dedicated PHPUnitsrctestsuite; includesrc/in PHPStan configs; document migration rules inAGENTS.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. |
JohnVillalovos
force-pushed
the
jlvillal/psr4
branch
2 times, most recently
from
July 26, 2026 02:28
3423852 to
4cb58ac
Compare
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
force-pushed
the
jlvillal/psr4
branch
from
July 26, 2026 02:30
4cb58ac to
d7187b0
Compare
Closed
Contributor
|
@JohnVillalovos thank you for the help! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
composer dump-autoload --optimize --strict-psr.Related: #1501
Assisted-by: Claude:claude-fable-5