Skip to content

Instantly share code, notes, and snippets.

@mageekguy
Created May 12, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mageekguy/f873ffaf0cdc5f69d108 to your computer and use it in GitHub Desktop.
Save mageekguy/f873ffaf0cdc5f69d108 to your computer and use it in GitHub Desktop.
Extends and private properties are in a boat…
<?php
namespace
{
class abscisse
{
private $value;
function __construct($value)
{
$this->value = $value;
}
}
class ordinate extends abscisse
{
}
class point
{
private
$x,
$y
;
function __construct(abscisse $x, ordinate $y)
{
$this->x = $x;
$this->y = $y;
}
protected function abscisseAndOrdinateAreNeededByPoint(self $point)
{
$point->abscisseAndOrdinateAre($this->x, $this->y);
return $this;
}
protected function abscisseAndOrdinateAre(abscisse $abscisse, ordinate $ordinate)
{
return $this;
}
}
}
namespace myPoint
{
class displayer
{
function abscisseAndOrdinateAre(\abscisse $abscisse, \ordinate $ordinate)
{
var_dump($abscisse, $ordinate);
return $this;
}
}
class point extends \point
{
private
$displayer
;
function displayerIs(displayer $displayer)
{
$this->displayer = $displayer;
parent::abscisseAndOrdinateAreNeededByPoint($this);
return $this;
}
protected function abscisseAndOrdinateAre(\abscisse $abscisse, \ordinate $ordinate)
{
$this->displayer->abscisseAndOrdinateAre($abscisse, $ordinate);
return $this;
}
}
(new point(new \abscisse(2), new \ordinate(3)))->displayerIs(new displayer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment