diff --git a/4dev/tests/Convert/CoreLibsConvertJsonTest.php b/4dev/tests/Convert/CoreLibsConvertJsonTest.php index af6e7e35..74e7ec75 100644 --- a/4dev/tests/Convert/CoreLibsConvertJsonTest.php +++ b/4dev/tests/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/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index c317b77b..00000000 --- a/phpstan-baseline.neon +++ /dev/null @@ -1,47 +0,0 @@ -parameters: - ignoreErrors: - - - message: "#^Parameter \\#1 \\$connection of function pg_escape_bytea expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_escape_identifier expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_escape_literal expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_escape_string expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_execute expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_parameter_status expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_prepare expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_query expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - - - - message: "#^Parameter \\#1 \\$connection of function pg_query_params expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#" - count: 1 - path: www/lib/CoreLibs/DB/SQL/PgSQL.php - diff --git a/www/admin/class_test.html_build.element.php b/www/admin/class_test.html_build.element.php index 68bb56f6..94bdcc40 100644 --- a/www/admin/class_test.html_build.element.php +++ b/www/admin/class_test.html_build.element.php @@ -75,6 +75,7 @@ print "EL_O:
" . print_r($el_o, true) . "
"; echo "
"; print "buildHtml():
" . htmlentities($el_o->buildHtml()) . "
"; echo "
"; +/** @phpstan-ignore-next-line */ print "phfo(\$el_o):
" . htmlentities($el_o::printHtmlFromObject($el_o, true)) . "
"; echo "
"; print "phfa(\$el_list):
" . htmlentities($el_o::buildHtmlFromList($el_o_list, true)) . "
"; 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.lang.php b/www/admin/class_test.lang.php index 989bdd02..fc7a9a95 100644 --- a/www/admin/class_test.lang.php +++ b/www/admin/class_test.lang.php @@ -51,6 +51,7 @@ echo "
AUTO DETECT
"; // DEPRECATED // $get_locale = Language\GetLocale::setLocale(); // print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "
"; +/** @phpstan-ignore-next-line */ $get_locale = Language\GetLocale::setLocaleFromSession( SITE_LOCALE, str_replace('/', '', CONTENT_PATH), @@ -58,6 +59,7 @@ $get_locale = Language\GetLocale::setLocaleFromSession( BASE . INCLUDES . LOCALE ); print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "
"; +/** @phpstan-ignore-next-line */ $get_locale = Language\GetLocale::setLocaleFromSession( 'en', 'foo', @@ -74,6 +76,7 @@ $_SESSION['DEFAULT_LOCALE'] = 'ja_JP.UTF-8'; $_SESSION['DEFAULT_CHARSET'] = 'UTF-8'; $_SESSION['DEFAULT_DOMAIN'] = 'admin'; $_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE; +/** @phpstan-ignore-next-line */ $get_locale = Language\GetLocale::setLocaleFromSession( SITE_LOCALE, SITE_DOMAIN, @@ -90,6 +93,7 @@ $_SESSION['DEFAULT_LOCALE'] = '00000#####'; $_SESSION['DEFAULT_CHARSET'] = ''; $_SESSION['DEFAULT_DOMAIN'] = 'admin'; $_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE; +/** @phpstan-ignore-next-line */ $get_locale = Language\GetLocale::setLocaleFromSession( SITE_LOCALE, SITE_DOMAIN, diff --git a/www/admin/class_test.readenvfile.php b/www/admin/class_test.readenvfile.php index 28d706c7..08c989a0 100644 --- a/www/admin/class_test.readenvfile.php +++ b/www/admin/class_test.readenvfile.php @@ -35,10 +35,12 @@ print '

' . $PAGE_NAME . '

'; print "ALREADY from config.php: " . \CoreLibs\Debug\Support::printAr($_ENV) . "
"; // test .env in local +/** @phpstan-ignore-next-line */ $status = \CoreLibs\Get\DotEnv::readEnvFile('.', 'test.env'); print "test.env: STATUS: " . $status . "
"; print "AFTER reading test.env file: " . \CoreLibs\Debug\Support::printAr($_ENV) . "
"; print ""; +// ;; // __END__