[php-src] Issue #12255: Tracing JIT triggers wrong Array to string conversion in Psalm
| From: | danog | Date: | Wed, 20 Sep 2023 20:41:25 +0000 |
| Subject: | [php-src] Issue #12255: Tracing JIT triggers wrong Array to string conversion in Psalm | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245406@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12255
Author: danog
### Description
Running the following command inside of https://github.com/vimeo/psalm/ @
7428e49b115a2a837aa29cf0fafd0ca902fe2457, only when tracing JIT is enabled with the config specified
in https://github.com/php/php-src/pull/12250,
triggers an Array to string conversion error in a place that makes no sense:
```
PSALM_ALLOW_XDEBUG=1 ./psalm --no-cache --threads=1
```
Result:
```
░░░░░░░Uncaught RuntimeException: PHP Error: Array to string conversion in
/home/daniil/repos/psalm/src/Psalm/Type/Atomic/TGenericObject.php:79 for command with CLI args
"./psalm --no-cache --threads=1" in
/home/daniil/repos/psalm/src/Psalm/Internal/ErrorHandler.php:75
```
The line that triggers the issue:
```
return $this->value . '<' . substr($s, 0, -2) . '>' .
$extra_types;
```
The code around it:
```
public function getKey(bool $include_extra = true): string
{
$s = '';
foreach ($this->type_params as $type_param) {
$s .= $type_param->getKey() . ', ';
}
$extra_types = '';
if ($include_extra && $this->extra_types) {
$extra_types = '&' . implode('&', $this->extra_types);
}
return $this->value . '<' . substr($s, 0, -2) . '>' .
$extra_types;
}
```
### PHP Version
PHP 8.2.10
### Operating System
Arch linux