View Issue Details

IDProjectCategoryView StatusLast Update
0002041XdebugUncategorizedpublic2021-12-01 15:39
ReporterCarnage Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformall 
Product Version3.0.4 
Fixed in Version3.1.2 
Summary0002041: __debugInfo is not used for var_dump output
Description

We have a class containing a __debugInfo method which exists to remove sensitive information from the output of var_dump, the relevant parts are in the steps to reproduce. The test passes with xdebug disabled, but fails with it enabled.

Steps To Reproduce

final class X
{
private string $secretValue;

public function __construct(string $secretValue)
{
    $this->secretValue = $secretValue;
}

/**
 * @return array<mixed>
 */
public function __debugInfo(): array
{
    $properties = get_object_vars($this);
    $properties['secretValue'] = empty($properties['secretValue']) ? '' : '********';
    return $properties;
}

}

class XTest extends TestCase
{
public function testVarDumpDoesntRevealSecret()
{
$secretValue = 'supersecret';
$sut = new X(
$secretValue,
);

    ob_start();
    var_dump($sut);
    $output = ob_get_clean();

    self::assertStringNotContainsString($secretValue, $output);
    self::assertStringContainsString('********', $output);
}

}

Additional Information

$ php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.24, Copyright (c), by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

$ bin/phpunit
PHPUnit 9.5.7 by Sebastian Bergmann and contributors.

TagsNo tags attached.
Operating System
PHP Version7.4.20-7.4.29

Activities

Issue History

Date Modified Username Field Change
2021-10-27 17:58 Carnage New Issue
2021-10-28 18:06 derick Assigned To => derick
2021-10-28 18:06 derick Status new => confirmed
2021-10-28 18:06 derick Note Added: 0006148
2021-10-29 13:15 derick Status confirmed => closed
2021-10-29 13:15 derick Resolution open => fixed
2021-10-29 13:15 derick Fixed in Version => 3.1dev
2021-12-01 15:39 derick Fixed in Version 3.1dev => 3.1.2