modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-01-01 18:14:49 +04:00
parent 4b0c79f4c3
commit ee0ae30257
9 changed files with 66 additions and 36 deletions

View File

@ -6,7 +6,6 @@
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="nur\sery\" />
<sourceFolder url="file://$MODULE_DIR$/nur_src" isTestSource="false" packagePrefix="nur\" />
<sourceFolder url="file://$MODULE_DIR$/nur_tests" isTestSource="true" packagePrefix="nur\" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/vendor" />
</content>
<orderEntry type="inheritedJdk" />

View File

@ -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": {

58
composer.lock generated
View File

@ -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": "*",

16
nur_autoload.php Normal file
View File

@ -0,0 +1,16 @@
<?php
## Fonctions qui doivent être disponible tout le temps dans le namespace global
# pour compatibilité, il est possible de ne pas définir ces fonctions
if (!defined("NO_AUTOLOAD_NUR_BASE")) {
/** définir $name s'il n'est pas encore défini */
function definem($name, $value): void {
if (!defined($name)) define($name, $value);
}
# nur\debug
function Txx(...$values): void { nur\debug::log(...$values); }
# nur
function q($vs): iterable { return nur\c::q($vs); }
}

View File

@ -24,8 +24,8 @@ class file {
return $file;
}
static function writer($output, ?callable $func=null): FileWriter {
$file = new FileWriter($output);
static function writer($output, ?string $mode=null, ?callable $func=null): FileWriter {
$file = new FileWriter($output, $mode);
if ($func !== null) {
try {
$func($file);

View File

@ -21,7 +21,7 @@ class FileReader extends _File {
if ($mode === null) $mode = static::DEFAULT_MODE;
$this->file = $file;
$this->mode = $mode;
$fd = null;
$fd = $this->open();
$close = true;
}
parent::__construct($fd, $close, $throwOnError, $allowLocking);

View File

@ -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);

View File

@ -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

View File

@ -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();
}