Skip to content

Instantly share code, notes, and snippets.

View bdelespierre's full-sized avatar
🚩
Working from home

Benjamin Delespierre bdelespierre

🚩
Working from home
View GitHub Profile
<?php
spl_autoload_register(function ($name) {
// $exp will be the name of the class without the \with\traitname part => array_splice
$exp = explode("\\", $name);
// serach from end
$index = array_search("with", array_reverse($exp, true));
if (!$index || $index - 1 == count($exp)) // also fail when value is 0
return false;