IF, however, you are refering to the example that stereofrog just gave, then your argument is justified and I 100% concur.
However, doing this:
Code: Select all
function foo($bar) {
}
$foobar = 'foo';Moderator: General Moderators
Code: Select all
function foo($bar) {
}
$foobar = 'foo';volka wrote:There's a difference: I know you're wronginfolock wrote:@volka : I think you are wrong, you think I am wrong, it's all good. We'll just agree to disagree (=
e.g.how many functions will bar() call and how would you implement it (without the mentioned interfaces)?volka wrote:Code: Select all
foreach( pendingActions() as $tfunc) { $results[] = bar($tfunc, 'getRecords'); }
There are as many actions as you want. Maybe it's a DOMNodeList. Maybe the last action manipulated the pendig actions list. Maybe it's something completely different. It's not hardcoded/hardwired.infolock wrote:as for your answer, it depends on how many actions you have setup to clean (however big the array is for pendingActions).
Code: Select all
$result[] = array_map('myFunc1', $anArray);
require 'script2.php';
$result[] = array_map(script2_function_getFunction(), $anArray);What integer would that be for the function (name) returned by script2_function_getFunction() ? Your switch block determines what function/methods can and cannot be called, it has to know them all. Each time a new function is present the switch code has to be altered, too. Therefore the code can never be sealed and marked as safe. One semantical change, two different code places to implement the change.infolock wrote:On the other hand, you could also skip this step by doing it the method in which I'm acustomed to, which is passing an integer to represent which mode or action you want to perform, conduct a switch on it, and then finally execute the function you desire.
Guess what php does withinfolock wrote:You are doing this with a string, an unknown string at that, that must be parsed, and then validated as a proper function variable.
Code: Select all
$a = myFunction($param);Code: Select all
require 'script2.php';
$a = function_from_script2();Cool (= Lots of people read a debate about an issue and automatically assume it's an argument. Just glad we're not in that boat (=volka wrote:No need to apologize, no one's been hurt.
Having you point this out made me think about my current coding methods a lot more now. I almost started to respond with "Well, this happens with switch statements all the time", and I stopped myself short. If this happens all the time with switch statements, then that means the logic in the code is flawed somewhere.volka wrote:What integer would that be for the function (name) returned by script2_function_getFunction() ? Your switch block determines what function/methods can and cannot be called, it has to know them all. Each time a new function is present the switch code has to be altered, too. Therefore the code can never be sealed and marked as safe. One semantical change, two different code places to implement the change.