この行を1行ずつ見ていきましょう。
abstract class ShopProductWriter {
abstract。という名前のクラスを宣言しShopProductWriterます。abstractクラスをインスタンス化することはできません(インスタンスを持つことはできませんShopProductWriter)。このクラスを使用するには、を拡張するクラスを作成する必要がありますShopProductWriter。http://php.net/manual/en/language.oop5.abstract.phpを参照してください
protected $products = array();
$products配列であるという名前のクラス変数を作成します。この変数の可視性はですprotected。これは$products、this演算子を使用してクラスコンテキスト内からのみアクセスできることを意味します。さらに、$this->productsを拡張するすべてのクラスで利用できるようになりますShopProductWriter。http://php.net/manual/en/language.oop5.visibility.phpおよびhttp://php.net/manual/en/language.oop5.basic.phpを参照してください。
public function addProduct( ShopProduct $shopProduct ) {
publicという名前の可視関数を定義しますaddProduct。この関数は、を拡張する任意のクラスインスタンスのクラスコンテキストの外部で呼び出すことができますShopProductWriter。ShopProductこの関数は、拡張する子クラスまたは子クラスのインスタンスである必要がある単一のパラメーターを取りますShopProduct (「クラスまたはインターフェースが型ヒントとして指定されている場合、そのすべての子または実装も許可されます。」http://php.net/manual/を参照してください。 en / language.oop5.typehinting.php)。
$childInstance = new ChildCLassExtendingShopProductWriter();
$childInstance->addProduct($IAmAShopProductInstance);
最後に、
$this->products[]=$shopProduct;
この関数は、addProduct関数に渡されたインスタンスをクラス配列に追加しますproducts。