@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | {$this->action} {$parameters}{$optional} |
187 | 187 | {$description} |
188 | 188 | |
189 | -EOD; |
|
189 | +eod; |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | protected function initializePradoApplication($directory) |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | </parameters> |
345 | 345 | --> |
346 | 346 | </application> |
347 | -EOD; |
|
347 | +eod; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | protected function renderHtaccessFile() |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | <h1>Welcome to PRADO!</h1> |
365 | 365 | </body> |
366 | 366 | </html> |
367 | -EOD; |
|
367 | +eod; |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | * @soapproperty |
586 | 586 | */ |
587 | 587 | |
588 | -EOD; |
|
588 | +eod; |
|
589 | 589 | } |
590 | 590 | $prop .= "\tpublic $name;"; |
591 | 591 | return $prop; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
615 | -EOD; |
|
615 | +eod; |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 |
@@ -9,15 +9,15 @@ discard block |
||
9 | 9 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
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 | 16 | // Locate composer's autoloader |
17 | -if (file_exists($autoloader = realpath(__DIR__ . '/../vendor/autoload.php'))) { |
|
17 | +if(file_exists($autoloader = realpath(__DIR__ . '/../vendor/autoload.php'))) { |
|
18 | 18 | // if we are running inside a prado repo checkout, get out of bin/ |
19 | 19 | include($autoloader); |
20 | -} elseif (file_exists($autoloader = realpath(__DIR__ . '/../../../autoload.php'))) { |
|
20 | +} elseif(file_exists($autoloader = realpath(__DIR__ . '/../../../autoload.php'))) { |
|
21 | 21 | // if we are running from inside an application's vendor/ directory, get out of pradosoft/prado/bin/ |
22 | 22 | include($autoloader); |
23 | 23 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public static function getInstance() |
79 | 79 | { |
80 | 80 | static $instance; |
81 | - if ($instance === null) { |
|
81 | + if($instance === null) { |
|
82 | 82 | $instance = new self; |
83 | 83 | } |
84 | 84 | return $instance; |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function run($args) |
97 | 97 | { |
98 | - if (count($args) > 1) { |
|
98 | + if(count($args) > 1) { |
|
99 | 99 | array_shift($args); |
100 | 100 | } |
101 | 101 | $valid = false; |
102 | - foreach ($this->_actions as $class => $action) { |
|
103 | - if ($action->isValidAction($args)) { |
|
102 | + foreach($this->_actions as $class => $action) { |
|
103 | + if($action->isValidAction($args)) { |
|
104 | 104 | $valid |= $action->performAction($args); |
105 | 105 | break; |
106 | 106 | } else { |
107 | 107 | $valid = false; |
108 | 108 | } |
109 | 109 | } |
110 | - if (!$valid) { |
|
110 | + if(!$valid) { |
|
111 | 111 | $this->printHelp(); |
112 | 112 | } |
113 | 113 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | echo "usage: php prado-cli.php action <parameter> [optional]\n"; |
123 | 123 | echo "example: php prado-cli.php -c mysite\n\n"; |
124 | 124 | echo "actions:\n"; |
125 | - foreach ($this->_actions as $action) { |
|
125 | + foreach($this->_actions as $action) { |
|
126 | 126 | echo $action->renderHelp(); |
127 | 127 | } |
128 | 128 | } |
@@ -145,18 +145,18 @@ discard block |
||
145 | 145 | |
146 | 146 | protected function createDirectory($dir, $mask) |
147 | 147 | { |
148 | - if (!is_dir($dir)) { |
|
148 | + if(!is_dir($dir)) { |
|
149 | 149 | mkdir($dir); |
150 | 150 | echo "creating $dir\n"; |
151 | 151 | } |
152 | - if (is_dir($dir)) { |
|
152 | + if(is_dir($dir)) { |
|
153 | 153 | chmod($dir, $mask); |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | 157 | protected function createFile($filename, $content) |
158 | 158 | { |
159 | - if (!is_file($filename)) { |
|
159 | + if(!is_file($filename)) { |
|
160 | 160 | file_put_contents($filename, $content); |
161 | 161 | echo "creating $filename\n"; |
162 | 162 | } |
@@ -171,17 +171,17 @@ discard block |
||
171 | 171 | public function renderHelp() |
172 | 172 | { |
173 | 173 | $params = []; |
174 | - foreach ($this->parameters as $v) { |
|
174 | + foreach($this->parameters as $v) { |
|
175 | 175 | $params[] = '<' . $v . '>'; |
176 | 176 | } |
177 | 177 | $parameters = implode($params, ' '); |
178 | 178 | $options = []; |
179 | - foreach ($this->optional as $v) { |
|
179 | + foreach($this->optional as $v) { |
|
180 | 180 | $options[] = '[' . $v . ']'; |
181 | 181 | } |
182 | 182 | $optional = (strlen($parameters) ? ' ' : '') . implode($options, ' '); |
183 | 183 | $description = ''; |
184 | - foreach (explode("\n", wordwrap($this->description, 65)) as $line) { |
|
184 | + foreach(explode("\n", wordwrap($this->description, 65)) as $line) { |
|
185 | 185 | $description .= ' ' . $line . "\n"; |
186 | 186 | } |
187 | 187 | return <<<EOD |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | { |
196 | 196 | $_SERVER['SCRIPT_FILENAME'] = $directory . '/index.php'; |
197 | 197 | $app_dir = realpath($directory . '/protected/'); |
198 | - if ($app_dir !== false && is_dir($app_dir)) { |
|
199 | - if (Prado::getApplication() === null) { |
|
198 | + if($app_dir !== false && is_dir($app_dir)) { |
|
199 | + if(Prado::getApplication() === null) { |
|
200 | 200 | $app = new PradoShellApplication($app_dir); |
201 | 201 | $app->run(); |
202 | 202 | $dir = substr(str_replace(realpath('./'), '', $app_dir), 1); |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | */ |
241 | 241 | protected function createNewPradoProject($dir) |
242 | 242 | { |
243 | - if (strlen(trim($dir)) == 0) { |
|
243 | + if(strlen(trim($dir)) == 0) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | 247 | $rootPath = realpath(dirname(trim($dir))); |
248 | 248 | |
249 | - if (basename($dir) !== '.') { |
|
249 | + if(basename($dir) !== '.') { |
|
250 | 250 | $basePath = $rootPath . DIRECTORY_SEPARATOR . basename($dir); |
251 | 251 | } else { |
252 | 252 | $basePath = $rootPath; |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | |
390 | 390 | protected function createTestFixtures($dir) |
391 | 391 | { |
392 | - if (strlen(trim($dir)) == 0) { |
|
392 | + if(strlen(trim($dir)) == 0) { |
|
393 | 393 | return; |
394 | 394 | } |
395 | 395 | |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | |
457 | 457 | public function performAction($args) |
458 | 458 | { |
459 | - if (count($args) > 1) { |
|
459 | + if(count($args) > 1) { |
|
460 | 460 | $this->initializePradoApplication($args[1]); |
461 | 461 | } |
462 | 462 | |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | { |
484 | 484 | $app_dir = count($args) > 3 ? $this->getAppDir($args[3]) : $this->getAppDir(); |
485 | 485 | $this->_soap = count($args) > 4; |
486 | - if ($app_dir !== false) { |
|
486 | + if($app_dir !== false) { |
|
487 | 487 | $config = $this->getActiveRecordConfig($app_dir); |
488 | 488 | $output = $this->getOutputFile($app_dir, $args[2]); |
489 | - if (is_file($output)) { |
|
489 | + if(is_file($output)) { |
|
490 | 490 | echo "** File $output already exists, skiping. \n"; |
491 | - } elseif ($config !== false && $output !== false) { |
|
491 | + } elseif($config !== false && $output !== false) { |
|
492 | 492 | $this->generateActiveRecord($config, $args[1], $output); |
493 | 493 | } |
494 | 494 | } |
@@ -497,10 +497,10 @@ discard block |
||
497 | 497 | |
498 | 498 | protected function getAppDir($dir = ".") |
499 | 499 | { |
500 | - if (is_dir($dir)) { |
|
500 | + if(is_dir($dir)) { |
|
501 | 501 | return realpath($dir); |
502 | 502 | } |
503 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) { |
|
503 | + if(false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) { |
|
504 | 504 | return $app_dir; |
505 | 505 | } |
506 | 506 | echo '** Unable to find directory "' . $dir . "\".\n"; |
@@ -509,10 +509,10 @@ discard block |
||
509 | 509 | |
510 | 510 | protected function getXmlFile($app_dir) |
511 | 511 | { |
512 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) { |
|
512 | + if(false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) { |
|
513 | 513 | return $xml; |
514 | 514 | } |
515 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) { |
|
515 | + if(false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) { |
|
516 | 516 | return $xml; |
517 | 517 | } |
518 | 518 | echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
@@ -521,13 +521,13 @@ discard block |
||
521 | 521 | |
522 | 522 | protected function getActiveRecordConfig($app_dir) |
523 | 523 | { |
524 | - if (false === ($xml = $this->getXmlFile($app_dir))) { |
|
524 | + if(false === ($xml = $this->getXmlFile($app_dir))) { |
|
525 | 525 | return false; |
526 | 526 | } |
527 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
527 | + if(false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
528 | 528 | Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
529 | - foreach ($app->getModules() as $module) { |
|
530 | - if ($module instanceof TActiveRecordConfig) { |
|
529 | + foreach($app->getModules() as $module) { |
|
530 | + if($module instanceof TActiveRecordConfig) { |
|
531 | 531 | return $module; |
532 | 532 | } |
533 | 533 | } |
@@ -538,12 +538,12 @@ discard block |
||
538 | 538 | |
539 | 539 | protected function getOutputFile($app_dir, $namespace) |
540 | 540 | { |
541 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) { |
|
541 | + if(is_file($namespace) && strpos($namespace, $app_dir) === 0) { |
|
542 | 542 | return $namespace; |
543 | 543 | } |
544 | 544 | $file = Prado::getPathOfNamespace($namespace, ".php"); |
545 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
546 | - if (strpos($path, $app_dir) === 0) { |
|
545 | + if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
546 | + if(strpos($path, $app_dir) === 0) { |
|
547 | 547 | return $file; |
548 | 548 | } |
549 | 549 | } |
@@ -554,15 +554,15 @@ discard block |
||
554 | 554 | protected function generateActiveRecord($config, $tablename, $output) |
555 | 555 | { |
556 | 556 | $manager = TActiveRecordManager::getInstance(); |
557 | - if ($manager->getDbConnection()) { |
|
557 | + if($manager->getDbConnection()) { |
|
558 | 558 | $gateway = $manager->getRecordGateway(); |
559 | 559 | $tableInfo = $gateway->getTableInfo($manager->getDbConnection(), $tablename); |
560 | - if (count($tableInfo->getColumns()) === 0) { |
|
560 | + if(count($tableInfo->getColumns()) === 0) { |
|
561 | 561 | echo '** Unable to find table or view "' . $tablename . '" in "' . $manager->getDbConnection()->getConnectionString() . "\".\n"; |
562 | 562 | return false; |
563 | 563 | } else { |
564 | 564 | $properties = []; |
565 | - foreach ($tableInfo->getColumns() as $field => $column) { |
|
565 | + foreach($tableInfo->getColumns() as $field => $column) { |
|
566 | 566 | $properties[] = $this->generateProperty($field, $column); |
567 | 567 | } |
568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $prop = ''; |
582 | 582 | $name = '$' . $field; |
583 | 583 | $type = $column->getPHPType(); |
584 | - if ($this->_soap) { |
|
584 | + if($this->_soap) { |
|
585 | 585 | $prop .= <<<EOD |
586 | 586 | |
587 | 587 | /** |
@@ -646,14 +646,14 @@ discard block |
||
646 | 646 | $this->_prefix = count($args) > 5 ? $args[5] : ''; |
647 | 647 | $this->_postfix = count($args) > 6 ? $args[6] : ''; |
648 | 648 | |
649 | - if ($app_dir !== false) { |
|
649 | + if($app_dir !== false) { |
|
650 | 650 | $config = $this->getActiveRecordConfig($app_dir); |
651 | 651 | |
652 | 652 | $manager = TActiveRecordManager::getInstance(); |
653 | 653 | $con = $manager->getDbConnection(); |
654 | 654 | $con->Active = true; |
655 | 655 | |
656 | - switch ($con->getDriverName()) { |
|
656 | + switch($con->getDriverName()) { |
|
657 | 657 | case 'mysqli': |
658 | 658 | case 'mysql': |
659 | 659 | $command = $con->createCommand("SHOW TABLES"); |
@@ -676,13 +676,13 @@ discard block |
||
676 | 676 | $dataReader = $command->query(); |
677 | 677 | $dataReader->bindColumn(1, $table); |
678 | 678 | $tables = []; |
679 | - while ($dataReader->read() !== false) { |
|
679 | + while($dataReader->read() !== false) { |
|
680 | 680 | $tables[] = $table; |
681 | 681 | } |
682 | 682 | $con->Active = false; |
683 | - foreach ($tables as $key => $table) { |
|
683 | + foreach($tables as $key => $table) { |
|
684 | 684 | $output = $args[1] . "." . $this->_prefix . ucfirst($table) . $this->_postfix; |
685 | - if ($config !== false && $output !== false) { |
|
685 | + if($config !== false && $output !== false) { |
|
686 | 686 | $this->generate("generate " . $table . " " . $output . " " . $this->_soap . " " . $this->_overwrite); |
687 | 687 | } |
688 | 688 | } |
@@ -693,14 +693,14 @@ discard block |
||
693 | 693 | public function generate($l) |
694 | 694 | { |
695 | 695 | $input = explode(" ", trim($l)); |
696 | - if (count($input) > 2) { |
|
696 | + if(count($input) > 2) { |
|
697 | 697 | $app_dir = '.'; |
698 | - if (Prado::getApplication() !== null) { |
|
698 | + if(Prado::getApplication() !== null) { |
|
699 | 699 | $app_dir = dirname(Prado::getApplication()->getBasePath()); |
700 | 700 | } |
701 | - $args = [$input[0],$input[1], $input[2],$app_dir]; |
|
702 | - if (count($input) > 3) { |
|
703 | - $args = [$input[0],$input[1], $input[2],$app_dir,'soap']; |
|
701 | + $args = [$input[0], $input[1], $input[2], $app_dir]; |
|
702 | + if(count($input) > 3) { |
|
703 | + $args = [$input[0], $input[1], $input[2], $app_dir, 'soap']; |
|
704 | 704 | } |
705 | 705 | $cmd = new PradoCommandLineActiveRecordGen; |
706 | 706 | $cmd->performAction($args); |
@@ -711,10 +711,10 @@ discard block |
||
711 | 711 | |
712 | 712 | protected function getAppDir($dir = ".") |
713 | 713 | { |
714 | - if (is_dir($dir)) { |
|
714 | + if(is_dir($dir)) { |
|
715 | 715 | return realpath($dir); |
716 | 716 | } |
717 | - if (false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) { |
|
717 | + if(false !== ($app_dir = realpath($dir . '/protected/')) && is_dir($app_dir)) { |
|
718 | 718 | return $app_dir; |
719 | 719 | } |
720 | 720 | echo '** Unable to find directory "' . $dir . "\".\n"; |
@@ -723,10 +723,10 @@ discard block |
||
723 | 723 | |
724 | 724 | protected function getXmlFile($app_dir) |
725 | 725 | { |
726 | - if (false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) { |
|
726 | + if(false !== ($xml = realpath($app_dir . '/application.xml')) && is_file($xml)) { |
|
727 | 727 | return $xml; |
728 | 728 | } |
729 | - if (false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) { |
|
729 | + if(false !== ($xml = realpath($app_dir . '/protected/application.xml')) && is_file($xml)) { |
|
730 | 730 | return $xml; |
731 | 731 | } |
732 | 732 | echo '** Unable to find application.xml in ' . $app_dir . "\n"; |
@@ -735,13 +735,13 @@ discard block |
||
735 | 735 | |
736 | 736 | protected function getActiveRecordConfig($app_dir) |
737 | 737 | { |
738 | - if (false === ($xml = $this->getXmlFile($app_dir))) { |
|
738 | + if(false === ($xml = $this->getXmlFile($app_dir))) { |
|
739 | 739 | return false; |
740 | 740 | } |
741 | - if (false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
741 | + if(false !== ($app = $this->initializePradoApplication($app_dir))) { |
|
742 | 742 | Prado::using('System.Data.ActiveRecord.TActiveRecordConfig'); |
743 | - foreach ($app->getModules() as $module) { |
|
744 | - if ($module instanceof TActiveRecordConfig) { |
|
743 | + foreach($app->getModules() as $module) { |
|
744 | + if($module instanceof TActiveRecordConfig) { |
|
745 | 745 | return $module; |
746 | 746 | } |
747 | 747 | } |
@@ -752,12 +752,12 @@ discard block |
||
752 | 752 | |
753 | 753 | protected function getOutputFile($app_dir, $namespace) |
754 | 754 | { |
755 | - if (is_file($namespace) && strpos($namespace, $app_dir) === 0) { |
|
755 | + if(is_file($namespace) && strpos($namespace, $app_dir) === 0) { |
|
756 | 756 | return $namespace; |
757 | 757 | } |
758 | 758 | $file = Prado::getPathOfNamespace($namespace, ""); |
759 | - if ($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
760 | - if (strpos($path, $app_dir) === 0) { |
|
759 | + if($file !== null && false !== ($path = realpath(dirname($file))) && is_dir($path)) { |
|
760 | + if(strpos($path, $app_dir) === 0) { |
|
761 | 761 | return $file; |
762 | 762 | } |
763 | 763 | } |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | */ |
347 | 347 | public function __construct() |
348 | 348 | { |
349 | - if ($this->getAutoGlobalListen()) { |
|
349 | + if($this->getAutoGlobalListen()) { |
|
350 | 350 | $this->listen(); |
351 | 351 | } |
352 | 352 | |
353 | 353 | $classes = array_reverse($this->getClassHierarchy(true)); |
354 | - foreach ($classes as $class) { |
|
355 | - if (isset(self::$_um[$class])) { |
|
354 | + foreach($classes as $class) { |
|
355 | + if(isset(self::$_um[$class])) { |
|
356 | 356 | $this->attachBehaviors(self::$_um[$class]); |
357 | 357 | } |
358 | 358 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | */ |
387 | 387 | public function __destruct() |
388 | 388 | { |
389 | - if ($this->_listeningenabled) { |
|
389 | + if($this->_listeningenabled) { |
|
390 | 390 | $this->unlisten(); |
391 | 391 | } |
392 | 392 | } |
@@ -412,10 +412,10 @@ discard block |
||
412 | 412 | { |
413 | 413 | $class = get_class($this); |
414 | 414 | $classes = [$class]; |
415 | - while ($class = get_parent_class($class)) { |
|
415 | + while($class = get_parent_class($class)) { |
|
416 | 416 | array_unshift($classes, $class); |
417 | 417 | } |
418 | - if ($lowercase) { |
|
418 | + if($lowercase) { |
|
419 | 419 | return array_map('strtolower', $classes); |
420 | 420 | } |
421 | 421 | return $classes; |
@@ -438,18 +438,18 @@ discard block |
||
438 | 438 | */ |
439 | 439 | public function listen() |
440 | 440 | { |
441 | - if ($this->_listeningenabled) { |
|
441 | + if($this->_listeningenabled) { |
|
442 | 442 | return; |
443 | 443 | } |
444 | 444 | |
445 | - $fx = array_filter(get_class_methods($this), [$this,'filter_prado_fx']); |
|
445 | + $fx = array_filter(get_class_methods($this), [$this, 'filter_prado_fx']); |
|
446 | 446 | |
447 | - foreach ($fx as $func) { |
|
448 | - $this->attachEventHandler($func, [$this,$func]); |
|
447 | + foreach($fx as $func) { |
|
448 | + $this->attachEventHandler($func, [$this, $func]); |
|
449 | 449 | } |
450 | 450 | |
451 | - if (is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
452 | - $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this,'__dycall']); |
|
451 | + if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
452 | + $this->attachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this, '__dycall']); |
|
453 | 453 | array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
454 | 454 | } |
455 | 455 | |
@@ -475,18 +475,18 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function unlisten() |
477 | 477 | { |
478 | - if (!$this->_listeningenabled) { |
|
478 | + if(!$this->_listeningenabled) { |
|
479 | 479 | return; |
480 | 480 | } |
481 | 481 | |
482 | - $fx = array_filter(get_class_methods($this), [$this,'filter_prado_fx']); |
|
482 | + $fx = array_filter(get_class_methods($this), [$this, 'filter_prado_fx']); |
|
483 | 483 | |
484 | - foreach ($fx as $func) { |
|
485 | - $this->detachEventHandler($func, [$this,$func]); |
|
484 | + foreach($fx as $func) { |
|
485 | + $this->detachEventHandler($func, [$this, $func]); |
|
486 | 486 | } |
487 | 487 | |
488 | - if (is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
489 | - $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this,'__dycall']); |
|
488 | + if(is_a($this, 'Prado\\Util\\IDynamicMethods')) { |
|
489 | + $this->detachEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER, [$this, '__dycall']); |
|
490 | 490 | array_push($fx, TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
491 | 491 | } |
492 | 492 | |
@@ -533,59 +533,59 @@ discard block |
||
533 | 533 | public function __call($method, $args) |
534 | 534 | { |
535 | 535 | $getset = substr($method, 0, 3); |
536 | - if (($getset == 'get') || ($getset == 'set')) { |
|
536 | + if(($getset == 'get') || ($getset == 'set')) { |
|
537 | 537 | $propname = substr($method, 3); |
538 | 538 | $jsmethod = $getset . 'js' . $propname; |
539 | - if (method_exists($this, $jsmethod)) { |
|
540 | - if (count($args) > 0) { |
|
541 | - if ($args[0] && !($args[0] instanceof TJavaScriptString)) { |
|
539 | + if(method_exists($this, $jsmethod)) { |
|
540 | + if(count($args) > 0) { |
|
541 | + if($args[0] && !($args[0] instanceof TJavaScriptString)) { |
|
542 | 542 | $args[0] = new TJavaScriptString($args[0]); |
543 | 543 | } |
544 | 544 | } |
545 | - return call_user_func_array([$this,$jsmethod], $args); |
|
545 | + return call_user_func_array([$this, $jsmethod], $args); |
|
546 | 546 | } |
547 | 547 | |
548 | - if (($getset == 'set') && method_exists($this, 'getjs' . $propname)) { |
|
548 | + if(($getset == 'set') && method_exists($this, 'getjs' . $propname)) { |
|
549 | 549 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $method); |
550 | 550 | } |
551 | 551 | } |
552 | 552 | |
553 | - if ($this->_m !== null && $this->_behaviorsenabled) { |
|
554 | - if (strncasecmp($method, 'dy', 2) === 0) { |
|
553 | + if($this->_m !== null && $this->_behaviorsenabled) { |
|
554 | + if(strncasecmp($method, 'dy', 2) === 0) { |
|
555 | 555 | $callchain = new TCallChain($method); |
556 | - foreach ($this->_m->toArray() as $behavior) { |
|
557 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) { |
|
556 | + foreach($this->_m->toArray() as $behavior) { |
|
557 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && (method_exists($behavior, $method) || ($behavior instanceof IDynamicMethods))) { |
|
558 | 558 | $behavior_args = $args; |
559 | - if ($behavior instanceof IClassBehavior) { |
|
559 | + if($behavior instanceof IClassBehavior) { |
|
560 | 560 | array_unshift($behavior_args, $this); |
561 | 561 | } |
562 | - $callchain->addCall([$behavior,$method], $behavior_args); |
|
562 | + $callchain->addCall([$behavior, $method], $behavior_args); |
|
563 | 563 | } |
564 | 564 | } |
565 | - if ($callchain->getCount() > 0) { |
|
566 | - return call_user_func_array([$callchain,'call'], $args); |
|
565 | + if($callchain->getCount() > 0) { |
|
566 | + return call_user_func_array([$callchain, 'call'], $args); |
|
567 | 567 | } |
568 | 568 | } else { |
569 | - foreach ($this->_m->toArray() as $behavior) { |
|
570 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) { |
|
571 | - if ($behavior instanceof IClassBehavior) { |
|
569 | + foreach($this->_m->toArray() as $behavior) { |
|
570 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && method_exists($behavior, $method)) { |
|
571 | + if($behavior instanceof IClassBehavior) { |
|
572 | 572 | array_unshift($args, $this); |
573 | 573 | } |
574 | - return call_user_func_array([$behavior,$method], $args); |
|
574 | + return call_user_func_array([$behavior, $method], $args); |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | - if (strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
581 | - if ($this instanceof IDynamicMethods) { |
|
580 | + if(strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
581 | + if($this instanceof IDynamicMethods) { |
|
582 | 582 | return $this->__dycall($method, $args); |
583 | 583 | } |
584 | 584 | return isset($args[0]) ? $args[0] : null; |
585 | 585 | } |
586 | 586 | |
587 | 587 | // don't thrown an exception for __magicMethods() or any other weird methods natively implemented by php |
588 | - if (!method_exists($this, $method)) { |
|
588 | + if(!method_exists($this, $method)) { |
|
589 | 589 | throw new TApplicationException('component_method_undefined', get_class($this), $method); |
590 | 590 | } |
591 | 591 | } |
@@ -616,33 +616,33 @@ discard block |
||
616 | 616 | */ |
617 | 617 | public function __get($name) |
618 | 618 | { |
619 | - if (method_exists($this, $getter = 'get' . $name)) { |
|
619 | + if(method_exists($this, $getter = 'get' . $name)) { |
|
620 | 620 | // getting a property |
621 | 621 | return $this->$getter(); |
622 | - } elseif (method_exists($this, $jsgetter = 'getjs' . $name)) { |
|
622 | + } elseif(method_exists($this, $jsgetter = 'getjs' . $name)) { |
|
623 | 623 | // getting a javascript property |
624 | - return (string)$this->$jsgetter(); |
|
625 | - } elseif (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
624 | + return (string) $this->$jsgetter(); |
|
625 | + } elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
626 | 626 | // getting an event (handler list) |
627 | 627 | $name = strtolower($name); |
628 | - if (!isset($this->_e[$name])) { |
|
628 | + if(!isset($this->_e[$name])) { |
|
629 | 629 | $this->_e[$name] = new TPriorityList; |
630 | 630 | } |
631 | 631 | return $this->_e[$name]; |
632 | - } elseif (strncasecmp($name, 'fx', 2) === 0) { |
|
632 | + } elseif(strncasecmp($name, 'fx', 2) === 0) { |
|
633 | 633 | // getting a global event (handler list) |
634 | 634 | $name = strtolower($name); |
635 | - if (!isset(self::$_ue[$name])) { |
|
635 | + if(!isset(self::$_ue[$name])) { |
|
636 | 636 | self::$_ue[$name] = new TPriorityList; |
637 | 637 | } |
638 | 638 | return self::$_ue[$name]; |
639 | - } elseif ($this->_behaviorsenabled) { |
|
639 | + } elseif($this->_behaviorsenabled) { |
|
640 | 640 | // getting a behavior property/event (handler list) |
641 | - if (isset($this->_m[$name])) { |
|
641 | + if(isset($this->_m[$name])) { |
|
642 | 642 | return $this->_m[$name]; |
643 | - } elseif ($this->_m !== null) { |
|
644 | - foreach ($this->_m->toArray() as $behavior) { |
|
645 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
643 | + } elseif($this->_m !== null) { |
|
644 | + foreach($this->_m->toArray() as $behavior) { |
|
645 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
646 | 646 | (property_exists($behavior, $name) || $behavior->canGetProperty($name) || $behavior->hasEvent($name))) { |
647 | 647 | return $behavior->$name; |
648 | 648 | } |
@@ -669,33 +669,33 @@ discard block |
||
669 | 669 | */ |
670 | 670 | public function __set($name, $value) |
671 | 671 | { |
672 | - if (method_exists($this, $setter = 'set' . $name)) { |
|
673 | - if (strncasecmp($name, 'js', 2) === 0 && $value && !($value instanceof TJavaScriptLiteral)) { |
|
672 | + if(method_exists($this, $setter = 'set' . $name)) { |
|
673 | + if(strncasecmp($name, 'js', 2) === 0 && $value && !($value instanceof TJavaScriptLiteral)) { |
|
674 | 674 | $value = new TJavaScriptLiteral($value); |
675 | 675 | } |
676 | 676 | return $this->$setter($value); |
677 | - } elseif (method_exists($this, $jssetter = 'setjs' . $name)) { |
|
678 | - if ($value && !($value instanceof TJavaScriptString)) { |
|
677 | + } elseif(method_exists($this, $jssetter = 'setjs' . $name)) { |
|
678 | + if($value && !($value instanceof TJavaScriptString)) { |
|
679 | 679 | $value = new TJavaScriptString($value); |
680 | 680 | } |
681 | 681 | return $this->$jssetter($value); |
682 | - } elseif ((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0) { |
|
682 | + } elseif((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0) { |
|
683 | 683 | return $this->attachEventHandler($name, $value); |
684 | - } elseif ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
684 | + } elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
685 | 685 | $sets = 0; |
686 | - foreach ($this->_m->toArray() as $behavior) { |
|
687 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
686 | + foreach($this->_m->toArray() as $behavior) { |
|
687 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && |
|
688 | 688 | (property_exists($behavior, $name) || $behavior->canSetProperty($name) || $behavior->hasEvent($name))) { |
689 | 689 | $behavior->$name = $value; |
690 | 690 | $sets++; |
691 | 691 | } |
692 | 692 | } |
693 | - if ($sets) { |
|
693 | + if($sets) { |
|
694 | 694 | return $value; |
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | - if (method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) { |
|
698 | + if(method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) { |
|
699 | 699 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
700 | 700 | } else { |
701 | 701 | throw new TInvalidOperationException('component_property_undefined', get_class($this), $name); |
@@ -716,22 +716,22 @@ discard block |
||
716 | 716 | */ |
717 | 717 | public function __isset($name) |
718 | 718 | { |
719 | - if (method_exists($this, $getter = 'get' . $name)) { |
|
719 | + if(method_exists($this, $getter = 'get' . $name)) { |
|
720 | 720 | return $this->$getter() !== null; |
721 | - } elseif (method_exists($this, $jsgetter = 'getjs' . $name)) { |
|
721 | + } elseif(method_exists($this, $jsgetter = 'getjs' . $name)) { |
|
722 | 722 | return $this->$jsgetter() !== null; |
723 | - } elseif (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
723 | + } elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
724 | 724 | $name = strtolower($name); |
725 | 725 | return isset($this->_e[$name]) && $this->_e[$name]->getCount(); |
726 | - } elseif (strncasecmp($name, 'fx', 2) === 0) { |
|
726 | + } elseif(strncasecmp($name, 'fx', 2) === 0) { |
|
727 | 727 | $name = strtolower($name); |
728 | 728 | return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount(); |
729 | - } elseif ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
730 | - if (isset($this->_m[$name])) { |
|
729 | + } elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
730 | + if(isset($this->_m[$name])) { |
|
731 | 731 | return true; |
732 | 732 | } |
733 | - foreach ($this->_m->toArray() as $behavior) { |
|
734 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
733 | + foreach($this->_m->toArray() as $behavior) { |
|
734 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
735 | 735 | return isset($behavior->$name); |
736 | 736 | } |
737 | 737 | } |
@@ -752,30 +752,30 @@ discard block |
||
752 | 752 | */ |
753 | 753 | public function __unset($name) |
754 | 754 | { |
755 | - if (method_exists($this, $setter = 'set' . $name)) { |
|
755 | + if(method_exists($this, $setter = 'set' . $name)) { |
|
756 | 756 | $this->$setter(null); |
757 | - } elseif (method_exists($this, $jssetter = 'setjs' . $name)) { |
|
757 | + } elseif(method_exists($this, $jssetter = 'setjs' . $name)) { |
|
758 | 758 | $this->$jssetter(null); |
759 | - } elseif (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
759 | + } elseif(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
760 | 760 | $this->_e[strtolower($name)]->clear(); |
761 | - } elseif (strncasecmp($name, 'fx', 2) === 0) { |
|
761 | + } elseif(strncasecmp($name, 'fx', 2) === 0) { |
|
762 | 762 | $this->getEventHandlers($name)->remove([$this, $name]); |
763 | - } elseif ($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
764 | - if (isset($this->_m[$name])) { |
|
763 | + } elseif($this->_m !== null && $this->_m->getCount() > 0 && $this->_behaviorsenabled) { |
|
764 | + if(isset($this->_m[$name])) { |
|
765 | 765 | $this->detachBehavior($name); |
766 | 766 | } else { |
767 | 767 | $unset = 0; |
768 | - foreach ($this->_m->toArray() as $behavior) { |
|
769 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
768 | + foreach($this->_m->toArray() as $behavior) { |
|
769 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled())) { |
|
770 | 770 | unset($behavior->$name); |
771 | 771 | $unset++; |
772 | 772 | } |
773 | 773 | } |
774 | - if (!$unset && method_exists($this, 'get' . $name)) { |
|
774 | + if(!$unset && method_exists($this, 'get' . $name)) { |
|
775 | 775 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
776 | 776 | } |
777 | 777 | } |
778 | - } elseif (method_exists($this, 'get' . $name)) { |
|
778 | + } elseif(method_exists($this, 'get' . $name)) { |
|
779 | 779 | throw new TInvalidOperationException('component_property_readonly', get_class($this), $name); |
780 | 780 | } |
781 | 781 | } |
@@ -803,11 +803,11 @@ discard block |
||
803 | 803 | */ |
804 | 804 | public function canGetProperty($name) |
805 | 805 | { |
806 | - if (method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) { |
|
806 | + if(method_exists($this, 'get' . $name) || method_exists($this, 'getjs' . $name)) { |
|
807 | 807 | return true; |
808 | - } elseif ($this->_m !== null && $this->_behaviorsenabled) { |
|
809 | - foreach ($this->_m->toArray() as $behavior) { |
|
810 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) { |
|
808 | + } elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
809 | + foreach($this->_m->toArray() as $behavior) { |
|
810 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canGetProperty($name)) { |
|
811 | 811 | return true; |
812 | 812 | } |
813 | 813 | } |
@@ -826,11 +826,11 @@ discard block |
||
826 | 826 | */ |
827 | 827 | public function canSetProperty($name) |
828 | 828 | { |
829 | - if (method_exists($this, 'set' . $name) || method_exists($this, 'setjs' . $name)) { |
|
829 | + if(method_exists($this, 'set' . $name) || method_exists($this, 'setjs' . $name)) { |
|
830 | 830 | return true; |
831 | - } elseif ($this->_m !== null && $this->_behaviorsenabled) { |
|
832 | - foreach ($this->_m->toArray() as $behavior) { |
|
833 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) { |
|
831 | + } elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
832 | + foreach($this->_m->toArray() as $behavior) { |
|
833 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->canSetProperty($name)) { |
|
834 | 834 | return true; |
835 | 835 | } |
836 | 836 | } |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | public function getSubProperty($path) |
852 | 852 | { |
853 | 853 | $object = $this; |
854 | - foreach (explode('.', $path) as $property) { |
|
854 | + foreach(explode('.', $path) as $property) { |
|
855 | 855 | $object = $object->$property; |
856 | 856 | } |
857 | 857 | return $object; |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | public function setSubProperty($path, $value) |
871 | 871 | { |
872 | 872 | $object = $this; |
873 | - if (($pos = strrpos($path, '.')) === false) { |
|
873 | + if(($pos = strrpos($path, '.')) === false) { |
|
874 | 874 | $property = $path; |
875 | 875 | } else { |
876 | 876 | $object = $this->getSubProperty(substr($path, 0, $pos)); |
@@ -893,11 +893,11 @@ discard block |
||
893 | 893 | */ |
894 | 894 | public function hasEvent($name) |
895 | 895 | { |
896 | - if ((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0 || strncasecmp($name, 'dy', 2) === 0) { |
|
896 | + if((strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) || strncasecmp($name, 'fx', 2) === 0 || strncasecmp($name, 'dy', 2) === 0) { |
|
897 | 897 | return true; |
898 | - } elseif ($this->_m !== null && $this->_behaviorsenabled) { |
|
899 | - foreach ($this->_m->toArray() as $behavior) { |
|
900 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) { |
|
898 | + } elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
899 | + foreach($this->_m->toArray() as $behavior) { |
|
900 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) { |
|
901 | 901 | return true; |
902 | 902 | } |
903 | 903 | } |
@@ -915,14 +915,14 @@ discard block |
||
915 | 915 | public function hasEventHandler($name) |
916 | 916 | { |
917 | 917 | $name = strtolower($name); |
918 | - if (strncasecmp($name, 'fx', 2) === 0) { |
|
918 | + if(strncasecmp($name, 'fx', 2) === 0) { |
|
919 | 919 | return isset(self::$_ue[$name]) && self::$_ue[$name]->getCount() > 0; |
920 | 920 | } else { |
921 | - if (isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) { |
|
921 | + if(isset($this->_e[$name]) && $this->_e[$name]->getCount() > 0) { |
|
922 | 922 | return true; |
923 | - } elseif ($this->_m !== null && $this->_behaviorsenabled) { |
|
924 | - foreach ($this->_m->toArray() as $behavior) { |
|
925 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) { |
|
923 | + } elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
924 | + foreach($this->_m->toArray() as $behavior) { |
|
925 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEventHandler($name)) { |
|
926 | 926 | return true; |
927 | 927 | } |
928 | 928 | } |
@@ -939,21 +939,21 @@ discard block |
||
939 | 939 | */ |
940 | 940 | public function getEventHandlers($name) |
941 | 941 | { |
942 | - if (strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
942 | + if(strncasecmp($name, 'on', 2) === 0 && method_exists($this, $name)) { |
|
943 | 943 | $name = strtolower($name); |
944 | - if (!isset($this->_e[$name])) { |
|
944 | + if(!isset($this->_e[$name])) { |
|
945 | 945 | $this->_e[$name] = new TPriorityList; |
946 | 946 | } |
947 | 947 | return $this->_e[$name]; |
948 | - } elseif (strncasecmp($name, 'fx', 2) === 0) { |
|
948 | + } elseif(strncasecmp($name, 'fx', 2) === 0) { |
|
949 | 949 | $name = strtolower($name); |
950 | - if (!isset(self::$_ue[$name])) { |
|
950 | + if(!isset(self::$_ue[$name])) { |
|
951 | 951 | self::$_ue[$name] = new TPriorityList; |
952 | 952 | } |
953 | 953 | return self::$_ue[$name]; |
954 | - } elseif ($this->_m !== null && $this->_behaviorsenabled) { |
|
955 | - foreach ($this->_m->toArray() as $behavior) { |
|
956 | - if ((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) { |
|
954 | + } elseif($this->_m !== null && $this->_behaviorsenabled) { |
|
955 | + foreach($this->_m->toArray() as $behavior) { |
|
956 | + if((!($behavior instanceof IBehavior) || $behavior->getEnabled()) && $behavior->hasEvent($name)) { |
|
957 | 957 | return $behavior->getEventHandlers($name); |
958 | 958 | } |
959 | 959 | } |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function detachEventHandler($name, $handler, $priority = false) |
1025 | 1025 | { |
1026 | - if ($this->hasEventHandler($name)) { |
|
1026 | + if($this->hasEventHandler($name)) { |
|
1027 | 1027 | try { |
1028 | 1028 | $this->getEventHandlers($name)->remove($handler, $priority); |
1029 | 1029 | return true; |
@@ -1108,12 +1108,12 @@ discard block |
||
1108 | 1108 | public function raiseEvent($name, $sender, $param, $responsetype = null, $postfunction = null) |
1109 | 1109 | { |
1110 | 1110 | $p = $param; |
1111 | - if (is_callable($responsetype)) { |
|
1111 | + if(is_callable($responsetype)) { |
|
1112 | 1112 | $postfunction = $responsetype; |
1113 | 1113 | $responsetype = null; |
1114 | 1114 | } |
1115 | 1115 | |
1116 | - if ($responsetype === null) { |
|
1116 | + if($responsetype === null) { |
|
1117 | 1117 | $responsetype = TEventResults::EVENT_RESULT_FILTER; |
1118 | 1118 | } |
1119 | 1119 | |
@@ -1122,26 +1122,26 @@ discard block |
||
1122 | 1122 | |
1123 | 1123 | $name = $this->dyPreRaiseEvent($name, $sender, $param, $responsetype, $postfunction); |
1124 | 1124 | |
1125 | - if ($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) { |
|
1125 | + if($this->hasEventHandler($name) || $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) { |
|
1126 | 1126 | $handlers = $this->getEventHandlers($name); |
1127 | 1127 | $handlerArray = $handlers->toArray(); |
1128 | - if (strncasecmp($name, 'fx', 2) === 0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) { |
|
1128 | + if(strncasecmp($name, 'fx', 2) === 0 && $this->hasEventHandler(TComponent::GLOBAL_RAISE_EVENT_LISTENER)) { |
|
1129 | 1129 | $globalhandlers = $this->getEventHandlers(TComponent::GLOBAL_RAISE_EVENT_LISTENER); |
1130 | 1130 | $handlerArray = array_merge($globalhandlers->toArrayBelowPriority(0), $handlerArray, $globalhandlers->toArrayAbovePriority(0)); |
1131 | 1131 | } |
1132 | 1132 | $response = null; |
1133 | - foreach ($handlerArray as $handler) { |
|
1134 | - if ($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name) === false) { |
|
1133 | + foreach($handlerArray as $handler) { |
|
1134 | + if($this->dyIntraRaiseEventTestHandler($handler, $sender, $param, $name) === false) { |
|
1135 | 1135 | continue; |
1136 | 1136 | } |
1137 | 1137 | |
1138 | - if (is_string($handler)) { |
|
1139 | - if (($pos = strrpos($handler, '.')) !== false) { |
|
1138 | + if(is_string($handler)) { |
|
1139 | + if(($pos = strrpos($handler, '.')) !== false) { |
|
1140 | 1140 | $object = $this->getSubProperty(substr($handler, 0, $pos)); |
1141 | 1141 | $method = substr($handler, $pos + 1); |
1142 | - if (method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
1143 | - if ($method == '__dycall') { |
|
1144 | - $response = $object->__dycall($name, [$sender,$param,$name]); |
|
1142 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
1143 | + if($method == '__dycall') { |
|
1144 | + $response = $object->__dycall($name, [$sender, $param, $name]); |
|
1145 | 1145 | } else { |
1146 | 1146 | $response = $object->$method($sender, $param, $name); |
1147 | 1147 | } |
@@ -1151,18 +1151,18 @@ discard block |
||
1151 | 1151 | } else { |
1152 | 1152 | $response = call_user_func($handler, $sender, $param, $name); |
1153 | 1153 | } |
1154 | - } elseif (is_callable($handler, true)) { |
|
1154 | + } elseif(is_callable($handler, true)) { |
|
1155 | 1155 | list($object, $method) = $handler; |
1156 | - if (is_string($object)) { |
|
1156 | + if(is_string($object)) { |
|
1157 | 1157 | $response = call_user_func($handler, $sender, $param, $name); |
1158 | 1158 | } else { |
1159 | - if (($pos = strrpos($method, '.')) !== false) { |
|
1159 | + if(($pos = strrpos($method, '.')) !== false) { |
|
1160 | 1160 | $object = $this->getSubProperty(substr($method, 0, $pos)); |
1161 | 1161 | $method = substr($method, $pos + 1); |
1162 | 1162 | } |
1163 | - if (method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
1164 | - if ($method == '__dycall') { |
|
1165 | - $response = $object->__dycall($name, [$sender,$param,$name]); |
|
1163 | + if(method_exists($object, $method) || strncasecmp($method, 'dy', 2) === 0 || strncasecmp($method, 'fx', 2) === 0) { |
|
1164 | + if($method == '__dycall') { |
|
1165 | + $response = $object->__dycall($name, [$sender, $param, $name]); |
|
1166 | 1166 | } else { |
1167 | 1167 | $response = $object->$method($sender, $param, $name); |
1168 | 1168 | } |
@@ -1176,25 +1176,25 @@ discard block |
||
1176 | 1176 | |
1177 | 1177 | $this->dyIntraRaiseEventPostHandler($name, $sender, $param, $handler, $response); |
1178 | 1178 | |
1179 | - if ($postfunction) { |
|
1180 | - $response = call_user_func_array($postfunction, [$sender,$param,$this,$response]); |
|
1179 | + if($postfunction) { |
|
1180 | + $response = call_user_func_array($postfunction, [$sender, $param, $this, $response]); |
|
1181 | 1181 | } |
1182 | 1182 | |
1183 | - if ($responsetype & TEventResults::EVENT_RESULT_ALL) { |
|
1184 | - $responses[] = ['sender' => $sender,'param' => $param,'response' => $response]; |
|
1183 | + if($responsetype & TEventResults::EVENT_RESULT_ALL) { |
|
1184 | + $responses[] = ['sender' => $sender, 'param' => $param, 'response' => $response]; |
|
1185 | 1185 | } else { |
1186 | 1186 | $responses[] = $response; |
1187 | 1187 | } |
1188 | 1188 | |
1189 | - if ($response !== null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) { |
|
1189 | + if($response !== null && ($responsetype & TEventResults::EVENT_RESULT_FEED_FORWARD)) { |
|
1190 | 1190 | $param = $response; |
1191 | 1191 | } |
1192 | 1192 | } |
1193 | - } elseif (strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name)) { |
|
1193 | + } elseif(strncasecmp($name, 'on', 2) === 0 && !$this->hasEvent($name)) { |
|
1194 | 1194 | throw new TInvalidOperationException('component_event_undefined', get_class($this), $name); |
1195 | 1195 | } |
1196 | 1196 | |
1197 | - if ($responsetype & TEventResults::EVENT_RESULT_FILTER) { |
|
1197 | + if($responsetype & TEventResults::EVENT_RESULT_FILTER) { |
|
1198 | 1198 | $responses = array_filter($responses); |
1199 | 1199 | } |
1200 | 1200 | |
@@ -1224,7 +1224,7 @@ discard block |
||
1224 | 1224 | { |
1225 | 1225 | $expression = $this->dyEvaluateExpressionFilter($expression); |
1226 | 1226 | try { |
1227 | - if (eval("\$result=$expression;") === false) { |
|
1227 | + if(eval("\$result=$expression;") === false) { |
|
1228 | 1228 | throw new \Exception(''); |
1229 | 1229 | } |
1230 | 1230 | return $result; |
@@ -1255,7 +1255,7 @@ discard block |
||
1255 | 1255 | $statements = $this->dyEvaluateStatementsFilter($statements); |
1256 | 1256 | try { |
1257 | 1257 | ob_start(); |
1258 | - if (eval($statements) === false) { |
|
1258 | + if(eval($statements) === false) { |
|
1259 | 1259 | throw new \Exception(''); |
1260 | 1260 | } |
1261 | 1261 | $content = ob_get_contents(); |
@@ -1324,7 +1324,7 @@ discard block |
||
1324 | 1324 | */ |
1325 | 1325 | public function fxAttachClassBehavior($sender, $param) |
1326 | 1326 | { |
1327 | - if (in_array($param->getClass(), $this->getClassHierarchy(true))) { |
|
1327 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) { |
|
1328 | 1328 | return $this->attachBehavior($param->getName(), $param->getBehavior(), $param->getPriority()); |
1329 | 1329 | } |
1330 | 1330 | } |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | */ |
1341 | 1341 | public function fxDetachClassBehavior($sender, $param) |
1342 | 1342 | { |
1343 | - if (in_array($param->getClass(), $this->getClassHierarchy(true))) { |
|
1343 | + if(in_array($param->getClass(), $this->getClassHierarchy(true))) { |
|
1344 | 1344 | return $this->detachBehavior($param->getName(), $param->getPriority()); |
1345 | 1345 | } |
1346 | 1346 | } |
@@ -1366,24 +1366,24 @@ discard block |
||
1366 | 1366 | */ |
1367 | 1367 | public static function attachClassBehavior($name, $behavior, $class = null, $priority = null) |
1368 | 1368 | { |
1369 | - if (!$class && function_exists('get_called_class')) { |
|
1369 | + if(!$class && function_exists('get_called_class')) { |
|
1370 | 1370 | $class = get_called_class(); |
1371 | 1371 | } |
1372 | - if (!$class) { |
|
1372 | + if(!$class) { |
|
1373 | 1373 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
1374 | 1374 | } |
1375 | 1375 | |
1376 | - if (!is_string($name)) { |
|
1376 | + if(!is_string($name)) { |
|
1377 | 1377 | $name = get_class($name); |
1378 | 1378 | } |
1379 | 1379 | $class = strtolower($class); |
1380 | - if ($class === 'tcomponent') { |
|
1380 | + if($class === 'tcomponent') { |
|
1381 | 1381 | throw new TInvalidOperationException('component_no_tcomponent_class_behaviors'); |
1382 | 1382 | } |
1383 | - if (empty(self::$_um[$class])) { |
|
1383 | + if(empty(self::$_um[$class])) { |
|
1384 | 1384 | self::$_um[$class] = []; |
1385 | 1385 | } |
1386 | - if (isset(self::$_um[$class][$name])) { |
|
1386 | + if(isset(self::$_um[$class][$name])) { |
|
1387 | 1387 | throw new TInvalidOperationException('component_class_behavior_defined', $class, $name); |
1388 | 1388 | } |
1389 | 1389 | $param = new TClassBehaviorEventParameter($class, $name, $behavior, $priority); |
@@ -1407,18 +1407,18 @@ discard block |
||
1407 | 1407 | */ |
1408 | 1408 | public static function detachClassBehavior($name, $class = null, $priority = false) |
1409 | 1409 | { |
1410 | - if (!$class && function_exists('get_called_class')) { |
|
1410 | + if(!$class && function_exists('get_called_class')) { |
|
1411 | 1411 | $class = get_called_class(); |
1412 | 1412 | } |
1413 | - if (!$class) { |
|
1413 | + if(!$class) { |
|
1414 | 1414 | throw new TInvalidOperationException('component_no_class_provided_nor_late_binding'); |
1415 | 1415 | } |
1416 | 1416 | |
1417 | 1417 | $class = strtolower($class); |
1418 | - if (!is_string($name)) { |
|
1418 | + if(!is_string($name)) { |
|
1419 | 1419 | $name = get_class($name); |
1420 | 1420 | } |
1421 | - if (empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) { |
|
1421 | + if(empty(self::$_um[$class]) || !isset(self::$_um[$class][$name])) { |
|
1422 | 1422 | return false; |
1423 | 1423 | } |
1424 | 1424 | $param = self::$_um[$class][$name]; |
@@ -1461,20 +1461,20 @@ discard block |
||
1461 | 1461 | */ |
1462 | 1462 | public function isa($class) |
1463 | 1463 | { |
1464 | - if ($this instanceof $class) { |
|
1464 | + if($this instanceof $class) { |
|
1465 | 1465 | return true; |
1466 | 1466 | } |
1467 | - if ($this->_m !== null && $this->_behaviorsenabled) { |
|
1468 | - foreach ($this->_m->toArray() as $behavior) { |
|
1469 | - if (($behavior instanceof IBehavior) && !$behavior->getEnabled()) { |
|
1467 | + if($this->_m !== null && $this->_behaviorsenabled) { |
|
1468 | + foreach($this->_m->toArray() as $behavior) { |
|
1469 | + if(($behavior instanceof IBehavior) && !$behavior->getEnabled()) { |
|
1470 | 1470 | continue; |
1471 | 1471 | } |
1472 | 1472 | |
1473 | 1473 | $check = null; |
1474 | - if (($behavior->isa('\Prado\Util\IInstanceCheck')) && $check = $behavior->isinstanceof($class, $this)) { |
|
1474 | + if(($behavior->isa('\Prado\Util\IInstanceCheck')) && $check = $behavior->isinstanceof($class, $this)) { |
|
1475 | 1475 | return true; |
1476 | 1476 | } |
1477 | - if ($check === null && ($behavior->isa($class))) { |
|
1477 | + if($check === null && ($behavior->isa($class))) { |
|
1478 | 1478 | return true; |
1479 | 1479 | } |
1480 | 1480 | } |
@@ -1492,8 +1492,8 @@ discard block |
||
1492 | 1492 | */ |
1493 | 1493 | public function attachBehaviors($behaviors) |
1494 | 1494 | { |
1495 | - foreach ($behaviors as $name => $behavior) { |
|
1496 | - if ($behavior instanceof TClassBehaviorEventParameter) { |
|
1495 | + foreach($behaviors as $name => $behavior) { |
|
1496 | + if($behavior instanceof TClassBehaviorEventParameter) { |
|
1497 | 1497 | $this->attachBehavior($behavior->getName(), $behavior->getBehavior(), $behavior->getPriority()); |
1498 | 1498 | } else { |
1499 | 1499 | $this->attachBehavior($name, $behavior); |
@@ -1511,9 +1511,9 @@ discard block |
||
1511 | 1511 | */ |
1512 | 1512 | public function detachBehaviors($behaviors) |
1513 | 1513 | { |
1514 | - if ($this->_m !== null) { |
|
1515 | - foreach ($behaviors as $name => $behavior) { |
|
1516 | - if ($behavior instanceof TClassBehaviorEventParameter) { |
|
1514 | + if($this->_m !== null) { |
|
1515 | + foreach($behaviors as $name => $behavior) { |
|
1516 | + if($behavior instanceof TClassBehaviorEventParameter) { |
|
1517 | 1517 | $this->detachBehavior($behavior->getName(), $behavior->getPriority()); |
1518 | 1518 | } else { |
1519 | 1519 | $this->detachBehavior(is_string($behavior) ? $behavior : $name); |
@@ -1528,8 +1528,8 @@ discard block |
||
1528 | 1528 | */ |
1529 | 1529 | public function clearBehaviors() |
1530 | 1530 | { |
1531 | - if ($this->_m !== null) { |
|
1532 | - foreach ($this->_m->toArray() as $name => $behavior) { |
|
1531 | + if($this->_m !== null) { |
|
1532 | + foreach($this->_m->toArray() as $name => $behavior) { |
|
1533 | 1533 | $this->detachBehavior($name); |
1534 | 1534 | } |
1535 | 1535 | $this->_m = null; |
@@ -1558,16 +1558,16 @@ discard block |
||
1558 | 1558 | */ |
1559 | 1559 | public function attachBehavior($name, $behavior, $priority = null) |
1560 | 1560 | { |
1561 | - if (is_string($behavior)) { |
|
1561 | + if(is_string($behavior)) { |
|
1562 | 1562 | $behavior = Prado::createComponent($behavior); |
1563 | 1563 | } |
1564 | - if (!($behavior instanceof IBaseBehavior)) { |
|
1564 | + if(!($behavior instanceof IBaseBehavior)) { |
|
1565 | 1565 | throw new TInvalidDataTypeException('component_not_a_behavior', get_class($behavior)); |
1566 | 1566 | } |
1567 | - if ($behavior instanceof IBehavior) { |
|
1567 | + if($behavior instanceof IBehavior) { |
|
1568 | 1568 | $behavior->setEnabled(true); |
1569 | 1569 | } |
1570 | - if ($this->_m === null) { |
|
1570 | + if($this->_m === null) { |
|
1571 | 1571 | $this->_m = new TPriorityMap; |
1572 | 1572 | } |
1573 | 1573 | $behavior->attach($this); |
@@ -1595,7 +1595,7 @@ discard block |
||
1595 | 1595 | */ |
1596 | 1596 | public function detachBehavior($name, $priority = false) |
1597 | 1597 | { |
1598 | - if ($this->_m != null && isset($this->_m[$name])) { |
|
1598 | + if($this->_m != null && isset($this->_m[$name])) { |
|
1599 | 1599 | $this->_m[$name]->detach($this); |
1600 | 1600 | $behavior = $this->_m->itemAt($name); |
1601 | 1601 | $this->_m->remove($name, $priority); |
@@ -1618,7 +1618,7 @@ discard block |
||
1618 | 1618 | */ |
1619 | 1619 | public function enableBehaviors() |
1620 | 1620 | { |
1621 | - if (!$this->_behaviorsenabled) { |
|
1621 | + if(!$this->_behaviorsenabled) { |
|
1622 | 1622 | $this->_behaviorsenabled = true; |
1623 | 1623 | $this->dyEnableBehaviors(); |
1624 | 1624 | } |
@@ -1638,7 +1638,7 @@ discard block |
||
1638 | 1638 | */ |
1639 | 1639 | public function disableBehaviors() |
1640 | 1640 | { |
1641 | - if ($this->_behaviorsenabled) { |
|
1641 | + if($this->_behaviorsenabled) { |
|
1642 | 1642 | $this->dyDisableBehaviors(); |
1643 | 1643 | $this->_behaviorsenabled = false; |
1644 | 1644 | } |
@@ -1673,8 +1673,8 @@ discard block |
||
1673 | 1673 | */ |
1674 | 1674 | public function enableBehavior($name) |
1675 | 1675 | { |
1676 | - if ($this->_m != null && isset($this->_m[$name])) { |
|
1677 | - if ($this->_m[$name] instanceof IBehavior) { |
|
1676 | + if($this->_m != null && isset($this->_m[$name])) { |
|
1677 | + if($this->_m[$name] instanceof IBehavior) { |
|
1678 | 1678 | $this->_m[$name]->setEnabled(true); |
1679 | 1679 | $this->dyEnableBehavior($name, $this->_m[$name]); |
1680 | 1680 | return true; |
@@ -1701,8 +1701,8 @@ discard block |
||
1701 | 1701 | */ |
1702 | 1702 | public function disableBehavior($name) |
1703 | 1703 | { |
1704 | - if ($this->_m != null && isset($this->_m[$name])) { |
|
1705 | - if ($this->_m[$name] instanceof IBehavior) { |
|
1704 | + if($this->_m != null && isset($this->_m[$name])) { |
|
1705 | + if($this->_m[$name] instanceof IBehavior) { |
|
1706 | 1706 | $this->_m[$name]->setEnabled(false); |
1707 | 1707 | $this->dyDisableBehavior($name, $this->_m[$name]); |
1708 | 1708 | return true; |
@@ -1719,7 +1719,7 @@ discard block |
||
1719 | 1719 | */ |
1720 | 1720 | public function __sleep() |
1721 | 1721 | { |
1722 | - $a = (array)$this; |
|
1722 | + $a = (array) $this; |
|
1723 | 1723 | $a = array_keys($a); |
1724 | 1724 | $exprops = []; |
1725 | 1725 | $this->_getZappableSleepProps($exprops); |
@@ -1734,16 +1734,16 @@ discard block |
||
1734 | 1734 | */ |
1735 | 1735 | protected function _getZappableSleepProps(&$exprops) |
1736 | 1736 | { |
1737 | - if ($this->_listeningenabled === false) { |
|
1737 | + if($this->_listeningenabled === false) { |
|
1738 | 1738 | $exprops[] = "\0Prado\TComponent\0_listeningenabled"; |
1739 | 1739 | } |
1740 | - if ($this->_behaviorsenabled === true) { |
|
1740 | + if($this->_behaviorsenabled === true) { |
|
1741 | 1741 | $exprops[] = "\0Prado\TComponent\0_behaviorsenabled"; |
1742 | 1742 | } |
1743 | - if ($this->_e === []) { |
|
1743 | + if($this->_e === []) { |
|
1744 | 1744 | $exprops[] = "\0Prado\TComponent\0_e"; |
1745 | 1745 | } |
1746 | - if ($this->_m === null) { |
|
1746 | + if($this->_m === null) { |
|
1747 | 1747 | $exprops[] = "\0Prado\TComponent\0_m"; |
1748 | 1748 | } |
1749 | 1749 | } |
@@ -23,17 +23,17 @@ discard block |
||
23 | 23 | use Prado\I18N\Translation; |
24 | 24 | |
25 | 25 | // Defines the PRADO framework installation path. |
26 | -if (!defined('PRADO_DIR')) { |
|
26 | +if(!defined('PRADO_DIR')) { |
|
27 | 27 | define('PRADO_DIR', __DIR__); |
28 | 28 | } |
29 | 29 | |
30 | 30 | // Defines the default permission for writable directories and files |
31 | -if (!defined('PRADO_CHMOD')) { |
|
31 | +if(!defined('PRADO_CHMOD')) { |
|
32 | 32 | define('PRADO_CHMOD', 0777); |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Defines the Composer's vendor/ path. |
36 | -if (!defined('PRADO_VENDORDIR')) { |
|
36 | +if(!defined('PRADO_VENDORDIR')) { |
|
37 | 37 | $reflector = new \ReflectionClass('\Composer\Autoload\ClassLoader'); |
38 | 38 | define('PRADO_VENDORDIR', dirname(dirname($reflector->getFileName()))); |
39 | 39 | } |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | /** |
121 | 121 | * Sets error handler to be Prado::phpErrorHandler |
122 | 122 | */ |
123 | - set_error_handler(['\Prado\PradoBase','phpErrorHandler']); |
|
123 | + set_error_handler(['\Prado\PradoBase', 'phpErrorHandler']); |
|
124 | 124 | /** |
125 | 125 | * Sets shutdown function to be Prado::phpFatalErrorHandler |
126 | 126 | */ |
127 | - register_shutdown_function(['PradoBase','phpFatalErrorHandler']); |
|
127 | + register_shutdown_function(['PradoBase', 'phpFatalErrorHandler']); |
|
128 | 128 | /** |
129 | 129 | * Sets exception handler to be Prado::exceptionHandler |
130 | 130 | */ |
131 | - set_exception_handler(['\Prado\PradoBase','exceptionHandler']); |
|
131 | + set_exception_handler(['\Prado\PradoBase', 'exceptionHandler']); |
|
132 | 132 | /** |
133 | 133 | * Disable php's builtin error reporting to avoid duplicated reports |
134 | 134 | */ |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | public static function poweredByPrado($logoType = 0) |
153 | 153 | { |
154 | 154 | $logoName = $logoType == 1 ? 'powered2' : 'powered'; |
155 | - if (self::$_application !== null) { |
|
155 | + if(self::$_application !== null) { |
|
156 | 156 | $am = self::$_application->getAssetManager(); |
157 | 157 | $url = $am->publishFilePath(self::getPathOfNamespace('Prado\\' . $logoName, '.gif')); |
158 | 158 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public static function phpErrorHandler($errno, $errstr, $errfile, $errline) |
175 | 175 | { |
176 | - if (error_reporting() & $errno) { |
|
176 | + if(error_reporting() & $errno) { |
|
177 | 177 | throw new TPhpErrorException($errno, $errstr, $errfile, $errline); |
178 | 178 | } |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | public static function phpFatalErrorHandler() |
188 | 188 | { |
189 | 189 | $error = error_get_last(); |
190 | - if ($error && |
|
190 | + if($error && |
|
191 | 191 | TPhpErrorException::isFatalError($error) && |
192 | 192 | error_reporting() & $error['type']) { |
193 | 193 | self::exceptionHandler(new TPhpFatalErrorException($error['type'], $error['message'], $error['file'], $error['line'])); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public static function exceptionHandler($exception) |
207 | 207 | { |
208 | - if (self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) { |
|
208 | + if(self::$_application !== null && ($errorHandler = self::$_application->getErrorHandler()) !== null) { |
|
209 | 209 | $errorHandler->handleError(null, $exception); |
210 | 210 | } else { |
211 | 211 | echo $exception; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public static function setApplication($application) |
226 | 226 | { |
227 | - if (self::$_application !== null && !defined('PRADO_TEST_RUN')) { |
|
227 | + if(self::$_application !== null && !defined('PRADO_TEST_RUN')) { |
|
228 | 228 | throw new TInvalidOperationException('prado_application_singleton_required'); |
229 | 229 | } |
230 | 230 | self::$_application = $application; |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | |
255 | 255 | protected static function prado3NamespaceToPhpNamespace($type) |
256 | 256 | { |
257 | - if (substr($type, 0, 6) === 'System') { |
|
257 | + if(substr($type, 0, 6) === 'System') { |
|
258 | 258 | $type = 'Prado' . substr($type, 6); |
259 | 259 | } |
260 | 260 | |
261 | - if (false === strpos($type, '\\')) { |
|
261 | + if(false === strpos($type, '\\')) { |
|
262 | 262 | return str_replace('.', '\\', $type); |
263 | 263 | } else { |
264 | 264 | return $type; |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | public static function createComponent($requestedType) |
282 | 282 | { |
283 | 283 | $type = static::prado3NamespaceToPhpNamespace($requestedType); |
284 | - if (!isset(self::$classExists[$type])) { |
|
284 | + if(!isset(self::$classExists[$type])) { |
|
285 | 285 | self::$classExists[$type] = class_exists($type, false); |
286 | 286 | } |
287 | 287 | |
288 | - if (!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
288 | + if(!isset(self::$_usings[$type]) && !self::$classExists[$type]) { |
|
289 | 289 | static::using($type); |
290 | 290 | self::$classExists[$type] = class_exists($type, false); |
291 | 291 | } |
@@ -297,13 +297,13 @@ discard block |
||
297 | 297 | * \Application\Common\MyDataModule) |
298 | 298 | * Skip this if the class is inside the Prado\* namespace, since all Prado classes are now namespaced |
299 | 299 | */ |
300 | - if (($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) { |
|
300 | + if(($pos = strrpos($type, '\\')) !== false && ($requestedType != $type) && strpos($type, 'Prado\\') !== 0) { |
|
301 | 301 | $type = substr($type, $pos + 1); |
302 | 302 | } |
303 | 303 | |
304 | - if (($n = func_num_args()) > 1) { |
|
304 | + if(($n = func_num_args()) > 1) { |
|
305 | 305 | $args = func_get_args(); |
306 | - switch ($n) { |
|
306 | + switch($n) { |
|
307 | 307 | case 2: |
308 | 308 | return new $type($args[1]); |
309 | 309 | break; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | break; |
319 | 319 | default: |
320 | 320 | $s = '$args[1]'; |
321 | - for ($i = 2;$i < $n;++$i) { |
|
321 | + for($i = 2; $i < $n; ++$i) { |
|
322 | 322 | $s .= ",\$args[$i]"; |
323 | 323 | } |
324 | 324 | eval("\$component=new $type($s);"); |
@@ -343,27 +343,27 @@ discard block |
||
343 | 343 | { |
344 | 344 | $namespace = static::prado3NamespaceToPhpNamespace($namespace); |
345 | 345 | |
346 | - if (isset(self::$_usings[$namespace]) || class_exists($namespace, false)) { |
|
346 | + if(isset(self::$_usings[$namespace]) || class_exists($namespace, false)) { |
|
347 | 347 | return; |
348 | 348 | } |
349 | 349 | |
350 | - if (array_key_exists($namespace, self::$classMap)) { |
|
350 | + if(array_key_exists($namespace, self::$classMap)) { |
|
351 | 351 | // fast autoload a Prado3 class name |
352 | 352 | $phpNamespace = self::$classMap[$namespace]; |
353 | - if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) { |
|
354 | - if (!class_exists($namespace) && !interface_exists($namespace)) { |
|
353 | + if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) { |
|
354 | + if(!class_exists($namespace) && !interface_exists($namespace)) { |
|
355 | 355 | class_alias($phpNamespace, $namespace); |
356 | 356 | } |
357 | 357 | return; |
358 | 358 | } |
359 | - } elseif (($pos = strrpos($namespace, '\\')) === false) { |
|
359 | + } elseif(($pos = strrpos($namespace, '\\')) === false) { |
|
360 | 360 | // trying to autoload an old class name |
361 | - foreach (self::$_usings as $k => $v) { |
|
361 | + foreach(self::$_usings as $k => $v) { |
|
362 | 362 | $path = $v . DIRECTORY_SEPARATOR . $namespace . self::CLASS_FILE_EXT; |
363 | - if (file_exists($path)) { |
|
363 | + if(file_exists($path)) { |
|
364 | 364 | $phpNamespace = '\\' . $k . '\\' . $namespace; |
365 | - if (class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) { |
|
366 | - if (!class_exists($namespace) && !interface_exists($namespace)) { |
|
365 | + if(class_exists($phpNamespace, true) || interface_exists($phpNamespace, true)) { |
|
366 | + if(!class_exists($namespace) && !interface_exists($namespace)) { |
|
367 | 367 | class_alias($phpNamespace, $namespace); |
368 | 368 | } |
369 | 369 | return; |
@@ -371,23 +371,23 @@ discard block |
||
371 | 371 | } |
372 | 372 | } |
373 | 373 | |
374 | - if ($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) { |
|
374 | + if($checkClassExistence && !class_exists($namespace, false) && !interface_exists($namespace, false)) { |
|
375 | 375 | throw new TInvalidOperationException('prado_component_unknown', $namespace, ''); |
376 | 376 | } |
377 | - } elseif (($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) { |
|
377 | + } elseif(($path = self::getPathOfNamespace($namespace, self::CLASS_FILE_EXT)) !== null) { |
|
378 | 378 | $className = substr($namespace, $pos + 1); |
379 | - if ($className === '*') { // a directory |
|
379 | + if($className === '*') { // a directory |
|
380 | 380 | self::$_usings[substr($namespace, 0, $pos)] = $path; |
381 | 381 | } else { // a file |
382 | 382 | //self::$_usings[$namespace]=$path; |
383 | - if (!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) { |
|
383 | + if(!$checkClassExistence || (!class_exists($className, false) && !interface_exists($className, false))) { |
|
384 | 384 | try { |
385 | 385 | include_once($path); |
386 | - if (class_exists($namespace, false) || interface_exists($namespace, false)) { |
|
386 | + if(class_exists($namespace, false) || interface_exists($namespace, false)) { |
|
387 | 387 | class_alias($namespace, $className); |
388 | 388 | } |
389 | 389 | } catch (\Exception $e) { |
390 | - if ($checkClassExistence && !class_exists($className, false)) { |
|
390 | + if($checkClassExistence && !class_exists($className, false)) { |
|
391 | 391 | throw new TInvalidOperationException('prado_component_unknown', $className, $e->getMessage()); |
392 | 392 | } else { |
393 | 393 | throw $e; |
@@ -414,12 +414,12 @@ discard block |
||
414 | 414 | { |
415 | 415 | $namespace = static::prado3NamespaceToPhpNamespace($namespace); |
416 | 416 | |
417 | - if (self::CLASS_FILE_EXT === $ext || empty($ext)) { |
|
418 | - if (isset(self::$_usings[$namespace])) { |
|
417 | + if(self::CLASS_FILE_EXT === $ext || empty($ext)) { |
|
418 | + if(isset(self::$_usings[$namespace])) { |
|
419 | 419 | return self::$_usings[$namespace]; |
420 | 420 | } |
421 | 421 | |
422 | - if (isset(self::$_aliases[$namespace])) { |
|
422 | + if(isset(self::$_aliases[$namespace])) { |
|
423 | 423 | return self::$_aliases[$namespace]; |
424 | 424 | } |
425 | 425 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | $segs = explode('\\', $namespace); |
428 | 428 | $alias = array_shift($segs); |
429 | 429 | |
430 | - if (null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) { |
|
430 | + if(null !== ($file = array_pop($segs)) && null !== ($root = self::getPathOfAlias($alias))) { |
|
431 | 431 | return rtrim($root . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $segs), '/\\') . (($file === '*') ? '' : DIRECTORY_SEPARATOR . $file . $ext); |
432 | 432 | } |
433 | 433 | |
@@ -456,10 +456,10 @@ discard block |
||
456 | 456 | */ |
457 | 457 | public static function setPathOfAlias($alias, $path) |
458 | 458 | { |
459 | - if (isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) { |
|
459 | + if(isset(self::$_aliases[$alias]) && !defined('PRADO_TEST_RUN')) { |
|
460 | 460 | throw new TInvalidOperationException('prado_alias_redefined', $alias); |
461 | - } elseif (($rp = realpath($path)) !== false && is_dir($rp)) { |
|
462 | - if (strpos($alias, '.') === false) { |
|
461 | + } elseif(($rp = realpath($path)) !== false && is_dir($rp)) { |
|
462 | + if(strpos($alias, '.') === false) { |
|
463 | 463 | self::$_aliases[$alias] = $rp; |
464 | 464 | } else { |
465 | 465 | throw new TInvalidDataValueException('prado_aliasname_invalid', $alias); |
@@ -479,53 +479,53 @@ discard block |
||
479 | 479 | { |
480 | 480 | echo '<h1>Fatal Error</h1>'; |
481 | 481 | echo '<p>' . $msg . '</p>'; |
482 | - if (!function_exists('debug_backtrace')) { |
|
482 | + if(!function_exists('debug_backtrace')) { |
|
483 | 483 | return; |
484 | 484 | } |
485 | 485 | echo '<h2>Debug Backtrace</h2>'; |
486 | 486 | echo '<pre>'; |
487 | 487 | $index = -1; |
488 | - foreach (debug_backtrace() as $t) { |
|
488 | + foreach(debug_backtrace() as $t) { |
|
489 | 489 | $index++; |
490 | - if ($index == 0) { // hide the backtrace of this function |
|
490 | + if($index == 0) { // hide the backtrace of this function |
|
491 | 491 | continue; |
492 | 492 | } |
493 | 493 | echo '#' . $index . ' '; |
494 | - if (isset($t['file'])) { |
|
494 | + if(isset($t['file'])) { |
|
495 | 495 | echo basename($t['file']) . ':' . $t['line']; |
496 | 496 | } else { |
497 | 497 | echo '<PHP inner-code>'; |
498 | 498 | } |
499 | 499 | echo ' -- '; |
500 | - if (isset($t['class'])) { |
|
500 | + if(isset($t['class'])) { |
|
501 | 501 | echo $t['class'] . $t['type']; |
502 | 502 | } |
503 | 503 | echo $t['function'] . '('; |
504 | - if (isset($t['args']) && count($t['args']) > 0) { |
|
504 | + if(isset($t['args']) && count($t['args']) > 0) { |
|
505 | 505 | $count = 0; |
506 | - foreach ($t['args'] as $item) { |
|
507 | - if (is_string($item)) { |
|
506 | + foreach($t['args'] as $item) { |
|
507 | + if(is_string($item)) { |
|
508 | 508 | $str = htmlentities(str_replace("\r\n", "", $item), ENT_QUOTES); |
509 | - if (strlen($item) > 70) { |
|
509 | + if(strlen($item) > 70) { |
|
510 | 510 | echo "'" . substr($str, 0, 70) . "...'"; |
511 | 511 | } else { |
512 | 512 | echo "'" . $str . "'"; |
513 | 513 | } |
514 | - } elseif (is_int($item) || is_float($item)) { |
|
514 | + } elseif(is_int($item) || is_float($item)) { |
|
515 | 515 | echo $item; |
516 | - } elseif (is_object($item)) { |
|
516 | + } elseif(is_object($item)) { |
|
517 | 517 | echo get_class($item); |
518 | - } elseif (is_array($item)) { |
|
518 | + } elseif(is_array($item)) { |
|
519 | 519 | echo 'array(' . count($item) . ')'; |
520 | - } elseif (is_bool($item)) { |
|
520 | + } elseif(is_bool($item)) { |
|
521 | 521 | echo $item ? 'true' : 'false'; |
522 | - } elseif ($item === null) { |
|
522 | + } elseif($item === null) { |
|
523 | 523 | echo 'NULL'; |
524 | - } elseif (is_resource($item)) { |
|
524 | + } elseif(is_resource($item)) { |
|
525 | 525 | echo get_resource_type($item); |
526 | 526 | } |
527 | 527 | $count++; |
528 | - if (count($t['args']) > $count) { |
|
528 | + if(count($t['args']) > $count) { |
|
529 | 529 | echo ', '; |
530 | 530 | } |
531 | 531 | } |
@@ -546,18 +546,18 @@ discard block |
||
546 | 546 | public static function getUserLanguages() |
547 | 547 | { |
548 | 548 | static $languages = null; |
549 | - if ($languages === null) { |
|
550 | - if (!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
549 | + if($languages === null) { |
|
550 | + if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
|
551 | 551 | $languages[0] = 'en'; |
552 | 552 | } else { |
553 | 553 | $languages = []; |
554 | - foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) { |
|
554 | + foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $language) { |
|
555 | 555 | $array = explode(';q=', trim($language)); |
556 | - $languages[trim($array[0])] = isset($array[1]) ? (float)$array[1] : 1.0; |
|
556 | + $languages[trim($array[0])] = isset($array[1]) ? (float) $array[1] : 1.0; |
|
557 | 557 | } |
558 | 558 | arsort($languages); |
559 | 559 | $languages = array_keys($languages); |
560 | - if (empty($languages)) { |
|
560 | + if(empty($languages)) { |
|
561 | 561 | $languages[0] = 'en'; |
562 | 562 | } |
563 | 563 | } |
@@ -572,10 +572,10 @@ discard block |
||
572 | 572 | public static function getPreferredLanguage() |
573 | 573 | { |
574 | 574 | static $language = null; |
575 | - if ($language === null) { |
|
575 | + if($language === null) { |
|
576 | 576 | $langs = Prado::getUserLanguages(); |
577 | 577 | $lang = explode('-', $langs[0]); |
578 | - if (empty($lang[0]) || !ctype_alpha($lang[0])) { |
|
578 | + if(empty($lang[0]) || !ctype_alpha($lang[0])) { |
|
579 | 579 | $language = 'en'; |
580 | 580 | } else { |
581 | 581 | $language = $lang[0]; |
@@ -598,12 +598,12 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public static function trace($msg, $category = 'Uncategorized', $ctl = null) |
600 | 600 | { |
601 | - if (self::$_application && self::$_application->getMode() === TApplicationMode::Performance) { |
|
601 | + if(self::$_application && self::$_application->getMode() === TApplicationMode::Performance) { |
|
602 | 602 | return; |
603 | 603 | } |
604 | - if (!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) { |
|
604 | + if(!self::$_application || self::$_application->getMode() === TApplicationMode::Debug) { |
|
605 | 605 | $trace = debug_backtrace(); |
606 | - if (isset($trace[0]['file']) && isset($trace[0]['line'])) { |
|
606 | + if(isset($trace[0]['file']) && isset($trace[0]['line'])) { |
|
607 | 607 | $msg .= " (line {$trace[0]['line']}, {$trace[0]['file']})"; |
608 | 608 | } |
609 | 609 | $level = TLogger::DEBUG; |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | */ |
628 | 628 | public static function log($msg, $level = TLogger::INFO, $category = 'Uncategorized', $ctl = null) |
629 | 629 | { |
630 | - if (self::$_logger === null) { |
|
630 | + if(self::$_logger === null) { |
|
631 | 631 | self::$_logger = new TLogger; |
632 | 632 | } |
633 | 633 | self::$_logger->log($msg, $level, $category, $ctl); |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | public static function getLogger() |
640 | 640 | { |
641 | - if (self::$_logger === null) { |
|
641 | + if(self::$_logger === null) { |
|
642 | 642 | self::$_logger = new TLogger; |
643 | 643 | } |
644 | 644 | return self::$_logger; |
@@ -673,16 +673,16 @@ discard block |
||
673 | 673 | $app = Prado::getApplication()->getGlobalization(false); |
674 | 674 | |
675 | 675 | $params = []; |
676 | - foreach ($parameters as $key => $value) { |
|
676 | + foreach($parameters as $key => $value) { |
|
677 | 677 | $params['{' . $key . '}'] = $value; |
678 | 678 | } |
679 | 679 | |
680 | 680 | //no translation handler provided |
681 | - if ($app === null || ($config = $app->getTranslationConfiguration()) === null) { |
|
681 | + if($app === null || ($config = $app->getTranslationConfiguration()) === null) { |
|
682 | 682 | return strtr($text, $params); |
683 | 683 | } |
684 | 684 | |
685 | - if ($catalogue === null) { |
|
685 | + if($catalogue === null) { |
|
686 | 686 | $catalogue = isset($config['catalogue']) ? $config['catalogue'] : 'messages'; |
687 | 687 | } |
688 | 688 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | $defaultCharset = ($app === null) ? 'UTF-8' : $app->getDefaultCharset(); |
696 | 696 | |
697 | 697 | //fall back |
698 | - if (empty($charset)) { |
|
698 | + if(empty($charset)) { |
|
699 | 699 | $charset = $appCharset; |
700 | 700 | } |
701 | - if (empty($charset)) { |
|
701 | + if(empty($charset)) { |
|
702 | 702 | $charset = $defaultCharset; |
703 | 703 | } |
704 | 704 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function loadFromFile($fname) |
68 | 68 | { |
69 | - if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { |
|
69 | + if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) { |
|
70 | 70 | $fcontent = include $fname; |
71 | 71 | $this->loadFromPhp($fcontent, dirname($fname)); |
72 | 72 | } else { |
@@ -92,30 +92,30 @@ discard block |
||
92 | 92 | public function loadFromPhp($config, $configPath) |
93 | 93 | { |
94 | 94 | // application properties |
95 | - if (isset($config['application'])) { |
|
96 | - foreach ($config['application'] as $name => $value) { |
|
95 | + if(isset($config['application'])) { |
|
96 | + foreach($config['application'] as $name => $value) { |
|
97 | 97 | $this->_properties[$name] = $value; |
98 | 98 | } |
99 | 99 | $this->_empty = false; |
100 | 100 | } |
101 | 101 | |
102 | - if (isset($config['paths']) && is_array($config['paths'])) { |
|
102 | + if(isset($config['paths']) && is_array($config['paths'])) { |
|
103 | 103 | $this->loadPathsPhp($config['paths'], $configPath); |
104 | 104 | } |
105 | 105 | |
106 | - if (isset($config['modules']) && is_array($config['modules'])) { |
|
106 | + if(isset($config['modules']) && is_array($config['modules'])) { |
|
107 | 107 | $this->loadModulesPhp($config['modules'], $configPath); |
108 | 108 | } |
109 | 109 | |
110 | - if (isset($config['services']) && is_array($config['services'])) { |
|
110 | + if(isset($config['services']) && is_array($config['services'])) { |
|
111 | 111 | $this->loadServicesPhp($config['services'], $configPath); |
112 | 112 | } |
113 | 113 | |
114 | - if (isset($config['parameters']) && is_array($config['parameters'])) { |
|
114 | + if(isset($config['parameters']) && is_array($config['parameters'])) { |
|
115 | 115 | $this->loadParametersPhp($config['parameters'], $configPath); |
116 | 116 | } |
117 | 117 | |
118 | - if (isset($config['includes']) && is_array($config['includes'])) { |
|
118 | + if(isset($config['includes']) && is_array($config['includes'])) { |
|
119 | 119 | $this->loadExternalXml($config['includes'], $configPath); |
120 | 120 | } |
121 | 121 | } |
@@ -128,13 +128,13 @@ discard block |
||
128 | 128 | public function loadFromXml($dom, $configPath) |
129 | 129 | { |
130 | 130 | // application properties |
131 | - foreach ($dom->getAttributes() as $name => $value) { |
|
131 | + foreach($dom->getAttributes() as $name => $value) { |
|
132 | 132 | $this->_properties[$name] = $value; |
133 | 133 | $this->_empty = false; |
134 | 134 | } |
135 | 135 | |
136 | - foreach ($dom->getElements() as $element) { |
|
137 | - switch ($element->getTagName()) { |
|
136 | + foreach($dom->getElements() as $element) { |
|
137 | + switch($element->getTagName()) { |
|
138 | 138 | case 'paths': |
139 | 139 | $this->loadPathsXml($element, $configPath); |
140 | 140 | break; |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | */ |
165 | 165 | protected function loadPathsPhp($pathsNode, $configPath) |
166 | 166 | { |
167 | - if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) { |
|
168 | - foreach ($pathsNode['aliases'] as $id => $path) { |
|
167 | + if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) { |
|
168 | + foreach($pathsNode['aliases'] as $id => $path) { |
|
169 | 169 | $path = str_replace('\\', '/', $path); |
170 | - if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { // if absolute path |
|
170 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { // if absolute path |
|
171 | 171 | $p = realpath($path); |
172 | 172 | } else { |
173 | 173 | $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
174 | 174 | } |
175 | - if ($p === false || !is_dir($p)) { |
|
175 | + if($p === false || !is_dir($p)) { |
|
176 | 176 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
177 | 177 | } |
178 | - if (isset($this->_aliases[$id])) { |
|
178 | + if(isset($this->_aliases[$id])) { |
|
179 | 179 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
180 | 180 | } |
181 | 181 | $this->_aliases[$id] = $p; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if (isset($pathsNode['using']) && is_array($pathsNode['using'])) { |
|
186 | - foreach ($pathsNode['using'] as $namespace) { |
|
185 | + if(isset($pathsNode['using']) && is_array($pathsNode['using'])) { |
|
186 | + foreach($pathsNode['using'] as $namespace) { |
|
187 | 187 | $this->_usings[] = $namespace; |
188 | 188 | } |
189 | 189 | } |
@@ -196,21 +196,21 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function loadPathsXml($pathsNode, $configPath) |
198 | 198 | { |
199 | - foreach ($pathsNode->getElements() as $element) { |
|
200 | - switch ($element->getTagName()) { |
|
199 | + foreach($pathsNode->getElements() as $element) { |
|
200 | + switch($element->getTagName()) { |
|
201 | 201 | case 'alias': |
202 | 202 | { |
203 | - if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) { |
|
203 | + if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) { |
|
204 | 204 | $path = str_replace('\\', '/', $path); |
205 | - if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { // if absolute path |
|
205 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { // if absolute path |
|
206 | 206 | $p = realpath($path); |
207 | 207 | } else { |
208 | 208 | $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
209 | 209 | } |
210 | - if ($p === false || !is_dir($p)) { |
|
210 | + if($p === false || !is_dir($p)) { |
|
211 | 211 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
212 | 212 | } |
213 | - if (isset($this->_aliases[$id])) { |
|
213 | + if(isset($this->_aliases[$id])) { |
|
214 | 214 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
215 | 215 | } |
216 | 216 | $this->_aliases[$id] = $p; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | } |
223 | 223 | case 'using': |
224 | 224 | { |
225 | - if (($namespace = $element->getAttribute('namespace')) !== null) { |
|
225 | + if(($namespace = $element->getAttribute('namespace')) !== null) { |
|
226 | 226 | $this->_usings[] = $namespace; |
227 | 227 | } else { |
228 | 228 | throw new TConfigurationException('appconfig_using_invalid'); |
@@ -243,19 +243,19 @@ discard block |
||
243 | 243 | */ |
244 | 244 | protected function loadModulesPhp($modulesNode, $configPath) |
245 | 245 | { |
246 | - foreach ($modulesNode as $id => $module) { |
|
247 | - if (!isset($module['class'])) { |
|
246 | + foreach($modulesNode as $id => $module) { |
|
247 | + if(!isset($module['class'])) { |
|
248 | 248 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
249 | 249 | } |
250 | 250 | $type = $module['class']; |
251 | 251 | unset($module['class']); |
252 | 252 | $properties = []; |
253 | - if (isset($module['properties'])) { |
|
253 | + if(isset($module['properties'])) { |
|
254 | 254 | $properties = $module['properties']; |
255 | 255 | unset($module['properties']); |
256 | 256 | } |
257 | 257 | $properties['id'] = $id; |
258 | - $this->_modules[$id] = [$type,$properties,$module]; |
|
258 | + $this->_modules[$id] = [$type, $properties, $module]; |
|
259 | 259 | $this->_empty = false; |
260 | 260 | } |
261 | 261 | } |
@@ -267,19 +267,19 @@ discard block |
||
267 | 267 | */ |
268 | 268 | protected function loadModulesXml($modulesNode, $configPath) |
269 | 269 | { |
270 | - foreach ($modulesNode->getElements() as $element) { |
|
271 | - if ($element->getTagName() === 'module') { |
|
270 | + foreach($modulesNode->getElements() as $element) { |
|
271 | + if($element->getTagName() === 'module') { |
|
272 | 272 | $properties = $element->getAttributes(); |
273 | 273 | $id = $properties->itemAt('id'); |
274 | 274 | $type = $properties->remove('class'); |
275 | - if ($type === null) { |
|
275 | + if($type === null) { |
|
276 | 276 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
277 | 277 | } |
278 | 278 | $element->setParent(null); |
279 | - if ($id === null) { |
|
280 | - $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
279 | + if($id === null) { |
|
280 | + $this->_modules[] = [$type, $properties->toArray(), $element]; |
|
281 | 281 | } else { |
282 | - $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
282 | + $this->_modules[$id] = [$type, $properties->toArray(), $element]; |
|
283 | 283 | } |
284 | 284 | $this->_empty = false; |
285 | 285 | } else { |
@@ -295,15 +295,15 @@ discard block |
||
295 | 295 | */ |
296 | 296 | protected function loadServicesPhp($servicesNode, $configPath) |
297 | 297 | { |
298 | - foreach ($servicesNode as $id => $service) { |
|
299 | - if (!isset($service['class'])) { |
|
298 | + foreach($servicesNode as $id => $service) { |
|
299 | + if(!isset($service['class'])) { |
|
300 | 300 | throw new TConfigurationException('appconfig_servicetype_required'); |
301 | 301 | } |
302 | 302 | $type = $service['class']; |
303 | 303 | $properties = isset($service['properties']) ? $service['properties'] : []; |
304 | 304 | unset($service['properties']); |
305 | 305 | $properties['id'] = $id; |
306 | - $this->_services[$id] = [$type,$properties,$service]; |
|
306 | + $this->_services[$id] = [$type, $properties, $service]; |
|
307 | 307 | $this->_empty = false; |
308 | 308 | } |
309 | 309 | } |
@@ -315,17 +315,17 @@ discard block |
||
315 | 315 | */ |
316 | 316 | protected function loadServicesXml($servicesNode, $configPath) |
317 | 317 | { |
318 | - foreach ($servicesNode->getElements() as $element) { |
|
319 | - if ($element->getTagName() === 'service') { |
|
318 | + foreach($servicesNode->getElements() as $element) { |
|
319 | + if($element->getTagName() === 'service') { |
|
320 | 320 | $properties = $element->getAttributes(); |
321 | - if (($id = $properties->itemAt('id')) === null) { |
|
321 | + if(($id = $properties->itemAt('id')) === null) { |
|
322 | 322 | throw new TConfigurationException('appconfig_serviceid_required'); |
323 | 323 | } |
324 | - if (($type = $properties->remove('class')) === null) { |
|
324 | + if(($type = $properties->remove('class')) === null) { |
|
325 | 325 | throw new TConfigurationException('appconfig_servicetype_required', $id); |
326 | 326 | } |
327 | 327 | $element->setParent(null); |
328 | - $this->_services[$id] = [$type,$properties->toArray(),$element]; |
|
328 | + $this->_services[$id] = [$type, $properties->toArray(), $element]; |
|
329 | 329 | $this->_empty = false; |
330 | 330 | } else { |
331 | 331 | throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
@@ -340,14 +340,14 @@ discard block |
||
340 | 340 | */ |
341 | 341 | protected function loadParametersPhp($parametersNode, $configPath) |
342 | 342 | { |
343 | - foreach ($parametersNode as $id => $parameter) { |
|
344 | - if (is_array($parameter)) { |
|
345 | - if (isset($parameter['class'])) { |
|
343 | + foreach($parametersNode as $id => $parameter) { |
|
344 | + if(is_array($parameter)) { |
|
345 | + if(isset($parameter['class'])) { |
|
346 | 346 | $type = $parameter['class']; |
347 | 347 | unset($parameter['class']); |
348 | 348 | $properties = isset($service['properties']) ? $service['properties'] : []; |
349 | 349 | $properties['id'] = $id; |
350 | - $this->_parameters[$id] = [$type,$properties]; |
|
350 | + $this->_parameters[$id] = [$type, $properties]; |
|
351 | 351 | } |
352 | 352 | } else { |
353 | 353 | $this->_parameters[$id] = $parameter; |
@@ -362,20 +362,20 @@ discard block |
||
362 | 362 | */ |
363 | 363 | protected function loadParametersXml($parametersNode, $configPath) |
364 | 364 | { |
365 | - foreach ($parametersNode->getElements() as $element) { |
|
366 | - if ($element->getTagName() === 'parameter') { |
|
365 | + foreach($parametersNode->getElements() as $element) { |
|
366 | + if($element->getTagName() === 'parameter') { |
|
367 | 367 | $properties = $element->getAttributes(); |
368 | - if (($id = $properties->remove('id')) === null) { |
|
368 | + if(($id = $properties->remove('id')) === null) { |
|
369 | 369 | throw new TConfigurationException('appconfig_parameterid_required'); |
370 | 370 | } |
371 | - if (($type = $properties->remove('class')) === null) { |
|
372 | - if (($value = $properties->remove('value')) === null) { |
|
371 | + if(($type = $properties->remove('class')) === null) { |
|
372 | + if(($value = $properties->remove('value')) === null) { |
|
373 | 373 | $this->_parameters[$id] = $element; |
374 | 374 | } else { |
375 | 375 | $this->_parameters[$id] = $value; |
376 | 376 | } |
377 | 377 | } else { |
378 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
378 | + $this->_parameters[$id] = [$type, $properties->toArray()]; |
|
379 | 379 | } |
380 | 380 | $this->_empty = false; |
381 | 381 | } else { |
@@ -391,13 +391,13 @@ discard block |
||
391 | 391 | */ |
392 | 392 | protected function loadExternalPhp($includeNode, $configPath) |
393 | 393 | { |
394 | - foreach ($includeNode as $include) { |
|
394 | + foreach($includeNode as $include) { |
|
395 | 395 | $when = isset($include['when']) ? true : false; |
396 | - if (!isset($include['file'])) { |
|
396 | + if(!isset($include['file'])) { |
|
397 | 397 | throw new TConfigurationException('appconfig_includefile_required'); |
398 | 398 | } |
399 | 399 | $filePath = $include['file']; |
400 | - if (isset($this->_includes[$filePath])) { |
|
400 | + if(isset($this->_includes[$filePath])) { |
|
401 | 401 | $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
402 | 402 | } else { |
403 | 403 | $$this->_includes[$filePath] = $when; |
@@ -413,13 +413,13 @@ discard block |
||
413 | 413 | */ |
414 | 414 | protected function loadExternalXml($includeNode, $configPath) |
415 | 415 | { |
416 | - if (($when = $includeNode->getAttribute('when')) === null) { |
|
416 | + if(($when = $includeNode->getAttribute('when')) === null) { |
|
417 | 417 | $when = true; |
418 | 418 | } |
419 | - if (($filePath = $includeNode->getAttribute('file')) === null) { |
|
419 | + if(($filePath = $includeNode->getAttribute('file')) === null) { |
|
420 | 420 | throw new TConfigurationException('appconfig_includefile_required'); |
421 | 421 | } |
422 | - if (isset($this->_includes[$filePath])) { |
|
422 | + if(isset($this->_includes[$filePath])) { |
|
423 | 423 | $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
424 | 424 | } else { |
425 | 425 | $this->_includes[$filePath] = $when; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getPdoType() |
70 | 70 | { |
71 | - switch ($this->getPHPType()) { |
|
71 | + switch($this->getPHPType()) { |
|
72 | 72 | case 'boolean': return PDO::PARAM_BOOL; |
73 | 73 | case 'integer': return PDO::PARAM_INT; |
74 | 74 | case 'string': return PDO::PARAM_STR; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | public function getMaxiumNumericConstraint() |
152 | 152 | { |
153 | - if (($precision = $this->getNumericPrecision()) !== null) { |
|
153 | + if(($precision = $this->getNumericPrecision()) !== null) { |
|
154 | 154 | $scale = $this->getNumericScale(); |
155 | 155 | return $scale === null ? pow(10, $precision) : pow(10, $precision - $scale); |
156 | 156 | } |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getLastInsertID() |
78 | 78 | { |
79 | - foreach ($this->getTableInfo()->getColumns() as $column) { |
|
80 | - if ($column->hasSequence()) { |
|
79 | + foreach($this->getTableInfo()->getColumns() as $column) { |
|
80 | + if($column->hasSequence()) { |
|
81 | 81 | return $this->getDbConnection()->getLastInsertID($column->getSequenceName()); |
82 | 82 | } |
83 | 83 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function applyLimitOffset($sql, $limit = -1, $offset = -1) |
95 | 95 | { |
96 | - $limit = $limit !== null ? (int)$limit : -1; |
|
97 | - $offset = $offset !== null ? (int)$offset : -1; |
|
96 | + $limit = $limit !== null ? (int) $limit : -1; |
|
97 | + $offset = $offset !== null ? (int) $offset : -1; |
|
98 | 98 | $limitStr = $limit >= 0 ? ' LIMIT ' . $limit : ''; |
99 | 99 | $offsetStr = $offset >= 0 ? ' OFFSET ' . $offset : ''; |
100 | 100 | return $sql . $limitStr . $offsetStr; |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | public function applyOrdering($sql, $ordering) |
109 | 109 | { |
110 | 110 | $orders = []; |
111 | - foreach ($ordering as $name => $direction) { |
|
111 | + foreach($ordering as $name => $direction) { |
|
112 | 112 | $direction = strtolower($direction) == 'desc' ? 'DESC' : 'ASC'; |
113 | - if (false !== strpos($name, '(') && false !== strpos($name, ')')) { |
|
113 | + if(false !== strpos($name, '(') && false !== strpos($name, ')')) { |
|
114 | 114 | // key is a function (bad practice, but we need to handle it) |
115 | 115 | $key = $name; |
116 | 116 | } else { |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | $orders[] = $key . ' ' . $direction; |
121 | 121 | } |
122 | - if (count($orders) > 0) { |
|
122 | + if(count($orders) > 0) { |
|
123 | 123 | $sql .= ' ORDER BY ' . implode(', ', $orders); |
124 | 124 | } |
125 | 125 | return $sql; |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function getSearchExpression($fields, $keywords) |
137 | 137 | { |
138 | - if (strlen(trim($keywords)) == 0) { |
|
138 | + if(strlen(trim($keywords)) == 0) { |
|
139 | 139 | return ''; |
140 | 140 | } |
141 | 141 | $words = preg_split('/\s/u', $keywords); |
142 | 142 | $conditions = []; |
143 | - foreach ($fields as $field) { |
|
143 | + foreach($fields as $field) { |
|
144 | 144 | $column = $this->getTableInfo()->getColumn($field)->getColumnName(); |
145 | 145 | $conditions[] = $this->getSearchCondition($column, $words); |
146 | 146 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | protected function getSearchCondition($column, $words) |
156 | 156 | { |
157 | 157 | $conditions = []; |
158 | - foreach ($words as $word) { |
|
158 | + foreach($words as $word) { |
|
159 | 159 | $conditions[] = $column . ' LIKE ' . $this->getDbConnection()->quoteString('%' . $word . '%'); |
160 | 160 | } |
161 | 161 | return '(' . implode(' AND ', $conditions) . ')'; |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function getSelectFieldList($data = '*') |
204 | 204 | { |
205 | - if (is_scalar($data)) { |
|
205 | + if(is_scalar($data)) { |
|
206 | 206 | $tmp = explode(',', $data); |
207 | 207 | $result = []; |
208 | - foreach ($tmp as $v) { |
|
208 | + foreach($tmp as $v) { |
|
209 | 209 | $result[] = trim($v); |
210 | 210 | } |
211 | 211 | return $result; |
@@ -213,94 +213,94 @@ discard block |
||
213 | 213 | |
214 | 214 | $bHasWildcard = false; |
215 | 215 | $result = []; |
216 | - if (is_array($data) || $data instanceof Traversable) { |
|
216 | + if(is_array($data) || $data instanceof Traversable) { |
|
217 | 217 | $columns = $this->getTableInfo()->getColumns(); |
218 | - foreach ($data as $key => $value) { |
|
219 | - if ($key === '*' || $value === '*') { |
|
218 | + foreach($data as $key => $value) { |
|
219 | + if($key === '*' || $value === '*') { |
|
220 | 220 | $bHasWildcard = true; |
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
224 | - if (strToUpper($key) === 'NULL') { |
|
224 | + if(strToUpper($key) === 'NULL') { |
|
225 | 225 | $result[] = 'NULL'; |
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
229 | - if (strpos($key, '(') !== false && strpos($key, ')') !== false) { |
|
229 | + if(strpos($key, '(') !== false && strpos($key, ')') !== false) { |
|
230 | 230 | $result[] = $key; |
231 | 231 | continue; |
232 | 232 | } |
233 | 233 | |
234 | - if (stripos($key, 'AS') !== false) { |
|
234 | + if(stripos($key, 'AS') !== false) { |
|
235 | 235 | $result[] = $key; |
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | |
239 | - if (stripos($value, 'AS') !== false) { |
|
239 | + if(stripos($value, 'AS') !== false) { |
|
240 | 240 | $result[] = $value; |
241 | 241 | continue; |
242 | 242 | } |
243 | 243 | |
244 | 244 | $v = isset($columns[$value]); |
245 | 245 | $k = isset($columns[$key]); |
246 | - if (is_int($key) && $v) { |
|
246 | + if(is_int($key) && $v) { |
|
247 | 247 | $key = $value; |
248 | 248 | $k = $v; |
249 | 249 | } |
250 | 250 | |
251 | - if (strToUpper($value) === 'NULL') { |
|
252 | - if ($k) { |
|
251 | + if(strToUpper($value) === 'NULL') { |
|
252 | + if($k) { |
|
253 | 253 | $result[] = 'NULL AS ' . $columns[$key]->getColumnName(); |
254 | 254 | } else { |
255 | - $result[] = 'NULL' . (is_string($key) ? (' AS ' . (string)$key) : ''); |
|
255 | + $result[] = 'NULL' . (is_string($key) ? (' AS ' . (string) $key) : ''); |
|
256 | 256 | } |
257 | 257 | continue; |
258 | 258 | } |
259 | 259 | |
260 | - if (strpos($value, '(') !== false && strpos($value, ')') !== false) { |
|
261 | - if ($k) { |
|
260 | + if(strpos($value, '(') !== false && strpos($value, ')') !== false) { |
|
261 | + if($k) { |
|
262 | 262 | $result[] = $value . ' AS ' . $columns[$key]->getColumnName(); |
263 | 263 | } else { |
264 | - $result[] = $value . (is_string($key) ? (' AS ' . (string)$key) : ''); |
|
264 | + $result[] = $value . (is_string($key) ? (' AS ' . (string) $key) : ''); |
|
265 | 265 | } |
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | - if ($v && $key == $value) { |
|
269 | + if($v && $key == $value) { |
|
270 | 270 | $result[] = $columns[$value]->getColumnName(); |
271 | 271 | continue; |
272 | 272 | } |
273 | 273 | |
274 | - if ($k && $value == null) { |
|
274 | + if($k && $value == null) { |
|
275 | 275 | $result[] = $columns[$key]->getColumnName(); |
276 | 276 | continue; |
277 | 277 | } |
278 | 278 | |
279 | - if (is_string($key) && $v) { |
|
279 | + if(is_string($key) && $v) { |
|
280 | 280 | $result[] = $columns[$value]->getColumnName() . ' AS ' . $key; |
281 | 281 | continue; |
282 | 282 | } |
283 | 283 | |
284 | - if (is_numeric($value) && $k) { |
|
284 | + if(is_numeric($value) && $k) { |
|
285 | 285 | $result[] = $value . ' AS ' . $columns[$key]->getColumnName(); |
286 | 286 | continue; |
287 | 287 | } |
288 | 288 | |
289 | - if (is_string($value) && $k) { |
|
289 | + if(is_string($value) && $k) { |
|
290 | 290 | $result[] = $this->getDbConnection()->quoteString($value) . ' AS ' . $columns[$key]->getColumnName(); |
291 | 291 | continue; |
292 | 292 | } |
293 | 293 | |
294 | - if (!$v && !$k && is_int($key)) { |
|
295 | - $result[] = is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value); |
|
294 | + if(!$v && !$k && is_int($key)) { |
|
295 | + $result[] = is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value); |
|
296 | 296 | continue; |
297 | 297 | } |
298 | 298 | |
299 | - $result[] = (is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string)$value)) . ' AS ' . $key; |
|
299 | + $result[] = (is_numeric($value) ? $value : $this->getDbConnection()->quoteString((string) $value)) . ' AS ' . $key; |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
303 | - if ($data === null || count($result) == 0 || $bHasWildcard) { |
|
303 | + if($data === null || count($result) == 0 || $bHasWildcard) { |
|
304 | 304 | $result = $result = array_merge($this->getTableInfo()->getColumnNames(), $result); |
305 | 305 | } |
306 | 306 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | $table = $this->getTableInfo()->getTableFullName(); |
320 | 320 | $fields = implode(', ', $this -> getSelectFieldList($select)); |
321 | 321 | $sql = "SELECT {$fields} FROM {$table}"; |
322 | - if (!empty($where)) { |
|
322 | + if(!empty($where)) { |
|
323 | 323 | $sql .= " WHERE {$where}"; |
324 | 324 | } |
325 | 325 | return $this->applyCriterias($sql, $parameters, $ordering, $limit, $offset); |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | |
328 | 328 | public function applyCriterias($sql, $parameters = [], $ordering = [], $limit = -1, $offset = -1) |
329 | 329 | { |
330 | - if (count($ordering) > 0) { |
|
330 | + if(count($ordering) > 0) { |
|
331 | 331 | $sql = $this->applyOrdering($sql, $ordering); |
332 | 332 | } |
333 | - if ($limit >= 0 || $offset >= 0) { |
|
333 | + if($limit >= 0 || $offset >= 0) { |
|
334 | 334 | $sql = $this->applyLimitOffset($sql, $limit, $offset); |
335 | 335 | } |
336 | 336 | $command = $this->createCommand($sql); |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | public function createDeleteCommand($where, $parameters = []) |
361 | 361 | { |
362 | 362 | $table = $this->getTableInfo()->getTableFullName(); |
363 | - if (!empty($where)) { |
|
363 | + if(!empty($where)) { |
|
364 | 364 | $where = ' WHERE ' . $where; |
365 | 365 | } |
366 | 366 | $command = $this->createCommand("DELETE FROM {$table}" . $where); |
@@ -396,13 +396,13 @@ discard block |
||
396 | 396 | public function createUpdateCommand($data, $where, $parameters = []) |
397 | 397 | { |
398 | 398 | $table = $this->getTableInfo()->getTableFullName(); |
399 | - if ($this->hasIntegerKey($parameters)) { |
|
399 | + if($this->hasIntegerKey($parameters)) { |
|
400 | 400 | $fields = implode(', ', $this->getColumnBindings($data, true)); |
401 | 401 | } else { |
402 | 402 | $fields = implode(', ', $this->getColumnBindings($data)); |
403 | 403 | } |
404 | 404 | |
405 | - if (!empty($where)) { |
|
405 | + if(!empty($where)) { |
|
406 | 406 | $where = ' WHERE ' . $where; |
407 | 407 | } |
408 | 408 | $command = $this->createCommand("UPDATE {$table} SET {$fields}" . $where); |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | { |
420 | 420 | $fields = []; |
421 | 421 | $bindings = []; |
422 | - foreach (array_keys($values) as $name) { |
|
422 | + foreach(array_keys($values) as $name) { |
|
423 | 423 | $fields[] = $this->getTableInfo()->getColumn($name)->getColumnName(); |
424 | 424 | $bindings[] = ':' . $name; |
425 | 425 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | protected function getColumnBindings($values, $position = false) |
436 | 436 | { |
437 | 437 | $bindings = []; |
438 | - foreach (array_keys($values) as $name) { |
|
438 | + foreach(array_keys($values) as $name) { |
|
439 | 439 | $column = $this->getTableInfo()->getColumn($name)->getColumnName(); |
440 | 440 | $bindings[] = $position ? $column . ' = ?' : $column . ' = :' . $name; |
441 | 441 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | */ |
460 | 460 | public function bindColumnValues($command, $values) |
461 | 461 | { |
462 | - foreach ($values as $name => $value) { |
|
462 | + foreach($values as $name => $value) { |
|
463 | 463 | $column = $this->getTableInfo()->getColumn($name); |
464 | - if ($value === null && $column->getAllowNull()) { |
|
464 | + if($value === null && $column->getAllowNull()) { |
|
465 | 465 | $command->bindValue(':' . $name, null, PDO::PARAM_NULL); |
466 | 466 | } else { |
467 | 467 | $command->bindValue(':' . $name, $value, $column->getPdoType()); |
@@ -475,13 +475,13 @@ discard block |
||
475 | 475 | */ |
476 | 476 | public function bindArrayValues($command, $values) |
477 | 477 | { |
478 | - if ($this->hasIntegerKey($values)) { |
|
478 | + if($this->hasIntegerKey($values)) { |
|
479 | 479 | $values = array_values($values); |
480 | - for ($i = 0, $max = count($values); $i < $max; $i++) { |
|
480 | + for($i = 0, $max = count($values); $i < $max; $i++) { |
|
481 | 481 | $command->bindValue($i + 1, $values[$i], $this->getPdoType($values[$i])); |
482 | 482 | } |
483 | 483 | } else { |
484 | - foreach ($values as $name => $value) { |
|
484 | + foreach($values as $name => $value) { |
|
485 | 485 | $prop = $name[0] === ':' ? $name : ':' . $name; |
486 | 486 | $command->bindValue($prop, $value, $this->getPdoType($value)); |
487 | 487 | } |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public static function getPdoType($value) |
496 | 496 | { |
497 | - switch (gettype($value)) { |
|
497 | + switch(gettype($value)) { |
|
498 | 498 | case 'boolean': return PDO::PARAM_BOOL; |
499 | 499 | case 'integer': return PDO::PARAM_INT; |
500 | 500 | case 'string': return PDO::PARAM_STR; |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | */ |
508 | 508 | protected function hasIntegerKey($array) |
509 | 509 | { |
510 | - foreach ($array as $k => $v) { |
|
511 | - if (gettype($k) === 'integer') { |
|
510 | + foreach($array as $k => $v) { |
|
511 | + if(gettype($k) === 'integer') { |
|
512 | 512 | return true; |
513 | 513 | } |
514 | 514 | } |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | { |
319 | 319 | $table = $this->getTableInfo()->getTableFullName(); |
320 | 320 | $fields = implode(', ', $this -> getSelectFieldList($select)); |
321 | - $sql = "SELECT {$fields} FROM {$table}"; |
|
321 | + $sql = "select {$fields} FROM {$table}"; |
|
322 | 322 | if (!empty($where)) { |
323 | 323 | $sql .= " WHERE {$where}"; |
324 | 324 | } |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | if (!empty($where)) { |
406 | 406 | $where = ' WHERE ' . $where; |
407 | 407 | } |
408 | - $command = $this->createCommand("UPDATE {$table} SET {$fields}" . $where); |
|
408 | + $command = $this->createCommand("update {$table} SET {$fields}" . $where); |
|
409 | 409 | $this->bindArrayValues($command, array_merge($data, $parameters)); |
410 | 410 | return $command; |
411 | 411 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function getColumn($name) |
119 | 119 | { |
120 | - if (($column = $this->_columns->itemAt($name)) !== null) { |
|
120 | + if(($column = $this->_columns->itemAt($name)) !== null) { |
|
121 | 121 | return $column; |
122 | 122 | } |
123 | 123 | throw new TDbException('dbtableinfo_invalid_column_name', $name, $this->getTableFullName()); |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function getColumnNames() |
131 | 131 | { |
132 | - if ($this->_names === null) { |
|
132 | + if($this->_names === null) { |
|
133 | 133 | $this->_names = []; |
134 | - foreach ($this->getColumns() as $column) { |
|
134 | + foreach($this->getColumns() as $column) { |
|
135 | 135 | $this->_names[] = $column->getColumnName(); |
136 | 136 | } |
137 | 137 | } |
@@ -159,9 +159,9 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public function getLowerCaseColumnNames() |
161 | 161 | { |
162 | - if ($this->_lowercase === null) { |
|
162 | + if($this->_lowercase === null) { |
|
163 | 163 | $this->_lowercase = []; |
164 | - foreach ($this->getColumns()->getKeys() as $key) { |
|
164 | + foreach($this->getColumns()->getKeys() as $key) { |
|
165 | 165 | $this->_lowercase[strtolower($key)] = $key; |
166 | 166 | } |
167 | 167 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | { |
36 | 36 | $limit = $limit !== null ? intval($limit) : -1; |
37 | 37 | $offset = $offset !== null ? intval($offset) : -1; |
38 | - if ($limit > 0 || $offset > 0) { |
|
38 | + if($limit > 0 || $offset > 0) { |
|
39 | 39 | $limitStr = ' LIMIT ' . $limit; |
40 | 40 | $offsetStr = $offset >= 0 ? ' OFFSET ' . $offset : ''; |
41 | 41 | return $sql . $limitStr . $offsetStr; |
@@ -81,19 +81,19 @@ discard block |
||
81 | 81 | $index = 0; |
82 | 82 | $columns = []; |
83 | 83 | $primary = []; |
84 | - foreach ($command->query() as $col) { |
|
84 | + foreach($command->query() as $col) { |
|
85 | 85 | $col['index'] = $index++; |
86 | 86 | $column = $this->processColumn($col, $foreign); |
87 | 87 | $columns[$col['name']] = $column; |
88 | - if ($column->getIsPrimaryKey()) { |
|
88 | + if($column->getIsPrimaryKey()) { |
|
89 | 89 | $primary[] = $col['name']; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | $info['TableName'] = $tableName; |
93 | - if ($this->getIsView($tableName)) { |
|
93 | + if($this->getIsView($tableName)) { |
|
94 | 94 | $info['IsView'] = true; |
95 | 95 | } |
96 | - if (count($columns) === 0) { |
|
96 | + if(count($columns) === 0) { |
|
97 | 97 | throw new TDbException('dbmetadata_invalid_table_view', $tableName); |
98 | 98 | } |
99 | 99 | $class = $this->getTableInfoClass(); |
@@ -128,18 +128,18 @@ discard block |
||
128 | 128 | $info['ColumnId'] = $columnId; |
129 | 129 | $info['ColumnIndex'] = $col['index']; |
130 | 130 | |
131 | - if ($col['notnull'] !== '99') { |
|
131 | + if($col['notnull'] !== '99') { |
|
132 | 132 | $info['AllowNull'] = true; |
133 | 133 | } |
134 | 134 | |
135 | - if ($col['pk'] === '1') { |
|
135 | + if($col['pk'] === '1') { |
|
136 | 136 | $info['IsPrimaryKey'] = true; |
137 | 137 | } |
138 | - if ($this->isForeignKeyColumn($columnId, $foreign)) { |
|
138 | + if($this->isForeignKeyColumn($columnId, $foreign)) { |
|
139 | 139 | $info['IsForeignKey'] = true; |
140 | 140 | } |
141 | 141 | |
142 | - if ($col['dflt_value'] !== null) { |
|
142 | + if($col['dflt_value'] !== null) { |
|
143 | 143 | $info['DefaultValue'] = $col['dflt_value']; |
144 | 144 | } |
145 | 145 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | |
149 | 149 | $info['DbType'] = $type; |
150 | 150 | $match = []; |
151 | - if (is_int($pos = strpos($type, '(')) && preg_match('/\((.*)\)/', $type, $match)) { |
|
151 | + if(is_int($pos = strpos($type, '(')) && preg_match('/\((.*)\)/', $type, $match)) { |
|
152 | 152 | $ps = explode(',', $match[1]); |
153 | - if (count($ps) === 2) { |
|
153 | + if(count($ps) === 2) { |
|
154 | 154 | $info['NumericPrecision'] = intval($ps[0]); |
155 | 155 | $info['NumericScale'] = intval($ps[1]); |
156 | 156 | } else { |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $sql = "PRAGMA foreign_key_list({$table})"; |
174 | 174 | $command = $this->getDbConnection()->createCommand($sql); |
175 | 175 | $fkeys = []; |
176 | - foreach ($command->query() as $col) { |
|
176 | + foreach($command->query() as $col) { |
|
177 | 177 | $fkeys[$col['table']]['keys'][$col['from']] = $col['to']; |
178 | 178 | $fkeys[$col['table']]['table'] = $col['table']; |
179 | 179 | } |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | */ |
188 | 188 | protected function isForeignKeyColumn($columnId, $foreign) |
189 | 189 | { |
190 | - foreach ($foreign as $fk) { |
|
191 | - if (in_array($columnId, array_keys($fk['keys']))) { |
|
190 | + foreach($foreign as $fk) { |
|
191 | + if(in_array($columnId, array_keys($fk['keys']))) { |
|
192 | 192 | return true; |
193 | 193 | } |
194 | 194 | } |