@@ -99,23 +99,27 @@ |
||
99 | 99 | // Now, let's split the string using ' |
100 | 100 | $work_table = explode("'", $work_str); |
101 | 101 | |
102 | - if (count($work_table)==0) |
|
103 | - return ''; |
|
102 | + if (count($work_table)==0) { |
|
103 | + return ''; |
|
104 | + } |
|
104 | 105 | |
105 | 106 | // if we start with a ', let's remove the first text |
106 | - if (strstr($work_str,"'")===0) |
|
107 | - array_shift($work_table); |
|
107 | + if (strstr($work_str,"'")===0) { |
|
108 | + array_shift($work_table); |
|
109 | + } |
|
108 | 110 | |
109 | - if (count($work_table)==0) |
|
110 | - return ''; |
|
111 | + if (count($work_table)==0) { |
|
112 | + return ''; |
|
113 | + } |
|
111 | 114 | |
112 | 115 | // Now, let's take only the stuff outside the quotes. |
113 | 116 | $work_str2 = ''; |
114 | 117 | |
115 | 118 | $i=0; |
116 | 119 | foreach ($work_table as $str_fragment) { |
117 | - if (($i % 2) == 0) |
|
118 | - $work_str2 .= $str_fragment.' '; |
|
120 | + if (($i % 2) == 0) { |
|
121 | + $work_str2 .= $str_fragment.' '; |
|
122 | + } |
|
119 | 123 | $i++; |
120 | 124 | } |
121 | 125 |
@@ -50,8 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | private static function getAllPossiblePathsRec($sub_table_paths) |
52 | 52 | { |
53 | - if (count($sub_table_paths)==0) |
|
54 | - return array(); |
|
53 | + if (count($sub_table_paths)==0) { |
|
54 | + return array(); |
|
55 | + } |
|
55 | 56 | |
56 | 57 | $table_path = array_shift($sub_table_paths); |
57 | 58 | $possible_sub_paths = AmbiguityException::getAllPossiblePathsRec($sub_table_paths); |
@@ -63,9 +64,9 @@ discard block |
||
63 | 64 | { |
64 | 65 | $return_table_paths[] = array_merge(array(array('paths'=>array($path))), $possible_sub_path); |
65 | 66 | } |
67 | + } else { |
|
68 | + $return_table_paths[] = array(array('paths'=>array($path))); |
|
66 | 69 | } |
67 | - else |
|
68 | - $return_table_paths[] = array(array('paths'=>array($path))); |
|
69 | 70 | } |
70 | 71 | return $return_table_paths; |
71 | 72 | } |
@@ -170,6 +170,9 @@ |
||
170 | 170 | |
171 | 171 | protected $errorMsg; |
172 | 172 | |
173 | + /** |
|
174 | + * @param string $msg |
|
175 | + */ |
|
173 | 176 | private function displayErrorMsg($msg) { |
174 | 177 | $this->errorMsg = $msg; |
175 | 178 | $this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this); |
@@ -31,12 +31,10 @@ discard block |
||
31 | 31 | if ($cnt==1) |
32 | 32 | { |
33 | 33 | return $this[0]->__get($var); |
34 | - } |
|
35 | - elseif ($cnt>1) |
|
34 | + } elseif ($cnt>1) |
|
36 | 35 | { |
37 | 36 | throw new TDBMException('Array contains many objects! Use getarray_'.$var.' to retrieve an array of '.$var); |
38 | - } |
|
39 | - else |
|
37 | + } else |
|
40 | 38 | { |
41 | 39 | throw new TDBMException('Array contains no objects'); |
42 | 40 | } |
@@ -47,12 +45,10 @@ discard block |
||
47 | 45 | if ($cnt==1) |
48 | 46 | { |
49 | 47 | return $this[0]->__set($var, $value); |
50 | - } |
|
51 | - elseif ($cnt>1) |
|
48 | + } elseif ($cnt>1) |
|
52 | 49 | { |
53 | 50 | throw new TDBMException('Array contains many objects! Use setarray_'.$var.' to set the array of '.$var); |
54 | - } |
|
55 | - else |
|
51 | + } else |
|
56 | 52 | { |
57 | 53 | throw new TDBMException('Array contains no objects'); |
58 | 54 | } |
@@ -77,8 +73,7 @@ discard block |
||
77 | 73 | return $this->setarray($column, $values[0]); |
78 | 74 | } elseif (count($this)==1) { |
79 | 75 | $this[0]->__call($func_name, $values); |
80 | - } |
|
81 | - else |
|
76 | + } else |
|
82 | 77 | { |
83 | 78 | throw new TDBMException("Method ".$func_name." not found"); |
84 | 79 | } |
@@ -84,6 +84,9 @@ discard block |
||
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | + /** |
|
88 | + * @param string $column |
|
89 | + */ |
|
87 | 90 | private function getarray($column) { |
88 | 91 | $arr = array(); |
89 | 92 | foreach ($this as $object) { |
@@ -92,6 +95,9 @@ discard block |
||
92 | 95 | return $arr; |
93 | 96 | } |
94 | 97 | |
98 | + /** |
|
99 | + * @param string $column |
|
100 | + */ |
|
95 | 101 | private function setarray($column, $value) { |
96 | 102 | foreach ($this as $object) { |
97 | 103 | $object->__set($column, $value); |
@@ -67,8 +67,7 @@ |
||
67 | 67 | if ($this->link_type == "*1") |
68 | 68 | { |
69 | 69 | echo "Table $this->table_name points to table ".$this->parent_node->table_name." through its foreign key on column $this->keyNode that points to column $this->keyParent<br />"; |
70 | - } |
|
71 | - else if ($this->link_type == "1*") |
|
70 | + } else if ($this->link_type == "1*") |
|
72 | 71 | { |
73 | 72 | echo "Table $this->table_name is pointed by table ".$this->parent_node->table_name." by its foreign key on column $this->keyParent that points to column $this->keyNode<br />"; |
74 | 73 | } |
@@ -263,10 +263,11 @@ discard block |
||
263 | 263 | // Let's try to be accurate in error reporting. The checkColumnExist returns an array of closest matches. |
264 | 264 | $result_array = $column_exist; |
265 | 265 | |
266 | - if (count($result_array)==1) |
|
267 | - $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant this column: '".$result_array[0]."'"; |
|
268 | - else |
|
269 | - $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '",$result_array)."'"; |
|
266 | + if (count($result_array)==1) { |
|
267 | + $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant this column: '".$result_array[0]."'"; |
|
268 | + } else { |
|
269 | + $str = "Could not find column \"$var\" in table \"$this->db_table_name\". Maybe you meant one of those columns: '".implode("', '",$result_array)."'"; |
|
270 | + } |
|
270 | 271 | |
271 | 272 | |
272 | 273 | throw new TDBMException($str); |
@@ -348,10 +349,11 @@ discard block |
||
348 | 349 | if (count($pk_array)>1 && !$pk_set) { |
349 | 350 | $msg = "Error! You did not set the primary keys for the new object of type '$this->db_table_name'. TDBM usually assumes that the primary key is automatically set by the DB engine to the maximum value in the database. However, in this case, the '$this->db_table_name' table has a primary key on multiple columns. TDBM would be unable to find back this record after save. Please specify the primary keys for all new objects of kind '$this->db_table_name'."; |
350 | 351 | |
351 | - if (!$this->tdbmService->isProgramExiting()) |
|
352 | - throw new TDBMException($msg); |
|
353 | - else |
|
354 | - trigger_error($msg, E_USER_ERROR); |
|
352 | + if (!$this->tdbmService->isProgramExiting()) { |
|
353 | + throw new TDBMException($msg); |
|
354 | + } else { |
|
355 | + trigger_error($msg, E_USER_ERROR); |
|
356 | + } |
|
355 | 357 | } |
356 | 358 | |
357 | 359 | $sql = 'INSERT INTO '.$this->db_connection->escapeDBItem($this->db_table_name). |
@@ -360,8 +362,9 @@ discard block |
||
360 | 362 | |
361 | 363 | $first = true; |
362 | 364 | foreach ($this->db_row as $key=>$value) { |
363 | - if (!$first) |
|
364 | - $sql .= ','; |
|
365 | + if (!$first) { |
|
366 | + $sql .= ','; |
|
367 | + } |
|
365 | 368 | $sql .= $this->db_connection->quoteSmart($value); |
366 | 369 | $first=false; |
367 | 370 | } |
@@ -378,9 +381,9 @@ discard block |
||
378 | 381 | // trigger_error("program exiting"); |
379 | 382 | trigger_error($e->getMessage(), E_USER_ERROR); |
380 | 383 | |
381 | - if (!$this->tdbmService->isProgramExiting()) |
|
382 | - throw $e; |
|
383 | - else |
|
384 | + if (!$this->tdbmService->isProgramExiting()) { |
|
385 | + throw $e; |
|
386 | + } else |
|
384 | 387 | { |
385 | 388 | trigger_error($e->getMessage(), E_USER_ERROR); |
386 | 389 | } |
@@ -447,8 +450,9 @@ discard block |
||
447 | 450 | |
448 | 451 | $first = true; |
449 | 452 | foreach ($this->db_row as $key=>$value) { |
450 | - if (!$first) |
|
451 | - $sql .= ','; |
|
453 | + if (!$first) { |
|
454 | + $sql .= ','; |
|
455 | + } |
|
452 | 456 | $sql .= $this->db_connection->escapeDBItem($key)." = ".$this->db_connection->quoteSmart($value); |
453 | 457 | $first=false; |
454 | 458 | } |
@@ -456,10 +460,11 @@ discard block |
||
456 | 460 | try { |
457 | 461 | $this->db_connection->exec($sql); |
458 | 462 | } catch (TDBMException $e) { |
459 | - if (!$this->tdbmService->isProgramExiting()) |
|
460 | - throw $e; |
|
461 | - else |
|
462 | - trigger_error($e->getMessage(), E_USER_ERROR); |
|
463 | + if (!$this->tdbmService->isProgramExiting()) { |
|
464 | + throw $e; |
|
465 | + } else { |
|
466 | + trigger_error($e->getMessage(), E_USER_ERROR); |
|
467 | + } |
|
463 | 468 | } |
464 | 469 | |
465 | 470 | // Let's remove this object from the $new_objects static table. |
@@ -490,11 +495,13 @@ discard block |
||
490 | 495 | * |
491 | 496 | */ |
492 | 497 | public function discardChanges() { |
493 | - if ($this->TDBMObject_state == "new") |
|
494 | - throw new TDBMException("You cannot call discardChanges() on an object that has been created with getNewObject and that has not yet been saved."); |
|
498 | + if ($this->TDBMObject_state == "new") { |
|
499 | + throw new TDBMException("You cannot call discardChanges() on an object that has been created with getNewObject and that has not yet been saved."); |
|
500 | + } |
|
495 | 501 | |
496 | - if ($this->TDBMObject_state == "deleted") |
|
497 | - throw new TDBMException("You cannot call discardChanges() on an object that has been deleted."); |
|
502 | + if ($this->TDBMObject_state == "deleted") { |
|
503 | + throw new TDBMException("You cannot call discardChanges() on an object that has been deleted."); |
|
504 | + } |
|
498 | 505 | |
499 | 506 | $this->db_modified_state = false; |
500 | 507 | $this->TDBMObject_state = "not loaded"; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * false if an explicit call to save() is required. |
146 | 146 | * |
147 | 147 | * @param unknown_type $autoSave |
148 | - * @return boolean |
|
148 | + * @return boolean|null |
|
149 | 149 | */ |
150 | 150 | public function setAutoSaveMode($autoSave) { |
151 | 151 | $this->db_autosave = $autoSave; |
@@ -255,6 +255,9 @@ discard block |
||
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | + /** |
|
259 | + * @param string $var |
|
260 | + */ |
|
258 | 261 | public function __get($var) { |
259 | 262 | $this->_dbLoadIfNotLoaded(); |
260 | 263 | |
@@ -307,6 +310,10 @@ discard block |
||
307 | 310 | return isset($this->db_row[$var]); |
308 | 311 | } |
309 | 312 | |
313 | + /** |
|
314 | + * @param string $var |
|
315 | + * @param string|null $value |
|
316 | + */ |
|
310 | 317 | public function __set($var, $value) { |
311 | 318 | $this->_dbLoadIfNotLoaded(); |
312 | 319 | |
@@ -525,7 +532,7 @@ discard block |
||
525 | 532 | * |
526 | 533 | * @param unknown_type $func_name |
527 | 534 | * @param unknown_type $values |
528 | - * @return unknown |
|
535 | + * @return TDBMObjectArray |
|
529 | 536 | */ |
530 | 537 | public function __call($func_name, $values) { |
531 | 538 |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | $defaultSort = $data['column_name']; |
427 | 427 | if (count($matches == 3)){ |
428 | 428 | $defaultSortDirection = $matches[2]; |
429 | - }else{ |
|
429 | + } else{ |
|
430 | 430 | $defaultSortDirection = 'ASC'; |
431 | 431 | } |
432 | 432 | } |
@@ -836,8 +836,9 @@ discard block |
||
836 | 836 | public static function toCamelCase($str) { |
837 | 837 | $str = strtoupper(substr($str,0,1)).substr($str,1); |
838 | 838 | while (true) { |
839 | - if (strpos($str, "_") === false && strpos($str, " ") === false) |
|
840 | - break; |
|
839 | + if (strpos($str, "_") === false && strpos($str, " ") === false) { |
|
840 | + break; |
|
841 | + } |
|
841 | 842 | |
842 | 843 | $pos = strpos($str, "_"); |
843 | 844 | if ($pos === false) { |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Generates in one method call the daos and the beans for one table. |
126 | 126 | * |
127 | - * @param $tableName |
|
127 | + * @param string $tableName |
|
128 | 128 | */ |
129 | 129 | public function generateDaoAndBean($tableName) { |
130 | 130 | //$baseClassName = TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName)); |
@@ -427,6 +427,10 @@ discard block |
||
427 | 427 | * @param string $fileName The file that will be written (without the directory) |
428 | 428 | * @param string $className The name of the class |
429 | 429 | * @param string $tableName The name of the table |
430 | + * @param string $baseFileName |
|
431 | + * @param string $beanFileName |
|
432 | + * @param string $baseClassName |
|
433 | + * @param string $beanClassName |
|
430 | 434 | */ |
431 | 435 | public function generateDao($fileName, $baseFileName, $beanFileName, $className, $baseClassName, $beanClassName, $tableName) { |
432 | 436 | $info = $this->dbConnection->getTableInfo($tableName); |
@@ -697,7 +701,7 @@ discard block |
||
697 | 701 | /** |
698 | 702 | * Generates the factory bean. |
699 | 703 | * |
700 | - * @param $tableList |
|
704 | + * @param string[] $tableList |
|
701 | 705 | */ |
702 | 706 | private function generateFactory($tableList) { |
703 | 707 | // For each table, let's write a property. |
@@ -763,7 +767,6 @@ discard block |
||
763 | 767 | * Transforms the property name in a setter name. |
764 | 768 | * For instance, phone => getPhone or name => getName |
765 | 769 | * |
766 | - * @param string $methodName |
|
767 | 770 | * @return string |
768 | 771 | */ |
769 | 772 | public static function getSetterNameForPropertyName($propertyName) { |
@@ -843,7 +846,7 @@ discard block |
||
843 | 846 | * Tries to put string to the singular form (if it is plural). |
844 | 847 | * Obviously, this can't be perfect, be we do the best we can. |
845 | 848 | * |
846 | - * @param $str string |
|
849 | + * @param string $str string |
|
847 | 850 | * @return string |
848 | 851 | */ |
849 | 852 | public static function toSingular($str) { |
@@ -864,7 +867,7 @@ discard block |
||
864 | 867 | * Put the first letter of the string in lower case. |
865 | 868 | * Very useful to transform a class name into a variable name. |
866 | 869 | * |
867 | - * @param $str string |
|
870 | + * @param string $str string |
|
868 | 871 | * @return string |
869 | 872 | */ |
870 | 873 | public static function toVariableName($str) { |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | * This action generates the TDBM instance, then the DAOs and Beans. |
137 | 137 | * |
138 | 138 | * @Action |
139 | - * @param string $name |
|
140 | - * @param bool $selfedit |
|
139 | + * @param string|boolean $selfedit |
|
141 | 140 | */ |
142 | 141 | public function generate($sourcedirectory, $daonamespace, $beannamespace, $keepSupport = 0, $storeInUtc = 0, $selfedit="false") { |
143 | 142 | $this->selfedit = $selfedit; |
@@ -163,6 +162,9 @@ discard block |
||
163 | 162 | |
164 | 163 | protected $errorMsg; |
165 | 164 | |
165 | + /** |
|
166 | + * @param string $msg |
|
167 | + */ |
|
166 | 168 | private function displayErrorMsg($msg) { |
167 | 169 | $this->errorMsg = $msg; |
168 | 170 | $this->content->addFile(dirname(__FILE__)."/../../../../views/installError.php", $this); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | * Default constructor to build the filter. |
49 | 49 | * All parameters are optional and can later be set using the setters. |
50 | 50 | * |
51 | - * @param array<FilterInterface> $filter |
|
51 | + * @param array<FilterInterface> $filters |
|
52 | 52 | */ |
53 | 53 | public function __construct($filters=null) { |
54 | 54 | $this->filters = $filters; |
@@ -98,7 +98,7 @@ |
||
98 | 98 | * |
99 | 99 | * @param string $tableName |
100 | 100 | * @param string $columnName |
101 | - * @param string $value |
|
101 | + * @param string $value1 |
|
102 | 102 | */ |
103 | 103 | public function __construct($tableName=null, $columnName=null, $value1=null, $value2=null) { |
104 | 104 | $this->tableName = $tableName; |