Skip to content

FacebookAds\PII_DATA_TYPE is unautoloadable — PSR-4 violation in 1.3.1 breaks php-business-sdk 25.0.2 #36

Description

@bretterer

Summary

The FacebookAds\PII_DATA_TYPE class ships in php/capi-param-builder/src/model/Constants.php, but the package's PSR-4 autoload maps FacebookAds\php/capi-param-builder/src/. Under PSR-4 the class must live in php/capi-param-builder/src/PII_DATA_TYPE.php. Because the filename doesn't match the class name, Composer cannot autoload it (optimized or not), and class_exists('FacebookAds\PII_DATA_TYPE') returns false.

This breaks facebook/php-business-sdk 25.0.2, which added capi-param-builder-php ^1.3.1 as a dependency and calls FacebookAds\PII_DATA_TYPE::EMAIL (etc.) inside UserData::normalize(). Any app sending a server-side Conversions API event fatals.

Environment

  • facebook/capi-param-builder-php: 1.3.1 (latest)
  • facebook/php-business-sdk: 25.0.2
  • Composer: 2.9.5, PHP: 8.4

Reproduction

composer require facebook/capi-param-builder-php:1.3.1
php -r "require 'vendor/autoload.php'; var_dump(class_exists('FacebookAds\\PII_DATA_TYPE'));"
# bool(false)   <- expected: true

Downstream, via the SDK:

composer require facebook/php-business-sdk:25.0.2
php -r "require 'vendor/autoload.php'; (new FacebookAds\Object\ServerSide\UserData())->setEmails(['a@b.com'])->normalize();"
# PHP Fatal error: Uncaught Error: Class "FacebookAds\PII_DATA_TYPE" not found

Expected

FacebookAds\PII_DATA_TYPE autoloads, class_exists(...) returns true, and UserData::normalize() succeeds.

Actual

The class never autoloads; the SDK fatals.

Root cause

PSR-4 requires the file path to match the fully-qualified class name. class FacebookAds\PII_DATA_TYPE sits in src/model/Constants.php instead of src/PII_DATA_TYPE.php. Other FacebookAds\-namespaced classes in src/util/ and src/piiUtil/ appear to have the same mismatch and are likely also unautoloadable.

Suggested fixes (any one)

  1. Move PII_DATA_TYPE into src/PII_DATA_TYPE.php (one class per PSR-4-correct file), and do the same for the other subdirectory classes.

  2. Add a classmap autoload entry alongside the PSR-4 entry so Composer maps the subdirectory classes regardless of filename:

    "autoload": {
      "psr-4": { "FacebookAds\\": "php/capi-param-builder/src/" },
      "classmap": ["php/capi-param-builder/src/model/", "php/capi-param-builder/src/util/", "php/capi-param-builder/src/piiUtil/"]
    }

Running composer dump-autoload --strict-psr on the package surfaces the violation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions