Add phpcs and phpstan tooling from template-php - #22
Open
aviator-ua wants to merge 4 commits into
Open
Conversation
- Reject invalid uploads with 400 instead of TypeError; use getPathname() instead of getRealPath() (also fixes macOS test failures) - Reject non-POST methods and non-multipart content types with 400 - Check the stream factory lazily when a file is actually wrapped - Fail container compilation when a controller-served multipart endpoint is registered but no PSR-17 stream factory is available - Autoconfigure RequestDataExtractorInterface implementations with the request data extractor tag - Decode "0" request bodies in DefaultRequestDataExtractor - Move psr/http-message to require-dev, suggest nyholm/psr7 - Document multipart endpoints, custom extractors and the constructor BC break in README - Extend test coverage: nested file arrays, invalid uploads, unfilled optional inputs, method/content-type guards, decode failures, compiler pass; clean up temp files in tearDown()
- DefaultRequestDataExtractor: reject scalar/null decoded bodies with a Serializer UnexpectedValueException so they resolve to 400 instead of an uncaught TypeError (500) - MultipartRequestDataExtractor: check the real wire method so method overrides on a wire POST are accepted; match the Content-Type mime case-insensitively and also accept application/x-www-form-urlencoded; reject non-empty form bodies PHP failed to parse (post_max_size) - MultipartStreamFactoryCompilerPass: read endpoints already baked into the registry definition by EndpointProviderCompilerPass instead of instantiating every tagged provider a second time; run the pass at negative priority to guarantee ordering; document the compile-time coverage boundary in the class docblock and README - Tests: cover the new behaviors, rename CUT variables to $target, break multi-call chains one call per line, name the fopen mode literal
- phpcs.xml.dist / phpstan.neon.dist (level 6) adapted to the bundle's root-level source layout; ApiDoc/ excluded from phpstan because the optional nelmio/api-doc-bundle integration classes are not installable together as dev dependencies - require-dev: phpstan/phpstan ^2.1, squizlabs/php_codesniffer ^4.0 - require: symfony/finder - EndpointRouterCompilerPass instantiates Finder but relied on it being pulled in transitively - phpcs: add declare(strict_types=1) to legacy files, constant visibility, phpcbf formatting fixes - phpstan: value-typed array/iterable PHPDocs; drop the unreachable Symfony <=4.4 GetResponseForControllerResultEvent branch and type onKernelView() against ViewEvent; align EndpointLoader::load()/ supports() signatures with the Symfony 6.4 LoaderInterface
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.
Summary
Adopts the phpcs and phpstan setup from
wkda/template-php, adapted to this bundle's root-level source layout, and fixes everything needed to make both tools pass.phpcs.xml.dist— same ruleset as the template: PSR-12,Generic.Arrays.DisallowLongArraySyntax,Generic.PHP.RequireStrictTypes, forbiddenvar_dump/die/phpinfo;fileentries point at the bundle's source directories andTests/.phpstan.neon.dist— level 6.ApiDoc/is not analysed: it integrates with the optionalnelmio/api-doc-bundle, whose two supported major versions (EXSyst-based and OpenApi-annotation-based) cannot be installed together as dev dependencies.phpstan/phpstan ^2.1andsquizlabs/php_codesniffer ^4.0in require-dev;symfony/finderadded to require —EndpointRouterCompilerPassinstantiatesFinderbut the dependency was only ever satisfied transitively.Code fixes
declare(strict_types=1)added to the legacy files missing it; explicitpublicvisibility onEndpointRouterCompilerPassconstants (implicitly public before, no BC change); phpcbf formatting fixes.Response/andRouting/classes.ServiceResponseListener::onKernelView()is now natively typed againstViewEvent: theGetResponseForControllerResultEventbranch was unreachable — that class was removed in Symfony 5, and this bundle requires~6.4|~7.0.EndpointLoader::load()/supports()signatures aligned with the Symfony 6.4LoaderInterface(mixed $resource, ?string $type = null).Testing
vendor/bin/phpcs— cleanvendor/bin/phpstan analyse— no errors at level 6vendor/bin/phpunit— 32 tests, 41 assertions, all passing🤖 Generated with Claude Code