-1
So I was able to create a class with a method for verify if the return of one another function is a boolean:
Technically and there would enter the orienteering of you, it works like this:
class Classe {}
$a = new Classe();
$util = new Util();
echo $util->instancia ("Classe", $a) ? "Confirmado!" : "Não é uma instancia dessa classe!";
But I’m not getting it adapt that in:
public function buscarTodos () : array ::{}
I need to get ensure that the return of function buscarTodos
be in fact a array of objects of a given class.
In the java, just do:
public function buscarTodos () : array<Pessoas> {}
For example, the part I need to take care of is already taken care of. But in the php is very difficult get that outworking.
Note: I could ensure that in the body of method. But that’s not the goal.
My gosh! They refused?
– Carlos Rocha
Yes, because it makes no sense to have return statement in a dynamic typing language.
– Woss
Well, I think I should have the option available to anyone who wants to use it anyway. Although it doesn’t really make sense for that kind of language but it would be interesting to provide that resource if someone needed it. In this case, the programmer would get the resources he needs. But it’s great. It’s playing forward. Thank you for now! Maybe someone in the community has had some similar idea and I find a solution.
– Carlos Rocha
That’s the question: you use a dynamic typing language if it gives you any advantage. If static typing brings benefits, just use another language.
– Woss
Basically you don’t buy a screwdriver waiting for it to have a saw in case you need to cut something.
– Woss
I get it. Thank you
– Carlos Rocha