[php-src] Issue #8103: __invoke magic method doesn't work
| From: | linescrow | Date: | Tue, 15 Feb 2022 16:42:49 +0000 |
| Subject: | [php-src] Issue #8103: __invoke magic method doesn't work | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239817@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8103
Author: linescrow
### Description
The following code:
```php
<?php
class UserName
{
public readonly string $value;
public function __construct(string $value)
{
$this->value = $value;
}
public function __invoke()
{
return $this->value;
}
}
class User
{
public UserName $name;
public function __construct(string $name)
{
$this->name = new UserName($name);
}
}
// this is run
$name = new UserName('sample');
var_dump( $name() );
// this is not run...
$user = new User('hoge');
var_dump( $user->name() );
```
Resulted in this output:
```
```
But I expected this output instead:
```
```
### PHP Version
PHP 8.1.2
### Operating System
Ubuntu 20.04