Skip to content

Commit 25d1ed5

Browse files
committed
improved coding style
1 parent 8fca346 commit 25d1ed5

40 files changed

+272
-266
lines changed

src/Bridges/CacheLatte/CacheMacro.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Bridges\CacheLatte;
99

10-
use Nette,
11-
Latte;
10+
use Nette;
11+
use Latte;
1212

1313

1414
/**

src/Caching/Cache.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Caching;
99

10-
use Nette,
11-
Nette\Utils\Callback;
10+
use Nette;
11+
use Nette\Utils\Callback;
1212

1313

1414
/**
@@ -79,7 +79,7 @@ public function getNamespace()
7979
/**
8080
* Returns new nested cache object.
8181
* @param string
82-
* @return Cache
82+
* @return self
8383
*/
8484
public function derive($namespace)
8585
{
@@ -98,7 +98,7 @@ public function load($key, $fallback = NULL)
9898
{
9999
$data = $this->storage->read($this->generateKey($key));
100100
if ($data === NULL && $fallback) {
101-
return $this->save($key, function(& $dependencies) use ($fallback) {
101+
return $this->save($key, function (& $dependencies) use ($fallback) {
102102
return call_user_func_array($fallback, array(& $dependencies));
103103
});
104104
}
@@ -145,8 +145,8 @@ public function save($key, $data, array $dependencies = NULL)
145145
private function completeDependencies($dp, $data)
146146
{
147147
// convert expire into relative amount of seconds
148-
if (isset($dp[Cache::EXPIRATION])) {
149-
$dp[Cache::EXPIRATION] = Nette\Utils\DateTime::from($dp[Cache::EXPIRATION])->format('U') - time();
148+
if (isset($dp[self::EXPIRATION])) {
149+
$dp[self::EXPIRATION] = Nette\Utils\DateTime::from($dp[self::EXPIRATION])->format('U') - time();
150150
}
151151

152152
// convert FILES into CALLBACKS
@@ -214,7 +214,7 @@ public function call($function)
214214
if (is_array($function) && is_object($function[0])) {
215215
$key[0][0] = get_class($function[0]);
216216
}
217-
return $this->load($key, function() use ($function, $key) {
217+
return $this->load($key, function () use ($function, $key) {
218218
return Callback::invokeArgs($function, array_slice($key, 1));
219219
});
220220
}
@@ -229,7 +229,7 @@ public function call($function)
229229
public function wrap($function, array $dependencies = NULL)
230230
{
231231
$cache = $this;
232-
return function() use ($cache, $function, $dependencies) {
232+
return function () use ($cache, $function, $dependencies) {
233233
$key = array($function, func_get_args());
234234
if (is_array($function) && is_object($function[0])) {
235235
$key[0][0] = get_class($function[0]);

src/Caching/Storages/FileJournal.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Caching\Storages;
99

10-
use Nette,
11-
Nette\Caching\Cache;
10+
use Nette;
11+
use Nette\Caching\Cache;
1212

1313

1414
/**
@@ -22,13 +22,13 @@ class FileJournal extends Nette\Object implements IJournal
2222
const FILE = 'btfj.dat';
2323

2424
/** 4 bytes file header magic (btfj) */
25-
const FILE_MAGIC = 0x6274666A;
25+
const FILE_MAGIC = 0x6274666A;
2626

2727
/** 4 bytes index node magic (inde) */
2828
const INDEX_MAGIC = 0x696E6465;
2929

3030
/** 4 bytes data node magic (data) */
31-
const DATA_MAGIC = 0x64617461;
31+
const DATA_MAGIC = 0x64617461;
3232

3333
/** Node size in bytes */
3434
const NODE_SIZE = 4096;
@@ -40,7 +40,7 @@ class FileJournal extends Nette\Object implements IJournal
4040
const HEADER_SIZE = 4096;
4141

4242
/** Size of 32 bit integer in bytes. INT32_SIZE = 32 / 8 :-) */
43-
const INT32_SIZE = 4;
43+
const INT32_SIZE = 4;
4444

4545
const INFO = 'i',
4646
TYPE = 't', // TAGS, PRIORITY or DATA
@@ -92,10 +92,10 @@ class FileJournal extends Nette\Object implements IJournal
9292

9393
/** @var array */
9494
private static $startNode = array(
95-
self::TAGS => 0,
95+
self::TAGS => 0,
9696
self::PRIORITY => 1,
97-
self::ENTRIES => 2,
98-
self::DATA => 3,
97+
self::ENTRIES => 2,
98+
self::DATA => 3,
9999
);
100100

101101

@@ -190,7 +190,7 @@ public function write($key, array $dependencies)
190190
self::INFO => array(
191191
self::LAST_INDEX => ($freeDataNode << self::BITROT),
192192
self::TYPE => self::DATA,
193-
)
193+
),
194194
);
195195
}
196196

@@ -249,7 +249,7 @@ public function clean(array $conditions)
249249
$toDelete = array(
250250
self::TAGS => array(),
251251
self::PRIORITY => array(),
252-
self::ENTRIES => array()
252+
self::ENTRIES => array(),
253253
);
254254

255255
$entries = array();
@@ -297,7 +297,7 @@ private function cleanTags(array $tags, array & $toDelete)
297297

298298
/**
299299
* Cleans entries from journal by priority.
300-
* @param integer
300+
* @param int
301301
* @param array
302302
* @return array of removed items
303303
*/
@@ -560,7 +560,7 @@ private function cleanIndexData($nextNodeId, array $links, & $masterNodeLink)
560560

561561
/**
562562
* Get node from journal.
563-
* @param integer
563+
* @param int
564564
* @return array
565565
*/
566566
private function getNode($id)
@@ -606,7 +606,7 @@ private function getNode($id)
606606

607607
/**
608608
* Save node to cache.
609-
* @param integer
609+
* @param int
610610
* @param array
611611
* @return void
612612
*/
@@ -706,7 +706,7 @@ private function commit()
706706

707707
/**
708708
* Prepare node to journal file structure.
709-
* @param integer
709+
* @param int
710710
* @param array|bool
711711
* @return bool Successfully committed
712712
*/
@@ -750,7 +750,7 @@ private function prepareNode($id, $node)
750750

751751
/**
752752
* Commit node string to journal file.
753-
* @param integer
753+
* @param int
754754
* @param string
755755
* @return void
756756
*/
@@ -788,7 +788,7 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
788788
self::PREV_NODE => -1,
789789
self::END => -1,
790790
self::MAX => -1,
791-
)
791+
),
792792
),
793793
$parentId,
794794
); // Init empty node
@@ -818,8 +818,8 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
818818

819819
/**
820820
* Find complete free node.
821-
* @param integer
822-
* @return array|integer Node ID
821+
* @param int
822+
* @return array|int Node ID
823823
*/
824824
private function findFreeNode($count = 1)
825825
{
@@ -858,8 +858,8 @@ private function findFreeNode($count = 1)
858858

859859
/**
860860
* Find free data node that has $size bytes of free space.
861-
* @param integer size in bytes
862-
* @return integer Node ID
861+
* @param int size in bytes
862+
* @return int Node ID
863863
*/
864864
private function findFreeDataNode($size)
865865
{
@@ -904,7 +904,7 @@ private function findFreeDataNode($size)
904904

905905
/**
906906
* Bisect node or when has only one key, move part to data node.
907-
* @param integer Node ID
907+
* @param int Node ID
908908
* @param array Node
909909
* @return void
910910
*/
@@ -993,7 +993,7 @@ private function bisectNode($id, array $node)
993993
);
994994
$this->saveNode($id, $second);
995995

996-
list(,, $parent) = $this->findIndexNode($nodeInfo[self::TYPE], $halfKey);
996+
list(, , $parent) = $this->findIndexNode($nodeInfo[self::TYPE], $halfKey);
997997
$parentNode = $this->getNode($parent);
998998
if ($parentNode === FALSE) {
999999
if (self::$debug) {
@@ -1021,7 +1021,7 @@ private function headerCommit()
10211021

10221022
/**
10231023
* Remove node from journal file.
1024-
* @param integer
1024+
* @param int
10251025
* @return void
10261026
*/
10271027
private function deleteNode($id)
@@ -1087,7 +1087,7 @@ private function lock()
10871087

10881088

10891089
/**
1090-
* Open btfj.dat file (or create it if not exists) and load metainformation
1090+
* Open btfj.dat file (or create it if not exists) and load metainformation.
10911091
* @throws Nette\InvalidStateException
10921092
*/
10931093
private function prepare()
@@ -1104,7 +1104,7 @@ private function prepare()
11041104
$written = fwrite($init, pack('N2', self::FILE_MAGIC, $this->lastNode));
11051105
fclose($init);
11061106
if ($written !== self::INT32_SIZE * 2) {
1107-
throw new Nette\InvalidStateException("Cannot write journal header.");
1107+
throw new Nette\InvalidStateException('Cannot write journal header.');
11081108
}
11091109
}
11101110
}
@@ -1149,8 +1149,7 @@ private function unlock()
11491149

11501150

11511151
/**
1152-
* @param int $nodeId
1153-
* @param array $nodeData
1152+
* @param int
11541153
* @return int
11551154
* @throws Nette\InvalidStateException
11561155
*/
@@ -1175,7 +1174,7 @@ private function findNextFreeKey($nodeId, array & $nodeData)
11751174

11761175
/**
11771176
* Append $append to $array.
1178-
* This function is much faster then $array = array_merge($array, $append)
1177+
* This function is much faster than $array = array_merge($array, $append)
11791178
* @param array
11801179
* @param array
11811180
* @return void
@@ -1190,7 +1189,7 @@ private function arrayAppend(array & $array, array $append)
11901189

11911190
/**
11921191
* Append $append to $array with preserve keys.
1193-
* This function is much faster then $array = $array + $append
1192+
* This function is much faster than $array = $array + $append
11941193
* @param array
11951194
* @param array
11961195
* @return void
@@ -1201,4 +1200,5 @@ private function arrayAppendKeys(array & $array, array $append)
12011200
$array[$key] = $value;
12021201
}
12031202
}
1203+
12041204
}

src/Caching/Storages/FileStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Caching\Storages;
99

10-
use Nette,
11-
Nette\Caching\Cache;
10+
use Nette;
11+
use Nette\Caching\Cache;
1212

1313

1414
/**

src/Caching/Storages/IJournal.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ interface IJournal
2020

2121
/**
2222
* Writes entry information into the journal.
23-
* @param string $key
24-
* @param array $dependencies
23+
* @param string
24+
* @param array
2525
* @return void
2626
*/
2727
function write($key, array $dependencies);
2828

2929

3030
/**
3131
* Cleans entries from journal.
32-
* @param array $conditions
32+
* @param array
3333
* @return array of removed items or NULL when performing a full cleanup
3434
*/
3535
function clean(array $conditions);

src/Caching/Storages/MemcachedStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Caching\Storages;
99

10-
use Nette,
11-
Nette\Caching\Cache;
10+
use Nette;
11+
use Nette\Caching\Cache;
1212

1313

1414
/**

src/Caching/Storages/SQLiteStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace Nette\Caching\Storages;
99

10-
use Nette,
11-
Nette\Caching\Cache;
10+
use Nette;
11+
use Nette\Caching\Cache;
1212

1313

1414
/**

tests/Caching.Latte/CacheMacro.cache.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Test: {cache ...}
55
*/
66

7-
use Nette\Bridges\CacheLatte\CacheMacro,
8-
Tester\Assert;
7+
use Nette\Bridges\CacheLatte\CacheMacro;
8+
use Tester\Assert;
99

1010

1111
require __DIR__ . '/../bootstrap.php';

tests/Caching/Cache.load.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Test: Nette\Caching\Cache load().
55
*/
66

7-
use Nette\Caching\Cache,
8-
Tester\Assert;
7+
use Nette\Caching\Cache;
8+
use Tester\Assert;
99

1010

1111
require __DIR__ . '/../bootstrap.php';
@@ -17,12 +17,12 @@ require __DIR__ . '/Cache.inc';
1717
$storage = new TestStorage();
1818
$cache = new Cache($storage, 'ns');
1919

20-
$value = $cache->load('key', function() {
20+
$value = $cache->load('key', function () {
2121
return 'value';
2222
});
2323
Assert::equal('value', $value);
2424

25-
$data = $cache->load('key', function() {
25+
$data = $cache->load('key', function () {
2626
return "won't load this value"; // will read from storage
2727
});
2828
Assert::equal('value', $data['data']);
@@ -33,13 +33,13 @@ $dependencies = array(Cache::TAGS => 'tag');
3333
$storage = new TestStorage();
3434
$cache = new Cache($storage, 'ns');
3535

36-
$value = $cache->load('key', function(& $deps) use ($dependencies) {
36+
$value = $cache->load('key', function (& $deps) use ($dependencies) {
3737
$deps = $dependencies;
3838
return 'value';
3939
});
4040
Assert::equal('value', $value);
4141

42-
$data = $cache->load('key', function() {
42+
$data = $cache->load('key', function () {
4343
return "won't load this value"; // will read from storage
4444
});
4545
Assert::equal('value', $data['data']);

0 commit comments

Comments
 (0)