# Local phone-number dependency

Upstream: https://github.com/giggsey/libphonenumber-for-php

Pinned release: **8.13.55**, commit
`6e28b3d53cf96d7f41c83d9b80b6021ecbd00537` (2025-02-14).
Google numbering-plan metadata: **8.13.55**, from the same upstream release.
This is a compatibility pin for Abientot's PHP 8.0 minimum. Its metadata is dated
February 2025; it does not establish present-day allocation or reachability.
Revisit the pin when updating the supported PHP baseline, and explicitly review
upstream metadata updates while PHP 8.0 support remains necessary.

Compatibility rechecked against the official tags API on 2026-10-06:
`8.13.55` is the final published 8.x tag (there is no `8.13.59`). The first 9.x
release (`9.0.0`) and current release (`9.0.40`, Google metadata 2026-09-23)
both declare PHP `^8.1`. This bundle therefore retains the last release whose
upstream PHP contract supports Abientot's declared minimum. New 9.x metadata
has not been mixed into the older parser or backported without upstream support.
Official review sources:
https://api.github.com/repos/giggsey/libphonenumber-for-php/tags?per_page=100
https://github.com/giggsey/libphonenumber-for-php/blob/8.13.55/composer.json
https://github.com/giggsey/libphonenumber-for-php/blob/9.0.0/composer.json
https://github.com/giggsey/libphonenumber-for-php/blob/9.0.40/composer.json

Downloaded official archive:
https://codeload.github.com/giggsey/libphonenumber-for-php/tar.gz/6e28b3d53cf96d7f41c83d9b80b6021ecbd00537

Archive SHA-256:
`32334457e6b5a940fb1f95ac566fce733a9c0c1b53e46ac00bd21f70a5de6810`

Upstream license: Apache-2.0, retained in `LICENSE-APACHE-2.0.txt`.
Apache-2.0 is compatible with GPLv3; Abientot is GPLv3-or-later, so the combined
distribution is GPLv3-or-later. Preserve upstream copyright
headers and this license in both Free and Pro artifacts.

Vendored files: core parser/formatting/metadata classes needed by
`Abientot\Support\Phone`, `PhoneNumberMetadata_*.php` and
`PhoneNumberAlternateFormats_*.php`. Carrier, geocoder, timezone, matching and
as-you-type APIs, short-number metadata, development tooling, tests and the
unneeded `giggsey/locale` dependency are excluded.

Modification: replace `libphonenumber\` namespace references with
`Abientot\ThirdParty\PhoneNumber\Lib\` and namespace declarations accordingly.
`bootstrap.php` registers an autoloader for that prefix only. No Composer global
autoload, remote request, browser metadata or global third-party class is used.

Modification (Abientot 1.0.1, WordPress.org review): each `Lib/data/*.php` metadata
file gets the line `if ( ! defined( 'ABSPATH' ) ) { exit; }` directly after `<?php`,
so it cannot be requested directly.

Modification (Abientot 1.1.2, WordPress.org review): every `Lib/*.php` class file also
gets `if (!defined('ABSPATH')) { exit; }` directly after its namespace line. Exception arguments are escaped
in place instead of carrying `phpcs:ignore` comments. In `Lib/PhoneNumberUtil.php`
the integer error-type constants passed to `NumberParseException` are written as
`(int) NumberParseException::...` (they are already integers), the region code in the
`InvalidArgumentException` message goes through `esc_html()`, and the rethrow in
`parseHelper()` passes `(int) $e->getErrorType()` and `esc_html( $e->getMessage() )`
without chaining the previous exception. In `Lib/MultiFileMetadataSourceImpl.php` the
file name in the `missing metadata` message goes through `esc_html()`. Messages are
internal and never rendered; no parsing logic or data changed.

`utf8.php` is Abientot glue, not an upstream file. It supplies the three namespaced
mbstring functions used by the retained parsing/formatting path. Count and slice
use native mbstring when available, otherwise UTF-8 PCRE; uppercasing is ASCII.
The public adapter normalizes fullwidth, Arabic and Persian digits and rejects
all letters, extensions and control/format characters before upstream parsing,
so the restricted input needs no Unicode case mapping. No extra PHP extension
or global polyfill is required. The vendored library is private to that adapter;
it is not a general-purpose external API.

To reproduce: extract the pinned archive, select the class files present in `Lib/`
plus the two metadata filename families from `src/`, apply the namespace substitution
and the 1.0.1 and 1.1.2 modifications described above, and copy upstream `LICENSE`
without modification.
