php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49281 Using . operator whilst assigning to a property gives misleading error
Submitted: 2009-08-17 14:18 UTC Modified: 2014-10-12 14:41 UTC
From: RQuadling at GMail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3SVN-2009-08-17 (snap) OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: RQuadling at GMail dot com
New email:
PHP Version: OS:

 

 [2009-08-17 14:18 UTC] 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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 13:13 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem -Operating System: Irrelevant +Operating System: *
 [2010-12-29 13:13 UTC] jani@php.net
-Summary: Using . operator whilst assigning to a property gives misleading error. +Summary: Using . operator whilst assigning to a property gives misleading error
 [2014-10-12 14:41 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 14:41 UTC] nikic@php.net
Supported in PHP 5.6.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 11:01:32 2025 UTC