@@ -58,12 +58,12 @@ class AnyDataset
5858
5959 /**
6060 * Path to anydataset file
61- * @var string
61+ * @var string|null
6262 */
6363 private $ filename ;
6464
6565 /**
66- * @param string $filename
66+ * @param null| string $filename
6767 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
6868 * @throws \ByJG\Util\Exception\XmlUtilException
6969 */
@@ -80,18 +80,23 @@ public function __construct($filename = null)
8080 });
8181 }
8282
83+ /**
84+ * @return string|null
85+ */
8386 public function getFilename ()
8487 {
8588 return $ this ->filename ;
8689 }
8790
91+ /**
92+ *
93+ * @param string|null $file
94+ * @param mixed $closure
95+ * @return void
96+ */
8897 private function defineSavePath ($ file , $ closure )
8998 {
9099 if (!is_null ($ file )) {
91- if (!is_string ($ file )) {
92- throw new InvalidArgumentException ('I expected a string as a file name ' );
93- }
94-
95100 $ ext = pathinfo ($ file , PATHINFO_EXTENSION );
96101 if (empty ($ ext ) && substr ($ file , 0 , 6 ) !== "php:// " ) {
97102 $ file .= '.anydata.xml ' ;
@@ -106,6 +111,7 @@ private function defineSavePath($file, $closure)
106111 * Private method used to read and populate anydataset class from specified file
107112 *
108113 * @param string $filepath Path and Filename to be read
114+ * @return void
109115 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
110116 * @throws \ByJG\Util\Exception\XmlUtilException
111117 */
@@ -121,7 +127,7 @@ private function createFrom($filepath)
121127 $ fields = $ row ->getElementsByTagName ("field " );
122128 foreach ($ fields as $ field ) {
123129 $ attr = $ field ->attributes ->getNamedItem ("name " );
124- if (is_null ($ attr )) {
130+ if (is_null ($ attr ) || is_null ( $ attr -> nodeValue ) ) {
125131 throw new InvalidArgumentException ('Malformed anydataset file ' . basename ($ filepath ));
126132 }
127133
@@ -146,7 +152,8 @@ public function xml()
146152 }
147153
148154 /**
149- * @param string $filename
155+ * @param string|null $filename
156+ * @return void
150157 * @throws DatabaseException
151158 * @throws \ByJG\Util\Exception\XmlUtilException
152159 */
@@ -164,7 +171,7 @@ public function save($filename = null)
164171 /**
165172 * Append one row to AnyDataset.
166173 *
167- * @param Row|array|\stdClass|object $singleRow
174+ * @param Row|array|\stdClass|object|null $singleRow
168175 * @return void
169176 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
170177 */
@@ -191,6 +198,7 @@ public function appendRow($singleRow = [])
191198 * Enter description here...
192199 *
193200 * @param GenericIterator $iterator
201+ * @return void
194202 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
195203 */
196204 public function import ($ iterator )
@@ -204,10 +212,11 @@ public function import($iterator)
204212 * Insert one row before specified position.
205213 *
206214 * @param int $rowNumber
207- * @param mixed $row
215+ * @param Row|array|\stdClass|object $row
216+ * @return void
208217 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
209218 */
210- public function insertRowBefore ($ rowNumber , $ row = null )
219+ public function insertRowBefore ($ rowNumber , $ row )
211220 {
212221 if ($ rowNumber > count ($ this ->collection )) {
213222 $ this ->appendRow ($ row );
@@ -216,14 +225,22 @@ public function insertRowBefore($rowNumber, $row = null)
216225 if (!($ row instanceof Row)) {
217226 $ singleRow = new Row ($ row );
218227 }
228+
229+ /**
230+ * @psalm-suppress InvalidPropertyAssignmentValue
231+ */
219232 array_splice ($ this ->collection , $ rowNumber , 0 , '' );
233+ /**
234+ * @psalm-suppress InvalidPropertyAssignmentValue
235+ */
220236 $ this ->collection [$ rowNumber ] = $ singleRow ;
221237 }
222238 }
223239
224240 /**
225241 *
226242 * @param mixed $row
243+ * @return void
227244 * @throws \ByJG\Serializer\Exception\InvalidArgumentException
228245 */
229246 public function removeRow ($ row = null )
@@ -291,8 +308,7 @@ public function getArray($fieldName, $itf = null)
291308 {
292309 $ iterator = $ this ->getIterator ($ itf );
293310 $ result = array ();
294- while ($ iterator ->hasNext ()) {
295- $ singleRow = $ iterator ->moveNext ();
311+ foreach ($ iterator as $ singleRow ) {
296312 $ result [] = $ singleRow ->get ($ fieldName );
297313 }
298314 return $ result ;
@@ -310,13 +326,11 @@ public function sort($field)
310326 }
311327
312328 $ this ->collection = $ this ->quickSortExec ($ this ->collection , $ field );
313-
314- return ;
315329 }
316330
317331 /**
318332 * @param Row[] $seq
319- * @param $field
333+ * @param string $field
320334 * @return array
321335 */
322336 protected function quickSortExec ($ seq , $ field )
0 commit comments