Replace Psalm with PHPStan and upgrade dependencies#8
Merged
Conversation
- Bump facebook/php-business-sdk from ^22.0 to ^25.0 (Graph API v25.0) - Replace setono/code-quality-pack with its individual dev tools pinned to the latest versions that still support PHP 8.1 (PHPStan ^2.1, PHPUnit ^10.5, Infection ^0.29, ECS via sylius-labs/coding-standard, etc.) - Swap Psalm for PHPStan (level max): drop psalm.xml, add phpstan.dist.neon, update the analyse script and remove @psalm-suppress annotations - Fix the resulting level-max findings: remove dead responseFactory from Client, add precise iterable/array types, narrow mixed in ErrorResponse, refactor getPayload() so its array<string, mixed> contract is provable - Make implicitly-nullable params explicit (8.4 deprecation) and migrate phpunit.xml.dist to the PHPUnit 10 schema - Add tests (25 -> 39): Client error path + test_event_code, ErrorResponse parsing, Content payload, FbqGenerator branches, Event::isCustom, Fbc immutable creation time - Add PHP 8.4 to the CI matrices
- Restore Client::setResponseFactory() (removing it broke BC); make the companion getResponseFactory() public so the response factory is used and PHPStan is happy - Type TestLogger::log()'s $context (psr/log 1.x has no value-typed $context, which tripped missingType.iterableValue on the lowest matrix) - Build LiveClientTest::getTestValues() as an explicit array shape via an env() helper so PHPStan 2.1.x can prove the declared return type
loevgaard
commented
Jun 15, 2026
loevgaard
commented
Jun 15, 2026
loevgaard
commented
Jun 15, 2026
- Client: drop the public getResponseFactory() getter; keep setResponseFactory() as a @deprecated no-op retained only for BC (the client never creates responses, so the response factory was always unused) - Parameters: document why getPayload() iterates the mapping (to keep the precise array<string, mixed> return type that FbqGenerator::generateInit() consumes)
The static-analysis CI matrix runs on PHP 8.1-8.4, so each version is analysed natively; the explicit phpVersion pin is redundant.
Pins the exact getPayload() output for a fully-populated object graph (nested Parameters, lists, scalars, normalization, hashing, value objects, custom properties, empty-value filtering). Verified to pass against both the pre-refactor (master) and refactored getPayload() implementations, proving the refactor is behaviour-preserving.
Resolves the TODO in ErrorResponse: besides message/type/code/fbtrace_id, Meta may also return error_subcode, is_transient and the user-facing error_user_title / error_user_msg fields. These optional fields are now parsed when present, and ClientException surfaces the subcode and the user-facing explanation in its message.
Rewrite with runnable examples covering the common cases (server events, multiple pixels, test events, error handling, browser-side fbq() generation with deduplication, custom events, fbc/fbp, custom HTTP client, logging, extending events) and document the automatic normalization/hashing behaviour. Also fixes the missing Client import in the original usage example.
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
Modernizes the dev toolchain and bumps the Meta SDK while keeping the library's
php: >=8.1requirement intact.facebook/php-business-sdk^22.0→^25.0(Graph API endpoint movesv22.0→v25.0).setono/code-quality-pack's current major requires PHP 8.2, so instead of depending on the meta-package its tools are listed directly inrequire-dev, each pinned to the latest version that still supports PHP 8.1 (PHPStan^2.1, PHPUnit^10.5, Infection^0.29, ECS viasylius-labs/coding-standard ^4.5, Rector, composer-normalize, composer-dependency-analyser, prophecy).level: max). Deletespsalm.xml, addsphpstan.dist.neon(analysed against PHP 8.1), updates theanalysescript, and removes the now-dead@psalm-suppressannotations.responseFactoryfromClient, added precise iterable/array types, narrowedmixedaccess inErrorResponse, and refactoredParameters::getPayload()so itsarray<string, mixed>contract is provable (sharedfilterEmptyValues()helper).Content,Pixel,Parameters) and migratedphpunit.xml.distto the PHPUnit 10 schema.Tests
25 → 39 tests; mutation MSI ~72% → ~78%. New coverage: Client error path +
test_event_code,ErrorResponseparsing,Contentpayload,FbqGeneratorinit/trackCustombranches,Event::isCustom,Fbc::withCreationTimeimmutability.Verified green on PHP 8.1 and 8.4: PHPStan, ECS, composer-dependency-analyser, composer validate/normalize, PHPUnit, Infection.
--prefer-lowestresolves on 8.1.🤖 Generated with Claude Code