コード例 #1
0
ファイル: File.php プロジェクト: travisj/zf
 /**
  * fromReflectedFilePath() - use this if you intend on generating code generation objects based on the same file.
  * This will keep previous changes to the file in tact during the same PHP process
  *
  * @param string $filePath
  * @param bool $usePreviousCodeGeneratorIfItExists
  * @param bool $includeIfNotAlreadyIncluded
  * @return Zend_CodeGenerator_Php_File
  */
 public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true)
 {
     $realpath = realpath($filePath);
     if ($realpath === false) {
         if (($realpath = Zend_Reflection_file::findRealpathInIncludePath($filePath)) === false) {
             require_once 'Zend/CodeGenerator/Php/Exception.php';
             throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.');
         }
     }
     if ($usePreviousCodeGeneratorIfItExists && isset(self::$_fileCodeGenerators[$realpath])) {
         return self::$_fileCodeGenerators[$realpath];
     }
     if ($includeIfNotAlreadyIncluded && !in_array($realpath, get_included_files())) {
         include $realpath;
     }
     $codeGenerator = self::fromReflection($fileReflector = new Zend_Reflection_File($realpath));
     if (!isset(self::$_fileCodeGenerators[$fileReflector->getFileName()])) {
         self::$_fileCodeGenerators[$fileReflector->getFileName()] = $codeGenerator;
     }
     return $codeGenerator;
 }
コード例 #2
0
 public function testFileGetFilenameReturnsCorrectFilename()
 {
     require_once 'Zend/Version.php';
     $reflectionFile = new Zend_Reflection_File('Zend/Version.php');
     // Make sure this test works on all platforms
     $this->assertRegExp('#^.*Zend.Version.php$#i', $reflectionFile->getFileName());
 }