Skip to content

Instantly share code, notes, and snippets.

@dg
Created May 21, 2013 01:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dg/5616877 to your computer and use it in GitHub Desktop.
Save dg/5616877 to your computer and use it in GitHub Desktop.
Workaround for missing ::class in PHP < 5.5
<?php
use Nette\Http;
echo Http\Request::class; // prints 'Nette\Http\Request' since PHP 5.5
echo Http\Request\type::of; // prints 'Nette\Http\Request' alwyas ;)
// workaround
function __autoload($c)
{
$c = substr($c, 0, -5);
eval("namespace $c;class type{const of='$c';}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment