What do you think of this question in the cert guide

General discussion on certification and training programs

What do you think of this question in the cert guide

Postby daan3137 on Sat Nov 18, 2017 3:15 pm

Hi there,

I strongly disagree with one of the questions in the certification guide. I am curious how others think about it.

The question is:
What is the best way to test if $param is an anonymous function in a method.
A: ...
B: use is callable($param)
C: use the type hint closure on the signature
D: ...

In my opinion the answer should be B. But gotcha. According to the text book it should be C.
But, the question was how to test if a variable contains a certain type. Not how to prevent the situation. Testing suggests you are already in an uncertain situation. Also, C should not even be marked as a possible answer I would say. Because the answer is based on assumptions. Who says I can change the method signature? And even if I was allowed to change some interface ... Changing that might have impact on other parts of the software. I would not say this can be considered the better solution in many real world applications. Don't get me wrong. I love strictness. It would have been as C suggests from the beginning. But that was not the question.
Also who says $param was input? It is likely but an assumption none less. It might have been somebody preparing some $param to pass to another function?

Anyway. I strongly disagree with the claim that C is always the best solution to test if some variable called $param is callable.

I am curious to hear how others think about it.
Posts: 1
Joined: Sat Nov 18, 2017 2:29 pm

Re: What do you think of this question in the cert guide

Postby meo2381 on Mon Jan 29, 2018 8:25 am

yes i do (Y)
Posts: 1
Joined: Mon Jan 29, 2018 8:08 am

Return to Zend Certification and Training

Who is online

Users browsing this forum: No registered users and 2 guests