Compare commits

...

13 Commits

Author SHA1 Message Date
Clemens Schwaighofer
d06769c48b empty admin folder page for edit base page creation tests 2023-09-27 11:38:32 +09:00
Clemens Schwaighofer
4c0390f082 ErrorMessage class: add notice for non error logging to log file
info is already used for write back to front. So we use notice for
non error level messages into the log file
2023-09-27 11:37:26 +09:00
Clemens Schwaighofer
95bee3dc8c Update DB\IO dbWriteDataExt to allow null primary key
So we do not get an error on a new data call with a null primary key
2023-09-27 11:22:16 +09:00
Clemens Schwaighofer
65132d8a4a Fix DB\ArrayIO access to unset pk_id 2023-09-27 09:41:41 +09:00
Clemens Schwaighofer
b2243cd06d Add EditOrder dummy template class for edit_order page
without this dummy class the Form\Generate cannot load.

We don't need it, except for the set page name
2023-09-26 18:36:29 +09:00
Clemens Schwaighofer
8f09b67d86 Update for phpunit tests 2023-09-15 18:31:41 +09:00
Clemens Schwaighofer
fe459aec80 Update ErrorMsg with optional target_style string for one style
Applied to master or to target style
2023-09-15 18:22:38 +09:00
Clemens Schwaighofer
de0ed058ca ErrorMessage: new flag for logging 'error' level to log 2023-09-11 13:35:35 +09:00
Clemens Schwaighofer
f90bd193d9 Change setError to setMessage to make it clear what is the corret name 2023-09-08 18:54:44 +09:00
Clemens Schwaighofer
0e31180868 Rename setErrorMsgLevel to setError for backend calls 2023-09-08 18:47:44 +09:00
Clemens Schwaighofer
68c9164eaa New ErrorMessage class for frontend return error messages 2023-09-08 18:30:05 +09:00
Clemens Schwaighofer
c2389db1c9 Composer updates 2023-09-08 18:30:02 +09:00
Clemens Schwaighofer
f9558cd3aa Fix for the SetVarType / SetVarTypeNull
string: if it is stringable in anyway, set string (it converts)
this is not check IF it is a string value as it was before
int/float: same, if it is numerc it will be convert to int or float
All other stay the same

Note "set ..." imply to set, and not to convert to 0 if it is int
string that can be covnerted to int
2023-09-05 14:26:57 +09:00
29 changed files with 1046 additions and 143 deletions

View File

@@ -43,12 +43,17 @@ final class CoreLibsConvertSetVarTypeNullTest extends TestCase
'int, no override' => [
1,
null,
null
'1'
],
'int, override set' => [
1,
'not int',
'not int'
'1'
],
'array, override set' => [
[1, 2],
null,
null
]
];
}
@@ -201,7 +206,7 @@ final class CoreLibsConvertSetVarTypeNullTest extends TestCase
'float' => [
1.5,
null,
null
1
]
];
}
@@ -349,7 +354,7 @@ final class CoreLibsConvertSetVarTypeNullTest extends TestCase
'int' => [
1,
null,
null
1.0
]
];
}

View File

@@ -43,11 +43,16 @@ final class CoreLibsConvertSetVarTypeTest extends TestCase
'int, no override' => [
1,
null,
''
'1'
],
'int, override set' => [
1,
'not int',
'1'
],
'array, override set' => [
[1, 2],
'not int',
'not int'
]
];
@@ -189,7 +194,7 @@ final class CoreLibsConvertSetVarTypeTest extends TestCase
'float' => [
1.5,
null,
0
1
]
];
}
@@ -330,7 +335,7 @@ final class CoreLibsConvertSetVarTypeTest extends TestCase
'int' => [
1,
null,
0.0
1.0
]
];
}
@@ -341,7 +346,7 @@ final class CoreLibsConvertSetVarTypeTest extends TestCase
* @dataProvider varSetTypeFloatProvider
* @testdox setFloat $input with override $default will be $expected [$_dataName]
*
* @param mixed $input
* @param mixed $input
* @param float|null $default
* @param float $expected
* @return void

View File

@@ -0,0 +1,370 @@
<?php
declare(strict_types=1);
namespace tests;
use PHPUnit\Framework\TestCase;
use CoreLibs\Logging\Logger\Level;
/**
* Test class for Logging
* @coversDefaultClass \CoreLibs\Logging\ErrorMessages
* @testdox \CoreLibs\Logging\ErrorMEssages method tests
*/
final class CoreLibsLoggingErrorMessagesTest extends TestCase
{
private const LOG_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR;
/**
* tear down and remove log data
*
* @return void
*/
public static function tearDownAfterClass(): void
{
array_map('unlink', glob(self::LOG_FOLDER . '*.log'));
}
/**
* for checking level only
*
* @return array
*/
public function providerErrorMessageLevel(): array
{
return [
'ok' => [
'level' => 'ok',
'str' => 'OK',
'expected' => 'ok',
],
'info' => [
'level' => 'info',
'str' => 'INFO',
'expected' => 'info',
],
'notice' => [
'level' => 'notice',
'str' => 'NOTICE',
'expected' => 'notice',
],
'warn' => [
'level' => 'warn',
'str' => 'WARN',
'expected' => 'warn'
],
'warning' => [
'level' => 'warning',
'str' => 'WARN',
'expected' => 'warn'
],
'error' => [
'level' => 'error',
'str' => 'ERROR',
'expected' => 'error'
],
'abort' => [
'level' => 'abort',
'str' => 'ABORT',
'expected' => 'abort'
],
'crash' => [
'level' => 'crash',
'str' => 'CRASH',
'expected' => 'crash'
],
'wrong level' => [
'level' => 'wrong',
'str' => 'WRONG',
'expected' => 'unknown'
]
];
}
/**
* Undocumented function
*
* @dataProvider providerErrorMessageLevel
* @testdox error message level: $level will be $expected [$_dataName]
*
* @param string $level
* @param string $str
* @param string $expected
* @return void
*/
public function testErrorMessageLevelOk(string $level, string $str, string $expected): void
{
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug,
]);
$em = new \CoreLibs\Logging\ErrorMessage($log);
$em->setMessage(
$level,
$str
);
$this->assertEquals(
[
'level' => $expected,
'str' => $str,
'id' => '',
'target' => '',
'target_style' => '',
'highlight' => [],
],
$em->getLastErrorMsg()
);
}
/**
* Undocumented function
*
* @testdox Test of all methods for n messages [$_dataName]
*
* @return void
*/
public function testErrorMessageOk(): void
{
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug
]);
$em = new \CoreLibs\Logging\ErrorMessage($log);
$em->setErrorMsg(
'100',
'info',
'INFO MESSAGE'
);
$this->assertEquals(
[
'id' => '100',
'level' => 'info',
'str' => 'INFO MESSAGE',
'target' => '',
'target_style' => '',
'highlight' => [],
],
$em->getLastErrorMsg()
);
$this->assertEquals(
['100'],
$em->getErrorIds()
);
$this->assertEquals(
[
[
'id' => '100',
'level' => 'info',
'str' => 'INFO MESSAGE',
'target' => '',
'target_style' => '',
'highlight' => [],
]
],
$em->getErrorMsg()
);
$em->setErrorMsg(
'200',
'error',
'ERROR MESSAGE'
);
$this->assertEquals(
[
'id' => '200',
'level' => 'error',
'str' => 'ERROR MESSAGE',
'target' => '',
'target_style' => '',
'highlight' => [],
],
$em->getLastErrorMsg()
);
$this->assertEquals(
['100', '200'],
$em->getErrorIds()
);
$this->assertEquals(
[
[
'id' => '100',
'level' => 'info',
'str' => 'INFO MESSAGE',
'target' => '',
'target_style' => '',
'highlight' => [],
],
[
'id' => '200',
'level' => 'error',
'str' => 'ERROR MESSAGE',
'target' => '',
'target_style' => '',
'highlight' => [],
]
],
$em->getErrorMsg()
);
}
/**
* Undocumented function
*
* @return array
*/
public function providerErrorMessageLog(): array
{
return [
'error, not logged' => [
'id' => '200',
'level' => 'error',
'str' => 'ERROR MESSAGE',
'message' => null,
'log_error' => null,
'expected' => '<ERROR> ERROR MESSAGE',
],
'error, logged' => [
'id' => '200',
'level' => 'error',
'str' => 'ERROR MESSAGE',
'message' => null,
'log_error' => true,
'expected' => '<ERROR> ERROR MESSAGE',
],
'error, logged, message' => [
'id' => '200',
'level' => 'error',
'str' => 'ERROR MESSAGE',
'message' => 'OTHER ERROR MESSAGE',
'log_error' => true,
'expected' => '<ERROR> OTHER ERROR MESSAGE',
],
'notice' => [
'id' => '100',
'level' => 'notice',
'str' => 'NOTICE MESSAGE',
'message' => null,
'log_error' => null,
'expected' => '<NOTICE> NOTICE MESSAGE',
],
'notice, message' => [
'id' => '100',
'level' => 'notice',
'str' => 'NOTICE MESSAGE',
'message' => 'OTHER NOTICE MESSAGE',
'log_error' => null,
'expected' => '<NOTICE> OTHER NOTICE MESSAGE',
],
'crash' => [
'id' => '300',
'level' => 'crash',
'str' => 'CRASH MESSAGE',
'message' => null,
'log_error' => null,
'expected' => '<ALERT> CRASH MESSAGE',
],
'crash, message' => [
'id' => '300',
'level' => 'crash',
'str' => 'CRASH MESSAGE',
'message' => 'OTHER CRASH MESSAGE',
'log_error' => null,
'expected' => '<ALERT> OTHER CRASH MESSAGE',
],
'abort' => [
'id' => '200',
'level' => 'abort',
'str' => 'ABORT MESSAGE',
'message' => null,
'log_error' => null,
'expected' => '<CRITICAL> ABORT MESSAGE',
],
'abort, message' => [
'id' => '200',
'level' => 'abort',
'str' => 'ABORT MESSAGE',
'message' => 'OTHER ABORT MESSAGE',
'log_error' => null,
'expected' => '<CRITICAL> OTHER ABORT MESSAGE',
],
'unknown' => [
'id' => '400',
'level' => 'wrong level',
'str' => 'WRONG LEVEL MESSAGE',
'message' => null,
'log_error' => null,
'expected' => '<EMERGENCY> WRONG LEVEL MESSAGE',
],
'unknown, message' => [
'id' => '400',
'level' => 'wrong level',
'str' => 'WRONG LEVEL MESSAGE',
'message' => 'OTHER WRONG LEVEL MESSAGE',
'log_error' => null,
'expected' => '<EMERGENCY> OTHER WRONG LEVEL MESSAGE',
],
];
}
/**
* Undocumented function
*
* @dataProvider providerErrorMessageLog
* @testdox Test Log writing [$_dataName]
*
* @param string $id
* @param string $level
* @param string $str
* @param string|null $message
* @param bool|null $log_error
* @param string $expected
* @return void
*/
public function testErrorMessageLog(
string $id,
string $level,
string $str,
?string $message,
?bool $log_error,
string $expected
): void {
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug,
'log_per_run' => true
]);
$em = new \CoreLibs\Logging\ErrorMessage($log);
$em->setErrorMsg(
$id,
$level,
$str,
message: $message,
log_error: $log_error
);
$file_content = '';
if (is_file($log->getLogFolder() . $log->getLogFile())) {
$file_content = file_get_contents(
$log->getLogFolder() . $log->getLogFile()
) ?: '';
}
// if n
if ($level == 'error' && ($log_error === null || $log_error === false)) {
$this->assertStringNotContainsString(
$expected,
$file_content
);
} else {
$this->assertStringContainsString(
$expected,
$file_content
);
}
}
}
// __END__

36
composer.lock generated
View File

@@ -297,16 +297,16 @@
},
{
"name": "composer/semver",
"version": "3.3.2",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9"
"reference": "35e8d0af4486141bc745f23a29cc2091eb624a32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9",
"url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32",
"reference": "35e8d0af4486141bc745f23a29cc2091eb624a32",
"shasum": ""
},
"require": {
@@ -356,9 +356,9 @@
"versioning"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.3.2"
"source": "https://github.com/composer/semver/tree/3.4.0"
},
"funding": [
{
@@ -374,7 +374,7 @@
"type": "tidelift"
}
],
"time": "2022-04-01T19:23:25+00:00"
"time": "2023-08-31T09:50:34+00:00"
},
{
"name": "composer/xdebug-handler",
@@ -1133,16 +1133,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.23.1",
"version": "1.24.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26"
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26",
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"shasum": ""
},
"require": {
@@ -1174,22 +1174,22 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0"
},
"time": "2023-08-03T16:32:59+00:00"
"time": "2023-09-07T20:46:32+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.10.32",
"version": "1.10.34",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44"
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901",
"shasum": ""
},
"require": {
@@ -1238,7 +1238,7 @@
"type": "tidelift"
}
],
"time": "2023-08-24T21:54:50+00:00"
"time": "2023-09-13T09:49:47+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",

View File

@@ -248,17 +248,17 @@
},
{
"name": "composer/semver",
"version": "3.3.2",
"version_normalized": "3.3.2.0",
"version": "3.4.0",
"version_normalized": "3.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9"
"reference": "35e8d0af4486141bc745f23a29cc2091eb624a32"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/3953f23262f2bff1919fc82183ad9acb13ff62c9",
"reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9",
"url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32",
"reference": "35e8d0af4486141bc745f23a29cc2091eb624a32",
"shasum": ""
},
"require": {
@@ -268,7 +268,7 @@
"phpstan/phpstan": "^1.4",
"symfony/phpunit-bridge": "^4.2 || ^5"
},
"time": "2022-04-01T19:23:25+00:00",
"time": "2023-08-31T09:50:34+00:00",
"type": "library",
"extra": {
"branch-alias": {
@@ -310,9 +310,9 @@
"versioning"
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.3.2"
"source": "https://github.com/composer/semver/tree/3.4.0"
},
"funding": [
{
@@ -1129,17 +1129,17 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.23.1",
"version_normalized": "1.23.1.0",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26"
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26",
"reference": "846ae76eef31c6d7790fac9bc399ecee45160b26",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"shasum": ""
},
"require": {
@@ -1156,7 +1156,7 @@
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"time": "2023-08-03T16:32:59+00:00",
"time": "2023-09-07T20:46:32+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -1173,23 +1173,23 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues",
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.23.1"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0"
},
"install-path": "../phpstan/phpdoc-parser"
},
{
"name": "phpstan/phpstan",
"version": "1.10.32",
"version_normalized": "1.10.32.0",
"version": "1.10.34",
"version_normalized": "1.10.34.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44"
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901",
"shasum": ""
},
"require": {
@@ -1198,7 +1198,7 @@
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2023-08-24T21:54:50+00:00",
"time": "2023-09-13T09:49:47+00:00",
"bin": [
"phpstan",
"phpstan.phar"

View File

@@ -38,9 +38,9 @@
'dev_requirement' => true,
),
'composer/semver' => array(
'pretty_version' => '3.3.2',
'version' => '3.3.2.0',
'reference' => '3953f23262f2bff1919fc82183ad9acb13ff62c9',
'pretty_version' => '3.4.0',
'version' => '3.4.0.0',
'reference' => '35e8d0af4486141bc745f23a29cc2091eb624a32',
'type' => 'library',
'install_path' => __DIR__ . '/./semver',
'aliases' => array(),
@@ -182,18 +182,18 @@
'dev_requirement' => true,
),
'phpstan/phpdoc-parser' => array(
'pretty_version' => '1.23.1',
'version' => '1.23.1.0',
'reference' => '846ae76eef31c6d7790fac9bc399ecee45160b26',
'pretty_version' => '1.24.0',
'version' => '1.24.0.0',
'reference' => '3510b0a6274cc42f7219367cb3abfc123ffa09d6',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpdoc-parser',
'aliases' => array(),
'dev_requirement' => true,
),
'phpstan/phpstan' => array(
'pretty_version' => '1.10.32',
'version' => '1.10.32.0',
'reference' => 'c47e47d3ab03137c0e121e77c4d2cb58672f6d44',
'pretty_version' => '1.10.34',
'version' => '1.10.34.0',
'reference' => '7f806b6f1403e6914c778140e2ba07c293cb4901',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),

View File

@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
### [3.4.0] 2023-08-31
* Support larger major version numbers (#149)
### [3.3.2] 2022-04-01
* Fixed handling of non-string values (#134)
@@ -175,6 +179,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint`
* Changed: code style using php-cs-fixer.
[3.4.0]: https://github.com/composer/semver/compare/3.3.2...3.4.0
[3.3.2]: https://github.com/composer/semver/compare/3.3.1...3.3.2
[3.3.1]: https://github.com/composer/semver/compare/3.3.0...3.3.1
[3.3.0]: https://github.com/composer/semver/compare/3.2.9...3.3.0

View File

@@ -6,8 +6,9 @@ Semver (Semantic Versioning) library that offers utilities, version constraint p
Originally written as part of [composer/composer](https://github.com/composer/composer),
now extracted and made available as a stand-alone library.
[![Continuous Integration](https://github.com/composer/semver/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/semver/actions)
[![Continuous Integration](https://github.com/composer/semver/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/continuous-integration.yml)
[![PHP Lint](https://github.com/composer/semver/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/lint.yml)
[![PHPStan](https://github.com/composer/semver/actions/workflows/phpstan.yml/badge.svg?branch=main)](https://github.com/composer/semver/actions/workflows/phpstan.yml)
Installation
------------
@@ -15,7 +16,7 @@ Installation
Install the latest version with:
```bash
$ composer require composer/semver
composer require composer/semver
```

View File

@@ -27,7 +27,7 @@
}
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues"
},
"require": {

View File

@@ -0,0 +1,11 @@
parameters:
ignoreErrors:
-
message: "#^Parameter \\#1 \\$operator of class Composer\\\\Semver\\\\Constraint\\\\Constraint constructor expects '\\!\\='\\|'\\<'\\|'\\<\\='\\|'\\<\\>'\\|'\\='\\|'\\=\\='\\|'\\>'\\|'\\>\\=', non\\-falsy\\-string given\\.$#"
count: 1
path: src/VersionParser.php
-
message: "#^Strict comparison using \\=\\=\\= between null and non\\-empty\\-string will always evaluate to false\\.$#"
count: 2
path: src/VersionParser.php

View File

@@ -134,15 +134,15 @@ class VersionParser
}
// match classical versioning
if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
if (preg_match('{^v?(\d{1,5}+)(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = $matches[1]
. (!empty($matches[2]) ? $matches[2] : '.0')
. (!empty($matches[3]) ? $matches[3] : '.0')
. (!empty($matches[4]) ? $matches[4] : '.0');
$index = 5;
// match date(time) based versioning
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = preg_replace('{\D}', '.', $matches[1]);
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3}){0,2})' . self::$modifierRegex . '$}i', $version, $matches)) {
$version = (string) preg_replace('{\D}', '.', $matches[1]);
$index = 2;
}
@@ -260,16 +260,16 @@ class VersionParser
}
$orGroups = array();
foreach ($orConstraints as $constraints) {
$andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
foreach ($orConstraints as $orConstraint) {
$andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
if (false === $andConstraints) {
throw new \RuntimeException('Failed to preg_split string: '.$constraints);
throw new \RuntimeException('Failed to preg_split string: '.$orConstraint);
}
if (\count($andConstraints) > 1) {
$constraintObjects = array();
foreach ($andConstraints as $constraint) {
foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
$constraintObjects[] = $parsedConstraint;
foreach ($andConstraints as $andConstraint) {
foreach ($this->parseConstraint($andConstraint) as $parsedAndConstraint) {
$constraintObjects[] = $parsedAndConstraint;
}
}
} else {
@@ -285,11 +285,11 @@ class VersionParser
$orGroups[] = $constraint;
}
$constraint = MultiConstraint::create($orGroups, false);
$parsedConstraint = MultiConstraint::create($orGroups, false);
$constraint->setPrettyString($prettyConstraint);
$parsedConstraint->setPrettyString($prettyConstraint);
return $constraint;
return $parsedConstraint;
}
/**

View File

@@ -682,24 +682,34 @@ class PhpDocParser
$tokens->dropSavePoint(); // because of ConstFetchNode
}
$exception = new ParserException(
$tokens->currentTokenValue(),
$tokens->currentTokenType(),
$tokens->currentTokenOffset(),
Lexer::TOKEN_IDENTIFIER,
null,
$tokens->currentTokenLine()
);
$currentTokenValue = $tokens->currentTokenValue();
$currentTokenType = $tokens->currentTokenType();
$currentTokenOffset = $tokens->currentTokenOffset();
$currentTokenLine = $tokens->currentTokenLine();
try {
$constExpr = $this->doctrineConstantExprParser->parse($tokens, true);
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
return $constExpr;
} catch (LogicException $e) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
}
@@ -1117,15 +1127,13 @@ class PhpDocParser
{
if ($tokens->isCurrentTokenType(Lexer::TOKEN_THIS_VARIABLE)) {
$parameter = '$this';
$requirePropertyOrMethod = true;
$tokens->next();
} else {
$parameter = $tokens->currentTokenValue();
$requirePropertyOrMethod = false;
$tokens->consumeTokenType(Lexer::TOKEN_VARIABLE);
}
if ($requirePropertyOrMethod || $tokens->isCurrentTokenType(Lexer::TOKEN_ARROW)) {
if ($tokens->isCurrentTokenType(Lexer::TOKEN_ARROW)) {
$tokens->consumeTokenType(Lexer::TOKEN_ARROW);
$propertyOrMethod = $tokens->currentTokenValue();

View File

@@ -196,28 +196,45 @@ class TypeParser
$tokens->dropSavePoint(); // because of ConstFetchNode
}
$exception = new ParserException(
$tokens->currentTokenValue(),
$tokens->currentTokenType(),
$tokens->currentTokenOffset(),
Lexer::TOKEN_IDENTIFIER,
null,
$tokens->currentTokenLine()
);
$currentTokenValue = $tokens->currentTokenValue();
$currentTokenType = $tokens->currentTokenType();
$currentTokenOffset = $tokens->currentTokenOffset();
$currentTokenLine = $tokens->currentTokenLine();
if ($this->constExprParser === null) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
try {
$constExpr = $this->constExprParser->parse($tokens, true);
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
return $this->enrichWithAttributes($tokens, new Ast\Type\ConstTypeNode($constExpr), $startLine, $startIndex);
} catch (LogicException $e) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
}
@@ -600,23 +617,33 @@ class TypeParser
}
}
$exception = new ParserException(
$tokens->currentTokenValue(),
$tokens->currentTokenType(),
$tokens->currentTokenOffset(),
Lexer::TOKEN_IDENTIFIER,
null,
$tokens->currentTokenLine()
);
$currentTokenValue = $tokens->currentTokenValue();
$currentTokenType = $tokens->currentTokenType();
$currentTokenOffset = $tokens->currentTokenOffset();
$currentTokenLine = $tokens->currentTokenLine();
if ($this->constExprParser === null) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
try {
$constExpr = $this->constExprParser->parse($tokens, true);
if ($constExpr instanceof Ast\ConstExpr\ConstExprArrayNode) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
$type = new Ast\Type\ConstTypeNode($constExpr);
@@ -631,7 +658,14 @@ class TypeParser
return $type;
} catch (LogicException $e) {
throw $exception;
throw new ParserException(
$currentTokenValue,
$currentTokenType,
$currentTokenOffset,
Lexer::TOKEN_IDENTIFIER,
null,
$currentTokenLine
);
}
}

Binary file not shown.

View File

@@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmTn0ZAACgkQUcZzBf/C
5cCXIA/9Gmo24JCtSO2yzad3Gi+Jlv0kJtbTMiFgnteWGOq+eXDVC4o9A8I671ei
wkVuv2Gesez0hCcEvFT+QIUwS/xek3tvlGEqj7y9QPtPjhWb1x8hLyy8mlxwhFQh
w17ecQncsyRH0yLkNJB8LkMNNi6t+EjZfrxtyezeKGfVT8HM439Wy/VjccybcJEc
+8Ld5odxf9WINDUq2D+ysiQ9uW0EJsaxe227SZ4Vm9MgPQw0PFFMXxWn96Bb/Eyv
ryB8nKL/Hp3nVzcQdcjaZ4L9K6aH0FO4VtSSdSYaHA3jVxTBugr19FTHiWEEJalS
zv0j97fDkH4xlnzuW74j/35rOqZlMd6NBzS0/eHvpuJ6kfz0KPHXnhW3EQWu6cTY
MTrXo5CfSAfpsMSp6w1evnDRS4z9pqNQ5hmdA2hl+3qTwixyYjP19EKxKfTWC7Qr
o7SwJruaCl6MfQ3dTtvZrRYtvDyJxIUKXGlAaUMA2NP4rh7vUWGwgSJmSwaSs9wP
Fv5cTJ+NO3XRDF5RaWF/MNWH1JjupCwQxlsQthW8Dyy1W2pMtv84AY8jk508boo1
9nEIa/nrKbmjz2fSuIWWVVKrUD6qR5JpF4Odd4p+NR0h8WT/2JAF9rW38WZXWrmh
MsSLy056l96wOB3CnNWtCx7M2FXXGlcOK61Kv7+ybu4A6oFybGg=
=4S4l
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmUBhZwACgkQUcZzBf/C
5cDAIA/+JOxOdWCg6b1+/Bs4Opm7cmILJzh3Rw1366MzXFHJhe2n7exemzTE3X2E
0HTjVVWoE0MpTt6knBgb+dulXTGm+yzJNIRLnCJFhsSdwUcxNAZMPozliZszGMcC
HhGC1Ya7RU5d9WEg/lCAKRjNgSeY8VTRRfa49m6TQPQwGinXBNpH6q665feziUX5
NB+rBMaWUDKp6GelPVrezEfME+SMfT66hW31n5m5paTwT+khk2Cenub5xXBUyXtz
saxSayOShlUPN8kZKOjS/L/FPnOApGwcKxkX2kMK0qDs8YQFYHibNgnyhrEOBRD1
UV9kBiU1+LUuxDcya8f0qo/gk6QN7Y/ywnIY3kTkqTYchCAAO+osu1amLYlInBSu
r0LtQQ8+/llQ/bP0XS6cC6247J1fxO9xYMMmKVBfJrul3Wi6ETRI5WIdEQTSc2Z+
rE00JY2X/vxJijUyGZ88+QDX3z7vGyaQJZiXq1XyjmBYw6w8UlxhGZcGGDIbTsb7
lACLR/t4hgtE69QXW+L4P2ngU0agk5XXojg/+r+CnCWD/TdKcvs1WTn4TyuMZOLa
2XF3h9/H0XMfE5LPlNJmb4YRjYjcNvPQwmGI4dmUMCJuTpjHUnpFXfswu4xgsaYV
xq756DVfrRyG9PyXFfJZ66P7jt5+wisrVsWh/X3nX69P0ruwwss=
=aOCq
-----END PGP SIGNATURE-----

View File

@@ -0,0 +1,54 @@
<?php // phpcs:ignore warning
/**
* @phan-file-suppress PhanTypeSuspiciousStringExpression
*/
declare(strict_types=1);
error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR);
ob_start();
// basic class test file
define('USE_DATABASE', false);
// sample config
require 'config.php';
// define log file id
$LOG_FILE_ID = 'classTest-error_msg';
ob_end_flush();
use CoreLibs\Logging\Logger\MessageLevel as ml;
$log = new CoreLibs\Logging\Logging([
'log_folder' => BASE . LOG,
'log_file_id' => $LOG_FILE_ID,
'log_per_date' => true,
]);
$PAGE_NAME = 'TEST CLASS: ERROR MSG';
print "<!DOCTYPE html>";
print "<html><head><title>" . $PAGE_NAME . "</title><head>";
print "<body>";
print '<div><a href="class_test.php">Class Test Master</a></div>';
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
$em = new \CoreLibs\Logging\ErrorMessage($log);
print "FN: " . ml::fromName('Affe')->name . "<br>";
print "NU: " . ml::fromValue(100)->name . "<br>";
print "NU: " . ml::fromValue(1000)->name . "<br>";
$em->setErrorMsg('123', 'error', 'msg this is bad, not logged');
$em->setErrorMsg('123', 'error', 'msg this is bad, not logged', 'target-id', 'other-style');
$em->setErrorMsg('123', 'error', 'msg this is bad, logged', log_error:true);
$em->setErrorMsg('1000', 'info', 'This is good');
$em->setErrorMsg('9999', 'abort', 'BAD: This is critical (abort)');
$em->setErrorMsg('10-1000', 'wrong', 'Wrong level: This is emergency');
print "ErrorsLast: <pre>" . $log->prAr($em->getLastErrorMsg()) . "</pre>";
print "ErrorsIds: <pre>" . $log->prAr($em->getErrorIds()) . "</pre>";
print "Errors: <pre>" . $log->prAr($em->getErrorMsg()) . "</pre>";
print "</body></html>";
// __END__

View File

@@ -15,7 +15,7 @@ define('USE_DATABASE', false);
// sample config
require 'config.php';
// define log file id
$LOG_FILE_ID = 'classTest-datetime';
$LOG_FILE_ID = 'classTest-file';
ob_end_flush();
use CoreLibs\Check\File;

View File

@@ -115,6 +115,7 @@ $test_files = [
'class_test.config.link.php' => 'Class Test: CONFIG LINK',
'class_test.config.direct.php' => 'Class Test: CONFIG DIRECT',
'class_test.class-calls.php' => 'Class Test: CLASS CALLS',
'class_test.error_msg.php' => 'Class Test: ERROR MSG',
'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB',
];

View File

@@ -0,0 +1,6 @@
<?php
// empty file for add and remove test
// __END__

View File

@@ -35,6 +35,8 @@ class EditBase
private \CoreLibs\Output\Form\Generate $form;
/** @var \CoreLibs\Logging\Logging */
public \CoreLibs\Logging\Logging $log;
/** @var \CoreLibs\Language\L10n */
public \CoreLibs\Language\L10n $l;
/** @var \CoreLibs\ACL\Login */
public \CoreLibs\ACL\Login $login;
@@ -57,6 +59,7 @@ class EditBase
) {
$this->log = $log;
$this->login = $login;
$this->l = $l10n;
// smarty template engine (extended Translation version)
$this->smarty = new \CoreLibs\Template\SmartyExtend(
$l10n,
@@ -77,7 +80,7 @@ class EditBase
echo "I am sorry, but this page cannot be viewed by a mobile phone";
exit;
}
// $this->form->log->debug('POST', $this->form->log->prAr($_POST));
// $this->log->debug('POST', $this->log->prAr($_POST));
}
/**
@@ -179,7 +182,7 @@ class EditBase
} // while read data ...
// html title
$this->HEADER['HTML_TITLE'] = $this->form->l->__('Edit Order');
$this->HEADER['HTML_TITLE'] = $this->l->__('Edit Order');
$messages = [];
$error = $_POST['error'] ?? 0;
@@ -632,7 +635,7 @@ class EditBase
'editAdmin_' . $this->smarty->lang
);
$this->form->log->debug('DEBUGEND', '==================================== [Form END]');
$this->log->debug('DEBUGEND', '==================================== [Form END]');
}
}

View File

@@ -26,8 +26,12 @@ class SetVarTypeMain
?string $default = null,
bool $to_null = false
): ?string {
if (is_string($val)) {
return $val;
if (
$val === null ||
is_scalar($val) ||
$val instanceof \Stringable
) {
return (string)$val;
}
if ($to_null === false) {
return (string)$default;
@@ -39,6 +43,7 @@ class SetVarTypeMain
* Will convert input data to string if possible.
* Runs for string/int/float/bool/null
* Will skip array/object/resource/callable/etc and use default for that
* Note: this is pretty much the same as setStrMain because string is easy
*
* @param mixed $val Input variable
* @param string|null $default Default value
@@ -71,6 +76,7 @@ class SetVarTypeMain
/**
* If input variable is int, return it, else return default value. If to_null
* is true then null as return is allowed, else only int is returned
* Note, if float is sent in, int is returned
*
* @param mixed $val Input variable
* @param int|null $default Default value
@@ -82,8 +88,8 @@ class SetVarTypeMain
?int $default = null,
bool $to_null = false
): ?int {
if (is_int($val)) {
return $val;
if (is_numeric($val)) {
return (int)$val;
}
if ($to_null === false) {
return (int)$default;
@@ -129,6 +135,7 @@ class SetVarTypeMain
/**
* If input is float return it, else set to default value. If to_null is set
* to true, allow null return
* Note if an int is sent in, float is returned
*
* @param mixed $val Input variable
* @param float|null $default Default value
@@ -140,8 +147,8 @@ class SetVarTypeMain
?float $default = null,
bool $to_null = false
): ?float {
if (is_float($val)) {
return $val;
if (is_numeric($val)) {
return (float)$val;
}
if ($to_null === false) {
return (float)$default;

View File

@@ -198,7 +198,7 @@ class ArrayIO extends \CoreLibs\DB\IO
public function dbCheckPkSet(): bool
{
// if pk_id is set, overrule ...
if ($this->pk_id) {
if (!empty($this->pk_id)) {
$this->table_array[$this->pk_name]['value'] = $this->pk_id;
}
// if not set ... produce error

View File

@@ -3232,7 +3232,7 @@ class IO
*
* @param array<mixed> $write_array list of elements to write
* @param array<mixed> $not_write_array list of elements not to write
* @param int $primary_key id key to decide if we write insert or update
* @param int|null $primary_key id key to decide if we write insert or update
* @param string $table name for the target table
* @param array<mixed> $data data array to override _POST data
* @return int|false primary key
@@ -3240,7 +3240,7 @@ class IO
public function dbWriteData(
array $write_array,
array $not_write_array,
int $primary_key,
?int $primary_key,
string $table,
array $data = []
): int|false {
@@ -3260,19 +3260,19 @@ class IO
* PARAM INFO: $primary key
* this can be a plain string/int and will be internal transformed into the array form
* or it takes the array form of array [row => column, value => pk value]
* @param array<mixed> $write_array list of elements to write
* @param int|string|array<mixed> $primary_key primary key string or array set
* @param string $table name for the target table
* @param array<mixed> $not_write_array list of elements not to write (optional)
* @param array<mixed> $not_write_update_array list of elements not
* to write during update (optional)
* @param array<mixed> $data optional array with data
* if not _POST vars are used
* @return int|false primary key
* @param array<mixed> $write_array list of elements to write
* @param null|int|string|array<mixed> $primary_key primary key string or array set
* @param string $table name for the target table
* @param array<mixed> $not_write_array list of elements not to write (optional)
* @param array<mixed> $not_write_update_array list of elements not
* to write during update (optional)
* @param array<mixed> $data optional array with data
* if not _POST vars are used
* @return int|false primary key
*/
public function dbWriteDataExt(
array $write_array,
int|string|array $primary_key,
null|int|string|array $primary_key,
string $table,
array $not_write_array = [],
array $not_write_update_array = [],

View File

@@ -0,0 +1,246 @@
<?php
/**
* AUTOR: Clemens Schwaighofer
* CREATED: 2023/9/7
* DESCRIPTION:
* General error collection class for output to frontend or to log
*/
declare(strict_types=1);
namespace CoreLibs\Logging;
use CoreLibs\Logging\Logger\MessageLevel;
class ErrorMessage
{
/** @var array<int,array{id:string,level:string,str:string,target:string,target_style:string,highlight:string[]}> */
private array $error_str = [];
/** @var \CoreLibs\Logging\Logging $log */
public \CoreLibs\Logging\Logging $log;
/** @var bool $log_error global flag to log error level message */
private bool $log_error = false;
/**
* init ErrorMessage
*
* @param \CoreLibs\Logging\Logging $log
* @param bool $log_error [=false]
*/
public function __construct(
\CoreLibs\Logging\Logging $log,
bool $log_error = false
) {
$this->log = $log;
$this->log_error = $log_error;
}
/**
* pushes new error message into the error_str array
* error_id: internal Error ID (should be unique)
* level: error level, can only be ok, info, warn, error, abort, crash
* ok and info are positive response: success
* notice: a debug message for information only
* warn: success, but there might be some things that are not 100% ok
* error: input error or error in executing request
* abort: an internal error happened as mandatory information that normally is
* there is missing, or the ACL level that should normally match does not
* will be logged to "critical"
* crash: system failure or critical system problems (db connection failure)
* will be logged as "alert"
* not set: unkown, will be logged as "emergency"
* target/highlight: id target name for frontend where to attach this message
* highlight is a list of other target points to highlight
* for highlight targets css names are $level without a prefix and should be
* nested in the target element "input .error { ... }"
* target_style: if not set uses 'error-' $level as css style. applies to targets or main only
*
* @param string $error_id Any internal error ID for this error
* @param string $level Error level in ok/info/warn/error
* @param string $str Error message (out)
* @param string $target alternate attachment point for this error message
* @param string $target_style Alternate color style for the error message
* @param array<string> $highlight Any additional error data as error OR
* highlight points for field highlights
* @param string|null $message If abort/crash, non localized $str
* @param array<mixed> $context Additionl info for abort/crash messages
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
* else set for this call only
*/
public function setErrorMsg(
string $error_id,
string $level,
string $str,
string $target = '',
string $target_style = '',
array $highlight = [],
?string $message = null,
array $context = [],
?bool $log_error = null,
): void {
if ($log_error === null) {
$log_error = $this->log_error;
}
$original_level = $level;
$level = MessageLevel::fromName($level)->name;
// if not string set, write message string if set, else level/error id
if (empty($str)) {
$str = $message ?? 'L:' . $level . '|E:' . $error_id;
}
$this->error_str[] = [
'id' => $error_id,
'level' => $level,
'str' => $str,
'target' => $target,
'target_style' => $target_style,
'highlight' => $highlight,
];
// write to log for abort/crash
switch ($level) {
case 'notice':
$this->log->notice($message ?? $str, array_merge([
'id' => $error_id,
'level' => $original_level,
], $context));
break;
case 'error':
if ($log_error) {
$this->log->error($message ?? $str, array_merge([
'id' => $error_id,
'level' => $original_level,
], $context));
}
break;
case 'abort':
$this->log->critical($message ?? $str, array_merge([
'id' => $error_id,
'level' => $original_level,
], $context));
break;
case 'crash':
$this->log->alert($message ?? $str, array_merge([
'id' => $error_id,
'level' => $original_level,
], $context));
break;
case 'unknown':
$this->log->emergency($message ?? $str, array_merge([
'id' => $error_id,
'level' => $original_level,
], $context));
break;
}
}
/**
* pushes new error message into the error_str array
* Note, the parameter order is different and does not need an error id
* This is for backend alerts
*
* @param string $level error level (ok/warn/info/error)
* @param string $str error string
* @param string|null $error_id optional error id for precise error lookup
* @param string $target Alternate id name for output target on frontend
* @param string $target_style Alternate color style for the error message
* @param array<string> $highlight Any additional error data as error OR
* highlight points for field highlights
* @param string|null $message If abort/crash, non localized $str
* @param array<mixed> $context Additionl info for abort/crash messages
* @param bool|null $log_error [=null] log level 'error' to error, if null use global,
* else set for this call only
*/
public function setMessage(
string $level,
string $str,
?string $error_id = null,
string $target = '',
string $target_style = '',
array $highlight = [],
?string $message = null,
array $context = [],
?bool $log_error = null,
): void {
$this->setErrorMsg(
$error_id ?? '',
$level,
$str,
$target,
$target_style,
$highlight,
$message,
$context,
$log_error
);
}
// *********************************************************************
// GETTERS
// *********************************************************************
/**
* Returns the current set error content from setErrorMsg method
*
* @return array<int,array{id:string,level:string,str:string,target:string,highlight:string[]}> Error messages array
*/
public function getErrorMsg(): array
{
return $this->error_str;
}
/**
* Current set error ids
*
* @return array<string>
*/
public function getErrorIds(): array
{
return array_column($this->error_str, 'id');
}
/**
* Gets the LAST entry in the array list.
* If nothing found returns empty array set
*
* @return array{id:string,level:string,str:string,target:string,target:string,highlight:string[]} Error block
*/
public function getLastErrorMsg(): array
{
return $this->error_str[array_key_last($this->error_str)] ?? [
'level' => '',
'str' => '',
'id' => '',
'target' => '',
'target_string' => '',
'highlight' => [],
];
}
// *********************************************************************
// FLAG SETTERS
// *********************************************************************
/**
* Set the log error flag
*
* @param bool $flag True to log level error too, False for do not (Default)
* @return void
*/
public function setFlagLogError(bool $flag): void
{
$this->log_error = $flag;
}
/**
* Get the current log error flag
*
* @return bool
*/
public function getFlagLogError(): bool
{
return $this->log_error;
}
}
// __END__

View File

@@ -113,17 +113,32 @@ enum Level: int
/**
* Returns true if the passed $level is higher or equal to $this
*
* @param Level $level
* @return bool
*/
public function includes(Level $level): bool
{
return $this->value <= $level->value;
}
/**
* If level is higher than set one
*
* @param Level $level
* @return bool
*/
public function isHigherThan(Level $level): bool
{
return $this->value > $level->value;
}
/**
* if level is lower than set one
*
* @param Level $level
* @return bool
*/
public function isLowerThan(Level $level): bool
{
return $this->value < $level->value;

View File

@@ -0,0 +1,86 @@
<?php // phpcs:disable Generic.Files.LineLength
/**
* AUTOR: Clemens Schwaighofer
* CREATED: 2023-09-08
* DESCRIPTION:
* Error message return levels
*/
declare(strict_types=1);
namespace CoreLibs\Logging\Logger;
enum MessageLevel: int
{
case ok = 100;
case info = 200;
case notice = 250;
case warn = 300;
case error = 400;
case abort = 500;
case crash = 550;
case unknown = 600;
/**
* @param string $name any string name, if not matching use unkown
* @return static
*/
public static function fromName(string $name): self
{
return match (strtolower($name)) {
'ok' => self::ok,
'info' => self::info,
'notice' => self::notice,
'warn', 'warning' => self::warn,
'error' => self::error,
'abort' => self::abort,
'crash' => self::crash,
default => self::unknown,
};
}
/**
* @param int $value
* @return static
*/
public static function fromValue(int $value): self
{
return self::tryFrom($value) ?? self::unknown;
}
/**
* Returns true if the passed $level is higher or equal to $this
*
* @param MessageLevel $level
* @return bool
*/
public function includes(MessageLevel $level): bool
{
return $this->value <= $level->value;
}
/**
* If level is higher than set one
*
* @param MessageLevel $level
* @return bool
*/
public function isHigherThan(MessageLevel $level): bool
{
return $this->value > $level->value;
}
/**
* if level is lower than set one
*
* @param MessageLevel $level
* @return bool
*/
public function isLowerThan(MessageLevel $level): bool
{
return $this->value < $level->value;
}
}
// __END__

View File

@@ -0,0 +1,40 @@
<?php
declare(strict_types=1);
namespace CoreLibs\Output\Form\TableArrays;
class EditOrder implements Interface\TableArraysInterface
{
/** @var \CoreLibs\Output\Form\Generate */
private \CoreLibs\Output\Form\Generate $form;
/**
* constructor
* @param \CoreLibs\Output\Form\Generate $form base form class
*/
public function __construct(\CoreLibs\Output\Form\Generate $form)
{
$this->form = $form;
$this->form->log->debug('CLASS LOAD', __NAMESPACE__ . __CLASS__);
}
/**
* NOTE: this is a dummy array to just init the Form\Generate class and is not used for anything else
*
* @return array<mixed>
*/
public function setTableArray(): array
{
return [
'table_array' => [
'-'
],
'table_name' => '-',
'load_query' => '',
'show_fields' => [],
];
}
}
// __END__

View File

@@ -57,8 +57,10 @@ return array(
'CoreLibs\\Language\\Core\\StringReader' => $baseDir . '/lib/CoreLibs/Language/Core/StringReader.php',
'CoreLibs\\Language\\GetLocale' => $baseDir . '/lib/CoreLibs/Language/GetLocale.php',
'CoreLibs\\Language\\L10n' => $baseDir . '/lib/CoreLibs/Language/L10n.php',
'CoreLibs\\Logging\\ErrorMessage' => $baseDir . '/lib/CoreLibs/Logging/ErrorMessage.php',
'CoreLibs\\Logging\\Logger\\Flag' => $baseDir . '/lib/CoreLibs/Logging/Logger/Flag.php',
'CoreLibs\\Logging\\Logger\\Level' => $baseDir . '/lib/CoreLibs/Logging/Logger/Level.php',
'CoreLibs\\Logging\\Logger\\MessageLevel' => $baseDir . '/lib/CoreLibs/Logging/Logger/MessageLevel.php',
'CoreLibs\\Logging\\Logging' => $baseDir . '/lib/CoreLibs/Logging/Logging.php',
'CoreLibs\\Output\\Form\\Elements' => $baseDir . '/lib/CoreLibs/Output/Form/Elements.php',
'CoreLibs\\Output\\Form\\Generate' => $baseDir . '/lib/CoreLibs/Output/Form/Generate.php',
@@ -66,6 +68,7 @@ return array(
'CoreLibs\\Output\\Form\\TableArrays\\EditGroups' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditLanguages' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditLanguages.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditMenuGroup' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditOrder' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditOrder.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditPages' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditPages.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditSchemas' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditUsers' => $baseDir . '/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php',

View File

@@ -108,8 +108,10 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
'CoreLibs\\Language\\Core\\StringReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/StringReader.php',
'CoreLibs\\Language\\GetLocale' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/GetLocale.php',
'CoreLibs\\Language\\L10n' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/L10n.php',
'CoreLibs\\Logging\\ErrorMessage' => __DIR__ . '/../..' . '/lib/CoreLibs/Logging/ErrorMessage.php',
'CoreLibs\\Logging\\Logger\\Flag' => __DIR__ . '/../..' . '/lib/CoreLibs/Logging/Logger/Flag.php',
'CoreLibs\\Logging\\Logger\\Level' => __DIR__ . '/../..' . '/lib/CoreLibs/Logging/Logger/Level.php',
'CoreLibs\\Logging\\Logger\\MessageLevel' => __DIR__ . '/../..' . '/lib/CoreLibs/Logging/Logger/MessageLevel.php',
'CoreLibs\\Logging\\Logging' => __DIR__ . '/../..' . '/lib/CoreLibs/Logging/Logging.php',
'CoreLibs\\Output\\Form\\Elements' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Elements.php',
'CoreLibs\\Output\\Form\\Generate' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Generate.php',
@@ -117,6 +119,7 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9
'CoreLibs\\Output\\Form\\TableArrays\\EditGroups' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditLanguages' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditLanguages.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditMenuGroup' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditOrder' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditOrder.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditPages' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditPages.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditSchemas' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php',
'CoreLibs\\Output\\Form\\TableArrays\\EditUsers' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php',