[php-src] Issue #10155: GMP Objects should disallow invoking constructor like other opaque objects
| From: | Girgias | Date: | Thu, 22 Dec 2022 17:27:57 +0000 |
| Subject: | [php-src] Issue #10155: GMP Objects should disallow invoking constructor like other opaque objects | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243226@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10155
Author: Girgias
### Description
The following code:
```php
<?php
var_dump(new GMP(6));
```
Resulted in this output:
```
object(GMP)#5 (1) {
["num"]=>
string(1) "0"
}
```
But I expected this output instead:
```
Fatal error: Uncaught Error: Cannot directly construct GMP, use gmp_init() instead in /in/SdNJu:2
Stack trace:
#0 {main}
thrown in /in/SdNJu on line 2
```
Which is in line with the behaviour of other opaque objects such as `
XMLParser`: https://3v4l.org/SdNJu
And this just made me spend 30 minutes trying to understand why I was not getting the correct
results...
### PHP Version
PHP 5.6-8.2
### Operating System
_No response_