[php-src] Issue #7778: Enum could not be converted to string with \array_intersect
| From: | benelori | Date: | Wed, 15 Dec 2021 07:34:17 +0000 |
| Subject: | [php-src] Issue #7778: Enum could not be converted to string with \array_intersect | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238423@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7778
Author: benelori
### Description
The following code:
```php
<?php
class EnumTest extends Unit
{
public function testArrayIntersect(): void
{
$array1 = [TestEnum::TEST];
$array2 = [TestEnum::TEST];
$actual = \array_intersect($array1, $array2);
self::assertCount(1, $actual);
}
}
enum TestEnum {
case TEST;
}
```
Resulted in this output:
```
Object of class TestEnum could not be converted to string
```
But I expected this output instead:
```
I expected the test to pass and internally \array_intersect to be able to work with enums. The same
goes for \array_diff as well, so most probably other array functions, too
```
### PHP Version
PHP 8.1.0
### Operating System
php:8.1-fpm-buster