From 6484ef5461a1cf2ecd2d01702d96a7ee18b2443c Mon Sep 17 00:00:00 2001 From: IsmaelR04 Date: Fri, 27 Dec 2024 12:08:27 +0100 Subject: [PATCH 1/2] Add support for php 8 --- .gitignore | 1 + composer.json | 4 ++-- src/Encoding.php | 4 ++-- tests/FileEncodingTest.php | 2 +- tests/files/iso88591.txt | 1 + tests/files/utf8.txt | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 tests/files/iso88591.txt create mode 100644 tests/files/utf8.txt diff --git a/.gitignore b/.gitignore index aadd369..1b6f326 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor composer.lock build +.phpunit.result.cache \ No newline at end of file diff --git a/composer.json b/composer.json index fcbf9d1..0b30ea4 100644 --- a/composer.json +++ b/composer.json @@ -16,10 +16,10 @@ } ], "require": { - "php": "^5.6 || ^7.0" + "php": "^5.6 || ^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^5.7" + "phpunit/phpunit": "^5.7 || ^8.0" }, "autoload": { "psr-4": { diff --git a/src/Encoding.php b/src/Encoding.php index c23e4fe..0e3003c 100644 --- a/src/Encoding.php +++ b/src/Encoding.php @@ -42,8 +42,8 @@ public function encodeFile($file, $encoding_to = 'UTF-8', $encodings_detected = } else { return false; } - } catch (Exception $e) { - if (file_exits($fileW)) { + } catch (\Exception $e) { + if (file_exists($fileW)) { unlink($fileW); } diff --git a/tests/FileEncodingTest.php b/tests/FileEncodingTest.php index dc084f6..4bd77fe 100644 --- a/tests/FileEncodingTest.php +++ b/tests/FileEncodingTest.php @@ -7,7 +7,7 @@ class FileEncodingTest extends TestCase { - public function setUp() + public function setUp() : void { parent::setUp(); copy(__DIR__.'/files/test_iso-8859-1.txt', __DIR__.'/files/iso88591.txt'); diff --git a/tests/files/iso88591.txt b/tests/files/iso88591.txt new file mode 100644 index 0000000..623a2fe --- /dev/null +++ b/tests/files/iso88591.txt @@ -0,0 +1 @@ +Texto de ejemplo con acentos áéíóúàèìòùñ \ No newline at end of file diff --git a/tests/files/utf8.txt b/tests/files/utf8.txt new file mode 100644 index 0000000..9a0ab69 --- /dev/null +++ b/tests/files/utf8.txt @@ -0,0 +1 @@ +Example file test \ No newline at end of file From 71a22c13936b24f2c4aeb023390495b494b6c110 Mon Sep 17 00:00:00 2001 From: IsmaelR04 Date: Fri, 27 Dec 2024 12:09:36 +0100 Subject: [PATCH 2/2] Remove created test files --- tests/files/iso88591.txt | 1 - tests/files/utf8.txt | 1 - 2 files changed, 2 deletions(-) delete mode 100644 tests/files/iso88591.txt delete mode 100644 tests/files/utf8.txt diff --git a/tests/files/iso88591.txt b/tests/files/iso88591.txt deleted file mode 100644 index 623a2fe..0000000 --- a/tests/files/iso88591.txt +++ /dev/null @@ -1 +0,0 @@ -Texto de ejemplo con acentos áéíóúàèìòùñ \ No newline at end of file diff --git a/tests/files/utf8.txt b/tests/files/utf8.txt deleted file mode 100644 index 9a0ab69..0000000 --- a/tests/files/utf8.txt +++ /dev/null @@ -1 +0,0 @@ -Example file test \ No newline at end of file