php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46476 initial property value can't be different than primitive type?!!
Submitted: 2008-11-04 08:48 UTC Modified: 2008-11-04 09:06 UTC
From: info at netmosfera dot it Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.0alpha2 OS: irrelevant
Private report: No CVE-ID: None
 [2008-11-04 08:48 UTC] info at netmosfera dot it
Description:
------------
hello
i think there is a logic problem with php's
fields/properties initial values
they can be only int float string boolean or null!

please see the code
thank you

Reproduce code:
---------------
class Config
{
   private static $defaultLanguage = new Lang("en");
   private static $objectsUrl = new Path("my/path/");
   private static $look = new LookAndFeel("default");
}
-------------------
the only way i can set initial static values is
-------------------
class Config
{
   private static $defaultLanguage;
   private static $objectsUrl;
   private static $look;
   public static __unbelievable_static_constructor() //!!!!!!!
   {
      self::$defaultLanguage = new Lang("en");
      self::$objectsUrl = new Path("my/path/");
      self::$look = new LookAndFeel("default");
   }
}
Config::__unbelievable_static_constructor();

Actual result:
--------------
unexpected NEW

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-04 09:06 UTC] tularis@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please check the documentation, this is a known limitation.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC