# generate a notice for bogus function calls

- Thread: https://externals.io/message/19093
- Original archive: https://news-web.php.net/php.internals/19093
- Started by Nuno Lopes on 2005-09-19T21:28:15+00:00
- Messages: 8
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #19093 — Nuno Lopes — 2005-09-19T21:28:15+00:00

URL: https://externals.io/message/19093#19093

Hi,

Although this is not as hot as references or Unicode stuff, I would like to 
discuss a new topic.
Currently PHP accepts more parameters to a function than the required.
In English:
<?
function a($b) {}
a(1,2,3);
?>

PHP accepts this and generates no errors. My purpose is to start generating 
an E_NOTICE, just like we do for not yet initialized variables.
This behaviour has already beaten me for a couple of times, because I had a 
program with functions with similar names, but with different number of 
parameters. The result for calling the wrong function? A nice infinite loop 
:)

I hope this is not hard to implement (maybe in the parser, to get the errors 
on compile time - for performance).

Regards,
Nuno

---

## #19094 — Thorsten Suckow-Homberg — 2005-09-19T21:34:22+00:00

URL: https://externals.io/message/19093#19094 · In reply to: #19093

> <?
> function a($b) {}
> a(1,2,3);
> ?>
>
> PHP accepts this and generates no errors. My purpose is to start 
> generating an E_NOTICE, just like we do for not yet initialized variables.

This would break BC (btw a hot topic nowadays, too ;) ) so this is not a 
good idea. Also it makes no sense in an oo-driven environment as long as 
there is no way of overloading methods.

Best way to deal with this is to write gateway methods that delegate to the 
appropriate methods based on the passed in parameters.

---

## #19095 — ondrej@kmit.sk — 2005-09-19T21:40:12+00:00

URL: https://externals.io/message/19093#19095 · In reply to: #19093

Nuno Lopes wrote:
> <?
> function a($b) {}
> a(1,2,3);
> ?>
> 
> PHP accepts this and generates no errors. My purpose is to start 
> generating an E_NOTICE, just like we do for not yet initialized variables.

No, stupid output!

Generating `E_NOTICE` is not a good idea. You don't need to create 
functions with variable arguments count like `printf()`?

-- 
Ondrej Ivanic
(ondrej@kmit.sk)

---

## #19096 — Nuno Lopes — 2005-09-19T21:45:43+00:00

URL: https://externals.io/message/19093#19096 · In reply to: #19095

> Nuno Lopes wrote:
> > […]
>
> No, stupid output!
>
> Generating `E_NOTICE` is not a good idea. You don't need to create functions 
> with variable arguments count like `printf()`?

No, I at least I think I've never created such a function. To be sincere, 
I've not even remembered of such functions when I was writing that e-mail :)

So, I think my suggestion is bogus.. Although a special syntax (copied from 
C) could be introduced.. well maybe not..

Nuno

---

## #19097 — oliver.graetz@arcor.de — 2005-09-19T22:55:53+00:00

URL: https://externals.io/message/19093#19097 · In reply to: #19093

Nuno Lopes schrieb:

> Currently PHP accepts more parameters to a function than the required.
> In English:
> <?
> function a($b) {}
> a(1,2,3);
> ?>
> 
> PHP accepts this and generates no errors.

This is expected behaviour in PHP! Since PHP does not offer true
overloading of method headers (multiple methods or functions with the
same name but different parameter lists) this is badly needed.

AllOLLi
____________
Bender: "We're making beer. I'm the brewery."
Dwight: "I heard alcohol makes you stupid."
Fry: "No I'm... doesn't."
[Futurama 312]

---

## #19101 — Jani Taskinen — 2005-09-20T09:19:28+00:00

URL: https://externals.io/message/19093#19101 · In reply to: #19093

No way.

     --Jani




>
> Hi,
>
> Although this is not as hot as references or Unicode stuff, I would like to 
> discuss a new topic.
> Currently PHP accepts more parameters to a function than the required.
> In English:
> <?
> function a($b) {}
> a(1,2,3);
> ?>
>
> PHP accepts this and generates no errors. My purpose is to start generating an 
> E_NOTICE, just like we do for not yet initialized variables.
> This behaviour has already beaten me for a couple of times, because I had a 
> program with functions with similar names, but with different number of 
> parameters. The result for calling the wrong function? A nice infinite loop :)
>
> I hope this is not hard to implement (maybe in the parser, to get the errors 
> on compile time - for performance).
>
> Regards,
> Nuno 
>

-- 
Donate @ <http://pecl.php.net/wishlist.php/sniper>
Disclaimer: Donating money may make me happier and friendlier for a limited period!

---

## #19102 — Derick Rethans — 2005-09-20T09:26:10+00:00

URL: https://externals.io/message/19093#19102 · In reply to: #19093

> Hi,
> 
> Although this is not as hot as references or Unicode stuff, I would like to
> discuss a new topic.
> Currently PHP accepts more parameters to a function than the required.
> In English:
> <?
> function a($b) {}
> a(1,2,3);
> ?>
> 
> PHP accepts this and generates no errors. My purpose is to start generating an
> E_NOTICE, just like we do for not yet initialized variables.

No way, we have `func_get_arg()` for this, do to some kind of overloading.

Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

---

## #19103 — Marcus Boerger — 2005-09-20T09:28:45+00:00

URL: https://externals.io/message/19093#19103 · In reply to: #19101

Hello Jani,

Tuesday, September 20, 2005, 11:19:28 AM, you wrote:

>      No way.


Yep no way! PHP doesn't offer a '...' signature so we need it the way it is.
And i don't think we want to have those '...' signatures.

marcus

> 

> > […]

> -- 
> Donate @ <http://pecl.php.net/wishlist.php/sniper>
> Disclaimer: Donating money may make me happier and friendlier for a limited period!




Best regards,
 Marcus
