Skip to content

Commit

Permalink
Add var type hint to help phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jan 25, 2024
1 parent 2f546e5 commit d79e571
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/FileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,13 @@ private function validateFile(UploadedFileInterface $file): bool
}
}

if (! empty($this->getAllowedMimeTypes())) {
$allowedMimeTypes = $this->getAllowedMimeTypes();
if (! empty($allowedMimeTypes)) {
$hasAllowedMimeType = false;
$fileMimetype = $file->getClientMediaType();

if ($fileMimetype) {
foreach ($this->getAllowedMimeTypes() as $type) {
foreach ($allowedMimeTypes as $type) {
if (($pos = strpos($type, '/*')) !== false) { // image/*
$typePrefix = substr($type, 0, $pos);
if (Str::startsWith($fileMimetype, $typePrefix)) {
Expand All @@ -243,7 +244,7 @@ private function validateFile(UploadedFileInterface $file): bool
$this->translate('File %s is of type %s. Only %s allowed.'),
$file->getClientFilename(),
$file->getClientMediaType(),
implode(', ', $this->allowedMimeTypes)
implode(', ', $allowedMimeTypes)
));

$isValid = false;
Expand Down

0 comments on commit d79e571

Please sign in to comment.