You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
function __construct($q) {
echo "Constructor $q";
}
function a($a) {
echo 'A';
}
}
$x = new test('test');
$x->a();
?>`
I have created the following code snippet, and it works as expected. However I am missing any warning message about missing parameter. Since it is not optional, as there is no default value assigned to it, I believe there should be at least some information about that mistake.
What is more, if I implement additional a($a, $b) function which takes two arguments, the same code will execute the first function with matching name. I think that best solution would be that $x->a() returning NULL instead of executing some method/function that does not match parameters number.
Same happens if there are several methods with the same name / same number of parameters.
Only first declared is working and there is no information about duplicate function name.
In addition I were able to launch protected & private method from outside of class they were implemented.
The text was updated successfully, but these errors were encountered:
Warnings are not of particular interest in this case because PH7 support function overloading (i.e. function or methods with different parameters but same name) as an extension to the PHP programming language.
I know that, but in this particular case we have 2 functions with same name (overloaded). One of them takes one argument, while second takes two arguments.
When I execute then myfunc(); I imagine that it will not match to any function with that name as there are missing parameters. There should be warning generated and code not executed at all.
Finally, if I have a class named MyClass and a private method MyMethod() inside. The following code should not work:
MyClass::MyMethod();
It should not work because it is private method.
These should be consideres as bugs.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
`<?php
class test {
}
$x = new test('test');
$x->a();
?>`
I have created the following code snippet, and it works as expected. However I am missing any warning message about missing parameter. Since it is not optional, as there is no default value assigned to it, I believe there should be at least some information about that mistake.
What is more, if I implement additional a($a, $b) function which takes two arguments, the same code will execute the first function with matching name. I think that best solution would be that $x->a() returning NULL instead of executing some method/function that does not match parameters number.
Same happens if there are several methods with the same name / same number of parameters.
Only first declared is working and there is no information about duplicate function name.
In addition I were able to launch protected & private method from outside of class they were implemented.
The text was updated successfully, but these errors were encountered: