@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function clearCache() |
52 | 52 | { |
53 | 53 | $cache = $this->getApplication()->getCache(); |
54 | - if ($cache !== null) { |
|
54 | + if($cache !== null) { |
|
55 | 55 | $cache->delete($this->getCacheKey()); |
56 | 56 | } |
57 | 57 | } |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function getSqlMapManager() |
68 | 68 | { |
69 | - if (($manager = $this->loadCachedSqlMapManager()) === null) { |
|
69 | + if(($manager = $this->loadCachedSqlMapManager()) === null) { |
|
70 | 70 | $manager = new TSqlMapManager($this->getDbConnection()); |
71 | - if (strlen($file = $this->getConfigFile()) > 0) { |
|
71 | + if(strlen($file = $this->getConfigFile()) > 0) { |
|
72 | 72 | $manager->configureXml($file); |
73 | 73 | $this->cacheSqlMapManager($manager); |
74 | 74 | } |
75 | - } elseif ($this->getConnectionID() !== '') { |
|
75 | + } elseif($this->getConnectionID() !== '') { |
|
76 | 76 | $manager->setDbConnection($this->getDbConnection()); |
77 | 77 | } |
78 | 78 | return $manager; |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | */ |
85 | 85 | protected function cacheSqlMapManager($manager) |
86 | 86 | { |
87 | - if ($this->getEnableCache()) { |
|
87 | + if($this->getEnableCache()) { |
|
88 | 88 | $cache = $this->getApplication()->getCache(); |
89 | - if ($cache !== null) { |
|
89 | + if($cache !== null) { |
|
90 | 90 | $dependencies = null; |
91 | - if ($this->getApplication()->getMode() !== TApplicationMode::Performance) { |
|
91 | + if($this->getApplication()->getMode() !== TApplicationMode::Performance) { |
|
92 | 92 | $dependencies = $manager->getCacheDependencies(); |
93 | 93 | } |
94 | 94 | return $cache->set($this->getCacheKey(), $manager, 0, $dependencies); |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function loadCachedSqlMapManager() |
105 | 105 | { |
106 | - if ($this->getEnableCache()) { |
|
106 | + if($this->getEnableCache()) { |
|
107 | 107 | $cache = $this->getApplication()->getCache(); |
108 | - if ($cache !== null) { |
|
108 | + if($cache !== null) { |
|
109 | 109 | $manager = $cache->get($this->getCacheKey()); |
110 | - if ($manager instanceof TSqlMapManager) { |
|
110 | + if($manager instanceof TSqlMapManager) { |
|
111 | 111 | return $manager; |
112 | 112 | } |
113 | 113 | } |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function setConfigFile($value) |
132 | 132 | { |
133 | - if (is_file($value)) { |
|
133 | + if(is_file($value)) { |
|
134 | 134 | $this->_configFile = $value; |
135 | 135 | } else { |
136 | 136 | $file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT); |
137 | - if ($file === null || !is_file($file)) { |
|
137 | + if($file === null || !is_file($file)) { |
|
138 | 138 | throw new TConfigurationException('sqlmap_configfile_invalid', $value); |
139 | 139 | } else { |
140 | 140 | $this->_configFile = $file; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function getClient() |
175 | 175 | { |
176 | - if ($this->_sqlmap === null) { |
|
176 | + if($this->_sqlmap === null) { |
|
177 | 177 | $this->_sqlmap = $this->createSqlMapGateway(); |
178 | 178 | } |
179 | 179 | return $this->_sqlmap; |
@@ -139,22 +139,22 @@ |
||
139 | 139 | { |
140 | 140 | $exprops = []; |
141 | 141 | $cn = 'TParameterProperty'; |
142 | - if ($this->_typeHandler === null) { |
|
142 | + if($this->_typeHandler === null) { |
|
143 | 143 | $exprops[] = "\0$cn\0_typeHandler"; |
144 | 144 | } |
145 | - if ($this->_type === null) { |
|
145 | + if($this->_type === null) { |
|
146 | 146 | $exprops[] = "\0$cn\0_type"; |
147 | 147 | } |
148 | - if ($this->_column === null) { |
|
148 | + if($this->_column === null) { |
|
149 | 149 | $exprops[] = "\0$cn\0_column"; |
150 | 150 | } |
151 | - if ($this->_dbType === null) { |
|
151 | + if($this->_dbType === null) { |
|
152 | 152 | $exprops[] = "\0$cn\0_dbType"; |
153 | 153 | } |
154 | - if ($this->_property === null) { |
|
154 | + if($this->_property === null) { |
|
155 | 155 | $exprops[] = "\0$cn\0_property"; |
156 | 156 | } |
157 | - if ($this->_nullValue === null) { |
|
157 | + if($this->_nullValue === null) { |
|
158 | 158 | $exprops[] = "\0$cn\0_nullValue"; |
159 | 159 | } |
160 | 160 | return array_diff(parent::__sleep(), $exprops); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | { |
165 | 165 | $handler = $registry->getTypeHandler($this->getClass()); |
166 | 166 | try { |
167 | - if ($handler !== null) { |
|
167 | + if($handler !== null) { |
|
168 | 168 | return $handler->createNewInstance(); |
169 | 169 | } else { |
170 | 170 | return $registry->createInstanceOf($this->getClass()); |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | public function resolveSubMap($registry, $row) |
189 | 189 | { |
190 | 190 | $subMap = $this; |
191 | - if (($disc = $this->getDiscriminator()) !== null) { |
|
191 | + if(($disc = $this->getDiscriminator()) !== null) { |
|
192 | 192 | $value = $disc->getMapping()->getPropertyValue($registry, $row); |
193 | - $subMap = $disc->getSubMap((string)$value); |
|
193 | + $subMap = $disc->getSubMap((string) $value); |
|
194 | 194 | |
195 | - if ($subMap === null) { |
|
195 | + if($subMap === null) { |
|
196 | 196 | $subMap = $this; |
197 | - } elseif ($subMap !== $this) { |
|
197 | + } elseif($subMap !== $this) { |
|
198 | 198 | $subMap = $subMap->resolveSubMap($registry, $row); |
199 | 199 | } |
200 | 200 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function initialize($manager) |
250 | 250 | { |
251 | - if (strlen($this->_resultMapName) > 0) { |
|
251 | + if(strlen($this->_resultMapName) > 0) { |
|
252 | 252 | $this->_resultMap = $manager->getResultMap($this->_resultMapName); |
253 | 253 | } |
254 | - if (strlen($this->_parameterMapName) > 0) { |
|
254 | + if(strlen($this->_parameterMapName) > 0) { |
|
255 | 255 | $this->_parameterMap = $manager->getParameterMap($this->_parameterMapName); |
256 | 256 | } |
257 | 257 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function createInstanceOfListClass($registry) |
264 | 264 | { |
265 | - if (strlen($type = $this->getListClass()) > 0) { |
|
265 | + if(strlen($type = $this->getListClass()) > 0) { |
|
266 | 266 | return $this->createInstanceOf($registry, $type); |
267 | 267 | } |
268 | 268 | return []; |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | protected function createInstanceOf($registry, $type, $row = null) |
279 | 279 | { |
280 | 280 | $handler = $registry->getTypeHandler($type); |
281 | - if ($handler !== null) { |
|
281 | + if($handler !== null) { |
|
282 | 282 | return $handler->createNewInstance($row); |
283 | 283 | } else { |
284 | 284 | return $registry->createInstanceOf($type); |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function createInstanceOfResultClass($registry, $row) |
295 | 295 | { |
296 | - if (strlen($type = $this->getResultClass()) > 0) { |
|
296 | + if(strlen($type = $this->getResultClass()) > 0) { |
|
297 | 297 | return $this->createInstanceOf($registry, $type, $row); |
298 | 298 | } |
299 | 299 | } |
@@ -302,40 +302,40 @@ discard block |
||
302 | 302 | { |
303 | 303 | $cn = __CLASS__; |
304 | 304 | $exprops = ["\0$cn\0_resultMap"]; |
305 | - if (!$this->_parameterMapName) { |
|
305 | + if(!$this->_parameterMapName) { |
|
306 | 306 | $exprops[] = "\0$cn\0_parameterMapName"; |
307 | 307 | } |
308 | - if (!$this->_parameterMap) { |
|
308 | + if(!$this->_parameterMap) { |
|
309 | 309 | $exprops[] = "\0$cn\0_parameterMap"; |
310 | 310 | } |
311 | - if (!$this->_parameterClassName) { |
|
311 | + if(!$this->_parameterClassName) { |
|
312 | 312 | $exprops[] = "\0$cn\0_parameterClassName"; |
313 | 313 | } |
314 | - if (!$this->_resultMapName) { |
|
314 | + if(!$this->_resultMapName) { |
|
315 | 315 | $exprops[] = "\0$cn\0_resultMapName"; |
316 | 316 | } |
317 | - if (!$this->_resultMap) { |
|
317 | + if(!$this->_resultMap) { |
|
318 | 318 | $exprops[] = "\0$cn\0_resultMap"; |
319 | 319 | } |
320 | - if (!$this->_resultClassName) { |
|
320 | + if(!$this->_resultClassName) { |
|
321 | 321 | $exprops[] = "\0$cn\0_resultClassName"; |
322 | 322 | } |
323 | - if (!$this->_cacheModelName) { |
|
323 | + if(!$this->_cacheModelName) { |
|
324 | 324 | $exprops[] = "\0$cn\0_cacheModelName"; |
325 | 325 | } |
326 | - if (!$this->_SQL) { |
|
326 | + if(!$this->_SQL) { |
|
327 | 327 | $exprops[] = "\0$cn\0_SQL"; |
328 | 328 | } |
329 | - if (!$this->_listClass) { |
|
329 | + if(!$this->_listClass) { |
|
330 | 330 | $exprops[] = "\0$cn\0_listClass"; |
331 | 331 | } |
332 | - if (!$this->_typeHandler) { |
|
332 | + if(!$this->_typeHandler) { |
|
333 | 333 | $exprops[] = "\0$cn\0_typeHandler"; |
334 | 334 | } |
335 | - if (!$this->_extendStatement) { |
|
335 | + if(!$this->_extendStatement) { |
|
336 | 336 | $exprops[] = "\0$cn\0_extendStatement"; |
337 | 337 | } |
338 | - if (!$this->_cache) { |
|
338 | + if(!$this->_cache) { |
|
339 | 339 | $exprops[] = "\0$cn\0_cache"; |
340 | 340 | } |
341 | 341 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $mappings = []; |
44 | 44 | preg_match_all(self::PARAMETER_TOKEN_REGEXP, $sqlText, $matches); |
45 | 45 | |
46 | - for ($i = 0, $k = count($matches[1]); $i < $k; $i++) { |
|
46 | + for($i = 0, $k = count($matches[1]); $i < $k; $i++) { |
|
47 | 47 | $mappings[] = $this->parseMapping($matches[1][$i], $scope); |
48 | 48 | $sqlText = str_replace($matches[0][$i], '?', $sqlText); |
49 | 49 | } |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | $mapping = new TParameterProperty; |
62 | 62 | $properties = explode(',', $token); |
63 | 63 | $mapping->setProperty(trim(array_shift($properties))); |
64 | - foreach ($properties as $property) { |
|
64 | + foreach($properties as $property) { |
|
65 | 65 | $prop = explode('=', $property); |
66 | 66 | $name = trim($prop[0]); |
67 | 67 | $value = trim($prop[1]); |
68 | - if ($mapping->canSetProperty($name)) { |
|
68 | + if($mapping->canSetProperty($name)) { |
|
69 | 69 | $mapping->{'set' . $name}($value); |
70 | 70 | } else { |
71 | 71 | throw new TSqlMapUndefinedException( |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $this->_configFile = $filename; |
65 | 65 | $document = $this->loadXmlDocument($filename, $this); |
66 | 66 | |
67 | - foreach ($document->xpath('//property') as $property) { |
|
67 | + foreach($document->xpath('//property') as $property) { |
|
68 | 68 | $this->loadGlobalProperty($property); |
69 | 69 | } |
70 | 70 | |
71 | - foreach ($document->xpath('//typeHandler') as $handler) { |
|
71 | + foreach($document->xpath('//typeHandler') as $handler) { |
|
72 | 72 | $this->loadTypeHandler($handler); |
73 | 73 | } |
74 | 74 | |
75 | - foreach ($document->xpath('//connection[last()]') as $conn) { |
|
75 | + foreach($document->xpath('//connection[last()]') as $conn) { |
|
76 | 76 | $this->loadDatabaseConnection($conn); |
77 | 77 | } |
78 | 78 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $mapping = new TSqlMapXmlMappingConfiguration($this); |
81 | 81 | $mapping->configure($filename); |
82 | 82 | |
83 | - foreach ($document->xpath('//sqlMap') as $sqlmap) { |
|
83 | + foreach($document->xpath('//sqlMap') as $sqlmap) { |
|
84 | 84 | $this->loadSqlMappingFiles($sqlmap); |
85 | 85 | } |
86 | 86 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | protected function loadGlobalProperty($node) |
96 | 96 | { |
97 | - $this->_properties[(string)$node['name']] = (string)$node['value']; |
|
97 | + $this->_properties[(string) $node['name']] = (string) $node['value']; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | */ |
124 | 124 | protected function loadSqlMappingFiles($node) |
125 | 125 | { |
126 | - if (strlen($resource = (string)$node['resource']) > 0) { |
|
127 | - if (strpos($resource, '${') !== false) { |
|
126 | + if(strlen($resource = (string) $node['resource']) > 0) { |
|
127 | + if(strpos($resource, '${') !== false) { |
|
128 | 128 | $resource = $this->replaceProperties($resource); |
129 | 129 | } |
130 | 130 | |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | protected function resolveResultMapping() |
141 | 141 | { |
142 | 142 | $maps = $this->_manager->getResultMaps(); |
143 | - foreach ($maps as $entry) { |
|
144 | - foreach ($entry->getColumns() as $item) { |
|
143 | + foreach($maps as $entry) { |
|
144 | + foreach($entry->getColumns() as $item) { |
|
145 | 145 | $resultMap = $item->getResultMapping(); |
146 | - if (strlen($resultMap) > 0) { |
|
147 | - if ($maps->contains($resultMap)) { |
|
146 | + if(strlen($resultMap) > 0) { |
|
147 | + if($maps->contains($resultMap)) { |
|
148 | 148 | $item->setNestedResultMap($maps[$resultMap]); |
149 | 149 | } else { |
150 | 150 | throw new TSqlMapConfigurationException( |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | } |
158 | 158 | } |
159 | - if ($entry->getDiscriminator() !== null) { |
|
159 | + if($entry->getDiscriminator() !== null) { |
|
160 | 160 | $entry->getDiscriminator()->initialize($this->_manager); |
161 | 161 | } |
162 | 162 | } |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function attachCacheModels() |
169 | 169 | { |
170 | - foreach ($this->_manager->getMappedStatements() as $mappedStatement) { |
|
171 | - if (strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) { |
|
170 | + foreach($this->_manager->getMappedStatements() as $mappedStatement) { |
|
171 | + if(strlen($model = $mappedStatement->getStatement()->getCacheModel()) > 0) { |
|
172 | 172 | $cache = $this->_manager->getCacheModel($model); |
173 | 173 | $mappedStatement->getStatement()->setCache($cache); |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | */ |
184 | 184 | public function replaceProperties($string) |
185 | 185 | { |
186 | - foreach ($this->_properties as $find => $replace) { |
|
186 | + foreach($this->_properties as $find => $replace) { |
|
187 | 187 | $string = str_replace('${' . $find . '}', $replace, $string); |
188 | 188 | } |
189 | 189 | return $string; |
@@ -34,7 +34,7 @@ |
||
34 | 34 | $matches = []; |
35 | 35 | $mappings = []; |
36 | 36 | preg_match_all(self::PARAMETER_TOKEN_REGEXP, $sqlText, $matches); |
37 | - for ($i = 0, $k = count($matches[1]); $i < $k; $i++) { |
|
37 | + for($i = 0, $k = count($matches[1]); $i < $k; $i++) { |
|
38 | 38 | $mappings[] = $matches[1][$i]; |
39 | 39 | $sqlText = str_replace($matches[0][$i], self::DYNAMIC_TOKEN, $sqlText); |
40 | 40 | } |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getProperty($index) |
103 | 103 | { |
104 | - if (is_string($index)) { |
|
104 | + if(is_string($index)) { |
|
105 | 105 | return $this->_propertyMap->itemAt($index); |
106 | - } elseif (is_int($index)) { |
|
106 | + } elseif(is_int($index)) { |
|
107 | 107 | return $this->_properties->itemAt($index); |
108 | 108 | } else { |
109 | 109 | throw new TSqlMapException('sqlmap_index_must_be_string_or_int', $index); |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | { |
149 | 149 | $value = $this->getObjectValue($parameterValue, $property); |
150 | 150 | |
151 | - if (($handler = $this->createTypeHandler($property, $registry)) !== null) { |
|
151 | + if(($handler = $this->createTypeHandler($property, $registry)) !== null) { |
|
152 | 152 | $value = $handler->getParameter($value); |
153 | 153 | } |
154 | 154 | |
155 | 155 | $value = $this->nullifyDefaultValue($property, $value); |
156 | 156 | |
157 | - if (($type = $property->getType()) !== null) { |
|
157 | + if(($type = $property->getType()) !== null) { |
|
158 | 158 | $value = $registry->convertToType($type, $value); |
159 | 159 | } |
160 | 160 | |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | { |
173 | 173 | $type = $property->getTypeHandler() ? $property->getTypeHandler() : $property->getType(); |
174 | 174 | $handler = $registry->getTypeHandler($type); |
175 | - if ($handler === null && $property->getTypeHandler()) { |
|
175 | + if($handler === null && $property->getTypeHandler()) { |
|
176 | 176 | $handler = Prado::createComponent($type); |
177 | 177 | } |
178 | 178 | return $handler; |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | */ |
209 | 209 | protected function nullifyDefaultValue($property, $value) |
210 | 210 | { |
211 | - if (($nullValue = $property->getNullValue()) !== null) { |
|
212 | - if ($nullValue === $value) { |
|
211 | + if(($nullValue = $property->getNullValue()) !== null) { |
|
212 | + if($nullValue === $value) { |
|
213 | 213 | $value = null; |
214 | 214 | } |
215 | 215 | } |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | */ |
31 | 31 | protected function createObjectFromNode($node) |
32 | 32 | { |
33 | - if (isset($node['class'])) { |
|
34 | - $obj = Prado::createComponent((string)$node['class']); |
|
33 | + if(isset($node['class'])) { |
|
34 | + $obj = Prado::createComponent((string) $node['class']); |
|
35 | 35 | $this->setObjectPropFromNode($obj, $node, ['class']); |
36 | 36 | return $obj; |
37 | 37 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | */ |
52 | 52 | protected function setObjectPropFromNode($obj, $node, $except = []) |
53 | 53 | { |
54 | - foreach ($node->attributes() as $name => $value) { |
|
55 | - if (!in_array($name, $except)) { |
|
56 | - if ($obj->canSetProperty($name)) { |
|
57 | - $obj->{$name} = (string)$value; |
|
54 | + foreach($node->attributes() as $name => $value) { |
|
55 | + if(!in_array($name, $except)) { |
|
56 | + if($obj->canSetProperty($name)) { |
|
57 | + $obj->{$name} = (string) $value; |
|
58 | 58 | } else { |
59 | 59 | throw new TSqlMapConfigurationException( |
60 | 60 | 'sqlmap_invalid_property', |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | { |
78 | 78 | $basedir = dirname($basefile); |
79 | 79 | $file = realpath($basedir . DIRECTORY_SEPARATOR . $resource); |
80 | - if (!is_string($file) || !is_file($file)) { |
|
80 | + if(!is_string($file) || !is_file($file)) { |
|
81 | 81 | $file = realpath($resource); |
82 | 82 | } |
83 | - if (is_string($file) && is_file($file)) { |
|
83 | + if(is_string($file) && is_file($file)) { |
|
84 | 84 | return $file; |
85 | 85 | } else { |
86 | 86 | throw new TSqlMapConfigurationException( |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | */ |
97 | 97 | protected function loadXmlDocument($filename, TSqlMapXmlConfiguration $config) |
98 | 98 | { |
99 | - if (strpos($filename, '${') !== false) { |
|
99 | + if(strpos($filename, '${') !== false) { |
|
100 | 100 | $filename = $config->replaceProperties($filename); |
101 | 101 | } |
102 | - if (!is_file($filename)) { |
|
102 | + if(!is_file($filename)) { |
|
103 | 103 | throw new TSqlMapConfigurationException( |
104 | 104 | 'sqlmap_unable_to_find_config', |
105 | 105 | $filename |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | protected function getElementByIdValue($document, $tag, $value) |
118 | 118 | { |
119 | 119 | //hack to allow upper case and lower case attribute names. |
120 | - foreach (['id','ID','Id', 'iD'] as $id) { |
|
120 | + foreach(['id', 'ID', 'Id', 'iD'] as $id) { |
|
121 | 121 | $xpath = "//{$tag}[@{$id}='{$value}']"; |
122 | - foreach ($document->xpath($xpath) as $node) { |
|
122 | + foreach($document->xpath($xpath) as $node) { |
|
123 | 123 | return $node; |
124 | 124 | } |
125 | 125 | } |