Req #49281 [Opn->Csd]: Using . operator whilst assigning to a property gives misleading error

From: Date: Sun, 12 Oct 2014 14:41:21 +0000
Subject: Req #49281 [Opn->Csd]: Using . operator whilst assigning to a property gives misleading error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188032@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49281&edit=1 ID: 49281 Updated by: nikic@php.net Reported by: RQuadling at GMail dot com Summary: Using . operator whilst assigning to a property gives misleading error -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: 5.3SVN-2009-08-17 (snap) -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Supported in PHP 5.6. Previous Comments: ------------------------------------------------------------------------ [2009-08-17 14:18:49] RQuadling at GMail dot com Description: ------------ Changeset http://svn.php.net/viewvc?view=revision&revision=286600. The Config.php class is using . to create a property. The error that is generated is appropriate, but I feel it is misleading. The error is different under slightly different circumstances. The 2 scripts below show what I mean. Having said that, the elements being concatenated are constant, so I believe there is some argument that these are NOT dynamic as say a function call would be. Reproduce code: --------------- ===== Test1.php ===== <?php class Config { public $string = __DIR__ . 'something'; } ?> ===== Test2.php ===== <?php class Config { public $array = array(__DIR__ . 'something'); } Expected result: ---------------- An error along the lines that you cannot assign dynamic values to properties during class creation. Actual result: -------------- ===== Test1.php ===== Parse error: parse error, expecting ','' or ';'' in Z:\Test1.php on line 3 ===== Test2.php ===== Parse error: parse error, expecting `')'' in Z:\Test2.php on line 3 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49281&edit=1

« previous php.bugs (#188032) next »