mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-18 02:08:40 +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 string $password Password to encrypt the file with
|
||||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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
|
* @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)
|
* 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.
|
* 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 string $password Password to encrypt the file with
|
||||||
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
* @param null|string $outputPath Output path of the encryption (null = replace file)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -45,10 +45,9 @@ class MediaView extends View
|
||||||
protected function filePathFunction(Media $media, string $sub) : string
|
protected function filePathFunction(Media $media, string $sub) : string
|
||||||
{
|
{
|
||||||
if (\is_file($media->getPath() . $sub)
|
if (\is_file($media->getPath() . $sub)
|
||||||
&& StringUtils::startsWith(
|
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||||
$media->getPath()
|
&& StringUtils::startsWith($path, $media->getPath())
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return $media->getPath() . $sub;
|
return $media->getPath() . $sub;
|
||||||
}
|
}
|
||||||
|
|
@ -69,10 +68,9 @@ class MediaView extends View
|
||||||
protected function dirPathFunction(Media $media, string $sub) : string
|
protected function dirPathFunction(Media $media, string $sub) : string
|
||||||
{
|
{
|
||||||
if (\is_dir($media->getPath() . $sub)
|
if (\is_dir($media->getPath() . $sub)
|
||||||
&& StringUtils::startsWith(
|
&& ($path = \realpath($media->getPath() . $sub)) !== false
|
||||||
\str_replace('\\', '/', \realpath($media->getPath() . $sub)),
|
&& ($path = \str_replace('\\', '/', $path)) !== false
|
||||||
$media->getPath()
|
&& StringUtils::startsWith($path, $media->getPath())
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return $media->getPath() . $sub;
|
return $media->getPath() . $sub;
|
||||||
}
|
}
|
||||||
|
|
@ -111,6 +109,11 @@ class MediaView extends View
|
||||||
protected function getFileContent(string $path) : string
|
protected function getFileContent(string $path) : string
|
||||||
{
|
{
|
||||||
$output = \file_get_contents($path);
|
$output = \file_get_contents($path);
|
||||||
|
|
||||||
|
if ($output === false) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
|
|
@ -128,6 +131,11 @@ class MediaView extends View
|
||||||
protected function lineContentFunction(string $path) : array
|
protected function lineContentFunction(string $path) : array
|
||||||
{
|
{
|
||||||
$output = \file_get_contents($path);
|
$output = \file_get_contents($path);
|
||||||
|
|
||||||
|
if ($output === false) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
$output = \str_replace(["\r\n", "\r"], "\n", $output);
|
||||||
|
|
||||||
return \explode("\n", $output);
|
return \explode("\n", $output);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user