1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-08-26 18:21:02 +00:00

Move to PHPStan level 4

This commit is contained in:
Yassine Guedidi 2025-04-05 17:34:00 +02:00
parent 31e1be4191
commit b4483023e6
22 changed files with 116 additions and 104 deletions

View file

@ -3,6 +3,7 @@
namespace Wallabag\Form\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
/**
* Transforms a comma-separated list to a proper PHP array.
@ -21,8 +22,6 @@ class StringToListTransformer implements DataTransformerInterface
/**
* Transforms a list to a string.
*
* @param array|null $list
*
* @return string
*/
public function transform($list)
@ -31,14 +30,16 @@ class StringToListTransformer implements DataTransformerInterface
return '';
}
if (!\is_array($list)) {
throw new UnexpectedTypeException($list, 'array');
}
return implode($this->separator, $list);
}
/**
* Transforms a string to a list.
*
* @param string $string
*
* @return array|null
*/
public function reverseTransform($string)
@ -47,6 +48,10 @@ class StringToListTransformer implements DataTransformerInterface
return null;
}
if (!\is_string($string)) {
throw new UnexpectedTypeException($string, 'string');
}
return array_values(array_filter(array_map('trim', explode($this->separator, $string))));
}
}