bump tests to phpstan level 5 (#1922)

This commit is contained in:
Kevin Papst
2020-09-05 16:48:19 +02:00
committed by GitHub
parent b69ea0648c
commit ed528eb19a
35 changed files with 128 additions and 93 deletions

View File

@@ -42,8 +42,8 @@ final class AnnotationExtractor implements ExtractorInterface
*/
public function extract($value): array
{
if (!\is_string($value)) {
throw new ExtractorException('AnnotationExtractor needs a class name (string) for work');
if (!\is_string($value) || empty($value)) {
throw new ExtractorException('AnnotationExtractor needs a non-empty class name for work');
}
try {

View File

@@ -23,7 +23,7 @@ class SearchTermTransformer implements DataTransformerInterface
*/
public function transform($searchTerm)
{
if (empty($searchTerm) || !$searchTerm instanceof SearchTerm) {
if (empty($searchTerm) || !($searchTerm instanceof SearchTerm)) {
return '';
}
@@ -33,7 +33,7 @@ class SearchTermTransformer implements DataTransformerInterface
/**
* Transforms a string to a SearchTerm object.
*
* @param string $searchTerm
* @param string|null $searchTerm
* @return SearchTerm|null
* @throws TransformationFailedException if object (issue) is not found
*/

View File

@@ -48,7 +48,7 @@ class TagArrayToStringTransformer implements DataTransformerInterface
/**
* Transforms a string to an array of tags.
*
* @param string $stringOfTags
* @param string|null $stringOfTags
*
* @return Tag[]
* @throws TransformationFailedException if object (issue) is not found

View File

@@ -25,11 +25,11 @@ class TimesheetStatistic
*/
protected $durationTotal = 0;
/**
* @var int
* @var float
*/
protected $amountThisMonth = 0;
/**
* @var int
* @var float
*/
protected $amountTotal = 0;
/**
@@ -54,17 +54,24 @@ class TimesheetStatistic
$this->durationThisMonth = (int) $durationThisMonth;
}
public function getAmountTotal(): int
/**
* This is actually the rate, wrong wording...
*
* @return float
*/
public function getAmountTotal(): float
{
return $this->amountTotal;
}
/**
* @param int $amountTotal
* This is actually the rate, wrong wording...
*
* @param float|int $amountTotal
*/
public function setAmountTotal($amountTotal)
{
$this->amountTotal = (int) $amountTotal;
$this->amountTotal = (float) $amountTotal;
}
public function getDurationTotal(): int
@@ -80,17 +87,24 @@ class TimesheetStatistic
$this->durationTotal = (int) $durationTotal;
}
public function getAmountThisMonth(): int
/**
* This is actually the rate, wrong wording...
*
* @return float
*/
public function getAmountThisMonth(): float
{
return $this->amountThisMonth;
}
/**
* @param int $amountThisMonth
* This is actually the rate, wrong wording...
*
* @param float|int $amountThisMonth
*/
public function setAmountThisMonth($amountThisMonth)
{
$this->amountThisMonth = (int) $amountThisMonth;
$this->amountThisMonth = (float) $amountThisMonth;
}
public function getFirstEntry(): ?\DateTime

View File

@@ -78,10 +78,10 @@ final class MarkdownExtension extends AbstractExtension
/**
* Transforms the timesheet description content into HTML.
*
* @param string $content
* @param string|null $content
* @return string
*/
public function timesheetContent($content): string
public function timesheetContent(?string $content): string
{
if (empty($content)) {
return '';

View File

@@ -19,12 +19,12 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
final class TimesheetValidator extends ConstraintValidator
{
/**
* @var TimesheetConstraint[]
* @var Constraint[]
*/
private $constraints;
/**
* @param TimesheetConstraint[] $constraints
* @param Constraint[] $constraints
*/
public function __construct(iterable $constraints)
{