Skip to content

Remove single-use undeclared composer/pcre dependency with native preg_match - #91

Merged
glaubinix merged 1 commit into
masterfrom
drop-composer-pcre-dependency
May 8, 2026
Merged

Remove single-use undeclared composer/pcre dependency with native preg_match#91
glaubinix merged 1 commit into
masterfrom
drop-composer-pcre-dependency

Conversation

@jdworschak

Copy link
Copy Markdown
Contributor

The single use of Composer\Pcre\Preg::isMatch in AbstractApi::parseLinkHeader relied on composer/pcre being available transitively via composer/xdebug-handler (a dev dependency of friendsofphp/php-cs-fixer). Downstream projects that install private-packagist/api-client without that chain hit a Class "Composer\Pcre\Preg" not found fatal at runtime when paginating any list endpoint.

This switches the one call site to native preg_match and removes the use import.
Trade-off vs. declaring composer/pcre as a runtime require is that Preg::isMatch throws on PCRE errors while preg_match(...) === 1 returns false on those errors and silently skips the if-block. For this simple regex against a server-generated Link header I personally feel the dependency is unwarranted.

@jdworschak
jdworschak requested a review from a team May 8, 2026 11:16
@jdworschak jdworschak self-assigned this May 8, 2026

@stevenrombauts stevenrombauts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@glaubinix
glaubinix merged commit b658e61 into master May 8, 2026
8 checks passed
@glaubinix
glaubinix deleted the drop-composer-pcre-dependency branch May 8, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants