What does the word Order mean in the meaning of the method and how does this affect the $order ?
public static function onOrderSave(Order $order) { ... } What does the word Order mean in the meaning of the method and how does this affect the $order ?
public static function onOrderSave(Order $order) { ... } So the type of the passed parameter is declared. That is, this function will accept only the Order object or classes inherited from it in $order .
Quote from the documentation:
Type declarations allow functions to strictly specify the type of parameters passed. Passing values of an inappropriate type to a function will result in an error: in PHP 5 this will be a fatal error handled, and in PHP 7 a TypeError exception will be thrown.
You can read more in the official documentation , the Объявление типов section.
Source: https://ru.stackoverflow.com/questions/669710/
All Articles