Bug #55043 [Opn->Bgs]: not throwing error on wrong syntax
| From: | felipe@php.net | Date: | Sun, 12 Jun 2011 15:59:46 +0000 |
| Subject: | Bug #55043 [Opn->Bgs]: not throwing error on wrong syntax | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161346@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=55043&edit=1
ID: 55043
Updated by: felipe@php.net
Reported by: khurramijazm at gmail dot com
Summary: not throwing error on wrong syntax
-Status: Open
+Status: Bogus
Type: Bug
Package: Class/Object related
Operating System: windows7
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[2011-06-12 17:36:52] khurramijazm at gmail dot com
After researching i narrow down the problem to that in PHP you can declare a reserved keyword as a
goto label: because in the above sent bug report php must have thought of it as an goto label i.e.
self: $instance = ....
i hope it helps
------------------------------------------------------------------------
[2011-06-12 17:16:34] khurramijazm at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/internals2.objects
---
class MyPDO extends PDO
{
private static $instance = null;
function __construct(){
try{
parent::__construct("mysql:host=localhost;port=3306;dbname=blog",
"root", "");
parent::setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}catch(PDOException $e){
echo 'Exception in constructor'.print_r($e->trace(),true);
}
}
static public function getDB(){
if(self::$instance == null){
self:$instance = new MyPDO();
}
return self::$instance;
}
function selectAll($sql){
$stmt = self::$instance->prepare($sql);
$stmt->execute(array(":cat_id"=>1));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
Expected result:
----------------
class MyPDO extends PDO
{
private static $instance = null;
function __construct(){
try{
parent::__construct("mysql:host=localhost;port=3306;dbname=blog",
"root", "");
parent::setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
}catch(PDOException $e){
echo 'Exception in constructor'.print_r($e->trace(),true);
}
}
static public function getDB(){
if(self::$instance == null){
self::$instance = new MyPDO();** ERROR SHOULD BE REPORTED HERE
WHEN USING self:$instance , it SHOULD BE THE SCOPE RESOLUTION OPERATOR WITH DOUBLE COLON ::...Sorry
if it is not a bug but some thing i don't have knowledge of..
}
return self::$instance;
}
function selectAll($sql){
$stmt = self::$instance->prepare($sql);
$stmt->execute(array(":cat_id"=>1));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=55043&edit=1