@@ -76,27 +76,27 @@ class FileJournal extends Nette\Object implements IJournal
76
76
private $ processIdentifier ;
77
77
78
78
/** @var array Cache and uncommitted but changed nodes */
79
- private $ nodeCache = array () ;
79
+ private $ nodeCache = [] ;
80
80
81
81
/** @var array */
82
- private $ nodeChanged = array () ;
82
+ private $ nodeChanged = [] ;
83
83
84
84
/** @var array */
85
- private $ toCommit = array () ;
85
+ private $ toCommit = [] ;
86
86
87
87
/** @var array */
88
- private $ deletedLinks = array () ;
88
+ private $ deletedLinks = [] ;
89
89
90
90
/** @var array Free space in data nodes */
91
- private $ dataNodeFreeSpace = array () ;
91
+ private $ dataNodeFreeSpace = [] ;
92
92
93
93
/** @var array */
94
- private static $ startNode = array (
94
+ private static $ startNode = [
95
95
self ::TAGS => 0 ,
96
96
self ::PRIORITY => 1 ,
97
97
self ::ENTRIES => 2 ,
98
98
self ::DATA => 3 ,
99
- ) ;
99
+ ] ;
100
100
101
101
102
102
/**
@@ -151,7 +151,7 @@ public function write($key, array $dependencies)
151
151
}
152
152
$ exists = TRUE ;
153
153
} else { // Already exists, but with other tags or priority
154
- $ toDelete = array () ;
154
+ $ toDelete = [] ;
155
155
foreach ($ dataNode [$ link ][self ::TAGS ] as $ tag ) {
156
156
$ toDelete [self ::TAGS ][$ tag ][$ link ] = TRUE ;
157
157
}
@@ -186,21 +186,21 @@ public function write($key, array $dependencies)
186
186
$ data = $ this ->getNode ($ freeDataNode );
187
187
188
188
if ($ data === FALSE ) {
189
- $ data = array (
190
- self ::INFO => array (
189
+ $ data = [
190
+ self ::INFO => [
191
191
self ::LAST_INDEX => ($ freeDataNode << self ::BITROT ),
192
192
self ::TYPE => self ::DATA ,
193
- )
194
- ) ;
193
+ ]
194
+ ] ;
195
195
}
196
196
197
197
$ dataNodeKey = $ this ->findNextFreeKey ($ freeDataNode , $ data );
198
- $ data [$ dataNodeKey ] = array (
198
+ $ data [$ dataNodeKey ] = [
199
199
self ::KEY => $ key ,
200
- self ::TAGS => $ tags ? $ tags : array () ,
200
+ self ::TAGS => $ tags ? $ tags : [] ,
201
201
self ::PRIORITY => $ priority ,
202
202
self ::DELETED => FALSE ,
203
- ) ;
203
+ ] ;
204
204
205
205
$ this ->saveNode ($ freeDataNode , $ data );
206
206
@@ -240,19 +240,19 @@ public function clean(array $conditions)
240
240
$ this ->lock ();
241
241
242
242
if (!empty ($ conditions [Cache::ALL ])) {
243
- $ this ->nodeCache = $ this ->nodeChanged = $ this ->dataNodeFreeSpace = array () ;
243
+ $ this ->nodeCache = $ this ->nodeChanged = $ this ->dataNodeFreeSpace = [] ;
244
244
$ this ->deleteAll ();
245
245
$ this ->unlock ();
246
246
return NULL ;
247
247
}
248
248
249
- $ toDelete = array (
250
- self ::TAGS => array () ,
251
- self ::PRIORITY => array () ,
252
- self ::ENTRIES => array ()
253
- ) ;
249
+ $ toDelete = [
250
+ self ::TAGS => [] ,
251
+ self ::PRIORITY => [] ,
252
+ self ::ENTRIES => []
253
+ ] ;
254
254
255
- $ entries = array () ;
255
+ $ entries = [] ;
256
256
257
257
if (!empty ($ conditions [Cache::TAGS ])) {
258
258
$ entries = $ this ->cleanTags ((array ) $ conditions [Cache::TAGS ], $ toDelete );
@@ -262,7 +262,7 @@ public function clean(array $conditions)
262
262
$ this ->arrayAppend ($ entries , $ this ->cleanPriority ((int ) $ conditions [Cache::PRIORITY ], $ toDelete ));
263
263
}
264
264
265
- $ this ->deletedLinks = array () ;
265
+ $ this ->deletedLinks = [] ;
266
266
$ this ->cleanFromIndex ($ toDelete );
267
267
268
268
$ this ->commit ();
@@ -280,7 +280,7 @@ public function clean(array $conditions)
280
280
*/
281
281
private function cleanTags (array $ tags , array & $ toDelete )
282
282
{
283
- $ entries = array () ;
283
+ $ entries = [] ;
284
284
285
285
foreach ($ tags as $ tag ) {
286
286
list (, $ node ) = $ this ->findIndexNode (self ::TAGS , $ tag );
@@ -307,7 +307,7 @@ private function cleanPriority($priority, array & $toDelete)
307
307
308
308
ksort ($ node );
309
309
310
- $ allData = array () ;
310
+ $ allData = [] ;
311
311
312
312
foreach ($ node as $ prior => $ data ) {
313
313
if ($ prior === self ::INFO ) {
@@ -351,7 +351,7 @@ private function cleanPriority($priority, array & $toDelete)
351
351
*/
352
352
private function cleanLinks (array $ data , array & $ toDelete )
353
353
{
354
- $ return = array () ;
354
+ $ return = [] ;
355
355
356
356
$ data = array_keys ($ data );
357
357
sort ($ data );
@@ -700,7 +700,7 @@ private function commit()
700
700
foreach ($ this ->toCommit as $ node => $ str ) {
701
701
$ this ->commitNode ($ node , $ str );
702
702
}
703
- $ this ->toCommit = array () ;
703
+ $ this ->toCommit = [] ;
704
704
}
705
705
706
706
@@ -779,23 +779,23 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
779
779
$ node = $ this ->getNode ($ nodeId );
780
780
781
781
if ($ node === FALSE ) {
782
- return array (
782
+ return [
783
783
$ nodeId ,
784
- array (
785
- self ::INFO => array (
784
+ [
785
+ self ::INFO => [
786
786
self ::TYPE => $ type ,
787
787
self ::IS_LEAF => TRUE ,
788
788
self ::PREV_NODE => -1 ,
789
789
self ::END => -1 ,
790
790
self ::MAX => -1 ,
791
- )
792
- ) ,
791
+ ]
792
+ ] ,
793
793
$ parentId ,
794
- ) ; // Init empty node
794
+ ] ; // Init empty node
795
795
}
796
796
797
797
if ($ node [self ::INFO ][self ::IS_LEAF ] || $ nodeId === $ childId || $ node [self ::INFO ][self ::PREV_NODE ] === $ prevId ) {
798
- return array ( $ nodeId , $ node , $ parentId) ;
798
+ return [ $ nodeId , $ node , $ parentId] ;
799
799
}
800
800
801
801
$ parentId = $ nodeId ;
@@ -824,7 +824,7 @@ private function findIndexNode($type, $search, $childId = NULL, $prevId = NULL)
824
824
private function findFreeNode ($ count = 1 )
825
825
{
826
826
$ id = $ this ->lastNode ;
827
- $ nodesId = array () ;
827
+ $ nodesId = [] ;
828
828
829
829
do {
830
830
if (isset ($ this ->nodeCache [$ id ])) {
@@ -917,12 +917,12 @@ private function bisectNode($id, array $node)
917
917
$ key = key ($ node );
918
918
919
919
$ dataId = $ this ->findFreeDataNode (self ::NODE_SIZE );
920
- $ this ->saveNode ($ dataId , array (
920
+ $ this ->saveNode ($ dataId , [
921
921
self ::INDEX_DATA => $ node [$ key ],
922
- self ::INFO => array (
922
+ self ::INFO => [
923
923
self ::TYPE => self ::DATA ,
924
924
self ::LAST_INDEX => ($ dataId << self ::BITROT ),
925
- )) );
925
+ ]] );
926
926
927
927
unset($ node [$ key ]);
928
928
$ node [$ key ][self ::INDEX_DATA ] = $ dataId ;
@@ -943,54 +943,54 @@ private function bisectNode($id, array $node)
943
943
if ($ id <= 2 ) { // Root
944
944
list ($ firstId , $ secondId ) = $ this ->findFreeNode (2 );
945
945
946
- $ first [self ::INFO ] = array (
946
+ $ first [self ::INFO ] = [
947
947
self ::TYPE => $ nodeInfo [self ::TYPE ],
948
948
self ::IS_LEAF => $ nodeInfo [self ::IS_LEAF ],
949
949
self ::PREV_NODE => -1 ,
950
950
self ::END => -1 ,
951
951
self ::MAX => $ halfKey ,
952
- ) ;
952
+ ] ;
953
953
$ this ->saveNode ($ firstId , $ first );
954
954
955
- $ second [self ::INFO ] = array (
955
+ $ second [self ::INFO ] = [
956
956
self ::TYPE => $ nodeInfo [self ::TYPE ],
957
957
self ::IS_LEAF => $ nodeInfo [self ::IS_LEAF ],
958
958
self ::PREV_NODE => $ firstId ,
959
959
self ::END => $ nodeInfo [self ::END ],
960
960
self ::MAX => -1 ,
961
- ) ;
961
+ ] ;
962
962
$ this ->saveNode ($ secondId , $ second );
963
963
964
- $ parentNode = array (
965
- self ::INFO => array (
964
+ $ parentNode = [
965
+ self ::INFO => [
966
966
self ::TYPE => $ nodeInfo [self ::TYPE ],
967
967
self ::IS_LEAF => FALSE ,
968
968
self ::PREV_NODE => -1 ,
969
969
self ::END => $ secondId ,
970
970
self ::MAX => -1 ,
971
- ) ,
971
+ ] ,
972
972
$ halfKey => $ firstId ,
973
- ) ;
973
+ ] ;
974
974
$ this ->saveNode ($ id , $ parentNode );
975
975
} else {
976
976
$ firstId = $ this ->findFreeNode ();
977
977
978
- $ first [self ::INFO ] = array (
978
+ $ first [self ::INFO ] = [
979
979
self ::TYPE => $ nodeInfo [self ::TYPE ],
980
980
self ::IS_LEAF => $ nodeInfo [self ::IS_LEAF ],
981
981
self ::PREV_NODE => $ nodeInfo [self ::PREV_NODE ],
982
982
self ::END => -1 ,
983
983
self ::MAX => $ halfKey ,
984
- ) ;
984
+ ] ;
985
985
$ this ->saveNode ($ firstId , $ first );
986
986
987
- $ second [self ::INFO ] = array (
987
+ $ second [self ::INFO ] = [
988
988
self ::TYPE => $ nodeInfo [self ::TYPE ],
989
989
self ::IS_LEAF => $ nodeInfo [self ::IS_LEAF ],
990
990
self ::PREV_NODE => $ firstId ,
991
991
self ::END => $ nodeInfo [self ::END ],
992
992
self ::MAX => $ nodeInfo [self ::MAX ],
993
- ) ;
993
+ ] ;
994
994
$ this ->saveNode ($ id , $ second );
995
995
996
996
list (,, $ parent ) = $ this ->findIndexNode ($ nodeInfo [self ::TYPE ], $ halfKey );
@@ -1077,7 +1077,7 @@ private function lock()
1077
1077
1078
1078
$ lastProcessIdentifier = stream_get_contents ($ this ->handle , self ::INT32_SIZE , self ::INT32_SIZE * 2 );
1079
1079
if ($ lastProcessIdentifier !== $ this ->processIdentifier ) {
1080
- $ this ->nodeCache = $ this ->dataNodeFreeSpace = array () ;
1080
+ $ this ->nodeCache = $ this ->dataNodeFreeSpace = [] ;
1081
1081
1082
1082
// Write current processIdentifier to file header
1083
1083
fseek ($ this ->handle , self ::INT32_SIZE * 2 );
0 commit comments