get_debug_type() does the same thing but better (spelling type names in the same way as in type declarations, and including names of object classes and resource types). It was added in PHP 8, but the symfony/polyfill-php80 package provides it while we still support 7.4. Also remove uses of get_class() and get_resource_type() where the new method already provides the same information. For reference: https://www.php.net/manual/en/function.get-debug-type.php https://www.php.net/manual/en/function.gettype.php In this commit I'm only changing code where it looks like the result is used only for some king of debug, log, or test output. This probably won't break anything important, but I'm not sure whether anything might depend on the exact values. Change-Id: I7c1f0a8f669228643e86f8e511c0e26a2edb2948
38 lines
699 B
PHP
38 lines
699 B
PHP
<?php
|
|
|
|
namespace Wikimedia\Tests\DebugInfo;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use stdClass;
|
|
use Wikimedia\DebugInfo\Placeholder;
|
|
|
|
/**
|
|
* @covers \Wikimedia\DebugInfo\Placeholder
|
|
*/
|
|
class PlaceholderTest extends TestCase {
|
|
public static function provideConstruct() {
|
|
return [
|
|
[
|
|
new stdClass,
|
|
'/^stdClass#[0-9]*$/'
|
|
],
|
|
[
|
|
1,
|
|
'/^int$/'
|
|
],
|
|
[
|
|
'test',
|
|
'/^string$/',
|
|
]
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideConstruct
|
|
*/
|
|
public function testConstruct( $input, $expected ) {
|
|
$placeholder = new Placeholder( $input );
|
|
$this->assertInstanceOf( Placeholder::class, $placeholder );
|
|
$this->assertMatchesRegularExpression( $expected, $placeholder->desc );
|
|
}
|
|
}
|