Answer the question
In order to leave comments, you need to log in
Do property/parameter types need to be checked?
There is a class, for example:
class MyClass {
private $_flag;
public function setData($value){
$this->_flag = $value;
}
public function getData(){
return $this->_flag;
}
}
Answer the question
In order to leave comments, you need to log in
here, most likely, by "user", you mean the programmer using the class .. then, just indicate the type in the method signature:
well, if this is an input from some user, then it needs to be validated before entering the
PS class Leave everything on the conscience of users not worth it .. Incoming parameters should be limited and validated, this will simplify the use of the class and prevent the appearance of implicit errors
For example, now in WP there is a two-year bug that demonstrates such consequences:
https://core.trac.wordpress.org/ticket/29750
if it is very critical - it is possible to lead to the necessary type.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question