Compare commits

..

14 Commits

Author SHA1 Message Date
Clemens Schwaighofer afcb953d2d Fix publish workflow with auth and no prefix 2026-05-11 17:45:46 +09:00
Clemens Schwaighofer 742b4087aa Update minimum PHP to 8.3 2026-05-11 17:06:09 +09:00
Clemens Schwaighofer f0c8daf26a Version: 9.41.0 actual push 2026-05-11 16:03:39 +09:00
Clemens Schwaighofer ee32a90ff9 Version: 9.41.0 2026-05-11 15:59:33 +09:00
Clemens Schwaighofer 1823fd369b File getMimeType throws exception if no mime type can be set, fixes for phpstan checks 2026-05-11 15:55:33 +09:00
Clemens Schwaighofer 116f0a770c Switch to dotenv v3 instead of dev-master 2026-04-20 16:21:43 +09:00
Clemens Schwaighofer b2123a183d Version: v9.40.0.1 2026-04-17 12:21:53 +09:00
Clemens Schwaighofer e92c585638 Set all to stable for composer packages 2026-04-17 12:20:10 +09:00
Clemens Schwaighofer 82c982c2c7 composer repository update 2026-02-19 14:35:39 +09:00
Clemens Schwaighofer 6b3ef52c5d Release: v9.40.0 2026-01-22 11:47:55 +09:00
Clemens Schwaighofer f2271313fc Json class json_validate support and json_decode flags support 2026-01-22 11:47:10 +09:00
Clemens Schwaighofer a7f81766bf Release: v9.39.1 2026-01-14 15:11:06 +09:00
Clemens Schwaighofer 7a4c905ae3 Bug fix in RandomKey validateRandomKeyData() 2026-01-14 15:10:12 +09:00
Clemens Schwaighofer 0531b29749 Release: v9.39.0 2026-01-14 13:23:21 +09:00
18 changed files with 209 additions and 47 deletions
+2 -2
View File
@@ -54,8 +54,8 @@ return [
// Note that the **only** effect of choosing `'5.6'` is to infer that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
// Automatically inferred from composer.json requirement for "php" of ">=8.2"
'target_php_version' => '8.2',
"minimum_target_php_version" => "8.2",
'target_php_version' => '8.3',
"minimum_target_php_version" => "8.3",
// turn color on (-C)
"color_issue_messages_if_supported" => true,
+10 -10
View File
@@ -15,10 +15,11 @@
"email": "clemens.schwaighofer@egplusww.com"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"psr/log": "^3.0@dev"
"php": ">=8.3",
"psr/log": "^3.0"
},
"require-dev": {
"phpstan/phpstan": "^2.0",
@@ -26,13 +27,12 @@
"phpstan/phpstan-deprecation-rules": "^2.0",
"phan/phan": "^5.4",
"egrajp/smarty-extended": "^5.4",
"gullevek/dotenv": "dev-master",
"gullevek/dotenv": "^3",
"phpunit/phpunit": "^9"
},
"repositories": {
"git.egplusww.jp.Composer": {
"type": "composer",
"url": "https://git.egplusww.jp/api/packages/Composer/composer"
}
}
"repositories": [{
"name": "packages.omnicomproduction.Composer",
"type": "composer",
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
}]
}
+1 -1
View File
@@ -1 +1 @@
9.38.1
9.41.0
+10 -2
View File
@@ -11,6 +11,9 @@ go_flag="$1";
function gitea_publish
{
# MUST have in app.ini, else upload will fail
# [repository]
# PREFIX_ARCHIVE_FILES = false
_GITEA_PUBLISH="${1}"
_GITEA_UPLOAD_FILENAME="${2}"
_GITEA_URL_DL="${3}"
@@ -32,7 +35,12 @@ function gitea_publish
echo "> Download: ${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip";
curl -LJO \
--output-dir "${_PACKAGE_DOWNLOAD}" \
"${_GITEA_URL_DL}"/v"${_VERSION}".zip;
-H "Authorization: token ${_GITEA_TOKEN}" \
"${_GITEA_URL_DL}/v${_VERSION}.zip";
fi;
# if this is the short name, if long down load does not work
if [ -f "${_PACKAGE_DOWNLOAD}v${_VERSION}.zip" ]; then
mv "${_PACKAGE_DOWNLOAD}v${_VERSION}.zip" "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip";
fi;
if [ ! -f "${_PACKAGE_DOWNLOAD}${_GITEA_UPLOAD_FILENAME}-v${_VERSION}.zip" ]; then
echo "[!] Package file does not exist for version: ${_VERSION}";
@@ -46,8 +54,8 @@ function gitea_publish
echo "[!] Error ${status}: ${message}";
else
echo "> Publish completed";
echo "${_VERSION}" > "${_file_last_published}";
fi;
echo "${_VERSION}" > "${_file_last_published}";
fi;
else
echo "[!] Missing either GITEA_UPLOAD_FILENAME, GITEA_URL_DL, GITEA_URL_PUSH, GITEA_USER or GITEA_TOKEN environment variable";
+9 -3
View File
@@ -58,15 +58,21 @@ class File
* else returns '' for any other finfo read problem
*
* @param string $read_file File to read, relative or absolute path
* @return string
* @return string mime type
* @throws \UnexpectedValueException if file cannot be read or is not a file
* @throws \RangeException if we cannot get a mime type and throw exception is on
*/
public static function getMimeType(string $read_file): string
{
$finfo = new \finfo(FILEINFO_MIME_TYPE);
if (!is_file($read_file)) {
if (!is_file($read_file) || !is_readable($read_file)) {
throw new \UnexpectedValueException('[getMimeType] File not found: ' . $read_file);
}
return $finfo->file($read_file) ?: '';
$mime_type = $finfo->file($read_file);
if ($mime_type === false) {
throw new \RangeException('[getMimeType] Cannot get mime type for: ' . $read_file);
}
return $mime_type;
}
}
+2 -2
View File
@@ -133,7 +133,7 @@ class DateTime
} else {
for ($i = 0, $iMax = count($timegroups); $i < $iMax; $i++) {
$output = floor((float)$timestamp / $timegroups[$i]);
$timestamp = (float)$timestamp % $timegroups[$i];
$timestamp = $timestamp % $timegroups[$i];
// output has days|hours|min|sec
if ($output || $time_string) {
$time_string .= $output . $labels[$i] . (($i + 1) != count($timegroups) ? ' ' : '');
@@ -453,7 +453,7 @@ class DateTime
}
if (isset($matches[11]) && is_numeric($matches[11])) {
// for milliseconds, we need to divide by 1000 and add them
$timestamp += (float)($matches[11] / 1000);
$timestamp += ((float)$matches[11] / 1000);
}
if ($negative) {
// cast to float so we can do a negative multiplication
+1 -1
View File
@@ -154,7 +154,7 @@ class Byte
if (!empty($matches[1])) {
$number_negative = true;
}
if (isset($matches[2]) && isset($matches[3])) {
if (isset($matches[2])) {
// remove all non valid characters from the number
$number = preg_replace('/[^0-9\.]/', '', $matches[2]);
// final clean up and convert to float
+6 -6
View File
@@ -957,9 +957,9 @@ class Color
* Undocumented function
*
* @param HWB $hwb
* @return Lch
* @return LCH
*/
public static function hwbToLch(HWB $hwb): Lch
public static function hwbToLch(HWB $hwb): LCH
{
return self::rgbToLch(
self::hwbToRgb($hwb)
@@ -1078,10 +1078,10 @@ class Color
/**
* OkLab to Lch (CIE)
*
* @param LAB $lab
* @param Lab $lab
* @return LCH
*/
public static function okLabToLch(LAB $lab): LCH
public static function okLabToLch(Lab $lab): LCH
{
return self::labToLch(
self::okLabToLab($lab)
@@ -1092,9 +1092,9 @@ class Color
* Lch (CIE) to OkLab
*
* @param LCH $lch
* @return LAB
* @return Lab
*/
public static function lchToOkLab(LCH $lch): LAB
public static function lchToOkLab(LCH $lch): Lab
{
return self::labToOkLab(
self::lchToLab($lch)
+25 -2
View File
@@ -27,10 +27,14 @@ class Json
* set original value as array
* @return array<mixed> returns an array from the json values
*/
public static function jsonConvertToArray(?string $json, bool $override = false): array
public static function jsonConvertToArray(?string $json, bool $override = false, int $flags = 0): array
{
if ($json !== null) {
$_json = json_decode($json, true);
// if flags has JSON_THROW_ON_ERROR remove it
if ($flags & JSON_THROW_ON_ERROR) {
$flags = $flags & ~JSON_THROW_ON_ERROR;
}
$_json = json_decode($json, true, flags:$flags);
if (self::$json_last_error = json_last_error()) {
if ($override == true) {
// init return as array with original as element
@@ -65,6 +69,25 @@ class Json
return (string)$json_string;
}
/**
* Validate if a json string could be decoded.
* Weill set the internval last error state and info can be read with jsonGetLastError
*
* @param string $json
* @param int $flags only JSON_INVALID_UTF8_IGNORE is currently allowed
* @return bool
* @throws \InvalidArgumentException if flags is invalid
*/
public static function jsonValidate(string $json, int $flags = 0): bool
{
if ($flags != 0 && $flags != JSON_INVALID_UTF8_IGNORE) {
throw new \InvalidArgumentException("For flag only 0 or JSON_INVALID_UTF8_IGNORE is allwed: " . $flags);
}
$json_valid = json_validate($json, flags:$flags);
self::$json_last_error = json_last_error();
return $json_valid;
}
/**
* returns human readable string for json errors thrown in jsonConvertToArray
* Source: https://www.php.net/manual/en/function.json-last-error.php
+1 -1
View File
@@ -49,7 +49,7 @@ class RandomKey
private static function validateRandomKeyData(array ...$key_range): string
{
$key_character_range = Strings::buildCharStringFromLists(...$key_range);
if (strlen(self::$key_character_range) <= 1) {
if (strlen($key_character_range) <= 1) {
return '';
}
return $key_character_range;
+12 -6
View File
@@ -2562,21 +2562,27 @@ class IO
// set field names
$this->cursor_ext[$query_hash]['field_names'] = [];
for ($i = 0; $i < $this->cursor_ext[$query_hash]['num_fields']; $i++) {
$this->cursor_ext[$query_hash]['field_names'][] =
$this->db_functions->__dbFieldName(
if (
($field_name = $this->db_functions->__dbFieldName(
$this->cursor_ext[$query_hash]['cursor'],
$i
);
)) !== false
) {
$this->cursor_ext[$query_hash]['field_names'][] = $field_name;
}
}
$this->field_names = $this->cursor_ext[$query_hash]['field_names'];
// field types
$this->cursor_ext[$query_hash]['field_types'] = [];
for ($i = 0; $i < $this->cursor_ext[$query_hash]['num_fields']; $i++) {
$this->cursor_ext[$query_hash]['field_types'][] =
$this->db_functions->__dbFieldType(
if (
($field_type = $this->db_functions->__dbFieldType(
$this->cursor_ext[$query_hash]['cursor'],
$i
);
)) !== false
) {
$this->cursor_ext[$query_hash]['field_types'][] = $field_type;
}
}
$this->field_types = $this->cursor_ext[$query_hash]['field_types'];
// combined name => type
+1 -1
View File
@@ -51,7 +51,7 @@ enum Convert: int
/**
* Get internal name from int value
*
* @param int $value
* @param int $value
* @return self
*/
public static function fromValue(int $value): self
+2 -2
View File
@@ -134,8 +134,8 @@ class Support
* Convert bool value to string value. Short name alias for printBool
*
* @param bool $bool Bool value to be transformed
* @param string $true [='true'] Override default string 'true'
* @param string $false [=false'] Override default string 'false'
* @param string $true [=true] Override default string 'true'
* @param string $false [=false] Override default string 'false'
* @return string $true or $false string for true/false bool
*/
public static function prBl(
+1 -1
View File
@@ -63,7 +63,7 @@ enum Flag: int
/**
* Get internal name from int value
*
* @param int $value
* @param value-of<self::VALUES> $value
* @return self
*/
public static function fromValue(int $value): self
+5 -5
View File
@@ -178,11 +178,11 @@ class Elements
"/(href=\")?(\>)?\b($protRegex)([\w\.\-?&=+%#~,;\/]+)\b([\.\-?&=+%#~,;\/]*)(\|([^\||^#]+)(#([^\|]+))?\|)?/",
function ($matches) {
return self::createUrl(
$matches[1] ?? '',
$matches[2] ?? '',
$matches[3] ?? '',
$matches[4] ?? '',
$matches[5] ?? '',
$matches[1],
$matches[2],
$matches[3],
$matches[4],
$matches[5],
$matches[7] ?? '',
$matches[9] ?? ''
);
@@ -164,6 +164,51 @@ final class CoreLibsConvertJsonTest extends TestCase
);
}
/**
* test with flags
*
* @covers ::jsonConvertToArray
* @testdox jsonConvertToArray flag test, if flag is used
*
* @return void
*/
public function testJsonConvertToArrayWithFlags(): void
{
$input = '{"valid":"json","invalid":"\xB1\x31"}';
/* $expected_without_flag = [
'valid' => 'json'
];
$expected_with_flag = [
'valid' => 'json',
'invalid' => "\xB1\x31"
]; */
// no idea why in both it throws an erro
$expected_without_flag = [];
$expected_with_flag = [];
$this->assertEquals(
$expected_without_flag,
\CoreLibs\Convert\Json::jsonConvertToArray($input)
);
$this->assertEquals(
$expected_with_flag,
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_INVALID_UTF8_IGNORE)
);
}
public function testJsonConvertToArrayRemoveThrowFlag(): void
{
$input = '{"valid":"json","invalid":"\xB1\x31"}';
// show NOT throw an exception
try {
$this->assertEquals(
[],
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_THROW_ON_ERROR)
);
} catch (\Exception $e) {
$this->fail('Exception was thrown despite flag removal');
}
}
/**
* test json error states
*
@@ -189,6 +234,81 @@ final class CoreLibsConvertJsonTest extends TestCase
);
}
/**
* test json error states
*
* @covers ::jsonValidate
* @dataProvider jsonErrorProvider
* @testdox jsonValidate $input will be $expected_i/$expected_s [$_dataName]
*
* @param string|null $input
* @param int $expected_i
* @param string $expected_s
* @return void
*/
public function testJsonValidateGetLastError(?string $input, int $expected_i, string $expected_s): void
{
\CoreLibs\Convert\Json::jsonValidate($input);
$this->assertEquals(
$expected_i,
\CoreLibs\Convert\Json::jsonGetLastError()
);
$this->assertEquals(
$expected_s,
\CoreLibs\Convert\Json::jsonGetLastError(true)
);
}
/**
* test json validation
*
* @covers ::jsonValidate
* @testdox jsonValidate test valid and invalid json
*
* @return void
*/
public function testJsonValidate(): void
{
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}')
);
$this->assertFalse(
\CoreLibs\Convert\Json::jsonValidate('not valid json')
);
}
/**
* Check if invalid flag throws exception
*
* @covers ::jsonValidate
* @testdox jsonValidate test exception thrown on invalid flag
*
* @return void
*/
public function testJsonValidateInvalidFlag(): void
{
$this->expectException("\InvalidArgumentException");
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', 5);
}
/**
* Check if valid flag throws no exception
*
* @covers ::jsonValidate
* @testdox jsonValidate test no exception on valid flag
*
* @return void
*/
public function testJsonValidateValidflag(): void
{
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', 0)
);
$this->assertTrue(
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}', JSON_INVALID_UTF8_IGNORE)
);
}
/**
* Undocumented function
*
-1
View File
@@ -45,7 +45,6 @@ use CoreLibs\DB\Support\ConvertPlaceholder;
* Test class for DB\IO + DB\SQL\PgSQL
* This will only test the PgSQL parts
* @coversDefaultClass \CoreLibs\DB\IO
* @coversDefaultClass \CoreLibs\DB\SQL\PgSQL
* @testdox \CoreLibs\DB\IO method tests for SQL\PgSQL
*/
final class CoreLibsDBIOTest extends TestCase
+1 -1
View File
@@ -1,7 +1,7 @@
<?php
$set = 0;
foreach (['/../../www', '/../www', '/../..', '/..', '/../../src', '/../src'] as $src) {
foreach (['/../../www', '/../www', '/../../src', '/../src', '/../..', '/..'] as $src) {
if (is_file(dirname(__DIR__) . $src . '/vendor/autoload.php')) {
require dirname(__DIR__) . $src . '/vendor/autoload.php';
$set = 1;