diff --git a/.idea/nur-sery.iml b/.idea/nur-sery.iml index 8f5e5e3..93a8f92 100644 --- a/.idea/nur-sery.iml +++ b/.idea/nur-sery.iml @@ -6,7 +6,6 @@ - diff --git a/composer.json b/composer.json index 553eb1f..ee579f4 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "ext-json": "*", "ext-iconv": "*", "ext-curl": "*", + "ext-tidy": "*", "ext-oci8": "*", "ext-pdo": "*", "ext-pgsql": "*", @@ -37,7 +38,10 @@ "psr-4": { "nur\\sery\\": "src", "nur\\": "nur_src" - } + }, + "files": [ + "nur_autoload.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/composer.lock b/composer.lock index 53f0cb2..756a009 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b812e89a26ebc52585e5908d66151999", + "content-hash": "4bd0015796ba3b74f5a4e1a85f3a2287", "packages": [ { "name": "nulib/php", @@ -12,18 +12,23 @@ "dist": { "type": "path", "url": "../nulib", - "reference": "d7323d7d45a73edf8d033253a6b52ae8a3f6e25e" + "reference": "2964153e54b269c833810194f16bd9bccc9267ce" }, "require": { - "php": ">=7.3" + "php": ">=7.4" }, "require-dev": { - "nulib/tests": "7.3" + "ext-curl": "*", + "nulib/tests": "7.4" }, "type": "library", "autoload": { "psr-4": { - "nulib\\": "php/src_base" + "nulib\\": "php/src_base", + "nulib\\ref\\": "php/src_ref", + "nulib\\php\\": "php/src_php", + "nulib\\output\\": "php/src_output", + "nulib\\web\\": "php/src_web" } }, "autoload-dev": { @@ -598,23 +603,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.29", + "version": "9.2.30", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", - "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca2bd87d2f9215904682a9cb9bb37dda98e76089", + "reference": "ca2bd87d2f9215904682a9cb9bb37dda98e76089", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -664,7 +669,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.30" }, "funding": [ { @@ -672,7 +677,7 @@ "type": "github" } ], - "time": "2023-09-19T04:57:46+00:00" + "time": "2023-12-22T06:47:57+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1261,20 +1266,20 @@ }, { "name": "sebastian/complexity", - "version": "2.0.2", + "version": "2.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", - "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", "shasum": "" }, "require": { - "nikic/php-parser": "^4.7", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1306,7 +1311,7 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" }, "funding": [ { @@ -1314,7 +1319,7 @@ "type": "github" } ], - "time": "2020-10-26T15:52:27+00:00" + "time": "2023-12-22T06:19:30+00:00" }, { "name": "sebastian/diff", @@ -1588,20 +1593,20 @@ }, { "name": "sebastian/lines-of-code", - "version": "1.0.3", + "version": "1.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", - "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", "shasum": "" }, "require": { - "nikic/php-parser": "^4.6", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=7.3" }, "require-dev": { @@ -1633,7 +1638,7 @@ "homepage": "https://github.com/sebastianbergmann/lines-of-code", "support": { "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" }, "funding": [ { @@ -1641,7 +1646,7 @@ "type": "github" } ], - "time": "2020-11-28T06:42:11+00:00" + "time": "2023-12-22T06:20:34+00:00" }, { "name": "sebastian/object-enumerator", @@ -2053,6 +2058,7 @@ "ext-json": "*", "ext-iconv": "*", "ext-curl": "*", + "ext-tidy": "*", "ext-oci8": "*", "ext-pdo": "*", "ext-pgsql": "*", diff --git a/nur_autoload.php b/nur_autoload.php new file mode 100644 index 0000000..769614e --- /dev/null +++ b/nur_autoload.php @@ -0,0 +1,16 @@ +file = $file; $this->mode = $mode; - $fd = null; + $fd = $this->open(); $close = true; } parent::__construct($fd, $close, $throwOnError, $allowLocking); diff --git a/src/os/file/FileWriter.php b/src/os/file/FileWriter.php index e73ddc1..0a81b9f 100644 --- a/src/os/file/FileWriter.php +++ b/src/os/file/FileWriter.php @@ -24,7 +24,7 @@ class FileWriter extends _File { IOException::ensure_value(sh::mkdirof($file)); $this->file = $file; $this->mode = $mode; - $fd = null; + $fd = $this->open(); $close = true; } parent::__construct($fd, $close, $throwOnError, $allowLocking); diff --git a/src/os/file/TmpfileWriter.php b/src/os/file/TmpfileWriter.php index 1e3d1e5..7dd6e25 100644 --- a/src/os/file/TmpfileWriter.php +++ b/src/os/file/TmpfileWriter.php @@ -2,13 +2,15 @@ namespace nur\sery\os\file; use nur\sery\os\IOException; +use nur\sery\os\path; use nur\sery\web\http; class TmpfileWriter extends FileWriter { const DEFAULT_MODE = "w+b"; function __construct(?string $destdir=null, ?string $mode=null, bool $throwOnError=true, ?bool $allowLocking=null) { - if ($destdir === null) $destdir = sys_get_temp_dir(); + $tmpDir = sys_get_temp_dir(); + if ($destdir === null) $destdir = $tmpDir; if (is_dir($destdir)) { # si on spécifie un répertoire, créer un fichier temporaire dedans $file = tempnam($destdir, "tmp_nulib_"); @@ -17,6 +19,7 @@ class TmpfileWriter extends FileWriter { # si on spécifie un fichier qui existe le prendre comme "fichier # temporaire" mais ne pas le supprimer automatiquement $file = $destdir; + if (!path::is_qualified($file)) $file = path::join($tmpDir, $file); $this->delete = false; } else { # un chemin qui n'existe pas: ne le sélectionner que si le répertoire diff --git a/src/os/file/_File.php b/src/os/file/_File.php index d9ee42b..349a9f3 100644 --- a/src/os/file/_File.php +++ b/src/os/file/_File.php @@ -15,10 +15,12 @@ abstract class _File extends Stream { /** @var string */ protected $mode; + protected function open() { + return IOException::ensure_value(@fopen($this->file, $this->mode)); + } + function getResource() { - if ($this->fd === null && $this->file !== null) { - $this->fd = IOException::ensure_value(@fopen($this->file, $this->mode)); - } + if ($this->fd === null && $this->file !== null) $this->fd = $this->open(); return parent::getResource(); }