From e74bd04d6f3c93bf5d55ecd9fb0ef4c07efe44f8 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 28 Aug 2023 09:54:33 +0900 Subject: [PATCH] Composer updates --- www/admin/class_test.class-calls.php | 42 ++ www/admin/class_test.db.php | 30 ++ www/admin/class_test.debug.php | 2 + www/admin/class_test.json.php | 5 + www/admin/class_test.php | 1 + www/admin/class_test.readenvfile.php | 1 + www/composer.lock | 7 +- www/vendor/composer/installed.json | 9 +- www/vendor/composer/installed.php | 6 +- www/vendor/composer/platform_check.php | 4 +- .../.phan/config.old-20230828.php | 123 ++++++ .../corelibs-composer-all/.phan/config.php | 411 ++++++++++++++---- .../corelibs-composer-all/composer.json | 5 +- .../publish/last.published | 2 +- .../corelibs-composer-all/src/ACL/Login.php | 17 +- .../src/Admin/Backend.php | 2 +- .../corelibs-composer-all/src/Check/Email.php | 8 +- .../src/Convert/Colors.php | 56 +-- .../src/Convert/Json.php | 27 ++ .../corelibs-composer-all/src/DB/IO.php | 61 ++- .../src/Debug/LoggingLegacy.php | 6 +- .../src/Debug/Support.php | 85 ++-- .../src/Logging/Logging.php | 43 +- .../Convert/CoreLibsConvertJsonTest.php | 54 ++- .../Debug/CoreLibsDebugSupportTest.php | 38 +- .../Logging/CoreLibsLoggingLoggingTest.php | 2 +- 26 files changed, 841 insertions(+), 206 deletions(-) create mode 100644 www/admin/class_test.class-calls.php create mode 100644 www/vendor/egrajp/corelibs-composer-all/.phan/config.old-20230828.php diff --git a/www/admin/class_test.class-calls.php b/www/admin/class_test.class-calls.php new file mode 100644 index 00000000..dab66808 --- /dev/null +++ b/www/admin/class_test.class-calls.php @@ -0,0 +1,42 @@ + BASE . LOG, + 'log_file_id' => $LOG_FILE_ID, + 'log_per_date' => true, +]); +// db connection and attach logger +$db = new CoreLibs\DB\IO(DB_CONFIG, $log); + +// define a list of from to color sets for conversion test + +$PAGE_NAME = 'TEST CLASS: CLASS CALLS'; +print ""; +print "" . $PAGE_NAME . ""; +print ""; +print '
Class Test Master
'; +print '

' . $PAGE_NAME . '

'; + +$test = new \TestCalls\Test($db, $log); + +$test->testDbCall(); + +print ""; + +// __END__ diff --git a/www/admin/class_test.db.php b/www/admin/class_test.db.php index bff2aeeb..507956fd 100644 --- a/www/admin/class_test.db.php +++ b/www/admin/class_test.db.php @@ -73,6 +73,36 @@ $db->dbSetEncoding('SJIS'); print "ENCODING TEST: " . $db->dbVersionInfo('client_encoding') . "/" . $db->dbGetEncoding() . "
"; $db->dbResetEncoding(); +// empty calls, none of the below should fail +// +$db->dbGetInsertPKName(); +// +$db->dbGetInsertPK(); +// +$db->dbGetReturningExt(); +$db->dbGetReturningExt('foo'); +$db->dbGetReturningExt('foo', 0); +$db->dbGetReturningExt(pos:0); +// +$db->dbGetReturningArray(); +// +$db->dbGetNumRows(); +// +$db->dbGetNumFields(); +// +$db->dbGetFieldNames(); +// +$db->dbGetFieldTypes(); +// +$db->dbGetFieldNameTypes(); +// +$db->dbGetFieldName(0); +// +$db->dbGetFieldType(0); +$db->dbGetFieldType('foo'); +// +$db->dbGetPrepareCursorValue('foo', 'bar'); + // TEST CACHE READS $res = $db->dbReturn("SELECT * FROM max_test"); diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index 09325d39..a19d8b9c 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -169,6 +169,7 @@ class TestL public function test(?string $ts = null): bool { print "* GETCALLERCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
"; + print "* GETCALLERTOPCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "
"; $this->log->debug('TESTL', 'Logging in class testL' . ($ts !== null ? ': ' . $ts : '')); $this->log->debug('TESTL', 'Some other message'); return true; @@ -191,6 +192,7 @@ class TestR extends TestL public function subTest(): bool { print "** GETCALLERCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
"; + print "** GETCALLERTOPCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerTopLevelClass() . "
"; $this->log->debug('TESTR', 'Logging in class testR (extends testL)'); $this->test('TESTR INSIDE'); $this->log->debug('TESTR', 'Array: ' diff --git a/www/admin/class_test.json.php b/www/admin/class_test.json.php index 9816abde..e86f5ccc 100644 --- a/www/admin/class_test.json.php +++ b/www/admin/class_test.json.php @@ -63,6 +63,11 @@ print "J/S::E-JSON ERROR: " . $json_class::jsonGetLastError() . ": " . $json_cla // print "S::JSON: $json: " . DgS::printAr($output) . "
"; // print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "
"; +// convert an array to json +$array = ['foo' => 'bar']; +$output = Json::jsonConvertArrayTo($array); +print "S::JSON: " . DgS::printAr($array) . " => " . $output . "
"; + print ""; // __END__ diff --git a/www/admin/class_test.php b/www/admin/class_test.php index c0f15b72..f7645079 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -114,6 +114,7 @@ $test_files = [ 'class_test.autoloader.php' => 'Class Test: AUTOLOADER', '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', 'subfolder/class_test.config.direct.php' => 'Class Test: CONFIG DIRECT SUB', ]; diff --git a/www/admin/class_test.readenvfile.php b/www/admin/class_test.readenvfile.php index 28d706c7..2e569e32 100644 --- a/www/admin/class_test.readenvfile.php +++ b/www/admin/class_test.readenvfile.php @@ -40,5 +40,6 @@ print "test.env: STATUS: " . $status . "
"; print "AFTER reading test.env file: " . \CoreLibs\Debug\Support::printAr($_ENV) . "
"; print ""; +// ;; // __END__ diff --git a/www/composer.lock b/www/composer.lock index 5444e62e..90394877 100644 --- a/www/composer.lock +++ b/www/composer.lock @@ -8,18 +8,19 @@ "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "dev-master", + "version": "dev-development", "dist": { "type": "path", "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", - "reference": "5dde52a309227892acbe34679e359cad6bfd7912" + "reference": "6f657f28901fee93a5aa2d5232a355da59e15fa3" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "psr/log": "^3.0@dev" }, "require-dev": { "egrajp/smarty-extended": "^4.3", + "gullevek/dotenv": "dev-master", "phan/phan": "v5.x-dev", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9", diff --git a/www/vendor/composer/installed.json b/www/vendor/composer/installed.json index 5ec8102f..67a78f41 100644 --- a/www/vendor/composer/installed.json +++ b/www/vendor/composer/installed.json @@ -2,19 +2,20 @@ "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "dev-master", - "version_normalized": "dev-master", + "version": "dev-development", + "version_normalized": "dev-development", "dist": { "type": "path", "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", - "reference": "5dde52a309227892acbe34679e359cad6bfd7912" + "reference": "6f657f28901fee93a5aa2d5232a355da59e15fa3" }, "require": { - "php": ">=8.1", + "php": ">=8.2", "psr/log": "^3.0@dev" }, "require-dev": { "egrajp/smarty-extended": "^4.3", + "gullevek/dotenv": "dev-master", "phan/phan": "v5.x-dev", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9", diff --git a/www/vendor/composer/installed.php b/www/vendor/composer/installed.php index 99ce2d64..579977ea 100644 --- a/www/vendor/composer/installed.php +++ b/www/vendor/composer/installed.php @@ -11,9 +11,9 @@ ), 'versions' => array( 'egrajp/corelibs-composer-all' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '5dde52a309227892acbe34679e359cad6bfd7912', + 'pretty_version' => 'dev-development', + 'version' => 'dev-development', + 'reference' => '6f657f28901fee93a5aa2d5232a355da59e15fa3', 'type' => 'library', 'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all', 'aliases' => array(), diff --git a/www/vendor/composer/platform_check.php b/www/vendor/composer/platform_check.php index 4c3a5d68..d32d90c6 100644 --- a/www/vendor/composer/platform_check.php +++ b/www/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80100)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80200)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/www/vendor/egrajp/corelibs-composer-all/.phan/config.old-20230828.php b/www/vendor/egrajp/corelibs-composer-all/.phan/config.old-20230828.php new file mode 100644 index 00000000..9b998621 --- /dev/null +++ b/www/vendor/egrajp/corelibs-composer-all/.phan/config.old-20230828.php @@ -0,0 +1,123 @@ + "8.2", + // turn color on (-C) + "color_issue_messages_if_supported" => true, + // If true, missing properties will be created when + // they are first seen. If false, we'll report an + // error message. + "allow_missing_properties" => false, + + // Allow null to be cast as any type and for any + // type to be cast to null. + "null_casts_as_any_type" => false, + + // Backwards Compatibility Checking + 'backward_compatibility_checks' => false, + + // Run a quick version of checks that takes less + // time + "quick_mode" => false, + + // Only emit critical issues to start with + // (0 is low severity, 5 is normal severity, 10 is critical) + "minimum_severity" => 0, + + // enable for dead code check + // this will spill out errors for all methods never called + // use after all is OK to try to find unused code blocks + // ignore recommended: PhanUnreferencedPublicMethod + // "dead_code_detection" => true, + + // default false for include path check + "enable_include_path_checks" => true, + "include_paths" => [ + '.', + // '../test/configs/' + ], + 'ignore_undeclared_variables_in_global_scope' => true, + + "file_list" => [ + "./test/configs/config.php", + // "./test/configs/config.db.php", + // "./test/configs/config.host.php", + // "./test/configs/config.path.php", + "./test/configs/config.other.php", + "./test/configs/config.master.php", + ], + + // A list of directories that should be parsed for class and + // method information. After excluding the directories + // defined in exclude_analysis_directory_list, the remaining + // files will be statically analyzed for errors. + // + // Thus, both first-party and third-party code being used by + // your application should be included in this list. + 'directory_list' => [ + // Change this to include the folders you wish to analyze + // (and the folders of their dependencies) + 'src', + // To speed up analysis, we recommend going back later and + // limiting this to only the vendor/ subdirectories your + // project depends on. + // `phan --init` will generate a list of folders for you + 'vendor/egrajp/smarty-extended', + ], + + + // A list of directories holding code that we want + // to parse, but not analyze + "exclude_analysis_directory_list" => [ + 'vendor/egrajp/smarty-extended', + ], + 'exclude_file_list' => [ + ], + + // what not to show as problem + 'suppress_issue_types' => [ + // 'PhanUndeclaredMethod', + 'PhanEmptyFile', + // ignore unreferences public methods, etc here (for dead code check) + 'PhanUnreferencedPublicMethod', + 'PhanUnreferencedClass', + 'PhanWriteOnlyPublicProperty', + 'PhanUnreferencedConstant', + 'PhanWriteOnlyPublicProperty', + 'PhanReadOnlyPublicProperty', + // start ignore annotations + 'PhanUnextractableAnnotationElementName', + 'PhanUnextractableAnnotationSuffix', + ], + + // Override to hardcode existence and types of (non-builtin) globals in the global scope. + // Class names should be prefixed with `\`. + // + // (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`) + 'globals_type_map' => [], +]; diff --git a/www/vendor/egrajp/corelibs-composer-all/.phan/config.php b/www/vendor/egrajp/corelibs-composer-all/.phan/config.php index 9b998621..dace5350 100644 --- a/www/vendor/egrajp/corelibs-composer-all/.phan/config.php +++ b/www/vendor/egrajp/corelibs-composer-all/.phan/config.php @@ -1,12 +1,25 @@ "8.2", - // turn color on (-C) - "color_issue_messages_if_supported" => true, - // If true, missing properties will be created when + + // The PHP version that the codebase will be checked for compatibility against. + // For best results, the PHP binary used to run Phan should have the same PHP version. + // (Phan relies on Reflection for some types, param counts, + // and checks for undefined classes/methods/functions) + // + // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, + // `'8.0'`, `'8.1'`, `null`. + // If this is set to `null`, + // then Phan assumes the PHP version which is closest to the minor version + // of the php executable used to execute Phan. + // + // 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.1', + + // If enabled, missing properties will be created when // they are first seen. If false, we'll report an - // error message. - "allow_missing_properties" => false, + // error message if there is an attempt to write + // to a class property that wasn't explicitly + // defined. + 'allow_missing_properties' => false, - // Allow null to be cast as any type and for any - // type to be cast to null. - "null_casts_as_any_type" => false, + // If enabled, null can be cast to any type and any + // type can be cast to null. Setting this to true + // will cut down on false positives. + 'null_casts_as_any_type' => false, - // Backwards Compatibility Checking - 'backward_compatibility_checks' => false, + // If enabled, allow null to be cast as any array-like type. + // + // This is an incremental step in migrating away from `null_casts_as_any_type`. + // If `null_casts_as_any_type` is true, this has no effect. + 'null_casts_as_array' => true, - // Run a quick version of checks that takes less - // time - "quick_mode" => false, + // If enabled, allow any array-like type to be cast to null. + // This is an incremental step in migrating away from `null_casts_as_any_type`. + // If `null_casts_as_any_type` is true, this has no effect. + 'array_casts_as_null' => true, - // Only emit critical issues to start with - // (0 is low severity, 5 is normal severity, 10 is critical) - "minimum_severity" => 0, + // If enabled, scalars (int, float, bool, string, null) + // are treated as if they can cast to each other. + // This does not affect checks of array keys. See `scalar_array_key_cast`. + 'scalar_implicit_cast' => false, - // enable for dead code check - // this will spill out errors for all methods never called - // use after all is OK to try to find unused code blocks - // ignore recommended: PhanUnreferencedPublicMethod - // "dead_code_detection" => true, + // If enabled, any scalar array keys (int, string) + // are treated as if they can cast to each other. + // E.g. `array` can cast to `array` and vice versa. + // Normally, a scalar type such as int could only cast to/from int and mixed. + 'scalar_array_key_cast' => true, - // default false for include path check - "enable_include_path_checks" => true, - "include_paths" => [ - '.', - // '../test/configs/' - ], + // If this has entries, scalars (int, float, bool, string, null) + // are allowed to perform the casts listed. + // + // E.g. `['int' => ['float', 'string'], 'float' => ['int'], 'string' => ['int'], 'null' => ['string']]` + // allows casting null to a string, but not vice versa. + // (subset of `scalar_implicit_cast`) + 'scalar_implicit_partial' => [], + + // If enabled, Phan will warn if **any** type in a method invocation's object + // is definitely not an object, + // or if **any** type in an invoked expression is not a callable. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_method_checking' => false, + + // If enabled, Phan will warn if **any** type of the object expression for a property access + // does not contain that property. + 'strict_object_checking' => false, + + // If enabled, Phan will warn if **any** type in the argument's union type + // cannot be cast to a type in the parameter's expected union type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_param_checking' => false, + + // If enabled, Phan will warn if **any** type in a property assignment's union type + // cannot be cast to a type in the property's declared union type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_property_checking' => false, + + // If enabled, Phan will warn if **any** type in a returned value's union type + // cannot be cast to the declared return type. + // Setting this to true will introduce numerous false positives + // (and reveal some bugs). + 'strict_return_checking' => false, + + // If true, seemingly undeclared variables in the global + // scope will be ignored. + // + // This is useful for projects with complicated cross-file + // globals that you have no hope of fixing. 'ignore_undeclared_variables_in_global_scope' => true, - "file_list" => [ - "./test/configs/config.php", - // "./test/configs/config.db.php", - // "./test/configs/config.host.php", - // "./test/configs/config.path.php", - "./test/configs/config.other.php", - "./test/configs/config.master.php", - ], - - // A list of directories that should be parsed for class and - // method information. After excluding the directories - // defined in exclude_analysis_directory_list, the remaining - // files will be statically analyzed for errors. + // Set this to false to emit `PhanUndeclaredFunction` issues for internal functions that Phan has signatures for, + // but aren't available in the codebase, or from Reflection. + // (may lead to false positives if an extension isn't loaded) // - // Thus, both first-party and third-party code being used by - // your application should be included in this list. - 'directory_list' => [ - // Change this to include the folders you wish to analyze - // (and the folders of their dependencies) - 'src', - // To speed up analysis, we recommend going back later and - // limiting this to only the vendor/ subdirectories your - // project depends on. - // `phan --init` will generate a list of folders for you - 'vendor/egrajp/smarty-extended', - ], + // If this is true(default), then Phan will not warn. + // + // Even when this is false, Phan will still infer return values and check parameters of internal functions + // if Phan has the signatures. + 'ignore_undeclared_functions_with_known_signatures' => true, + // Backwards Compatibility Checking. This is slow + // and expensive, but you should consider running + // it before upgrading your version of PHP to a + // new version that has backward compatibility + // breaks. + // + // If you are migrating from PHP 5 to PHP 7, + // you should also look into using + // [php7cc (no longer maintained)](https://github.com/sstalle/php7cc) + // and [php7mar](https://github.com/Alexia/php7mar), + // which have different backwards compatibility checks. + // + // If you are still using versions of php older than 5.6, + // `PHP53CompatibilityPlugin` may be worth looking into if you are not running + // syntax checks for php 5.3 through another method such as + // `InvokePHPNativeSyntaxCheckPlugin` (see .phan/plugins/README.md). + 'backward_compatibility_checks' => false, - // A list of directories holding code that we want - // to parse, but not analyze - "exclude_analysis_directory_list" => [ - 'vendor/egrajp/smarty-extended', - ], - 'exclude_file_list' => [ - ], + // If true, check to make sure the return type declared + // in the doc-block (if any) matches the return type + // declared in the method signature. + 'check_docblock_signature_return_type_match' => false, - // what not to show as problem - 'suppress_issue_types' => [ - // 'PhanUndeclaredMethod', - 'PhanEmptyFile', - // ignore unreferences public methods, etc here (for dead code check) - 'PhanUnreferencedPublicMethod', - 'PhanUnreferencedClass', - 'PhanWriteOnlyPublicProperty', - 'PhanUnreferencedConstant', - 'PhanWriteOnlyPublicProperty', - 'PhanReadOnlyPublicProperty', - // start ignore annotations - 'PhanUnextractableAnnotationElementName', - 'PhanUnextractableAnnotationSuffix', - ], + // This setting maps case-insensitive strings to union types. + // + // This is useful if a project uses phpdoc that differs from the phpdoc2 standard. + // + // If the corresponding value is the empty string, + // then Phan will ignore that union type (E.g. can ignore 'the' in `@return the value`) + // + // If the corresponding value is not empty, + // then Phan will act as though it saw the corresponding UnionTypes(s) + // when the keys show up in a UnionType of `@param`, `@return`, `@var`, `@property`, etc. + // + // This matches the **entire string**, not parts of the string. + // (E.g. `@return the|null` will still look for a class with the name `the`, + // but `@return the` will be ignored with the below setting) + // + // (These are not aliases, this setting is ignored outside of doc comments). + // (Phan does not check if classes with these names exist) + // + // Example setting: `['unknown' => '', 'number' => 'int|float', 'char' => 'string', 'long' => 'int', 'the' => '']` + 'phpdoc_type_mapping' => [], + + // Set to true in order to attempt to detect dead + // (unreferenced) code. Keep in mind that the + // results will only be a guess given that classes, + // properties, constants and methods can be referenced + // as variables (like `$class->$property` or + // `$class->$method()`) in ways that we're unable + // to make sense of. + // + // To more aggressively detect dead code, + // you may want to set `dead_code_detection_prefer_false_negative` to `false`. + 'dead_code_detection' => false, + + // Set to true in order to attempt to detect unused variables. + // `dead_code_detection` will also enable unused variable detection. + // + // This has a few known false positives, e.g. for loops or branches. + 'unused_variable_detection' => false, + + // Set to true in order to attempt to detect redundant and impossible conditions. + // + // This has some false positives involving loops, + // variables set in branches of loops, and global variables. + 'redundant_condition_detection' => false, + + // If enabled, Phan will act as though it's certain of real return types of a subset of internal functions, + // even if those return types aren't available in reflection + // (real types were taken from php 7.3 or 8.0-dev, depending on target_php_version). + // + // Note that with php 7 and earlier, php would return null or false for many internal functions + // if the argument types or counts were incorrect. + // As a result, enabling this setting with target_php_version 8.0 may result in false positives + // for `--redundant-condition-detection` when codebases also support php 7.x. + 'assume_real_types_for_internal_functions' => false, + + // If true, this runs a quick version of checks that takes less + // time at the cost of not running as thorough + // of an analysis. You should consider setting this + // to true only when you wish you had more **undiagnosed** issues + // to fix in your code base. + // + // In quick-mode the scanner doesn't rescan a function + // or a method's code block every time a call is seen. + // This means that the problem here won't be detected: + // + // ```php + // false, // Override to hardcode existence and types of (non-builtin) globals in the global scope. // Class names should be prefixed with `\`. // // (E.g. `['_FOO' => '\FooClass', 'page' => '\PageClass', 'userId' => 'int']`) 'globals_type_map' => [], + + // The minimum severity level to report on. This can be + // set to `Issue::SEVERITY_LOW`, `Issue::SEVERITY_NORMAL` or + // `Issue::SEVERITY_CRITICAL`. Setting it to only + // critical issues is a good place to start on a big + // sloppy mature code base. + 'minimum_severity' => Issue::SEVERITY_LOW, + + // Add any issue types (such as `'PhanUndeclaredMethod'`) + // to this list to inhibit them from being reported. + 'suppress_issue_types' => [ + // start ignore annotations + 'PhanUnextractableAnnotationElementName', + 'PhanUnextractableAnnotationSuffix', + // wrongly thinks Enum is class + 'PhanCommentObjectInClassConstantType', + ], + + // A regular expression to match files to be excluded + // from parsing and analysis and will not be read at all. + // + // This is useful for excluding groups of test or example + // directories/files, unanalyzable files, or files that + // can't be removed for whatever reason. + // (e.g. `'@Test\.php$@'`, or `'@vendor/.*/(tests|Tests)/@'`) + 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', + + // A list of files that will be excluded from parsing and analysis + // and will not be read at all. + // + // This is useful for excluding hopelessly unanalyzable + // files that can't be removed for whatever reason. + 'exclude_file_list' => [], + + // A directory list that defines files that will be excluded + // from static analysis, but whose class and method + // information should be included. + // + // Generally, you'll want to include the directories for + // third-party code (such as "vendor/") in this list. + // + // n.b.: If you'd like to parse but not analyze 3rd + // party code, directories containing that code + // should be added to the `directory_list` as well as + // to `exclude_analysis_directory_list`. + 'exclude_analysis_directory_list' => [ + 'vendor/', + ], + + // Enable this to enable checks of require/include statements referring to valid paths. + // The settings `include_paths` and `warn_about_relative_include_statement` affect the checks. + 'enable_include_path_checks' => true, + "include_paths" => [ + '.', + ], + + // The number of processes to fork off during the analysis + // phase. + 'processes' => 1, + + // List of case-insensitive file extensions supported by Phan. + // (e.g. `['php', 'html', 'htm']`) + 'analyzed_file_extensions' => [ + 'php', + ], + + // You can put paths to stubs of internal extensions in this config option. + // If the corresponding extension is **not** loaded, then Phan will use the stubs instead. + // Phan will continue using its detailed type annotations, + // but load the constants, classes, functions, and classes (and their Reflection types) + // from these stub files (doubling as valid php files). + // Use a different extension from php to avoid accidentally loading these. + // The `tools/make_stubs` script can be used to generate your own stubs (compatible with php 7.0+ right now) + // + // (e.g. `['xdebug' => '.phan/internal_stubs/xdebug.phan_php']`) + 'autoload_internal_extension_signatures' => [], + + // A list of plugin files to execute. + // + // Plugins which are bundled with Phan can be added here by providing their name (e.g. `'AlwaysReturnPlugin'`) + // + // Documentation about available bundled plugins can be found + // [here](https://github.com/phan/phan/tree/v5/.phan/plugins). + // + // Alternately, you can pass in the full path to a PHP file with the plugin's implementation + // (e.g. `'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php'`) + 'plugins' => [ + 'AlwaysReturnPlugin', + 'PregRegexCheckerPlugin', + 'UnreachableCodePlugin', + ], + + // A list of directories that should be parsed for class and + // method information. After excluding the directories + // defined in `exclude_analysis_directory_list`, the remaining + // files will be statically analyzed for errors. + // + // Thus, both first-party and third-party code being used by + // your application should be included in this list. + 'directory_list' => [ + 'src', + 'vendor/egrajp/smarty-extended/src', + 'vendor/phan/phan/src/Phan', + 'vendor/phpunit/phpunit/src', + 'vendor/psr/log/src', + 'vendor/vimeo/psalm/src/Psalm', + 'vendor/gullevek/dotenv', + ], + + // A list of individual files to include in analysis + // with a path relative to the root directory of the + // project. + 'file_list' => [ + "./test/configs/config.php", + "./test/configs/config.other.php", + "./test/configs/config.master.php", + ], ]; diff --git a/www/vendor/egrajp/corelibs-composer-all/composer.json b/www/vendor/egrajp/corelibs-composer-all/composer.json index b688dfdf..e34000c0 100644 --- a/www/vendor/egrajp/corelibs-composer-all/composer.json +++ b/www/vendor/egrajp/corelibs-composer-all/composer.json @@ -16,7 +16,7 @@ ], "minimum-stability": "dev", "require": { - "php": ">=8.1", + "php": ">=8.2", "psr/log": "^3.0@dev" }, "require-dev": { @@ -24,7 +24,8 @@ "phan/phan": "v5.x-dev", "phpunit/phpunit": "^9", "egrajp/smarty-extended": "^4.3", - "vimeo/psalm": "^5.0@dev" + "vimeo/psalm": "^5.0@dev", + "gullevek/dotenv": "dev-master" }, "repositories": { "git.egplusww.jp.Composer": { diff --git a/www/vendor/egrajp/corelibs-composer-all/publish/last.published b/www/vendor/egrajp/corelibs-composer-all/publish/last.published index 1445f05a..9c50fbf5 100644 --- a/www/vendor/egrajp/corelibs-composer-all/publish/last.published +++ b/www/vendor/egrajp/corelibs-composer-all/publish/last.published @@ -1 +1 @@ -9.3.2 +9.5.1 diff --git a/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php b/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php index 8374a592..9522d52c 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/ACL/Login.php @@ -231,8 +231,6 @@ class Login ) { // attach db class $this->db = $db; - // log login data for this class only - $log->setLogFlag(\CoreLibs\Logging\Logger\Flag::per_class); // attach logger $this->log = $log; // attach session class @@ -1060,9 +1058,9 @@ class Login ]; // set the default unit if ($res['edit_default']) { - $_SESSION['UNIT_DEFAULT'] = $res['edit_access_id']; + $_SESSION['UNIT_DEFAULT'] = (int)$res['edit_access_id']; } - $_SESSION['UNIT_UID'][$res['uid']] = $res['edit_access_id']; + $_SESSION['UNIT_UID'][$res['uid']] = (int)$res['edit_access_id']; // sub arrays for simple access array_push($eauid, $res['edit_access_id']); $unit_acl[$res['edit_access_id']] = $res['level']; @@ -1148,18 +1146,18 @@ class Login // user > page > group // group ACL 0 if ($_SESSION['GROUP_ACL_LEVEL'] != -1) { - $this->acl['base'] = $_SESSION['GROUP_ACL_LEVEL']; + $this->acl['base'] = (int)$_SESSION['GROUP_ACL_LEVEL']; } // page ACL 1 if ( isset($_SESSION['PAGES_ACL_LEVEL'][$this->page_name]) && $_SESSION['PAGES_ACL_LEVEL'][$this->page_name] != -1 ) { - $this->acl['base'] = $_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; + $this->acl['base'] = (int)$_SESSION['PAGES_ACL_LEVEL'][$this->page_name]; } // user ACL 2 if ($_SESSION['USER_ACL_LEVEL'] != -1) { - $this->acl['base'] = $_SESSION['USER_ACL_LEVEL']; + $this->acl['base'] = (int)$_SESSION['USER_ACL_LEVEL']; } } $_SESSION['BASE_ACL_LEVEL'] = $this->acl['base']; @@ -2347,7 +2345,10 @@ HTML; is_array($_SESSION['UNIT']) && !array_key_exists($edit_access_id, $_SESSION['UNIT']) ) { - return $_SESSION['UNIT_DEFAULT'] ?? null; + $edit_access_id = null; + if (is_numeric($_SESSION['UNIT_DEFAULT'])) { + $edit_access_id = (int)$_SESSION['UNIT_DEFAULT']; + } } return $edit_access_id; } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php b/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php index 2a8a1dcf..f06b7860 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Admin/Backend.php @@ -556,7 +556,7 @@ class Backend string $suffix = '', int $min_steps = 1, bool $name_pos_back = false - ) { + ): string { // get the build layout $html_time = \CoreLibs\Output\Form\Elements::printDateTime( $year, diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Check/Email.php b/www/vendor/egrajp/corelibs-composer-all/src/Check/Email.php index 6e78beeb..455a7d24 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Check/Email.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Check/Email.php @@ -169,10 +169,10 @@ class Email * @param string $email email string * @param bool $short default false, if true, * returns only short type (pc instead of pc_html) - * @return string|bool email type, eg "pc", "docomo", etc, + * @return string|false email type, eg "pc", "docomo", etc, * false for invalid short type */ - public static function getEmailType(string $email, bool $short = false) + public static function getEmailType(string $email, bool $short = false): string|false { // trip if there is no email address if (!$email) { @@ -200,9 +200,9 @@ class Email * gets the short email type from a long email type * * @param string $email_type email string - * @return string|bool short string or false for invalid + * @return string|false short string or false for invalid */ - public static function getShortEmailType(string $email_type) + public static function getShortEmailType(string $email_type): string|false { // check if the short email type exists if (isset(self::$mobile_email_type_short[$email_type])) { diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php index b88c6d3f..1c6f4b4c 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php @@ -28,7 +28,7 @@ class Colors * @param int $green green 0-255 * @param int $blue blue 0-255 * @param bool $hex_prefix default true, prefix with "#" - * @return string|bool rgb in hex values with leading # if set, + * @return string|false rgb in hex values with leading # if set, * false for invalid color */ public static function rgb2hex( @@ -36,7 +36,7 @@ class Colors int $green, int $blue, bool $hex_prefix = true - ): string|bool { + ): string|false { $hex_color = ''; if ($hex_prefix === true) { $hex_color = '#'; @@ -58,14 +58,14 @@ class Colors * @param string $hexStr RGB hexstring * @param bool $return_as_string flag to return as string * @param string $seperator string seperator: default: "," - * @return string|array|bool false on error or array with RGB - * or a string with the seperator + * @return string|array|false false on error or array with RGB + * or a string with the seperator */ public static function hex2rgb( string $hexStr, bool $return_as_string = false, string $seperator = ',' - ): string|array|bool { + ): string|array|false { $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string if (!is_string($hexStr)) { return false; @@ -97,13 +97,13 @@ class Colors * returns: * array with hue (0-360), sat (0-100%), brightness/value (0-100%) * - * @param int $red red 0-255 - * @param int $green green 0-255 - * @param int $blue blue 0-255 - * @return array|bool Hue, Sat, Brightness/Value - * false for input value error + * @param int $red red 0-255 + * @param int $green green 0-255 + * @param int $blue blue 0-255 + * @return array|false Hue, Sat, Brightness/Value + * false for input value error */ - public static function rgb2hsb(int $red, int $green, int $blue): array|bool + public static function rgb2hsb(int $red, int $green, int $blue): array|false { // check that rgb is from 0 to 255 foreach (['red', 'green', 'blue'] as $c) { @@ -144,13 +144,13 @@ class Colors * converts HSB/V to RGB values RGB is full INT * if HSB/V value is invalid, sets this value to 0 * - * @param float $H hue 0-360 (int) - * @param float $S saturation 0-100 (int) - * @param float $V brightness/value 0-100 (int) - * @return array|bool 0 red/1 green/2 blue array as 0-255 - * false for input value error + * @param float $H hue 0-360 (int) + * @param float $S saturation 0-100 (int) + * @param float $V brightness/value 0-100 (int) + * @return array|false 0 red/1 green/2 blue array as 0-255 + * false for input value error */ - public static function hsb2rgb(float $H, float $S, float $V): array|bool + public static function hsb2rgb(float $H, float $S, float $V): array|false { // check that H is 0 to 359, 360 = 0 // and S and V are 0 to 1 @@ -230,13 +230,13 @@ class Colors * return: * array with hue (0-360), saturation (0-100%) and luminance (0-100%) * - * @param int $red red 0-255 - * @param int $green green 0-255 - * @param int $blue blue 0-255 - * @return array|bool hue/sat/luminance - * false for input value error + * @param int $red red 0-255 + * @param int $green green 0-255 + * @param int $blue blue 0-255 + * @return array|false hue/sat/luminance + * false for input value error */ - public static function rgb2hsl(int $red, int $green, int $blue): array|bool + public static function rgb2hsl(int $red, int $green, int $blue): array|false { // check that rgb is from 0 to 255 foreach (['red', 'green', 'blue'] as $c) { @@ -284,12 +284,12 @@ class Colors * converts an HSL to RGB * if HSL value is invalid, set this value to 0 * - * @param float $hue hue: 0-360 (degrees) - * @param float $sat saturation: 0-100 - * @param float $lum luminance: 0-100 - * @return array|bool red/blue/green 0-255 each + * @param float $hue hue: 0-360 (degrees) + * @param float $sat saturation: 0-100 + * @param float $lum luminance: 0-100 + * @return array|false red/blue/green 0-255 each */ - public static function hsl2rgb(float $hue, float $sat, float $lum): array|bool + public static function hsl2rgb(float $hue, float $sat, float $lum): array|false { if ($hue == 360) { $hue = 0; diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php index 96867157..7f885df4 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Json.php @@ -48,8 +48,26 @@ class Json return (array)$json; } + /** + * convert array to json + * Will set empty json {} on false/error + * Error can be read with jsonGetLastError + * Deos not throw errors + * + * @param array $data + * @param int $flags json_encode flags as is + * @return string JSON string or '{}' if false + */ + public static function jsonConvertArrayTo(array $data, int $flags = 0): string + { + $json_string = json_encode($data, $flags) ?: '{}'; + self::$json_last_error = json_last_error(); + return (string)$json_string; + } + /** * returns human readable string for json errors thrown in jsonConvertToArray + * Source: https://www.php.net/manual/en/function.json-last-error.php * * @param bool $return_string [default=false] if set to true * it will return the message string and not @@ -80,6 +98,15 @@ class Json case JSON_ERROR_UTF8: $json_error_string = 'Malformed UTF-8 characters, possibly incorrectly encoded'; break; + case JSON_ERROR_RECURSION: + $json_error_string = 'One or more recursive references in the value to be encoded'; + break; + case JSON_ERROR_INF_OR_NAN: + $json_error_string = 'One or more NAN or INF values in the value to be encoded'; + break; + case JSON_ERROR_UNSUPPORTED_TYPE: + $json_error_string = ' A value of a type that cannot be encoded was given'; + break; case JSON_ERROR_INVALID_PROPERTY_NAME: $json_error_string = 'A key starting with \u0000 character was in the string'; break; diff --git a/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php b/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php index 3a9d885d..398ba1ce 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/DB/IO.php @@ -302,14 +302,14 @@ class IO /** @var string */ private string $to_encoding = ''; /** @var string the query string at the moment */ - private string $query; + private string $query = ''; /** @var array current params for query */ - private array $params; + private array $params = []; // only inside // basic vars // the dbh handler, if disconnected by command is null, bool:false on error, /** @var \PgSql\Connection|false|null */ - private \PgSql\Connection|false|null $dbh; + private \PgSql\Connection|false|null $dbh = null; /** @var bool DB_DEBUG ... (if set prints out debug msgs) */ private bool $db_debug = false; /** @var string the DB connected to */ @@ -344,7 +344,7 @@ class IO // FOR BELOW: (This should be private and only readable through some method) // cursor array for cached readings /** @var array extended cursoers string index with content */ - private array $cursor_ext; + private array $cursor_ext = []; // per query vars /** @var \PgSql\Result|false actual cursor (DBH) */ private \PgSql\Result|false $cursor; @@ -401,7 +401,7 @@ class IO /** @var bool if we use RETURNING in the INSERT call */ private bool $returning_id = false; /** @var string if a sync is running holds the hash key of the query */ - private string $async_running; + private string $async_running = ''; // logging class, must be public so settings can be changed /** @var \CoreLibs\Logging\Logging */ public \CoreLibs\Logging\Logging $log; @@ -805,7 +805,10 @@ class IO $call_stack[] = ($call_trace['file'] ?? 'n/f') . ':' . ($call_trace['line'] ?? '-') . ':' - . (!empty($call_trace['class']) ? $call_trace['class'] . '->' : '') + . (!empty($call_trace['class']) ? + $call_trace['class'] . ($call_trace['type'] ?? '') : + '' + ) . $call_trace['function']; } $context = [ @@ -825,7 +828,7 @@ class IO ); break; default: - // used named arguments so we can easy change the order of debug + // used named arguments so we can easy change the order of debug $this->log->debug( group_id: $debug_id, message: $error_string, @@ -2057,10 +2060,11 @@ class IO /** * this is only needed for Postgresql. Converts postgresql arrays to PHP * Recommended to rather user 'array_to_json' instead and convet JSON in PHP + * or if ARRAY_AGG -> JSONB_AGG * * @param string $text input text to parse to an array * @return array PHP array of the parsed data - * @deprecated Recommended to use 'array_to_json' in PostgreSQL instead + * @deprecated Recommended to use 'array_to_json/jsonb_agg' in PostgreSQL instead */ public function dbArrayParse(string $text): array { @@ -2683,7 +2687,7 @@ class IO */ public function dbGetCursor(): \PgSql\Result|false { - return $this->cursor; + return $this->cursor ?? false; } // *************************** @@ -2740,7 +2744,7 @@ class IO } $query_hash = $this->dbGetQueryHash($query, $params); if ( - is_array($this->cursor_ext) && + !empty($this->cursor_ext) && isset($this->cursor_ext[$query_hash]) ) { if (empty($query_field)) { @@ -2759,9 +2763,9 @@ class IO * @param string $query Query to find in cursor_ext * @param array $params If the query is params type we need params * data to create a unique call one, optional - * @return int|false query position (row pos), false on error + * @return int|false|null query position (row pos), false on error */ - public function dbGetCursorPos(string $query, array $params = []): int|false + public function dbGetCursorPos(string $query, array $params = []): int|false|null { $this->__dbErrorReset(); if (!$query) { @@ -2769,7 +2773,14 @@ class IO return false; } $query_hash = $this->dbGetQueryHash($query, $params); - return (int)$this->cursor_ext[$query_hash]['pos']; + if ( + !empty($this->cursor_ext) && + isset($this->cursor_ext[$query_hash]) + ) { + return (int)$this->cursor_ext[$query_hash]['pos']; + } else { + return null; + } } /** @@ -2778,9 +2789,9 @@ class IO * @param string $query Query to find in cursor_ext * @param array $params If the query is params type we need params * data to create a unique call one, optional - * @return int|false query position (row pos), false on error + * @return int|false|null numer of rows returned, false on error */ - public function dbGetCursorNumRows(string $query, array $params = []): int|false + public function dbGetCursorNumRows(string $query, array $params = []): int|false|null { $this->__dbErrorReset(); if (!$query) { @@ -2788,7 +2799,14 @@ class IO return false; } $query_hash = $this->dbGetQueryHash($query, $params); - return (int)$this->cursor_ext[$query_hash]['num_rows']; + if ( + !empty($this->cursor_ext) && + isset($this->cursor_ext[$query_hash]) + ) { + return (int)$this->cursor_ext[$query_hash]['num_rows']; + } else { + return null; + } } // *************************** @@ -3190,7 +3208,7 @@ class IO /** * Returns the current async running query hash * - * @return string Current async running query hash + * @return string Current async running query hash, empty string for nothing */ public function dbGetAsyncRunning(): string { @@ -3735,7 +3753,7 @@ class IO * Either a single element for a single insert or an array * if multiple insert values where used. * - * @return array|string|int|null Current insert query primary key + * @return array|string|int|null Current insert query primary key, null on not set */ public function dbGetInsertPK(): array|string|int|null { @@ -3825,7 +3843,7 @@ class IO */ public function dbGetNumRows(): ?int { - return $this->num_rows; + return $this->num_rows ?? null; } /** @@ -3835,10 +3853,7 @@ class IO */ public function dbGetNumFields(): ?int { - if (!isset($this->num_fields)) { - return null; - } - return $this->num_fields; + return $this->num_fields ?? null; } /** diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Debug/LoggingLegacy.php b/www/vendor/egrajp/corelibs-composer-all/src/Debug/LoggingLegacy.php index 6d3a6029..0b5f6fdd 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Debug/LoggingLegacy.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Debug/LoggingLegacy.php @@ -405,7 +405,7 @@ class LoggingLegacy // set per class, but don't use get_class as we will only get self $rpl_string = !$this->log_per_class ? '' : '_' // set sub class settings - . str_replace('\\', '-', Support::getCallerClass()); + . str_replace('\\', '-', Support::getCallerTopLevelClass()); $fn = str_replace('{CLASS}', $rpl_string, $fn); // create output filename // if request to write to one file @@ -756,7 +756,7 @@ class LoggingLegacy return $status; } // get the last class entry and wrie that - $class = Support::getCallerClass(); + $class = Support::getCallerTopLevelClass(); // get timestamp $timestamp = Support::printTime(); // same string put for print (no html data inside) @@ -855,7 +855,7 @@ class LoggingLegacy . 'border-bottom: 1px solid black; margin: 10px 0 10px 0; ' . 'background-color: white; color: black;">' . '
{' - . Support::getCallerClass() . '}
'; + . Support::getCallerTopLevelClass() . '}'; $string_output = $string_prefix . $string_output . '
Script Run Time: ' . $script_end . '
' diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Debug/Support.php b/www/vendor/egrajp/corelibs-composer-all/src/Debug/Support.php index cc1333db..456be11c 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Debug/Support.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Debug/Support.php @@ -79,10 +79,10 @@ class Support * default true: true, false: false * * @param bool $bool Variable to convert - * @param string $name [default: ''] Prefix name - * @param string $true [default: 'true'] True string - * @param string $false [default: 'false'] False string - * @param bool $no_html [default: false] if true do not print html + * @param string $name [=''] Prefix name + * @param string $true [='true'] True string + * @param string $false [='false'] False string + * @param bool $no_html [=false] if true do not print html * @return string String with converted bool text for debug */ public static function printBool( @@ -104,8 +104,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 [default: 'true'] Override default string 'true' - * @param string $false [default: '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( @@ -159,7 +159,7 @@ class Support * Recommended debug output * * @param mixed $data Anything - * @param bool $no_html [default=false] If true strip all html tags + * @param bool $no_html [=false] If true strip all html tags * (for text print) * @return string A text string */ @@ -203,7 +203,7 @@ class Support * exports (dumps) var, in more printable design, but without detail info * * @param mixed $data Anything - * @param bool $no_html If true true do not add
 tags
+	 * @param  bool   $no_html [=false] If true true do not add 
 tags
 	 * @return string          A text string
 	 */
 	public static function exportVar(mixed $data, bool $no_html = false): string
@@ -217,7 +217,7 @@ class Support
 	 * Return file name and line number where this was called
 	 * One level up
 	 *
-	 * @param  int         $level trace level, default 1
+	 * @param  int         $level [=1] trace level
 	 * @return string|null        null or file name:line number
 	 */
 	public static function getCallerFileLine(int $level = 1): ?string
@@ -238,14 +238,14 @@ class Support
 	 * eg for debugging, this function does this
 	 *
 	 * call this method in the child method and you get the parent function that called
-	 * @param  int    $level trace level, default 1
-	 * @return ?string       null or the function that called the function
-	 *                       where this method is called
+	 * @param  int         $level [=1] trace level
+	 * @return string|null        null or the function that called the function
+	 *                            where this method is called
 	 */
 	public static function getCallerMethod(int $level = 1): ?string
 	{
 		$traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
-		// print \CoreLibs\Debug\Support::printAr($traces);
+		// print "getCallerMethod:
" . \CoreLibs\Debug\Support::printAr($traces); // We should check from top down if unset? // sets the start point here, and in level two (the sub call) we find this if (isset($traces[$level])) { @@ -254,6 +254,41 @@ class Support return null; } + /** + * get the class that first called it and skip the base class + * Companion method to getCallerMethod + * + * @param int $level [=1] trace level + * @return ?string null if class not found + */ + public static function getCallerClass(int $level = 1): ?string + { + $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + // print "getCallerClass:
" . \CoreLibs\Debug\Support::printAr($traces); + if (isset($traces[$level])) { + return $traces[$level]['class'] ?? null; + } + return null; + } + + /** + * Returns class and method together + * + * @param int $level [=1] travel level + * @return string|null null if trace level not found, else namespace class and method + */ + public static function getCallerClassMethod(int $level = 1): ?string + { + $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + // print "getCallerClass:
" . \CoreLibs\Debug\Support::printAr($traces); + if (isset($traces[$level])) { + return ($traces[$level]['class'] ?? '-') + . ($traces[$level]['type'] ?? '') + . $traces[$level]['function']; + } + return null; + } + /** * Returns array with all methods in the call stack in the order so that last * called is last in order @@ -283,25 +318,21 @@ class Support * Is mostly used in debug log statements to get the class where the debug * was called * gets top level class - * loops over the debug backtrace until if finds the first class (from the end) + * loops over the debug backtrace until if finds the first class (from the end) * * @return string Class name with namespace */ - public static function getCallerClass(): string + public static function getCallerTopLevelClass(): string { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - // ?? [['class' => get_called_class()]]; - // TODO make sure that this doesn't loop forver + $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + // print "getCallerClass:
" . \CoreLibs\Debug\Support::printAr($traces); $class = null; - while ($class === null && count($backtrace) > 0) { - // if current is - // [function] => debug - // [class] => CoreLibs\Debug\Logging - // then return - // (OUTSIDE) because it was not called from a class method - // or return file name - $get_class = array_pop($backtrace); - $class = $get_class['class'] ?? null; + // reverse and stop at first set class, this is the top level one + foreach (array_reverse($traces) as $trace) { + $class = $trace['class'] ?? null; + if (!empty($class)) { + break; + } } // on null or empty return empty string return empty($class) ? '' : $class; diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Logging/Logging.php b/www/vendor/egrajp/corelibs-composer-all/src/Logging/Logging.php index 6c748452..d672d9a7 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Logging/Logging.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Logging/Logging.php @@ -381,7 +381,7 @@ class Logging // auto set (should be deprecated in future) $this->setLogFileId( str_replace(':', '-', $this->host_name) . '_' - . str_replace('\\', '-', Support::getCallerClass()) + . str_replace('\\', '-', Support::getCallerTopLevelClass()) ); } if (empty($this->getLogFileId())) { @@ -460,7 +460,7 @@ class Logging // set per class, but don't use get_class as we will only get self $rpl_string = !$this->getLogFlag(Flag::per_class) ? '' : '_' // set sub class settings - . str_replace('\\', '-', Support::getCallerClass()); + . str_replace('\\', '-', Support::getCallerTopLevelClass()); $fn = str_replace('{CLASS}', $rpl_string, $fn); // create output filename // if request to write to one file @@ -526,7 +526,10 @@ class Logging /** * Prepare the log message with all needed info blocks: - * [timestamp] [host name] [file path + file] [running uid] {class} - message + * [timestamp] [host name] [file path + file::row number] [running uid] {class::/->method} + * - message + * Note: group id is only for debug level + * if no method can be found or no class is found a - will be wirtten * * @param Level $level Log level we will write to * @param string|Stringable $message The message to write @@ -545,16 +548,32 @@ class Logging if (!$this->checkLogLevel($level)) { return ''; } + $file_line = ''; + $caller_class_method = '-'; + $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + // print "[" . $level->getName() . "] [$message] prepareLog:
" . Support::printAr($traces); // file + line: call not this but one before (the one that calls this) - $file_line = Support::getCallerFileLine(2) ?? - System::getPageName(System::FULL_PATH); - // get the last class entry and wrie that - $class = Support::getCallerClass(); - // method/function: prepareLog->(debug|info|...)->[THIS] - $method = Support::getCallerMethod(3); - if ($method !== null) { - $class .= '::' . $method; + // start from this level, if unset fall down until we are at null + $start_trace_level = 2; + for ($trace_level = $start_trace_level; $trace_level >= 0; $trace_level--) { + if (isset($traces[$trace_level])) { + $file_line = ($traces[$trace_level]['file'] ?? $traces[$trace_level]['function']) + . ':' . ($traces[$trace_level]['line'] ?? '-'); + // as namespace\class->method + $caller_class_method = + // get the last call before we are in the Logging class + ($traces[$trace_level]['class'] ?? '') + // connector, if unkown use == + . ($traces[$trace_level]['type'] ?? '') + // method/function: prepareLog->(debug|info|...)->[THIS] + . $traces[$trace_level]['function']; + break; + } } + if (empty($file_line)) { + $file_line = System::getPageName(System::FULL_PATH); + } + // print "CLASS: " . $class . "
"; // get timestamp $timestamp = Support::printTime(); @@ -574,7 +593,7 @@ class Logging . '[' . $this->host_name . '] ' . '[' . $file_line . '] ' . '[' . $this->running_uid . '] ' - . '{' . $class . '} ' + . '{' . $caller_class_method . '} ' . '<' . strtoupper($group_str) . '> ' . $message . $context_str; diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertJsonTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertJsonTest.php index af6e7e35..74e7ec75 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertJsonTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertJsonTest.php @@ -16,7 +16,7 @@ final class CoreLibsConvertJsonTest extends TestCase /** * test list for json convert tests * - * @return array + * @return array */ public function jsonProvider(): array { @@ -54,10 +54,36 @@ final class CoreLibsConvertJsonTest extends TestCase ]; } + /** + * Undocumented function + * + * @return array + */ + public function jsonArrayProvider(): array + { + return [ + 'valid json' => [ + [ + 'm' => 2, + 'f' => 'sub_2' + ], + '{"m":2,"f":"sub_2"}', + ], + 'empty json array' => [ + [], + '[]' + ], + 'empty json hash' => [ + ['' => ''], + '{"":""}' + ] + ]; + } + /** * json error list * - * @return array JSON error list + * @return array JSON error list */ public function jsonErrorProvider(): array { @@ -127,7 +153,7 @@ final class CoreLibsConvertJsonTest extends TestCase * * @param string|null $input * @param bool $flag - * @param array $expected + * @param array $expected * @return void */ public function testJsonConvertToArray(?string $input, bool $flag, array $expected): void @@ -146,7 +172,8 @@ final class CoreLibsConvertJsonTest extends TestCase * @testdox jsonGetLastError $input will be $expected_i/$expected_s [$_dataName] * * @param string|null $input - * @param string $expected + * @param int $expected_i + * @param string $expected_s * @return void */ public function testJsonGetLastError(?string $input, int $expected_i, string $expected_s): void @@ -161,6 +188,25 @@ final class CoreLibsConvertJsonTest extends TestCase \CoreLibs\Convert\Json::jsonGetLastError(true) ); } + + /** + * Undocumented function + * + * @covers ::jsonConvertArrayTo + * @dataProvider jsonArrayProvider + * @testdox jsonConvertArrayTo $input (Override: $flag) will be $expected [$_dataName] + * + * @param array $input + * @param string $expected + * @return void + */ + public function testJsonConvertArrayto(array $input, string $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Convert\Json::jsonConvertArrayTo($input) + ); + } } // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Debug/CoreLibsDebugSupportTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Debug/CoreLibsDebugSupportTest.php index 15e0e9c8..2420d5a6 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Debug/CoreLibsDebugSupportTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Debug/CoreLibsDebugSupportTest.php @@ -562,10 +562,10 @@ final class CoreLibsDebugSupportTest extends TestCase } /** - * Undocumented function + * test the lowest one (one above base) * * @cover ::getCallerClass - * @testWith ["PHPUnit\\TextUI\\Command"] + * @testWith ["tests\\CoreLibsDebugSupportTest"] * @testdox getCallerClass check if it returns $expected [$_dataName] * * @return void @@ -578,6 +578,40 @@ final class CoreLibsDebugSupportTest extends TestCase ); } + /** + * test highest return (top level) + * + * @cover ::getCallerTopLevelClass + * @testWith ["PHPUnit\\TextUI\\Command"] + * @testdox getCallerTopLevelClass check if it returns $expected [$_dataName] + * + * @return void + */ + public function testGetCallerTopLevelClass(string $expected): void + { + $this->assertEquals( + $expected, + Support::getCallerTopLevelClass() + ); + } + + /** + * test highest return (top level) + * + * @cover ::getCallerClassMethod + * @testWith ["tests\\CoreLibsDebugSupportTest->testGetCallerClassMethod"] + * @testdox getCallerClassMethod check if it returns $expected [$_dataName] + * + * @return void + */ + public function testGetCallerClassMethod(string $expected): void + { + $this->assertEquals( + $expected, + Support::getCallerClassMethod() + ); + } + /** * Undocumented function * diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php index e60efc52..bf9a189f 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php @@ -22,7 +22,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase . "\[[\w\.]+(:\d+)?\]\s{1}" // host:port . "\[[\w\-\.\/]+:\d+\]\s{1}" // folder/file . "\[\w+\]\s{1}" // run id - . "{[\w\\\\]+(::\w+)?}\s{1}"; // class + . "{[\w\\\\]+((::|->)\w+)?}\s{1}"; // class public static function tearDownAfterClass(): void {