Skip to content

GMP Objects should disallow invoking constructor like other opaque objects #10155

Closed
@Girgias

Description

@Girgias

Description

The following code:

<?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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions