Skip to content

Composer Class Aliassing - THIS IS STUPID, DON'T EVER DO THIS, EVER.

Notifications You must be signed in to change notification settings

frankdejonge/Poser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WARNING WARNING, DEPRECATED PACKAGE!

I've made a way better and optimizable version: FuelPHP/Alias. I strongly recommend using that package instead of this one.

Poser

Build Status

Poser appends itself to the autoloading stack and resolves class aliasses. This all so your classes can pretend to be someone else.

Usage

<?php

use Poser\Poser;

Poser::alias(array(
	// Rename a class
	'Namespaced\Alias' => 'Namespaced\Classname',
	
	// Rename namespace
	'Other\Namespaced\Classname' => 'Real\Namespaced\Classname'
	
	// Alias to global
	'Classname' => 'Namespaced\Classname',
));

Wildcards

With a wildcard like;

Poser\Poser::alias(array(
	'NotSo\Deep\*' => 'ACLass\InA\Deep\And\Hidden\Namespace\$1',
));

Poser wil act like:

$obj = new NotSo\Deep\Model();
// ACLass\InA\Deep\And\Hidden\Namespace\Model;

You can also have multiple wildcards:

Poser\Poser::alias(array(
	'*\Dude\*\Is\*\Man' => '$1\$2\$3',
));

$obj = new Hey\Dude\What\Is\Up\Man()
// Wil stranslate to Hey\WHat\Up

Closure translations

You can also modify the translation in a closure.

Poser\Poser::alias(array(
	'*\*\Strange' => function($one, $two)
	{
		return $one.'\\'.$two.'\\Weird';
	}
));

$instance = new That\Stuffs\Strange();
// Will be a new instance of That\Stuffs\Weird

Registering the autoloader

Poser\Poser::register();

// Unregister
Poser\Poser::unregister();

Multiton usage

You can also register more Posers to the autoloader.

$poser = Poser\Poser::instance('justin_bieber');

// Alias some classes
$poser->alias(array(
	'Justin\Bieber' => 'InvalidArgumentException',
));

// Register the autoloader
$poser->register();

About

Composer Class Aliassing - THIS IS STUPID, DON'T EVER DO THIS, EVER.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages