Completed
Push — php-cs-fixer ( b6f93e )
by Fabio
07:29
created
framework/Data/SqlMap/Statements/TCachingStatement.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -97,6 +97,10 @@
 block discarded – undo
97 97
 		return $cacheKey->getHash();
98 98
 	}
99 99
 
100
+	/**
101
+	 * @param integer $skip
102
+	 * @param integer $max
103
+	 */
100 104
 	protected function createCommand($connection, $parameter, $skip=null, $max=null)
101 105
 	{
102 106
 		return $this->_mappedStatement->getCommand()->create($this->getManager(),
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	public function __construct(TMappedStatement $statement)
28 28
 	{
29
-		$this->_mappedStatement = $statement;
29
+		$this->_mappedStatement=$statement;
30 30
 	}
31 31
 
32 32
 	public function getID()
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public function executeQueryForMap($connection, $parameter, $keyProperty, $valueProperty=null, $skip=-1, $max=-1, $delegate=null)
48 48
 	{
49
-		$sql = $this->createCommand($connection, $parameter, $skip, $max);
50
-		$key = $this->getCacheKey([clone($sql), $keyProperty, $valueProperty,$skip, $max]);
51
-		$map = $this->getStatement()->getCache()->get($key);
49
+		$sql=$this->createCommand($connection, $parameter, $skip, $max);
50
+		$key=$this->getCacheKey([clone($sql), $keyProperty, $valueProperty, $skip, $max]);
51
+		$map=$this->getStatement()->getCache()->get($key);
52 52
 		if($map===null)
53 53
 		{
54
-			$map = $this->_mappedStatement->runQueryForMap(
54
+			$map=$this->_mappedStatement->runQueryForMap(
55 55
 				$connection, $parameter, $sql, $keyProperty, $valueProperty, $delegate);
56 56
 			$this->getStatement()->getCache()->set($key, $map);
57 57
 		}
@@ -70,12 +70,12 @@  discard block
 block discarded – undo
70 70
 
71 71
 	public function executeQueryForList($connection, $parameter, $result=null, $skip=-1, $max=-1, $delegate=null)
72 72
 	{
73
-		$sql = $this->createCommand($connection, $parameter, $skip, $max);
74
-		$key = $this->getCacheKey([clone($sql), $parameter, $skip, $max]);
75
-		$list = $this->getStatement()->getCache()->get($key);
73
+		$sql=$this->createCommand($connection, $parameter, $skip, $max);
74
+		$key=$this->getCacheKey([clone($sql), $parameter, $skip, $max]);
75
+		$list=$this->getStatement()->getCache()->get($key);
76 76
 		if($list===null)
77 77
 		{
78
-			$list = $this->_mappedStatement->runQueryForList(
78
+			$list=$this->_mappedStatement->runQueryForList(
79 79
 				$connection, $parameter, $sql, $result, $delegate);
80 80
 			$this->getStatement()->getCache()->set($key, $list);
81 81
 		}
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 
85 85
 	public function executeQueryForObject($connection, $parameter, $result=null)
86 86
 	{
87
-		$sql = $this->createCommand($connection, $parameter);
88
-		$key = $this->getCacheKey([clone($sql), $parameter]);
89
-		$object = $this->getStatement()->getCache()->get($key);
87
+		$sql=$this->createCommand($connection, $parameter);
88
+		$key=$this->getCacheKey([clone($sql), $parameter]);
89
+		$object=$this->getStatement()->getCache()->get($key);
90 90
 		if($object===null)
91 91
 		{
92
-			$object = $this->_mappedStatement->runQueryForObject($connection, $sql, $result);
92
+			$object=$this->_mappedStatement->runQueryForObject($connection, $sql, $result);
93 93
 			$this->getStatement()->getCache()->set($key, $object);
94 94
 		}
95 95
 		return $object;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 	protected function getCacheKey($object)
99 99
 	{
100
-		$cacheKey = new TSqlMapCacheKey($object);
100
+		$cacheKey=new TSqlMapCacheKey($object);
101 101
 		return $cacheKey->getHash();
102 102
 	}
103 103
 
Please login to merge, or discard this patch.
framework/Data/SqlMap/TSqlMapConfig.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -77,6 +77,7 @@
 block discarded – undo
77 77
 
78 78
 	/**
79 79
 	 * Saves the current SqlMap manager to cache.
80
+	 * @param TSqlMapManager $manager
80 81
 	 * @return boolean true if SqlMap manager was cached, false otherwise.
81 82
 	 */
82 83
 	protected function cacheSqlMapManager($manager)
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
 				$manager->configureXml($file);
69 69
 				$this->cacheSqlMapManager($manager);
70 70
 			}
71
-		}
72
-		elseif($this->getConnectionID() !== '') {
71
+		} elseif($this->getConnectionID() !== '') {
73 72
 			$manager->setDbConnection($this->getDbConnection());
74 73
 		}
75 74
 		return $manager;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	private function getCacheKey()
45 45
 	{
46
-		return $this->getID() . $this->getConfigFile();
46
+		return $this->getID().$this->getConfigFile();
47 47
 	}
48 48
 
49 49
 	/**
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function clearCache()
53 53
 	{
54
-		$cache = $this->getApplication()->getCache();
55
-		if($cache !== null) {
54
+		$cache=$this->getApplication()->getCache();
55
+		if($cache!==null) {
56 56
 			$cache->delete($this->getCacheKey());
57 57
 		}
58 58
 	}
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	 * @since 3.1.7
67 67
 	 */
68 68
 	public function getSqlMapManager() {
69
-		if(($manager = $this->loadCachedSqlMapManager())===null)
69
+		if(($manager=$this->loadCachedSqlMapManager())===null)
70 70
 		{
71
-			$manager = new TSqlMapManager($this->getDbConnection());
71
+			$manager=new TSqlMapManager($this->getDbConnection());
72 72
 			if(strlen($file=$this->getConfigFile()) > 0)
73 73
 			{
74 74
 				$manager->configureXml($file);
75 75
 				$this->cacheSqlMapManager($manager);
76 76
 			}
77 77
 		}
78
-		elseif($this->getConnectionID() !== '') {
78
+		elseif($this->getConnectionID()!=='') {
79 79
 			$manager->setDbConnection($this->getDbConnection());
80 80
 		}
81 81
 		return $manager;
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	{
90 90
 		if($this->getEnableCache())
91 91
 		{
92
-			$cache = $this->getApplication()->getCache();
93
-			if($cache !== null) {
94
-				$dependencies = null;
95
-				if($this->getApplication()->getMode() !== TApplicationMode::Performance)
96
-					$dependencies = $manager->getCacheDependencies();
92
+			$cache=$this->getApplication()->getCache();
93
+			if($cache!==null) {
94
+				$dependencies=null;
95
+				if($this->getApplication()->getMode()!==TApplicationMode::Performance)
96
+					$dependencies=$manager->getCacheDependencies();
97 97
 				return $cache->set($this->getCacheKey(), $manager, 0, $dependencies);
98 98
 			}
99 99
 		}
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	{
109 109
 		if($this->getEnableCache())
110 110
 		{
111
-			$cache = $this->getApplication()->getCache();
112
-			if($cache !== null)
111
+			$cache=$this->getApplication()->getCache();
112
+			if($cache!==null)
113 113
 			{
114
-				$manager = $cache->get($this->getCacheKey());
114
+				$manager=$cache->get($this->getCacheKey());
115 115
 				if($manager instanceof TSqlMapManager)
116 116
 					return $manager;
117 117
 			}
@@ -138,11 +138,11 @@  discard block
 block discarded – undo
138 138
 			$this->_configFile=$value;
139 139
 		else
140 140
 		{
141
-			$file = Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT);
142
-			if($file === null || !is_file($file))
141
+			$file=Prado::getPathOfNamespace($value, self::CONFIG_FILE_EXT);
142
+			if($file===null || !is_file($file))
143 143
 				throw new TConfigurationException('sqlmap_configfile_invalid', $value);
144 144
 			else
145
-				$this->_configFile = $file;
145
+				$this->_configFile=$file;
146 146
 		}
147 147
 	}
148 148
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function setEnableCache($value)
154 154
 	{
155
-		$this->_enableCache = TPropertyValue::ensureBoolean($value);
155
+		$this->_enableCache=TPropertyValue::ensureBoolean($value);
156 156
 	}
157 157
 
158 158
 	/**
Please login to merge, or discard this patch.
framework/Data/TDataSourceConfig.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -149,6 +149,7 @@
 block discarded – undo
149 149
 	/**
150 150
 	 * Finds the database connection instance from the Application modules.
151 151
 	 * @param string Database connection module ID.
152
+	 * @param string $id
152 153
 	 * @return TDbConnection database connection.
153 154
 	 * @throws TConfigurationException when module is not of TDbConnection or TDataSourceConfig.
154 155
 	 */
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 		if($this->_conn===null)
111 111
 		{
112 112
 			if($this->_connID!=='')
113
-				$this->_conn = $this->findConnectionByID($this->getConnectionID());
113
+				$this->_conn=$this->findConnectionByID($this->getConnectionID());
114 114
 			else
115
-				$this->_conn = Prado::createComponent($this->getConnectionClass());
115
+				$this->_conn=Prado::createComponent($this->getConnectionClass());
116 116
 		}
117 117
 		return $this->_conn;
118 118
 	}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	protected function findConnectionByID($id)
160 160
 	{
161
-		$conn = $this->getApplication()->getModule($id);
161
+		$conn=$this->getApplication()->getModule($id);
162 162
 		if($conn instanceof TDbConnection)
163 163
 			return $conn;
164 164
 		elseif($conn instanceof TDataSourceConfig)
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@
 block discarded – undo
68 68
 				foreach($xml['database'] as $name=>$value)
69 69
 					$db->setSubProperty($name, $value);
70 70
 			}
71
-		}
72
-		else
71
+		} else
73 72
 		{
74 73
 			if($prop=$xml->getElementByTagName('database'))
75 74
 			{
Please login to merge, or discard this patch.
framework/Data/TDbConnection.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -157,6 +157,7 @@  discard block
 block discarded – undo
157 157
 	/**
158 158
 	 * Open or close the DB connection.
159 159
 	 * @param boolean whether to open or close DB connection
160
+	 * @param boolean $value
160 161
 	 * @throws TDbException if connection fails
161 162
 	 */
162 163
 	public function setActive($value)
@@ -241,6 +242,7 @@  discard block
 block discarded – undo
241 242
 
242 243
 	/**
243 244
 	 * @param string The Data Source Name, or DSN, contains the information required to connect to the database.
245
+	 * @param string $value
244 246
 	 * @see http://www.php.net/manual/en/function.PDO-construct.php
245 247
 	 */
246 248
 	public function setConnectionString($value)
@@ -258,6 +260,7 @@  discard block
 block discarded – undo
258 260
 
259 261
 	/**
260 262
 	 * @param string the username for establishing DB connection
263
+	 * @param string $value
261 264
 	 */
262 265
 	public function setUsername($value)
263 266
 	{
@@ -274,6 +277,7 @@  discard block
 block discarded – undo
274 277
 
275 278
 	/**
276 279
 	 * @param string the password for establishing DB connection
280
+	 * @param string $value
277 281
 	 */
278 282
 	public function setPassword($value)
279 283
 	{
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @since 3.1.7
94 94
 	 */
95
-	const DEFAULT_TRANSACTION_CLASS = 'System.Data.TDbTransaction';
95
+	const DEFAULT_TRANSACTION_CLASS='System.Data.TDbTransaction';
96 96
 
97 97
 	private $_dsn='';
98 98
 	private $_username='';
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function __sleep()
142 142
 	{
143 143
 //		$this->close(); - DO NOT CLOSE the current connection as serializing doesn't neccessarily mean we don't this connection anymore in the current session
144
-		return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo","\0Prado\Data\TDbConnection\0_active"]);
144
+		return array_diff(parent::__sleep(), ["\0Prado\Data\TDbConnection\0_pdo", "\0Prado\Data\TDbConnection\0_active"]);
145 145
 	}
146 146
 
147 147
 	/**
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			try
190 190
 			{
191
-				$this->_pdo=new PDO($this->getConnectionString(),$this->getUsername(),
191
+				$this->_pdo=new PDO($this->getConnectionString(), $this->getUsername(),
192 192
 									$this->getPassword(), $this->_attributes);
193 193
 				// This attribute is only useful for PDO::MySql driver.
194 194
 				// Ignore the warning if a driver doesn't understand this.
@@ -221,16 +221,16 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	protected function setConnectionCharset()
223 223
 	{
224
-		if ($this->_charset === '' || $this->_active === false)
224
+		if($this->_charset==='' || $this->_active===false)
225 225
 			return;
226
-		switch ($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME))
226
+		switch($this->_pdo->getAttribute(PDO::ATTR_DRIVER_NAME))
227 227
 		{
228 228
 			case 'mysql':
229 229
 			case 'sqlite':
230
-				$stmt = $this->_pdo->prepare('SET NAMES ?');
230
+				$stmt=$this->_pdo->prepare('SET NAMES ?');
231 231
 			break;
232 232
 			case 'pgsql':
233
-				$stmt = $this->_pdo->prepare('SET client_encoding TO ?');
233
+				$stmt=$this->_pdo->prepare('SET client_encoding TO ?');
234 234
 			break;
235 235
 			default:
236 236
 				throw new TDbException('dbconnection_unsupported_driver_charset', $driver);
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	/**
291 291
 	 * @return string the charset used for database connection. Defaults to emtpy string.
292 292
 	 */
293
-	public function getCharset ()
293
+	public function getCharset()
294 294
 	{
295 295
 		return $this->_charset;
296 296
 	}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	/**
299 299
 	 * @param string the charset used for database connection
300 300
 	 */
301
-	public function setCharset ($value)
301
+	public function setCharset($value)
302 302
 	{
303 303
 		$this->_charset=$value;
304 304
 		$this->setConnectionCharset();
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public function setTransactionClass($value)
373 373
 	{
374
-		$this->_transactionClass = (string)$value;
374
+		$this->_transactionClass=(string) $value;
375 375
 	}
376 376
 
377 377
 	/**
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 	{
440 440
 		if($this->_dbMeta===null)
441 441
 		{
442
-			$this->_dbMeta = TDbMetaData::getInstance($this);
442
+			$this->_dbMeta=TDbMetaData::getInstance($this);
443 443
 		}
444 444
 		return $this->_dbMeta;
445 445
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -196,8 +196,7 @@  discard block
 block discarded – undo
196 196
 				$this->_pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
197 197
 				$this->_active=true;
198 198
 				$this->setConnectionCharset();
199
-			}
200
-			catch(PDOException $e)
199
+			} catch(PDOException $e)
201 200
 			{
202 201
 				throw new TDbException('dbconnection_open_failed', $e->getMessage());
203 202
 			}
@@ -350,8 +349,7 @@  discard block
 block discarded – undo
350 349
 		{
351 350
 			$this->_pdo->beginTransaction();
352 351
 			return $this->_transaction=Prado::createComponent($this->getTransactionClass(), $this);
353
-		}
354
-		else
352
+		} else
355 353
 			throw new TDbException('dbconnection_connection_inactive');
356 354
 	}
357 355
 
Please login to merge, or discard this patch.
framework/Data/TDbTransaction.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -101,6 +101,7 @@
 block discarded – undo
101 101
 
102 102
 	/**
103 103
 	 * @param boolean whether this transaction is active
104
+	 * @param boolean $value
104 105
 	 */
105 106
 	protected function setActive($value)
106 107
 	{
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
 		{
64 64
 			$this->_connection->getPdoInstance()->commit();
65 65
 			$this->_active=false;
66
-		}
67
-		else
66
+		} else
68 67
 			throw new TDbException('dbtransaction_transaction_inactive');
69 68
 	}
70 69
 
@@ -78,8 +77,7 @@  discard block
 block discarded – undo
78 77
 		{
79 78
 			$this->_connection->getPdoInstance()->rollBack();
80 79
 			$this->_active=false;
81
-		}
82
-		else
80
+		} else
83 81
 			throw new TDbException('dbtransaction_transaction_inactive');
84 82
 	}
85 83
 
Please login to merge, or discard this patch.
framework/I18N/core/MessageCache.php 2 patches
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -99,9 +99,7 @@
 block discarded – undo
99 99
 	 * Get the data from the cache.
100 100
 	 * @param string $catalogue The translation section.
101 101
 	 * @param string $culture The translation locale, e.g. "en_AU".
102
-	 * @param string $filename If the source is a file, this file's modified
103
-	 * time is newer than the cache's modified time, no cache hit.
104
-	 * @return mixed Boolean FALSE if no cache hit. Otherwise, translation
102
+	 * @return false|string Boolean FALSE if no cache hit. Otherwise, translation
105 103
 	 * table data for the specified section and locale.
106 104
 	 */
107 105
 	public function get($catalogue, $culture, $lastmodified=0)
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 use Exception;
14 14
 
15
-require_once(dirname(__FILE__) . '/TCache_Lite.php');
15
+require_once(dirname(__FILE__).'/TCache_Lite.php');
16 16
 
17 17
 /**
18 18
  * Cache the translation table into the file system.
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * Caceh life time, default is 1 year.
34 34
 	 */
35
-	protected $lifetime = 3153600;
35
+	protected $lifetime=3153600;
36 36
 
37 37
 
38 38
 	/**
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function __construct($cacheDir)
43 43
 	{
44
-		$cacheDir = $cacheDir . '/';
44
+		$cacheDir=$cacheDir.'/';
45 45
 
46 46
 		if(!is_dir($cacheDir))
47 47
 			throw new Exception(
48
-				'The cache directory ' . $cacheDir . ' does not exists.' .
48
+				'The cache directory '.$cacheDir.' does not exists.'.
49 49
 				'The cache directory must be writable by the server.');
50 50
 		if(!is_writable($cacheDir))
51 51
 			throw new Exception(
52
-				'The cache directory ' . $cacheDir . ' must be writable ' .
52
+				'The cache directory '.$cacheDir.' must be writable '.
53 53
 				'by the server.');
54 54
 
55
-		$options = [
55
+		$options=[
56 56
 			'cacheDir' => $cacheDir,
57 57
 			'lifeTime' => $this->getLifeTime(),
58 58
 			'automaticSerialization' => true
59 59
 		];
60 60
 
61
-		$this->cache = new TCache_Lite($options);
61
+		$this->cache=new TCache_Lite($options);
62 62
 	}
63 63
 
64 64
 	/**
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function setLifeTime($time)
78 78
 	{
79
-		$this->lifetime = (int)$time;
79
+		$this->lifetime=(int) $time;
80 80
 	}
81 81
 
82 82
 	/**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	protected function getID($catalogue, $culture)
88 88
 	{
89
-		return $catalogue . ':' . $culture;
89
+		return $catalogue.':'.$culture;
90 90
 	}
91 91
 
92 92
 	/**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	protected function getGroup($catalogue, $culture)
98 98
 	{
99
-		return $catalogue . ':' . get_class($this);
99
+		return $catalogue.':'.get_class($this);
100 100
 	}
101 101
 
102 102
 	/**
@@ -110,18 +110,18 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function get($catalogue, $culture, $lastmodified=0)
112 112
 	{
113
-		$ID = $this->getID($catalogue, $culture);
114
-		$group = $this->getGroup($catalogue, $culture);
113
+		$ID=$this->getID($catalogue, $culture);
114
+		$group=$this->getGroup($catalogue, $culture);
115 115
 
116 116
 		$this->cache->_setFileName($ID, $group);
117 117
 
118
-		$cache = $this->cache->getCacheFile();
118
+		$cache=$this->cache->getCacheFile();
119 119
 
120
-		if(is_file($cache) == false)
120
+		if(is_file($cache)==false)
121 121
 			return false;
122 122
 
123 123
 
124
-		$lastmodified = (int)$lastmodified;
124
+		$lastmodified=(int) $lastmodified;
125 125
 
126 126
 		if($lastmodified <= 0 || $lastmodified > filemtime($cache))
127 127
 			return false;
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	 */
141 141
 	public function save($data, $catalogue, $culture)
142 142
 	{
143
-		$ID = $this->getID($catalogue, $culture);
144
-		$group = $this->getGroup($catalogue, $culture);
143
+		$ID=$this->getID($catalogue, $culture);
144
+		$group=$this->getGroup($catalogue, $culture);
145 145
 
146 146
 		//echo '## Cache save: "'.$ID.'" : "'.$group.'"';
147 147
 		//echo "<br>\n";
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 */
157 157
 	public function clean($catalogue, $culture)
158 158
 	{
159
-		$group = $this->getGroup($catalogue, $culture);
159
+		$group=$this->getGroup($catalogue, $culture);
160 160
 		$this->cache->clean($group);
161 161
 	}
162 162
 
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_gettext.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -200,6 +200,9 @@  discard block
 block discarded – undo
200 200
 		return false;
201 201
 	}
202 202
 
203
+	/**
204
+	 * @param string $MOFile
205
+	 */
203 206
 	private function getPOFile($MOFile)
204 207
 	{
205 208
 		$filebase = substr($MOFile, 0, strlen($MOFile)-strlen($this->dataExt));
@@ -422,6 +425,9 @@  discard block
 block discarded – undo
422 425
 		return $catalogue;
423 426
 	}
424 427
 
428
+	/**
429
+	 * @param string $catalogue
430
+	 */
425 431
 	protected function createMessageTemplate($catalogue)
426 432
 	{
427 433
 		if($catalogue === null) {
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -260,8 +260,7 @@  discard block
 block discarded – undo
260 260
 				if(!empty($this->cache))
261 261
 					$this->cache->clean($variant, $this->culture);
262 262
 				return true;
263
-			}
264
-			else
263
+			} else
265 264
 				return false;
266 265
 		}
267 266
 		return false;
@@ -304,8 +303,7 @@  discard block
 block discarded – undo
304 303
 					if(!empty($this->cache))
305 304
 						$this->cache->clean($variant, $this->culture);
306 305
 					return true;
307
-				}
308
-				else
306
+				} else
309 307
 					return false;
310 308
 			}
311 309
 		}
@@ -354,8 +352,7 @@  discard block
 block discarded – undo
354 352
 					if(!empty($this->cache))
355 353
 						$this->cache->clean($variant, $this->culture);
356 354
 					return true;
357
-				}
358
-				else
355
+				} else
359 356
 					return false;
360 357
 			}
361 358
 		}
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 /**
26 26
  * Get the Gettext class.
27 27
  */
28
-require_once(dirname(__FILE__) . '/Gettext/TGettext.php');
28
+require_once(dirname(__FILE__).'/Gettext/TGettext.php');
29 29
 
30 30
 /**
31 31
  * MessageSource_gettext class.
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 	 * Message data filename extension.
45 45
 	 * @var string
46 46
 	 */
47
-	protected $dataExt = '.mo';
47
+	protected $dataExt='.mo';
48 48
 
49 49
 	/**
50 50
 	 * PO data filename extension
51 51
 	 * @var string
52 52
 	 */
53
-	protected $poExt = '.po';
53
+	protected $poExt='.po';
54 54
 
55 55
 	/**
56 56
 	 * Separator between culture name and source.
57 57
 	 * @var string
58 58
 	 */
59
-	protected $dataSeparator = '.';
59
+	protected $dataSeparator='.';
60 60
 
61 61
 	public function __construct($source)
62 62
 	{
63
-		$this->source = (string)$source;
63
+		$this->source=(string) $source;
64 64
 	}
65 65
 
66 66
 
@@ -71,17 +71,17 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	protected function &loadData($filename)
73 73
 	{
74
-		$mo = TGettext::factory('MO', $filename);
74
+		$mo=TGettext::factory('MO', $filename);
75 75
 		$mo->load();
76
-		$result = $mo->toArray();
76
+		$result=$mo->toArray();
77 77
 
78
-		$results = [];
78
+		$results=[];
79 79
 		$count=0;
80 80
 		foreach($result['strings'] as $source => $target)
81 81
 		{
82
-			$results[$source][] = $target; //target
83
-			$results[$source][] = $count++; //id
84
-			$results[$source][] = ''; //comments
82
+			$results[$source][]=$target; //target
83
+			$results[$source][]=$count++; //id
84
+			$results[$source][]=''; //comments
85 85
 		}
86 86
 		return $results;
87 87
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	protected function getSource($variant)
106 106
 	{
107
-		return $this->source . '/' . $variant;
107
+		return $this->source.'/'.$variant;
108 108
 	}
109 109
 
110 110
 	/**
@@ -128,24 +128,24 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	protected function getCatalogueList($catalogue)
130 130
 	{
131
-		$variants = explode('_', $this->culture);
132
-		$source = $catalogue . $this->dataExt;
131
+		$variants=explode('_', $this->culture);
132
+		$source=$catalogue.$this->dataExt;
133 133
 
134
-		$catalogues = [$source];
134
+		$catalogues=[$source];
135 135
 
136
-		$variant = null;
136
+		$variant=null;
137 137
 
138
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
138
+		for($i=0, $k=count($variants); $i < $k; ++$i)
139 139
 		{
140 140
 			if(isset($variants[$i]{0}))
141 141
 			{
142
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
143
-				$catalogues[] = $catalogue . $this->dataSeparator .
144
-								$variant . $this->dataExt;
142
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
143
+				$catalogues[]=$catalogue.$this->dataSeparator.
144
+								$variant.$this->dataExt;
145 145
 			}
146 146
 		}
147
-		$byDir = $this->getCatalogueByDir($catalogue);
148
-		$catalogues = array_merge($byDir, array_reverse($catalogues));
147
+		$byDir=$this->getCatalogueByDir($catalogue);
148
+		$catalogues=array_merge($byDir, array_reverse($catalogues));
149 149
 		return $catalogues;
150 150
 	}
151 151
 
@@ -159,17 +159,17 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	private function getCatalogueByDir($catalogue)
161 161
 	{
162
-		$variants = explode('_', $this->culture);
163
-		$catalogues = [];
162
+		$variants=explode('_', $this->culture);
163
+		$catalogues=[];
164 164
 
165
-		$variant = null;
165
+		$variant=null;
166 166
 
167
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
167
+		for($i=0, $k=count($variants); $i < $k; ++$i)
168 168
 		{
169 169
 			if(isset($variants[$i]{0}))
170 170
 			{
171
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
172
-				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
171
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
172
+				$catalogues[]=$variant.'/'.$catalogue.$this->dataExt;
173 173
 			}
174 174
 		}
175 175
 		return array_reverse($catalogues);
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 	 */
186 186
 	private function getVariants($catalogue='messages')
187 187
 	{
188
-		if($catalogue === null) {
189
-			$catalogue = 'messages';
188
+		if($catalogue===null) {
189
+			$catalogue='messages';
190 190
 		}
191 191
 
192 192
 		foreach($this->getCatalogueList($catalogue) as $variant)
193 193
 		{
194
-			$file = $this->getSource($variant);
195
-			$po = $this->getPOFile($file);
194
+			$file=$this->getSource($variant);
195
+			$po=$this->getPOFile($file);
196 196
 			if(is_file($file) || is_file($po))
197 197
 				return [$variant, $file, $po];
198 198
 		}
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 
202 202
 	private function getPOFile($MOFile)
203 203
 	{
204
-		$filebase = substr($MOFile, 0, strlen($MOFile)-strlen($this->dataExt));
205
-		return $filebase . $this->poExt;
204
+		$filebase=substr($MOFile, 0, strlen($MOFile) - strlen($this->dataExt));
205
+		return $filebase.$this->poExt;
206 206
 	}
207 207
 
208 208
 	/**
@@ -214,46 +214,46 @@  discard block
 block discarded – undo
214 214
 	 */
215 215
 	public function save($catalogue='messages')
216 216
 	{
217
-		$messages = $this->untranslated;
217
+		$messages=$this->untranslated;
218 218
 
219 219
 		if(count($messages) <= 0) return false;
220 220
 
221
-		$variants = $this->getVariants($catalogue);
221
+		$variants=$this->getVariants($catalogue);
222 222
 
223 223
 		if($variants)
224
-			list($variant, $MOFile, $POFile) = $variants;
224
+			list($variant, $MOFile, $POFile)=$variants;
225 225
 		else
226
-			list($variant, $MOFile, $POFile) = $this->createMessageTemplate($catalogue);
226
+			list($variant, $MOFile, $POFile)=$this->createMessageTemplate($catalogue);
227 227
 
228
-		if(is_writable($MOFile) == false)
228
+		if(is_writable($MOFile)==false)
229 229
 			throw new TIOException("Unable to save to file {$MOFile}, file must be writable.");
230
-		if(is_writable($POFile) == false)
230
+		if(is_writable($POFile)==false)
231 231
 			throw new TIOException("Unable to save to file {$POFile}, file must be writable.");
232 232
 
233 233
 		//set the strings as untranslated.
234
-		$strings = [];
234
+		$strings=[];
235 235
 		foreach($messages as $message)
236
-			$strings[$message] = '';
236
+			$strings[$message]='';
237 237
 
238 238
 		//load the PO
239
-		$po = TGettext::factory('PO', $POFile);
239
+		$po=TGettext::factory('PO', $POFile);
240 240
 		$po->load();
241
-		$result = $po->toArray();
241
+		$result=$po->toArray();
242 242
 
243
-		$existing = count($result['strings']);
243
+		$existing=count($result['strings']);
244 244
 
245 245
 		//add to strings to the existing message list
246
-		$result['strings'] = array_merge($result['strings'], $strings);
246
+		$result['strings']=array_merge($result['strings'], $strings);
247 247
 
248
-		$new = count($result['strings']);
248
+		$new=count($result['strings']);
249 249
 
250 250
 		if($new > $existing)
251 251
 		{
252 252
 			//change the date 2004-12-25 12:26
253
-			$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
253
+			$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
254 254
 
255 255
 			$po->fromArray($result);
256
-			$mo = $po->toMO();
256
+			$mo=$po->toMO();
257 257
 			if($po->save() && $mo->save($MOFile))
258 258
 			{
259 259
 				if(!empty($this->cache))
@@ -274,30 +274,30 @@  discard block
 block discarded – undo
274 274
 	 */
275 275
 	public function delete($message, $catalogue='messages')
276 276
 	{
277
-		$variants = $this->getVariants($catalogue);
277
+		$variants=$this->getVariants($catalogue);
278 278
 		if($variants)
279
-			list($variant, $MOFile, $POFile) = $variants;
279
+			list($variant, $MOFile, $POFile)=$variants;
280 280
 		else
281 281
 			return false;
282 282
 
283
-		if(is_writable($MOFile) == false)
283
+		if(is_writable($MOFile)==false)
284 284
 			throw new TIOException("Unable to modify file {$MOFile}, file must be writable.");
285
-		if(is_writable($POFile) == false)
285
+		if(is_writable($POFile)==false)
286 286
 			throw new TIOException("Unable to modify file {$POFile}, file must be writable.");
287 287
 
288
-		$po = TGettext::factory('PO', $POFile);
288
+		$po=TGettext::factory('PO', $POFile);
289 289
 		$po->load();
290
-		$result = $po->toArray();
290
+		$result=$po->toArray();
291 291
 
292 292
 		foreach($result['strings'] as $string => $value)
293 293
 		{
294
-			if($string == $message)
294
+			if($string==$message)
295 295
 			{
296
-				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
296
+				$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
297 297
 				unset($result['strings'][$string]);
298 298
 
299 299
 				$po->fromArray($result);
300
-				$mo = $po->toMO();
300
+				$mo=$po->toMO();
301 301
 				if($po->save() && $mo->save($MOFile))
302 302
 				{
303 303
 					if(!empty($this->cache))
@@ -322,31 +322,31 @@  discard block
 block discarded – undo
322 322
 	 */
323 323
 	public function update($text, $target, $comments, $catalogue='messages')
324 324
 	{
325
-		$variants = $this->getVariants($catalogue);
325
+		$variants=$this->getVariants($catalogue);
326 326
 		if($variants)
327
-			list($variant, $MOFile, $POFile) = $variants;
327
+			list($variant, $MOFile, $POFile)=$variants;
328 328
 		else
329 329
 			return false;
330 330
 
331
-		if(is_writable($MOFile) == false)
331
+		if(is_writable($MOFile)==false)
332 332
 			throw new TIOException("Unable to update file {$MOFile}, file must be writable.");
333
-		if(is_writable($POFile) == false)
333
+		if(is_writable($POFile)==false)
334 334
 			throw new TIOException("Unable to update file {$POFile}, file must be writable.");
335 335
 
336 336
 
337
-		$po = TGettext::factory('PO', $POFile);
337
+		$po=TGettext::factory('PO', $POFile);
338 338
 		$po->load();
339
-		$result = $po->toArray();
339
+		$result=$po->toArray();
340 340
 
341 341
 		foreach($result['strings'] as $string => $value)
342 342
 		{
343
-			if($string == $text)
343
+			if($string==$text)
344 344
 			{
345
-				$result['strings'][$string] = $target;
346
-				$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
345
+				$result['strings'][$string]=$target;
346
+				$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
347 347
 
348 348
 				$po->fromArray($result);
349
-				$mo = $po->toMO();
349
+				$mo=$po->toMO();
350 350
 
351 351
 				if($po->save() && $mo->save($MOFile))
352 352
 				{
@@ -380,40 +380,40 @@  discard block
 block discarded – undo
380 380
 	 */
381 381
 	protected function getCatalogues($dir=null, $variant=null)
382 382
 	{
383
-		$dir = $dir?$dir:$this->source;
384
-		$files = scandir($dir);
383
+		$dir=$dir ? $dir : $this->source;
384
+		$files=scandir($dir);
385 385
 
386
-		$catalogue = [];
386
+		$catalogue=[];
387 387
 
388 388
 		foreach($files as $file)
389 389
 		{
390
-			if(is_dir($dir . '/' . $file)
390
+			if(is_dir($dir.'/'.$file)
391 391
 				&& preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file))
392 392
 			{
393 393
 
394
-				$catalogue = array_merge($catalogue,
395
-								$this->getCatalogues($dir . '/' . $file, $file));
394
+				$catalogue=array_merge($catalogue,
395
+								$this->getCatalogues($dir.'/'.$file, $file));
396 396
 			}
397 397
 
398
-			$pos = strpos($file, $this->dataExt);
398
+			$pos=strpos($file, $this->dataExt);
399 399
 
400
-			if($pos >0
401
-				&& substr($file, -1*strlen($this->dataExt)) == $this->dataExt)
400
+			if($pos > 0
401
+				&& substr($file, -1 * strlen($this->dataExt))==$this->dataExt)
402 402
 			{
403
-				$name = substr($file, 0, $pos);
404
-				$dot = strrpos($name, $this->dataSeparator);
405
-				$culture = $variant;
406
-				$cat = $name;
403
+				$name=substr($file, 0, $pos);
404
+				$dot=strrpos($name, $this->dataSeparator);
405
+				$culture=$variant;
406
+				$cat=$name;
407 407
 				if(is_int($dot))
408 408
 				{
409
-					$culture = substr($name, $dot+1, strlen($name));
410
-					$cat = substr($name, 0, $dot);
409
+					$culture=substr($name, $dot + 1, strlen($name));
410
+					$cat=substr($name, 0, $dot);
411 411
 				}
412
-				$details[0] = $cat;
413
-				$details[1] = $culture;
412
+				$details[0]=$cat;
413
+				$details[1]=$culture;
414 414
 
415 415
 
416
-				$catalogue[] = $details;
416
+				$catalogue[]=$details;
417 417
 			}
418 418
 		}
419 419
 		sort($catalogue);
@@ -423,15 +423,15 @@  discard block
 block discarded – undo
423 423
 
424 424
 	protected function createMessageTemplate($catalogue)
425 425
 	{
426
-		if($catalogue === null) {
427
-			$catalogue = 'messages';
426
+		if($catalogue===null) {
427
+			$catalogue='messages';
428 428
 		}
429
-		$variants = $this->getCatalogueList($catalogue);
430
-		$variant = array_shift($variants);
431
-		$mo_file = $this->getSource($variant);
432
-		$po_file = $this->getPOFile($mo_file);
429
+		$variants=$this->getCatalogueList($catalogue);
430
+		$variant=array_shift($variants);
431
+		$mo_file=$this->getSource($variant);
432
+		$po_file=$this->getPOFile($mo_file);
433 433
 
434
-		$dir = dirname($mo_file);
434
+		$dir=dirname($mo_file);
435 435
 		if(!is_dir($dir))
436 436
 		{
437 437
 			@mkdir($dir);
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 		if(!is_dir($dir))
441 441
 			throw new TException("Unable to create directory $dir");
442 442
 
443
-		$po = TGettext::factory('PO', $po_file);
444
-		$result['meta']['PO-Revision-Date'] = @date('Y-m-d H:i:s');
445
-		$result['strings'] = [];
443
+		$po=TGettext::factory('PO', $po_file);
444
+		$result['meta']['PO-Revision-Date']=@date('Y-m-d H:i:s');
445
+		$result['strings']=[];
446 446
 
447 447
 		$po->fromArray($result);
448
-		$mo = $po->toMO();
448
+		$mo=$po->toMO();
449 449
 		if($po->save() && $mo->save($mo_file))
450 450
 			return [$variant, $mo_file, $po_file];
451 451
 		else
Please login to merge, or discard this patch.
framework/I18N/core/MessageSource_XLIFF.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -486,6 +486,9 @@
 block discarded – undo
486 486
 		return false;
487 487
 	}
488 488
 
489
+	/**
490
+	 * @param string $catalogue
491
+	 */
489 492
 	protected function createMessageTemplate($catalogue)
490 493
 	{
491 494
 		if($catalogue === null) {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,6 @@
 block discarded – undo
19 19
 namespace Prado\I18N\core;
20 20
 
21 21
 use DOMDocument;
22
-use DOMXPath;
23 22
 use Prado\Exceptions\TException;
24 23
 use Prado\Exceptions\TIOException;
25 24
 
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 	 * Message data filename extension.
44 44
 	 * @var string
45 45
 	 */
46
-	protected $dataExt = '.xml';
46
+	protected $dataExt='.xml';
47 47
 
48 48
 	/**
49 49
 	 * Separator between culture name and source.
50 50
 	 * @var string
51 51
 	 */
52
-	protected $dataSeparator = '.';
52
+	protected $dataSeparator='.';
53 53
 
54 54
 	/**
55 55
 	 * Constructor.
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function __construct($source)
60 60
 	{
61
-		$this->source = (string)$source;
61
+		$this->source=(string) $source;
62 62
 	}
63 63
 
64 64
 	/**
@@ -69,20 +69,20 @@  discard block
 block discarded – undo
69 69
 	protected function &loadData($filename)
70 70
 	{
71 71
 		//load it.
72
-		if(false === ($XML = simplexml_load_file($filename))) {
72
+		if(false===($XML=simplexml_load_file($filename))) {
73 73
 			return false;
74 74
 		}
75 75
 
76
-		$translationUnit = $XML->xpath('//trans-unit');
76
+		$translationUnit=$XML->xpath('//trans-unit');
77 77
 
78
-		$translations = [];
78
+		$translations=[];
79 79
 
80 80
 		foreach($translationUnit as $unit)
81 81
 		{
82
-			$source = (string)$unit->source;
83
-			$translations[$source][] = (string)$unit->target;
84
-			$translations[$source][] = (string)$unit['id'];
85
-			$translations[$source][] = (string)$unit->note;
82
+			$source=(string) $unit->source;
83
+			$translations[$source][]=(string) $unit->target;
84
+			$translations[$source][]=(string) $unit['id'];
85
+			$translations[$source][]=(string) $unit->note;
86 86
 		}
87 87
 
88 88
 		return $translations;
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	protected function getSource($variant)
109 109
 	{
110
-		return $this->source . '/' . $variant;
110
+		return $this->source.'/'.$variant;
111 111
 	}
112 112
 
113 113
 	/**
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	protected function getCatalogueList($catalogue)
129 129
 	{
130
-		$variants = explode('_', $this->culture);
131
-		$source = $catalogue . $this->dataExt;
132
-		$catalogues = [$source];
133
-		$variant = null;
130
+		$variants=explode('_', $this->culture);
131
+		$source=$catalogue.$this->dataExt;
132
+		$catalogues=[$source];
133
+		$variant=null;
134 134
 
135
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
135
+		for($i=0, $k=count($variants); $i < $k; ++$i)
136 136
 		{
137 137
 			if(isset($variants[$i]{0}))
138 138
 			{
139
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
140
-				$catalogues[] = $catalogue . $this->dataSeparator . $variant . $this->dataExt;
139
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
140
+				$catalogues[]=$catalogue.$this->dataSeparator.$variant.$this->dataExt;
141 141
 			}
142 142
 		}
143 143
 
144
-		$byDir = $this->getCatalogueByDir($catalogue);
145
-		$catalogues = array_merge($byDir, array_reverse($catalogues));
146
-		$files = [];
144
+		$byDir=$this->getCatalogueByDir($catalogue);
145
+		$catalogues=array_merge($byDir, array_reverse($catalogues));
146
+		$files=[];
147 147
 
148 148
 		foreach($catalogues as $file)
149 149
 		{
150
-			$files[] = $file;
151
-			$files[] = preg_replace('/\.xml$/', '.xlf', $file);
150
+			$files[]=$file;
151
+			$files[]=preg_replace('/\.xml$/', '.xlf', $file);
152 152
 		}
153 153
 
154 154
 		return $files;
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	private function getCatalogueByDir($catalogue)
165 165
 	{
166
-		$variants = explode('_', $this->culture);
167
-		$catalogues = [];
168
-		$variant = null;
166
+		$variants=explode('_', $this->culture);
167
+		$catalogues=[];
168
+		$variant=null;
169 169
 
170
-		for($i = 0, $k = count($variants); $i < $k; ++$i)
170
+		for($i=0, $k=count($variants); $i < $k; ++$i)
171 171
 		{
172 172
 			if(isset($variants[$i]{0}))
173 173
 			{
174
-				$variant .= ($variant)?'_' . $variants[$i]:$variants[$i];
175
-				$catalogues[] = $variant . '/' . $catalogue . $this->dataExt;
174
+				$variant.=($variant) ? '_'.$variants[$i] : $variants[$i];
175
+				$catalogues[]=$variant.'/'.$catalogue.$this->dataExt;
176 176
 			}
177 177
 		}
178 178
 
@@ -198,36 +198,36 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	protected function getCatalogues($dir=null, $variant=null)
200 200
 	{
201
-		$dir = $dir?$dir:$this->source;
202
-		$files = scandir($dir);
203
-		$catalogue = [];
201
+		$dir=$dir ? $dir : $this->source;
202
+		$files=scandir($dir);
203
+		$catalogue=[];
204 204
 
205 205
 		foreach($files as $file)
206 206
 		{
207
-			if(is_dir($dir . '/' . $file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
208
-				$catalogue = array_merge(
207
+			if(is_dir($dir.'/'.$file) && preg_match('/^[a-z]{2}(_[A-Z]{2,3})?$/', $file)) {
208
+				$catalogue=array_merge(
209 209
 					$catalogue,
210
-					$this->getCatalogues($dir . '/' . $file, $file)
210
+					$this->getCatalogues($dir.'/'.$file, $file)
211 211
 				);
212 212
 			}
213 213
 
214
-			$pos = strpos($file, $this->dataExt);
215
-			if($pos >0 && substr($file, -1*strlen($this->dataExt)) == $this->dataExt)
214
+			$pos=strpos($file, $this->dataExt);
215
+			if($pos > 0 && substr($file, -1 * strlen($this->dataExt))==$this->dataExt)
216 216
 			{
217
-				$name = substr($file, 0, $pos);
218
-				$dot = strrpos($name, $this->dataSeparator);
219
-				$culture = $variant;
220
-				$cat = $name;
217
+				$name=substr($file, 0, $pos);
218
+				$dot=strrpos($name, $this->dataSeparator);
219
+				$culture=$variant;
220
+				$cat=$name;
221 221
 
222 222
 				if(is_int($dot))
223 223
 				{
224
-					$culture = substr($name, $dot+1, strlen($name));
225
-					$cat = substr($name, 0, $dot);
224
+					$culture=substr($name, $dot + 1, strlen($name));
225
+					$cat=substr($name, 0, $dot);
226 226
 				}
227 227
 
228
-				$details[0] = $cat;
229
-				$details[1] = $culture;
230
-				$catalogue[] = $details;
228
+				$details[0]=$cat;
229
+				$details[1]=$culture;
230
+				$catalogue[]=$details;
231 231
 			}
232 232
 		}
233 233
 		sort($catalogue);
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	private function getVariants($catalogue='messages')
246 246
 	{
247
-		if($catalogue === null) {
248
-			$catalogue = 'messages';
247
+		if($catalogue===null) {
248
+			$catalogue='messages';
249 249
 		}
250 250
 
251 251
 		foreach($this->getCatalogueList($catalogue) as $variant)
252 252
 		{
253
-			$file = $this->getSource($variant);
253
+			$file=$this->getSource($variant);
254 254
 			if(is_file($file)) {
255 255
 				return [$variant, $file];
256 256
 			}
@@ -267,48 +267,48 @@  discard block
 block discarded – undo
267 267
 	 */
268 268
 	public function save($catalogue='messages')
269 269
 	{
270
-		$messages = $this->untranslated;
270
+		$messages=$this->untranslated;
271 271
 		if(count($messages) <= 0) {
272 272
 			return false;
273 273
 		}
274 274
 
275
-		$variants = $this->getVariants($catalogue);
275
+		$variants=$this->getVariants($catalogue);
276 276
 
277 277
 		if($variants) {
278
-			list($variant, $filename) = $variants;
278
+			list($variant, $filename)=$variants;
279 279
 		} else {
280
-			list($variant, $filename) = $this->createMessageTemplate($catalogue);
280
+			list($variant, $filename)=$this->createMessageTemplate($catalogue);
281 281
 		}
282 282
 
283
-		if(is_writable($filename) == false) {
283
+		if(is_writable($filename)==false) {
284 284
 			throw new TIOException("Unable to save to file {$filename}, file must be writable.");
285 285
 		}
286 286
 
287 287
 		//create a new dom, import the existing xml
288
-		$dom = new DOMDocument();
288
+		$dom=new DOMDocument();
289 289
 		$dom->load($filename);
290 290
 
291 291
 		//find the body element
292
-		$xpath = new DomXPath($dom);
293
-		$body = $xpath->query('//body')->item(0);
292
+		$xpath=new DomXPath($dom);
293
+		$body=$xpath->query('//body')->item(0);
294 294
 
295
-		$lastNodes = $xpath->query('//trans-unit[last()]');
295
+		$lastNodes=$xpath->query('//trans-unit[last()]');
296 296
 		if(($last=$lastNodes->item(0))!==null) {
297
-			$count = (int)$last->getAttribute('id');
297
+			$count=(int) $last->getAttribute('id');
298 298
 		} else {
299
-			$count = 0;
299
+			$count=0;
300 300
 		}
301 301
 
302 302
 		//for each message add it to the XML file using DOM
303 303
 		foreach($messages as $message)
304 304
 		{
305
-			$unit = $dom->createElement('trans-unit');
305
+			$unit=$dom->createElement('trans-unit');
306 306
 			$unit->setAttribute('id', ++$count);
307 307
 
308
-			$source = $dom->createElement('source');
308
+			$source=$dom->createElement('source');
309 309
 			$source->appendChild($dom->createCDATASection($message));
310 310
 
311
-			$target = $dom->createElement('target');
311
+			$target=$dom->createElement('target');
312 312
 			$target->appendChild($dom->createCDATASection(''));
313 313
 
314 314
 			$unit->appendChild($dom->createTextNode("\n"));
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 
325 325
 
326
-		$fileNode = $xpath->query('//file')->item(0);
326
+		$fileNode=$xpath->query('//file')->item(0);
327 327
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
328 328
 
329 329
 		//save it and clear the cache for this variant
@@ -345,56 +345,56 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function update($text, $target, $comments, $catalogue='messages')
347 347
 	{
348
-		$variants = $this->getVariants($catalogue);
348
+		$variants=$this->getVariants($catalogue);
349 349
 
350 350
 		if($variants) {
351
-			list($variant, $filename) = $variants;
351
+			list($variant, $filename)=$variants;
352 352
 		} else {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		if(is_writable($filename) == false) {
356
+		if(is_writable($filename)==false) {
357 357
 			throw new TIOException("Unable to update file {$filename}, file must be writable.");
358 358
 		}
359 359
 
360 360
 		//create a new dom, import the existing xml
361
-		$dom = DOMDocument::load($filename);
361
+		$dom=DOMDocument::load($filename);
362 362
 
363 363
 		//find the body element
364
-		$xpath = new DomXPath($dom);
365
-		$units = $xpath->query('//trans-unit');
364
+		$xpath=new DomXPath($dom);
365
+		$units=$xpath->query('//trans-unit');
366 366
 
367 367
 		//for each of the existin units
368 368
 		foreach($units as $unit)
369 369
 		{
370
-			$found = false;
371
-			$targetted = false;
372
-			$commented = false;
370
+			$found=false;
371
+			$targetted=false;
372
+			$commented=false;
373 373
 
374 374
 			//in each unit, need to find the source, target and comment nodes
375 375
 			//it will assume that the source is before the target.
376 376
 			foreach($unit->childNodes as $node)
377 377
 			{
378 378
 				//source node
379
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $text) {
380
-					$found = true;
379
+				if($node->nodeName=='source' && $node->firstChild->wholeText==$text) {
380
+					$found=true;
381 381
 				}
382 382
 
383 383
 				//found source, get the target and notes
384 384
 				if($found)
385 385
 				{
386 386
 					//set the new translated string
387
-					if($node->nodeName == 'target')
387
+					if($node->nodeName=='target')
388 388
 					{
389
-						$node->nodeValue = $target;
390
-						$targetted = true;
389
+						$node->nodeValue=$target;
390
+						$targetted=true;
391 391
 					}
392 392
 
393 393
 					//set the notes
394
-					if(!empty($comments) && $node->nodeName == 'note')
394
+					if(!empty($comments) && $node->nodeName=='note')
395 395
 					{
396
-						$node->nodeValue = $comments;
397
-						$commented = true;
396
+						$node->nodeValue=$comments;
397
+						$commented=true;
398 398
 					}
399 399
 				}
400 400
 			}
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
 			}
416 416
 		}
417 417
 
418
-		$fileNode = $xpath->query('//file')->item(0);
418
+		$fileNode=$xpath->query('//file')->item(0);
419 419
 		$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
420 420
 
421
-		if($dom->save($filename) >0)
421
+		if($dom->save($filename) > 0)
422 422
 		{
423 423
 			if(!empty($this->cache)) {
424 424
 				$this->cache->clean($variant, $this->culture);
@@ -438,23 +438,23 @@  discard block
 block discarded – undo
438 438
 	 */
439 439
 	public function delete($message, $catalogue='messages')
440 440
 	{
441
-		$variants = $this->getVariants($catalogue);
441
+		$variants=$this->getVariants($catalogue);
442 442
 		if($variants) {
443
-			list($variant, $filename) = $variants;
443
+			list($variant, $filename)=$variants;
444 444
 		} else {
445 445
 			return false;
446 446
 		}
447 447
 
448
-		if(is_writable($filename) == false) {
448
+		if(is_writable($filename)==false) {
449 449
 			throw new TIOException("Unable to modify file {$filename}, file must be writable.");
450 450
 		}
451 451
 
452 452
 		//create a new dom, import the existing xml
453
-		$dom = DOMDocument::load($filename);
453
+		$dom=DOMDocument::load($filename);
454 454
 
455 455
 		//find the body element
456
-		$xpath = new DomXPath($dom);
457
-		$units = $xpath->query('//trans-unit');
456
+		$xpath=new DomXPath($dom);
457
+		$units=$xpath->query('//trans-unit');
458 458
 
459 459
 		//for each of the existin units
460 460
 		foreach($units as $unit)
@@ -464,14 +464,14 @@  discard block
 block discarded – undo
464 464
 			foreach($unit->childNodes as $node)
465 465
 			{
466 466
 				//source node
467
-				if($node->nodeName == 'source' && $node->firstChild->wholeText == $message)
467
+				if($node->nodeName=='source' && $node->firstChild->wholeText==$message)
468 468
 				{
469 469
 					//we found it, remove and save the xml file.
470 470
 					$unit->parentNode->removeChild($unit);
471
-					$fileNode = $xpath->query('//file')->item(0);
471
+					$fileNode=$xpath->query('//file')->item(0);
472 472
 					$fileNode->setAttribute('date', @date('Y-m-d\TH:i:s\Z'));
473 473
 
474
-					if(false !== $dom->save($filename)) {
474
+					if(false!==$dom->save($filename)) {
475 475
 						if(!empty($this->cache)) {
476 476
 							$this->cache->clean($variant, $this->culture);
477 477
 						}
@@ -488,14 +488,14 @@  discard block
 block discarded – undo
488 488
 
489 489
 	protected function createMessageTemplate($catalogue)
490 490
 	{
491
-		if($catalogue === null) {
492
-			$catalogue = 'messages';
491
+		if($catalogue===null) {
492
+			$catalogue='messages';
493 493
 		}
494 494
 		
495
-		$variants = $this->getCatalogueList($catalogue);
496
-		$variant = array_shift($variants);
497
-		$file = $this->getSource($variant);
498
-		$dir = dirname($file);
495
+		$variants=$this->getCatalogueList($catalogue);
496
+		$variant=array_shift($variants);
497
+		$file=$this->getSource($variant);
498
+		$dir=dirname($file);
499 499
 
500 500
 		if(!is_dir($dir)) {
501 501
 			@mkdir($dir);
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 
515 515
 	protected function getTemplate($catalogue)
516 516
 	{
517
-		$date = @date('c');
518
-		$xml = <<<EOD
517
+		$date=@date('c');
518
+		$xml=<<<EOD
519 519
 <?xml version="1.0" encoding="UTF-8"?>
520 520
 <xliff version="1.0">
521 521
  <file source-language="EN" target-language="{$this->culture}" datatype="plaintext" original="$catalogue" date="$date" product-name="$catalogue">
Please login to merge, or discard this patch.
framework/IO/TTextWriter.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -38,6 +38,7 @@
 block discarded – undo
38 38
 	/**
39 39
 	 * Writes a string.
40 40
 	 * @param string string to be written
41
+	 * @param string $str
41 42
 	 */
42 43
 	public function write($str)
43 44
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
53 53
 	 */
54 54
 	public function writeLine($str='')
55 55
 	{
56
-		$this->write($str . "\n");
56
+		$this->write($str."\n");
57 57
 	}
58 58
 }
59 59
 
Please login to merge, or discard this patch.