[Web] Some minor fixes and improvements for PHP 8

This commit is contained in:
andryyy
2021-08-08 16:06:55 +02:00
parent eec75690e0
commit cf8fdae277
138 changed files with 2398 additions and 2342 deletions

View File

@@ -27,7 +27,7 @@ class CsvFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
$messages = [];

View File

@@ -55,11 +55,9 @@ abstract class FileLoader extends ArrayLoader
}
/**
* @param string $resource
*
* @return array
*
* @throws InvalidResourceException if stream content has an invalid format
*/
abstract protected function loadResource($resource);
abstract protected function loadResource(string $resource);
}

View File

@@ -21,7 +21,7 @@ class IniFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
return parse_ini_file($resource, true);
}

View File

@@ -23,7 +23,7 @@ class JsonFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
$messages = [];
if ($data = file_get_contents($resource)) {

View File

@@ -41,7 +41,7 @@ class MoFileLoader extends FileLoader
*
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
$stream = fopen($resource, 'r');
@@ -89,7 +89,7 @@ class MoFileLoader extends FileLoader
fseek($stream, $offset);
$singularId = fread($stream, $length);
if (false !== strpos($singularId, "\000")) {
if (str_contains($singularId, "\000")) {
[$singularId, $pluralId] = explode("\000", $singularId);
}
@@ -104,7 +104,7 @@ class MoFileLoader extends FileLoader
fseek($stream, $offset);
$translated = fread($stream, $length);
if (false !== strpos($translated, "\000")) {
if (str_contains($translated, "\000")) {
$translated = explode("\000", $translated);
}

View File

@@ -23,7 +23,7 @@ class PhpFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
if ([] === self::$cache && \function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN) && (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true) || filter_var(ini_get('opcache.enable_cli'), \FILTER_VALIDATE_BOOLEAN))) {
self::$cache = null;

View File

@@ -60,7 +60,7 @@ class PoFileLoader extends FileLoader
*
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
$stream = fopen($resource, 'r');

View File

@@ -75,7 +75,7 @@ class XliffFileLoader implements LoaderInterface
return $catalogue;
}
private function extract($dom, MessageCatalogue $catalogue, string $domain)
private function extract(\DOMDocument $dom, MessageCatalogue $catalogue, string $domain)
{
$xliffVersion = XliffUtils::getVersionNumber($dom);

View File

@@ -29,7 +29,7 @@ class YamlFileLoader extends FileLoader
/**
* {@inheritdoc}
*/
protected function loadResource($resource)
protected function loadResource(string $resource)
{
if (null === $this->yamlParser) {
if (!class_exists(\Symfony\Component\Yaml\Parser::class)) {