Skip to content

Cassandra\Float "is a reserved word" #3

@downsider

Description

@downsider

I found an issue when using the Cassandra\Float class as a return type hint in PHP 8.0.9

Using the class name directly causes the following error:

PHP Fatal error:  Cannot use Cassandra\Float as Float because 'Float' is a special class name

Even when aliased, the compiler still throws an error, albeit a different one:

PHP Fatal error:  Cannot use 'Cassandra\Float' as class name as it is reserved

Example code

use Cassandra\Float as CassandraFloat;

class Test {

    public function getFloat(float $float): CassandraFloat
    {
        return new CassandraFloat($float);
    }

}

Removing the return type hint solves the problem, but shouldn't be required.

To be honest, this feels like it might be a PHP bug rather than an issue with the Cassandra extension, but it may be something that should be addressed here anyway; "float" is a reserved word and the class name may need to be changed to avoid issues in the future

As far as I can tell the only other "type" that might be an issue is Cassandra\Numeric, but that is only "soft" reserved

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomersquestionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions