Completed
Push — scrutinizer ( c2ef4a )
by Fabio
21:50
created
bin/prado-cli.php 4 patches
Doc Comments   +40 added lines patch added patch discarded remove patch
@@ -145,6 +145,10 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	public abstract function performAction($args);
147 147
 
148
+	/**
149
+	 * @param string $dir
150
+	 * @param integer $mask
151
+	 */
148 152
 	protected function createDirectory($dir, $mask)
149 153
 	{
150 154
 		if(!is_dir($dir))
@@ -156,6 +160,9 @@  discard block
 block discarded – undo
156 160
 			chmod($dir, $mask);
157 161
 	}
158 162
 
163
+	/**
164
+	 * @param string $filename
165
+	 */
159 166
 	protected function createFile($filename, $content)
160 167
 	{
161 168
 		if(!is_file($filename))
@@ -304,6 +311,9 @@  discard block
 block discarded – undo
304 311
 ';
305 312
 	}
306 313
 
314
+	/**
315
+	 * @param string $appName
316
+	 */
307 317
 	protected function renderConfigFile($appName)
308 318
 	{
309 319
 		return <<<EOD
@@ -500,6 +510,9 @@  discard block
 block discarded – undo
500 510
 		require_once($TEST_TOOLS.'/simpletest/reporter.php');
501 511
 	}
502 512
 
513
+	/**
514
+	 * @param string $dir
515
+	 */
503 516
 	protected function runUnitTests($dir, $args)
504 517
 	{
505 518
 		$app_dir = $this->getAppDir($dir);
@@ -538,6 +551,9 @@  discard block
 block discarded – undo
538 551
 		return realpath($dir.'/tests/unit/');
539 552
 	}
540 553
 
554
+	/**
555
+	 * @param string $dir
556
+	 */
541 557
 	protected function getUnitTestCases($dir,$args)
542 558
 	{
543 559
 		$matches = null;
@@ -549,6 +565,9 @@  discard block
 block discarded – undo
549 565
 		return $test;
550 566
 	}
551 567
 
568
+	/**
569
+	 * @param GroupTest $test
570
+	 */
552 571
 	protected function addTests($test,$path,$recursive=true,$match=null)
553 572
 	{
554 573
 		$dir=opendir($path);
@@ -565,6 +584,9 @@  discard block
 block discarded – undo
565 584
 		closedir($dir);
566 585
 	}
567 586
 
587
+	/**
588
+	 * @param string $entry
589
+	 */
568 590
 	protected function hasMatch($match,$entry)
569 591
 	{
570 592
 		$file = strtolower(substr($entry,0,strrpos($entry,'.')));
@@ -630,6 +652,9 @@  discard block
 block discarded – undo
630 652
 		return false;
631 653
 	}
632 654
 
655
+	/**
656
+	 * @param string $app_dir
657
+	 */
633 658
 	protected function getActiveRecordConfig($app_dir)
634 659
 	{
635 660
 		if(false === ($xml=$this->getXmlFile($app_dir)))
@@ -645,6 +670,9 @@  discard block
 block discarded – undo
645 670
 		return false;
646 671
 	}
647 672
 
673
+	/**
674
+	 * @param string $app_dir
675
+	 */
648 676
 	protected function getOutputFile($app_dir, $namespace)
649 677
 	{
650 678
 		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
@@ -659,6 +687,9 @@  discard block
 block discarded – undo
659 687
 		return false;
660 688
 	}
661 689
 
690
+	/**
691
+	 * @param TActiveRecordConfig $config
692
+	 */
662 693
 	protected function generateActiveRecord($config, $tablename, $output)
663 694
 	{
664 695
 		$manager = TActiveRecordManager::getInstance();
@@ -706,6 +737,9 @@  discard block
 block discarded – undo
706 737
 		return $prop;
707 738
 	}
708 739
 
740
+	/**
741
+	 * @param string $class
742
+	 */
709 743
 	protected function generateClass($properties, $tablename, $class)
710 744
 	{
711 745
 		$props = implode("\n", $properties);
@@ -799,6 +833,9 @@  discard block
 block discarded – undo
799 833
         return false;
800 834
     }
801 835
 
836
+    /**
837
+     * @param string $app_dir
838
+     */
802 839
     protected function getActiveRecordConfig($app_dir) {
803 840
         if (false === ($xml = $this->getXmlFile($app_dir)))
804 841
             return false;
@@ -842,6 +879,9 @@  discard block
 block discarded – undo
842 879
 			}
843 880
 	    }
844 881
 
882
+	    /**
883
+	     * @param string $l
884
+	     */
845 885
 	    public function generate($l)
846 886
 	    {
847 887
 			$input = explode(" ", trim($l));
Please login to merge, or discard this patch.
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -740,89 +740,89 @@  discard block
 block discarded – undo
740 740
  */
741 741
 class PradoCommandLineActiveRecordGenAll extends PradoCommandLineAction {
742 742
 
743
-    protected $action = 'generateAll';
744
-    protected $parameters = array('output');
745
-    protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
746
-    protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
747
-    private $_soap = false;
748
-    private $_prefix = '';
749
-    private $_postfix = '';
750
-    private $_overwrite = false;
751
-
752
-    public function performAction($args) {
753
-        $app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
754
-        $this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false;
755
-        $this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false;
756
-        $this->_prefix = count($args) > 5 ? $args[5] : '';
757
-        $this->_postfix = count($args) > 6 ? $args[6] : '';
758
-
759
-        if ($app_dir !== false) {
760
-            $config = $this->getActiveRecordConfig($app_dir);
761
-
762
-            $manager = TActiveRecordManager::getInstance();
763
-            $con = $manager->getDbConnection();
764
-            $con->Active = true;
765
-            $command = $con->createCommand("Show Tables");
766
-            $dataReader = $command->query();
767
-            $dataReader->bindColumn(1, $table);
768
-            $generator = new PHP_Shell_Extensions_ActiveRecord();
769
-            $tables = array();
770
-            while ($dataReader->read() !== false) {
771
-                $tables[] = $table;
772
-            }
773
-            $con->Active = False;
774
-            foreach ($tables as $key => $table) {
775
-                $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix;
776
-                if ($config !== false && $output !== false) {
777
-                    $generator->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite);
778
-                }
779
-            }
780
-        }
781
-        return true;
782
-    }
783
-
784
-    protected function getAppDir($dir=".") {
785
-        if (is_dir($dir))
786
-            return realpath($dir);
787
-        if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
788
-            return $app_dir;
789
-        echo '** Unable to find directory "' . $dir . "\".\n";
790
-        return false;
791
-    }
792
-
793
-    protected function getXmlFile($app_dir) {
794
-        if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
795
-            return $xml;
796
-        if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
797
-            return $xml;
798
-        echo '** Unable to find application.xml in ' . $app_dir . "\n";
799
-        return false;
800
-    }
801
-
802
-    protected function getActiveRecordConfig($app_dir) {
803
-        if (false === ($xml = $this->getXmlFile($app_dir)))
804
-            return false;
805
-        if (false !== ($app = $this->initializePradoApplication($app_dir))) {
806
-            Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
807
-            foreach ($app->getModules() as $module)
808
-                if ($module instanceof TActiveRecordConfig)
809
-                    return $module;
810
-            echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
811
-        }
812
-        return false;
813
-    }
814
-
815
-    protected function getOutputFile($app_dir, $namespace) {
816
-        if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
817
-            return $namespace;
818
-        $file = Prado::getPathOfNamespace($namespace, "");
819
-        if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
820
-            if (strpos($path, $app_dir) === 0)
821
-                return $file;
822
-        }
823
-        echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
824
-        return false;
825
-    }
743
+	protected $action = 'generateAll';
744
+	protected $parameters = array('output');
745
+	protected $optional = array('directory', 'soap', 'overwrite', 'prefix', 'postfix');
746
+	protected $description = "Generate Active Record skeleton for all Tables to <output> file using application.xml in [directory]. May also generate [soap] properties.\nGenerated Classes are named like the Table with optional [Prefix] and/or [Postfix]. [Overwrite] is used to overwrite existing Files.";
747
+	private $_soap = false;
748
+	private $_prefix = '';
749
+	private $_postfix = '';
750
+	private $_overwrite = false;
751
+
752
+	public function performAction($args) {
753
+		$app_dir = count($args) > 2 ? $this->getAppDir($args[2]) : $this->getAppDir();
754
+		$this->_soap = count($args) > 3 ? ($args[3] == "soap" || $args[3] == "true" ? true : false) : false;
755
+		$this->_overwrite = count($args) > 4 ? ($args[4] == "overwrite" || $args[4] == "true" ? true : false) : false;
756
+		$this->_prefix = count($args) > 5 ? $args[5] : '';
757
+		$this->_postfix = count($args) > 6 ? $args[6] : '';
758
+
759
+		if ($app_dir !== false) {
760
+			$config = $this->getActiveRecordConfig($app_dir);
761
+
762
+			$manager = TActiveRecordManager::getInstance();
763
+			$con = $manager->getDbConnection();
764
+			$con->Active = true;
765
+			$command = $con->createCommand("Show Tables");
766
+			$dataReader = $command->query();
767
+			$dataReader->bindColumn(1, $table);
768
+			$generator = new PHP_Shell_Extensions_ActiveRecord();
769
+			$tables = array();
770
+			while ($dataReader->read() !== false) {
771
+				$tables[] = $table;
772
+			}
773
+			$con->Active = False;
774
+			foreach ($tables as $key => $table) {
775
+				$output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix;
776
+				if ($config !== false && $output !== false) {
777
+					$generator->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite);
778
+				}
779
+			}
780
+		}
781
+		return true;
782
+	}
783
+
784
+	protected function getAppDir($dir=".") {
785
+		if (is_dir($dir))
786
+			return realpath($dir);
787
+		if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
788
+			return $app_dir;
789
+		echo '** Unable to find directory "' . $dir . "\".\n";
790
+		return false;
791
+	}
792
+
793
+	protected function getXmlFile($app_dir) {
794
+		if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
795
+			return $xml;
796
+		if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
797
+			return $xml;
798
+		echo '** Unable to find application.xml in ' . $app_dir . "\n";
799
+		return false;
800
+	}
801
+
802
+	protected function getActiveRecordConfig($app_dir) {
803
+		if (false === ($xml = $this->getXmlFile($app_dir)))
804
+			return false;
805
+		if (false !== ($app = $this->initializePradoApplication($app_dir))) {
806
+			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
807
+			foreach ($app->getModules() as $module)
808
+				if ($module instanceof TActiveRecordConfig)
809
+					return $module;
810
+			echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
811
+		}
812
+		return false;
813
+	}
814
+
815
+	protected function getOutputFile($app_dir, $namespace) {
816
+		if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
817
+			return $namespace;
818
+		$file = Prado::getPathOfNamespace($namespace, "");
819
+		if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
820
+			if (strpos($path, $app_dir) === 0)
821
+				return $file;
822
+		}
823
+		echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
824
+		return false;
825
+	}
826 826
 
827 827
 }
828 828
 
@@ -830,20 +830,20 @@  discard block
 block discarded – undo
830 830
 if(class_exists('PHP_Shell_Commands', false))
831 831
 {
832 832
 	class PHP_Shell_Extensions_ActiveRecord implements PHP_Shell_Extension {
833
-	    public function register()
834
-	    {
833
+		public function register()
834
+		{
835 835
 
836
-	        $cmd = PHP_Shell_Commands::getInstance();
836
+			$cmd = PHP_Shell_Commands::getInstance();
837 837
 			if(Prado::getApplication() !== null)
838 838
 			{
839
-		        $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]',
840
-		            'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL.
841
-		            '    application.xml in [directory]. May also generate [soap] properties.');
839
+				$cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]',
840
+					'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL.
841
+					'    application.xml in [directory]. May also generate [soap] properties.');
842 842
 			}
843
-	    }
843
+		}
844 844
 
845
-	    public function generate($l)
846
-	    {
845
+		public function generate($l)
846
+		{
847 847
 			$input = explode(" ", trim($l));
848 848
 			if(count($input) > 2)
849 849
 			{
@@ -860,12 +860,12 @@  discard block
 block discarded – undo
860 860
 			{
861 861
 				echo "\n    Usage: generate table_name Application.pages.RecordClassName\n";
862 862
 			}
863
-	    }
863
+		}
864 864
 	}
865 865
 
866 866
 	$__shell_exts = PHP_Shell_Extensions::getInstance();
867 867
 	$__shell_exts->registerExtensions(array(
868
-		    "active-record"        => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */
868
+			"active-record"        => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */
869 869
 
870 870
 	include_once(realpath(dirname(dirname(__FILE__))).'/framework/3rdParty/PhpShell/php-shell-cmd.php');
871 871
 }
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10 10
  */
11 11
 
12
-if(!isset($_SERVER['argv']) || php_sapi_name()!=='cli')
12
+if (!isset($_SERVER['argv']) || php_sapi_name() !== 'cli')
13 13
 	die('Must be run from the command line');
14 14
 
15
-$frameworkPath = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR;
15
+$frameworkPath = realpath(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR;
16 16
 
17
-require_once($frameworkPath.'prado.php');
17
+require_once($frameworkPath . 'prado.php');
18 18
 
19 19
 //stub application class
20 20
 class PradoShellApplication extends TApplication
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 restore_exception_handler();
29 29
 
30 30
 //config PHP shell
31
-if(count($_SERVER['argv']) > 1 && strtolower($_SERVER['argv'][1])==='shell')
31
+if (count($_SERVER['argv']) > 1 && strtolower($_SERVER['argv'][1]) === 'shell')
32 32
 {
33
-	function __shell_print_var($shell,$var)
33
+	function __shell_print_var($shell, $var)
34 34
 	{
35
-		if(!$shell->has_semicolon) echo Prado::varDump($var);
35
+		if (!$shell->has_semicolon) echo Prado::varDump($var);
36 36
 	}
37
-	include_once($frameworkPath.'/3rdParty/PhpShell/php-shell-init.php');
37
+	include_once($frameworkPath . '/3rdParty/PhpShell/php-shell-init.php');
38 38
 }
39 39
 
40 40
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	/**
65 65
 	 * @var array command action classes
66 66
 	 */
67
-	protected $_actions=array();
67
+	protected $_actions = array();
68 68
 
69 69
 	/**
70 70
 	 * @param string action class name
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	public static function getInstance()
81 81
 	{
82 82
 		static $instance;
83
-		if($instance === null)
83
+		if ($instance === null)
84 84
 			$instance = new self;
85 85
 		return $instance;
86 86
 	}
87 87
 
88 88
 	public static function printGreeting()
89 89
 	{
90
-		echo "Command line tools for Prado ".Prado::getVersion().".\n";
90
+		echo "Command line tools for Prado " . Prado::getVersion() . ".\n";
91 91
 	}
92 92
 
93 93
 	/**
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function run($args)
98 98
 	{
99
-		if(count($args) > 1)
99
+		if (count($args) > 1)
100 100
 			array_shift($args);
101 101
 		$valid = false;
102
-		foreach($this->_actions as $class => $action)
102
+		foreach ($this->_actions as $class => $action)
103 103
 		{
104
-			if($action->isValidAction($args))
104
+			if ($action->isValidAction($args))
105 105
 			{
106 106
 				$valid |= $action->performAction($args);
107 107
 				break;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 				$valid = false;
112 112
 			}
113 113
 		}
114
-		if(!$valid)
114
+		if (!$valid)
115 115
 			$this->printHelp();
116 116
 	}
117 117
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		echo "usage: php prado-cli.php action <parameter> [optional]\n";
126 126
 		echo "example: php prado-cli.php -c mysite\n\n";
127 127
 		echo "actions:\n";
128
-		foreach($this->_actions as $action)
128
+		foreach ($this->_actions as $action)
129 129
 			echo $action->renderHelp();
130 130
 	}
131 131
 }
@@ -147,18 +147,18 @@  discard block
 block discarded – undo
147 147
 
148 148
 	protected function createDirectory($dir, $mask)
149 149
 	{
150
-		if(!is_dir($dir))
150
+		if (!is_dir($dir))
151 151
 		{
152 152
 			mkdir($dir);
153 153
 			echo "creating $dir\n";
154 154
 		}
155
-		if(is_dir($dir))
155
+		if (is_dir($dir))
156 156
 			chmod($dir, $mask);
157 157
 	}
158 158
 
159 159
 	protected function createFile($filename, $content)
160 160
 	{
161
-		if(!is_file($filename))
161
+		if (!is_file($filename))
162 162
 		{
163 163
 			file_put_contents($filename, $content);
164 164
 			echo "creating $filename\n";
@@ -168,22 +168,22 @@  discard block
 block discarded – undo
168 168
 	public function isValidAction($args)
169 169
 	{
170 170
 		return strtolower($args[0]) === $this->action &&
171
-				count($args)-1 >= count($this->parameters);
171
+				count($args) - 1 >= count($this->parameters);
172 172
 	}
173 173
 
174 174
 	public function renderHelp()
175 175
 	{
176 176
 		$params = array();
177
-		foreach($this->parameters as $v)
178
-			$params[] = '<'.$v.'>';
177
+		foreach ($this->parameters as $v)
178
+			$params[] = '<' . $v . '>';
179 179
 		$parameters = join($params, ' ');
180 180
 		$options = array();
181
-		foreach($this->optional as $v)
182
-			$options[] = '['.$v.']';
183
-		$optional = (strlen($parameters) ? ' ' : ''). join($options, ' ');
184
-		$description='';
185
-		foreach(explode("\n", wordwrap($this->description,65)) as $line)
186
-			$description .= '    '.$line."\n";
181
+		foreach ($this->optional as $v)
182
+			$options[] = '[' . $v . ']';
183
+		$optional = (strlen($parameters) ? ' ' : '') . join($options, ' ');
184
+		$description = '';
185
+		foreach (explode("\n", wordwrap($this->description, 65)) as $line)
186
+			$description .= '    ' . $line . "\n";
187 187
 		return <<<EOD
188 188
   {$this->action} {$parameters}{$optional}
189 189
 {$description}
@@ -193,17 +193,17 @@  discard block
 block discarded – undo
193 193
 
194 194
 	protected function initializePradoApplication($directory)
195 195
 	{
196
-		$app_dir = realpath($directory.'/protected/');
197
-		if($app_dir !== false && is_dir($app_dir))
196
+		$app_dir = realpath($directory . '/protected/');
197
+		if ($app_dir !== false && is_dir($app_dir))
198 198
 		{
199
-			if(Prado::getApplication()===null)
199
+			if (Prado::getApplication() === null)
200 200
 			{
201 201
 				$app = new PradoShellApplication($app_dir);
202 202
 				$app->run();
203
-				$dir = substr(str_replace(realpath('./'),'',$app_dir),1);
204
-				$initialized=true;
203
+				$dir = substr(str_replace(realpath('./'), '', $app_dir), 1);
204
+				$initialized = true;
205 205
 				PradoCommandLineInterpreter::printGreeting();
206
-				echo '** Loaded PRADO appplication in directory "'.$dir."\".\n";
206
+				echo '** Loaded PRADO appplication in directory "' . $dir . "\".\n";
207 207
 			}
208 208
 
209 209
 			return Prado::getApplication();
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 		else
212 212
 		{
213 213
 			PradoCommandLineInterpreter::printGreeting();
214
-			echo '+'.str_repeat('-',77)."+\n";
215
-			echo '** Unable to load PRADO application in directory "'.$directory."\".\n";
216
-			echo '+'.str_repeat('-',77)."+\n";
214
+			echo '+' . str_repeat('-', 77) . "+\n";
215
+			echo '** Unable to load PRADO application in directory "' . $directory . "\".\n";
216
+			echo '+' . str_repeat('-', 77) . "+\n";
217 217
 		}
218 218
 		return false;
219 219
 	}
@@ -245,31 +245,31 @@  discard block
 block discarded – undo
245 245
 	 */
246 246
 	protected function createNewPradoProject($dir)
247 247
 	{
248
-		if(strlen(trim($dir)) == 0)
248
+		if (strlen(trim($dir)) == 0)
249 249
 			return;
250 250
 
251 251
 		$rootPath = realpath(dirname(trim($dir)));
252 252
 
253
-		if(basename($dir)!=='.')
254
-			$basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir);
253
+		if (basename($dir) !== '.')
254
+			$basePath = $rootPath . DIRECTORY_SEPARATOR . basename($dir);
255 255
 		else
256 256
 			$basePath = $rootPath;
257 257
 		$appName = basename($basePath);
258
-		$assetPath = $basePath.DIRECTORY_SEPARATOR.'assets';
259
-		$protectedPath  = $basePath.DIRECTORY_SEPARATOR.'protected';
260
-		$runtimePath = $basePath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'runtime';
261
-		$pagesPath = $protectedPath.DIRECTORY_SEPARATOR.'pages';
258
+		$assetPath = $basePath . DIRECTORY_SEPARATOR . 'assets';
259
+		$protectedPath = $basePath . DIRECTORY_SEPARATOR . 'protected';
260
+		$runtimePath = $basePath . DIRECTORY_SEPARATOR . 'protected' . DIRECTORY_SEPARATOR . 'runtime';
261
+		$pagesPath = $protectedPath . DIRECTORY_SEPARATOR . 'pages';
262 262
 
263
-		$indexFile = $basePath.DIRECTORY_SEPARATOR.'index.php';
264
-		$htaccessFile = $protectedPath.DIRECTORY_SEPARATOR.'.htaccess';
265
-		$configFile = $protectedPath.DIRECTORY_SEPARATOR.'application.xml';
266
-		$defaultPageFile = $pagesPath.DIRECTORY_SEPARATOR.'Home.page';
263
+		$indexFile = $basePath . DIRECTORY_SEPARATOR . 'index.php';
264
+		$htaccessFile = $protectedPath . DIRECTORY_SEPARATOR . '.htaccess';
265
+		$configFile = $protectedPath . DIRECTORY_SEPARATOR . 'application.xml';
266
+		$defaultPageFile = $pagesPath . DIRECTORY_SEPARATOR . 'Home.page';
267 267
 
268 268
 		$this->createDirectory($basePath, 0755);
269
-		$this->createDirectory($assetPath,0777);
270
-		$this->createDirectory($protectedPath,0755);
271
-		$this->createDirectory($runtimePath,0777);
272
-		$this->createDirectory($pagesPath,0755);
269
+		$this->createDirectory($assetPath, 0777);
270
+		$this->createDirectory($protectedPath, 0755);
271
+		$this->createDirectory($runtimePath, 0777);
272
+		$this->createDirectory($pagesPath, 0755);
273 273
 
274 274
 		$this->createFile($indexFile, $this->renderIndexFile());
275 275
 		$this->createFile($configFile, $this->renderConfigFile($appName));
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
 
280 280
 	protected function renderIndexFile()
281 281
 	{
282
-		$framework = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR.'prado.php';
282
+		$framework = realpath(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'framework' . DIRECTORY_SEPARATOR . 'prado.php';
283 283
 return '<?php
284 284
 
285
-$frameworkPath=\''.$framework.'\';
285
+$frameworkPath=\''.$framework . '\';
286 286
 
287 287
 // The following directory checks may be removed if performance is required
288 288
 $basePath=dirname(__FILE__);
@@ -392,22 +392,22 @@  discard block
 block discarded – undo
392 392
 
393 393
 	protected function createTestFixtures($dir)
394 394
 	{
395
-		if(strlen(trim($dir)) == 0)
395
+		if (strlen(trim($dir)) == 0)
396 396
 			return;
397 397
 
398 398
 		$rootPath = realpath(dirname(trim($dir)));
399
-		$basePath = $rootPath.'/'.basename($dir);
399
+		$basePath = $rootPath . '/' . basename($dir);
400 400
 
401
-		$tests = $basePath.'/tests';
402
-		$unit_tests = $tests.'/unit';
403
-		$functional_tests = $tests.'/functional';
401
+		$tests = $basePath . '/tests';
402
+		$unit_tests = $tests . '/unit';
403
+		$functional_tests = $tests . '/functional';
404 404
 
405
-		$this->createDirectory($tests,0755);
406
-		$this->createDirectory($unit_tests,0755);
407
-		$this->createDirectory($functional_tests,0755);
405
+		$this->createDirectory($tests, 0755);
406
+		$this->createDirectory($unit_tests, 0755);
407
+		$this->createDirectory($functional_tests, 0755);
408 408
 
409
-		$unit_test_index = $tests.'/unit.php';
410
-		$functional_test_index = $tests.'/functional.php';
409
+		$unit_test_index = $tests . '/unit.php';
410
+		$functional_test_index = $tests . '/functional.php';
411 411
 
412 412
 		$this->createFile($unit_test_index, $this->renderUnitTestFixture());
413 413
 		$this->createFile($functional_test_index, $this->renderFunctionalTestFixture());
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 
416 416
 	protected function renderUnitTestFixture()
417 417
 	{
418
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/unit_tests.php';
418
+		$tester = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/unit_tests.php';
419 419
 return '<?php
420 420
 
421
-include_once \''.$tester.'\';
421
+include_once \''.$tester . '\';
422 422
 
423 423
 $app_directory = "../protected";
424 424
 $test_cases = dirname(__FILE__)."/unit";
@@ -430,10 +430,10 @@  discard block
 block discarded – undo
430 430
 
431 431
 	protected function renderFunctionalTestFixture()
432 432
 	{
433
-		$tester = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/functional_tests.php';
433
+		$tester = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/functional_tests.php';
434 434
 return '<?php
435 435
 
436
-include_once \''.$tester.'\';
436
+include_once \''.$tester . '\';
437 437
 
438 438
 $test_cases = dirname(__FILE__)."/functional";
439 439
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 	public function performAction($args)
461 461
 	{
462
-		if(count($args) > 1)
462
+		if (count($args) > 1)
463 463
 			$app = $this->initializePradoApplication($args[1]);
464 464
 		return true;
465 465
 	}
@@ -483,94 +483,94 @@  discard block
 block discarded – undo
483 483
 	public function performAction($args)
484 484
 	{
485 485
 		$dir = realpath($args[1]);
486
-		if($dir !== false && is_dir($dir))
487
-			$this->runUnitTests($dir,$args);
486
+		if ($dir !== false && is_dir($dir))
487
+			$this->runUnitTests($dir, $args);
488 488
 		else
489
-			echo '** Unable to find directory "'.$args[1]."\".\n";
489
+			echo '** Unable to find directory "' . $args[1] . "\".\n";
490 490
 		return true;
491 491
 	}
492 492
 
493 493
 	protected function initializeTestRunner()
494 494
 	{
495
-		$TEST_TOOLS = realpath(dirname(dirname(__FILE__))).'/tests/test_tools/';
495
+		$TEST_TOOLS = realpath(dirname(dirname(__FILE__))) . '/tests/test_tools/';
496 496
 
497
-		require_once($TEST_TOOLS.'/simpletest/unit_tester.php');
498
-		require_once($TEST_TOOLS.'/simpletest/web_tester.php');
499
-		require_once($TEST_TOOLS.'/simpletest/mock_objects.php');
500
-		require_once($TEST_TOOLS.'/simpletest/reporter.php');
497
+		require_once($TEST_TOOLS . '/simpletest/unit_tester.php');
498
+		require_once($TEST_TOOLS . '/simpletest/web_tester.php');
499
+		require_once($TEST_TOOLS . '/simpletest/mock_objects.php');
500
+		require_once($TEST_TOOLS . '/simpletest/reporter.php');
501 501
 	}
502 502
 
503 503
 	protected function runUnitTests($dir, $args)
504 504
 	{
505 505
 		$app_dir = $this->getAppDir($dir);
506
-		if($app_dir !== false)
507
-			$this->initializePradoApplication($app_dir.'/../');
506
+		if ($app_dir !== false)
507
+			$this->initializePradoApplication($app_dir . '/../');
508 508
 
509 509
 		$this->initializeTestRunner();
510 510
 		$test_dir = $this->getTestDir($dir);
511
-		if($test_dir !== false)
511
+		if ($test_dir !== false)
512 512
 		{
513
-			$test =$this->getUnitTestCases($test_dir,$args);
514
-			$running_dir = substr(str_replace(realpath('./'),'',$test_dir),1);
515
-			echo 'Running unit tests in directory "'.$running_dir."\":\n";
513
+			$test = $this->getUnitTestCases($test_dir, $args);
514
+			$running_dir = substr(str_replace(realpath('./'), '', $test_dir), 1);
515
+			echo 'Running unit tests in directory "' . $running_dir . "\":\n";
516 516
 			$test->run(new TextReporter());
517 517
 		}
518 518
 		else
519 519
 		{
520
-			$running_dir = substr(str_replace(realpath('./'),'',$dir),1);
521
-			echo '** Unable to find test directory "'.$running_dir.'/unit" or "'.$running_dir.'/tests/unit".'."\n";
520
+			$running_dir = substr(str_replace(realpath('./'), '', $dir), 1);
521
+			echo '** Unable to find test directory "' . $running_dir . '/unit" or "' . $running_dir . '/tests/unit".' . "\n";
522 522
 		}
523 523
 	}
524 524
 
525 525
 	protected function getAppDir($dir)
526 526
 	{
527
-		$app_dir = realpath($dir.'/protected');
528
-		if($app_dir !== false && is_dir($app_dir))
527
+		$app_dir = realpath($dir . '/protected');
528
+		if ($app_dir !== false && is_dir($app_dir))
529 529
 			return $app_dir;
530
-		return realpath($dir.'/../protected');
530
+		return realpath($dir . '/../protected');
531 531
 	}
532 532
 
533 533
 	protected function getTestDir($dir)
534 534
 	{
535
-		$test_dir = realpath($dir.'/unit');
536
-		if($test_dir !== false && is_dir($test_dir))
535
+		$test_dir = realpath($dir . '/unit');
536
+		if ($test_dir !== false && is_dir($test_dir))
537 537
 			return $test_dir;
538
-		return realpath($dir.'/tests/unit/');
538
+		return realpath($dir . '/tests/unit/');
539 539
 	}
540 540
 
541
-	protected function getUnitTestCases($dir,$args)
541
+	protected function getUnitTestCases($dir, $args)
542 542
 	{
543 543
 		$matches = null;
544
-		if(count($args) > 2)
545
-			$matches = array_slice($args,2);
546
-		$test=new GroupTest(' ');
547
-		$this->addTests($test,$dir,true,$matches);
548
-		$test->setLabel(implode(' ',$this->matches));
544
+		if (count($args) > 2)
545
+			$matches = array_slice($args, 2);
546
+		$test = new GroupTest(' ');
547
+		$this->addTests($test, $dir, true, $matches);
548
+		$test->setLabel(implode(' ', $this->matches));
549 549
 		return $test;
550 550
 	}
551 551
 
552
-	protected function addTests($test,$path,$recursive=true,$match=null)
552
+	protected function addTests($test, $path, $recursive = true, $match = null)
553 553
 	{
554
-		$dir=opendir($path);
555
-		while(($entry=readdir($dir))!==false)
554
+		$dir = opendir($path);
555
+		while (($entry = readdir($dir)) !== false)
556 556
 		{
557
-			if(is_file($path.'/'.$entry) && (preg_match('/[^\s]*test[^\s]*\.php/', strtolower($entry))))
557
+			if (is_file($path . '/' . $entry) && (preg_match('/[^\s]*test[^\s]*\.php/', strtolower($entry))))
558 558
 			{
559
-				if($match==null||($match!=null && $this->hasMatch($match,$entry)))
560
-					$test->addTestFile($path.'/'.$entry);
559
+				if ($match == null || ($match != null && $this->hasMatch($match, $entry)))
560
+					$test->addTestFile($path . '/' . $entry);
561 561
 			}
562
-			if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive)
563
-				$this->addTests($test,$path.'/'.$entry,$recursive,$match);
562
+			if ($entry !== '.' && $entry !== '..' && is_dir($path . '/' . $entry) && $recursive)
563
+				$this->addTests($test, $path . '/' . $entry, $recursive, $match);
564 564
 		}
565 565
 		closedir($dir);
566 566
 	}
567 567
 
568
-	protected function hasMatch($match,$entry)
568
+	protected function hasMatch($match, $entry)
569 569
 	{
570
-		$file = strtolower(substr($entry,0,strrpos($entry,'.')));
571
-		foreach($match as $m)
570
+		$file = strtolower(substr($entry, 0, strrpos($entry, '.')));
571
+		foreach ($match as $m)
572 572
 		{
573
-			if(strtolower($m) === $file)
573
+			if (strtolower($m) === $file)
574 574
 			{
575 575
 				$this->matches[] = $m;
576 576
 				return true;
@@ -592,89 +592,89 @@  discard block
 block discarded – undo
592 592
 	protected $parameters = array('table', 'output');
593 593
 	protected $optional = array('directory', 'soap');
594 594
 	protected $description = 'Generate Active Record skeleton for <table> to <output> file using application.xml in [directory]. May also generate [soap] properties.';
595
-	private $_soap=false;
595
+	private $_soap = false;
596 596
 
597 597
 	public function performAction($args)
598 598
 	{
599 599
 		$app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir();
600 600
 		$this->_soap = count($args) > 4;
601
-		if($app_dir !== false)
601
+		if ($app_dir !== false)
602 602
 		{
603 603
 			$config = $this->getActiveRecordConfig($app_dir);
604 604
 			$output = $this->getOutputFile($app_dir, $args[2]);
605
-			if(is_file($output))
605
+			if (is_file($output))
606 606
 				echo "** File $output already exists, skiping. \n";
607
-			else if($config !== false && $output !== false)
607
+			else if ($config !== false && $output !== false)
608 608
 				$this->generateActiveRecord($config, $args[1], $output);
609 609
 		}
610 610
 		return true;
611 611
 	}
612 612
 
613
-	protected function getAppDir($dir=".")
613
+	protected function getAppDir($dir = ".")
614 614
 	{
615
-		if(is_dir($dir))
615
+		if (is_dir($dir))
616 616
 			return realpath($dir);
617
-		if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir))
617
+		if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
618 618
 			return $app_dir;
619
-		echo '** Unable to find directory "'.$dir."\".\n";
619
+		echo '** Unable to find directory "' . $dir . "\".\n";
620 620
 		return false;
621 621
 	}
622 622
 
623 623
 	protected function getXmlFile($app_dir)
624 624
 	{
625
-		if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml))
625
+		if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
626 626
 			return $xml;
627
-		if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml))
627
+		if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
628 628
 			return $xml;
629
-		echo '** Unable to find application.xml in '.$app_dir."\n";
629
+		echo '** Unable to find application.xml in ' . $app_dir . "\n";
630 630
 		return false;
631 631
 	}
632 632
 
633 633
 	protected function getActiveRecordConfig($app_dir)
634 634
 	{
635
-		if(false === ($xml=$this->getXmlFile($app_dir)))
635
+		if (false === ($xml = $this->getXmlFile($app_dir)))
636 636
 			return false;
637
-		if(false !== ($app=$this->initializePradoApplication($app_dir)))
637
+		if (false !== ($app = $this->initializePradoApplication($app_dir)))
638 638
 		{
639 639
 			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
640
-			foreach($app->getModules() as $module)
641
-				if($module instanceof TActiveRecordConfig)
640
+			foreach ($app->getModules() as $module)
641
+				if ($module instanceof TActiveRecordConfig)
642 642
 					return $module;
643
-			echo '** Unable to find TActiveRecordConfig module in '.$xml."\n";
643
+			echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
644 644
 		}
645 645
 		return false;
646 646
 	}
647 647
 
648 648
 	protected function getOutputFile($app_dir, $namespace)
649 649
 	{
650
-		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
650
+		if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
651 651
 				return $namespace;
652 652
 		$file = Prado::getPathOfNamespace($namespace, ".php");
653
-		if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
653
+		if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
654 654
 		{
655
-			if(strpos($path, $app_dir)===0)
655
+			if (strpos($path, $app_dir) === 0)
656 656
 				return $file;
657 657
 		}
658
-		echo '** Output file '.$file.' must be within directory '.$app_dir."\n";
658
+		echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
659 659
 		return false;
660 660
 	}
661 661
 
662 662
 	protected function generateActiveRecord($config, $tablename, $output)
663 663
 	{
664 664
 		$manager = TActiveRecordManager::getInstance();
665
-		if($connection = $manager->getDbConnection()) {
665
+		if ($connection = $manager->getDbConnection()) {
666 666
 			$gateway = $manager->getRecordGateway();
667 667
 			$tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename);
668
-			if(count($tableInfo->getColumns()) === 0)
668
+			if (count($tableInfo->getColumns()) === 0)
669 669
 			{
670
-				echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n";
670
+				echo '** Unable to find table or view "' . $tablename . '" in "' . $manager->getDbConnection()->getConnectionString() . "\".\n";
671 671
 				return false;
672 672
 			}
673 673
 			else
674 674
 			{
675 675
 				$properties = array();
676
-				foreach($tableInfo->getColumns() as $field=>$column)
677
-					$properties[] = $this->generateProperty($field,$column);
676
+				foreach ($tableInfo->getColumns() as $field=>$column)
677
+					$properties[] = $this->generateProperty($field, $column);
678 678
 			}
679 679
 
680 680
 			$classname = basename($output, '.php');
@@ -682,16 +682,16 @@  discard block
 block discarded – undo
682 682
 			echo "  Writing class $classname to file $output\n";
683 683
 			file_put_contents($output, $class);
684 684
 		} else {
685
-			echo '** Unable to connect to database with ConnectionID=\''.$config->getConnectionID()."'. Please check your settings in application.xml and ensure your database connection is set up first.\n";
685
+			echo '** Unable to connect to database with ConnectionID=\'' . $config->getConnectionID() . "'. Please check your settings in application.xml and ensure your database connection is set up first.\n";
686 686
 		}
687 687
 	}
688 688
 
689
-	protected function generateProperty($field,$column)
689
+	protected function generateProperty($field, $column)
690 690
 	{
691 691
 		$prop = '';
692
-		$name = '$'.$field;
692
+		$name = '$' . $field;
693 693
 		$type = $column->getPHPType();
694
-		if($this->_soap)
694
+		if ($this->_soap)
695 695
 		{
696 696
 			$prop .= <<<EOD
697 697
 
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
         return true;
782 782
     }
783 783
 
784
-    protected function getAppDir($dir=".") {
784
+    protected function getAppDir($dir = ".") {
785 785
         if (is_dir($dir))
786 786
             return realpath($dir);
787 787
         if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
@@ -827,17 +827,17 @@  discard block
 block discarded – undo
827 827
 }
828 828
 
829 829
 //run PHP shell
830
-if(class_exists('PHP_Shell_Commands', false))
830
+if (class_exists('PHP_Shell_Commands', false))
831 831
 {
832 832
 	class PHP_Shell_Extensions_ActiveRecord implements PHP_Shell_Extension {
833 833
 	    public function register()
834 834
 	    {
835 835
 
836 836
 	        $cmd = PHP_Shell_Commands::getInstance();
837
-			if(Prado::getApplication() !== null)
837
+			if (Prado::getApplication() !== null)
838 838
 			{
839 839
 		        $cmd->registerCommand('#^generate#', $this, 'generate', 'generate <table> <output> [soap]',
840
-		            'Generate Active Record skeleton for <table> to <output> file using'.PHP_EOL.
840
+		            'Generate Active Record skeleton for <table> to <output> file using' . PHP_EOL .
841 841
 		            '    application.xml in [directory]. May also generate [soap] properties.');
842 842
 			}
843 843
 	    }
@@ -845,14 +845,14 @@  discard block
 block discarded – undo
845 845
 	    public function generate($l)
846 846
 	    {
847 847
 			$input = explode(" ", trim($l));
848
-			if(count($input) > 2)
848
+			if (count($input) > 2)
849 849
 			{
850 850
 				$app_dir = '.';
851
-				if(Prado::getApplication()!==null)
851
+				if (Prado::getApplication() !== null)
852 852
 					$app_dir = dirname(Prado::getApplication()->getBasePath());
853
-				$args = array($input[0],$input[1], $input[2],$app_dir);
854
-				if(count($input)>3)
855
-					$args = array($input[0],$input[1], $input[2],$app_dir,'soap');
853
+				$args = array($input[0], $input[1], $input[2], $app_dir);
854
+				if (count($input) > 3)
855
+					$args = array($input[0], $input[1], $input[2], $app_dir, 'soap');
856 856
 				$cmd = new PradoCommandLineActiveRecordGen;
857 857
 				$cmd->performAction($args);
858 858
 			}
@@ -867,5 +867,5 @@  discard block
 block discarded – undo
867 867
 	$__shell_exts->registerExtensions(array(
868 868
 		    "active-record"        => new PHP_Shell_Extensions_ActiveRecord)); /* the :set command */
869 869
 
870
-	include_once(realpath(dirname(dirname(__FILE__))).'/framework/3rdParty/PhpShell/php-shell-cmd.php');
870
+	include_once(realpath(dirname(dirname(__FILE__))) . '/framework/3rdParty/PhpShell/php-shell-cmd.php');
871 871
 }
Please login to merge, or discard this patch.
Braces   +133 added lines, -96 removed lines patch added patch discarded remove patch
@@ -9,8 +9,9 @@  discard block
 block discarded – undo
9 9
  * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
10 10
  */
11 11
 
12
-if(!isset($_SERVER['argv']) || php_sapi_name()!=='cli')
12
+if(!isset($_SERVER['argv']) || php_sapi_name()!=='cli') {
13 13
 	die('Must be run from the command line');
14
+}
14 15
 
15 16
 $frameworkPath = realpath(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'framework'.DIRECTORY_SEPARATOR;
16 17
 
@@ -32,7 +33,9 @@  discard block
 block discarded – undo
32 33
 {
33 34
 	function __shell_print_var($shell,$var)
34 35
 	{
35
-		if(!$shell->has_semicolon) echo Prado::varDump($var);
36
+		if(!$shell->has_semicolon) {
37
+			echo Prado::varDump($var);
38
+		}
36 39
 	}
37 40
 	include_once($frameworkPath.'/3rdParty/PhpShell/php-shell-init.php');
38 41
 }
@@ -80,8 +83,9 @@  discard block
 block discarded – undo
80 83
 	public static function getInstance()
81 84
 	{
82 85
 		static $instance;
83
-		if($instance === null)
84
-			$instance = new self;
86
+		if($instance === null) {
87
+					$instance = new self;
88
+		}
85 89
 		return $instance;
86 90
 	}
87 91
 
@@ -96,8 +100,9 @@  discard block
 block discarded – undo
96 100
 	 */
97 101
 	public function run($args)
98 102
 	{
99
-		if(count($args) > 1)
100
-			array_shift($args);
103
+		if(count($args) > 1) {
104
+					array_shift($args);
105
+		}
101 106
 		$valid = false;
102 107
 		foreach($this->_actions as $class => $action)
103 108
 		{
@@ -105,14 +110,14 @@  discard block
 block discarded – undo
105 110
 			{
106 111
 				$valid |= $action->performAction($args);
107 112
 				break;
108
-			}
109
-			else
113
+			} else
110 114
 			{
111 115
 				$valid = false;
112 116
 			}
113 117
 		}
114
-		if(!$valid)
115
-			$this->printHelp();
118
+		if(!$valid) {
119
+					$this->printHelp();
120
+		}
116 121
 	}
117 122
 
118 123
 	/**
@@ -125,8 +130,9 @@  discard block
 block discarded – undo
125 130
 		echo "usage: php prado-cli.php action <parameter> [optional]\n";
126 131
 		echo "example: php prado-cli.php -c mysite\n\n";
127 132
 		echo "actions:\n";
128
-		foreach($this->_actions as $action)
129
-			echo $action->renderHelp();
133
+		foreach($this->_actions as $action) {
134
+					echo $action->renderHelp();
135
+		}
130 136
 	}
131 137
 }
132 138
 
@@ -152,8 +158,9 @@  discard block
 block discarded – undo
152 158
 			mkdir($dir);
153 159
 			echo "creating $dir\n";
154 160
 		}
155
-		if(is_dir($dir))
156
-			chmod($dir, $mask);
161
+		if(is_dir($dir)) {
162
+					chmod($dir, $mask);
163
+		}
157 164
 	}
158 165
 
159 166
 	protected function createFile($filename, $content)
@@ -174,16 +181,19 @@  discard block
 block discarded – undo
174 181
 	public function renderHelp()
175 182
 	{
176 183
 		$params = array();
177
-		foreach($this->parameters as $v)
178
-			$params[] = '<'.$v.'>';
184
+		foreach($this->parameters as $v) {
185
+					$params[] = '<'.$v.'>';
186
+		}
179 187
 		$parameters = join($params, ' ');
180 188
 		$options = array();
181
-		foreach($this->optional as $v)
182
-			$options[] = '['.$v.']';
189
+		foreach($this->optional as $v) {
190
+					$options[] = '['.$v.']';
191
+		}
183 192
 		$optional = (strlen($parameters) ? ' ' : ''). join($options, ' ');
184 193
 		$description='';
185
-		foreach(explode("\n", wordwrap($this->description,65)) as $line)
186
-			$description .= '    '.$line."\n";
194
+		foreach(explode("\n", wordwrap($this->description,65)) as $line) {
195
+					$description .= '    '.$line."\n";
196
+		}
187 197
 		return <<<EOD
188 198
   {$this->action} {$parameters}{$optional}
189 199
 {$description}
@@ -207,8 +217,7 @@  discard block
 block discarded – undo
207 217
 			}
208 218
 
209 219
 			return Prado::getApplication();
210
-		}
211
-		else
220
+		} else
212 221
 		{
213 222
 			PradoCommandLineInterpreter::printGreeting();
214 223
 			echo '+'.str_repeat('-',77)."+\n";
@@ -245,15 +254,17 @@  discard block
 block discarded – undo
245 254
 	 */
246 255
 	protected function createNewPradoProject($dir)
247 256
 	{
248
-		if(strlen(trim($dir)) == 0)
249
-			return;
257
+		if(strlen(trim($dir)) == 0) {
258
+					return;
259
+		}
250 260
 
251 261
 		$rootPath = realpath(dirname(trim($dir)));
252 262
 
253
-		if(basename($dir)!=='.')
254
-			$basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir);
255
-		else
256
-			$basePath = $rootPath;
263
+		if(basename($dir)!=='.') {
264
+					$basePath = $rootPath.DIRECTORY_SEPARATOR.basename($dir);
265
+		} else {
266
+					$basePath = $rootPath;
267
+		}
257 268
 		$appName = basename($basePath);
258 269
 		$assetPath = $basePath.DIRECTORY_SEPARATOR.'assets';
259 270
 		$protectedPath  = $basePath.DIRECTORY_SEPARATOR.'protected';
@@ -392,8 +403,9 @@  discard block
 block discarded – undo
392 403
 
393 404
 	protected function createTestFixtures($dir)
394 405
 	{
395
-		if(strlen(trim($dir)) == 0)
396
-			return;
406
+		if(strlen(trim($dir)) == 0) {
407
+					return;
408
+		}
397 409
 
398 410
 		$rootPath = realpath(dirname(trim($dir)));
399 411
 		$basePath = $rootPath.'/'.basename($dir);
@@ -459,8 +471,9 @@  discard block
 block discarded – undo
459 471
 
460 472
 	public function performAction($args)
461 473
 	{
462
-		if(count($args) > 1)
463
-			$app = $this->initializePradoApplication($args[1]);
474
+		if(count($args) > 1) {
475
+					$app = $this->initializePradoApplication($args[1]);
476
+		}
464 477
 		return true;
465 478
 	}
466 479
 }
@@ -483,10 +496,11 @@  discard block
 block discarded – undo
483 496
 	public function performAction($args)
484 497
 	{
485 498
 		$dir = realpath($args[1]);
486
-		if($dir !== false && is_dir($dir))
487
-			$this->runUnitTests($dir,$args);
488
-		else
489
-			echo '** Unable to find directory "'.$args[1]."\".\n";
499
+		if($dir !== false && is_dir($dir)) {
500
+					$this->runUnitTests($dir,$args);
501
+		} else {
502
+					echo '** Unable to find directory "'.$args[1]."\".\n";
503
+		}
490 504
 		return true;
491 505
 	}
492 506
 
@@ -503,8 +517,9 @@  discard block
 block discarded – undo
503 517
 	protected function runUnitTests($dir, $args)
504 518
 	{
505 519
 		$app_dir = $this->getAppDir($dir);
506
-		if($app_dir !== false)
507
-			$this->initializePradoApplication($app_dir.'/../');
520
+		if($app_dir !== false) {
521
+					$this->initializePradoApplication($app_dir.'/../');
522
+		}
508 523
 
509 524
 		$this->initializeTestRunner();
510 525
 		$test_dir = $this->getTestDir($dir);
@@ -514,8 +529,7 @@  discard block
 block discarded – undo
514 529
 			$running_dir = substr(str_replace(realpath('./'),'',$test_dir),1);
515 530
 			echo 'Running unit tests in directory "'.$running_dir."\":\n";
516 531
 			$test->run(new TextReporter());
517
-		}
518
-		else
532
+		} else
519 533
 		{
520 534
 			$running_dir = substr(str_replace(realpath('./'),'',$dir),1);
521 535
 			echo '** Unable to find test directory "'.$running_dir.'/unit" or "'.$running_dir.'/tests/unit".'."\n";
@@ -525,24 +539,27 @@  discard block
 block discarded – undo
525 539
 	protected function getAppDir($dir)
526 540
 	{
527 541
 		$app_dir = realpath($dir.'/protected');
528
-		if($app_dir !== false && is_dir($app_dir))
529
-			return $app_dir;
542
+		if($app_dir !== false && is_dir($app_dir)) {
543
+					return $app_dir;
544
+		}
530 545
 		return realpath($dir.'/../protected');
531 546
 	}
532 547
 
533 548
 	protected function getTestDir($dir)
534 549
 	{
535 550
 		$test_dir = realpath($dir.'/unit');
536
-		if($test_dir !== false && is_dir($test_dir))
537
-			return $test_dir;
551
+		if($test_dir !== false && is_dir($test_dir)) {
552
+					return $test_dir;
553
+		}
538 554
 		return realpath($dir.'/tests/unit/');
539 555
 	}
540 556
 
541 557
 	protected function getUnitTestCases($dir,$args)
542 558
 	{
543 559
 		$matches = null;
544
-		if(count($args) > 2)
545
-			$matches = array_slice($args,2);
560
+		if(count($args) > 2) {
561
+					$matches = array_slice($args,2);
562
+		}
546 563
 		$test=new GroupTest(' ');
547 564
 		$this->addTests($test,$dir,true,$matches);
548 565
 		$test->setLabel(implode(' ',$this->matches));
@@ -556,11 +573,13 @@  discard block
 block discarded – undo
556 573
 		{
557 574
 			if(is_file($path.'/'.$entry) && (preg_match('/[^\s]*test[^\s]*\.php/', strtolower($entry))))
558 575
 			{
559
-				if($match==null||($match!=null && $this->hasMatch($match,$entry)))
560
-					$test->addTestFile($path.'/'.$entry);
576
+				if($match==null||($match!=null && $this->hasMatch($match,$entry))) {
577
+									$test->addTestFile($path.'/'.$entry);
578
+				}
579
+			}
580
+			if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive) {
581
+							$this->addTests($test,$path.'/'.$entry,$recursive,$match);
561 582
 			}
562
-			if($entry!=='.' && $entry!=='..' && is_dir($path.'/'.$entry) && $recursive)
563
-				$this->addTests($test,$path.'/'.$entry,$recursive,$match);
564 583
 		}
565 584
 		closedir($dir);
566 585
 	}
@@ -602,44 +621,51 @@  discard block
 block discarded – undo
602 621
 		{
603 622
 			$config = $this->getActiveRecordConfig($app_dir);
604 623
 			$output = $this->getOutputFile($app_dir, $args[2]);
605
-			if(is_file($output))
606
-				echo "** File $output already exists, skiping. \n";
607
-			else if($config !== false && $output !== false)
608
-				$this->generateActiveRecord($config, $args[1], $output);
624
+			if(is_file($output)) {
625
+							echo "** File $output already exists, skiping. \n";
626
+			} else if($config !== false && $output !== false) {
627
+							$this->generateActiveRecord($config, $args[1], $output);
628
+			}
609 629
 		}
610 630
 		return true;
611 631
 	}
612 632
 
613 633
 	protected function getAppDir($dir=".")
614 634
 	{
615
-		if(is_dir($dir))
616
-			return realpath($dir);
617
-		if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir))
618
-			return $app_dir;
635
+		if(is_dir($dir)) {
636
+					return realpath($dir);
637
+		}
638
+		if(false !== ($app_dir = realpath($dir.'/protected/')) && is_dir($app_dir)) {
639
+					return $app_dir;
640
+		}
619 641
 		echo '** Unable to find directory "'.$dir."\".\n";
620 642
 		return false;
621 643
 	}
622 644
 
623 645
 	protected function getXmlFile($app_dir)
624 646
 	{
625
-		if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml))
626
-			return $xml;
627
-		if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml))
628
-			return $xml;
647
+		if(false !== ($xml = realpath($app_dir.'/application.xml')) && is_file($xml)) {
648
+					return $xml;
649
+		}
650
+		if(false !== ($xml = realpath($app_dir.'/protected/application.xml')) && is_file($xml)) {
651
+					return $xml;
652
+		}
629 653
 		echo '** Unable to find application.xml in '.$app_dir."\n";
630 654
 		return false;
631 655
 	}
632 656
 
633 657
 	protected function getActiveRecordConfig($app_dir)
634 658
 	{
635
-		if(false === ($xml=$this->getXmlFile($app_dir)))
636
-			return false;
659
+		if(false === ($xml=$this->getXmlFile($app_dir))) {
660
+					return false;
661
+		}
637 662
 		if(false !== ($app=$this->initializePradoApplication($app_dir)))
638 663
 		{
639 664
 			Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
640
-			foreach($app->getModules() as $module)
641
-				if($module instanceof TActiveRecordConfig)
665
+			foreach($app->getModules() as $module) {
666
+							if($module instanceof TActiveRecordConfig)
642 667
 					return $module;
668
+			}
643 669
 			echo '** Unable to find TActiveRecordConfig module in '.$xml."\n";
644 670
 		}
645 671
 		return false;
@@ -647,13 +673,15 @@  discard block
 block discarded – undo
647 673
 
648 674
 	protected function getOutputFile($app_dir, $namespace)
649 675
 	{
650
-		if(is_file($namespace) && strpos($namespace, $app_dir)===0)
651
-				return $namespace;
676
+		if(is_file($namespace) && strpos($namespace, $app_dir)===0) {
677
+						return $namespace;
678
+		}
652 679
 		$file = Prado::getPathOfNamespace($namespace, ".php");
653 680
 		if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path))
654 681
 		{
655
-			if(strpos($path, $app_dir)===0)
656
-				return $file;
682
+			if(strpos($path, $app_dir)===0) {
683
+							return $file;
684
+			}
657 685
 		}
658 686
 		echo '** Output file '.$file.' must be within directory '.$app_dir."\n";
659 687
 		return false;
@@ -669,12 +697,12 @@  discard block
 block discarded – undo
669 697
 			{
670 698
 				echo '** Unable to find table or view "'.$tablename.'" in "'.$manager->getDbConnection()->getConnectionString()."\".\n";
671 699
 				return false;
672
-			}
673
-			else
700
+			} else
674 701
 			{
675 702
 				$properties = array();
676
-				foreach($tableInfo->getColumns() as $field=>$column)
677
-					$properties[] = $this->generateProperty($field,$column);
703
+				foreach($tableInfo->getColumns() as $field=>$column) {
704
+									$properties[] = $this->generateProperty($field,$column);
705
+				}
678 706
 			}
679 707
 
680 708
 			$classname = basename($output, '.php');
@@ -782,43 +810,51 @@  discard block
 block discarded – undo
782 810
     }
783 811
 
784 812
     protected function getAppDir($dir=".") {
785
-        if (is_dir($dir))
786
-            return realpath($dir);
787
-        if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir))
788
-            return $app_dir;
813
+        if (is_dir($dir)) {
814
+                    return realpath($dir);
815
+        }
816
+        if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) {
817
+                    return $app_dir;
818
+        }
789 819
         echo '** Unable to find directory "' . $dir . "\".\n";
790 820
         return false;
791 821
     }
792 822
 
793 823
     protected function getXmlFile($app_dir) {
794
-        if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml))
795
-            return $xml;
796
-        if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml))
797
-            return $xml;
824
+        if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) {
825
+                    return $xml;
826
+        }
827
+        if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) {
828
+                    return $xml;
829
+        }
798 830
         echo '** Unable to find application.xml in ' . $app_dir . "\n";
799 831
         return false;
800 832
     }
801 833
 
802 834
     protected function getActiveRecordConfig($app_dir) {
803
-        if (false === ($xml = $this->getXmlFile($app_dir)))
804
-            return false;
835
+        if (false === ($xml = $this->getXmlFile($app_dir))) {
836
+                    return false;
837
+        }
805 838
         if (false !== ($app = $this->initializePradoApplication($app_dir))) {
806 839
             Prado::using('System.Data.ActiveRecord.TActiveRecordConfig');
807
-            foreach ($app->getModules() as $module)
808
-                if ($module instanceof TActiveRecordConfig)
840
+            foreach ($app->getModules() as $module) {
841
+                            if ($module instanceof TActiveRecordConfig)
809 842
                     return $module;
843
+            }
810 844
             echo '** Unable to find TActiveRecordConfig module in ' . $xml . "\n";
811 845
         }
812 846
         return false;
813 847
     }
814 848
 
815 849
     protected function getOutputFile($app_dir, $namespace) {
816
-        if (is_file($namespace) && strpos($namespace, $app_dir) === 0)
817
-            return $namespace;
850
+        if (is_file($namespace) && strpos($namespace, $app_dir) === 0) {
851
+                    return $namespace;
852
+        }
818 853
         $file = Prado::getPathOfNamespace($namespace, "");
819 854
         if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) {
820
-            if (strpos($path, $app_dir) === 0)
821
-                return $file;
855
+            if (strpos($path, $app_dir) === 0) {
856
+                            return $file;
857
+            }
822 858
         }
823 859
         echo '** Output file ' . $file . ' must be within directory ' . $app_dir . "\n";
824 860
         return false;
@@ -848,15 +884,16 @@  discard block
 block discarded – undo
848 884
 			if(count($input) > 2)
849 885
 			{
850 886
 				$app_dir = '.';
851
-				if(Prado::getApplication()!==null)
852
-					$app_dir = dirname(Prado::getApplication()->getBasePath());
887
+				if(Prado::getApplication()!==null) {
888
+									$app_dir = dirname(Prado::getApplication()->getBasePath());
889
+				}
853 890
 				$args = array($input[0],$input[1], $input[2],$app_dir);
854
-				if(count($input)>3)
855
-					$args = array($input[0],$input[1], $input[2],$app_dir,'soap');
891
+				if(count($input)>3) {
892
+									$args = array($input[0],$input[1], $input[2],$app_dir,'soap');
893
+				}
856 894
 				$cmd = new PradoCommandLineActiveRecordGen;
857 895
 				$cmd->performAction($args);
858
-			}
859
-			else
896
+			} else
860 897
 			{
861 898
 				echo "\n    Usage: generate table_name Application.pages.RecordClassName\n";
862 899
 			}
Please login to merge, or discard this patch.
buildscripts/Benchmark/Profiler.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -233,6 +233,7 @@  discard block
 block discarded – undo
233 233
      * Returns formatted profiling information.
234 234
      *
235 235
      * @param  string output format (auto, plain or html), default auto
236
+     * @param string $format
236 237
      * @see    display()
237 238
      * @access private
238 239
      */
@@ -363,6 +364,7 @@  discard block
 block discarded – undo
363 364
      * Enters code section.
364 365
      *
365 366
      * @param  string  name of the code section
367
+     * @param string $name
366 368
      * @see    start(), leaveSection()
367 369
      * @access public
368 370
      */
@@ -398,6 +400,7 @@  discard block
 block discarded – undo
398 400
      * Leaves code section.
399 401
      *
400 402
      * @param  string  name of the marker to be set
403
+     * @param string $name
401 404
      * @see     stop(), enterSection()
402 405
      * @access public
403 406
      */
@@ -436,7 +439,7 @@  discard block
 block discarded – undo
436 439
     /**
437 440
      * Wrapper for microtime().
438 441
      *
439
-     * @return float
442
+     * @return string
440 443
      * @access private
441 444
      * @since  1.3.0
442 445
      */
Please login to merge, or discard this patch.
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -77,371 +77,371 @@
 block discarded – undo
77 77
  * @since     1.2.0
78 78
  */
79 79
 class Benchmark_Profiler extends PEAR {
80
-    /**
81
-     * Contains the total ex. time of each section
82
-     *
83
-     * @var    array
84
-     * @access private
85
-     */
86
-    var $_sections = array();
87
-
88
-    /**
89
-     * Calling stack
90
-     *
91
-     * @var    array
92
-     * @access private
93
-     */
94
-    var $_stack = array();
95
-
96
-    /**
97
-     * Notes how often a section was entered
98
-     *
99
-     * @var    array
100
-     * @access private
101
-     */
102
-    var $_numberOfCalls = array();
103
-
104
-    /**
105
-     * Notes for each section how much time is spend in sub-sections
106
-     *
107
-     * @var    array
108
-     * @access private
109
-     */
110
-    var $_subSectionsTime = array();
111
-
112
-    /**
113
-     * Notes for each section how often it calls which section
114
-     *
115
-     * @var    array
116
-     * @access private
117
-     */
118
-    var $_calls = array();
119
-
120
-    /**
121
-     * Notes for each section how often it was called by which section
122
-     *
123
-     * @var    array
124
-     * @access private
125
-     */
126
-    var $_callers = array();
127
-
128
-    /**
129
-     * Auto-starts and stops profiler
130
-     *
131
-     * @var    boolean
132
-     * @access private
133
-     */
134
-    var $_auto = FALSE;
135
-
136
-    /**
137
-     * Max marker name length for non-html output
138
-     *
139
-     * @var    integer
140
-     * @access private
141
-     */
142
-    var $_maxStringLength = 0;
143
-
144
-    /**
145
-     * Constructor, starts profiling recording
146
-     *
147
-     * @access public
148
-     */
149
-    function Benchmark_Profiler($auto = FALSE) {
150
-        $this->_auto = $auto;
151
-
152
-        if ($this->_auto) {
153
-            $this->start();
154
-        }
155
-
156
-        $this->PEAR();
157
-    }
158
-
159
-    /**
160
-     * Destructor, stops profiling recording
161
-     *
162
-     * @access private
163
-     */
164
-    function _Benchmark_Profiler() {
165
-        if (isset($this->_auto) && $this->_auto) {
166
-            $this->stop();
167
-            $this->display();
168
-        }
169
-    }
170
-
171
-    /**
172
-     * Returns profiling informations for a given section.
173
-     *
174
-     * @param  string $section
175
-     * @return array
176
-     * @access public
177
-     */
178
-    function getSectionInformations($section = 'Global') {
179
-        if (isset($this->_sections[$section])) {
180
-            $calls = array();
181
-
182
-            if (isset($this->_calls[$section])) {
183
-                $calls = $this->_calls[$section];
184
-            }
185
-
186
-            $callers = array();
187
-
188
-            if (isset($this->_callers[$section])) {
189
-                $callers = $this->_callers[$section];
190
-            }
191
-
192
-            $informations = array();
193
-
194
-            $informations['time']       = $this->_sections[$section];
195
-            if (isset($this->_sections['Global'])) {
196
-                $informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', '');
197
-            } else {
198
-                $informations['percentage'] = 'N/A';
199
-            }
200
-            $informations['calls']      = $calls;
201
-            $informations['num_calls']  = $this->_numberOfCalls[$section];
202
-            $informations['callers']    = $callers;
203
-
204
-      	    if (isset($this->_subSectionsTime[$section])) {
205
-                $informations['netto_time'] = $this->_sections[$section] - $this->_subSectionsTime[$section];
206
-      	    } else {
207
-                $informations['netto_time'] = $this->_sections[$section];
208
-      	    }
209
-
210
-            return $informations;
211
-        } else {
212
-            $this->raiseError("The section '$section' does not exists.\n", NULL, PEAR_ERROR_TRIGGER, E_USER_WARNING);
213
-        }
214
-    }
215
-
216
-    /**
217
-     * Returns profiling informations for all sections.
218
-     *
219
-     * @return array
220
-     * @access public
221
-     */
222
-    function getAllSectionsInformations() {
223
-        $informations = array();
224
-
225
-        foreach($this->_sections as $section => $time) {
226
-            $informations[$section] = $this->getSectionInformations($section);
227
-        }
228
-
229
-        return $informations;
230
-    }
231
-
232
-    /**
233
-     * Returns formatted profiling information.
234
-     *
235
-     * @param  string output format (auto, plain or html), default auto
236
-     * @see    display()
237
-     * @access private
238
-     */
239
-    function _getOutput($format) {
80
+	/**
81
+	 * Contains the total ex. time of each section
82
+	 *
83
+	 * @var    array
84
+	 * @access private
85
+	 */
86
+	var $_sections = array();
87
+
88
+	/**
89
+	 * Calling stack
90
+	 *
91
+	 * @var    array
92
+	 * @access private
93
+	 */
94
+	var $_stack = array();
95
+
96
+	/**
97
+	 * Notes how often a section was entered
98
+	 *
99
+	 * @var    array
100
+	 * @access private
101
+	 */
102
+	var $_numberOfCalls = array();
103
+
104
+	/**
105
+	 * Notes for each section how much time is spend in sub-sections
106
+	 *
107
+	 * @var    array
108
+	 * @access private
109
+	 */
110
+	var $_subSectionsTime = array();
111
+
112
+	/**
113
+	 * Notes for each section how often it calls which section
114
+	 *
115
+	 * @var    array
116
+	 * @access private
117
+	 */
118
+	var $_calls = array();
119
+
120
+	/**
121
+	 * Notes for each section how often it was called by which section
122
+	 *
123
+	 * @var    array
124
+	 * @access private
125
+	 */
126
+	var $_callers = array();
127
+
128
+	/**
129
+	 * Auto-starts and stops profiler
130
+	 *
131
+	 * @var    boolean
132
+	 * @access private
133
+	 */
134
+	var $_auto = FALSE;
135
+
136
+	/**
137
+	 * Max marker name length for non-html output
138
+	 *
139
+	 * @var    integer
140
+	 * @access private
141
+	 */
142
+	var $_maxStringLength = 0;
143
+
144
+	/**
145
+	 * Constructor, starts profiling recording
146
+	 *
147
+	 * @access public
148
+	 */
149
+	function Benchmark_Profiler($auto = FALSE) {
150
+		$this->_auto = $auto;
151
+
152
+		if ($this->_auto) {
153
+			$this->start();
154
+		}
155
+
156
+		$this->PEAR();
157
+	}
158
+
159
+	/**
160
+	 * Destructor, stops profiling recording
161
+	 *
162
+	 * @access private
163
+	 */
164
+	function _Benchmark_Profiler() {
165
+		if (isset($this->_auto) && $this->_auto) {
166
+			$this->stop();
167
+			$this->display();
168
+		}
169
+	}
170
+
171
+	/**
172
+	 * Returns profiling informations for a given section.
173
+	 *
174
+	 * @param  string $section
175
+	 * @return array
176
+	 * @access public
177
+	 */
178
+	function getSectionInformations($section = 'Global') {
179
+		if (isset($this->_sections[$section])) {
180
+			$calls = array();
181
+
182
+			if (isset($this->_calls[$section])) {
183
+				$calls = $this->_calls[$section];
184
+			}
185
+
186
+			$callers = array();
187
+
188
+			if (isset($this->_callers[$section])) {
189
+				$callers = $this->_callers[$section];
190
+			}
191
+
192
+			$informations = array();
193
+
194
+			$informations['time']       = $this->_sections[$section];
195
+			if (isset($this->_sections['Global'])) {
196
+				$informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', '');
197
+			} else {
198
+				$informations['percentage'] = 'N/A';
199
+			}
200
+			$informations['calls']      = $calls;
201
+			$informations['num_calls']  = $this->_numberOfCalls[$section];
202
+			$informations['callers']    = $callers;
203
+
204
+	  		if (isset($this->_subSectionsTime[$section])) {
205
+				$informations['netto_time'] = $this->_sections[$section] - $this->_subSectionsTime[$section];
206
+	  		} else {
207
+				$informations['netto_time'] = $this->_sections[$section];
208
+	  		}
209
+
210
+			return $informations;
211
+		} else {
212
+			$this->raiseError("The section '$section' does not exists.\n", NULL, PEAR_ERROR_TRIGGER, E_USER_WARNING);
213
+		}
214
+	}
215
+
216
+	/**
217
+	 * Returns profiling informations for all sections.
218
+	 *
219
+	 * @return array
220
+	 * @access public
221
+	 */
222
+	function getAllSectionsInformations() {
223
+		$informations = array();
224
+
225
+		foreach($this->_sections as $section => $time) {
226
+			$informations[$section] = $this->getSectionInformations($section);
227
+		}
228
+
229
+		return $informations;
230
+	}
231
+
232
+	/**
233
+	 * Returns formatted profiling information.
234
+	 *
235
+	 * @param  string output format (auto, plain or html), default auto
236
+	 * @see    display()
237
+	 * @access private
238
+	 */
239
+	function _getOutput($format) {
240 240
         
241
-        /* Quickly find out the maximun length: Ineffecient, but will do for now! */
242
-        $informations = $this->getAllSectionsInformations();
243
-        $names = array_keys($informations);
241
+		/* Quickly find out the maximun length: Ineffecient, but will do for now! */
242
+		$informations = $this->getAllSectionsInformations();
243
+		$names = array_keys($informations);
244 244
         
245
-        $maxLength = 0;
246
-        foreach ($names as $name)
247
-        {
248
-            if ($maxLength < strlen($name)) {
249
-                $maxLength = strlen($name);
250
-            }
251
-        }
252
-        $this->_maxStringLength = $maxLength;
253
-
254
-        if ($format == 'auto') {
255
-            if (function_exists('version_compare') &&
256
-                version_compare(phpversion(), '4.1', 'ge')) {
257
-                $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain';
258
-            } else {
259
-                global $HTTP_SERVER_VARS;
260
-                $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain';
261
-            }
262
-        }
263
-
264
-        if ($format == 'html') {
265
-            $out = '<table style="border: 1px solid #000000; ">'."\n";
266
-            $out .=
267
-                '<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>'.
268
-                '<td align="center"><b>netto ex. time</b></td>'.
269
-                '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'.
270
-                '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'.
271
-                "\n";
272
-        } else {
273
-            $dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT);
274
-            $out .= str_pad('Section', $this->_maxStringLength + 10);
275
-            $out .= str_pad("Total Ex Time", 22);
276
-            $out .= str_pad("Netto Ex Time", 22);
277
-            $out .= str_pad("#Calls", 10);
278
-            $out .= "Percentage\n";
279
-            $out .= $dashes;
280
-        }
245
+		$maxLength = 0;
246
+		foreach ($names as $name)
247
+		{
248
+			if ($maxLength < strlen($name)) {
249
+				$maxLength = strlen($name);
250
+			}
251
+		}
252
+		$this->_maxStringLength = $maxLength;
253
+
254
+		if ($format == 'auto') {
255
+			if (function_exists('version_compare') &&
256
+				version_compare(phpversion(), '4.1', 'ge')) {
257
+				$format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain';
258
+			} else {
259
+				global $HTTP_SERVER_VARS;
260
+				$format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain';
261
+			}
262
+		}
263
+
264
+		if ($format == 'html') {
265
+			$out = '<table style="border: 1px solid #000000; ">'."\n";
266
+			$out .=
267
+				'<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>'.
268
+				'<td align="center"><b>netto ex. time</b></td>'.
269
+				'<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'.
270
+				'<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'.
271
+				"\n";
272
+		} else {
273
+			$dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT);
274
+			$out .= str_pad('Section', $this->_maxStringLength + 10);
275
+			$out .= str_pad("Total Ex Time", 22);
276
+			$out .= str_pad("Netto Ex Time", 22);
277
+			$out .= str_pad("#Calls", 10);
278
+			$out .= "Percentage\n";
279
+			$out .= $dashes;
280
+		}
281 281
            
282
-        foreach($informations as $name => $values) {
283
-            $percentage = $values['percentage'];
284
-            $calls_str = "";
285
-
286
-            foreach($values['calls'] as $key => $val) {
287
-                if ($calls_str) {
288
-                    $calls_str .= ", ";
289
-                }
290
-
291
-                $calls_str .= "$key ($val)";
292
-            }
293
-
294
-            $callers_str = "";
295
-
296
-            foreach($values['callers'] as $key => $val) {
297
-                if ($callers_str) {
298
-                    $callers_str .= ", ";
299
-    		        }
300
-
301
-                $callers_str .= "$key ($val)";
302
-            }
303
-
304
-            if ($format == 'html') {
305
-                $out .= "<tr><td><b>$name</b></td><td>{$values['time']}</td><td>{$values['netto_time']}</td><td>{$values['num_calls']}</td>";
306
-                if (is_numeric($values['percentage'])) {
307
-                    $out .= "<td align=\"right\">{$values['percentage']}%</td>\n";
308
-                } else {
309
-                    $out .= "<td align=\"right\">{$values['percentage']}</td>\n";
310
-                }
311
-                $out .= "<td>$calls_str</td><td>$callers_str</td></tr>";
312
-            } else {
313
-                $out .= str_pad($name, $this->_maxStringLength + 10);
314
-                $out .= str_pad($values['time'], 22);
315
-                $out .= str_pad($values['netto_time'], 22);
316
-                $out .= str_pad($values['num_calls'], 10);
317
-                if (is_numeric($values['percentage'])) {
318
-                    $out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT);
319
-                } else {
320
-                    $out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT);
321
-                }
322
-            }
323
-        }
282
+		foreach($informations as $name => $values) {
283
+			$percentage = $values['percentage'];
284
+			$calls_str = "";
285
+
286
+			foreach($values['calls'] as $key => $val) {
287
+				if ($calls_str) {
288
+					$calls_str .= ", ";
289
+				}
290
+
291
+				$calls_str .= "$key ($val)";
292
+			}
293
+
294
+			$callers_str = "";
295
+
296
+			foreach($values['callers'] as $key => $val) {
297
+				if ($callers_str) {
298
+					$callers_str .= ", ";
299
+					}
300
+
301
+				$callers_str .= "$key ($val)";
302
+			}
303
+
304
+			if ($format == 'html') {
305
+				$out .= "<tr><td><b>$name</b></td><td>{$values['time']}</td><td>{$values['netto_time']}</td><td>{$values['num_calls']}</td>";
306
+				if (is_numeric($values['percentage'])) {
307
+					$out .= "<td align=\"right\">{$values['percentage']}%</td>\n";
308
+				} else {
309
+					$out .= "<td align=\"right\">{$values['percentage']}</td>\n";
310
+				}
311
+				$out .= "<td>$calls_str</td><td>$callers_str</td></tr>";
312
+			} else {
313
+				$out .= str_pad($name, $this->_maxStringLength + 10);
314
+				$out .= str_pad($values['time'], 22);
315
+				$out .= str_pad($values['netto_time'], 22);
316
+				$out .= str_pad($values['num_calls'], 10);
317
+				if (is_numeric($values['percentage'])) {
318
+					$out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT);
319
+				} else {
320
+					$out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT);
321
+				}
322
+			}
323
+		}
324 324
         
325
-        if ($format == 'html') {
326
-            return $out . '</table>';
327
-        } else {
328
-            return $out;
329
-        }
330
-    }
331
-
332
-    /**
333
-     * Returns formatted profiling information.
334
-     *
335
-     * @param  string output format (auto, plain or html), default auto
336
-     * @access public
337
-     */
338
-    function display($format = 'auto') {
339
-        echo $this->_getOutput($format);
340
-    }
341
-
342
-    /**
343
-     * Enters "Global" section.
344
-     *
345
-     * @see    enterSection(), stop()
346
-     * @access public
347
-     */
348
-    function start() {
349
-        $this->enterSection('Global');
350
-    }
351
-
352
-    /**
353
-     * Leaves "Global" section.
354
-     *
355
-     * @see    leaveSection(), start()
356
-     * @access public
357
-     */
358
-    function stop() {
359
-        $this->leaveSection('Global');
360
-    }
361
-
362
-    /**
363
-     * Enters code section.
364
-     *
365
-     * @param  string  name of the code section
366
-     * @see    start(), leaveSection()
367
-     * @access public
368
-     */
369
-    function enterSection($name) {
370
-        if (count($this->_stack)) {
371
-            if (isset($this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]])) {
372
-                $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]]++;
373
-            } else {
374
-                $this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]] = 1;
375
-            }
376
-
377
-            if (isset($this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name])) {
378
-                $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name]++;
379
-            } else {
380
-                $this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name] = 1;
381
-            }
382
-        } else {
383
-            if ($name != 'Global') {
384
-                $this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
385
-            }
386
-        }
387
-
388
-        if (isset($this->_numberOfCalls[$name])) {
389
-            $this->_numberOfCalls[$name]++;
390
-        } else {
391
-            $this->_numberOfCalls[$name] = 1;
392
-        }
393
-
394
-        array_push($this->_stack, array("name" => $name, "time" => $this->_getMicrotime()));
395
-    }
396
-
397
-    /**
398
-     * Leaves code section.
399
-     *
400
-     * @param  string  name of the marker to be set
401
-     * @see     stop(), enterSection()
402
-     * @access public
403
-     */
404
-    function leaveSection($name) {
405
-        $microtime = $this->_getMicrotime();
406
-
407
-        if (!count($this->_stack)) {
408
-            $this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
409
-        }
410
-
411
-        $x = array_pop($this->_stack);
412
-
413
-        if ($x["name"] != $name) {
414
-            $this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE);
415
-        }
416
-
417
-        if (isset($this->_sections[$name])) {
418
-            $this->_sections[$name] += $microtime - $x["time"];
419
-        } else {
420
-            $this->_sections[$name] = $microtime - $x["time"];
421
-        }
422
-
423
-        $parent = array_pop($this->_stack);
424
-
425
-      	if (isset($parent)) {
426
-            if (isset($this->_subSectionsTime[$parent['name']])) {
427
-                $this->_subSectionsTime[$parent['name']] += $microtime - $x['time'];
428
-            } else {
429
-                $this->_subSectionsTime[$parent['name']] = $microtime - $x['time'];
430
-            }
431
-
432
-            array_push($this->_stack, $parent);
433
-        }
434
-    }
435
-
436
-    /**
437
-     * Wrapper for microtime().
438
-     *
439
-     * @return float
440
-     * @access private
441
-     * @since  1.3.0
442
-     */
443
-    function _getMicrotime() {
444
-        $microtime = explode(' ', microtime());
445
-        return $microtime[1] . substr($microtime[0], 1);
446
-    }
325
+		if ($format == 'html') {
326
+			return $out . '</table>';
327
+		} else {
328
+			return $out;
329
+		}
330
+	}
331
+
332
+	/**
333
+	 * Returns formatted profiling information.
334
+	 *
335
+	 * @param  string output format (auto, plain or html), default auto
336
+	 * @access public
337
+	 */
338
+	function display($format = 'auto') {
339
+		echo $this->_getOutput($format);
340
+	}
341
+
342
+	/**
343
+	 * Enters "Global" section.
344
+	 *
345
+	 * @see    enterSection(), stop()
346
+	 * @access public
347
+	 */
348
+	function start() {
349
+		$this->enterSection('Global');
350
+	}
351
+
352
+	/**
353
+	 * Leaves "Global" section.
354
+	 *
355
+	 * @see    leaveSection(), start()
356
+	 * @access public
357
+	 */
358
+	function stop() {
359
+		$this->leaveSection('Global');
360
+	}
361
+
362
+	/**
363
+	 * Enters code section.
364
+	 *
365
+	 * @param  string  name of the code section
366
+	 * @see    start(), leaveSection()
367
+	 * @access public
368
+	 */
369
+	function enterSection($name) {
370
+		if (count($this->_stack)) {
371
+			if (isset($this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]])) {
372
+				$this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]]++;
373
+			} else {
374
+				$this->_callers[$name][$this->_stack[count($this->_stack) - 1]["name"]] = 1;
375
+			}
376
+
377
+			if (isset($this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name])) {
378
+				$this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name]++;
379
+			} else {
380
+				$this->_calls[$this->_stack[count($this->_stack) - 1]["name"]][$name] = 1;
381
+			}
382
+		} else {
383
+			if ($name != 'Global') {
384
+				$this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
385
+			}
386
+		}
387
+
388
+		if (isset($this->_numberOfCalls[$name])) {
389
+			$this->_numberOfCalls[$name]++;
390
+		} else {
391
+			$this->_numberOfCalls[$name] = 1;
392
+		}
393
+
394
+		array_push($this->_stack, array("name" => $name, "time" => $this->_getMicrotime()));
395
+	}
396
+
397
+	/**
398
+	 * Leaves code section.
399
+	 *
400
+	 * @param  string  name of the marker to be set
401
+	 * @see     stop(), enterSection()
402
+	 * @access public
403
+	 */
404
+	function leaveSection($name) {
405
+		$microtime = $this->_getMicrotime();
406
+
407
+		if (!count($this->_stack)) {
408
+			$this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
409
+		}
410
+
411
+		$x = array_pop($this->_stack);
412
+
413
+		if ($x["name"] != $name) {
414
+			$this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE);
415
+		}
416
+
417
+		if (isset($this->_sections[$name])) {
418
+			$this->_sections[$name] += $microtime - $x["time"];
419
+		} else {
420
+			$this->_sections[$name] = $microtime - $x["time"];
421
+		}
422
+
423
+		$parent = array_pop($this->_stack);
424
+
425
+	  	if (isset($parent)) {
426
+			if (isset($this->_subSectionsTime[$parent['name']])) {
427
+				$this->_subSectionsTime[$parent['name']] += $microtime - $x['time'];
428
+			} else {
429
+				$this->_subSectionsTime[$parent['name']] = $microtime - $x['time'];
430
+			}
431
+
432
+			array_push($this->_stack, $parent);
433
+		}
434
+	}
435
+
436
+	/**
437
+	 * Wrapper for microtime().
438
+	 *
439
+	 * @return float
440
+	 * @access private
441
+	 * @since  1.3.0
442
+	 */
443
+	function _getMicrotime() {
444
+		$microtime = explode(' ', microtime());
445
+		return $microtime[1] . substr($microtime[0], 1);
446
+	}
447 447
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
             $informations = array();
193 193
 
194
-            $informations['time']       = $this->_sections[$section];
194
+            $informations['time'] = $this->_sections[$section];
195 195
             if (isset($this->_sections['Global'])) {
196 196
                 $informations['percentage'] = number_format(100 * $this->_sections[$section] / $this->_sections['Global'], 2, '.', '');
197 197
             } else {
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     function getAllSectionsInformations() {
223 223
         $informations = array();
224 224
 
225
-        foreach($this->_sections as $section => $time) {
225
+        foreach ($this->_sections as $section => $time) {
226 226
             $informations[$section] = $this->getSectionInformations($section);
227 227
         }
228 228
 
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
         }
263 263
 
264 264
         if ($format == 'html') {
265
-            $out = '<table style="border: 1px solid #000000; ">'."\n";
265
+            $out = '<table style="border: 1px solid #000000; ">' . "\n";
266 266
             $out .=
267
-                '<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>'.
268
-                '<td align="center"><b>netto ex. time</b></td>'.
269
-                '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>'.
270
-                '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>'.
267
+                '<tr><td>&nbsp;</td><td align="center"><b>total ex. time</b></td>' .
268
+                '<td align="center"><b>netto ex. time</b></td>' .
269
+                '<td align="center"><b>#calls</b></td><td align="center"><b>%</b></td>' .
270
+                '<td align="center"><b>calls</b></td><td align="center"><b>callers</b></td></tr>' .
271 271
                 "\n";
272 272
         } else {
273 273
             $dashes = $out = str_pad("\n", ($this->_maxStringLength + 75), '-', STR_PAD_LEFT);
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
             $out .= $dashes;
280 280
         }
281 281
            
282
-        foreach($informations as $name => $values) {
282
+        foreach ($informations as $name => $values) {
283 283
             $percentage = $values['percentage'];
284 284
             $calls_str = "";
285 285
 
286
-            foreach($values['calls'] as $key => $val) {
286
+            foreach ($values['calls'] as $key => $val) {
287 287
                 if ($calls_str) {
288 288
                     $calls_str .= ", ";
289 289
                 }
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 
294 294
             $callers_str = "";
295 295
 
296
-            foreach($values['callers'] as $key => $val) {
296
+            foreach ($values['callers'] as $key => $val) {
297 297
                 if ($callers_str) {
298 298
                     $callers_str .= ", ";
299 299
     		        }
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
                 $out .= str_pad($values['netto_time'], 22);
316 316
                 $out .= str_pad($values['num_calls'], 10);
317 317
                 if (is_numeric($values['percentage'])) {
318
-                    $out .= str_pad($values['percentage']."%\n", 8, ' ', STR_PAD_LEFT);
318
+                    $out .= str_pad($values['percentage'] . "%\n", 8, ' ', STR_PAD_LEFT);
319 319
                 } else {
320
-                    $out .= str_pad($values['percentage']."\n", 8, ' ', STR_PAD_LEFT);
320
+                    $out .= str_pad($values['percentage'] . "\n", 8, ' ', STR_PAD_LEFT);
321 321
                 }
322 322
             }
323 323
         }
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
             }
382 382
         } else {
383 383
             if ($name != 'Global') {
384
-                $this->raiseError("tried to enter section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
384
+                $this->raiseError("tried to enter section " . $name . " but profiling was not started\n", NULL, PEAR_ERROR_DIE);
385 385
             }
386 386
         }
387 387
 
@@ -405,13 +405,13 @@  discard block
 block discarded – undo
405 405
         $microtime = $this->_getMicrotime();
406 406
 
407 407
         if (!count($this->_stack)) {
408
-            $this->raiseError("tried to leave section ".$name." but profiling was not started\n", NULL, PEAR_ERROR_DIE);
408
+            $this->raiseError("tried to leave section " . $name . " but profiling was not started\n", NULL, PEAR_ERROR_DIE);
409 409
         }
410 410
 
411 411
         $x = array_pop($this->_stack);
412 412
 
413 413
         if ($x["name"] != $name) {
414
-            $this->raiseError("reached end of section $name but expecting end of " . $x["name"]."\n", NULL, PEAR_ERROR_DIE);
414
+            $this->raiseError("reached end of section $name but expecting end of " . $x["name"] . "\n", NULL, PEAR_ERROR_DIE);
415 415
         }
416 416
 
417 417
         if (isset($this->_sections[$name])) {
Please login to merge, or discard this patch.
buildscripts/Benchmark/Timer.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@
 block discarded – undo
308 308
     /**
309 309
      * Wrapper for microtime().
310 310
      *
311
-     * @return float
311
+     * @return string
312 312
      * @access private
313 313
      * @since  1.3.0
314 314
      */
Please login to merge, or discard this patch.
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -58,262 +58,262 @@
 block discarded – undo
58 58
  * @package   Benchmark
59 59
  */
60 60
 class Benchmark_Timer extends PEAR {
61
-    /**
62
-     * Contains the markers.
63
-     *
64
-     * @var    array
65
-     * @access private
66
-     */
67
-    var $markers = array();
61
+	/**
62
+	 * Contains the markers.
63
+	 *
64
+	 * @var    array
65
+	 * @access private
66
+	 */
67
+	var $markers = array();
68 68
 
69
-    /**
70
-     * Auto-start and stop timer.
71
-     *
72
-     * @var    boolean
73
-     * @access private
74
-     */
75
-    var $auto = FALSE;
69
+	/**
70
+	 * Auto-start and stop timer.
71
+	 *
72
+	 * @var    boolean
73
+	 * @access private
74
+	 */
75
+	var $auto = FALSE;
76 76
 
77
-    /**
78
-     * Max marker name length for non-html output.
79
-     *
80
-     * @var    integer
81
-     * @access private
82
-     */
83
-    var $maxStringLength = 0;
77
+	/**
78
+	 * Max marker name length for non-html output.
79
+	 *
80
+	 * @var    integer
81
+	 * @access private
82
+	 */
83
+	var $maxStringLength = 0;
84 84
 
85
-    /**
86
-     * Constructor.
87
-     *
88
-     * @param  boolean $auto
89
-     * @access public
90
-     */
91
-    function Benchmark_Timer($auto = FALSE) {
92
-        $this->auto = $auto;
85
+	/**
86
+	 * Constructor.
87
+	 *
88
+	 * @param  boolean $auto
89
+	 * @access public
90
+	 */
91
+	function Benchmark_Timer($auto = FALSE) {
92
+		$this->auto = $auto;
93 93
 
94
-        if ($this->auto) {
95
-            $this->start();
96
-        }
94
+		if ($this->auto) {
95
+			$this->start();
96
+		}
97 97
 
98
-        $this->PEAR();
99
-    }
98
+		$this->PEAR();
99
+	}
100 100
 
101
-    /**
102
-     * Destructor.
103
-     *
104
-     * @access private
105
-     */
106
-    function _Benchmark_Timer() {
107
-        if ($this->auto) {
108
-            $this->stop();
109
-            $this->display();
110
-        }
111
-    }
101
+	/**
102
+	 * Destructor.
103
+	 *
104
+	 * @access private
105
+	 */
106
+	function _Benchmark_Timer() {
107
+		if ($this->auto) {
108
+			$this->stop();
109
+			$this->display();
110
+		}
111
+	}
112 112
 
113
-    /**
114
-     * Set "Start" marker.
115
-     *
116
-     * @see    setMarker(), stop()
117
-     * @access public
118
-     */
119
-    function start() {
120
-        $this->setMarker('Start');
121
-    }
113
+	/**
114
+	 * Set "Start" marker.
115
+	 *
116
+	 * @see    setMarker(), stop()
117
+	 * @access public
118
+	 */
119
+	function start() {
120
+		$this->setMarker('Start');
121
+	}
122 122
 
123
-    /**
124
-     * Set "Stop" marker.
125
-     *
126
-     * @see    setMarker(), start()
127
-     * @access public
128
-     */
129
-    function stop() {
130
-        $this->setMarker('Stop');
131
-    }
123
+	/**
124
+	 * Set "Stop" marker.
125
+	 *
126
+	 * @see    setMarker(), start()
127
+	 * @access public
128
+	 */
129
+	function stop() {
130
+		$this->setMarker('Stop');
131
+	}
132 132
 
133
-    /**
134
-     * Set marker.
135
-     *
136
-     * @param  string  $name Name of the marker to be set.
137
-     * @see    start(), stop()
138
-     * @access public
139
-     */
140
-    function setMarker($name) {
141
-        $this->markers[$name] = $this->_getMicrotime();
142
-    }
133
+	/**
134
+	 * Set marker.
135
+	 *
136
+	 * @param  string  $name Name of the marker to be set.
137
+	 * @see    start(), stop()
138
+	 * @access public
139
+	 */
140
+	function setMarker($name) {
141
+		$this->markers[$name] = $this->_getMicrotime();
142
+	}
143 143
 
144
-    /**
145
-     * Returns the time elapsed betweens two markers.
146
-     *
147
-     * @param  string  $start        start marker, defaults to "Start"
148
-     * @param  string  $end          end marker, defaults to "Stop"
149
-     * @return double  $time_elapsed time elapsed between $start and $end
150
-     * @access public
151
-     */
152
-    function timeElapsed($start = 'Start', $end = 'Stop') {
153
-        if ($end == 'Stop' && !isset($this->markers['Stop'])) {
154
-            $this->markers['Stop'] = $this->_getMicrotime();
155
-        }
144
+	/**
145
+	 * Returns the time elapsed betweens two markers.
146
+	 *
147
+	 * @param  string  $start        start marker, defaults to "Start"
148
+	 * @param  string  $end          end marker, defaults to "Stop"
149
+	 * @return double  $time_elapsed time elapsed between $start and $end
150
+	 * @access public
151
+	 */
152
+	function timeElapsed($start = 'Start', $end = 'Stop') {
153
+		if ($end == 'Stop' && !isset($this->markers['Stop'])) {
154
+			$this->markers['Stop'] = $this->_getMicrotime();
155
+		}
156 156
 
157
-        if (extension_loaded('bcmath')) {
158
-            return bcsub($this->markers[$end], $this->markers[$start], 6);
159
-        } else {
160
-            return $this->markers[$end] - $this->markers[$start];
161
-        }
162
-    }
157
+		if (extension_loaded('bcmath')) {
158
+			return bcsub($this->markers[$end], $this->markers[$start], 6);
159
+		} else {
160
+			return $this->markers[$end] - $this->markers[$start];
161
+		}
162
+	}
163 163
 
164
-    /**
165
-     * Returns profiling information.
166
-     *
167
-     * $profiling[x]['name']  = name of marker x
168
-     * $profiling[x]['time']  = time index of marker x
169
-     * $profiling[x]['diff']  = execution time from marker x-1 to this marker x
170
-     * $profiling[x]['total'] = total execution time up to marker x
171
-     *
172
-     * @return array
173
-     * @access public
174
-     */
175
-    function getProfiling() {
176
-        $i = $total = 0;
177
-        $result = array();
178
-        $temp = reset($this->markers);
179
-        $this->maxStringLength = 0;
164
+	/**
165
+	 * Returns profiling information.
166
+	 *
167
+	 * $profiling[x]['name']  = name of marker x
168
+	 * $profiling[x]['time']  = time index of marker x
169
+	 * $profiling[x]['diff']  = execution time from marker x-1 to this marker x
170
+	 * $profiling[x]['total'] = total execution time up to marker x
171
+	 *
172
+	 * @return array
173
+	 * @access public
174
+	 */
175
+	function getProfiling() {
176
+		$i = $total = 0;
177
+		$result = array();
178
+		$temp = reset($this->markers);
179
+		$this->maxStringLength = 0;
180 180
 
181
-        foreach ($this->markers as $marker => $time) {
182
-            if (extension_loaded('bcmath')) {
183
-                $diff  = bcsub($time, $temp, 6);
184
-                $total = bcadd($total, $diff, 6);
185
-            } else {
186
-                $diff  = $time - $temp;
187
-                $total = $total + $diff;
188
-            }
181
+		foreach ($this->markers as $marker => $time) {
182
+			if (extension_loaded('bcmath')) {
183
+				$diff  = bcsub($time, $temp, 6);
184
+				$total = bcadd($total, $diff, 6);
185
+			} else {
186
+				$diff  = $time - $temp;
187
+				$total = $total + $diff;
188
+			}
189 189
 
190
-            $result[$i]['name']  = $marker;
191
-            $result[$i]['time']  = $time;
192
-            $result[$i]['diff']  = $diff;
193
-            $result[$i]['total'] = $total;
190
+			$result[$i]['name']  = $marker;
191
+			$result[$i]['time']  = $time;
192
+			$result[$i]['diff']  = $diff;
193
+			$result[$i]['total'] = $total;
194 194
 
195
-            $this->maxStringLength = (strlen($marker) > $this->maxStringLength ? strlen($marker) + 1 : $this->maxStringLength);
195
+			$this->maxStringLength = (strlen($marker) > $this->maxStringLength ? strlen($marker) + 1 : $this->maxStringLength);
196 196
 
197
-            $temp = $time;
198
-            $i++;
199
-        }
197
+			$temp = $time;
198
+			$i++;
199
+		}
200 200
 
201
-        $result[0]['diff'] = '-';
202
-        $result[0]['total'] = '-';
203
-        $this->maxStringLength = (strlen('total') > $this->maxStringLength ? strlen('total') : $this->maxStringLength);
204
-        $this->maxStringLength += 2;
201
+		$result[0]['diff'] = '-';
202
+		$result[0]['total'] = '-';
203
+		$this->maxStringLength = (strlen('total') > $this->maxStringLength ? strlen('total') : $this->maxStringLength);
204
+		$this->maxStringLength += 2;
205 205
 
206
-        return $result;
207
-    }
206
+		return $result;
207
+	}
208 208
 
209
-    /**
210
-     * Return formatted profiling information.
211
-     *
212
-     * @param  boolean  $showTotal   Optionnaly includes total in output, default no
213
-     * @param  string  $format   output format (auto, plain or html), default auto
214
-     * @return string
215
-     * @see    getProfiling()
216
-     * @access public
217
-     */
218
-    function getOutput($showTotal = FALSE, $format = 'auto') {
219
-        if ($format == 'auto') {
220
-            if (function_exists('version_compare') &&
221
-                version_compare(phpversion(), '4.1', 'ge'))
222
-            {
223
-                $format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain';
224
-            } else {
225
-                global $HTTP_SERVER_VARS;
226
-                $format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain';
227
-	    }
228
-        }
209
+	/**
210
+	 * Return formatted profiling information.
211
+	 *
212
+	 * @param  boolean  $showTotal   Optionnaly includes total in output, default no
213
+	 * @param  string  $format   output format (auto, plain or html), default auto
214
+	 * @return string
215
+	 * @see    getProfiling()
216
+	 * @access public
217
+	 */
218
+	function getOutput($showTotal = FALSE, $format = 'auto') {
219
+		if ($format == 'auto') {
220
+			if (function_exists('version_compare') &&
221
+				version_compare(phpversion(), '4.1', 'ge'))
222
+			{
223
+				$format = isset($_SERVER['SERVER_PROTOCOL']) ? 'html' : 'plain';
224
+			} else {
225
+				global $HTTP_SERVER_VARS;
226
+				$format = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']) ? 'html' : 'plain';
227
+		}
228
+		}
229 229
 
230
-        $total  = $this->TimeElapsed();
231
-        $result = $this->getProfiling();
232
-        $dashes = '';
230
+		$total  = $this->TimeElapsed();
231
+		$result = $this->getProfiling();
232
+		$dashes = '';
233 233
 
234
-        if ($format == 'html') {
235
-            $out = '<table border="1">'."\n";
236
-            $out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'.
237
-            ($showTotal ?
238
-              '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>'
239
-               : '')."</tr>\n";
240
-        } else {
241
-            $dashes = $out = str_pad("\n",
242
-                $this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT);
243
-            $out .= str_pad('marker', $this->maxStringLength) .
244
-                    str_pad("time index", 22) .
245
-                    str_pad("ex time", 16) .
246
-                    str_pad("perct ", 8) .
247
-                    ($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" .
248
-                    $dashes;
249
-        }
234
+		if ($format == 'html') {
235
+			$out = '<table border="1">'."\n";
236
+			$out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'.
237
+			($showTotal ?
238
+			  '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>'
239
+			   : '')."</tr>\n";
240
+		} else {
241
+			$dashes = $out = str_pad("\n",
242
+				$this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT);
243
+			$out .= str_pad('marker', $this->maxStringLength) .
244
+					str_pad("time index", 22) .
245
+					str_pad("ex time", 16) .
246
+					str_pad("perct ", 8) .
247
+					($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" .
248
+					$dashes;
249
+		}
250 250
 
251
-        foreach ($result as $k => $v) {
252
-            $perc = (($v['diff'] * 100) / $total);
253
-            $tperc = (($v['total'] * 100) / $total);
251
+		foreach ($result as $k => $v) {
252
+			$perc = (($v['diff'] * 100) / $total);
253
+			$tperc = (($v['total'] * 100) / $total);
254 254
 
255
-            if ($format == 'html') {
256
-                $out .= "<tr><td><b>" . $v['name'] .
257
-                       "</b></td><td>" . $v['time'] .
258
-                       "</td><td>" . $v['diff'] .
259
-                       "</td><td align=\"right\">" . number_format($perc, 2, '.', '') .
260
-                       "%</td>".
261
-                       ($showTotal ?
262
-                            "<td>" . $v['total'] .
263
-                            "</td><td align=\"right\">" .
264
-                            number_format($tperc, 2, '.', '') .
265
-                            "%</td>" : '').
266
-                       "</tr>\n";
267
-            } else {
268
-                $out .= str_pad($v['name'], $this->maxStringLength, ' ') .
269
-                        str_pad($v['time'], 22) .
270
-                        str_pad($v['diff'], 14) .
271
-                        str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) .
272
-                        ($showTotal ? '   '.
273
-                            str_pad($v['total'], 14) .
274
-                            str_pad(number_format($tperc, 2, '.', '')."%",
275
-                                             8, ' ', STR_PAD_LEFT) : '').
276
-                        "\n";
277
-            }
255
+			if ($format == 'html') {
256
+				$out .= "<tr><td><b>" . $v['name'] .
257
+					   "</b></td><td>" . $v['time'] .
258
+					   "</td><td>" . $v['diff'] .
259
+					   "</td><td align=\"right\">" . number_format($perc, 2, '.', '') .
260
+					   "%</td>".
261
+					   ($showTotal ?
262
+							"<td>" . $v['total'] .
263
+							"</td><td align=\"right\">" .
264
+							number_format($tperc, 2, '.', '') .
265
+							"%</td>" : '').
266
+					   "</tr>\n";
267
+			} else {
268
+				$out .= str_pad($v['name'], $this->maxStringLength, ' ') .
269
+						str_pad($v['time'], 22) .
270
+						str_pad($v['diff'], 14) .
271
+						str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) .
272
+						($showTotal ? '   '.
273
+							str_pad($v['total'], 14) .
274
+							str_pad(number_format($tperc, 2, '.', '')."%",
275
+											 8, ' ', STR_PAD_LEFT) : '').
276
+						"\n";
277
+			}
278 278
 
279
-            $out .= $dashes;
280
-        }
279
+			$out .= $dashes;
280
+		}
281 281
 
282
-        if ($format == 'html') {
283
-            $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n";
284
-            $out .= "</table>\n";
285
-        } else {
286
-            $out .= str_pad('total', $this->maxStringLength);
287
-            $out .= str_pad('-', 22);
288
-            $out .= str_pad($total, 15);
289
-            $out .= "100.00%\n";
290
-            $out .= $dashes;
291
-        }
282
+		if ($format == 'html') {
283
+			$out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n";
284
+			$out .= "</table>\n";
285
+		} else {
286
+			$out .= str_pad('total', $this->maxStringLength);
287
+			$out .= str_pad('-', 22);
288
+			$out .= str_pad($total, 15);
289
+			$out .= "100.00%\n";
290
+			$out .= $dashes;
291
+		}
292 292
 
293
-        return $out;
294
-    }
293
+		return $out;
294
+	}
295 295
 
296
-    /**
297
-     * Prints the information returned by getOutput().
298
-     *
299
-     * @param  boolean  $showTotal   Optionnaly includes total in output, default no
300
-     * @param  string  $format   output format (auto, plain or html), default auto
301
-     * @see    getOutput()
302
-     * @access public
303
-     */
304
-    function display($showTotal = FALSE, $format = 'auto') {
305
-        print $this->getOutput($showTotal, $format);
306
-    }
296
+	/**
297
+	 * Prints the information returned by getOutput().
298
+	 *
299
+	 * @param  boolean  $showTotal   Optionnaly includes total in output, default no
300
+	 * @param  string  $format   output format (auto, plain or html), default auto
301
+	 * @see    getOutput()
302
+	 * @access public
303
+	 */
304
+	function display($showTotal = FALSE, $format = 'auto') {
305
+		print $this->getOutput($showTotal, $format);
306
+	}
307 307
 
308
-    /**
309
-     * Wrapper for microtime().
310
-     *
311
-     * @return float
312
-     * @access private
313
-     * @since  1.3.0
314
-     */
315
-    function _getMicrotime() {
316
-        $microtime = explode(' ', microtime());
317
-        return $microtime[1] . substr($microtime[0], 1);
318
-    }
308
+	/**
309
+	 * Wrapper for microtime().
310
+	 *
311
+	 * @return float
312
+	 * @access private
313
+	 * @since  1.3.0
314
+	 */
315
+	function _getMicrotime() {
316
+		$microtime = explode(' ', microtime());
317
+		return $microtime[1] . substr($microtime[0], 1);
318
+	}
319 319
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
         $dashes = '';
233 233
 
234 234
         if ($format == 'html') {
235
-            $out = '<table border="1">'."\n";
236
-            $out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>'.
235
+            $out = '<table border="1">' . "\n";
236
+            $out .= '<tr><td>&nbsp;</td><td align="center"><b>time index</b></td><td align="center"><b>ex time</b></td><td align="center"><b>%</b></td>' .
237 237
             ($showTotal ?
238 238
               '<td align="center"><b>elapsed</b></td><td align="center"><b>%</b></td>'
239
-               : '')."</tr>\n";
239
+               : '') . "</tr>\n";
240 240
         } else {
241 241
             $dashes = $out = str_pad("\n",
242 242
                 $this->maxStringLength + ($showTotal ? 70 : 45), '-', STR_PAD_LEFT);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                     str_pad("time index", 22) .
245 245
                     str_pad("ex time", 16) .
246 246
                     str_pad("perct ", 8) .
247
-                    ($showTotal ? ' '.str_pad("elapsed", 16)."perct" : '')."\n" .
247
+                    ($showTotal ? ' ' . str_pad("elapsed", 16) . "perct" : '') . "\n" .
248 248
                     $dashes;
249 249
         }
250 250
 
@@ -257,22 +257,22 @@  discard block
 block discarded – undo
257 257
                        "</b></td><td>" . $v['time'] .
258 258
                        "</td><td>" . $v['diff'] .
259 259
                        "</td><td align=\"right\">" . number_format($perc, 2, '.', '') .
260
-                       "%</td>".
260
+                       "%</td>" .
261 261
                        ($showTotal ?
262 262
                             "<td>" . $v['total'] .
263 263
                             "</td><td align=\"right\">" .
264 264
                             number_format($tperc, 2, '.', '') .
265
-                            "%</td>" : '').
265
+                            "%</td>" : '') .
266 266
                        "</tr>\n";
267 267
             } else {
268 268
                 $out .= str_pad($v['name'], $this->maxStringLength, ' ') .
269 269
                         str_pad($v['time'], 22) .
270 270
                         str_pad($v['diff'], 14) .
271
-                        str_pad(number_format($perc, 2, '.', '')."%",8, ' ', STR_PAD_LEFT) .
272
-                        ($showTotal ? '   '.
271
+                        str_pad(number_format($perc, 2, '.', '') . "%", 8, ' ', STR_PAD_LEFT) .
272
+                        ($showTotal ? '   ' .
273 273
                             str_pad($v['total'], 14) .
274
-                            str_pad(number_format($tperc, 2, '.', '')."%",
275
-                                             8, ' ', STR_PAD_LEFT) : '').
274
+                            str_pad(number_format($tperc, 2, '.', '') . "%",
275
+                                             8, ' ', STR_PAD_LEFT) : '') .
276 276
                         "\n";
277 277
             }
278 278
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         }
281 281
 
282 282
         if ($format == 'html') {
283
-            $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>".($showTotal ? "<td>-</td><td>-</td>" : "")."</tr>\n";
283
+            $out .= "<tr style='background: silver;'><td><b>total</b></td><td>-</td><td>${total}</td><td>100.00%</td>" . ($showTotal ? "<td>-</td><td>-</td>" : "") . "</tr>\n";
284 284
             $out .= "</table>\n";
285 285
         } else {
286 286
             $out .= str_pad('total', $this->maxStringLength);
Please login to merge, or discard this patch.
buildscripts/classtree/build.php 3 patches
Doc Comments   +12 added lines patch added patch discarded remove patch
@@ -67,6 +67,9 @@  discard block
 block discarded – undo
67 67
 		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
68 68
 	}
69 69
 
70
+	/**
71
+	 * @param integer $level
72
+	 */
70 73
 	public function displayTreeInternal($classNames,$level)
71 74
 	{
72 75
 		foreach($classNames as $className)
@@ -153,6 +156,9 @@  discard block
 block discarded – undo
153 156
 		}
154 157
 	}
155 158
 
159
+	/**
160
+	 * @param string $path
161
+	 */
156 162
 	protected function isValidPath($path)
157 163
 	{
158 164
 		if(is_dir($path))
@@ -161,6 +167,9 @@  discard block
 block discarded – undo
161 167
 			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
162 168
 	}
163 169
 
170
+	/**
171
+	 * @param string $path
172
+	 */
164 173
 	public function getSourceFiles($path)
165 174
 	{
166 175
 		$files=array();
@@ -227,6 +236,9 @@  discard block
 block discarded – undo
227 236
 
228 237
 	}
229 238
 
239
+	/**
240
+	 * @param PradoVTMDocument $doc
241
+	 */
230 242
 	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
231 243
 	{
232 244
 		foreach($objectInfo['Properties'] as $name=>$property)
Please login to merge, or discard this patch.
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -1,14 +1,14 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-$basePath=dirname(__FILE__);
4
-$frameworkPath=realpath($basePath.'/../../framework');
5
-require_once($frameworkPath.'/prado.php');
6
-require_once($basePath.'/DWExtension.php');
3
+$basePath = dirname(__FILE__);
4
+$frameworkPath = realpath($basePath . '/../../framework');
5
+require_once($frameworkPath . '/prado.php');
6
+require_once($basePath . '/DWExtension.php');
7 7
 
8 8
 //the manager class sets up some dependency paths
9 9
 Prado::using('System.Data.SqlMap.TSqlMapManager');
10 10
 
11
-$exclusions=array(
11
+$exclusions = array(
12 12
 	'pradolite.php',
13 13
 	'prado-cli.php',
14 14
 	'JSMin.php',
@@ -17,93 +17,93 @@  discard block
 block discarded – undo
17 17
 	'/Testing',
18 18
 	'/Web/UI/WebControls/assets',
19 19
 	);
20
-$a=new ClassTreeBuilder($frameworkPath,$exclusions);
20
+$a = new ClassTreeBuilder($frameworkPath, $exclusions);
21 21
 $a->buildTree();
22
-$a->saveToFile($basePath.'/classes.data');
22
+$a->saveToFile($basePath . '/classes.data');
23 23
 $a->saveAsDWExtension($basePath);
24 24
 
25 25
 class ClassTreeBuilder
26 26
 {
27
-	const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
27
+	const REGEX_RULES = '/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
28 28
 	private $_frameworkPath;
29 29
 	private $_exclusions;
30
-	private $_classes=array();
30
+	private $_classes = array();
31 31
 
32
-	public function __construct($frameworkPath,$exclusions)
32
+	public function __construct($frameworkPath, $exclusions)
33 33
 	{
34
-		$this->_frameworkPath=realpath($frameworkPath);
35
-		$this->_exclusions=array();
36
-		foreach($exclusions as $exclusion)
34
+		$this->_frameworkPath = realpath($frameworkPath);
35
+		$this->_exclusions = array();
36
+		foreach ($exclusions as $exclusion)
37 37
 		{
38
-			if($exclusion[0]==='/')
39
-				$this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
38
+			if ($exclusion[0] === '/')
39
+				$this->_exclusions[realpath($frameworkPath . '/' . $exclusion)] = true;
40 40
 			else
41
-				$this->_exclusions[$exclusion]=true;
41
+				$this->_exclusions[$exclusion] = true;
42 42
 		}
43 43
 	}
44 44
 
45 45
 	public function buildTree()
46 46
 	{
47
-		$sourceFiles=$this->getSourceFiles($this->_frameworkPath);
48
-		foreach($sourceFiles as $sourceFile)
47
+		$sourceFiles = $this->getSourceFiles($this->_frameworkPath);
48
+		foreach ($sourceFiles as $sourceFile)
49 49
 			$this->parseFile($sourceFile);
50 50
 		ksort($this->_classes);
51
-		foreach(array_keys($this->_classes) as $className)
51
+		foreach (array_keys($this->_classes) as $className)
52 52
 		{
53
-			$parentClass=$this->_classes[$className]['ParentClass'];
54
-			if(isset($this->_classes[$parentClass]))
55
-				$this->_classes[$parentClass]['ChildClasses'][]=$className;
53
+			$parentClass = $this->_classes[$className]['ParentClass'];
54
+			if (isset($this->_classes[$parentClass]))
55
+				$this->_classes[$parentClass]['ChildClasses'][] = $className;
56 56
 		}
57
-		echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
57
+		echo "\nClass tree built successfully. Total " . count($this->_classes) . " classes found.\n";
58 58
 	}
59 59
 
60 60
 	public function saveToFile($fileName)
61 61
 	{
62
-		file_put_contents($fileName,serialize($this->_classes));
62
+		file_put_contents($fileName, serialize($this->_classes));
63 63
 	}
64 64
 
65 65
 	public function displayTree()
66 66
 	{
67
-		$this->displayTreeInternal(array_keys($this->_baseClasses),0);
67
+		$this->displayTreeInternal(array_keys($this->_baseClasses), 0);
68 68
 	}
69 69
 
70
-	public function displayTreeInternal($classNames,$level)
70
+	public function displayTreeInternal($classNames, $level)
71 71
 	{
72
-		foreach($classNames as $className)
72
+		foreach ($classNames as $className)
73 73
 		{
74
-			echo str_repeat(' ',$level*4);
75
-			echo $className.':'.$this->_classes[$className]->Package."\n";
76
-			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
74
+			echo str_repeat(' ', $level * 4);
75
+			echo $className . ':' . $this->_classes[$className]->Package . "\n";
76
+			$this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses), $level + 1);
77 77
 		}
78 78
 	}
79 79
 
80 80
 	protected function parseFile($sourceFile)
81 81
 	{
82 82
 		include_once($sourceFile);
83
-		$classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
83
+		$classFile = strtr(substr($sourceFile, strlen($this->_frameworkPath)), '\\', '/');
84 84
 		echo "Parsing $classFile...\n";
85
-		$content=file_get_contents($sourceFile);
86
-		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
87
-			$package=$matches[1];
85
+		$content = file_get_contents($sourceFile);
86
+		if (preg_match('/@package\s+([\w\.]+)\s*/msS', $content, $matches) > 0)
87
+			$package = $matches[1];
88 88
 		else
89
-			$package='';
90
-		$n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
91
-		for($i=0;$i<$n;++$i)
89
+			$package = '';
90
+		$n = preg_match_all(self::REGEX_RULES, $content, $matches, PREG_SET_ORDER);
91
+		for ($i = 0; $i < $n; ++$i)
92 92
 		{
93
-			$className=$matches[$i][2];
94
-			if(isset($this->_classes[$className]))
95
-				throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
96
-			$c=new TComponentReflection($className);
97
-			$properties=$c->getProperties();
93
+			$className = $matches[$i][2];
94
+			if (isset($this->_classes[$className]))
95
+				throw new Exception("Class $className is defined in both $sourceFile and " . $this->_classes[$className]->ClassFile);
96
+			$c = new TComponentReflection($className);
97
+			$properties = $c->getProperties();
98 98
 			$this->parseMethodComments($properties);
99
-			$events=$c->getEvents();
99
+			$events = $c->getEvents();
100 100
 			$this->parseMethodComments($events);
101
-			$methods=$c->getMethods();
101
+			$methods = $c->getMethods();
102 102
 			$this->parseMethodComments($methods);
103
-			$this->_classes[$className]=array(
103
+			$this->_classes[$className] = array(
104 104
 				'ClassFile'=>$classFile,
105 105
 				'Package'=>$package,
106
-				'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
106
+				'ParentClass'=>isset($matches[$i][4]) ? $matches[$i][4] : '',
107 107
 				'ChildClasses'=>array(),
108 108
 				'Properties'=>$properties,
109 109
 				'Events'=>$events,
@@ -113,69 +113,69 @@  discard block
 block discarded – undo
113 113
 
114 114
 	protected function parseMethodComments(&$methods)
115 115
 	{
116
-		foreach(array_keys($methods) as $key)
116
+		foreach (array_keys($methods) as $key)
117 117
 		{
118
-			$method=&$methods[$key];
119
-			$comments=$method['comments'];
120
-			$s='';
121
-			foreach(explode("\n",$comments) as $line)
118
+			$method = &$methods[$key];
119
+			$comments = $method['comments'];
120
+			$s = '';
121
+			foreach (explode("\n", $comments) as $line)
122 122
 			{
123
-				$line=trim($line);
124
-				$line=trim($line,'/*');
125
-				$s.=' '.$line;
123
+				$line = trim($line);
124
+				$line = trim($line, '/*');
125
+				$s .= ' ' . $line;
126 126
 			}
127
-			$s=trim($s);
128
-			$s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
129
-			$pos1=strpos($s,'@');
130
-			$pos2=strpos($s,'.');
131
-			if($pos1===false)
127
+			$s = trim($s);
128
+			$s = preg_replace('/\{@link.*?([\w\(\)]+)\}/i', '$1', $s);
129
+			$pos1 = strpos($s, '@');
130
+			$pos2 = strpos($s, '.');
131
+			if ($pos1 === false)
132 132
 			{
133
-				if($pos2!==false)
134
-					$method['comments']=substr($s,0,$pos2);
133
+				if ($pos2 !== false)
134
+					$method['comments'] = substr($s, 0, $pos2);
135 135
 				else
136
-					$method['comments']=$s;
136
+					$method['comments'] = $s;
137 137
 			}
138
-			else if($pos1>0)
138
+			else if ($pos1 > 0)
139 139
 			{
140
-				if($pos2 && $pos2<$pos1)	// use the first line as comment
141
-					$method['comments']=substr($s,0,$pos2);
140
+				if ($pos2 && $pos2 < $pos1)	// use the first line as comment
141
+					$method['comments'] = substr($s, 0, $pos2);
142 142
 				else
143
-					$method['comments']=substr($s,0,$pos1);
143
+					$method['comments'] = substr($s, 0, $pos1);
144 144
 			}
145 145
 			else
146 146
 			{
147
-				$matches=array();
148
-				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
149
-					$method['comments']=$matches[1];
147
+				$matches = array();
148
+				if (preg_match('/@return\s+[\w\|]+\s+([^\.]*)/', $s, $matches) > 0)
149
+					$method['comments'] = $matches[1];
150 150
 				else
151
-					$method['comments']='';
151
+					$method['comments'] = '';
152 152
 			}
153 153
 		}
154 154
 	}
155 155
 
156 156
 	protected function isValidPath($path)
157 157
 	{
158
-		if(is_dir($path))
158
+		if (is_dir($path))
159 159
 			return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
160 160
 		else
161
-			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
161
+			return basename($path) !== basename($path, '.php') && !isset($this->_exclusions[basename($path)]);
162 162
 	}
163 163
 
164 164
 	public function getSourceFiles($path)
165 165
 	{
166
-		$files=array();
167
-		$folder=opendir($path);
168
-		while($file=readdir($folder))
166
+		$files = array();
167
+		$folder = opendir($path);
168
+		while ($file = readdir($folder))
169 169
 		{
170
-			if($file==='.' || $file==='..')
170
+			if ($file === '.' || $file === '..')
171 171
 				continue;
172
-			$fullPath=realpath($path.'/'.$file);
173
-			if($this->isValidPath($fullPath))
172
+			$fullPath = realpath($path . '/' . $file);
173
+			if ($this->isValidPath($fullPath))
174 174
 			{
175
-				if(is_file($fullPath))
176
-					$files[]=$fullPath;
175
+				if (is_file($fullPath))
176
+					$files[] = $fullPath;
177 177
 				else
178
-					$files=array_merge($files,$this->getSourceFiles($fullPath));
178
+					$files = array_merge($files, $this->getSourceFiles($fullPath));
179 179
 			}
180 180
 		}
181 181
 		closedir($folder);
@@ -184,71 +184,71 @@  discard block
 block discarded – undo
184 184
 
185 185
 	public function saveAsDWExtension($basePath)
186 186
 	{
187
-		$tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
187
+		$tagPath = $basePath . '/Configuration/TagLibraries/PRADO';
188 188
 
189 189
 		// prepare the directory to save tag lib
190
-		@mkdir($basePath.'/Configuration');
191
-		@mkdir($basePath.'/Configuration/TagLibraries');
192
-		@mkdir($basePath.'/Configuration/TagLibraries/PRADO');
190
+		@mkdir($basePath . '/Configuration');
191
+		@mkdir($basePath . '/Configuration/TagLibraries');
192
+		@mkdir($basePath . '/Configuration/TagLibraries/PRADO');
193 193
 
194 194
 		$docMXI = new PradoMXIDocument(Prado::getVersion());
195 195
 		$tagChooser = new PradoTagChooser;
196 196
 
197 197
 		$controlClass = new ReflectionClass('TControl');
198 198
 
199
-		foreach($this->_classes as $className=>$classInfo)
199
+		foreach ($this->_classes as $className=>$classInfo)
200 200
 		{
201 201
 			$class = new ReflectionClass($className);
202
-			if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
202
+			if ($class->isInstantiable() && ($className === 'TControl' || $class->isSubclassOf($controlClass)))
203 203
 			{
204 204
 				$docMXI->addTag($className);
205 205
 				$tagChooser->addElement($className);
206 206
 				$docVTM = new PradoVTMDocument($className);
207
-				foreach($classInfo['Properties'] as $name=>$property)
207
+				foreach ($classInfo['Properties'] as $name=>$property)
208 208
 				{
209
-					$type=$property['type'];
210
-					if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
211
-						$this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
212
-					if($property['readonly'] || $property['protected'])
209
+					$type = $property['type'];
210
+					if (isset($this->_classes[$type]) && ($type === 'TFont' || strrpos($type, 'Style') === strlen($type) - 5 && $type !== 'TStyle'))
211
+						$this->processObjectType($type, $this->_classes[$type], $name, $docVTM);
212
+					if ($property['readonly'] || $property['protected'])
213 213
 						continue;
214
-					if(($type=$this->checkType($className,$name,$property['type']))!=='')
215
-						$docVTM->addAttribute($name,$type);
214
+					if (($type = $this->checkType($className, $name, $property['type'])) !== '')
215
+						$docVTM->addAttribute($name, $type);
216 216
 				}
217
-				foreach($classInfo['Events'] as $name=>$event)
217
+				foreach ($classInfo['Events'] as $name=>$event)
218 218
 				{
219 219
 					$docVTM->addEvent($name);
220 220
 				}
221
-				file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
221
+				file_put_contents($tagPath . '/' . $className . '.vtm', $docVTM->getXML());
222 222
 			}
223 223
 		}
224 224
 
225
-		file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
226
-		file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
225
+		file_put_contents($basePath . '/PRADO.mxi', $docMXI->getXML());
226
+		file_put_contents($tagPath . '/TagChooser.xml', $tagChooser->getXML());
227 227
 
228 228
 	}
229 229
 
230
-	private	function processObjectType($objectType,$objectInfo,$prefix,$doc)
230
+	private	function processObjectType($objectType, $objectInfo, $prefix, $doc)
231 231
 	{
232
-		foreach($objectInfo['Properties'] as $name=>$property)
232
+		foreach ($objectInfo['Properties'] as $name=>$property)
233 233
 		{
234
-			if($property['type']==='TFont')
235
-				$this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
236
-			if($property['readonly'] || $property['protected'])
234
+			if ($property['type'] === 'TFont')
235
+				$this->processObjectType('TFont', $this->_classes['TFont'], $prefix . '.' . $name, $doc);
236
+			if ($property['readonly'] || $property['protected'])
237 237
 				continue;
238
-			if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
239
-				$doc->addAttribute($prefix.'.'.$name,$type);
238
+			if (($type = $this->checkType($objectType, $name, $property['type'])) !== '')
239
+				$doc->addAttribute($prefix . '.' . $name, $type);
240 240
 		}
241 241
 	}
242 242
 
243
-	private	function checkType($className,$propertyName,$type)
243
+	private	function checkType($className, $propertyName, $type)
244 244
 	{
245
-		if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
245
+		if (strrpos($propertyName, 'Color') === strlen($propertyName) - 5)
246 246
 			return 'color';
247
-		if($propertyName==='Style')
247
+		if ($propertyName === 'Style')
248 248
 			return 'style';
249
-		if($type==='boolean')
250
-			return array('true','false');
251
-		if($type==='string' || $type==='integer' || $type==='ITemplate')
249
+		if ($type === 'boolean')
250
+			return array('true', 'false');
251
+		if ($type === 'string' || $type === 'integer' || $type === 'ITemplate')
252 252
 			return 'text';
253 253
 		return '';
254 254
 	}
Please login to merge, or discard this patch.
Braces   +79 added lines, -59 removed lines patch added patch discarded remove patch
@@ -35,24 +35,27 @@  discard block
 block discarded – undo
35 35
 		$this->_exclusions=array();
36 36
 		foreach($exclusions as $exclusion)
37 37
 		{
38
-			if($exclusion[0]==='/')
39
-				$this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
40
-			else
41
-				$this->_exclusions[$exclusion]=true;
38
+			if($exclusion[0]==='/') {
39
+							$this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
40
+			} else {
41
+							$this->_exclusions[$exclusion]=true;
42
+			}
42 43
 		}
43 44
 	}
44 45
 
45 46
 	public function buildTree()
46 47
 	{
47 48
 		$sourceFiles=$this->getSourceFiles($this->_frameworkPath);
48
-		foreach($sourceFiles as $sourceFile)
49
-			$this->parseFile($sourceFile);
49
+		foreach($sourceFiles as $sourceFile) {
50
+					$this->parseFile($sourceFile);
51
+		}
50 52
 		ksort($this->_classes);
51 53
 		foreach(array_keys($this->_classes) as $className)
52 54
 		{
53 55
 			$parentClass=$this->_classes[$className]['ParentClass'];
54
-			if(isset($this->_classes[$parentClass]))
55
-				$this->_classes[$parentClass]['ChildClasses'][]=$className;
56
+			if(isset($this->_classes[$parentClass])) {
57
+							$this->_classes[$parentClass]['ChildClasses'][]=$className;
58
+			}
56 59
 		}
57 60
 		echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
58 61
 	}
@@ -83,16 +86,18 @@  discard block
 block discarded – undo
83 86
 		$classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
84 87
 		echo "Parsing $classFile...\n";
85 88
 		$content=file_get_contents($sourceFile);
86
-		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
87
-			$package=$matches[1];
88
-		else
89
-			$package='';
89
+		if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0) {
90
+					$package=$matches[1];
91
+		} else {
92
+					$package='';
93
+		}
90 94
 		$n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
91 95
 		for($i=0;$i<$n;++$i)
92 96
 		{
93 97
 			$className=$matches[$i][2];
94
-			if(isset($this->_classes[$className]))
95
-				throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
98
+			if(isset($this->_classes[$className])) {
99
+							throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
100
+			}
96 101
 			$c=new TComponentReflection($className);
97 102
 			$properties=$c->getProperties();
98 103
 			$this->parseMethodComments($properties);
@@ -130,35 +135,38 @@  discard block
 block discarded – undo
130 135
 			$pos2=strpos($s,'.');
131 136
 			if($pos1===false)
132 137
 			{
133
-				if($pos2!==false)
134
-					$method['comments']=substr($s,0,$pos2);
135
-				else
136
-					$method['comments']=$s;
137
-			}
138
-			else if($pos1>0)
138
+				if($pos2!==false) {
139
+									$method['comments']=substr($s,0,$pos2);
140
+				} else {
141
+									$method['comments']=$s;
142
+				}
143
+			} else if($pos1>0)
139 144
 			{
140
-				if($pos2 && $pos2<$pos1)	// use the first line as comment
145
+				if($pos2 && $pos2<$pos1) {
146
+					// use the first line as comment
141 147
 					$method['comments']=substr($s,0,$pos2);
142
-				else
143
-					$method['comments']=substr($s,0,$pos1);
144
-			}
145
-			else
148
+				} else {
149
+									$method['comments']=substr($s,0,$pos1);
150
+				}
151
+			} else
146 152
 			{
147 153
 				$matches=array();
148
-				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
149
-					$method['comments']=$matches[1];
150
-				else
151
-					$method['comments']='';
154
+				if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0) {
155
+									$method['comments']=$matches[1];
156
+				} else {
157
+									$method['comments']='';
158
+				}
152 159
 			}
153 160
 		}
154 161
 	}
155 162
 
156 163
 	protected function isValidPath($path)
157 164
 	{
158
-		if(is_dir($path))
159
-			return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
160
-		else
161
-			return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
165
+		if(is_dir($path)) {
166
+					return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
167
+		} else {
168
+					return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
169
+		}
162 170
 	}
163 171
 
164 172
 	public function getSourceFiles($path)
@@ -167,15 +175,17 @@  discard block
 block discarded – undo
167 175
 		$folder=opendir($path);
168 176
 		while($file=readdir($folder))
169 177
 		{
170
-			if($file==='.' || $file==='..')
171
-				continue;
178
+			if($file==='.' || $file==='..') {
179
+							continue;
180
+			}
172 181
 			$fullPath=realpath($path.'/'.$file);
173 182
 			if($this->isValidPath($fullPath))
174 183
 			{
175
-				if(is_file($fullPath))
176
-					$files[]=$fullPath;
177
-				else
178
-					$files=array_merge($files,$this->getSourceFiles($fullPath));
184
+				if(is_file($fullPath)) {
185
+									$files[]=$fullPath;
186
+				} else {
187
+									$files=array_merge($files,$this->getSourceFiles($fullPath));
188
+				}
179 189
 			}
180 190
 		}
181 191
 		closedir($folder);
@@ -207,12 +217,15 @@  discard block
 block discarded – undo
207 217
 				foreach($classInfo['Properties'] as $name=>$property)
208 218
 				{
209 219
 					$type=$property['type'];
210
-					if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
211
-						$this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
212
-					if($property['readonly'] || $property['protected'])
213
-						continue;
214
-					if(($type=$this->checkType($className,$name,$property['type']))!=='')
215
-						$docVTM->addAttribute($name,$type);
220
+					if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle')) {
221
+											$this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
222
+					}
223
+					if($property['readonly'] || $property['protected']) {
224
+											continue;
225
+					}
226
+					if(($type=$this->checkType($className,$name,$property['type']))!=='') {
227
+											$docVTM->addAttribute($name,$type);
228
+					}
216 229
 				}
217 230
 				foreach($classInfo['Events'] as $name=>$event)
218 231
 				{
@@ -231,25 +244,32 @@  discard block
 block discarded – undo
231 244
 	{
232 245
 		foreach($objectInfo['Properties'] as $name=>$property)
233 246
 		{
234
-			if($property['type']==='TFont')
235
-				$this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
236
-			if($property['readonly'] || $property['protected'])
237
-				continue;
238
-			if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
239
-				$doc->addAttribute($prefix.'.'.$name,$type);
247
+			if($property['type']==='TFont') {
248
+							$this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
249
+			}
250
+			if($property['readonly'] || $property['protected']) {
251
+							continue;
252
+			}
253
+			if(($type=$this->checkType($objectType,$name,$property['type']))!=='') {
254
+							$doc->addAttribute($prefix.'.'.$name,$type);
255
+			}
240 256
 		}
241 257
 	}
242 258
 
243 259
 	private	function checkType($className,$propertyName,$type)
244 260
 	{
245
-		if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
246
-			return 'color';
247
-		if($propertyName==='Style')
248
-			return 'style';
249
-		if($type==='boolean')
250
-			return array('true','false');
251
-		if($type==='string' || $type==='integer' || $type==='ITemplate')
252
-			return 'text';
261
+		if(strrpos($propertyName,'Color')===strlen($propertyName)-5) {
262
+					return 'color';
263
+		}
264
+		if($propertyName==='Style') {
265
+					return 'style';
266
+		}
267
+		if($type==='boolean') {
268
+					return array('true','false');
269
+		}
270
+		if($type==='string' || $type==='integer' || $type==='ITemplate') {
271
+					return 'text';
272
+		}
253 273
 		return '';
254 274
 	}
255 275
 }
Please login to merge, or discard this patch.
buildscripts/classtree/DWExtension.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -100,6 +100,9 @@
 block discarded – undo
100 100
 	private $_filesElement;
101 101
 	private $_document;
102 102
 
103
+	/**
104
+	 * @param string $version
105
+	 */
103 106
 	public function __construct($version)
104 107
 	{
105 108
 		$this->_document = new DOMDocument('1.0', 'utf-8');
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 
24 24
 		//--- add <tag>
25 25
 		$tag = $this->_document->createElement('tag');
26
-		$tag->setAttribute('name',$controlName);
27
-		$tag->setAttribute('casesensitive','yes');
26
+		$tag->setAttribute('name', $controlName);
27
+		$tag->setAttribute('casesensitive', 'yes');
28 28
 		$this->_document->appendChild($tag);
29 29
 
30 30
 		//--- add <tagformat>
31 31
 		$tagFormat = $this->_document->createElement('tagformat');
32
-		$tagFormat->setAttribute('nlbeforetag','1');
33
-		$tagFormat->setAttribute('nlaftertag','1');
34
-		$tagFormat->setAttribute('indentcontents','yes');
32
+		$tagFormat->setAttribute('nlbeforetag', '1');
33
+		$tagFormat->setAttribute('nlaftertag', '1');
34
+		$tagFormat->setAttribute('indentcontents', 'yes');
35 35
 		$tag->appendChild($tagFormat);
36 36
 
37 37
 		//--- add <tagdialog file="Control.htm" />
@@ -52,33 +52,33 @@  discard block
 block discarded – undo
52 52
 	{
53 53
 		//--- add <attrib>
54 54
 		$attrib = $this->_document->createElement('attrib');
55
-		$attrib->setAttribute('name',$attribName);
55
+		$attrib->setAttribute('name', $attribName);
56 56
 		if (is_array($attribType))
57 57
 		{
58
-			$attrib->setAttribute('type','Enumerated');
58
+			$attrib->setAttribute('type', 'Enumerated');
59 59
 			foreach ($attribType as $value)
60 60
 			{
61 61
 				$option = $this->_document->createElement('attriboption');
62
-				$option->setAttribute('value',$value);
63
-				$option->setAttribute('caption','');
62
+				$option->setAttribute('value', $value);
63
+				$option->setAttribute('caption', '');
64 64
 				$attrib->appendChild($option);
65 65
 			}
66 66
 		}
67
-		else if($attribType!=='')
67
+		else if ($attribType !== '')
68 68
 		{
69
-			$attrib->setAttribute('type',$attribType);
69
+			$attrib->setAttribute('type', $attribType);
70 70
 		}
71
-		$attrib->setAttribute('casesensitive','yes');
71
+		$attrib->setAttribute('casesensitive', 'yes');
72 72
 		$this->_attributes->appendChild($attrib);
73 73
 	}
74 74
 
75 75
 	public function addEvent($eventName)
76 76
 	{
77 77
 		//--- add <attrib>
78
-		$this->addAttribute($eventName,'');
78
+		$this->addAttribute($eventName, '');
79 79
 		//--- add <event>
80 80
 		$event = $this->_document->createElement('event');
81
-		$event->setAttribute('name',$eventName);
81
+		$event->setAttribute('name', $eventName);
82 82
 		$this->_attributes->appendChild($event);
83 83
 	}
84 84
 
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 		$this->_document->formatOutput = true;
112 112
 		//--- add root element
113 113
 		$rootElement = $this->_document->createElement('macromedia-extension');
114
-		$rootElement->setAttribute('name','PRADO Taglib');
115
-		$rootElement->setAttribute('version',$version);
116
-		$rootElement->setAttribute('type','Suite');
117
-		$rootElement->setAttribute('requires-restart','true');
114
+		$rootElement->setAttribute('name', 'PRADO Taglib');
115
+		$rootElement->setAttribute('version', $version);
116
+		$rootElement->setAttribute('type', 'Suite');
117
+		$rootElement->setAttribute('requires-restart', 'true');
118 118
 		$this->_document->appendChild($rootElement);
119 119
 		//--- add <author>
120 120
 		$element = $this->_document->createElement('author');
121
-		$element->setAttribute('name','Stanislav Yordanov, Qiang Xue');
121
+		$element->setAttribute('name', 'Stanislav Yordanov, Qiang Xue');
122 122
 		$rootElement->appendChild($element);
123
-		$time = date('F j, Y, h:i:s a',time());
123
+		$time = date('F j, Y, h:i:s a', time());
124 124
 		//--- add <description>
125 125
 		$description = <<<EOD
126 126
 PRADO $version Tag Library
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 		$rootElement->appendChild($productsElement);
139 139
 		//--- add <product>
140 140
 		$product = $this->_document->createElement('product');
141
-		$product->setAttribute('name','Dreamweaver');
142
-		$product->setAttribute('version','6');
143
-		$product->setAttribute('primary','false');
141
+		$product->setAttribute('name', 'Dreamweaver');
142
+		$product->setAttribute('version', '6');
143
+		$product->setAttribute('primary', 'false');
144 144
 		$productsElement->appendChild($product);
145 145
 		//--- add <ui-access>
146 146
 		$element = $this->_document->createElement('ui-access');
@@ -160,29 +160,29 @@  discard block
 block discarded – undo
160 160
 		$tagLibChangeElement->appendChild($tagLibInsertElement);
161 161
 		//--- add <taglibrary>
162 162
 		$this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary');
163
-		$element->setAttribute('doctypes','HTML,DWTemplate');
164
-		$element->setAttribute('id','DWTagLibrary_PRADO_tags');
165
-		$element->setAttribute('name','PRADO tags');
166
-		$element->setAttribute('prefix','<com:');
167
-		$element->setAttribute('tagchooser','PRADO/TagChooser.xml');
163
+		$element->setAttribute('doctypes', 'HTML,DWTemplate');
164
+		$element->setAttribute('id', 'DWTagLibrary_PRADO_tags');
165
+		$element->setAttribute('name', 'PRADO tags');
166
+		$element->setAttribute('prefix', '<com:');
167
+		$element->setAttribute('tagchooser', 'PRADO/TagChooser.xml');
168 168
 		$tagLibInsertElement->appendChild($element);
169 169
 
170 170
 		$element = $this->_document->createElement('file');
171
-		$element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml');
172
-		$element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
171
+		$element->setAttribute('name', 'Configuration/TagLibraries/PRADO/TagChooser.xml');
172
+		$element->setAttribute('destination', '$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
173 173
 		$this->_filesElement->appendChild($element);
174 174
 	}
175 175
 
176 176
 	public function addTag($tagName)
177 177
 	{
178 178
 		$element = $this->_document->createElement('file');
179
-		$element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
180
-		$element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
179
+		$element->setAttribute('name', 'Configuration/TagLibraries/PRADO/' . $tagName . '.vtm');
180
+		$element->setAttribute('destination', '$dreamweaver/Configuration/TagLibraries/PRADO/' . $tagName . '.vtm');
181 181
 		$this->_filesElement->appendChild($element);
182 182
 
183 183
 		$element = $this->_document->createElement('tagref');
184
-		$element->setAttribute('file','PRADO/'.$tagName.'.vtm');
185
-		$element->setAttribute('name',$tagName);
184
+		$element->setAttribute('file', 'PRADO/' . $tagName . '.vtm');
185
+		$element->setAttribute('name', $tagName);
186 186
 		$this->_tagLibraryElement->appendChild($element);
187 187
 	}
188 188
 
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 		$this->_document->standalone = true;
221 221
 		$this->_document->formatOutput = true;
222 222
 		$tclibrary = $this->_document->createElement('tclibrary');
223
-		$tclibrary->setAttribute('name','PRADO tags');
224
-		$tclibrary->setAttribute('desc','A collection of all PRADO tags.');
225
-		$tclibrary->setAttribute('reference','PRADO');
223
+		$tclibrary->setAttribute('name', 'PRADO tags');
224
+		$tclibrary->setAttribute('desc', 'A collection of all PRADO tags.');
225
+		$tclibrary->setAttribute('reference', 'PRADO');
226 226
 		$this->_document->appendChild($tclibrary);
227 227
 
228 228
 		$this->_category = $this->_document->createElement('category');
229
-		$this->_category->setAttribute('name','General');
230
-		$this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif');
229
+		$this->_category->setAttribute('name', 'General');
230
+		$this->_category->setAttribute('icon', 'Configuration/TagLibraries/Icons/Elements.gif');
231 231
 		$tclibrary->appendChild($this->_category);
232 232
 	}
233 233
 
234 234
 	public function addElement($elementName)
235 235
 	{
236 236
 		$element = $this->_document->createElement('element');
237
-		$element->setAttribute('name','com:'.$elementName);
238
-		$element->setAttribute('value','<com:'.$elementName.'>');
239
-		$element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName));
237
+		$element->setAttribute('name', 'com:' . $elementName);
238
+		$element->setAttribute('value', '<com:' . $elementName . '>');
239
+		$element->setAttribute('reference', 'PRADO,COM:' . strtoupper($elementName));
240 240
 		$this->_category->appendChild($element);
241 241
 	}
242 242
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@
 block discarded – undo
63 63
 				$option->setAttribute('caption','');
64 64
 				$attrib->appendChild($option);
65 65
 			}
66
-		}
67
-		else if($attribType!=='')
66
+		} else if($attribType!=='')
68 67
 		{
69 68
 			$attrib->setAttribute('type',$attribType);
70 69
 		}
Please login to merge, or discard this patch.
buildscripts/index/api_index.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
 	private $_index;	
11 11
 	private $_api;
12 12
 	
13
+	/**
14
+	 * @param string $api
15
+	 */
13 16
 	public function __construct($index_file, $api)
14 17
 	{
15 18
 		$this->_api = $api;
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		echo "Building search index...\n";
24 24
 		$files = $this->get_files($this->_api);
25 25
 		$count = 0;
26
-		foreach($files as $file)
26
+		foreach ($files as $file)
27 27
 		{
28 28
 			$content = $this->get_details($file, $this->_api);
29 29
 			
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			
32 32
 			$title = $content['class'];
33 33
 			
34
-			echo "  Adding ".$title."\n";
34
+			echo "  Adding " . $title . "\n";
35 35
 			
36 36
 			//unsearchable text
37 37
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $content['link']));
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 			//$doc->addField(Zend_Search_Lucene_Field::UnIndexed('text', $content['content']));
40 40
 			
41 41
 			//searchable
42
-			$body = strtolower($this->sanitize($content['content'])).' '.strtolower($title);			
43
-			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.',' ',$title))));
44
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
42
+			$body = strtolower($this->sanitize($content['content'])) . ' ' . strtolower($title);			
43
+			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower(str_replace('.', ' ', $title))));
44
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
45 45
 			$this->_index->addDocument($doc);
46 46
 			$count++;
47 47
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 
52 52
 	function sanitize($input) 
53 53
 	{
54
-		return htmlentities(strip_tags( $input ));
54
+		return htmlentities(strip_tags($input));
55 55
 	}	
56 56
 
57 57
 	function get_files($path)
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 		$files = array();
62 62
 		while (false !== ($entry = $d->read()))
63 63
 		{
64
-			$filepath = $path.'/'.$entry;
65
-			if(is_file($filepath) && strpos($entry, 'class-')===0)
64
+			$filepath = $path . '/' . $entry;
65
+			if (is_file($filepath) && strpos($entry, 'class-') === 0)
66 66
 				$files[] = realpath($filepath);
67 67
 		}
68 68
 		$d->close();
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 	function get_doc_content($file)
73 73
 	{
74 74
 		$content = file_get_contents($file);
75
-		$html = preg_replace('/<h1>/','~~~', $content);
75
+		$html = preg_replace('/<h1>/', '~~~', $content);
76 76
 		$html = preg_replace('/<![^~]+/m', '', $html);
77 77
 		$html = preg_replace('/<div class="credit">[\s\w\W\S]+/m', '', $html);
78
-		$html = preg_replace('/&nbsp;|~+|\s{2,}/',' ',$html);
79
-		$html = preg_replace('/\s{2,}/',' ',$html);
78
+		$html = preg_replace('/&nbsp;|~+|\s{2,}/', ' ', $html);
79
+		$html = preg_replace('/\s{2,}/', ' ', $html);
80 80
 		$text = strip_tags($html);
81
-		$text = str_replace(' , ',', ',$text);
81
+		$text = str_replace(' , ', ', ', $text);
82 82
 		return $text;
83 83
 	}
84 84
 	
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$replace = array('', '', '');
90 90
 		$path = str_replace($find, $replace, $file);
91 91
 		$result['class'] = $path;
92
-		$result['link'] = self::API_URL.$file;
92
+		$result['link'] = self::API_URL . $file;
93 93
 		return $result;
94 94
 	}
95 95
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -62,8 +62,9 @@
 block discarded – undo
62 62
 		while (false !== ($entry = $d->read()))
63 63
 		{
64 64
 			$filepath = $path.'/'.$entry;
65
-			if(is_file($filepath) && strpos($entry, 'class-')===0)
66
-				$files[] = realpath($filepath);
65
+			if(is_file($filepath) && strpos($entry, 'class-')===0) {
66
+							$files[] = realpath($filepath);
67
+			}
67 68
 		}
68 69
 		$d->close();
69 70
 		return $files;
Please login to merge, or discard this patch.
buildscripts/index/quickstart_index.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -8,6 +8,10 @@  discard block
 block discarded – undo
8 8
 	private $_base;
9 9
 	private $_source;
10 10
 
11
+	/**
12
+	 * @param string $base
13
+	 * @param string $source
14
+	 */
11 15
 	public function __construct($index_file, $base, $source)
12 16
 	{
13 17
 		$this->_index = new Zend_Search_Lucene($index_file, true);
@@ -37,6 +41,10 @@  discard block
 block discarded – undo
37 41
 		echo "\n {$count} files indexed.\n";
38 42
 	}
39 43
 
44
+	/**
45
+	 * @param string $content
46
+	 * @param integer $mtime
47
+	 */
40 48
 	public function add($content, $section, $mtime)
41 49
 	{
42 50
 		foreach($this->split_headings($content) as $headers)
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 		echo "Building search index...\n";
22 22
 		$pages = include($this->_source);
23 23
 		$count = 0;
24
-		foreach($pages as $chapter => $sections)
24
+		foreach ($pages as $chapter => $sections)
25 25
 		{
26
-			foreach($sections as $section)
26
+			foreach ($sections as $section)
27 27
 			{
28 28
 				echo "    Adding $section\n";
29
-				$page = $this->_base.'/'.$section;
29
+				$page = $this->_base . '/' . $section;
30 30
 				$file_content = file_get_contents($page);
31
-				$this->add($file_content,$section, filemtime($page));
31
+				$this->add($file_content, $section, filemtime($page));
32 32
 				$count++;
33 33
 			}
34 34
 		}
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 
40 40
 	public function add($content, $section, $mtime)
41 41
 	{
42
-		foreach($this->split_headings($content) as $headers)
42
+		foreach ($this->split_headings($content) as $headers)
43 43
 		{
44 44
 			$doc = new Zend_Search_Lucene_Document();
45
-			$link = "index.php?page=".preg_replace('/\/|\\\/', '.', $section);
46
-			$link = str_replace('.page', '', $link).'#'.$headers['section'];
45
+			$link = "index.php?page=" . preg_replace('/\/|\\\/', '.', $section);
46
+			$link = str_replace('.page', '', $link) . '#' . $headers['section'];
47 47
 
48 48
 			//unsearchable text
49 49
 			$doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $link));
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 
54 54
 			//searchable text
55 55
 			$doc->addField(Zend_Search_Lucene_Field::Keyword('page', strtolower($headers['title'])));
56
-			$body = strtolower($this->sanitize($headers['content'])).' '.strtolower($headers['title']);
57
-			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents',$body));
56
+			$body = strtolower($this->sanitize($headers['content'])) . ' ' . strtolower($headers['title']);
57
+			$doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $body));
58 58
 			$this->_index->addDocument($doc);
59 59
 		}
60 60
 	}
61 61
 
62 62
 	function sanitize($input)
63 63
 	{
64
-		return htmlentities(strip_tags( $input ));
64
+		return htmlentities(strip_tags($input));
65 65
 	}
66 66
 
67 67
 	public function index()
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 		$html = preg_replace('/<h3([^>]*)>([^<]*)<\/h3>/', '<hh$1>$2</hh>', $html);
83 83
 
84 84
 
85
-		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html,-1);
85
+		$sections = preg_split('/<hh[^>]*>([^<]+)<\/hh>/', $html, -1);
86 86
 		$headers = array();
87 87
 		preg_match_all('/<hh([^>]*)>([^<]+)<\/hh>/', $html, $headers);
88 88
 		$contents = array();
89
-		for($i = 1, $t = count($sections); $i < $t; $i++)
89
+		for ($i = 1, $t = count($sections); $i < $t; $i++)
90 90
 		{
91
-			$content['title'] = trim($this->sanitize($headers[2][$i-1]));
92
-			$content['section'] = str_replace('"', '',trim($headers[1][$i-1],'"'));
91
+			$content['title'] = trim($this->sanitize($headers[2][$i - 1]));
92
+			$content['section'] = str_replace('"', '', trim($headers[1][$i - 1], '"'));
93 93
 			$content['content'] = trim($this->sanitize($sections[$i]));
94 94
 			$contents[] = $content;
95 95
 		}
Please login to merge, or discard this patch.
buildscripts/texbuilder/Page2Tex.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -71,6 +71,9 @@
 block discarded – undo
71 71
 		}
72 72
 	}
73 73
 
74
+	/**
75
+	 * @param string $filename
76
+	 */
74 77
 	function include_figure($info, $filename)
75 78
 	{
76 79
 		$width = sprintf('%0.2f', $info[0]/(135/2.54));
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,10 +167,10 @@
 block discarded – undo
167 167
 
168 168
 		//DocLink
169 169
 		$html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^."]*)"\s+Text="([^"]+)"\s*\/>/',
170
-	                        '\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$3}', $html);
170
+							'\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$3}', $html);
171 171
 
172 172
 		$html = preg_replace('/<com:DocLink\s+ClassPath="([^"]*)[.]([^.]*)"\s+\/>/',
173
-	                        '\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
173
+							'\href{http://pradosoft.github.io/docs/manual/$1/$2.html}{$1.$2 API Reference}', $html);
174 174
 
175 175
 		//text modifiers
176 176
 		$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 {
5 5
 	private $_current_page;
6 6
 	private static $header_count = 0;
7
-	private static $p_count=0;
8
-	private static $hil_count=0;
9
-	private $page_count=0;
7
+	private static $p_count = 0;
8
+	private static $hil_count = 0;
9
+	private $page_count = 0;
10 10
 	private $_base;
11 11
 	private $_dir;
12 12
 
13
-	private $_verb_find = array('\$','\%', '\{', '\}', "\t",'``','`');
14
-	private $_verb_replace = array('$', '%', '{','}', "     ",'"','\'');
13
+	private $_verb_find = array('\$', '\%', '\{', '\}', "\t", '``', '`');
14
+	private $_verb_replace = array('$', '%', '{', '}', "     ", '"', '\'');
15 15
 
16
-	function __construct($base, $dir, $current='')
16
+	function __construct($base, $dir, $current = '')
17 17
 	{
18 18
 		$this->_base = $base;
19 19
 		$this->_current_page = $current;
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
 
23 23
 	function setCurrentPage($current)
24 24
 	{
25
-		self::$header_count = self::$header_count+1000;
25
+		self::$header_count = self::$header_count + 1000;
26 26
 		$this->_current_page = $current;
27 27
 	}
28 28
 
29 29
 	function escape_verbatim($matches)
30 30
 	{
31
-		return "\begin{small}\begin{verbatim}".
32
-				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]).
33
-				'\end{verbatim}\end{small}'."\n";
31
+		return "\begin{small}\begin{verbatim}" .
32
+				str_replace($this->_verb_find, $this->_verb_replace, $matches[1]) .
33
+				'\end{verbatim}\end{small}' . "\n";
34 34
 	}
35 35
 
36 36
 	function escape_verb($matches)
37 37
 	{
38 38
 		$text = str_replace($this->_verb_find, $this->_verb_replace, $matches[1]);
39
-		return '\begin{small}\verb<'.$text.'< \end{small}';
39
+		return '\begin{small}\verb<' . $text . '< \end{small}';
40 40
 	}
41 41
 
42 42
 	function include_image($matches)
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 
45 45
 		$current_path = $this->_current_page;
46 46
 
47
-		$image = dirname($current_path).'/'.trim($matches[1]);
47
+		$image = dirname($current_path) . '/' . trim($matches[1]);
48 48
 
49 49
 		$file = realpath($image);
50 50
 		$info = getimagesize($file);
51
-		switch($info[2])
51
+		switch ($info[2])
52 52
 		{
53 53
 			case 1:
54 54
 				$im = imagecreatefromgif($file);
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		}
59 59
 		$base = $this->_base;
60 60
 
61
-		if(isset($im))
61
+		if (isset($im))
62 62
 		{
63 63
 			$prefix = strtolower(str_replace(realpath($base), '', $file));
64
-			$filename = preg_replace('/\\\|\//', '_', substr($prefix,1));
65
-			$filename = substr($filename, 0, strrpos($filename,'.')).'.png';
66
-			$newfile = $this->_dir.'/'.$filename;
67
-			imagepng($im,$newfile);
64
+			$filename = preg_replace('/\\\|\//', '_', substr($prefix, 1));
65
+			$filename = substr($filename, 0, strrpos($filename, '.')) . '.png';
66
+			$newfile = $this->_dir . '/' . $filename;
67
+			imagepng($im, $newfile);
68 68
 			imagedestroy($im);
69 69
 
70 70
 			return $this->include_figure($info, $filename);
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 
74 74
 	function include_figure($info, $filename)
75 75
 	{
76
-		$width = sprintf('%0.2f', $info[0]/(135/2.54));
76
+		$width = sprintf('%0.2f', $info[0] / (135 / 2.54));
77 77
 		return '
78 78
 	\begin{figure}[!ht]
79 79
 		\centering
80
-			\includegraphics[width='.$width.'cm]{'.$filename.'}
81
-		\label{fig:'.$filename.'}
80
+			\includegraphics[width='.$width . 'cm]{' . $filename . '}
81
+		\label{fig:'.$filename . '}
82 82
 	\end{figure}
83 83
 	';
84 84
 	}
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	function anchor($matches)
87 87
 	{
88 88
 		$page = $this->get_current_path();
89
-		return '\hypertarget{'.$page.'/'.strtolower($matches[1]).'}{}';
89
+		return '\hypertarget{' . $page . '/' . strtolower($matches[1]) . '}{}';
90 90
 	}
91 91
 
92 92
 	function texttt($matches)
93 93
 	{
94
-		$text ='\texttt{'.str_replace(array('#','_','&amp;'),array('\#','\_','\&'), $matches[1]).'}';
94
+		$text = '\texttt{' . str_replace(array('#', '_', '&amp;'), array('\#', '\_', '\&'), $matches[1]) . '}';
95 95
 		//$text = preg_replace('/([^\\\\])&([^;]+)/', '$1\&$2', $text);
96 96
 		return $text;
97 97
 	}
@@ -100,39 +100,39 @@  discard block
 block discarded – undo
100 100
 	{
101 101
 		$current_path = $this->_current_page;
102 102
 		$base = $this->_base;
103
-		$page = strtolower(substr(str_replace($base, '', $current_path),1));
103
+		$page = strtolower(substr(str_replace($base, '', $current_path), 1));
104 104
 		return $page;
105 105
 	}
106 106
 
107 107
 	function make_link($matches)
108 108
 	{
109
-		if(is_int(strpos($matches[1], '#')))
109
+		if (is_int(strpos($matches[1], '#')))
110 110
 		{
111
-			if(strpos($matches[1],'?') ===false)
111
+			if (strpos($matches[1], '?') === false)
112 112
 			{
113
-				if(strpos($matches[1],'http://')===false)
113
+				if (strpos($matches[1], 'http://') === false)
114 114
 				{
115
-					$target = $this->get_current_path().'/'.substr($matches[1],1);
116
-					return '\hyperlink{'.$target.'}{'.$matches[2].'}';
115
+					$target = $this->get_current_path() . '/' . substr($matches[1], 1);
116
+					return '\hyperlink{' . $target . '}{' . $matches[2] . '}';
117 117
 				}
118 118
 			}
119 119
 			else
120 120
 			{
121 121
 				$page = strtolower(str_replace('?page=', '', $matches[1]));
122
-				$page = str_replace('.','/',$page);
123
-				$page = str_replace('#','.page/',$page);
124
-				return '\hyperlink{'.$page.'}{'.$matches[2].'}';
122
+				$page = str_replace('.', '/', $page);
123
+				$page = str_replace('#', '.page/', $page);
124
+				return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
125 125
 			}
126 126
 		}
127
-		else if(is_int(strpos($matches[1],'?')))
127
+		else if (is_int(strpos($matches[1], '?')))
128 128
 		{
129
-			$page = str_replace('?page=','',$matches[1]);
130
-			return '\hyperlink{'.$page.'}{'.$matches[2].'}';
129
+			$page = str_replace('?page=', '', $matches[1]);
130
+			return '\hyperlink{' . $page . '}{' . $matches[2] . '}';
131 131
 		}
132
-		return '\href{'.str_replace('#','\\#',$matches[1]).'}{'.$matches[2].'}';
132
+		return '\href{' . str_replace('#', '\\#', $matches[1]) . '}{' . $matches[2] . '}';
133 133
 	}
134 134
 
135
-	function parse_html($page,$html)
135
+	function parse_html($page, $html)
136 136
 	{
137 137
 		$html = preg_replace('/<\/?com:TContent[^>]*>/', '', $html);
138 138
 		$html = preg_replace('/<\/?p [^>]*>/', '', $html);
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
 		//codes
153 153
 		$html = str_replace('$', '\$', $html);
154 154
 
155
-		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this,'escape_verbatim'), $html);
155
+		$html = preg_replace_callback('/<com:TTextHighlighter[^>]*>((.|\n)*?)<\/com:TTextHighlighter\s*>/', array($this, 'escape_verbatim'), $html);
156 156
 //		$html = preg_replace('/<\/com:TTextHighlighter>/', '`2`', $html);
157 157
 //		$html = preg_replace_callback('/(`1`)([^`]*)(`2`)/m', array($this,'escape_verbatim'), $html);
158
-		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this,'escape_verbatim'), $html);
159
-		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this,'escape_verbatim'), $html);
158
+		$html = preg_replace_callback('/(<div class="source">)((.|\n)*?)(<\/div>)/', array($this, 'escape_verbatim'), $html);
159
+		$html = preg_replace_callback('/(<pre>)([^<]*)(<\/pre>)/', array($this, 'escape_verbatim'), $html);
160 160
 
161 161
 		//<code>
162
-		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this,'escape_verb'), $html);
162
+		$html = preg_replace_callback('/<code>([^<]*)<\/code>/', array($this, 'escape_verb'), $html);
163 163
 
164 164
 		//runbar
165 165
 		$html = preg_replace('/<com:RunBar\s+PagePath="([^"]*)"\s+\/>/',
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		//text modifiers
176 176
 		$html = preg_replace('/<(b|strong)[^>]*>([^<]*)<\/(b|strong)>/', '\textbf{$2}', $html);
177 177
 		$html = preg_replace('/<i [^>]*>([^<]*)+?<\/i>/', '\emph{$1}', $html);
178
-		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this,'texttt'), $html);
178
+		$html = preg_replace_callback('/<tt>([^<]*)<\/tt>/', array($this, 'texttt'), $html);
179 179
 
180 180
 		//links
181 181
 		$html = preg_replace_callback('/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/',
182
-								array($this,'make_link'), $html);
182
+								array($this, 'make_link'), $html);
183 183
 		//anchor
184
-		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this,'anchor'), $html);
184
+		$html = preg_replace_callback('/<a[^>]+name="([^"]*)"[^>]*><\/a>/', array($this, 'anchor'), $html);
185 185
 
186 186
 		//description <dl>
187 187
 		$html = preg_replace('/<dt>([^<]*)<\/dt>/', '\item[$1]', $html);
@@ -230,20 +230,20 @@  discard block
 block discarded – undo
230 230
 	function tabular($matches)
231 231
 	{
232 232
 		$options = array();
233
-		foreach(explode(',', $matches[1]) as $string)
233
+		foreach (explode(',', $matches[1]) as $string)
234 234
 		{
235 235
 			$sub = explode('=', trim($string));
236 236
 			$options[trim($sub[0])] = trim($sub[1]);
237 237
 		}
238 238
 
239
-		$widths = explode(' ',preg_replace('/\(|\)/', '', $options['width']));
239
+		$widths = explode(' ', preg_replace('/\(|\)/', '', $options['width']));
240 240
 		$this->_tabular_widths = $widths;
241 241
 
242 242
 		$this->_tabular_total = count($widths);
243 243
 		$this->_tabular_col = 0;
244 244
 
245
-		$begin = '\begin{table}[!hpt]\centering '."\n".' \begin{tabular}{'.$options['align'].'}\hline';
246
-		$end = '\end{tabular} '."\n".'\end{table}'."\n";
245
+		$begin = '\begin{table}[!hpt]\centering ' . "\n" . ' \begin{tabular}{' . $options['align'] . '}\hline';
246
+		$end = '\end{tabular} ' . "\n" . '\end{table}' . "\n";
247 247
 		$table = preg_replace('/<\/tr>/', '\\\\\\\\ \hline', $matches[2]);
248 248
 		$table = preg_replace('/<tr>/', '', $table);
249 249
 		$table = preg_replace('/<th>([^<]+)<\/th>/', '\textbf{$1} &', $table);
@@ -251,95 +251,95 @@  discard block
 block discarded – undo
251 251
 		$table = preg_replace('/<br \/>/', ' \\\\\\\\', $table);
252 252
 
253 253
 		$table = preg_replace('/&\s*\\\\\\\\/', '\\\\\\\\', $table);
254
-		return $begin.$table.$end;
254
+		return $begin . $table . $end;
255 255
 	}
256 256
 
257 257
 	function table_column($matches)
258 258
 	{
259 259
 		$width = $this->_tabular_widths[$this->_tabular_col];
260
-		if($this->_tabular_col >= $this->_tabular_total-1)
260
+		if ($this->_tabular_col >= $this->_tabular_total - 1)
261 261
 			$this->_tabular_col = 0;
262 262
 		else
263 263
 			$this->_tabular_col++;
264
-		return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
265
-			$matches[1].'\vspace{3mm}\end{minipage} & ';
264
+		return '\begin{minipage}{' . $width . '\textwidth}\vspace{3mm}' .
265
+			$matches[1] . '\vspace{3mm}\end{minipage} & ';
266 266
 	}
267 267
 
268 268
 	function mbox($matches)
269 269
 	{
270
-		return "\n\begin{mybox}\n".$matches[1]."\n".'\end{mybox}'."\n";
270
+		return "\n\begin{mybox}\n" . $matches[1] . "\n" . '\end{mybox}' . "\n";
271 271
 	}
272 272
 
273 273
 	function get_chapter_label($chapter)
274 274
 	{
275
-		return '\hypertarget{'.str_replace(' ', '', $chapter).'}{}';
275
+		return '\hypertarget{' . str_replace(' ', '', $chapter) . '}{}';
276 276
 	}
277 277
 
278 278
 	function get_section_label($section)
279 279
 	{
280 280
 		$section = str_replace('.page', '', $section);
281
-		return '\hypertarget{'.str_replace('/', '.', $section).'}{}';
281
+		return '\hypertarget{' . str_replace('/', '.', $section) . '}{}';
282 282
 	}
283 283
 
284 284
 
285 285
 	function set_header_id($content, $j)
286 286
 	{
287
-		$this->page_count=$j;
288
-		$content = preg_replace_callback('/<h1>/', array($this,"h1"), $content);
289
-		$content = preg_replace_callback('/<h2>/', array($this,"h2"), $content);
290
-		$content = preg_replace_callback('/<h3>/', array($this,"h3"), $content);
287
+		$this->page_count = $j;
288
+		$content = preg_replace_callback('/<h1>/', array($this, "h1"), $content);
289
+		$content = preg_replace_callback('/<h2>/', array($this, "h2"), $content);
290
+		$content = preg_replace_callback('/<h3>/', array($this, "h3"), $content);
291 291
 		$content = $this->set_block_content_id($content);
292 292
 		return $content;
293 293
 	}
294 294
 
295 295
 	function h1($matches)
296 296
 	{
297
-		$page = $this->page_count*1000;
298
-		return "<h1 id=\"".($page + (++self::$header_count))."\">";
297
+		$page = $this->page_count * 1000;
298
+		return "<h1 id=\"" . ($page + (++self::$header_count)) . "\">";
299 299
 	}
300 300
 
301 301
 	function h2($matches)
302 302
 	{
303
-		$page = $this->page_count*1000;
304
-		return "<h2 id=\"".($page + (++self::$header_count))."\">";
303
+		$page = $this->page_count * 1000;
304
+		return "<h2 id=\"" . ($page + (++self::$header_count)) . "\">";
305 305
 	}
306 306
 
307 307
 	function h3($matches)
308 308
 	{
309
-		$page = $this->page_count*1000;
310
-		return "<h3 id=\"".($page + (++self::$header_count))."\">";
309
+		$page = $this->page_count * 1000;
310
+		return "<h3 id=\"" . ($page + (++self::$header_count)) . "\">";
311 311
 	}
312 312
 
313 313
 	function set_block_content_id($content)
314 314
 	{
315
-		$content = preg_replace_callback('/<p>/',  array($this, 'add_p'), $content);
315
+		$content = preg_replace_callback('/<p>/', array($this, 'add_p'), $content);
316 316
 		$content = preg_replace_callback('/<com:TTextHighlighter([^>]+)>/', array($this, 'hil'), $content);
317 317
 		return $content;
318 318
 	}
319 319
 
320 320
 	function hil($matches)
321 321
 	{
322
-		$id = ($this->page_count*10000) + (++self::$hil_count);
323
-		if(preg_match('/id="code-\d+"/i', $matches[1]))
322
+		$id = ($this->page_count * 10000) + (++self::$hil_count);
323
+		if (preg_match('/id="code-\d+"/i', $matches[1]))
324 324
 		{
325 325
 			$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
326 326
 			//var_dump($code);
327 327
 			return $code;
328 328
 		}
329
-		else if(preg_match('/id="[^"]+"/i', $matches[1]))
329
+		else if (preg_match('/id="[^"]+"/i', $matches[1]))
330 330
 		{
331 331
 			return $matches[0];
332 332
 		}
333 333
 		else
334 334
 		{
335
-			$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
335
+			$changes = str_replace('"source"', '"source block-content" id="code-' . $id . '"', $matches[0]);
336 336
 			return $changes;
337 337
 		}
338 338
 	}
339 339
 
340 340
 	function add_p($matches)
341 341
 	{
342
-		 $page = $this->page_count*10000;
343
-		 return "<p id=\"".($page + (++self::$p_count))."\" class=\"block-content\">";
342
+		 $page = $this->page_count * 10000;
343
+		 return "<p id=\"" . ($page + (++self::$p_count)) . "\" class=\"block-content\">";
344 344
 	}
345 345
 }
Please login to merge, or discard this patch.
Braces   +9 added lines, -12 removed lines patch added patch discarded remove patch
@@ -115,16 +115,14 @@  discard block
 block discarded – undo
115 115
 					$target = $this->get_current_path().'/'.substr($matches[1],1);
116 116
 					return '\hyperlink{'.$target.'}{'.$matches[2].'}';
117 117
 				}
118
-			}
119
-			else
118
+			} else
120 119
 			{
121 120
 				$page = strtolower(str_replace('?page=', '', $matches[1]));
122 121
 				$page = str_replace('.','/',$page);
123 122
 				$page = str_replace('#','.page/',$page);
124 123
 				return '\hyperlink{'.$page.'}{'.$matches[2].'}';
125 124
 			}
126
-		}
127
-		else if(is_int(strpos($matches[1],'?')))
125
+		} else if(is_int(strpos($matches[1],'?')))
128 126
 		{
129 127
 			$page = str_replace('?page=','',$matches[1]);
130 128
 			return '\hyperlink{'.$page.'}{'.$matches[2].'}';
@@ -257,10 +255,11 @@  discard block
 block discarded – undo
257 255
 	function table_column($matches)
258 256
 	{
259 257
 		$width = $this->_tabular_widths[$this->_tabular_col];
260
-		if($this->_tabular_col >= $this->_tabular_total-1)
261
-			$this->_tabular_col = 0;
262
-		else
263
-			$this->_tabular_col++;
258
+		if($this->_tabular_col >= $this->_tabular_total-1) {
259
+					$this->_tabular_col = 0;
260
+		} else {
261
+					$this->_tabular_col++;
262
+		}
264 263
 		return '\begin{minipage}{'.$width.'\textwidth}\vspace{3mm}'.
265 264
 			$matches[1].'\vspace{3mm}\end{minipage} & ';
266 265
 	}
@@ -325,12 +324,10 @@  discard block
 block discarded – undo
325 324
 			$code = preg_replace('/id="code-(\d+)"/', 'id="code_$1"', $matches[0]);
326 325
 			//var_dump($code);
327 326
 			return $code;
328
-		}
329
-		else if(preg_match('/id="[^"]+"/i', $matches[1]))
327
+		} else if(preg_match('/id="[^"]+"/i', $matches[1]))
330 328
 		{
331 329
 			return $matches[0];
332
-		}
333
-		else
330
+		} else
334 331
 		{
335 332
 			$changes = str_replace('"source"', '"source block-content" id="code-'.$id.'"', $matches[0]);
336 333
 			return $changes;
Please login to merge, or discard this patch.
demos/blog-tutorial/samples/day5/blog/protected/pages/posts/ListPost.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -48,6 +48,7 @@
 block discarded – undo
48 48
 
49 49
 	/**
50 50
 	 * Fetches posts from database with offset and limit.
51
+	 * @param double $offset
51 52
 	 */
52 53
 	protected function getPosts($offset, $limit)
53 54
 	{
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 	public function onInit($param)
11 11
 	{
12 12
 		parent::onInit($param);
13
-		if(!$this->IsPostBack)  // if the page is requested the first time
13
+		if (!$this->IsPostBack)  // if the page is requested the first time
14 14
 		{
15 15
 			// get the total number of posts available
16
-			$this->Repeater->VirtualItemCount=PostRecord::finder()->count();
16
+			$this->Repeater->VirtualItemCount = PostRecord::finder()->count();
17 17
 			// populates post data into the repeater
18 18
 			$this->populateData();
19 19
 		}
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 	 * This method is invoked when the user clicks on a page button
25 25
 	 * and thus changes the page of posts to display.
26 26
 	 */
27
-	public function pageChanged($sender,$param)
27
+	public function pageChanged($sender, $param)
28 28
 	{
29 29
 		// change the current page index to the new one
30
-		$this->Repeater->CurrentPageIndex=$param->NewPageIndex;
30
+		$this->Repeater->CurrentPageIndex = $param->NewPageIndex;
31 31
 		// re-populate data into the repeater
32 32
 		$this->populateData();
33 33
 	}
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	protected function populateData()
40 40
 	{
41
-		$offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
42
-		$limit=$this->Repeater->PageSize;
43
-		if($offset+$limit>$this->Repeater->VirtualItemCount)
44
-			$limit=$this->Repeater->VirtualItemCount-$offset;
45
-		$this->Repeater->DataSource=$this->getPosts($offset,$limit);
41
+		$offset = $this->Repeater->CurrentPageIndex * $this->Repeater->PageSize;
42
+		$limit = $this->Repeater->PageSize;
43
+		if ($offset + $limit > $this->Repeater->VirtualItemCount)
44
+			$limit = $this->Repeater->VirtualItemCount - $offset;
45
+		$this->Repeater->DataSource = $this->getPosts($offset, $limit);
46 46
 		$this->Repeater->dataBind();
47 47
 	}
48 48
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	protected function getPosts($offset, $limit)
53 53
 	{
54 54
 		// Construts a query criteria
55
-		$criteria=new TActiveRecordCriteria;
56
-		$criteria->OrdersBy['create_time']='desc';
57
-		$criteria->Limit=$limit;
58
-		$criteria->Offset=$offset;
55
+		$criteria = new TActiveRecordCriteria;
56
+		$criteria->OrdersBy['create_time'] = 'desc';
57
+		$criteria->Limit = $limit;
58
+		$criteria->Offset = $offset;
59 59
 		// query for the posts with the above criteria and with author information
60 60
 		return PostRecord::finder()->withAuthor()->findAll($criteria);
61 61
 	}
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,10 +10,12 @@  discard block
 block discarded – undo
10 10
 	public function onInit($param)
11 11
 	{
12 12
 		parent::onInit($param);
13
-		if(!$this->IsPostBack)  // if the page is requested the first time
13
+		if(!$this->IsPostBack) {
14
+			// if the page is requested the first time
14 15
 		{
15 16
 			// get the total number of posts available
16 17
 			$this->Repeater->VirtualItemCount=PostRecord::finder()->count();
18
+		}
17 19
 			// populates post data into the repeater
18 20
 			$this->populateData();
19 21
 		}
@@ -40,8 +42,9 @@  discard block
 block discarded – undo
40 42
 	{
41 43
 		$offset=$this->Repeater->CurrentPageIndex*$this->Repeater->PageSize;
42 44
 		$limit=$this->Repeater->PageSize;
43
-		if($offset+$limit>$this->Repeater->VirtualItemCount)
44
-			$limit=$this->Repeater->VirtualItemCount-$offset;
45
+		if($offset+$limit>$this->Repeater->VirtualItemCount) {
46
+					$limit=$this->Repeater->VirtualItemCount-$offset;
47
+		}
45 48
 		$this->Repeater->DataSource=$this->getPosts($offset,$limit);
46 49
 		$this->Repeater->dataBind();
47 50
 	}
Please login to merge, or discard this patch.