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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 01:01:30 2024 UTC