I'm quite new with PHP. I'm having problems declaring an object as array for function parameter. In Java, I simply use public void methodName (List<Object> listVariableName){} for passing a list of many Objects.
I did some research in PHP and one of the answers suggested to put array in method parameter declaration like so function myFunction($a, array Object $obj){}
Currently, I have a class named Lesson
class Lesson implements JsonSerializable{
private $lessonId;
private $lessonNo;
private $lessonTitle;
private $isLessonActive;
private $isLessonRemoved;
//getters and setter here....
}
Then I'm trying to declare a method called addTopicLesson
function addTopicLesson(Topic $topic, array Lesson $lesson){
}
But, I'm getting an error in array Lesson $lesson
There's 1 topic and MANY lessons. How can I go about implementing or defining the method signature?
I found this but I'd like to know if there's a better approach than to call itself.
I'd appreciate any suggestion.
Thank you.
array of Objects, eitherarrayorObject