facebook / facebook/capi-param-builder

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

Open
#36 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
33
Forks
9
PR merge metrics
No merged PRs in 30d

Description

### 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

```bash
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:

```bash
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:

```json
"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.

Contributor guide

Open the contributing guide

Research direction

Start with php/capi-param-builder/src/model/Constants.php and the package Composer autoload configuration, then run composer dump-autoload --strict-psr and the class_exists reproduction. Check the related classes under src/util/ and src/piiUtil/ for the same mismatch. Done means FacebookAds\PII_DATA_TYPE autoloads and the UserData::normalize() reproduction completes without a class-not-found error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.