[PHP-DEV] PHP 4.0 Bug #8476 Updated: Class documentaion request

2001-04-06 Thread danbeck

ID: 8476
Updated by: danbeck
Reported By: [EMAIL PROTECTED]
Old-Status: Analyzed
Status: Closed
Bug Type: Documentation problem
Assigned To: 
Comments:

By default, error reporting is not set to the maximum value in a default PHP 4 
configuration. (Or PHP 3 for that matter.)  Having a warning in the documentation 
about the need to set any class variables to some value before it's first use is 
unecessary for the majority of the people who use PHP and would most likely cause 
confusion instead of clarification.

As far as the statement about declaring class variables in the class intro tutorial on 
zend.com, it is correct.  Declaring a class variable is different than setting it to 
some value before it's first use.




Previous Comments:
---

[2001-03-20 11:20:16] [EMAIL PROTECTED]
jmcastagnetto,

Possibly you do not have your error reporting set to max

Bob

---

[2001-03-17 00:37:23] [EMAIL PROTECTED]
Cannot replicate behavior in RH 6.1 and Solaris 2.6, more info needed.

---

[2000-12-29 09:41:53] [EMAIL PROTECTED]
Hello,

Please modify the documentaion on the Class to reflect the fact that
variables set in the classes must be given a value to prevent  
the "Undefined property:somevar" warning.

var $items;  // Items in our shopping cart

should be :
var $items = "";  // Items in our shopping cart
or
var $items = array();  // Items in our shopping cart
etc.

In fact, it appears to me that the variable declaration inside classes
is just about as imporatant as variable declaration anywhere in php scripts.
You either declare them or you don't, and to a large degree it doesn't
really affect your scripts, other than the warnings.

Furthermore , without $items given an initial value, it still has to be
checked inside the function using it to prevent the warnings, for example:

!empty($this-items) ? $this-items[] .= $num : $this-items[] = $num; 

So I don't see any "fatal error" causing reason to declare vars/attributes
outside of functions/methods in Classes.

The only reason I do see for setting vars outside of functions/methods in Classes
is to give it an initial value:
var $items = "";
And therefore  one does not have to do an isset() or empty() on the var
inside a method:
$this-items[] .= $num;  // no warning on this with:  var $items = "";


So the statement made in:
http://www.zend.com/zend/tut/class-intro.php
"All of the variables used by a class must be declared before any of the
class' functions including constructors" does not hold true for the reasons
I've given above above.

Thanks,
Bob

---



ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=8476edit=2


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] PHP 4.0 Bug #8476 Updated: Class documentaion request

2001-03-20 Thread bobw123

ID: 8476
User Update by: [EMAIL PROTECTED]
Status: Analyzed
Bug Type: Documentation problem
Description: Class documentaion request

jmcastagnetto,

Possibly you do not have your error reporting set to max

Bob

Previous Comments:
---

[2001-03-17 00:37:23] [EMAIL PROTECTED]
Cannot replicate behavior in RH 6.1 and Solaris 2.6, more info needed.

---

[2000-12-29 09:41:53] [EMAIL PROTECTED]
Hello,

Please modify the documentaion on the Class to reflect the fact that
variables set in the classes must be given a value to prevent  
the "Undefined property:somevar" warning.

var $items;  // Items in our shopping cart

should be :
var $items = "";  // Items in our shopping cart
or
var $items = array();  // Items in our shopping cart
etc.

In fact, it appears to me that the variable declaration inside classes
is just about as imporatant as variable declaration anywhere in php scripts.
You either declare them or you don't, and to a large degree it doesn't
really affect your scripts, other than the warnings.

Furthermore , without $items given an initial value, it still has to be
checked inside the function using it to prevent the warnings, for example:

!empty($this-items) ? $this-items[] .= $num : $this-items[] = $num; 

So I don't see any "fatal error" causing reason to declare vars/attributes
outside of functions/methods in Classes.

The only reason I do see for setting vars outside of functions/methods in Classes
is to give it an initial value:
var $items = "";
And therefore  one does not have to do an isset() or empty() on the var
inside a method:
$this-items[] .= $num;  // no warning on this with:  var $items = "";


So the statement made in:
http://www.zend.com/zend/tut/class-intro.php
"All of the variables used by a class must be declared before any of the
class' functions including constructors" does not hold true for the reasons
I've given above above.

Thanks,
Bob

---


Full Bug description available at: http://bugs.php.net/?id=8476


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]