[PHP-DOC] Bug #16479 Updated: var declaration in class has no meaning?
ID: 16479 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Documentation problem Operating System: Win98SE PHP Version: 4.0.6 New Comment: So is it (and will it continue to be) valid to use/create class variables not explicitly declared with var? Currently the following produce the excact same results except that the varaible 'a' will not be returned by get_class_vars. class foo { var $a; function foo() { $this->a = "test"; } }; class foo2 { function foo2() { $this->a = "test"; } }; Previous Comments: [2002-04-08 15:49:12] [EMAIL PROTECTED] Yeah, I guess I asked for it. But then I'd have to argue that the var declaration itself is against the nature of PHP! Firstly because it's a declaration, and secondly because it's useless. Anyway, I understand that there will be major changes in OOP in ZendEngine2, so this is probably not relevant anymore. BTW, when is this ZE2 scheduled to launch? Will it be already in 4.2.0 which is now in RC stage? [2002-04-08 01:29:14] [EMAIL PROTECTED] Well, you have get_class_vars() which can retrieve all the default properties (i.e. the ones declared with 'var $foo'). And your last suggestions is against the nature of PHP. You just do not have to declare variables to use it. Making this a doc problem though I'm not quite sure; letting the doc team decide. [2002-04-07 18:31:55] [EMAIL PROTECTED] I am not sure whether this is a bug, a feature, or lack of a feature. Perhaps this should be marked a "Feature Request" then... Anyway, here goes: the var declaration in a class seems to have no meaning whatsoever, except perhaps for documentation purposes. PHP allows me to assign to class variables that weren't declared without even a warning at the highest warning reporting level. That's actually not very surprising since PHP doesn't otherwise have declarations of variables, but what is then the meaning of var in classes? I suggest that PHP should at least warn about class variables that weren't declared. -- Edit this bug report at http://bugs.php.net/?id=16479&edit=1
[PHP-DOC] Bug #16479 Updated: var declaration in class has no meaning?
ID: 16479 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open Bug Type: Documentation problem Operating System: Win98SE PHP Version: 4.0.6 New Comment: Yeah, I guess I asked for it. But then I'd have to argue that the var declaration itself is against the nature of PHP! Firstly because it's a declaration, and secondly because it's useless. Anyway, I understand that there will be major changes in OOP in ZendEngine2, so this is probably not relevant anymore. BTW, when is this ZE2 scheduled to launch? Will it be already in 4.2.0 which is now in RC stage? Previous Comments: [2002-04-08 01:29:14] [EMAIL PROTECTED] Well, you have get_class_vars() which can retrieve all the default properties (i.e. the ones declared with 'var $foo'). And your last suggestions is against the nature of PHP. You just do not have to declare variables to use it. Making this a doc problem though I'm not quite sure; letting the doc team decide. [2002-04-07 18:31:55] [EMAIL PROTECTED] I am not sure whether this is a bug, a feature, or lack of a feature. Perhaps this should be marked a "Feature Request" then... Anyway, here goes: the var declaration in a class seems to have no meaning whatsoever, except perhaps for documentation purposes. PHP allows me to assign to class variables that weren't declared without even a warning at the highest warning reporting level. That's actually not very surprising since PHP doesn't otherwise have declarations of variables, but what is then the meaning of var in classes? I suggest that PHP should at least warn about class variables that weren't declared. -- Edit this bug report at http://bugs.php.net/?id=16479&edit=1
[PHP-DOC] Bug #16479 Updated: var declaration in class has no meaning?
ID: 16479 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Open -Bug Type: Class/Object related +Bug Type: Documentation problem Operating System: Win98SE PHP Version: 4.0.6 New Comment: Well, you have get_class_vars() which can retrieve all the default properties (i.e. the ones declared with 'var $foo'). And your last suggestions is against the nature of PHP. You just do not have to declare variables to use it. Making this a doc problem though I'm not quite sure; letting the doc team decide. Previous Comments: [2002-04-07 18:31:55] [EMAIL PROTECTED] I am not sure whether this is a bug, a feature, or lack of a feature. Perhaps this should be marked a "Feature Request" then... Anyway, here goes: the var declaration in a class seems to have no meaning whatsoever, except perhaps for documentation purposes. PHP allows me to assign to class variables that weren't declared without even a warning at the highest warning reporting level. That's actually not very surprising since PHP doesn't otherwise have declarations of variables, but what is then the meaning of var in classes? I suggest that PHP should at least warn about class variables that weren't declared. -- Edit this bug report at http://bugs.php.net/?id=16479&edit=1