@@ -19,7 +19,7 @@ class MetadataAwareStringFrontend extends StringFrontend
1919 /**
2020 * Store metadata of all loaded cache entries indexed by identifier
2121 *
22- * @var array
22+ * @var array<string, array{identifier:string, tags: string[], lifetime: int|null}>
2323 */
2424 protected $ metadata = [];
2525
@@ -39,6 +39,10 @@ class MetadataAwareStringFrontend extends StringFrontend
3939 * Set a cache entry and store additional metadata (tags and lifetime)
4040 *
4141 * {@inheritdoc}
42+ *
43+ * @param string $content
44+ * @param string[] $tags
45+ * @return void
4246 */
4347 public function set (string $ entryIdentifier , $ content , array $ tags = [], int $ lifetime = null )
4448 {
@@ -48,6 +52,8 @@ public function set(string $entryIdentifier, $content, array $tags = [], int $li
4852
4953 /**
5054 * {@inheritdoc}
55+ *
56+ * @return string|false
5157 */
5258 public function get (string $ entryIdentifier )
5359 {
@@ -61,6 +67,7 @@ public function get(string $entryIdentifier)
6167
6268 /**
6369 * {@inheritdoc}
70+ * @return array<string,string>
6471 */
6572 public function getByTag (string $ tag ): array
6673 {
@@ -77,16 +84,12 @@ public function getByTag(string $tag): array
7784 *
7885 * @param string $content
7986 * @param string $entryIdentifier The identifier metadata
80- * @param array $tags The tags metadata
87+ * @param string[] $tags The tags metadata
8188 * @param integer $lifetime The lifetime metadata
8289 * @return string The content including the serialized metadata
83- * @throws InvalidDataTypeException
8490 */
85- protected function insertMetadata ($ content , $ entryIdentifier , array $ tags , $ lifetime )
91+ protected function insertMetadata (string $ content , string $ entryIdentifier , array $ tags , ? int $ lifetime )
8692 {
87- if (!is_string ($ content )) {
88- throw new InvalidDataTypeException ('Given data is of type " ' . gettype ($ content ) . '", but a string is expected for string cache. ' , 1433155737 );
89- }
9093 $ metadata = [
9194 'identifier ' => $ entryIdentifier ,
9295 'tags ' => $ tags ,
@@ -106,7 +109,7 @@ protected function insertMetadata($content, $entryIdentifier, array $tags, $life
106109 * @return string The content without metadata
107110 * @throws InvalidDataTypeException
108111 */
109- protected function extractMetadata ($ entryIdentifier , $ content )
112+ protected function extractMetadata ($ entryIdentifier , $ content ): string
110113 {
111114 $ separatorIndex = strpos ($ content , self ::SEPARATOR );
112115 if ($ separatorIndex === false ) {
@@ -116,6 +119,7 @@ protected function extractMetadata($entryIdentifier, $content)
116119 } else {
117120 throw $ exception ;
118121 }
122+ return $ content ;
119123 }
120124
121125 $ metadataJson = substr ($ content , 0 , $ separatorIndex );
@@ -135,9 +139,9 @@ protected function extractMetadata($entryIdentifier, $content)
135139 }
136140
137141 /**
138- * @return array Metadata of all loaded entries (indexed by identifier)
142+ * @return array<string, array{identifier:string, tags?: string[], lifetime?: int|null}> Metadata of all loaded entries (indexed by identifier)
139143 */
140- public function getAllMetadata ()
144+ public function getAllMetadata (): array
141145 {
142146 return $ this ->metadata ;
143147 }
0 commit comments