77
88namespace 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}
0 commit comments