From 7777ebc287094abfb0d30520b981395477ac1f3f Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 19 Nov 2024 15:58:23 -0500 Subject: [PATCH] phan-plugins: Work around microsoft/tolerant-php-parser not being 8.4-safe yet --- .../phan-plugins/changelog/add-ci-php-8.4 | 5 +++++ .../tests/php/IntegrationTest.php | 20 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 projects/packages/phan-plugins/changelog/add-ci-php-8.4 diff --git a/projects/packages/phan-plugins/changelog/add-ci-php-8.4 b/projects/packages/phan-plugins/changelog/add-ci-php-8.4 new file mode 100644 index 0000000000000..ddbb5f3179535 --- /dev/null +++ b/projects/packages/phan-plugins/changelog/add-ci-php-8.4 @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Work around microsoft/tolerant-php-parser not being 8.4-safe yet in test + + diff --git a/projects/packages/phan-plugins/tests/php/IntegrationTest.php b/projects/packages/phan-plugins/tests/php/IntegrationTest.php index 95cad2e73a2a6..86f4736023e93 100644 --- a/projects/packages/phan-plugins/tests/php/IntegrationTest.php +++ b/projects/packages/phan-plugins/tests/php/IntegrationTest.php @@ -101,12 +101,22 @@ private function runPhan( $dir, $usePolyfill = false, $analyzeTwice = false ) { $printer = new CapturingJSONPrinter(); Phan::setPrinter( $printer ); - Phan::analyzeFileList( - $this->codeBase, - static function () use ( $cli ) { - return $cli->getFileList(); + $old = error_reporting(); + try { + if ( $usePolyfill ) { + // microsoft/tolerant-php-parser raises PHP 8.4 deprecation warnings. + // @todo If it gets updated at some point, hopefully this can be removed. + error_reporting( $old & ~E_DEPRECATED ); } - ); + Phan::analyzeFileList( + $this->codeBase, + static function () use ( $cli ) { + return $cli->getFileList(); + } + ); + } finally { + error_reporting( $old ); + } $expectFile = $this->chooseFile( "$dir/expect.json", $usePolyfill, $analyzeTwice ); $expect = json_decode( file_get_contents( $expectFile ), true );