1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-12-28 08:20:56 +01:00

Fix strlen() being passed a null in ArcanistUnitConsoleRenderer.php

Summary:
Fix the following error in ArcanistUnitConsoleRenderer.php under PHP 8.1:

```
strlen(): Passing null to parameter #1 ($string) of type string is deprecated
```

Stack trace:

```
EXCEPTION: (RuntimeException) strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [<arcanist>/src/error/PhutilErrorHandler.php:261]
arcanist(head=master, ref.master=97e163187418, custom=4)
  #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:190]
  #2 ArcanistUnitWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]
```

Ref T15187

Test Plan: arc unit

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15187

Differential Revision: https://we.phorge.it/D25300
This commit is contained in:
Steve Campbell 2023-06-19 14:55:33 +01:00
parent 97e1631874
commit 677e117b97
2 changed files with 14 additions and 1 deletions

View file

@ -40,4 +40,17 @@ final class ArcanistUnitTestResultTestCase extends PhutilTestCase {
}
}
public function testRenderer() {
$result = new ArcanistUnitTestResult();
$result->setName('RendererTest');
$result->setResult('pass');
$result->setDuration(0.001);
$result->setUserData('');
$renderer = new ArcanistUnitConsoleRenderer();
$output = $renderer->renderUnitResult($result);
$test_dscr = 'Renderer copes with null namespace';
$this->assertTrue((bool)preg_match('/PASS/', $output), $test_dscr);
}
}

View file

@ -12,7 +12,7 @@ final class ArcanistUnitConsoleRenderer extends ArcanistUnitRenderer {
$test_name = $result->getName();
$test_namespace = $result->getNamespace();
if (strlen($test_namespace)) {
if (phutil_nonempty_string($test_namespace)) {
$test_name = $test_namespace.'::'.$test_name;
}