HomePhabricator

Fix PhutilTypeSpec's regex handling for PHP 8

Description

Fix PhutilTypeSpec's regex handling for PHP 8

Summary:
In previous versions, passing the wrong type to preg_match would give a
warning that could be suppressed by @ and caught by set_error_handler,
but as of PHP 8 this raises a TypeError and so remains uncaught. Thus
check up-front whether the provided value is a string.

This fixes linting arc itself when run with PHP 8, as includes and
excludes use "optional regex | list<regex>", so would previously try to
pass an array to preg_match for the first alternative and die.

Test Plan: Ran arc lint

Reviewers: epriestley, Blessed Reviewers

Reviewed By: epriestley, Blessed Reviewers

Subscribers: Korvin

Maniphest Tasks: T13588

Differential Revision: https://secure.phabricator.com/D21499

Details

Provenance
jrtc27Authored on Jan 11 2021, 4:04 AM
industryPushed on Jan 11 2021, 4:04 AM
Reviewer
Blessed Reviewers
Differential Revision
D21499: Fix PhutilTypeSpec's regex handling for PHP 8
Parents
rARC446dcf1ccdcd: Fix error handler on PHP 8
Branches
Unknown
Tags
Unknown
Tasks
T13588: PHP 8 Compatibility
Build Status
Buildable 24989
Build 34479: Run Core Tests