equal
deleted
inserted
replaced
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_CodeGenerator |
16 * @package Zend_CodeGenerator |
17 * @subpackage PHP |
17 * @subpackage PHP |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: File.php 20096 2010-01-06 02:05:09Z bkarwin $ |
20 * @version $Id: File.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_CodeGenerator_Php_Abstract |
24 * @see Zend_CodeGenerator_Php_Abstract |
25 */ |
25 */ |
31 require_once 'Zend/CodeGenerator/Php/Class.php'; |
31 require_once 'Zend/CodeGenerator/Php/Class.php'; |
32 |
32 |
33 /** |
33 /** |
34 * @category Zend |
34 * @category Zend |
35 * @package Zend_CodeGenerator |
35 * @package Zend_CodeGenerator |
36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
36 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
38 */ |
38 */ |
39 class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract |
39 class Zend_CodeGenerator_Php_File extends Zend_CodeGenerator_Php_Abstract |
40 { |
40 { |
41 |
41 |
95 self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator; |
95 self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator; |
96 |
96 |
97 } |
97 } |
98 |
98 |
99 /** |
99 /** |
100 * fromReflectedFilePath() - use this if you intend on generating code generation objects based on the same file. |
100 * fromReflectedFileName() - use this if you intend on generating code generation objects based on the same file. |
101 * This will keep previous changes to the file in tact during the same PHP process |
101 * This will keep previous changes to the file in tact during the same PHP process |
102 * |
102 * |
103 * @param string $filePath |
103 * @param string $filePath |
104 * @param bool $usePreviousCodeGeneratorIfItExists |
104 * @param bool $usePreviousCodeGeneratorIfItExists |
105 * @param bool $includeIfNotAlreadyIncluded |
105 * @param bool $includeIfNotAlreadyIncluded |
108 public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true) |
108 public static function fromReflectedFileName($filePath, $usePreviousCodeGeneratorIfItExists = true, $includeIfNotAlreadyIncluded = true) |
109 { |
109 { |
110 $realpath = realpath($filePath); |
110 $realpath = realpath($filePath); |
111 |
111 |
112 if ($realpath === false) { |
112 if ($realpath === false) { |
113 if ( ($realpath = Zend_Reflection_file::findRealpathInIncludePath($filePath)) === false) { |
113 if ( ($realpath = Zend_Reflection_File::findRealpathInIncludePath($filePath)) === false) { |
114 require_once 'Zend/CodeGenerator/Php/Exception.php'; |
114 require_once 'Zend/CodeGenerator/Php/Exception.php'; |
115 throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.'); |
115 throw new Zend_CodeGenerator_Php_Exception('No file for ' . $realpath . ' was found.'); |
116 } |
116 } |
117 } |
117 } |
118 |
118 |
392 $output = '<?php' . self::LINE_FEED; |
392 $output = '<?php' . self::LINE_FEED; |
393 } |
393 } |
394 |
394 |
395 // if there are markers, put the body into the output |
395 // if there are markers, put the body into the output |
396 $body = $this->getBody(); |
396 $body = $this->getBody(); |
397 if (preg_match('#/\* Zend_CodeGenerator_Php_File-(.*?)Marker:#', $body)) { |
397 if (preg_match('#/\* Zend_CodeGenerator_Php_File-(.*?)Marker#', $body)) { |
398 $output .= $body; |
398 $output .= $body; |
399 $body = ''; |
399 $body = ''; |
400 } |
400 } |
401 |
401 |
402 // Add file docblock, if any |
402 // Add file docblock, if any |
426 |
426 |
427 // process classes |
427 // process classes |
428 $classes = $this->getClasses(); |
428 $classes = $this->getClasses(); |
429 if (!empty($classes)) { |
429 if (!empty($classes)) { |
430 foreach ($classes as $class) { |
430 foreach ($classes as $class) { |
|
431 if($this->getDocblock() == $class->getDocblock()) { |
|
432 $class->setDocblock(null); |
|
433 } |
431 $regex = str_replace('?', $class->getName(), self::$_markerClass); |
434 $regex = str_replace('?', $class->getName(), self::$_markerClass); |
432 $regex = preg_quote($regex, '#'); |
435 $regex = preg_quote($regex, '#'); |
433 if (preg_match('#'.$regex.'#', $output)) { |
436 if (preg_match('#'.$regex.'#', $output)) { |
434 $output = preg_replace('#'.$regex.'#', $class->generate(), $output, 1); |
437 $output = preg_replace('#'.$regex.'#', $class->generate(), $output, 1); |
435 } else { |
438 } else { |