Bug #16046 Updated: isset empty parse error w/ objects

2002-03-13 Thread sniper

 ID:   16046
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: linux
 PHP Version:  4.1.2
 New Comment:

RTFM:

http://www.php.net/manual/en/function.empty.php

empty() only works with plain variables.




Previous Comments:


[2002-03-13 15:30:41] [EMAIL PROTECTED]

/*
See the script below. Passing a value returned from an object function
call to isset() and empty() results in a parsing error. strlen() and
other functions don't have this problem.  The code example below tests
empty(). You may substitute isset() as well and get the same parse
error.
This bug exists on both Apache 1.3.9/PHP 4.1.1 and Apache 1.3.23/PHP
4.1.2
*/

//first, declare a simple class with 1 function
class Foo {
function getStr() { return foo; }
}

//now make an object of that class
$foo = new Foo();

/*
* now let's test empty() with just the string
* this should evaluate false, and result in not empty 
* being printed
*/
$fooStr = $foo-getStr();
if ( empty($foostr) ) {
echo empty!;
} else {
echo not empty!;
}

/*
* now test it using the object function call. This is the
* functional equivalent of the previous test, and should 
* result in the same result. However it results in: 
* Parse error: parse error, expecting `')'' 
* If you comment out this block, this script parses and
* executes successfully.
*/
if ( empty($foo-getStr()) ) {
   echo empty!;
} else {
   echo not empty!;
}






-- 
Edit this bug report at http://bugs.php.net/?id=16046edit=1




Bug #16046 Updated: isset empty parse error w/ objects

2002-03-13 Thread jabeardsley

 ID:   16046
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: linux
 PHP Version:  4.1.2
 New Comment:

Well, I did RTFM, quite a bit in fact. The result of the function call
*is* a plain variable, no? If not, your telling me that (from my
example) $foo-getStr() is not equal to the plain string foo? It's
just a string coming back from the call, and that should be accepted
into empty() just as if I'd typed a string in there to begin with.
Seems like the evaluation order is screwed up to me. In any case, if
this function is working as intended, a better FM might be in order
in this case.


Previous Comments:


[2002-03-13 15:53:21] [EMAIL PROTECTED]

RTFM:

http://www.php.net/manual/en/function.empty.php

empty() only works with plain variables.





[2002-03-13 15:30:41] [EMAIL PROTECTED]

/*
See the script below. Passing a value returned from an object function
call to isset() and empty() results in a parsing error. strlen() and
other functions don't have this problem.  The code example below tests
empty(). You may substitute isset() as well and get the same parse
error.
This bug exists on both Apache 1.3.9/PHP 4.1.1 and Apache 1.3.23/PHP
4.1.2
*/

//first, declare a simple class with 1 function
class Foo {
function getStr() { return foo; }
}

//now make an object of that class
$foo = new Foo();

/*
* now let's test empty() with just the string
* this should evaluate false, and result in not empty 
* being printed
*/
$fooStr = $foo-getStr();
if ( empty($foostr) ) {
echo empty!;
} else {
echo not empty!;
}

/*
* now test it using the object function call. This is the
* functional equivalent of the previous test, and should 
* result in the same result. However it results in: 
* Parse error: parse error, expecting `')'' 
* If you comment out this block, this script parses and
* executes successfully.
*/
if ( empty($foo-getStr()) ) {
   echo empty!;
} else {
   echo not empty!;
}






-- 
Edit this bug report at http://bugs.php.net/?id=16046edit=1




Bug #16046 Updated: isset empty parse error w/ objects

2002-03-13 Thread torben

 ID:   16046
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Bogus
 Bug Type: Scripting Engine problem
 Operating System: linux
 PHP Version:  4.1.2
 New Comment:

From the manual (http://www.php.net/manual/en/function.empty.php):

  Note that this is meaningless when used on anything which 
  isn't a variable; i.e. empty (addslashes ($name)) has no 
  meaning since it would be checking whether something which 
  isn't a variable is a variable with a FALSE value.

This not only explains the issue, it gives an example.

You're not using empty() on a variable in your example; 
you're using it on an anonymous value (specifically, the 
return value of a function).


Torben


Previous Comments:


[2002-03-13 16:56:00] [EMAIL PROTECTED]

Well, I did RTFM, quite a bit in fact. The result of the function call
*is* a plain variable, no? If not, your telling me that (from my
example) $foo-getStr() is not equal to the plain string foo? It's
just a string coming back from the call, and that should be accepted
into empty() just as if I'd typed a string in there to begin with.
Seems like the evaluation order is screwed up to me. In any case, if
this function is working as intended, a better FM might be in order
in this case.



[2002-03-13 15:53:21] [EMAIL PROTECTED]

RTFM:

http://www.php.net/manual/en/function.empty.php

empty() only works with plain variables.





[2002-03-13 15:30:41] [EMAIL PROTECTED]

/*
See the script below. Passing a value returned from an object function
call to isset() and empty() results in a parsing error. strlen() and
other functions don't have this problem.  The code example below tests
empty(). You may substitute isset() as well and get the same parse
error.
This bug exists on both Apache 1.3.9/PHP 4.1.1 and Apache 1.3.23/PHP
4.1.2
*/

//first, declare a simple class with 1 function
class Foo {
function getStr() { return foo; }
}

//now make an object of that class
$foo = new Foo();

/*
* now let's test empty() with just the string
* this should evaluate false, and result in not empty 
* being printed
*/
$fooStr = $foo-getStr();
if ( empty($foostr) ) {
echo empty!;
} else {
echo not empty!;
}

/*
* now test it using the object function call. This is the
* functional equivalent of the previous test, and should 
* result in the same result. However it results in: 
* Parse error: parse error, expecting `')'' 
* If you comment out this block, this script parses and
* executes successfully.
*/
if ( empty($foo-getStr()) ) {
   echo empty!;
} else {
   echo not empty!;
}






-- 
Edit this bug report at http://bugs.php.net/?id=16046edit=1