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::appendChil dNode()
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 4748
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.c omwrote:
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::appendChil dNode()
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.comwro te:
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::appendChil dNode()
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.comwro te:
>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::appendChil dNode() 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*******@attgl obal.net
=============== ===
On 13 Jan., 04:32, Jerry Stuckle <jstuck...@attg lobal.netwrote:
seaside wrote:
On 13 Jan., 04:00, "Rik Wasmus" <luiheidsgoe... @hotmail.comwro te:
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::appendChil dNode() 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.comwro te:
>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. 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 and is defined in an assembly
common to the client and server components. The custom class merely defines
three (3) constructors -- the null constructor; one with a string parameter;
and one with a string and innner exception parameter -- that...
|
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 click a button to
determine whether the zip code is unique. If the zip code is not unique,
another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip
code is passed to the lookup form/dialog by reference. I then load a...
|
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 original value of the local."
My code is:
using System;
using System.Collections.Generic;
|
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 when I pass a class as a
parameter to a Windows Form. Basically, I have a class that has several
fields, two of these fields are an instance of an inner class, the rest
are basic value types (bool's in this case). I have a windows form, the...
| |
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 main class whenever it is
needed:
class shop_main {
var $prices = null;
function &get_prices() {
|
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 object is a reference type?
my code is not proving that. I have a web project i created from a web
service that is my object:
public class ExcelService : SoapHttpClientProtocol
{
|
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 Hello()
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |