当前位置: 首页>>代码示例>>PHP>>正文


PHP ReflectionClass::getFileName方法代码示例

本文整理汇总了PHP中ReflectionClass::getFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionClass::getFileName方法的具体用法?PHP ReflectionClass::getFileName怎么用?PHP ReflectionClass::getFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReflectionClass的用法示例。


在下文中一共展示了ReflectionClass::getFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFilenames

 /**
  * Get an array of loaded file names in order of loading.
  *
  * @return array
  */
 public function getFilenames()
 {
     $files = array();
     foreach ($this->classList->getClasses() as $class) {
         // Push interfaces before classes if not already loaded
         try {
             $r = new \ReflectionClass($class);
             foreach ($r->getInterfaces() as $inf) {
                 $name = $inf->getFileName();
                 if ($name && !in_array($name, $files)) {
                     $files[] = $name;
                 }
             }
             if (!in_array($r->getFileName(), $files)) {
                 $files[] = $r->getFileName();
             }
         } catch (\ReflectionException $e) {
             // We ignore all exceptions related to reflection,
             // because in some cases class can't exists. This
             // can be if you use in your code constructions like
             //
             // if (class_exists('SomeClass')) { // <-- here will trigger autoload
             //      class SomeSuperClass extends SomeClass {
             //      }
             // }
             //
             // We ignore all problems with classes, interfaces and
             // traits.
         }
     }
     return $files;
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:37,代码来源:ClassLoader.php

示例2: getDirectory

 /**
  * @return string $classFileDirectory
  */
 protected function getDirectory() : string
 {
     if (is_null($this->directory)) {
         $this->directory = dirname($this->reflection->getFileName());
     }
     return $this->directory;
 }
开发者ID:geolysis,项目名称:gz3-base,代码行数:10,代码来源:AbstractModule.php

示例3: create

 /**
  *
  *   Ejemplo:   
  *
  *
  */
 function create($className)
 {
     $myArray = explode("/", $className);
     $reflector = new ReflectionClass(get_class($this));
     //si el tamano del array es dos se debe incluir un modelo en otro subsistema
     //si el tamano del array es uno se incluye un modelo del mismo subsistema
     // sino se de lanzar una excepcion
     if (sizeof($myArray) == 1) {
         $includeDir = dirname($reflector->getFileName()) . "/../modelo/";
         $fileName = $myArray[0] . '.php';
         include_once $includeDir . $fileName;
         eval('$modelObj = new $myArray[0]($this->objParam);');
     } else {
         if (sizeof($myArray) == 2) {
             $includeDir = dirname($reflector->getFileName()) . "/../../" . $myArray[0] . "/modelo/";
             $fileName = $myArray[1] . '.php';
             include_once $includeDir . $fileName;
             eval('$modelObj = new $myArray[1]($this->objParam);');
         } else {
             if (sizeof($myArray) == 3) {
                 $includeDir = dirname($reflector->getFileName()) . "/../../../" . $myArray[1] . "/modelo/";
                 $fileName = $myArray[2] . '.php';
                 include_once $includeDir . $fileName;
                 eval('$modelObj = new $myArray[2]($this->objParam);');
             } else {
                 throw new Exception(__METHOD__ . ': No se pudo incluir el modelo ' . $className);
             }
         }
     }
     //var_dump($this->objParam->getParametro("codigo_tipo_documento")); exit;
     return $modelObj;
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:38,代码来源:ACTbase.php

示例4: testGenerator

 public function testGenerator()
 {
     /** @var OpsWay\Test2\Solid\I $generator */
     $generator = OpsWay\Test2\Solid\Factory::create('d');
     $generator->generate();
     $this->assertFileExists($file = __DIR__ . '/../../test/D/IReader.php');
     include $file;
     $this->assertTrue(interface_exists('IReader'), 'interface IReader not exists');
     $this->assertFileExists($file = __DIR__ . '/../../test/D/CsvReader.php');
     include $file;
     $this->assertTrue(class_exists('CsvReader'), 'class CsvReader not exists');
     $this->assertTrue(method_exists('CsvReader', 'read'), 'Method read not exists in CsvReader');
     $this->assertFileExists($file = __DIR__ . '/../../test/D/App.php');
     include $file;
     $this->assertTrue(class_exists('App'), 'class App not exists');
     $this->assertContains('private $reader', file_get_contents($file));
     $this->assertFileExists($file = __DIR__ . '/../../test/D/run.php');
     $this->assertContains('$app = new App();', file_get_contents($file));
     $this->assertContains('print_r($app->parse());', file_get_contents($file));
     $app = new ReflectionClass('App');
     $this->assertGreaterThan(0, count($app->getMethods()), 'Too less methods in ' . $app->getName());
     $construct = $app->getMethod('__construct');
     $this->assertNotFalse($construct->getName());
     $construct = $app->getMethod('parse');
     $this->assertNotFalse($construct->getName());
     $this->assertEquals(0, count($construct->getParameters()), 'Too less arguments in ' . $construct->getName());
     $this->assertContains('$reader = new CsvReader();', file_get_contents($app->getFileName()));
     $this->assertContains('return $reader->read();', file_get_contents($app->getFileName()));
     $this->checkRead(new App());
 }
开发者ID:kokareff,项目名称:hr-test-2,代码行数:30,代码来源:Test_Generator_D.php

示例5: registerValidatorAnnotations

 protected static function registerValidatorAnnotations($force = false)
 {
     if (!$force && self::$registered) {
         return;
     }
     $refl = new \ReflectionClass(Validation::class);
     if ($refl->getFileName() === false) {
         // We can't setup the auto loading without knowing the path
         return;
     }
     $filePath = str_replace('\\', '/', $refl->getFileName());
     // Detect PSR-0 loading
     $psr0Path = '/Symfony/Component/Validator/Validation.php';
     if (substr($filePath, -strlen($psr0Path)) === $psr0Path) {
         AnnotationRegistry::registerAutoloadNamespace('Symfony\\Component\\Validator\\Constraints', substr($filePath, 0, -strlen($psr0Path)));
         self::$registered = true;
         return;
     }
     // Custom PSR-4 loader
     $constraintsDir = dirname($filePath) . '/Constraints/';
     AnnotationRegistry::registerLoader(function ($class) use($constraintsDir) {
         $ns = 'Symfony\\Component\\Validator\\Constraints\\';
         if (strpos($class, $ns) !== 0) {
             return;
         }
         $filePath = $constraintsDir . str_replace('\\', DIRECTORY_SEPARATOR, substr($class, strlen($ns))) . '.php';
         if (file_exists($filePath)) {
             include $filePath;
             return true;
         }
     });
     self::$registered = true;
 }
开发者ID:a-mayer,项目名称:boekkooi-broadway,代码行数:33,代码来源:SymfonyValidatorAnnotationTestTrait.php

示例6: testCompileBuilderNeedsRedefine

 public function testCompileBuilderNeedsRedefine()
 {
     $builder = $this->getBuilder();
     // The builder should need redefine as the file hasn't been generated yet
     $builder->ttl(3600);
     $this->assertTrue($builder->needsRedefine());
     // -1 disables ttl checking (never needs redefine)
     $builder->ttl(-1);
     $this->assertFalse($builder->needsRedefine());
     // 0 disables ttl checking (always needs redefine)
     $builder->ttl(0);
     $this->assertTrue($builder->needsRedefine());
     // Build the container
     $container = $builder->build();
     // Set a TTL and check if it needs redefine
     $builder->ttl(3600);
     $this->assertFalse($builder->needsRedefine());
     // Touch the file, it should need redefine
     $r = new \ReflectionClass($container);
     $builder->ttl(1200);
     $orig = filemtime($r->getFileName());
     touch($r->getFileName(), $orig - 3600);
     $this->assertTrue($builder->needsRedefine());
     touch($r->getFileName(), $orig);
     // Precompiled never needs redefine
     $builder->precompiled(true);
     $this->assertFalse($builder->needsRedefine());
     // Dynamic always requires redefine
     $builder2 = new ContainerBuilder();
     $this->assertTrue($builder2->needsRedefine());
 }
开发者ID:jbboehr,项目名称:zdi,代码行数:31,代码来源:BuilderTest.php

示例7: afterExample

 public function afterExample(ExampleEvent $event)
 {
     $exception = $event->getException();
     if (null !== $exception && $exception instanceof MethodNotFoundException) {
         if (null === ($ioTemp = $this->io->cutTemp())) {
             if ("\n" !== $this->io->getLastWrittenMessage()) {
                 $this->io->writeln();
             }
         }
         $shortcut = get_class($exception->getSubject()) . '::' . $exception->getMethod();
         if (in_array($shortcut, $this->proposedMethods)) {
             return;
         }
         $this->proposedMethods[] = $shortcut;
         if ($this->io->askConfirmation('Do you want me to create this method for you?')) {
             $class = new \ReflectionClass($exception->getSubject());
             $method = $exception->getMethod();
             $content = file_get_contents($class->getFileName());
             $content = preg_replace('/}[ \\n]*$/', $this->getMethodContentFor($method) . "\n}\n", $content);
             file_put_contents($class->getFileName(), $content);
             $this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $class->getName(), $method), 6);
         }
         $this->io->writeln();
         if (null !== $ioTemp) {
             $this->io->writeTemp($ioTemp);
         }
     }
 }
开发者ID:phpspec,项目名称:phpspec2,代码行数:28,代码来源:MethodNotFoundListener.php

示例8: getConfigTreeBuilder

 public function getConfigTreeBuilder()
 {
     $c = $this->container;
     $tb = new TreeBuilder();
     $tb->root('jms_translation')->fixXmlConfig('config')->children()->arrayNode('locales')->prototype('scalar')->end()->end()->scalarNode('source_language')->defaultValue('en')->end()->arrayNode('configs')->useAttributeAsKey('name')->prototype('array')->fixXmlConfig('dir', 'dirs')->fixXmlConfig('excluded_dir')->fixXmlConfig('excluded_name')->fixXmlConfig('ignore_domain')->fixXmlConfig('external_translations_dir')->fixXmlConfig('domain')->fixXmlConfig('extractor')->children()->arrayNode('extractors')->prototype('scalar')->end()->end()->arrayNode('dirs')->requiresAtLeastOneElement()->prototype('scalar')->validate()->always(function ($v) use($c) {
         $v = str_replace(DIRECTORY_SEPARATOR, '/', $v);
         if ('@' === $v[0]) {
             if (false === ($pos = strpos($v, '/'))) {
                 $bundleName = substr($v, 1);
             } else {
                 $bundleName = substr($v, 1, $pos - 2);
             }
             $bundles = $c->getParameter('kernel.bundles');
             if (!isset($bundles[$bundleName])) {
                 throw new \Exception(sprintf('The bundle "%s" does not exist. Available bundles: %s', $bundleName, array_keys($bundles)));
             }
             $ref = new \ReflectionClass($bundles[$bundleName]);
             $v = false === $pos ? dirname($ref->getFileName()) : dirname($ref->getFileName()) . substr($v, $pos);
         }
         if (!is_dir($v)) {
             throw new \Exception(sprintf('The directory "%s" does not exist.', $v));
         }
         return $v;
     })->end()->end()->end()->arrayNode('excluded_dirs')->prototype('scalar')->end()->end()->arrayNode('excluded_names')->prototype('scalar')->end()->end()->arrayNode('external_translations_dirs')->prototype('scalar')->end()->end()->scalarNode('output_format')->end()->scalarNode('default_output_format')->end()->arrayNode('ignored_domains')->prototype('scalar')->end()->end()->arrayNode('domains')->prototype('scalar')->end()->end()->scalarNode('output_dir')->isRequired()->cannotBeEmpty()->end()->scalarNode('keep')->defaultValue(false)->end()->arrayNode('output_options')->children()->arrayNode('xlf')->children()->scalarNode('add_date')->end()->scalarNode('add_filerefs')->end()->end()->end()->end()->end()->end()->end()->end()->end()->end();
     return $tb;
 }
开发者ID:Kofel,项目名称:JMSTranslationBundle,代码行数:26,代码来源:Configuration.php

示例9: 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

示例10: load

 /**
  * Loads a list of classes and caches them in one big file.
  *
  * @param array   $classes    An array of classes to load
  * @param string  $cacheDir   A cache directory
  * @param string  $name       The cache name prefix
  * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not
  * @param Boolean $adaptive   Whether to remove already declared classes or not
  *
  * @throws \InvalidArgumentException When class can't be loaded
  */
 public static function load($classes, $cacheDir, $name, $autoReload, $adaptive = false)
 {
     // each $name can only be loaded once per PHP process
     if (isset(self::$loaded[$name])) {
         return;
     }
     self::$loaded[$name] = true;
     $classes = array_unique($classes);
     if ($adaptive) {
         // don't include already declared classes
         $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces());
         // the cache is different depending on which classes are already declared
         $name = $name . '-' . substr(md5(implode('|', $classes)), 0, 5);
     }
     $cache = $cacheDir . '/' . $name . '.php';
     // auto-reload
     $reload = false;
     if ($autoReload) {
         $metadata = $cacheDir . '/' . $name . '.meta';
         if (!file_exists($metadata) || !file_exists($cache)) {
             $reload = true;
         } else {
             $time = filemtime($cache);
             $meta = unserialize(file_get_contents($metadata));
             if ($meta[1] != $classes) {
                 $reload = true;
             } else {
                 foreach ($meta[0] as $resource) {
                     if (!file_exists($resource) || filemtime($resource) > $time) {
                         $reload = true;
                         break;
                     }
                 }
             }
         }
     }
     if (!$reload && file_exists($cache)) {
         require_once $cache;
         return;
     }
     $files = array();
     $content = '';
     foreach ($classes as $class) {
         if (!class_exists($class) && !interface_exists($class)) {
             throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class));
         }
         $r = new \ReflectionClass($class);
         $files[] = $r->getFileName();
         $content .= preg_replace(array('/^\\s*<\\?php/', '/\\?>\\s*$/'), '', file_get_contents($r->getFileName()));
     }
     // cache the core classes
     if (!is_dir(dirname($cache))) {
         mkdir(dirname($cache), 0777, true);
     }
     self::writeCacheFile($cache, Kernel::stripComments('<?php ' . $content));
     if ($autoReload) {
         // save the resources
         self::writeCacheFile($metadata, serialize(array($files, $classes)));
     }
 }
开发者ID:spf13,项目名称:symfony,代码行数:71,代码来源:ClassCollectionLoader.php

示例11: getParentCall

 /**
  * Get arguments of parent __construct call
  *
  * @param \ReflectionClass $class
  * @param array $classArguments
  * @return array|null
  */
 public function getParentCall(\ReflectionClass $class, array $classArguments)
 {
     /** Skip native PHP types */
     if (!$class->getFileName()) {
         return null;
     }
     $trimFunction = function (&$value) {
         $value = trim($value, PHP_EOL . ' $');
     };
     $method = $class->getMethod('__construct');
     $start = $method->getStartLine();
     $end = $method->getEndLine();
     $length = $end - $start;
     $source = file($class->getFileName());
     $content = implode('', array_slice($source, $start, $length));
     $pattern = '/parent::__construct\\(([ ' . PHP_EOL . ']*[$]{1}[a-zA-Z0-9_]*,)*[ ' . PHP_EOL . ']*' . '([$]{1}[a-zA-Z0-9_]*){1}[' . PHP_EOL . ' ]*\\);/';
     if (!preg_match($pattern, $content, $matches)) {
         return null;
     }
     $arguments = $matches[0];
     if (!trim($arguments)) {
         return null;
     }
     $arguments = substr(trim($arguments), 20, -2);
     $arguments = explode(',', $arguments);
     array_walk($arguments, $trimFunction);
     $output = array();
     foreach ($arguments as $argumentPosition => $argumentName) {
         $type = isset($classArguments[$argumentName]) ? $classArguments[$argumentName]['type'] : null;
         $output[$argumentPosition] = array('name' => $argumentName, 'position' => $argumentPosition, 'type' => $type);
     }
     return $output;
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:40,代码来源:ArgumentsReader.php

示例12: __construct

 public function __construct($options)
 {
     $this->options = $options;
     $reflect = new \ReflectionClass($this);
     $this->path = dirname($reflect->getFileName());
     $this->assetsPath = '/' . str_replace(DS, '/', str_replace(\T4\ROOT_PATH, '', dirname($reflect->getFileName())));
 }
开发者ID:RayManOff,项目名称:t4,代码行数:7,代码来源:Extension.php

示例13: setBasepath

 /**
  * Set the 'basepath' and the 'namespace' for the extension. We can't use
  * __DIR__, because that would give us the base path for BaseExtension.php
  * (the file you're looking at), rather than the base path for the actual,
  * derived, extension class.
  *
  * @see http://stackoverflow.com/questions/11117637/getting-current-working-directory-of-an-extended-class-in-php
  */
 private function setBasepath()
 {
     $reflection = new \ReflectionClass($this);
     $basepath = dirname($reflection->getFileName());
     $this->basepath = $this->app['pathmanager']->create($basepath);
     $this->namespace = basename(dirname($reflection->getFileName()));
 }
开发者ID:halechan,项目名称:bolt,代码行数:15,代码来源:BaseExtension.php

示例14: _details

 /**
  * Defines the base template details object
  *
  * Templates should extend this object and customise to their own needs
  *
  * @param none
  * @return stdClass
  *
  **/
 protected static function _details()
 {
     $_d = new stdClass();
     $_d->iam = get_called_class();
     $_reflect = new ReflectionClass($_d->iam);
     //	The human friendly name of this template
     $_d->label = 'Widget';
     //	A brief description of the template, optional
     $_d->description = '';
     //	Any additional fields to request
     //	TODO: use the form builder library
     $_d->additional_fields = array();
     //	Empty manual_config object
     $_d->manual_config = '';
     //	An icon/preview to render
     $_d->img = new stdClass();
     $_d->img->icon = '';
     //	Try to detect the icon
     $_extensions = array('png', 'jpg', 'jpeg', 'gif');
     $_path = $_reflect->getFileName();
     $_path = dirname($_path);
     foreach ($_extensions as $ext) {
         $_icon = $_path . '/icon.' . $ext;
         if (is_file($_icon)) {
             $_url = '';
             if (preg_match('#^' . preg_quote(NAILS_PATH, '#') . '#', $_icon)) {
                 //	Nails asset
                 $_d->img->icon = preg_replace('#^' . preg_quote(NAILS_PATH, '#') . '#', NAILS_URL, $_icon);
             } elseif (preg_match('#^' . preg_quote(FCPATH . APPPATH, '#') . '#', $_icon)) {
                 if (page_is_secure()) {
                     $_d->img->icon = preg_replace('#^' . preg_quote(FCPATH . APPPATH, '#') . '#', SECURE_BASE_URL . APPPATH . '', $_icon);
                 } else {
                     $_d->img->icon = preg_replace('#^' . preg_quote(FCPATH . APPPATH, '#') . '#', BASE_URL . APPPATH . '', $_icon);
                 }
             }
             break;
         }
     }
     //	an array of the widget-able areas
     $_d->widget_areas = array();
     // --------------------------------------------------------------------------
     //	Automatically calculated properties
     $_d->slug = '';
     // --------------------------------------------------------------------------
     //	Work out slug - this should uniquely identify a type of template
     $_d->slug = $_reflect->getFileName();
     $_d->slug = pathinfo($_d->slug);
     $_d->slug = explode('/', $_d->slug['dirname']);
     $_d->slug = array_pop($_d->slug);
     // --------------------------------------------------------------------------
     //	Define any assets need to be loaded by the template
     $_d->assets_editor = array();
     $_d->assets_render = array();
     // --------------------------------------------------------------------------
     //	Path
     $_d->path = dirname($_reflect->getFileName()) . '/';
     // --------------------------------------------------------------------------
     //	Return the D
     return $_d;
 }
开发者ID:nailsapp,项目名称:module-cms,代码行数:69,代码来源:_template.php

示例15: registerCapsules

 /**
  * Register different capsules that we can use
  * @param array $capsules
  */
 public function registerCapsules($capsules = array())
 {
     $cachePath = Config::get('base_path') . 'storage/cache/';
     if (is_file($cachePath . 'reactor.cache.php')) {
         require_once $cachePath . 'reactor.cache.php';
         $cached = true;
     } else {
         $cached = false;
         $toCache = '';
     }
     foreach ($capsules as $capsule) {
         //todo: load anything we need to, configs, etc
         $this->_capsules[] = $capsule;
         if (!$cached) {
             $reflector = new \ReflectionClass(get_class($capsule));
             $capsuleDir = !is_dir(dirname($reflector->getFileName()) . '/config/') ? $this->getConfigDirectory(dirname($reflector->getFileName())) : dirname($reflector->getFileName()) . '/config/';
             $capsuleArray = Virge::dirToArray($capsuleDir);
             //crawl the config directory if it exists
             $files = $capsuleArray ? $capsuleArray['file'] : array();
             foreach ($files as $file) {
                 $toCache .= str_replace(array("<?php", "?>"), '', file_get_contents($capsuleDir . $file)) . "\n";
                 require_once $capsuleDir . $file;
             }
         }
     }
     foreach ($capsules as $capsule) {
         $capsule->registerCapsule();
     }
     if (!$cached && Config::get('app', 'cache_reactor') === true) {
         //save cache
         file_put_contents($cachePath . 'reactor.cache.php', "<?php\n" . $this->sanitizeCache($toCache));
     }
 }
开发者ID:siosphere,项目名称:virge-core,代码行数:37,代码来源:BaseReactor.php


注:本文中的ReflectionClass::getFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。