diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/config.iml b/.idea/config.iml new file mode 100644 index 0000000..7b68c58 --- /dev/null +++ b/.idea/config.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..3c358ba --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e8b6c6b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 0000000..3d1e5a5 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..8306744 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json index d211359..828a51f 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^8.1" + "php": "^8.4" }, "require-dev": { "phpunit/phpunit": "^9.5", diff --git a/src/Config.php b/src/Config.php index f9ec4a7..09d2937 100644 --- a/src/Config.php +++ b/src/Config.php @@ -80,12 +80,12 @@ class Config extends AbstractConfig * Loads a Config instance. * * @param string|array $values Filenames or string with configuration - * @param ParserInterface | null $parser Configuration parser + * @param ParserInterface | null $parser Configuration parser * @throws EmptyDirectoryException * @throws FileNotFoundException * @throws UnsupportedFormatException */ - private function __construct(string | array $values, ParserInterface $parser = null, bool $loadFromString = false) + private function __construct(string | array $values, ?ParserInterface $parser = null, bool $loadFromString = false) { if ($loadFromString && !is_array($values) && !file_exists($values)) { if ($parser === null) { @@ -156,7 +156,7 @@ class Config extends AbstractConfig * @throws Exception\WriteException if the data could not be written to the file * @throws UnsupportedFormatException */ - public function toFile(string $filename, WriterInterface $writer = null): void + public function toFile(string $filename, ?WriterInterface $writer = null): void { if ($writer === null) { // Get file information diff --git a/src/Exception/WriteException.php b/src/Exception/WriteException.php index 06d6148..a2f36b7 100644 --- a/src/Exception/WriteException.php +++ b/src/Exception/WriteException.php @@ -8,11 +8,11 @@ class WriteException extends ErrorException { public function __construct(array $error) { - $message = isset($error['message']) ? $error['message'] : 'There was an error writing the file'; - $code = isset($error['code']) ? $error['code'] : 0; - $severity = isset($error['type']) ? $error['type'] : 1; - $filename = isset($error['file']) ? $error['file'] : __FILE__; - $exception = isset($error['exception']) ? $error['exception'] : null; + $message = $error['message'] ?? 'There was an error writing the file'; + $code = $error['code'] ?? 0; + $severity = $error['type'] ?? 1; + $filename = $error['file'] ?? __FILE__; + $exception = $error['exception'] ?? null; parent::__construct($message, $code, $severity, $filename, $exception); } diff --git a/src/Parser/Json.php b/src/Parser/Json.php index 3a3a06c..317f17c 100644 --- a/src/Parser/Json.php +++ b/src/Parser/Json.php @@ -49,13 +49,13 @@ class Json implements ParserInterface /** * Completes parsing of JSON data * - * @param array | null $data - * @param string | null $filename + * @param array | null $data + * @param string | null $filename * @return array | null * * @throws ParseException If there is an error parsing the JSON data */ - protected function parse(array $data = null, string $filename = null): ?array + protected function parse(?array $data = null, ?string $filename = null): ?array { if (json_last_error() !== JSON_ERROR_NONE) { $error_message = 'Syntax error'; diff --git a/src/Parser/Php.php b/src/Parser/Php.php index 89df0ad..a9fdd73 100644 --- a/src/Parser/Php.php +++ b/src/Parser/Php.php @@ -84,12 +84,12 @@ class Php implements ParserInterface * Completes parsing of PHP data * * @param array | callable | null $data - * @param string | null $filename + * @param string | null $filename * * @return array | null * @throws UnsupportedFormatException */ - protected function parse(array | callable $data = null, string $filename = null): ?array + protected function parse(array | callable|null $data = null, ?string $filename = null): ?array { // If we have a callable, run it and expect an array back if (is_callable($data)) { diff --git a/src/Parser/Serialize.php b/src/Parser/Serialize.php index dcdff25..7d49d49 100644 --- a/src/Parser/Serialize.php +++ b/src/Parser/Serialize.php @@ -38,13 +38,13 @@ class Serialize implements ParserInterface /** * Completes parsing of JSON data * - * @param string | null $data - * @param string | null $filename + * @param string | null $data + * @param string | null $filename * @return array|null * * @throws ParseException If there is an error parsing the serialized data */ - protected function parse(string $data = null, string $filename = null): ?array + protected function parse(?string $data = null, ?string $filename = null): ?array { try { $serializedData = unserialize($data, ['allowed_classes' => false]); diff --git a/src/Parser/Xml.php b/src/Parser/Xml.php index 4d9d74a..a0a7345 100644 --- a/src/Parser/Xml.php +++ b/src/Parser/Xml.php @@ -20,7 +20,7 @@ class Xml implements ParserInterface * {@inheritDoc} * Parses an XML file as an array * - * @throws ParseException If there is an error parsing the XML file + * @throws ParseException|\JsonException If there is an error parsing the XML file */ public function parseFile(string $filename): array { @@ -52,14 +52,14 @@ class Xml implements ParserInterface * Completes parsing of XML data * * @param \SimpleXMLElement | null $data - * @param string | null $filename + * @param string | null $filename * * @return array|null * * @throws ParseException If there is an error parsing the XML data * @throws \JsonException */ - protected function parse(\SimpleXMLElement $data = null, string $filename = null): ?array + protected function parse(?\SimpleXMLElement $data = null, ?string $filename = null): ?array { if ($data === false) { $errors = libxml_get_errors();