Control type hinting data

How can I control that the passing variable is of the correct type?

function (Student $student)
{

}

Clicked tab to get indent, skipped to “post” and submitted the thread… And can’t edit >:( I’ll try again:

How can I control that the passing variable is of the correct type?

[php]function failexams(Student $student, Class $class)
{
// Do something
}
$student = “not a Student object”;
$class = new Class();

failexams($student, $class);
[/php]

This will fail. How can I check to see what parameters failexams() needs? I want to be able to automatically detect if the needed parameters matches my variables.

And forget about the fact that I gave a class the name Class :stuck_out_tongue: Stupid choice here (because it’s reserved), but it was only an example.

Sponsor our Newsletter | Privacy Policy | Terms of Service