Skip to content

Instantly share code, notes, and snippets.

@tacoberu
Last active October 7, 2015 12:55
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 tacoberu/f1742b794d1546342bfe to your computer and use it in GitHub Desktop.
Save tacoberu/f1742b794d1546342bfe to your computer and use it in GitHub Desktop.
Jak přidat do existující třídy novou funkcionalitu.
<?php
class Int
{
function __construct($blob)
{}
function plus(Int $m){}
function minus(Int $m){}
}
class IncInt extends Inc
{
function __construct(Int $pattern)
{}
function inc(){}
}
$a = new Int(1);
$b = new Int(2);
$c = new IncInt(3);
(new IncInt($a))->inc();
(new IncInt($b))->inc();
$c->inc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment