I have a method
>>>
function appendChildNode( AST $aNewChild ) {
...
}
<<<
where AST is a class. If I pass null, PHP renders this message:
>>>
Catchable fatal error: Argument 1 passed to AST::appendChildNode()
must be an instance of AST, null given, called in /Applications/MAMP/
htdocs/compile/includes/CParser.inc.php(517) : eval()'d code on line 1
and defined in /Applications/MAMP/htdocs/compile/includes/AST.inc.php
on line 43
<<<
Any ideas, why I can't pass a null value?
[appendChildNode() is a method declared inside the class AST] 13 4693
in php, null is not only a value but also a type, and the type hint was
violated
On 13 Jan., 03:56, "Peter Pei" <yan...@telus.comwrote:
in php, null is not only a value but also a type, and the type hint was
violated
OK, thx. How do I have to pass a null 'pointer' as an object?
On Sun, 13 Jan 2008 03:50:33 +0100, seaside <se********@mac.comwrote:
I have a method
>>>>
function appendChildNode( AST $aNewChild ) {
...
}
<<<
where AST is a class. If I pass null, PHP renders this message:
>>>>
Catchable fatal error: Argument 1 passed to AST::appendChildNode()
must be an instance of AST, null given, called in /Applications/MAMP/
htdocs/compile/includes/CParser.inc.php(517) : eval()'d code on line 1
and defined in /Applications/MAMP/htdocs/compile/includes/AST.inc.php
on line 43
<<<
Any ideas, why I can't pass a null value?
For some reason:
function appendChildNode( AST $aNewChild = NULL ) {
....
}
.... now it will work.
--
Rik Wasmus
buggy. inconsistent lang design
On 13 Jan., 04:00, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Sun, 13 Jan 2008 03:50:33 +0100, seaside <seaside...@mac.comwrote:
I have a method
* function appendChildNode( AST $aNewChild ) {
* ...
* }
<<<
where AST is a class. If I pass null, PHP renders this message:
Catchable fatal error: Argument 1 passed to AST::appendChildNode()
must be an instance of AST, null given, called in /Applications/MAMP/
htdocs/compile/includes/CParser.inc.php(517) : eval()'d code on line 1
and defined in /Applications/MAMP/htdocs/compile/includes/AST.inc.php
on line 43
<<<
Any ideas, why I can't pass a null value?
For some reason:
function appendChildNode( AST $aNewChild = NULL ) {
}
But now, I can call it 'legally' with no parameters, which I don't
want.
At least any reader would think, 'OK, passing no value is OK'.
Do we have other options?
Additionally: I'll go into details of the code soon, but does the
default value make to
exception disappear, since I passed no value at all to appendChildNode?
seaside wrote:
On 13 Jan., 04:00, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>On Sun, 13 Jan 2008 03:50:33 +0100, seaside <seaside...@mac.comwrote:
>>I have a method function appendChildNode( AST $aNewChild ) { ... } <<< where AST is a class. If I pass null, PHP renders this message: Catchable fatal error: Argument 1 passed to AST::appendChildNode() must be an instance of AST, null given, called in /Applications/MAMP/ htdocs/compile/includes/CParser.inc.php(517) : eval()'d code on line 1 and defined in /Applications/MAMP/htdocs/compile/includes/AST.inc.php on line 43 <<< Any ideas, why I can't pass a null value?
For some reason:
function appendChildNode( AST $aNewChild = NULL ) {
}
But now, I can call it 'legally' with no parameters, which I don't
want.
At least any reader would think, 'OK, passing no value is OK'.
Do we have other options?
Additionally: I'll go into details of the code soon, but does the
default value make to
exception disappear, since I passed no value at all to appendChildNode?
As Rik pointed out, type hinting is a somewhat inconsistent operation in
PHP. But this a new area for PHP, and I'm not sure it's been entirely
thought out yet (as seems to be with a lot of things in PHP).
Of course, you could not use type hinting. Instead, you can use
instanceof() in the function itself to ensure you have an instance of
the object. This way you can check for null, also.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
On 13 Jan., 04:32, Jerry Stuckle <jstuck...@attglobal.netwrote:
seaside wrote:
On 13 Jan., 04:00, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Sun, 13 Jan 2008 03:50:33 +0100, seaside <seaside...@mac.comwrote: I have a method * function appendChildNode( AST $aNewChild ) { * ... * } <<< where AST is a class. If I pass null, PHP renders this message: Catchable fatal error: Argument 1 passed to AST::appendChildNode() must be an instance of AST, null given, called in /Applications/MAMP/ htdocs/compile/includes/CParser.inc.php(517) : eval()'d code on line 1 and defined in /Applications/MAMP/htdocs/compile/includes/AST.inc.php on line 43 <<< Any ideas, why I can't pass a null value?
For some reason:
function appendChildNode( AST $aNewChild = NULL ) {
}
But now, I can call it 'legally' with no parameters, which I don't
want.
At least any reader would think, 'OK, passing no value is OK'.
Do we have other options?
Additionally: I'll go into details of the code soon, but does the
default value make to
exception disappear, since I passed no value at all to appendChildNode?
As Rik pointed out, type hinting is a somewhat inconsistent operation in
PHP. *But this a new area for PHP, and I'm not sure it's been entirely
thought out yet (as seems to be with a lot of things in PHP).
Thx, Jerry! In fact, the app failed to pass a value as an argument to
appendChildNode().
I'm building a parser generator and fetched a returned value from a
non-terminal symbol
from the wrong (let's say) stack frame.
Fixed it, removed the ' = NULL' - and things work fine.
Thx again for all quick answers!
..oO(seaside)
>On 13 Jan., 04:00, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
>For some reason:
function appendChildNode( AST $aNewChild = NULL ) {
} But now, I can call it 'legally' with no parameters, which I don't want.
Correct. It's the same as if you explicitly pass NULL.
>At least any reader would think, 'OK, passing no value is OK'.
Do we have other options?
For what? It does exactly what you described in your original posting.
Micha
it is absolutely inconsistent and bad design. null should assume the role of
any type, but not its own type. by saying = null, you are defining a default
value in any other normal cases. here it happens to mean something else.
the slightest inconsistent is inconsistent to me.
You cannot see his concern does not mean there is no concern. the language
is obviously badly defined here. it is forgived, as this is an improving
area in php.
..oO(Peter Pei)
>it is absolutely inconsistent and bad design.
NACK
>null should assume the role of any type, but not its own type. by saying = null, you are defining a default value in any other normal cases. here it happens to mean something else.
It means exactly the same thing - nothing (= no value).
Micha
that's what messed up your brain - nothing and no value. nothing is nothing,
no value is no value.
..oO(Peter Pei)
>that's what messed up your brain - nothing and no value. nothing is nothing, no value is no value.
NULL = no value = nothing
Micha This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: harry |
last post by:
I have 2 multi-dim arrays
double subTotals = null;
String rowTitles = null;
I want to pass them to a function that initialises & populates them like
so -
loadData( rowTitles, subTotals);
|
by: Ken Allen |
last post by:
I have a .net client/server application using remoting, and I cannot get the
custom exception class to pass from the server to the client. The custom
exception is derived from ApplicationException...
|
by: Johnny |
last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form
(fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip
code. The user can enter a zip code in the text box and...
|
by: MSDNAndi |
last post by:
Hi,
I get the following warning:
"Possibly incorrect assignment to local 'oLockObject' which is the argument
to a using or lock statement. The Dispose call or unlocking will happen on
the...
|
by: Ross McLean |
last post by:
Hi all,
I've been teaching myself C# for a new project at work. I have a bit of
a background in c++ and java but never been what you could call a guru.
I'm having some strange things happening...
|
by: Andrew Bullock |
last post by:
Hi,
I have two classes, A and B,
B takes an A as an argument in its constructor:
A a1 = new A();
B b = new B(a1);
|
by: AMP |
last post by:
Hello,
I have this in form1:
namespace Pass
{
public partial class Form1 : Form
{
public Form2 form2;
public Form1()
{
|
by: Markus Ernst |
last post by:
Hello
A class that composes the output of shop-related data gets some info
from the main shop class. Now I wonder whether it is faster to store the
info in the output class or get it from the...
|
by: TS |
last post by:
I was under the assumption that if you pass an object as a param to a method
and inside that method this object is changed, the object will stay changed
when returned from the method because the...
|
by: itarizin |
last post by:
Today I found as ignorance owe me..
Let me explain what I'm tring to do and fail (fail: in my needs)
For example, I've my stupid class:
public class Hello
{
private int x = 0;
public...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |