HomeSealhub

Fix some PHP 8.1 errors

Description

Fix some PHP 8.1 errors

Summary:
In some string functions PHP 8.1 no longer accepts null as parameter #1. This change fixes that by changing null to empty string right before the function call.

The errors I've encountered are:

[2022-01-23 23:09:58] EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arc-unit-mocha(head=master, ref.master=259af28a9429), arcanist(head=master, ref.master=b50a646a3f49), pinterest-linters(head=master, ref.master=b06e8ff831bd)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/unit/renderer/ArcanistUnitConsoleRenderer.php:15]
  #1 ArcanistUnitConsoleRenderer::renderUnitResult(ArcanistUnitTestResult) called at [<arcanist>/src/workflow/ArcanistUnitWorkflow.php:189]
  #2 ArcanistUnitWorkflow::run() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:1230]
  #3 ArcanistDiffWorkflow::runUnit() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:1132]
  #4 ArcanistDiffWorkflow::runLintUnit() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:365]
  #5 ArcanistDiffWorkflow::run() called at [<arcanist>/scripts/arcanist.php:419]
<<< [1] (+63,955) <exec> 63,955,923 us

[2022-01-23 23:00:57] EXCEPTION: (RuntimeException) substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arc-unit-mocha(head=master, ref.master=259af28a9429), arcanist(head=master, ref.master=b50a646a3f49), pinterest-linters(head=master, ref.master=b06e8ff831bd)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer)
  #1 substr_count(NULL, string) called at [<arcanist>/src/lint/renderer/ArcanistConsoleLintRenderer.php:122]
  #2 ArcanistConsoleLintRenderer::renderContext(ArcanistLintMessage, string, array) called at [<arcanist>/src/lint/renderer/ArcanistConsoleLintRenderer.php:91]
  #3 ArcanistConsoleLintRenderer::renderLintResult(ArcanistLintResult) called at [<arcanist>/src/workflow/ArcanistLintWorkflow.php:296]
  #4 ArcanistLintWorkflow::run() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:1169]
  #5 ArcanistDiffWorkflow::runLint() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:1131]
  #6 ArcanistDiffWorkflow::runLintUnit() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:365]
  #7 ArcanistDiffWorkflow::run() called at [<arcanist>/scripts/arcanist.php:419]

Not sure if that's the best approach, but that worked in my case

Test Plan: Run arc diff on a repo with linters and unit tests on a machine with php8.1 installed

Reviewers: #blessed_reviewers!

Subscribers: epriestley

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

Details

Provenance
kuba-orlikAuthored on Jan 24 2022, 10:08
kuba-orlikPushed on Jan 24 2022, 10:17
Parents
R118:b50a646a3f49: Provide additional Arcanist PHP 8.1 fixes
Branches
Unknown
Tags
Unknown

Event Timeline