本文整理汇总了PHP中get_declared_classes函数的典型用法代码示例。如果您正苦于以下问题:PHP get_declared_classes函数的具体用法?PHP get_declared_classes怎么用?PHP get_declared_classes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_declared_classes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: addCest
public function addCest($file)
{
$name = $this->relativeName($file);
$this->tests[$name] = $file;
$loaded_classes = get_declared_classes();
require_once $file;
$extra_loaded_classes = get_declared_classes();
$testClasses = array_diff($extra_loaded_classes, $loaded_classes);
foreach ($testClasses as $testClass) {
$unit = new $testClass();
$reflected = new \ReflectionClass($testClass);
$methods = $reflected->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
if ($method->isConstructor()) {
continue;
}
if ($method->isDestructor()) {
continue;
}
if (isset($unit->class)) {
$target = $unit->class;
$target .= $method->isStatic() ? '::' . $method->name : '.' . $method->name;
} else {
$target = get_class($unit) . '::' . $method->name;
}
$this->suite->addTest(new \Codeception\TestCase\Cest($this->dispatcher, array('name' => $name . ':' . $target, 'class' => $unit, 'method' => $method->name, 'static' => $method->isStatic(), 'signature' => $target, 'file' => $file, 'bootstrap' => $this->settings['bootstrap'])));
}
}
}
开发者ID:nike-17,项目名称:Codeception,代码行数:29,代码来源:SuiteManager.php
示例2: testAutoload
/**
* Autoload
*/
public function testAutoload()
{
$declared = get_declared_classes();
$declaredCount = count($declared);
Autoloader::autoload('Foo');
$this->assertEquals($declaredCount, count(get_declared_classes()), 'PhpOffice\\PhpPowerpoint\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\PhpPowerpoint namespace');
}
开发者ID:presclark,项目名称:PHPPowerPoint,代码行数:10,代码来源:AutoloaderTest.php
示例3: getAllClassNames
/**
* {@inheritDoc}
* @todo Same code exists in AnnotationDriver, should we re-use it somehow or not worry about it?
*/
public function getAllClassNames()
{
if ($this->classNames !== null) {
return $this->classNames;
}
if (!$this->paths) {
throw MongoDBException::pathRequired();
}
$classes = array();
$includedFiles = array();
foreach ($this->paths as $path) {
if (!is_dir($path)) {
throw MongoDBException::fileMappingDriversRequireConfiguredDirectoryPath();
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iterator as $file) {
if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
continue;
}
$sourceFile = realpath($file->getPathName());
require_once $sourceFile;
$includedFiles[] = $sourceFile;
}
}
$declared = get_declared_classes();
foreach ($declared as $className) {
$rc = new \ReflectionClass($className);
$sourceFile = $rc->getFileName();
if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) {
$classes[] = $className;
}
}
$this->classNames = $classes;
return $classes;
}
开发者ID:JasonOcean,项目名称:iOS_Interest_Group,代码行数:39,代码来源:PHPDriver.php
示例4: analyzeFile
/**
* Analyzes the file provided and gets a list of all valid tests
* The analyzer includes the class, scans the declared class space
* for new classes, inspects every included class, and then for each
* class, inspects the methods to find any that match the test criteria.
* The resulting array of file => classes => tests is then returned.
*
* @param $file the file to inspect
* @return array
**/
public function analyzeFile($file)
{
if (!file_exists($file)) {
throw new Snap_File_UnitTestLoader_LoadException('The test file ' . $file . ' was not found.');
}
// record the declated classes before include
$classes = get_declared_classes();
// include, and then scan for new classes
include_once $file;
$classes = array_diff(get_declared_classes(), $classes);
$output = array();
// loop through the tests and if it does not have a runTest method, continue
// otherwise, add that class as a valid test
$methods = array();
foreach ($classes as $class_name) {
// skip classes that don't have a runTests method
if (!method_exists($class_name, 'runTests')) {
continue;
}
$methods = get_class_methods($class_name);
// loop through the methods, adding the tests
foreach ($methods as $method) {
if (stripos($method, 'test') !== 0) {
continue;
}
if (!isset($output[$class_name])) {
$output[$class_name] = array();
}
$output[$class_name][] = $method;
}
}
return $output;
}
开发者ID:Jakobo,项目名称:snaptest,代码行数:43,代码来源:analyzer.php
示例5: getClassAnnotation
/**
* @return array
* @throws \Exception
*/
public function getClassAnnotation()
{
$classAttributes = [];
$this->getAllClasses();
$classes = get_declared_classes();
foreach ($classes as $class) {
$reflection = new \ReflectionClass($class);
$methods = $reflection->getMethods();
foreach ($methods as $method) {
$annotations = $method->getDocComment();
preg_match_all('#@(.*?)\\s#', $annotations, $annotation);
if ($annotation[1] != null) {
if (empty($method->name)) {
throw new \Exception('You have no method!');
}
$action = $method->name;
if (empty($annotation[1][0])) {
$annotation[1][0] = 'GET';
}
$type = $annotation[1][0];
if (empty($annotation[1][1])) {
$annotation[1][1] = '';
}
$route = $annotation[1][1];
if (empty($annotation[1][2])) {
$annotation[1][2] = 'UNAUTHORIZE';
}
$authorize = $annotation[1][2];
$classAttributes[] = ['method' => $action, 'type' => $type, 'route' => $route, 'authorize' => $authorize, 'class' => $class];
}
}
}
return $classAttributes;
}
开发者ID:nikolovns,项目名称:mvsFirstTry,代码行数:38,代码来源:Route.php
示例6: load
/**
* load() - called by the client initialize routine to load files
*
*/
public function load()
{
$this->_retrievedFiles = $this->getRetrievedFiles();
$this->_loadedClasses = array();
$manifestRegistry = $this->_registry->getManifestRepository();
$providerRegistry = $this->_registry->getProviderRepository();
$loadedClasses = array();
// loop through files and find the classes declared by loading the file
foreach ($this->_retrievedFiles as $file) {
$classesLoadedBefore = get_declared_classes();
$oldLevel = error_reporting(E_ALL | ~E_STRICT);
// remove strict so that other packages wont throw warnings
// should we lint the files here? i think so
include_once $file;
error_reporting($oldLevel);
// restore old error level
$classesLoadedAfter = get_declared_classes();
$loadedClasses = array_merge($loadedClasses, array_diff($classesLoadedAfter, $classesLoadedBefore));
}
// loop through the loaded classes and ensure that
foreach ($loadedClasses as $loadedClass) {
// reflect class to see if its something we want to load
$reflectionClass = new ReflectionClass($loadedClass);
if ($reflectionClass->implementsInterface('Zend_Tool_Framework_Manifest_Interface') && !$reflectionClass->isAbstract()) {
$manifestRegistry->addManifest($reflectionClass->newInstance());
$this->_loadedClasses[] = $loadedClass;
}
if ($reflectionClass->implementsInterface('Zend_Tool_Framework_Provider_Interface') && !$reflectionClass->isAbstract() && !$providerRegistry->hasProvider($reflectionClass->getName(), false)) {
$providerRegistry->addProvider($reflectionClass->newInstance());
$this->_loadedClasses[] = $loadedClass;
}
}
return $this->_loadedClasses;
}
开发者ID:robeendey,项目名称:ce,代码行数:38,代码来源:Abstract.php
示例7: __construct
/**
* Constructor.
*/
public function __construct()
{
$date = $this->month . '-01';
$classes = get_declared_classes();
sort($classes);
foreach ($classes as $className) {
if (is_subclass_of($className, 'Fixture') && !is_subclass_of($className, __CLASS__) && $className != __CLASS__ && $className != "Piwik_Test_Fixture_SqlDump" && $className != "Piwik\\Tests\\Fixtures\\UpdaterTestFixture" && $className != "Piwik\\Tests\\Fixtures\\UITestFixture") {
$klassReflect = new ReflectionClass($className);
if (!strpos($klassReflect->getFilename(), "tests/PHPUnit/Fixtures") && $className != "CustomAlerts" && $className != "Piwik\\Plugins\\Insights\\tests\\Fixtures\\SomeVisitsDifferentPathsOnTwoDays") {
continue;
}
$fixture = new $className();
if (!property_exists($fixture, 'dateTime')) {
continue;
}
$fixture->dateTime = $this->adjustDateTime($fixture->dateTime, $date);
$this->fixtures[$className] = $fixture;
$date = Date::factory($date)->addDay(1)->toString();
}
}
$this->now = $this->fixtures['ManySitesImportedLogsWithXssAttempts']->now;
// make sure ManySitesImportedLogsWithXssAttempts is the first fixture
$fixture = $this->fixtures['Piwik\\Tests\\Fixtures\\ManySitesImportedLogsWithXssAttempts'];
unset($this->fixtures['Piwik\\Tests\\Fixtures\\ManySitesImportedLogsWithXssAttempts']);
$this->fixtures = array_merge(array('Piwik\\Tests\\Fixtures\\ManySitesImportedLogsWithXssAttempts' => $fixture), $this->fixtures);
}
开发者ID:Abine,项目名称:piwik,代码行数:29,代码来源:OmniFixture.php
示例8: __construct
/** @param base base class to collect sub classes for
* @param check_interfaces whether we deal with interfaces
*/
function __construct($base, $check_interfaces = false)
{
foreach (get_declared_classes() as $cname) {
$parent = get_parent_class($cname);
if (strcasecmp($parent, $base) == 0) {
$this->offsetSet($cname, new SubClasses($cname));
}
if ($check_interfaces) {
if ($parent) {
$parent_imp = class_implements($parent);
}
foreach (class_implements($cname) as $iname) {
if (strcasecmp($iname, $base) == 0) {
if (!$parent || !in_array($iname, $parent_imp)) {
$this->offsetSet($cname, new SubClasses($cname));
}
}
}
}
}
if ($check_interfaces) {
foreach (get_declared_interfaces() as $cname) {
foreach (class_implements($cname) as $iname) {
if (strcasecmp($iname, $base) == 0) {
$this->offsetSet($cname, new SubClasses($cname, true));
}
}
}
}
$this->uksort('strnatcasecmp');
}
开发者ID:cefalo19,项目名称:php-src,代码行数:34,代码来源:class_tree.php
示例9: loadRelativeView
/**
* Same as loadView but loads relative to controllers name
*
* @param String $action
* @param Boolean $toVar
*
* @return String
*/
public function loadRelativeView($action, $toVar = false)
{
//Searching if Views is loaded
if (array_search('PhpBURN_Views', get_declared_classes()) == true) {
return PhpBURN_Views::loadView(get_class($this) . DS . $action, $this->_viewData, $toVar);
}
}
开发者ID:bellthoven,项目名称:phpburn,代码行数:15,代码来源:Controller.php
示例10: __construct
public function __construct()
{
if ($this->_resources = Axis::cache()->load('axis_acl_resources')) {
return;
}
foreach (Axis::app()->getModules() as $moduleName => $path) {
if ('Axis_Admin' === $moduleName) {
$path = $path . '/controllers';
} else {
$path = $path . '/controllers/Admin';
}
if (!is_dir($path)) {
continue;
}
foreach ($this->_scanDirectory($path) as $file) {
if (strstr($file, "Controller.php") == false) {
continue;
}
include_once $file;
}
}
$resource = 'admin';
$resources = array($resource);
$camelCaseToDash = new Zend_Filter_Word_CamelCaseToDash();
foreach (get_declared_classes() as $class) {
if (!is_subclass_of($class, 'Axis_Admin_Controller_Back')) {
continue;
}
list($module, $controller) = explode('Admin_', $class, 2);
$module = rtrim($module, '_');
if (empty($module)) {
$module = 'Axis_Core';
} elseif ('Axis' === $module) {
$module = 'Axis_Admin';
}
$module = strtolower($camelCaseToDash->filter($module));
list($namespace, $module) = explode('_', $module, 2);
$resource .= '/' . $namespace;
$resources[$resource] = $resource;
$resource .= '/' . $module;
$resources[$resource] = $resource;
$controller = substr($controller, 0, strpos($controller, "Controller"));
$controller = strtolower($camelCaseToDash->filter($controller));
$resource .= '/' . $controller;
$resources[$resource] = $resource;
foreach (get_class_methods($class) as $action) {
if (false == strstr($action, "Action")) {
continue;
}
$action = substr($action, 0, strpos($action, 'Action'));
$action = strtolower($camelCaseToDash->filter($action));
// $resources[$namespace][$module][$controller][] = $action;
$resources[$resource . '/' . $action] = $resource . '/' . $action;
}
$resource = 'admin';
}
asort($resources);
Axis::cache()->save($resources, 'axis_acl_resources', array('modules'));
$this->_resources = $resources;
}
开发者ID:rommmka,项目名称:axiscommerce,代码行数:60,代码来源:Resource.php
示例11: locateController
/**
* @param string $name
* @return mixed
*/
public function locateController($name)
{
// case $name is a real class name
if (is_object($name) || class_exists($name)) {
return $name;
}
// case $name is a short name
$mask = FrontController::getInstance()->getOption('controller_name_finder');
$full_name = sprintf($mask, Helper::getPropertyName($name));
if (class_exists($full_name)) {
return $full_name;
}
// a user defined locator
$locator = FrontController::getInstance()->getOption('controller_locator');
if (!is_null($locator) && is_callable($locator)) {
$result = call_user_func($locator, $name);
if (!empty($result) && class_exists($result)) {
return $result;
}
}
// loop over all defined classes
$n_length = strlen($name);
$fn_length = strlen($full_name);
foreach (get_declared_classes() as $classname) {
if (substr($classname, -$n_length) == $name || substr($classname, -$fn_length) == $full_name) {
return $classname;
}
}
return null;
}
开发者ID:atelierspierrot,项目名称:mvc-fundamental,代码行数:34,代码来源:Locator.php
示例12: getAllClassNames
/**
* Get all the metadata class names known to this driver.
* @throws DrestException
* @return array $classes
*/
public function getAllClassNames()
{
if (empty($this->classNames)) {
if (empty($this->paths)) {
throw DrestException::pathToConfigFilesRequired();
}
$classes = [];
$included = [];
foreach ($this->paths as $path) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($iterator as $file) {
/* @var \SplFileInfo $file */
if (!in_array($file->getExtension(), $this->extensions)) {
continue;
}
$path = $file->getRealPath();
if (!empty($path)) {
require_once $path;
}
// Register the files we've included here
$included[] = $path;
}
}
foreach (get_declared_classes() as $className) {
$reflClass = new \ReflectionClass($className);
$sourceFile = $reflClass->getFileName();
if (in_array($sourceFile, $included) && $this->isDrestResource($className)) {
$classes[] = $className;
}
}
$this->classNames = $classes;
}
return $this->classNames;
}
开发者ID:leedavis81,项目名称:drest,代码行数:39,代码来源:AnnotationDriver.php
示例13: runInFolder
public function runInFolder($folder, $prefix = '', $suffix = '', $beforeEach = null, $afterEach = null)
{
if (!$folder) {
trigger_error('No folder specified', E_USER_WARNING);
return false;
}
$tests = array();
$classes_before = get_declared_classes();
if (!$this->includeFolder($folder, $prefix, $suffix)) {
return false;
}
$classes_after = get_declared_classes();
$classes = array_diff($classes_after, $classes_before);
if (!empty($classes)) {
foreach ($classes as $class) {
try {
/** @var ClassTest $Test */
$Test = new $class();
} catch (\Exception $E) {
continue;
}
if ($Test instanceof ClassTest && get_class($Test) !== 'Jamm\\Tester\\ClassTest') {
if ($beforeEach && is_callable($beforeEach)) {
$beforeEach($Test);
}
$Test->RunTests();
$tests = array_merge($tests, $Test->getTests());
if ($afterEach && is_callable($afterEach)) {
$afterEach($Test);
}
}
}
}
return $tests;
}
开发者ID:jamm,项目名称:tester,代码行数:35,代码来源:TestsRunner.php
示例14: parsePackage
public function parsePackage($pPath, $pPackage, $pOrigin = true)
{
$classes = array();
$excluded_ext = '/\\.(tpl|tpl\\.php|ttf)$/';
$r = Folder::read($pPath, false);
foreach ($r as $name => $folder) {
if (is_file($folder['path'])) {
$file = $folder['path'];
if (preg_match($excluded_ext, $file, $matches)) {
continue;
}
include_once $file;
continue;
}
$this->parsePackage($folder['path'], $pPackage . '\\' . $name, false);
}
if ($pOrigin) {
$declared_classes = get_declared_classes();
foreach ($declared_classes as $classe) {
if (preg_match('/^' . $pPackage . '/', $classe, $matches)) {
$details = $this->parseClass($classe);
$classes[$classe] = $details;
}
}
}
$this->packages = array_merge($this->packages, $classes);
}
开发者ID:arno06,项目名称:Achilles,代码行数:27,代码来源:class.Documentor.php
示例15: perform
/**
* Processes the request.
*
* @param object HTML_QuickForm_Page the current form-page
* @param string Current action name, as one Action object can serve multiple actions
* @since 2.1.0
* @access public
*/
function perform(&$page, $actionName)
{
$page->isFormBuilt() or $page->buildForm();
$page->handle('display');
$sess =& $page->controller->container();
$opt = $page->getSubmitValue('dumpOption');
switch ($opt) {
case '1':
// Progress2 dump info
$arr = $page->controller->_progress->toArray();
varDump($arr);
break;
case '2':
// Forms values container
varDump($sess);
break;
case '3':
// Included files
$includes = get_included_files();
varDump($includes);
break;
case '4':
// declared classes
$classes = get_declared_classes();
varDump($classes);
break;
case '5':
// declared actions
$actions = $page->controller->_actions;
varDump($actions);
break;
}
}
开发者ID:vinnivinsachi,项目名称:Vincent-DR,代码行数:41,代码来源:Dump.php
示例16: load
/** @function load() loads the events into the system
* @return void
*/
public function load()
{
global $Init;
foreach ($Init->EventPaths as $subscriberDirectory) {
if (file_exists($subscriberDirectory)) {
$subscriberIterator = new DirectoryIterator($subscriberDirectory);
foreach ($subscriberIterator as $fileInfo) {
$file = !$fileInfo->isDot() && $fileInfo->isFile() && substr($fileInfo->getFilename(), -10) == '.event.php' ? file($fileInfo->getPathname()) : null;
$PluginName = preg_match('#plugins#i', $subscriberDirectory) ? basename(substr($subscriberDirectory, 0, -7)) : null;
if (in_array($PluginName, (array) $_SESSION['PluginsInstalled'])) {
$className = substr($fileInfo->getFilename(), -10) == '.event.php' ? substr($fileInfo->getFilename(), 0, -10) : null;
} else {
if ($file && !preg_match('#plugins#', $fileInfo->getPathname())) {
$key = '$active';
foreach ($file as $lineNumber => $line) {
if (strpos($line, $key) !== false) {
break;
}
}
if (preg_match('#true#i', $file[$lineNumber])) {
$className = substr($fileInfo->getFileName(), -10) == '.event.php' ? substr($fileInfo->getFilename(), 0, -10) : null;
}
}
}
if ($className && !in_array($className, get_declared_classes())) {
$this->getClass($className);
}
}
}
}
}
开发者ID:priestd09,项目名称:fogproject,代码行数:34,代码来源:EventManager.class.php
示例17: docs
/**
* generate docs
*/
public function docs()
{
$docs = [];
foreach (get_declared_classes() as $task) {
if (!preg_match('~Robo\\\\Task.*?Task$~', $task)) {
continue;
}
$docs[basename((new ReflectionClass($task))->getFileName(), '.php')][] = $task;
}
ksort($docs);
$taskGenerator = $this->taskGenDoc('docs/tasks.md')->filterClasses(function (\ReflectionClass $r) {
return !$r->isAbstract() or $r->isTrait();
})->prepend("# Tasks");
foreach ($docs as $file => $classes) {
$taskGenerator->docClass("Robo\\Task\\{$file}");
foreach ($classes as $task) {
$taskGenerator->docClass($task);
}
}
$taskGenerator->filterMethods(function (\ReflectionMethod $m) {
if ($m->isConstructor() or $m->isDestructor() or $m->isStatic()) {
return false;
}
return !in_array($m->name, ['run', '', '__call', 'getCommand']) and $m->isPublic();
// methods are not documented
})->processClassSignature(function ($c) {
return "## " . preg_replace('~Task$~', '', $c->getShortName()) . "\n";
})->processClassDocBlock(function ($c, $doc) {
return preg_replace('~@method .*?\\wTask (.*?)\\)~', '* `$1)` ', $doc);
})->processMethodSignature(function (\ReflectionMethod $m, $text) {
return str_replace('#### *public* ', '* `', $text) . '`';
})->processMethodDocBlock(function (\ReflectionMethod $m, $text) {
return $text ? ' ' . strtok($text, "\n") : '';
})->run();
}
开发者ID:sliver,项目名称:Robo,代码行数:38,代码来源:RoboFile.php
示例18: minifyYii
protected function minifyYii($entryScript)
{
try {
ob_start();
$this->runRequest($entryScript);
$_SERVER['REQUEST_URI'] = '/index.php';
$this->runRequest($entryScript, array('r' => 'post'));
ob_end_clean();
} catch (CException $e) {
echo $e;
die;
}
$classes = array_merge(get_declared_classes(), get_declared_interfaces());
$results = array();
foreach ($classes as $class) {
$c = new ReflectionClass($class);
if (strpos($c->getFileName(), YII_PATH) === 0 && strpos($c->getFileName(), YII_PATH . DIRECTORY_SEPARATOR . 'console') !== 0) {
$results[$class] = $c->getFileName();
}
}
$results = $this->sortByInheritance($results);
$content = '';
foreach ($results as $fileName => $class) {
$content .= "\n" . file_get_contents($fileName);
}
return $content;
}
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:27,代码来源:LiteCommand.php
示例19: determine_classes
function determine_classes($file)
{
$c = get_declared_classes();
require_once $file;
$diff = array_diff(get_declared_classes(), $c);
return $diff;
}
开发者ID:shabbyrobe,项目名称:amiss,代码行数:7,代码来源:functions.php
示例20: edit_action
/**
* Shows a dialog for creating or editing a course wizard step.
* @param string $id ID of step to edit, or null if new step
*/
public function edit_action($id = '')
{
if ($id) {
$title = _('Schritt bearbeiten');
$this->step = CourseWizardStepRegistry::find($id);
} else {
$title = _('Schritt hinzufügen');
$this->step = new CourseWizardStepRegistry();
$this->step->name = '';
$this->step->classname = '';
$this->step->number = 0;
$this->step->enabled = false;
$this->availableClasses = array();
foreach (get_declared_classes() as $className) {
if (is_a($className, "CourseWizardStep", true) && $className !== "CourseWizardStep") {
$collection = new SimpleCollection(CourseWizardStepRegistry::findBySQL("1 ORDER BY `number`"));
if (!in_array($className, $collection->pluck("classname"))) {
$this->availableClasses[] = $className;
}
}
}
}
if (Request::isXhr()) {
$this->response->add_header('X-Title', $title);
}
}
开发者ID:ratbird,项目名称:hope,代码行数:30,代码来源:coursewizardsteps.php
注:本文中的get_declared_classes函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论