mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-12 23:38:42 +00:00
fix phpstan
This commit is contained in:
parent
6814a076d7
commit
2e5ec71f29
|
|
@ -170,11 +170,11 @@ class Media implements \JsonSerializable
|
|||
* @param string $password Password to encrypt the file with
|
||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function encrypt(string $password, string $outputPath = null) : void
|
||||
public function encrypt(string $password, string $outputPath = null) : string
|
||||
{
|
||||
/**
|
||||
* @todo Orange-Management/Modules#185
|
||||
|
|
@ -182,6 +182,8 @@ class Media implements \JsonSerializable
|
|||
* The media module should allow to define a password (not encrypted on the hard drive)
|
||||
* and an encryption checkbox which forces a password AND encrypts the file on the harddrive.
|
||||
*/
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -190,7 +192,7 @@ class Media implements \JsonSerializable
|
|||
* @param string $password Password to encrypt the file with
|
||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ class MediaView extends View
|
|||
protected function filePathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_file($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||
&& StringUtils::startsWith($path, $media->getPath())
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
|
@ -69,10 +68,9 @@ class MediaView extends View
|
|||
protected function dirPathFunction(Media $media, string $sub) : string
|
||||
{
|
||||
if (\is_dir($media->getPath() . $sub)
|
||||
&& StringUtils::startsWith(
|
||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
||||
$media->getPath()
|
||||
)
|
||||
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||
&& StringUtils::startsWith($path, $media->getPath())
|
||||
) {
|
||||
return $media->getPath() . $sub;
|
||||
}
|
||||
|
|
@ -111,6 +109,11 @@ class MediaView extends View
|
|||
protected function getFileContent(string $path) : string
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
|
||||
if ($output === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||
|
||||
return $output;
|
||||
|
|
@ -128,6 +131,11 @@ class MediaView extends View
|
|||
protected function lineContentFunction(string $path) : array
|
||||
{
|
||||
$output = \file_get_contents($path);
|
||||
|
||||
if ($output === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||
|
||||
return \explode("\n", $output);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user