fix phpstan

This commit is contained in:
Dennis Eichhorn 2020-02-15 21:40:03 +01:00
parent 6814a076d7
commit 2e5ec71f29
2 changed files with 21 additions and 11 deletions

View File

@ -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
*/

View File

@ -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);