Skip to content

Instantly share code, notes, and snippets.

@RayBenefield
Created July 9, 2014 20:05
Show Gist options
  • Save RayBenefield/2f8b8aff0d6c54713072 to your computer and use it in GitHub Desktop.
Save RayBenefield/2f8b8aff0d6c54713072 to your computer and use it in GitHub Desktop.
<?php
class car {
// class-level variables storing classes; Type-hinted
protected $Frame;
protected $Paint;
protected $Tires;
// class-level variables; not Type-hinted
protected $paintColor = 'red'; // class-level variable storing a scalar
protected $level;
protected $bubble;
// Type-hinted arguments are studly cased and not type-hinted are camel cased
public function __construct(Frame $Frame, Paint $Paint, Tires $Tires, $level = Logger::DEBUG, $bubble = true) {
$this->Frame = $Frame;
$this->Paint = $Paint;
$this->Tires = $Tires;
// Not type-hinted
$this->level = $level;
$this->bubble = $bubble;
}
// Assembler is type-hinted and message is not
public function assembleCar(Assembler $Assembler, $message) {
$Assembler->add($this->Frame);
$Assembler->add($this->Paint, $this->paintColor);
$Assembler->add($this->Tires);
// Not type-hinted
echo $message;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment