Compare commits

...

10 Commits

Author SHA1 Message Date
Clemens Schwaighofer
dfdfcf87f2 Merge branch 'development' 2023-10-02 12:26:14 +09:00
Clemens Schwaighofer
6218e0a6a8 Output\Form\Generate fix for phan check 2023-10-02 12:25:07 +09:00
Clemens Schwaighofer
a84a745be2 Logging\ErrorMsg class update to log error level automatically for debug
if log level is debug, automatically log the error messages.
We still skip warn and info levels from logging.

The rest is based on the logging level (notice eg only gets logged if
log level is at least notice)
2023-10-02 12:23:44 +09:00
Clemens Schwaighofer
312762e92e Composer update 2023-10-02 12:23:15 +09:00
Clemens Schwaighofer
fa4c1f0597 Form\Generate and DB\Extend\ArrayIO split
Move DB\Extend\ArrayIO to internal class in variable and do not extend
Form\Generate from it (as we do not have a base class anymore, this is
no longer neded)

Update all calls in connected classes.

Add interface methods for DB\Extend\ArrayIO to interface with all class
vars that are now all private
2023-09-29 19:05:58 +09:00
Clemens Schwaighofer
438a75af23 Merge branch 'development' 2023-09-27 11:42:32 +09:00
Clemens Schwaighofer
afd8ff3e31 Composer updates 2023-09-27 11:42:07 +09:00
Clemens Schwaighofer
4343af7937 Composer core updates 2023-09-27 11:41:41 +09:00
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
22 changed files with 747 additions and 577 deletions

View File

@@ -44,6 +44,11 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
'str' => 'INFO',
'expected' => 'info',
],
'notice' => [
'level' => 'notice',
'str' => 'NOTICE',
'expected' => 'notice',
],
'warn' => [
'level' => 'warn',
'str' => 'WARN',
@@ -91,9 +96,9 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
public function testErrorMessageLevelOk(string $level, string $str, string $expected): void
{
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_file_id' => 'testErrorMessagesLevelOk',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug,
'log_level' => Level::Error,
]);
$em = new \CoreLibs\Logging\ErrorMessage($log);
$em->setMessage(
@@ -123,9 +128,9 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
public function testErrorMessageOk(): void
{
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_file_id' => 'testErrorMessagesOk',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug
'log_level' => Level::Error
]);
$em = new \CoreLibs\Logging\ErrorMessage($log);
$em->setErrorMsg(
@@ -238,6 +243,22 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
'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',
@@ -293,7 +314,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
* Undocumented function
*
* @dataProvider providerErrorMessageLog
* @testdox Test Log writing [$_dataName]
* @testdox Test Log writing with log level Error [$_dataName]
*
* @param string $id
* @param string $level
@@ -303,7 +324,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
* @param string $expected
* @return void
*/
public function testErrorMessageLog(
public function testErrorMessageLogErrorLevel(
string $id,
string $level,
string $str,
@@ -312,7 +333,63 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
string $expected
): void {
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessages',
'log_file_id' => 'testErrorMessagesLogError',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Notice,
'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 error, if null or false, it will not be logged
if ($level == 'error' && ($log_error === null || $log_error === false)) {
$this->assertStringNotContainsString(
$expected,
$file_content
);
} else {
$this->assertStringContainsString(
$expected,
$file_content
);
}
}
/**
* Undocumented function
*
* @dataProvider providerErrorMessageLog
* @testdox Test Log writing with log Level Debug [$_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 testErrorMessageLogErrorDebug(
string $id,
string $level,
string $str,
?string $message,
?bool $log_error,
string $expected
): void {
$log = new \CoreLibs\Logging\Logging([
'log_file_id' => 'testErrorMessagesLogDebug',
'log_folder' => self::LOG_FOLDER,
'log_level' => Level::Debug,
'log_per_run' => true
@@ -331,8 +408,8 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase
$log->getLogFolder() . $log->getLogFile()
) ?: '';
}
// if n
if ($level == 'error' && ($log_error === null || $log_error === false)) {
// if error, and log is debug level, only explicit false are not logged
if ($level == 'error' && $log_error === false) {
$this->assertStringNotContainsString(
$expected,
$file_content

46
composer.lock generated
View File

@@ -481,16 +481,16 @@
},
{
"name": "doctrine/deprecations",
"version": "v1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3"
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"shasum": ""
},
"require": {
@@ -522,9 +522,9 @@
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.1.1"
"source": "https://github.com/doctrine/deprecations/tree/1.1.2"
},
"time": "2023-06-03T09:27:29+00:00"
"time": "2023-09-27T20:04:15+00:00"
},
{
"name": "felixfbecker/advanced-json-rpc",
@@ -1133,16 +1133,16 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.24.0",
"version": "1.24.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
"reference": "bcad8d995980440892759db0c32acae7c8e79442"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442",
"reference": "bcad8d995980440892759db0c32acae7c8e79442",
"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.24.0"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2"
},
"time": "2023-09-07T20:46:32+00:00"
"time": "2023-09-26T12:28:12+00:00"
},
{
"name": "phpstan/phpstan",
"version": "1.10.34",
"version": "1.10.36",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901"
"reference": "ffa3089511121a672e62969404e4fddc753f9b15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/ffa3089511121a672e62969404e4fddc753f9b15",
"reference": "ffa3089511121a672e62969404e4fddc753f9b15",
"shasum": ""
},
"require": {
@@ -1238,7 +1238,7 @@
"type": "tidelift"
}
],
"time": "2023-09-13T09:49:47+00:00"
"time": "2023-09-29T14:07:45+00:00"
},
{
"name": "phpstan/phpstan-deprecation-rules",
@@ -2254,16 +2254,16 @@
},
{
"name": "symfony/string",
"version": "v6.3.2",
"version": "v6.3.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "53d1a83225002635bca3482fcbf963001313fb68"
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68",
"reference": "53d1a83225002635bca3482fcbf963001313fb68",
"url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339",
"shasum": ""
},
"require": {
@@ -2320,7 +2320,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.3.2"
"source": "https://github.com/symfony/string/tree/v6.3.5"
},
"funding": [
{
@@ -2336,7 +2336,7 @@
"type": "tidelift"
}
],
"time": "2023-07-05T08:41:27+00:00"
"time": "2023-09-18T10:38:32+00:00"
},
{
"name": "tysonandre/var_representation_polyfill",

View File

@@ -441,17 +441,17 @@
},
{
"name": "doctrine/deprecations",
"version": "v1.1.1",
"version_normalized": "1.1.1.0",
"version": "1.1.2",
"version_normalized": "1.1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3"
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931",
"shasum": ""
},
"require": {
@@ -469,7 +469,7 @@
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"time": "2023-06-03T09:27:29+00:00",
"time": "2023-09-27T20:04:15+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -485,7 +485,7 @@
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/v1.1.1"
"source": "https://github.com/doctrine/deprecations/tree/1.1.2"
},
"install-path": "../doctrine/deprecations"
},
@@ -1129,17 +1129,17 @@
},
{
"name": "phpstan/phpdoc-parser",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"version": "1.24.2",
"version_normalized": "1.24.2.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6"
"reference": "bcad8d995980440892759db0c32acae7c8e79442"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bcad8d995980440892759db0c32acae7c8e79442",
"reference": "bcad8d995980440892759db0c32acae7c8e79442",
"shasum": ""
},
"require": {
@@ -1156,7 +1156,7 @@
"phpunit/phpunit": "^9.5",
"symfony/process": "^5.2"
},
"time": "2023-09-07T20:46:32+00:00",
"time": "2023-09-26T12:28:12+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.24.0"
"source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.2"
},
"install-path": "../phpstan/phpdoc-parser"
},
{
"name": "phpstan/phpstan",
"version": "1.10.34",
"version_normalized": "1.10.34.0",
"version": "1.10.36",
"version_normalized": "1.10.36.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901"
"reference": "ffa3089511121a672e62969404e4fddc753f9b15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7f806b6f1403e6914c778140e2ba07c293cb4901",
"reference": "7f806b6f1403e6914c778140e2ba07c293cb4901",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/ffa3089511121a672e62969404e4fddc753f9b15",
"reference": "ffa3089511121a672e62969404e4fddc753f9b15",
"shasum": ""
},
"require": {
@@ -1198,7 +1198,7 @@
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2023-09-13T09:49:47+00:00",
"time": "2023-09-29T14:07:45+00:00",
"bin": [
"phpstan",
"phpstan.phar"
@@ -2351,17 +2351,17 @@
},
{
"name": "symfony/string",
"version": "v6.3.2",
"version_normalized": "6.3.2.0",
"version": "v6.3.5",
"version_normalized": "6.3.5.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "53d1a83225002635bca3482fcbf963001313fb68"
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/53d1a83225002635bca3482fcbf963001313fb68",
"reference": "53d1a83225002635bca3482fcbf963001313fb68",
"url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339",
"shasum": ""
},
"require": {
@@ -2381,7 +2381,7 @@
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^5.4|^6.0"
},
"time": "2023-07-05T08:41:27+00:00",
"time": "2023-09-18T10:38:32+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
@@ -2420,7 +2420,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.3.2"
"source": "https://github.com/symfony/string/tree/v6.3.5"
},
"funding": [
{

View File

@@ -65,9 +65,9 @@
'dev_requirement' => true,
),
'doctrine/deprecations' => array(
'pretty_version' => 'v1.1.1',
'version' => '1.1.1.0',
'reference' => '612a3ee5ab0d5dd97b7cf3874a6efe24325efac3',
'pretty_version' => '1.1.2',
'version' => '1.1.2.0',
'reference' => '4f2d4f2836e7ec4e7a8625e75c6aa916004db931',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/deprecations',
'aliases' => array(),
@@ -182,18 +182,18 @@
'dev_requirement' => true,
),
'phpstan/phpdoc-parser' => array(
'pretty_version' => '1.24.0',
'version' => '1.24.0.0',
'reference' => '3510b0a6274cc42f7219367cb3abfc123ffa09d6',
'pretty_version' => '1.24.2',
'version' => '1.24.2.0',
'reference' => 'bcad8d995980440892759db0c32acae7c8e79442',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpdoc-parser',
'aliases' => array(),
'dev_requirement' => true,
),
'phpstan/phpstan' => array(
'pretty_version' => '1.10.34',
'version' => '1.10.34.0',
'reference' => '7f806b6f1403e6914c778140e2ba07c293cb4901',
'pretty_version' => '1.10.36',
'version' => '1.10.36.0',
'reference' => 'ffa3089511121a672e62969404e4fddc753f9b15',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),
@@ -347,9 +347,9 @@
'dev_requirement' => true,
),
'symfony/string' => array(
'pretty_version' => 'v6.3.2',
'version' => '6.3.2.0',
'reference' => '53d1a83225002635bca3482fcbf963001313fb68',
'pretty_version' => 'v6.3.5',
'version' => '6.3.5.0',
'reference' => '13d76d0fb049051ed12a04bef4f9de8715bea339',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/string',
'aliases' => array(),

View File

@@ -11,6 +11,7 @@ use function array_reduce;
use function assert;
use function debug_backtrace;
use function sprintf;
use function str_replace;
use function strpos;
use function strrpos;
use function substr;
@@ -138,7 +139,7 @@ class Deprecation
// first check that the caller is not from a tests folder, in which case we always let deprecations pass
if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) {
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR;
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $package) . DIRECTORY_SEPARATOR;
if (strpos($backtrace[0]['file'], $path) === false) {
return;

View File

@@ -1,22 +0,0 @@
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="."/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="80"/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<!-- Ignore warnings, show progress of the run and show sniff names -->
<arg value="nps"/>
<config name="php_version" value="70100"/>
<!-- Directories to be checked -->
<file>lib</file>
<file>tests</file>
<!-- Include full Doctrine Coding Standard -->
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
</rule>
</ruleset>

View File

@@ -1,9 +0,0 @@
parameters:
level: 6
paths:
- lib
- tests
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon

View File

@@ -1,30 +0,0 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedBaselineEntry="true"
findUnusedCode="false"
>
<projectFiles>
<directory name="lib/Doctrine/Deprecations" />
<directory name="tests/Doctrine/Deprecations" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<issueHandlers>
<DeprecatedMethod>
<errorLevel type="suppress">
<!-- Remove when dropping support for PHPUnit 9.6 -->
<referencedMethod name="PHPUnit\Framework\TestCase::expectDeprecation"/>
<referencedMethod name="PHPUnit\Framework\TestCase::expectDeprecationMessage"/>
</errorLevel>
</DeprecatedMethod>
</issueHandlers>
</psalm>

View File

@@ -10,11 +10,6 @@ parameters:
count: 1
path: src/Ast/NodeTraverser.php
-
message: "#^Strict comparison using \\=\\=\\= between 2 and 2 will always evaluate to true\\.$#"
count: 2
path: src/Ast/NodeTraverser.php
-
message: "#^Variable property access on PHPStan\\\\PhpDocParser\\\\Ast\\\\Node\\.$#"
count: 1

View File

@@ -398,42 +398,33 @@ class TypeParser
public function parseGeneric(TokenIterator $tokens, Ast\Type\IdentifierTypeNode $baseType): Ast\Type\GenericTypeNode
{
$tokens->consumeTokenType(Lexer::TOKEN_OPEN_ANGLE_BRACKET);
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
$startLine = $baseType->getAttribute(Ast\Attribute::START_LINE);
$startIndex = $baseType->getAttribute(Ast\Attribute::START_INDEX);
$genericTypes = [];
$variances = [];
[$genericTypes[], $variances[]] = $this->parseGenericTypeArgument($tokens);
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
while ($tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
$isFirst = true;
while ($isFirst || $tokens->tryConsumeTokenType(Lexer::TOKEN_COMMA)) {
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
if ($tokens->tryConsumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) {
// trailing comma case
$type = new Ast\Type\GenericTypeNode($baseType, $genericTypes, $variances);
$startLine = $baseType->getAttribute(Ast\Attribute::START_LINE);
$startIndex = $baseType->getAttribute(Ast\Attribute::START_INDEX);
if ($startLine !== null && $startIndex !== null) {
$type = $this->enrichWithAttributes($tokens, $type, $startLine, $startIndex);
}
return $type;
// trailing comma case
if (!$isFirst && $tokens->isCurrentTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET)) {
break;
}
$isFirst = false;
[$genericTypes[], $variances[]] = $this->parseGenericTypeArgument($tokens);
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
}
$tokens->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET);
$type = new Ast\Type\GenericTypeNode($baseType, $genericTypes, $variances);
$startLine = $baseType->getAttribute(Ast\Attribute::START_LINE);
$startIndex = $baseType->getAttribute(Ast\Attribute::START_INDEX);
if ($startLine !== null && $startIndex !== null) {
$type = $this->enrichWithAttributes($tokens, $type, $startLine, $startIndex);
}
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_ANGLE_BRACKET);
return $type;
}
@@ -533,7 +524,7 @@ class TypeParser
return $this->parseNullable($tokens);
} elseif ($tokens->tryConsumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) {
$type = $this->parse($tokens);
$type = $this->subParse($tokens);
$tokens->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES);
if ($tokens->isCurrentTokenType(Lexer::TOKEN_OPEN_SQUARE_BRACKET)) {
$type = $this->tryParseArrayOrOffsetAccess($tokens, $type);

Binary file not shown.

View File

@@ -1,16 +1,16 @@
-----BEGIN PGP SIGNATURE-----
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
iQIzBAABCgAdFiEEynwsejDI6OEnSoR2UcZzBf/C5cAFAmUW2hQACgkQUcZzBf/C
5cAX+g/8DLEpwgjbRjXNPaPoL9y2lbhYuOAkFuTLElmFTNRvmUgOrqI3pGdfWves
tFCRVdzefPnbi8PX7Y0u14bKY/YieSgeXEwqaZfllPdan7TJ7gdu8ZvOxZeiOvT5
Ns7Bnn7F+TyK7Z9gFn9pSt4bopLXgoGM3Xw4yg//HWQIb2gYzP/OEUwzF6vj1N88
x7GyXKhuNClh8DOYLPdw/Mp5C+Z4wEqUpxFFZ6nMZN239gOC4kxz2IfbMj1Lb1jR
5diFq+lAB9IfmqlRqJnlkRDmM3jt6G6+i4YNIdk8iRN3ppMJWT0Ck9cSiRSPhImB
n/fo4AA+fhomI6aXBECmYRud78ul0nm411KVM+a/cCnVD9nYrab6eC3K6KBeuWOw
2SNTdKSY+Al5y6mwjwzLCwrOLR7WxCTMkdO8pcbCj62IuKKyxWtS4xI/oxZE+z1S
2o4arkHhv103JQiF9NkbRWnUQakt2IhjWDjZmz051jMjijHfSW3j4WpZ8sjwk5mY
GKO/jQMgJ0M/4h46q+pFawMljBgK+7ECHF1nEAuoF2e+5v8VJ+XRJ+VC6rdvjQWC
StcsiFDznyRJgosaOePn39mLt6E0wOBc6Ko8OIoBrSDP7l5Wh+H6yIzpCiPLCm9C
8sx9U+LB0Jt+BHpWYReQcHrdbek5H7Iu4h8s/F8YYZFEeI0O9tc=
=Y8DE
-----END PGP SIGNATURE-----

View File

@@ -3,8 +3,8 @@
/*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 15.0.0
* Date: 2022-10-05T17:16:36+02:00
* Unicode version: 15.1.0
* Date: 2023-09-13T11:47:12+00:00
*/
return [
@@ -166,7 +166,7 @@ return [
],
[
12272,
12283,
12287,
],
[
12288,
@@ -396,6 +396,10 @@ return [
12736,
12771,
],
[
12783,
12783,
],
[
12784,
12799,
@@ -1110,6 +1114,14 @@ return [
],
[
191457,
191471,
],
[
191472,
192093,
],
[
192094,
194559,
],
[

View File

@@ -3,8 +3,8 @@
/*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 15.0.0
* Date: 2022-10-05T17:16:37+02:00
* Unicode version: 15.1.0
* Date: 2023-09-13T11:47:13+00:00
*/
return [

View File

@@ -35,13 +35,16 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
$em = new \CoreLibs\Logging\ErrorMessage($log);
print "Log ERROR: " . $log->prAr($em->getFlagLogError()) . "<br>";
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('123', 'error', 'msg this is bad, auto logged if debug');
$em->setErrorMsg('123', 'error', 'msg this is bad, auto logged if debug', 'target-id', 'other-style');
$em->setErrorMsg('123', 'error', 'msg this is bad, logged always', log_error:true);
$em->setErrorMsg('123', 'error', 'msg this is bad, never logged', log_error:false);
$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');
@@ -51,4 +54,6 @@ print "Errors: <pre>" . $log->prAr($em->getErrorMsg()) . "</pre>";
print "</body></html>";
$log->debug('[END]', '==========================================>');
// __END__

View File

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

View File

@@ -42,6 +42,7 @@
<textarea name="{$element.data.name}"{if $element.data.rows} rows="{$element.data.rows}"{/if}{if $element.data.cols} cols="{$element.data.cols}"{/if}>{$element.data.value}</textarea>
{/if}
{if $element.type == 'drop_down'}
{* {$element.data.selected} *}
{html_options name=$element.data.name values=$element.data.value output=$element.data.output selected=$element.data.selected}
{if $drop_down_input}
&nbsp;&nbsp;&nbsp;<input type="text" name="{$element.data.input_name}" value="{$element.data.input_value}"{if $element.data.input_size} size="{$element.data.input_size}"{/if}{if $element.data.input_length} maxlength="{$element.data.input_length}"{/if}>

View File

@@ -154,7 +154,7 @@ class EditBase
$q = "UPDATE " . $table_name
. " SET order_number = " . $row_data_order[$i]
. " WHERE " . $table_name . "_id = " . $row_data_id[$i];
$q = $this->form->dbExec($q);
$q = $this->form->dba->dbExec($q);
}
} // for all article ids ...
} // if write
@@ -173,7 +173,7 @@ class EditBase
$options_name = [];
$options_selected = [];
// DB read data for menu
while (is_array($res = $this->form->dbReturn($q))) {
while (is_array($res = $this->form->dba->dbReturn($q))) {
$row_data[] = [
"id" => $res[$table_name . "_id"],
"name" => $res["name"],
@@ -431,9 +431,9 @@ class EditBase
$elements[] = $this->form->formCreateElement('template');
break;
case 'edit_pages':
if (!isset($this->form->table_array['edit_page_id']['value'])) {
if (!isset($this->form->dba->getTableArray()['edit_page_id']['value'])) {
$q = "DELETE FROM temp_files";
$this->form->dbExec($q);
$this->form->dba->dbExec($q);
// gets all files in the current dir and dirs given ending with .php
$folders = ['../admin/', '../frontend/'];
$files = ['*.php'];
@@ -461,16 +461,16 @@ class EditBase
if ($t_q) {
$t_q .= ', ';
}
$t_q .= "('" . $this->form->dbEscapeString($pathinfo['dirname']) . "', '"
. $this->form->dbEscapeString($pathinfo['basename']) . "')";
$t_q .= "('" . $this->form->dba->dbEscapeString($pathinfo['dirname']) . "', '"
. $this->form->dba->dbEscapeString($pathinfo['basename']) . "')";
}
$this->form->dbExec($q . $t_q, 'NULL');
$this->form->dba->dbExec($q . $t_q, 'NULL');
$elements[] = $this->form->formCreateElement('filename');
} else {
// show file menu
// just show name of file ...
$this->DATA['filename_exist'] = 1;
$this->DATA['filename'] = $this->form->table_array['filename']['value'];
$this->DATA['filename'] = $this->form->dba->getTableArray()['filename']['value'];
} // File Name View IF
$elements[] = $this->form->formCreateElement('hostname');
$elements[] = $this->form->formCreateElement('name');

View File

@@ -39,13 +39,13 @@ class ArrayIO extends \CoreLibs\DB\IO
{
// main calss variables
/** @var array<mixed> */
public array $table_array; // the array from the table to work on
private array $table_array; // the array from the table to work on
/** @var string */
public string $table_name; // the table_name
private string $table_name; // the table_name
/** @var string */
public string $pk_name = ''; // the primary key from this table
private string $pk_name = ''; // the primary key from this table
/** @var int|string|null */
public int|string|null $pk_id; // the PK id
private int|string|null $pk_id; // the PK id
// security values
/** @var int base acl for current page */
private int $base_acl_level = 0;
@@ -74,24 +74,21 @@ class ArrayIO extends \CoreLibs\DB\IO
// instance db_io class
parent::__construct($db_config, $log);
// more error vars for this class
$this->error_string['1999'] = 'No table array or table name set';
$this->error_string['1998'] = 'No table name set';
$this->error_string['1999'] = 'No table array set';
$this->error_string['1021'] = 'No Primary Key given';
$this->error_string['1022'] = 'Could not run Array Query';
$this->table_array = $table_array;
$this->table_name = $table_name;
// error abort if no table array or no table name
if (empty($table_array) || empty($table_name)) {
$this->__dbError(1999, false, 'MAJOR ERROR: Core settings missing');
throw new \RuntimeException('MAJOR ERROR: Core settings missing', 1999);
}
$this->setTableArray($table_array);
$this->setTableName($table_name);
// set primary key for given table_array
foreach ($this->table_array as $key => $value) {
if (!empty($value['pk'])) {
$this->pk_name = $key;
if (empty($value['pk'])) {
continue;
}
$this->setPkName($key);
break;
}
$this->dbArrayIOSetAcl($base_acl_level, $acl_admin);
}
@@ -104,6 +101,144 @@ class ArrayIO extends \CoreLibs\DB\IO
parent::__destruct();
}
/**
* Set the overall table array
*
* @param array<mixed> $table_array
* @return void
* @throws \RuntimeException 1999 for empty table array
*/
public function setTableArray(array $table_array): void
{
$this->table_array = $table_array;
if (empty($this->table_array)) {
$this->__dbError(1999, false, 'MAJOR ERROR: Core settings missing: table_arrry');
throw new \RuntimeException('MAJOR ERROR: Core settings missing: table_array', 1999);
}
}
/**
* return full table array, or [] if empty
* of reset is set to true, will reset array first
*
* @param bool $reset [=false] run a reset before returning
* @return array<mixed>
*/
public function getTableArray(bool $reset = false): array
{
if (!$reset) {
return $this->table_array ?? [];
}
$table_array = $this->table_array ?? [];
reset($table_array);
return $table_array;
}
/**
* get a table array entry under the key with element pos
*
* @param string $key
* @param string $pos
* @return mixed
*/
public function getTableArrayEntry(string $key, string $pos): mixed
{
return $this->table_array[$key][$pos] ?? null;
}
/**
* set a new value at key with pos
*
* @param mixed $value
* @param string $key
* @param string $pos
* @return void
*/
public function setTableArrayEntry(mixed $value, string $key, string $pos): void
{
$this->table_array[$key][$pos] = $value;
}
/**
* unset entry at key with pos
*
* @param string $key
* @param string $pos
* @return void
*/
public function unsetTableArrayEntry(string $key, string $pos): void
{
unset($this->table_array[$key][$pos]);
}
/**
* Set table name
*
* @param string $table_name
* @return void
* @throws \RuntimeException 1998 for empty table name
*/
public function setTableName(string $table_name): void
{
$this->table_name = $table_name;
if (empty($this->table_name)) {
$this->__dbError(1998, false, 'MAJOR ERROR: Core settings missing: table_name');
throw new \RuntimeException('MAJOR ERROR: Core settings missing: table_name', 1998);
}
}
/**
* Return table name or empty string if not net
*
* @return string
*/
public function getTableName(): string
{
return $this->table_name ?? '';
}
/**
* Set primary key name
*
* @param string $pk_name
* @return void
*/
public function setPkName(string $pk_name): void
{
$this->pk_name = $pk_name;
}
/**
* get primary key name
*
* @return string
*/
public function getPkName(): string
{
return $this->pk_name;
}
/**
* set primary key id, can be null for not yet set
*
* @param int|string|null $pk_id
* @return void
*/
public function setPkId(int|string|null $pk_id): void
{
$this->pk_id = $pk_id;
}
/**
* return primary key id, or null if not set
*
* @return int|string|null
*/
public function getPkId(): int|string|null
{
return $this->pk_id;
}
/**
* set the base acl level and admin acl flag
* This is needed for table array ACL checks
@@ -198,8 +333,8 @@ class ArrayIO extends \CoreLibs\DB\IO
public function dbCheckPkSet(): bool
{
// if pk_id is set, overrule ...
if (!empty($this->pk_id)) {
$this->table_array[$this->pk_name]['value'] = $this->pk_id;
if (!empty($this->getPkId())) {
$this->table_array[$this->pk_name]['value'] = $this->getPkId();
}
// if not set ... produce error
if (!$this->table_array[$this->pk_name]['value']) {
@@ -287,7 +422,7 @@ class ArrayIO extends \CoreLibs\DB\IO
$q .= ' AND ' . $q_where;
}
// if 0, error
$this->pk_id = null;
$this->setPkId(null);
if (!$this->dbExec($q)) {
$this->__dbError(1022);
}
@@ -374,7 +509,7 @@ class ArrayIO extends \CoreLibs\DB\IO
}
}
// possible dbFetchArray errors ...
$this->pk_id = $this->table_array[$this->pk_name]['value'];
$this->setPkId($this->table_array[$this->pk_name]['value']);
} else {
$this->__dbError(1022);
}
@@ -397,10 +532,6 @@ class ArrayIO extends \CoreLibs\DB\IO
if (count($table_array)) {
$this->table_array = $table_array;
}
// PK ID check
// if ($this->pk_id && !$this->table_array[$this->pk_name]["value"]) {
// $this->table_array[$this->pk_name]["value"]=$this->pk_id;
// }
// checken ob PKs gesetzt, wenn alle -> update, wenn keiner -> insert, wenn ein paar -> ERROR!
if (!$this->table_array[$this->pk_name]['value']) {
$insert = 1;
@@ -624,16 +755,11 @@ class ArrayIO extends \CoreLibs\DB\IO
$q .= ' AND ' . $q_where;
}
// set pk_id ... if it has changed or so
$this->pk_id = $this->table_array[$this->pk_name]['value'];
$this->setPkId($this->table_array[$this->pk_name]['value']);
} else {
$q = 'INSERT INTO ' . $this->table_name . ' ';
$q .= '(' . $q_vars . ') ';
$q .= 'VALUES (' . $q_data . ')';
// write primary key too
// if ($q_data)
// $q .= ", ";
// $q .= $this->pk_name." = ".$this->table_array[$this->pk_name]['value']." ";
// $this->pk_id = $this->table_array[$this->pk_name]['value'];
}
// return success or not
if (!$this->dbExec($q)) {
@@ -646,7 +772,7 @@ class ArrayIO extends \CoreLibs\DB\IO
$insert_id = 0;
}
$this->table_array[$this->pk_name]['value'] = $insert_id;
$this->pk_id = $insert_id;
$this->setPkId($insert_id);
}
// return the table if needed
return $this->table_array;

View File

@@ -27,13 +27,19 @@ class ErrorMessage
* init ErrorMessage
*
* @param \CoreLibs\Logging\Logging $log
* @param bool $log_error [=false]
* @param null|bool $log_error [=null], defaults to false if log is not level debug
*/
public function __construct(
\CoreLibs\Logging\Logging $log,
bool $log_error = false
?bool $log_error = null
) {
$this->log = $log;
// if log default logging is debug then log_error is default set to true
if ($this->log->loggingLevelIsDebug() && $log_error === null) {
$log_error = true;
} else {
$log_error = $log_error ?? false;
}
$this->log_error = $log_error;
}
@@ -42,6 +48,7 @@ class ErrorMessage
* 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
@@ -98,6 +105,12 @@ class ErrorMessage
];
// 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([

View File

@@ -15,6 +15,7 @@ enum MessageLevel: int
{
case ok = 100;
case info = 200;
case notice = 250;
case warn = 300;
case error = 400;
case abort = 500;
@@ -30,6 +31,7 @@ enum MessageLevel: int
return match (strtolower($name)) {
'ok' => self::ok,
'info' => self::info,
'notice' => self::notice,
'warn', 'warning' => self::warn,
'error' => self::error,
'abort' => self::abort,

File diff suppressed because it is too large Load Diff