1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Add polyfill for Stringable interface

This commit is contained in:
Matt Brown 2020-10-28 00:55:53 -04:00 committed by Daniil Gentili
parent 951c3715f7
commit 97dc34bed3
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 16 additions and 0 deletions

View File

@ -1741,6 +1741,16 @@ class Config
$core_generic_files[] = $ext_ds_path;
}
if (!\interface_exists('Stringable', false) && $codebase->php_major_version >= 8) {
$stringable_path = dirname(__DIR__, 2) . '/stubs/Stringable.php';
if (!file_exists($stringable_path)) {
throw new \UnexpectedValueException('Cannot locate core generic classes');
}
$core_generic_files[] = $stringable_path;
}
$stub_files = array_merge($core_generic_files, $this->stub_files);
$phpstorm_meta_path = $this->base_dir . DIRECTORY_SEPARATOR . '.phpstorm.meta.php';

6
stubs/Stringable.php Normal file
View File

@ -0,0 +1,6 @@
<?php
interface Stringable
{
function __toString() : string;
}