php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67019 Class variable initialization scalar expressions
Submitted: 2014-04-04 08:16 UTC Modified: 2014-04-04 13:54 UTC
From: flip101 at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *General Issues
PHP Version: 5.6.0alpha3 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: flip101 at gmail dot com
New email:
PHP Version: OS:

 

 [2014-04-04 08:16 UTC] flip101 at gmail dot com
Description:
------------
Since the value for class initialization are of a fixed nature, the method for constant scalar expressions could be used as well. As proposed here: https://wiki.php.net/rfc/const_scalar_exprs

Test script:
---------------
<?php
class TestClass {
  protected $testValue = 2 * 2;
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-04 13:54 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-04-04 13:54 UTC] nikic@php.net
Not sure what the request here is. Your code sample already works. The const_scalar_exprs RFC applies to anything that uses a static scalar intializer, which includes properties.
 [2014-04-04 15:28 UTC] flip101 at gmail dot com
Oh sorry you are right, i didn't look closely to the RFC. Also i was told in ##php it was "of course not possible". Excuse the confusion.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 14:01:31 2025 UTC