mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-19 10:24:50 +02:00
Added declare strict types to all files
This commit is contained in:
parent
bea90a7d94
commit
6a2ff9d153
196 changed files with 685 additions and 360 deletions
|
@ -64,7 +64,7 @@ class AttachmentManager
|
|||
*/
|
||||
public function toAbsoluteFilePath(Attachment $attachment): ?string
|
||||
{
|
||||
if (empty($attachment->getPath())) {
|
||||
if ($attachment->getPath() === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ class AttachmentManager
|
|||
*/
|
||||
public function isFileExisting(Attachment $attachment): bool
|
||||
{
|
||||
if (empty($attachment->getPath())) {
|
||||
if ($attachment->getPath() === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class AttachmentSubmitHandler
|
|||
public function isValidFileExtension(AttachmentType $attachment_type, UploadedFile $uploadedFile): bool
|
||||
{
|
||||
//Only validate if the attachment type has specified a filetype filter:
|
||||
if (empty($attachment_type->getFiletypeFilter())) {
|
||||
if ($attachment_type->getFiletypeFilter() === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ class AttachmentSubmitHandler
|
|||
|
||||
//Determine the old filepath
|
||||
$old_path = $this->pathResolver->placeholderToRealPath($attachment->getPath());
|
||||
if (empty($old_path) || !file_exists($old_path)) {
|
||||
if ($old_path === null || $old_path === '' || !file_exists($old_path)) {
|
||||
return $attachment;
|
||||
}
|
||||
$filename = basename($old_path);
|
||||
|
@ -357,7 +357,7 @@ class AttachmentSubmitHandler
|
|||
|
||||
//Check if we have an extension given
|
||||
$pathinfo = pathinfo($filename);
|
||||
if (!empty($pathinfo['extension'])) {
|
||||
if ($pathinfo['extension'] !== '') {
|
||||
$new_ext = $pathinfo['extension'];
|
||||
} else { //Otherwise we have to guess the extension for the new file, based on its content
|
||||
$new_ext = $this->mimeTypes->getExtensions($this->mimeTypes->guessMimeType($tmp_path))[0] ?? 'tmp';
|
||||
|
|
|
@ -119,7 +119,7 @@ class AttachmentURLGenerator
|
|||
throw new InvalidArgumentException('Thumbnail creation only works for picture attachments!');
|
||||
}
|
||||
|
||||
if ($attachment->isExternal() && !empty($attachment->getURL())) {
|
||||
if ($attachment->isExternal() && ($attachment->getURL() !== null && $attachment->getURL() !== '')) {
|
||||
return $attachment->getURL();
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ class BuiltinAttachmentsFinder
|
|||
*/
|
||||
public function find(string $keyword, array $options = [], ?array $base_list = []): array
|
||||
{
|
||||
if (empty($base_list)) {
|
||||
if ($base_list === null || $base_list === []) {
|
||||
$base_list = $this->getListOfRessources();
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,6 @@ class FileTypeFilterTools
|
|||
{
|
||||
$extension = strtolower($extension);
|
||||
|
||||
return empty($filter) || in_array($extension, $this->resolveFileExtensions($filter), false);
|
||||
return $filter === '' || in_array($extension, $this->resolveFileExtensions($filter), false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue