#!/usr/bin/php <?php class Car { public $color; } class Garage { public function paint(Car $car, $color) { $car->color = $color; } } $car1 = new Car(); $garage = new Garage(); $car1->color = "blue"; echo $car1->color; echo "\n"; $garage->paint($car1, "green"); echo $car1->color; // Displays “green” echo "\n"; $cat = 'tom'; $garage = new Garage(); $garage->paint($cat, 'red');
return 100; } } test('Je kan een Ferrari starten en stoppen net zoals elke Car', function () { $f = new Ferrari(); $f->start(); return $f->isRunning(); }); test('Je kan je Ferrari in mn Garage parkeren', function () { $g = new Garage(); $f = new Ferrari(); $g->parkeer($f); return true; }); test('Maar met uwen bucht moet ge thuis blijven', function () { $g = new Garage(); $c = new Car(); $g->parkeer($c); return true; }); class Garage { private $ferraris = []; public function parkeer(Car $f) { $this->ferraris[] = $f; } } abstract class Door { protected $secret = 'vinni';
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Garage $value A Garage object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Garage $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }