Req #70184 [Opn->Wfx]: New reserved words for Scalar Types need to be case sensitive
| From: | bwoebi@php.net | Date: | Sun, 02 Aug 2015 17:20:28 +0000 |
| Subject: | Req #70184 [Opn->Wfx]: New reserved words for Scalar Types need to be case sensitive | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194904@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70184&edit=1
ID: 70184
Updated by: bwoebi@php.net
Reported by: lauren at laurenblack dot co dot uk
Summary: New reserved words for Scalar Types need to be case
sensitive
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: CentOS 7
PHP Version: 7.0.0beta2
Block user comment: N
Private report: N
New Comment:
We know that issue, we already discussed it back then http://markmail.org/message/xooy74qsnvfmf6hd
(and following mails) ⦠but decided that it is the price to pay, sorry.
And the reason why it is case-insensitive is because every keyword is case-insensitive. Changing
that would make it either very inconsistent or breaking other code.
Also, class names in general are case-insensitive too.
Previous Comments:
------------------------------------------------------------------------
[2015-08-02 14:15:35] lauren at laurenblack dot co dot uk
Description:
------------
For PHP 5.3+ we have built a java-like scalar type encapsulation library to provide scalar type
hinting. We designed the library to provide the full gamut of context related manipulations that the
Java type classes do, as well.
Basically, since the reserved words for the scalar types are case insensitive, our enpowered Float,
Int, String, etc. classes aren't allowed, which would mean a full rewrite of our libraries.
int =/= Int
float =/= Float
string =/= String
Test script:
---------------
<?php
class Float
{
public $value;
public function __construct (float $float)
{
$this->value = $float;
}
public function multiply(float $float): Float
{
$val = (float) $this->value * $float;
return new Float($val);
}
}
$val1 = new Float(2.5);
echo $val1->multiply(3.2)->value;
Expected result:
----------------
Output: 8
Actual result:
--------------
Fatal error: Cannot use 'Float' as class name as it is reserved in
/var/www/clients/client1/web1/web/test/test.php on line 2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70184&edit=1