Last active
November 30, 2016 13:51
-
-
Save edwardgalligan/1330ec5264e7d729dd0e825c51df2e32 to your computer and use it in GitHub Desktop.
Old dirty legacy fake namespacing for PHP Sami
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Sami\Project; | |
use Sami\Reflection\ClassReflection; | |
class CustomProject extends Project | |
{ | |
protected function updateCache(ClassReflection $class) | |
{ | |
$name = $class->getName(); | |
$this->namespaces[$class->getNamespace()] = $class->getNamespace(); | |
// add sub-namespaces | |
$namespace = $class->getNamespace(); | |
while ($namespace = substr($namespace, 0, strrpos($namespace, '\\'))) { | |
$this->namespaces[$namespace] = $namespace; | |
} | |
if ($class->isException()) { | |
$this->namespaceExceptions[$class->getNamespace()][$name] = $class; | |
} elseif ($class->isInterface()) { | |
$this->namespaceInterfaces[$class->getNamespace()][$name] = $class; | |
$this->interfaces[$name] = $class; | |
} else { | |
$this->namespaceClasses[$class->getNamespace()][$name] = $class; | |
} | |
if ($this->getConfig('simulate_namespaces')) { | |
$namespace = preg_replace('/[\/\\\][^\/\\\]*\\.php$/', '', trim(str_replace('/', '\\', $class->getFile()), '.')); | |
$this->simulatedNamespaces[$namespace][$name] = $class; | |
while ($namespace = substr($namespace, 0, strrpos($namespace, '\\'))) { | |
if (!isset($this->simulatedNamespaces[$namespace])) { | |
$this->simulatedNamespaces[$namespace] = array(); | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Sami\Sami; | |
use Symfony\Component\Finder\Finder; | |
use Sami\Parser\Filter\TrueFilter; | |
require_once './CustomProject.php'; | |
$sami = new Sami( | |
Finder::create() | |
->files() | |
->name('*.php') | |
->in('../src'), | |
array( | |
'simulate_namespaces' => true | |
) | |
); | |
$sami['filter'] = function() { | |
return new TrueFilter(); | |
}; | |
$sami['project'] = function ($sc) { | |
$project = new CustomProject($sc['store'], $sc['_versions'], array( | |
'build_dir' => $sc['build_dir'], | |
'cache_dir' => $sc['cache_dir'], | |
'remote_repository' => $sc['remote_repository'], | |
'simulate_namespaces' => $sc['simulate_namespaces'], | |
'include_parent_data' => $sc['include_parent_data'], | |
'default_opened_level' => $sc['default_opened_level'], | |
'theme' => $sc['theme'], | |
'title' => $sc['title'], | |
'source_url' => $sc['source_url'], | |
'source_dir' => $sc['source_dir'], | |
)); | |
$project->setRenderer($sc['renderer']); | |
$project->setParser($sc['parser']); | |
return $project; | |
}; | |
return $sami; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment