diff --git a/4dev/composer/sync-to-composer-all-folder.sh b/4dev/composer/sync-to-composer-all-folder.sh new file mode 100644 index 00000000..d717bfcb --- /dev/null +++ b/4dev/composer/sync-to-composer-all-folder.sh @@ -0,0 +1,22 @@ +#!/bin/env bash + +# syncs +# 4dev/tests/ +# www/lib/CoreLibs/ +# +# to the composer corelibs all repo + +GO="${1}"; +DRY_RUN=""; +if [ "${GO}" != "go" ]; then + DRY_RUN="-n "; +fi; + +BASE="/storage/var/www/html/developers/clemens/core_data/"; +SOURCE="${BASE}php_libraries/trunk/" +TARGET="${BASE}composer-packages/CoreLibs-Composer-All/" + +rsync ${DRY_RUN}-Plzvrupt --stats --delete ${SOURCE}4dev/tests/ ${TARGET}test/phpunit/ +rsync ${DRY_RUN}-Plzvrupt --stats --delete ${SOURCE}www/lib/CoreLibs/ ${TARGET}src/ + +# __END__ diff --git a/4dev/tests/ACL/CoreLibsACLLoginTest.php b/4dev/tests/ACL/CoreLibsACLLoginTest.php index 2d011949..361e8edb 100644 --- a/4dev/tests/ACL/CoreLibsACLLoginTest.php +++ b/4dev/tests/ACL/CoreLibsACLLoginTest.php @@ -120,8 +120,6 @@ final class CoreLibsACLLoginTest extends TestCase // define('LOGIN_DB_SCHEMA', ''); // SHOULD SET - // PASSWORD_MIN_LENGTH (d9) - // PASSWORD_MAX_LENGTH (d255) // DEFAULT_ACL_LEVEL (d80) // OPT: @@ -1106,7 +1104,21 @@ final class CoreLibsACLLoginTest extends TestCase /** @var \CoreLibs\ACL\Login&MockObject */ $login_mock = $this->getMockBuilder(\CoreLibs\ACL\Login::class) - ->setConstructorArgs([self::$db, self::$log, $session_mock, false]) + ->setConstructorArgs([ + self::$db, + self::$log, + $session_mock, + [ + 'auto_login' => false, + 'default_acl_level' => 80, + 'logout_target' => '', + 'site_locale' => 'en_US.UTF-8', + 'site_domain' => 'admin', + 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR, + ] + ]) ->onlyMethods(['loginTerminate', 'loginReadPageName', 'loginPrintLogin']) ->getMock(); $login_mock->expects($this->any()) @@ -1774,7 +1786,21 @@ final class CoreLibsACLLoginTest extends TestCase ); /** @var \CoreLibs\ACL\Login&MockObject */ $login_mock = $this->getMockBuilder(\CoreLibs\ACL\Login::class) - ->setConstructorArgs([self::$db, self::$log, $session_mock, false]) + ->setConstructorArgs([ + self::$db, + self::$log, + $session_mock, + [ + 'auto_login' => false, + 'default_acl_level' => 80, + 'logout_target' => '', + 'site_locale' => 'en_US.UTF-8', + 'site_domain' => 'admin', + 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR, + ] + ]) ->onlyMethods(['loginTerminate']) ->getMock(); $login_mock->expects($this->any()) @@ -1873,7 +1899,21 @@ final class CoreLibsACLLoginTest extends TestCase ); /** @var \CoreLibs\ACL\Login&MockObject */ $login_mock = $this->getMockBuilder(\CoreLibs\ACL\Login::class) - ->setConstructorArgs([self::$db, self::$log, $session_mock, false]) + ->setConstructorArgs([ + self::$db, + self::$log, + $session_mock, + [ + 'auto_login' => false, + 'default_acl_level' => 80, + 'logout_target' => '', + 'site_locale' => 'en_US.UTF-8', + 'site_domain' => 'admin', + 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR, + ] + ]) ->onlyMethods(['loginTerminate']) ->getMock(); $login_mock->expects($this->any()) @@ -1946,7 +1986,21 @@ final class CoreLibsACLLoginTest extends TestCase ); /** @var \CoreLibs\ACL\Login&MockObject */ $login_mock = $this->getMockBuilder(\CoreLibs\ACL\Login::class) - ->setConstructorArgs([self::$db, self::$log, $session_mock, false]) + ->setConstructorArgs([ + self::$db, + self::$log, + $session_mock, + [ + 'auto_login' => false, + 'default_acl_level' => 80, + 'logout_target' => '', + 'site_locale' => 'en_US.UTF-8', + 'site_domain' => 'admin', + 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR, + ] + ]) ->onlyMethods(['loginTerminate']) ->getMock(); $login_mock->expects($this->any()) @@ -2027,7 +2081,21 @@ final class CoreLibsACLLoginTest extends TestCase ); /** @var \CoreLibs\ACL\Login&MockObject */ $login_mock = $this->getMockBuilder(\CoreLibs\ACL\Login::class) - ->setConstructorArgs([self::$db, self::$log, $session_mock, false]) + ->setConstructorArgs([ + self::$db, + self::$log, + $session_mock, + [ + 'auto_login' => false, + 'default_acl_level' => 80, + 'logout_target' => '', + 'site_locale' => 'en_US.UTF-8', + 'site_domain' => 'admin', + 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR, + ] + ]) ->onlyMethods(['loginTerminate']) ->getMock(); $login_mock->expects($this->any()) diff --git a/4dev/tests/ACL/includes b/4dev/tests/ACL/includes new file mode 120000 index 00000000..d9cfd763 --- /dev/null +++ b/4dev/tests/ACL/includes @@ -0,0 +1 @@ +../AAASetupData/includes \ No newline at end of file diff --git a/4dev/tests/Combined/CoreLibsCombinedArrayHandlerTest.php b/4dev/tests/Combined/CoreLibsCombinedArrayHandlerTest.php index 689f5922..0bc60dda 100644 --- a/4dev/tests/Combined/CoreLibsCombinedArrayHandlerTest.php +++ b/4dev/tests/Combined/CoreLibsCombinedArrayHandlerTest.php @@ -738,7 +738,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase $warning = array_shift($arrays); // phpunit 10.0 compatible - $this->expectExceptionMessage(($warning)); + $this->expectExceptionMessage($warning); \CoreLibs\Combined\ArrayHandler::arrayMergeRecursive(...$arrays); diff --git a/4dev/tests/Debug/CoreLibsDebugLoggingTest.php b/4dev/tests/Debug/CoreLibsDebugLoggingTest.php index 03f3c912..6b7daad0 100644 --- a/4dev/tests/Debug/CoreLibsDebugLoggingTest.php +++ b/4dev/tests/Debug/CoreLibsDebugLoggingTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase; */ final class CoreLibsDebugLoggingTest extends TestCase { + private const LOG_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR; /** * test set for options BASIC * @@ -33,7 +34,8 @@ final class CoreLibsDebugLoggingTest extends TestCase return [ 'log folder set' => [ [ - 'log_folder' => DIRECTORY_SEPARATOR . 'tmp' + 'log_folder' => DIRECTORY_SEPARATOR . 'tmp', + 'file_id' => 'testClassInit' ], [ 'log_folder' => DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR, @@ -43,7 +45,9 @@ final class CoreLibsDebugLoggingTest extends TestCase [] ], 'nothing set' => [ - null, + [ + 'file_id' => 'testClassInit' + ], [ 'log_folder' => getcwd() . DIRECTORY_SEPARATOR, 'debug_all' => false, @@ -51,8 +55,10 @@ final class CoreLibsDebugLoggingTest extends TestCase ], [] ], - 'no options set, constant set' => [ - null, + 'no options set, constant set [DEPRECATED]' => [ + [ + 'file_id' => 'testClassInit' + ], [ 'log_folder' => str_replace(DIRECTORY_SEPARATOR . 'configs', '', __DIR__) . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR, @@ -70,6 +76,7 @@ final class CoreLibsDebugLoggingTest extends TestCase 'standard test set' => [ [ 'log_folder' => DIRECTORY_SEPARATOR . 'tmp', + 'file_id' => 'testClassInit', 'debug_all' => true, 'print_all' => true, ], @@ -89,12 +96,12 @@ final class CoreLibsDebugLoggingTest extends TestCase * @dataProvider optionsProvider * @testdox init test [$_dataName] * - * @param array|null $options + * @param array $options * @param array $expected * @param array $override * @return void */ - public function testClassInit(?array $options, array $expected, array $override): void + public function testClassInit(array $options, array $expected, array $override): void { if (!empty($override['constant'])) { foreach ($override['constant'] as $var => $value) { @@ -116,11 +123,24 @@ final class CoreLibsDebugLoggingTest extends TestCase ); } } - if ($options === null) { - $log = new \CoreLibs\Debug\Logging(); - } else { - $log = new \CoreLibs\Debug\Logging($options); + // if not log folder and constant set -> expect E_USER_DEPRECATION + if (!empty($override['constant']) && empty($options['log_folder'])) { + // the deprecation message + $deprecation_message = 'options: log_folder must be set. ' + . 'Setting via BASE and LOG constants is deprecated'; + // convert E_USER_DEPRECATED to a exception + set_error_handler( + static function (int $errno, string $errstr): never { + throw new \Exception($errstr, $errno); + }, + E_USER_DEPRECATED + ); + // catch this with the message + $this->expectExceptionMessage($deprecation_message); } + $log = new \CoreLibs\Debug\Logging($options); + // reset error handler + restore_error_handler(); // check that settings match $this->assertEquals( $expected['log_folder'], @@ -152,17 +172,23 @@ final class CoreLibsDebugLoggingTest extends TestCase // 0: options // 1: expected // 2: override + // 3: exception message return [ 'no log id set' => [ - null, + [ + 'log_folder' => self::LOG_FOLDER, + ], [ 'log_file_id' => '' ], - [] + [], + null ], // set log id manually afterwards 'set log id manually' => [ - null, + [ + 'log_folder' => self::LOG_FOLDER, + ], [ 'log_file_id' => '', 'set_log_file_id' => 'abc123', @@ -172,21 +198,26 @@ final class CoreLibsDebugLoggingTest extends TestCase 'values' => [ 'log_file_id' => 'abc123' ] - ] + ], + null ], // set log id from options 'set log id via options' => [ [ 'file_id' => 'abc456', + 'log_folder' => self::LOG_FOLDER, ], [ 'log_file_id' => 'abc456' ], - [] + [], + null ], // set log id from GLOBALS [DEPRECATED] - 'set log id via globals' => [ - null, + 'set log id via globals [DEPRECATED]' => [ + [ + 'log_folder' => self::LOG_FOLDER, + ], [ 'log_file_id' => 'def123' ], @@ -194,11 +225,14 @@ final class CoreLibsDebugLoggingTest extends TestCase 'globals' => [ 'LOG_FILE_ID' => 'def123' ] - ] + ], + 'options: file_id must be set. Setting via LOG_FILE_ID global variable is deprecated' ], // set log id from CONSTANT [DEPRECATED] - 'set log id via constant' => [ - null, + 'set log id via constant [DEPRECATED]' => [ + [ + 'log_folder' => self::LOG_FOLDER, + ], [ 'log_file_id' => 'ghi123' ], @@ -210,12 +244,14 @@ final class CoreLibsDebugLoggingTest extends TestCase 'constant' => [ 'LOG_FILE_ID' => 'ghi123' ] - ] + ], + 'options: file_id must be set. Setting via LOG_FILE_ID constant is deprecated' ], // invalid, keep previous set 'invalid log id' => [ [ - 'file_id' => 'jkl456' + 'file_id' => 'jkl456', + 'log_folder' => self::LOG_FOLDER, ], [ 'log_file_id' => 'jkl456', @@ -225,7 +261,8 @@ final class CoreLibsDebugLoggingTest extends TestCase 'values' => [ 'log_file_id' => './#' ] - ] + ], + null ] ]; } @@ -237,13 +274,18 @@ final class CoreLibsDebugLoggingTest extends TestCase * @dataProvider logIdOptionsProvider * @testdox log id set/get tests [$_dataName] * - * @param array|null $options + * @param array $options * @param array $expected * @param array $override + * @param string|null $deprecation_message until we remove the old code * @return void */ - public function testLogId(?array $options, array $expected, array $override): void - { + public function testLogId( + array $options, + array $expected, + array $override, + ?string $deprecation_message + ): void { // we need to set with file_id option, globals LOG_FILE_ID, constant LOG_FILE_ID if (!empty($override['constant'])) { foreach ($override['constant'] as $var => $value) { @@ -255,11 +297,20 @@ final class CoreLibsDebugLoggingTest extends TestCase $GLOBALS[$var] = $value; } } - if ($options === null) { - $log = new \CoreLibs\Debug\Logging(); - } else { - $log = new \CoreLibs\Debug\Logging($options); + if (!empty($override['constant']) || !empty($override['globals'])) { + // convert E_USER_DEPRECATED to a exception + set_error_handler( + static function (int $errno, string $errstr): never { + throw new \Exception($errstr, $errno); + }, + E_USER_DEPRECATED + ); + // catch this with the message + $this->expectExceptionMessage($deprecation_message); } + $log = new \CoreLibs\Debug\Logging($options); + // reset error handler + restore_error_handler(); // check current $this->assertEquals( $log->getLogId(), @@ -334,7 +385,10 @@ final class CoreLibsDebugLoggingTest extends TestCase bool $expected_get ): void { // neutral start with default - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testSetGetLogLevelAll', + 'log_folder' => self::LOG_FOLDER + ]); // set and check $this->assertEquals( $log->setLogLevelAll($type, $flag), @@ -456,7 +510,10 @@ final class CoreLibsDebugLoggingTest extends TestCase $expected_get ): void { // neutral start with default - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testSetGetLogLevel', + 'log_folder' => self::LOG_FOLDER + ]); // set $this->assertEquals( $log->setLogLevel($type, $flag, $debug_on), @@ -535,7 +592,10 @@ final class CoreLibsDebugLoggingTest extends TestCase bool $expected_get ): void { // neutral start with default - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testSetGetLogPer', + 'log_folder' => self::LOG_FOLDER + ]); // set and check $this->assertEquals( $log->setLogPer($type, $set), @@ -564,7 +624,10 @@ final class CoreLibsDebugLoggingTest extends TestCase public function testSetGetLogPrintFileDate(bool $input, bool $expected_set, bool $expected_get): void { // neutral start with default - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testSetGetLogPrintFileDate', + 'log_folder' => self::LOG_FOLDER + ]); // set and check $this->assertEquals( $log->setGetLogPrintFileDate($input), @@ -630,7 +693,10 @@ final class CoreLibsDebugLoggingTest extends TestCase */ public function testPrAr(array $input, string $expected): void { - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testPrAr', + 'log_folder' => self::LOG_FOLDER + ]); $this->assertEquals( $log->prAr($input), $expected @@ -691,7 +757,10 @@ final class CoreLibsDebugLoggingTest extends TestCase */ public function testPrBl(bool $input, ?string $true, ?string $false, string $expected): void { - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testPrBl', + 'log_folder' => self::LOG_FOLDER + ]); $return = ''; if ($true === null && $false === null) { $return = $log->prBl($input); @@ -977,9 +1046,16 @@ final class CoreLibsDebugLoggingTest extends TestCase public function testLogUniqueId(bool $option, bool $override): void { if ($option === true) { - $log = new \CoreLibs\Debug\Logging(['per_run' => $option]); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testLogUniqueId', + 'log_folder' => self::LOG_FOLDER, + 'per_run' => $option + ]); } else { - $log = new \CoreLibs\Debug\Logging(); + $log = new \CoreLibs\Debug\Logging([ + 'file_id' => 'testLogUniqueId', + 'log_folder' => self::LOG_FOLDER + ]); $log->setLogUniqueId(); } $per_run_id = $log->getLogUniqueId(); diff --git a/4dev/tests/Get/CoreLibsGetDotEnvTest.php b/4dev/tests/Get/CoreLibsGetDotEnvTest.php index 285e19ef..ac8d2c70 100644 --- a/4dev/tests/Get/CoreLibsGetDotEnvTest.php +++ b/4dev/tests/Get/CoreLibsGetDotEnvTest.php @@ -134,6 +134,16 @@ final class CoreLibsGetDotEnvTest extends TestCase $old_chmod = fileperms($folder . DIRECTORY_SEPARATOR . $file); chmod($folder . DIRECTORY_SEPARATOR . $file, octdec($chmod)); } + $message = '\CoreLibs\Get\DotEnv is deprecated in favor for ' + . 'composer package gullevek\dotenv which is a copy of this'; + // convert E_USER_DEPRECATED to a exception + set_error_handler( + static function (int $errno, string $errstr): never { + throw new \Exception($errstr, $errno); + }, + E_USER_DEPRECATED + ); + $this->expectExceptionMessage($message); if ($folder !== null && $file !== null) { $status = DotEnv::readEnvFile($folder, $file); } elseif ($folder !== null) { @@ -141,6 +151,7 @@ final class CoreLibsGetDotEnvTest extends TestCase } else { $status = DotEnv::readEnvFile(); } + restore_error_handler(); $this->assertEquals( $status, $expected_status, diff --git a/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php b/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php index 981c3e27..f8c9c454 100644 --- a/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php +++ b/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php @@ -60,7 +60,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase /** * all the test data * - * @return array + * @return array */ public function setLocaleProvider(): array { @@ -72,6 +72,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase // 4: SESSION: DEFAULT_LOCALE // 5: SESSION: DEFAULT_CHARSET // 6: expected array + // 7: deprecation message 'no params, all default constants' => [ // lang, domain, encoding, path null, null, null, null, @@ -85,6 +86,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $locale or unset SESSION locale is deprecated', ], 'no params, session charset and lang' => [ // lang, domain, encoding, path @@ -99,6 +101,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $domain is deprecated' ], 'no params, session charset and lang short' => [ // lang, domain, encoding, path @@ -113,6 +116,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $domain is deprecated', ], // param lang (no sessions) 'locale param only, no sessions' => [ @@ -128,6 +132,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $domain is deprecated', ], // different locale setting 'locale complex param only, no sessions' => [ @@ -143,6 +148,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'SJIS', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $domain is deprecated', ], // param lang and domain (no override) 'locale, domain params, no sessions' => [ @@ -158,6 +164,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $path is deprecated', ], // param lang and domain (no override) 'locale, domain, encoding params, no sessions' => [ @@ -173,6 +180,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $path is deprecated' ], // lang, domain, path (no override) 'locale, domain and path, no sessions' => [ @@ -188,6 +196,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?locale_other\/$/", ], + null ], // all params set (no override) 'all parameter, no sessions' => [ @@ -203,6 +212,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?locale_other\/$/", ], + null ], // param lang and domain (no override) 'long locale, domain, encoding params, no sessions' => [ @@ -218,6 +228,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase 'encoding' => 'UTF-8', 'path' => "/^\/(.*\/)?includes\/locale\/$/", ], + 'setLocale: Unset $path is deprecated', ], // TODO invalid params (bad path) (no override) // TODO param calls, but with override set @@ -225,14 +236,22 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase } /** - * Undocumented function - * - * @covers ::setLocale - * @dataProvider setLocaleProvider - * @testdox lang settings lang $language, domain $domain, encoding $encoding, path $path; session lang: $SESSION_DEFAULT_LOCALE, session char: $SESSION_DEFAULT_CHARSET [$_dataName] - * - * @return void - */ + * Undocumented function + * + * @covers ::setLocale + * @dataProvider setLocaleProvider + * @testdox lang settings lang $language, domain $domain, encoding $encoding, path $path; session lang: $SESSION_DEFAULT_LOCALE, session char: $SESSION_DEFAULT_CHARSET [$_dataName] + * + * @param string|null $language + * @param string|null $domain + * @param string|null $encoding + * @param string|null $path + * @param string|null $SESSION_DEFAULT_LOCALE + * @param string|null $SESSION_DEFAULT_CHARSET + * @param array $expected + * @param string|null $deprecation_message + * @return void + */ public function testsetLocale( ?string $language, ?string $domain, @@ -240,7 +259,8 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase ?string $path, ?string $SESSION_DEFAULT_LOCALE, ?string $SESSION_DEFAULT_CHARSET, - array $expected + array $expected, + ?string $deprecation_message ): void { $return_lang_settings = []; global $_SESSION; @@ -251,19 +271,41 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase if ($SESSION_DEFAULT_CHARSET !== null) { $_SESSION['DEFAULT_CHARSET'] = $SESSION_DEFAULT_CHARSET; } + if ($deprecation_message !== null) { + set_error_handler( + static function (int $errno, string $errstr): never { + throw new \Exception($errstr, $errno); + }, + E_USER_DEPRECATED + ); + // catch this with the message + $this->expectExceptionMessage($deprecation_message); + } // function call - if ($language === null && $domain === null && $encoding === null && $path === null) { + if ( + $language === null && $domain === null && + $encoding === null && $path === null + ) { $return_lang_settings = \CoreLibs\Language\GetLocale::setLocale(); - } elseif ($language !== null && $domain === null && $encoding === null && $path === null) { + } elseif ( + $language !== null && $domain === null && + $encoding === null && $path === null + ) { $return_lang_settings = \CoreLibs\Language\GetLocale::setLocale( $language ); - } elseif ($language !== null && $domain !== null && $encoding === null && $path === null) { + } elseif ( + $language !== null && $domain !== null && + $encoding === null && $path === null + ) { $return_lang_settings = \CoreLibs\Language\GetLocale::setLocale( $language, $domain ); - } elseif ($language !== null && $domain !== null && $encoding !== null && $path === null) { + } elseif ( + $language !== null && $domain !== null && + $encoding !== null && $path === null + ) { $return_lang_settings = \CoreLibs\Language\GetLocale::setLocale( $language, $domain, @@ -277,6 +319,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase $path ); } + restore_error_handler(); // print "RETURN: " . print_r($return_lang_settings, true) . "\n"; foreach ( diff --git a/4dev/tests/Language/CoreLibsLanguageL10nTest.php b/4dev/tests/Language/CoreLibsLanguageL10nTest.php index ee5bf0f1..453e188e 100644 --- a/4dev/tests/Language/CoreLibsLanguageL10nTest.php +++ b/4dev/tests/Language/CoreLibsLanguageL10nTest.php @@ -22,37 +22,16 @@ final class CoreLibsLanguageL10nTest extends TestCase */ public static function setUpBeforeClass(): void { - // default web page encoding setting - if (!defined('DEFAULT_ENCODING')) { - define('DEFAULT_ENCODING', 'UTF-8'); - } - if (!defined('DEFAULT_LOCALE')) { - // default lang + encoding - define('DEFAULT_LOCALE', 'en_US.UTF-8'); - } - // site - if (!defined('SITE_ENCODING')) { - define('SITE_ENCODING', DEFAULT_ENCODING); - } - if (!defined('SITE_LOCALE')) { - define('SITE_LOCALE', DEFAULT_LOCALE); - } - // just set + // for deprecation test only, will be removed if (!defined('BASE')) { - define('BASE', str_replace('/configs', '', __DIR__) . DIRECTORY_SEPARATOR); + define('BASE', str_replace(DIRECTORY_SEPARATOR . 'configs', '', __DIR__) . DIRECTORY_SEPARATOR); } if (!defined('INCLUDES')) { define('INCLUDES', 'includes' . DIRECTORY_SEPARATOR); } - if (!defined('LANG')) { - define('LANG', 'lang' . DIRECTORY_SEPARATOR); - } if (!defined('LOCALE')) { define('LOCALE', 'locale' . DIRECTORY_SEPARATOR); } - if (!defined('CONTENT_PATH')) { - define('CONTENT_PATH', 'frontend' . DIRECTORY_SEPARATOR); - } } /** @@ -110,59 +89,90 @@ final class CoreLibsLanguageL10nTest extends TestCase // 3: path // 4: locale expected // 5: locale set expected - // 6: domain exepcted - // 7: context (null for none) - // 8: test string in - // 9: test translated + // 6: lang expected + // 7: encoding expected + // 8: domain exepcted + // 9: context (null for none) + // 10: test string in + // 11: test translated + // 12: deprecation message (until removed) // new style load 'gettext load en' => [ 'en_US.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // 'en_US.UTF-8', 'en_US', + 'en_US', + 'UTF-8', 'frontend', null, 'Original', 'Translated frontend en_US', + null, ], 'gettext load en' => [ 'en_US.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // 'en_US.UTF-8', 'en_US', + 'en_US', + 'UTF-8', 'frontend', 'context', 'Original', 'Original context frontend en_US', + null, ], 'gettext load ja' => [ 'ja_JP.UTF-8', 'admin', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // 'ja_JP.UTF-8', 'ja_JP', + 'ja_JP', + 'UTF-8', 'admin', null, 'Original', 'Translated admin ja_JP', + null, ], - // mixed path and domain - 'mixed path and domain' => [ + // mixed path and domain [DEPRECATED] + 'mixed path and domain [DEPRECATED]' => [ 'en_US.UTF-8', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, 'frontend', // 'en_US.UTF-8', 'en_US', + 'en_US', + 'UTF-8', 'frontend', 'context', 'Original', 'Original context frontend en_US', + 'L10n constructor parameter switch is no longer supported. domain is 2nd, path is 3rd parameter' + ], + // unset path + 'unset path with locale and domain [DEPRECATED]' => [ + 'ja_JP.UTF-8', + 'admin', + null, + // + 'ja_JP.UTF-8', + 'ja_JP', + 'ja_JP', + 'UTF-8', + 'admin', + null, + 'Original', + 'Translated admin ja_JP', + 'Empty path parameter is no longer allowed if locale and domain are set', ], // null set 'empty load new ' => [ @@ -173,9 +183,12 @@ final class CoreLibsLanguageL10nTest extends TestCase '', '', '', + '', + '', null, 'Original', 'Original', + null, ] ]; } @@ -192,10 +205,13 @@ final class CoreLibsLanguageL10nTest extends TestCase * @param string|null $path * @param string $locale_expected * @param string $locale_set_expected + * @param string $lang_expected + * @param string $encoding_expected * @param string $domain_expected - * @param ?string $context + * @param string|null $context * @param string $original * @param string $translated + * @param string|null $deprecation_message * @return void */ public function testL10nObject( @@ -204,20 +220,36 @@ final class CoreLibsLanguageL10nTest extends TestCase ?string $path, string $locale_expected, string $locale_set_expected, + string $lang_expected, + string $encoding_expected, string $domain_expected, ?string $context, string $original, - string $translated + string $translated, + ?string $deprecation_message ): void { + if ($deprecation_message !== null) { + set_error_handler( + static function (int $errno, string $errstr): never { + throw new \Exception($errstr, $errno); + }, + E_USER_DEPRECATED + ); + // catch this with the message + $this->expectExceptionMessage($deprecation_message); + } if ($locale === null) { $l10n = new \CoreLibs\Language\L10n(); } elseif ($domain === null) { + // same as if locale is null $l10n = new \CoreLibs\Language\L10n($locale); } elseif ($path === null) { + // deprecated, path must be set $l10n = new \CoreLibs\Language\L10n($locale, $domain); } else { $l10n = new \CoreLibs\Language\L10n($locale, $domain, $path); } + restore_error_handler(); // print "LOC: " . $locale . ", " . $l10n->getLocale() . ", " . $locale_expected . "\n"; // print "MO: " . $l10n->getMoFile() . "\n"; $this->assertEquals( @@ -248,6 +280,19 @@ final class CoreLibsLanguageL10nTest extends TestCase 'Translated string assert failed in context: ' . $context ); } + // test get locel as array + $locale = $l10n->getLocaleAsArray(); + $this->assertEquals( + [ + 'locale' => $locale_expected, + 'lang' => $lang_expected, + 'domain' => $domain_expected, + 'encoding' => $encoding_expected, + 'path' => $path + ], + $locale, + 'getLocaleAsArray mismatch' + ); } // l10nReloadMOfile and getTranslator @@ -283,7 +328,7 @@ final class CoreLibsLanguageL10nTest extends TestCase // set 0-2 'en_US.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // status 3 false, // to translate 4 @@ -296,7 +341,7 @@ final class CoreLibsLanguageL10nTest extends TestCase // set new 8-10 'ja_JP.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // status new 11 false, // check new setter 12-14 @@ -322,7 +367,7 @@ final class CoreLibsLanguageL10nTest extends TestCase // set new 8-10 'en_US.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // status new 11 false, // check new setter 12-14 @@ -387,12 +432,8 @@ final class CoreLibsLanguageL10nTest extends TestCase string $domain_expected_b, string $translated_b ): void { - if ($locale === null) { + if ($locale === null || $domain === null || $path === null) { $l10n = new \CoreLibs\Language\L10n(); - } elseif ($domain === null) { - $l10n = new \CoreLibs\Language\L10n($locale); - } elseif ($path === null) { - $l10n = new \CoreLibs\Language\L10n($locale, $domain); } else { $l10n = new \CoreLibs\Language\L10n($locale, $domain, $path); } @@ -494,16 +535,16 @@ final class CoreLibsLanguageL10nTest extends TestCase { return [ // 0: locale - // 1: path - // 2: domain + // 1: domain + // 2: path // 3: context (null for none) // 4: single string // 5: plural string // 6: array for each n value expected string 'plural text en' => [ 'en_US', - __DIR__ . 'includes/locale/', 'admin', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // context null, // text single/multi in @@ -518,8 +559,8 @@ final class CoreLibsLanguageL10nTest extends TestCase ], 'plural text context en' => [ 'en_US', - __DIR__ . 'includes/locale/', 'admin', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // context 'context', // text single/multi in @@ -544,8 +585,8 @@ final class CoreLibsLanguageL10nTest extends TestCase * @testdox plural string test for locale $locale and domain $domain with $context [$_dataName] * * @param string $locale - * @param string $path * @param string $domain + * @param string $path * @param ?string $context * @param string $original_single * @param string $original_plural @@ -555,8 +596,8 @@ final class CoreLibsLanguageL10nTest extends TestCase public function testNgettext( // config 0-3 string $locale, - string $path, string $domain, + string $path, // context string ?string $context, // input strings @@ -565,7 +606,7 @@ final class CoreLibsLanguageL10nTest extends TestCase // expected array $expected_strings ): void { - $l10n = new \CoreLibs\Language\L10n($locale, $path, $domain, false); + $l10n = new \CoreLibs\Language\L10n($locale, $domain, $path); foreach ($expected_strings as $n => $expected) { if (empty($context)) { @@ -981,7 +1022,7 @@ final class CoreLibsLanguageL10nTest extends TestCase 'standard en' => [ 'en_US.UTF-8', 'frontend', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, 'UTF-8', 'Original', 'Translated frontend en_US', @@ -989,7 +1030,7 @@ final class CoreLibsLanguageL10nTest extends TestCase 'standard ja' => [ 'ja_JP.UTF-8', 'admin', - __DIR__ . 'includes/locale/', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, 'UTF-8', 'Original', 'Translated admin ja_JP', @@ -1030,6 +1071,7 @@ final class CoreLibsLanguageL10nTest extends TestCase _textdomain($domain); _bindtextdomain($domain, $path); _bind_textdomain_codeset($domain, $encoding); + $this->assertEquals( $translated, __($original), diff --git a/README.md b/README.md index 5eb95820..3977ddbc 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ * Uses PSR-12 * tab indent instead of 4 spaces indent -* Warning at 120 character length, error at 240 character length ## General information @@ -24,9 +23,9 @@ There are three branches: ### master The active branch, which is the namespace branch. -Currently compatible with PHP 7.4 and 8.0 +Compatible with PHP 8.1 or higher -### legacy +### legacy (deprecated) The old non namepsace format layout. This is fully deprecated and will no longer be maintaned. @@ -39,17 +38,17 @@ Any current development is done here ## Static checks With phpstan (`4dev/checking/phpstan.sh`) -`phpstan` +`vendor/bin/phpstan` With phan (`4dev/checking/phan.sh`) -`phan --progress-bar -C --analyze-twice` +`vendor/bin/phan --progress-bar -C --analyze-twice` pslam is setup but not configured ## Unit tests With phpunit (`4dev/checking/phpunit.sh`) -`phpunit -c $phpunit.xml 4dev/tests/` +`www/vendor/bin/phpunit -c $phpunit.xml 4dev/tests/` ## Other Notes diff --git a/composer.lock b/composer.lock index 086a9c96..24cc6b0a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e0be39c8d67ae1599bb76d055debab50", + "content-hash": "d84c6906d304080e843d28d1b447cf8c", "packages": [], "packages-dev": [ { @@ -272,16 +272,16 @@ }, { "name": "microsoft/tolerant-php-parser", - "version": "v0.1.1", + "version": "v0.1.2", "source": { "type": "git", "url": "https://github.com/microsoft/tolerant-php-parser.git", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16" + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16", + "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/3eccfd273323aaf69513e2f1c888393f5947804b", + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b", "shasum": "" }, "require": { @@ -311,9 +311,9 @@ "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios", "support": { "issues": "https://github.com/microsoft/tolerant-php-parser/issues", - "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1" + "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.2" }, - "time": "2021-07-16T21:28:12+00:00" + "time": "2022-10-05T17:30:19+00:00" }, { "name": "netresearch/jsonmapper", @@ -368,16 +368,16 @@ }, { "name": "phan/phan", - "version": "5.4.1", + "version": "5.4.2", "source": { "type": "git", "url": "https://github.com/phan/phan.git", - "reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759" + "reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phan/phan/zipball/fef40178a952bcfcc3f69b76989dd613c3d5c759", - "reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759", + "url": "https://api.github.com/repos/phan/phan/zipball/4f2870ed6fea320f62f3c3c63f3274d357a7980e", + "reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e", "shasum": "" }, "require": { @@ -387,7 +387,7 @@ "ext-json": "*", "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.0.4", - "microsoft/tolerant-php-parser": "0.1.1", + "microsoft/tolerant-php-parser": "0.1.2", "netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0", "php": "^7.2.0|^8.0.0", "sabre/event": "^5.1.3", @@ -441,9 +441,9 @@ ], "support": { "issues": "https://github.com/phan/phan/issues", - "source": "https://github.com/phan/phan/tree/5.4.1" + "source": "https://github.com/phan/phan/tree/5.4.2" }, - "time": "2022-08-26T00:49:07+00:00" + "time": "2023-03-03T17:20:24+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -884,16 +884,16 @@ }, { "name": "symfony/console", - "version": "v6.2.5", + "version": "v6.2.7", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3e294254f2191762c1d137aed4b94e966965e985" + "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985", - "reference": "3e294254f2191762c1d137aed4b94e966965e985", + "url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45", + "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45", "shasum": "" }, "require": { @@ -960,7 +960,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.5" + "source": "https://github.com/symfony/console/tree/v6.2.7" }, "funding": [ { @@ -976,20 +976,20 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-02-25T17:00:03+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "shasum": "" }, "require": { @@ -1027,7 +1027,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" }, "funding": [ { @@ -1043,7 +1043,7 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-03-01T10:25:55+00:00" }, { "name": "symfony/polyfill-ctype", @@ -1460,16 +1460,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.2.0", + "version": "v3.2.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" + "reference": "a8c9cedf55f314f3a186041d19537303766df09a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a", + "reference": "a8c9cedf55f314f3a186041d19537303766df09a", "shasum": "" }, "require": { @@ -1525,7 +1525,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.1" }, "funding": [ { @@ -1541,20 +1541,20 @@ "type": "tidelift" } ], - "time": "2022-11-25T10:21:52+00:00" + "time": "2023-03-01T10:32:47+00:00" }, { "name": "symfony/string", - "version": "v6.2.5", + "version": "v6.2.7", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0" + "reference": "67b8c1eec78296b85dc1c7d9743830160218993d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", + "url": "https://api.github.com/repos/symfony/string/zipball/67b8c1eec78296b85dc1c7d9743830160218993d", + "reference": "67b8c1eec78296b85dc1c7d9743830160218993d", "shasum": "" }, "require": { @@ -1611,7 +1611,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.2.5" + "source": "https://github.com/symfony/string/tree/v6.2.7" }, "funding": [ { @@ -1627,7 +1627,7 @@ "type": "tidelift" } ], - "time": "2023-01-01T08:38:09+00:00" + "time": "2023-02-24T10:42:00+00:00" }, { "name": "tysonandre/var_representation_polyfill", @@ -1755,7 +1755,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.1" + }, "platform-dev": [], "plugin-api-version": "2.3.0" } diff --git a/phpstan-bootstrap.php b/phpstan-bootstrap.php index 3d165225..7011a7dd 100755 --- a/phpstan-bootstrap.php +++ b/phpstan-bootstrap.php @@ -8,5 +8,7 @@ $_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp'; // for whatever reason it does not load that from the confing.master.php // for includes/admin_header.php define('BASE_NAME', ''); +define('SITE_DOMAIN', ''); +define('HOST_NAME', 'soba.tokyo.tequila.jp'); // __END__ diff --git a/phpstan.neon b/phpstan.neon index de2fb518..e2711746 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -19,12 +19,12 @@ parameters: - www/configs/config.master.php # if composer.json autoloader defined, this is not needed # - www/lib/autoloader.php - - www/vendor/autoload.php + # - www/vendor/autoload.php excludePaths: # do not check old qq file uploader tests - www/admin/qq_file_upload_*.php # ignore all test files - - www/admin/class_test*.php + # - www/admin/class_test*.php # extra in sub folder - www/admin/subfolder/class_test*.php - www/admin/error_test.php diff --git a/phpunit.xml b/phpunit.xml index 917056a9..5305c6e6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,5 +2,6 @@ cacheResultFile="/tmp/phpunit-corelibs.result.cache" colors="true" verbose="true" + convertDeprecationsToExceptions="true" > diff --git a/psalm-config.php b/psalm-config.php new file mode 100644 index 00000000..a10003ae --- /dev/null +++ b/psalm-config.php @@ -0,0 +1,5 @@ + + + + + + + + + + + + + + + + + diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index e09c6a9e..d0311c50 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -22,6 +22,8 @@ class ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718 return self::$loader; } + require __DIR__ . '/platform_check.php'; + spl_autoload_register(array('ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInitdd705c6e8ab22e0d642372dec7767718', 'loadClassLoader')); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index bf3cd69c..1e5d0879 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -277,17 +277,17 @@ }, { "name": "microsoft/tolerant-php-parser", - "version": "v0.1.1", - "version_normalized": "0.1.1.0", + "version": "v0.1.2", + "version_normalized": "0.1.2.0", "source": { "type": "git", "url": "https://github.com/microsoft/tolerant-php-parser.git", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16" + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16", + "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/3eccfd273323aaf69513e2f1c888393f5947804b", + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b", "shasum": "" }, "require": { @@ -296,7 +296,7 @@ "require-dev": { "phpunit/phpunit": "^8.5.15" }, - "time": "2021-07-16T21:28:12+00:00", + "time": "2022-10-05T17:30:19+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -319,7 +319,7 @@ "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios", "support": { "issues": "https://github.com/microsoft/tolerant-php-parser/issues", - "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1" + "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.2" }, "install-path": "../microsoft/tolerant-php-parser" }, @@ -379,17 +379,17 @@ }, { "name": "phan/phan", - "version": "5.4.1", - "version_normalized": "5.4.1.0", + "version": "5.4.2", + "version_normalized": "5.4.2.0", "source": { "type": "git", "url": "https://github.com/phan/phan.git", - "reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759" + "reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phan/phan/zipball/fef40178a952bcfcc3f69b76989dd613c3d5c759", - "reference": "fef40178a952bcfcc3f69b76989dd613c3d5c759", + "url": "https://api.github.com/repos/phan/phan/zipball/4f2870ed6fea320f62f3c3c63f3274d357a7980e", + "reference": "4f2870ed6fea320f62f3c3c63f3274d357a7980e", "shasum": "" }, "require": { @@ -399,7 +399,7 @@ "ext-json": "*", "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.0.4", - "microsoft/tolerant-php-parser": "0.1.1", + "microsoft/tolerant-php-parser": "0.1.2", "netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0", "php": "^7.2.0|^8.0.0", "sabre/event": "^5.1.3", @@ -419,7 +419,7 @@ "ext-tokenizer": "Needed for fallback/polyfill parser support and file/line-based suppressions.", "ext-var_representation": "Suggested for converting values to strings in issue messages" }, - "time": "2022-08-26T00:49:07+00:00", + "time": "2023-03-03T17:20:24+00:00", "bin": [ "phan", "phan_client", @@ -455,7 +455,7 @@ ], "support": { "issues": "https://github.com/phan/phan/issues", - "source": "https://github.com/phan/phan/tree/5.4.1" + "source": "https://github.com/phan/phan/tree/5.4.2" }, "install-path": "../phan/phan" }, @@ -922,17 +922,17 @@ }, { "name": "symfony/console", - "version": "v6.2.5", - "version_normalized": "6.2.5.0", + "version": "v6.2.7", + "version_normalized": "6.2.7.0", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "3e294254f2191762c1d137aed4b94e966965e985" + "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/3e294254f2191762c1d137aed4b94e966965e985", - "reference": "3e294254f2191762c1d137aed4b94e966965e985", + "url": "https://api.github.com/repos/symfony/console/zipball/cbad09eb8925b6ad4fb721c7a179344dc4a19d45", + "reference": "cbad09eb8925b6ad4fb721c7a179344dc4a19d45", "shasum": "" }, "require": { @@ -967,7 +967,7 @@ "symfony/lock": "", "symfony/process": "" }, - "time": "2023-01-01T08:38:09+00:00", + "time": "2023-02-25T17:00:03+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1001,7 +1001,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.2.5" + "source": "https://github.com/symfony/console/tree/v6.2.7" }, "funding": [ { @@ -1021,23 +1021,23 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.0", - "version_normalized": "3.2.0.0", + "version": "v3.2.1", + "version_normalized": "3.2.1.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3" + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/1ee04c65529dea5d8744774d474e7cbd2f1206d3", - "reference": "1ee04c65529dea5d8744774d474e7cbd2f1206d3", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", "shasum": "" }, "require": { "php": ">=8.1" }, - "time": "2022-11-25T10:21:52+00:00", + "time": "2023-03-01T10:25:55+00:00", "type": "library", "extra": { "branch-alias": { @@ -1071,7 +1071,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" }, "funding": [ { @@ -1519,17 +1519,17 @@ }, { "name": "symfony/service-contracts", - "version": "v3.2.0", - "version_normalized": "3.2.0.0", + "version": "v3.2.1", + "version_normalized": "3.2.1.0", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75" + "reference": "a8c9cedf55f314f3a186041d19537303766df09a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/aac98028c69df04ee77eb69b96b86ee51fbf4b75", - "reference": "aac98028c69df04ee77eb69b96b86ee51fbf4b75", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a", + "reference": "a8c9cedf55f314f3a186041d19537303766df09a", "shasum": "" }, "require": { @@ -1542,7 +1542,7 @@ "suggest": { "symfony/service-implementation": "" }, - "time": "2022-11-25T10:21:52+00:00", + "time": "2023-03-01T10:32:47+00:00", "type": "library", "extra": { "branch-alias": { @@ -1587,7 +1587,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.2.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.2.1" }, "funding": [ { @@ -1607,17 +1607,17 @@ }, { "name": "symfony/string", - "version": "v6.2.5", - "version_normalized": "6.2.5.0", + "version": "v6.2.7", + "version_normalized": "6.2.7.0", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0" + "reference": "67b8c1eec78296b85dc1c7d9743830160218993d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", - "reference": "b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0", + "url": "https://api.github.com/repos/symfony/string/zipball/67b8c1eec78296b85dc1c7d9743830160218993d", + "reference": "67b8c1eec78296b85dc1c7d9743830160218993d", "shasum": "" }, "require": { @@ -1637,7 +1637,7 @@ "symfony/translation-contracts": "^2.0|^3.0", "symfony/var-exporter": "^5.4|^6.0" }, - "time": "2023-01-01T08:38:09+00:00", + "time": "2023-02-24T10:42:00+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -1676,7 +1676,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.2.5" + "source": "https://github.com/symfony/string/tree/v6.2.7" }, "funding": [ { diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 6b65eafc..cd85f2e5 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,24 +1,15 @@ array( - 'name' => '__root__', + 'name' => 'egrajp/development-corelibs-dev', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '44f37b7f74e1fcbfbbdf26036117d14404011abd', + 'reference' => NULL, 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => true, ), 'versions' => array( - '__root__' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '44f37b7f74e1fcbfbbdf26036117d14404011abd', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'composer/pcre' => array( 'pretty_version' => '3.1.0', 'version' => '3.1.0.0', @@ -46,6 +37,15 @@ 'aliases' => array(), 'dev_requirement' => true, ), + 'egrajp/development-corelibs-dev' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => NULL, + 'type' => 'library', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'felixfbecker/advanced-json-rpc' => array( 'pretty_version' => 'v3.2.1', 'version' => '3.2.1.0', @@ -56,9 +56,9 @@ 'dev_requirement' => true, ), 'microsoft/tolerant-php-parser' => array( - 'pretty_version' => 'v0.1.1', - 'version' => '0.1.1.0', - 'reference' => '6a965617cf484355048ac6d2d3de7b6ec93abb16', + 'pretty_version' => 'v0.1.2', + 'version' => '0.1.2.0', + 'reference' => '3eccfd273323aaf69513e2f1c888393f5947804b', 'type' => 'library', 'install_path' => __DIR__ . '/../microsoft/tolerant-php-parser', 'aliases' => array(), @@ -74,9 +74,9 @@ 'dev_requirement' => true, ), 'phan/phan' => array( - 'pretty_version' => '5.4.1', - 'version' => '5.4.1.0', - 'reference' => 'fef40178a952bcfcc3f69b76989dd613c3d5c759', + 'pretty_version' => '5.4.2', + 'version' => '5.4.2.0', + 'reference' => '4f2870ed6fea320f62f3c3c63f3274d357a7980e', 'type' => 'project', 'install_path' => __DIR__ . '/../phan/phan', 'aliases' => array(), @@ -161,18 +161,18 @@ 'dev_requirement' => true, ), 'symfony/console' => array( - 'pretty_version' => 'v6.2.5', - 'version' => '6.2.5.0', - 'reference' => '3e294254f2191762c1d137aed4b94e966965e985', + 'pretty_version' => 'v6.2.7', + 'version' => '6.2.7.0', + 'reference' => 'cbad09eb8925b6ad4fb721c7a179344dc4a19d45', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/console', 'aliases' => array(), 'dev_requirement' => true, ), 'symfony/deprecation-contracts' => array( - 'pretty_version' => 'v3.2.0', - 'version' => '3.2.0.0', - 'reference' => '1ee04c65529dea5d8744774d474e7cbd2f1206d3', + 'pretty_version' => 'v3.2.1', + 'version' => '3.2.1.0', + 'reference' => 'e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), @@ -224,18 +224,18 @@ 'dev_requirement' => true, ), 'symfony/service-contracts' => array( - 'pretty_version' => 'v3.2.0', - 'version' => '3.2.0.0', - 'reference' => 'aac98028c69df04ee77eb69b96b86ee51fbf4b75', + 'pretty_version' => 'v3.2.1', + 'version' => '3.2.1.0', + 'reference' => 'a8c9cedf55f314f3a186041d19537303766df09a', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/service-contracts', 'aliases' => array(), 'dev_requirement' => true, ), 'symfony/string' => array( - 'pretty_version' => 'v6.2.5', - 'version' => '6.2.5.0', - 'reference' => 'b2dac0fa27b1ac0f9c0c0b23b43977f12308d0b0', + 'pretty_version' => 'v6.2.7', + 'version' => '6.2.7.0', + 'reference' => '67b8c1eec78296b85dc1c7d9743830160218993d', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/string', 'aliases' => array(), diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 00000000..4c3a5d68 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/microsoft/tolerant-php-parser/phpstan.neon b/vendor/microsoft/tolerant-php-parser/phpstan.neon deleted file mode 100644 index 3d24b87a..00000000 --- a/vendor/microsoft/tolerant-php-parser/phpstan.neon +++ /dev/null @@ -1,7 +0,0 @@ -parameters: - level: 2 - paths: - - src/ - ignoreErrors: - # phpstan issue, see: https://github.com/phpstan/phpstan/issues/1306 - - "/Variable .unaryExpression might not be defined./" diff --git a/vendor/microsoft/tolerant-php-parser/src/NamespacedNameTrait.php b/vendor/microsoft/tolerant-php-parser/src/NamespacedNameTrait.php index 3fc292b5..a59e3dae 100644 --- a/vendor/microsoft/tolerant-php-parser/src/NamespacedNameTrait.php +++ b/vendor/microsoft/tolerant-php-parser/src/NamespacedNameTrait.php @@ -31,7 +31,7 @@ trait NamespacedNameTrait { return ResolvedName::buildName($this->getNameParts(), $content); } - if ($namespaceDefinition->name !== null) { + if ($namespaceDefinition->name instanceof QualifiedName) { $resolvedName = ResolvedName::buildName($namespaceDefinition->name->nameParts, $content); } else { $resolvedName = ResolvedName::buildName([], $content); @@ -47,4 +47,4 @@ trait NamespacedNameTrait { } return $resolvedName; } -} \ No newline at end of file +} diff --git a/vendor/microsoft/tolerant-php-parser/src/Node.php b/vendor/microsoft/tolerant-php-parser/src/Node.php index d1288876..bcc88731 100644 --- a/vendor/microsoft/tolerant-php-parser/src/Node.php +++ b/vendor/microsoft/tolerant-php-parser/src/Node.php @@ -91,7 +91,7 @@ abstract class Node implements \JsonSerializable { * Gets first child that is an instance of one of the provided classes. * Returns null if there is no match. * - * @param array ...$classNames + * @param string ...$classNames * @return Node|null */ public function getFirstChildNode(...$classNames) { @@ -117,7 +117,7 @@ abstract class Node implements \JsonSerializable { * Gets first descendant node that is an instance of one of the provided classes. * Returns null if there is no match. * - * @param array ...$classNames + * @param string ...$classNames * @return Node|null */ public function getFirstDescendantNode(...$classNames) { @@ -417,7 +417,7 @@ abstract class Node implements \JsonSerializable { return $this->getRoot()->fileContents; } - public function getUri() : string { + public function getUri() : ?string { return $this->getRoot()->uri; } diff --git a/vendor/microsoft/tolerant-php-parser/src/Node/Expression/CallExpression.php b/vendor/microsoft/tolerant-php-parser/src/Node/Expression/CallExpression.php index 0654fb34..c783ddea 100644 --- a/vendor/microsoft/tolerant-php-parser/src/Node/Expression/CallExpression.php +++ b/vendor/microsoft/tolerant-php-parser/src/Node/Expression/CallExpression.php @@ -8,10 +8,11 @@ namespace Microsoft\PhpParser\Node\Expression; use Microsoft\PhpParser\Node\DelimitedList; use Microsoft\PhpParser\Node\Expression; +use Microsoft\PhpParser\Node\QualifiedName; use Microsoft\PhpParser\Token; class CallExpression extends Expression { - /** @var Expression */ + /** @var QualifiedName|Expression */ public $callableExpression; /** @var Token */ diff --git a/vendor/microsoft/tolerant-php-parser/src/Node/Expression/YieldExpression.php b/vendor/microsoft/tolerant-php-parser/src/Node/Expression/YieldExpression.php index 63da2956..86bb8056 100644 --- a/vendor/microsoft/tolerant-php-parser/src/Node/Expression/YieldExpression.php +++ b/vendor/microsoft/tolerant-php-parser/src/Node/Expression/YieldExpression.php @@ -14,7 +14,7 @@ class YieldExpression extends Expression { /** @var Token */ public $yieldOrYieldFromKeyword; - /** @var ArrayElement */ + /** @var ArrayElement|null */ public $arrayElement; const CHILD_NAMES = ['yieldOrYieldFromKeyword', 'arrayElement']; diff --git a/vendor/microsoft/tolerant-php-parser/src/Node/ParenthesizedIntersectionType.php b/vendor/microsoft/tolerant-php-parser/src/Node/ParenthesizedIntersectionType.php new file mode 100644 index 00000000..a7afcd50 --- /dev/null +++ b/vendor/microsoft/tolerant-php-parser/src/Node/ParenthesizedIntersectionType.php @@ -0,0 +1,29 @@ +`)) */ + public $semicolonOrCloseTag; + + /** @var Token|null TokenKind::InlineHtml data unless there are no bytes (This is optional if there is nothing after the semicolon) */ + public $data; + + const CHILD_NAMES = [ + 'haltCompilerKeyword', + 'openParen', + 'closeParen', + 'semicolonOrCloseTag', + 'data', + ]; + + /** + * @return int + */ + public function getHaltCompilerOffset() { + // This accounts for the fact that PHP close tags may include a single newline, + // and that $this->data may be null. + return $this->semicolonOrCloseTag->getEndPosition(); + } +} diff --git a/vendor/microsoft/tolerant-php-parser/src/Parser.php b/vendor/microsoft/tolerant-php-parser/src/Parser.php index 4290dc89..d618633b 100644 --- a/vendor/microsoft/tolerant-php-parser/src/Parser.php +++ b/vendor/microsoft/tolerant-php-parser/src/Parser.php @@ -6,6 +6,7 @@ namespace Microsoft\PhpParser; +use Closure; use Microsoft\PhpParser\Node\AnonymousFunctionUseClause; use Microsoft\PhpParser\Node\ArrayElement; use Microsoft\PhpParser\Node\Attribute; @@ -70,6 +71,7 @@ use Microsoft\PhpParser\Node\MissingMemberDeclaration; use Microsoft\PhpParser\Node\NamespaceAliasingClause; use Microsoft\PhpParser\Node\NamespaceUseGroupClause; use Microsoft\PhpParser\Node\NumericLiteral; +use Microsoft\PhpParser\Node\ParenthesizedIntersectionType; use Microsoft\PhpParser\Node\PropertyDeclaration; use Microsoft\PhpParser\Node\ReservedWord; use Microsoft\PhpParser\Node\StringLiteral; @@ -95,6 +97,7 @@ use Microsoft\PhpParser\Node\Statement\{ ForStatement, FunctionDeclaration, GotoStatement, + HaltCompilerStatement, IfStatementNode, InlineHtml, InterfaceDeclaration, @@ -144,8 +147,9 @@ class Parser { [TokenKind::ArrayKeyword, TokenKind::CallableKeyword, TokenKind::BoolReservedWord, TokenKind::FloatReservedWord, TokenKind::IntReservedWord, TokenKind::StringReservedWord, TokenKind::ObjectReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord, - TokenKind::IterableReservedWord, TokenKind::MixedReservedWord]; // TODO update spec - $this->returnTypeDeclarationTokens = \array_merge([TokenKind::VoidReservedWord, TokenKind::NullReservedWord, TokenKind::FalseReservedWord, TokenKind::StaticKeyword], $this->parameterTypeDeclarationTokens); + TokenKind::TrueReservedWord, TokenKind::IterableReservedWord, TokenKind::MixedReservedWord, + TokenKind::VoidReservedWord, TokenKind::NeverReservedWord]; // TODO update spec + $this->returnTypeDeclarationTokens = \array_merge([TokenKind::StaticKeyword], $this->parameterTypeDeclarationTokens); } /** @@ -557,10 +561,8 @@ class Parser { // class-declaration case TokenKind::FinalKeyword: case TokenKind::AbstractKeyword: - if (!$this->lookahead(TokenKind::ClassKeyword)) { - $this->advanceToken(); - return new SkippedToken($token); - } + case TokenKind::ReadonlyKeyword: + // fallthrough case TokenKind::ClassKeyword: return $this->parseClassDeclaration($parentNode); @@ -614,6 +616,15 @@ class Parser { case TokenKind::UnsetKeyword: return $this->parseUnsetStatement($parentNode); + + case TokenKind::HaltCompilerKeyword: + if ($parentNode instanceof SourceFileNode) { + return $this->parseHaltCompilerStatement($parentNode); + } + // __halt_compiler is a fatal compile error anywhere other than the top level. + // It won't be seen elsewhere in other programs - warn about the token being unexpected. + $this->advanceToken(); + return new SkippedToken($token); } $expressionStatement = new ExpressionStatement(); @@ -657,10 +668,20 @@ class Parser { }; } + /** @return Token[] */ + private function parseClassModifiers(): array { + $modifiers = []; + while ($token = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::ReadonlyKeyword)) { + $modifiers[] = $token; + } + return $modifiers; + } + private function parseClassDeclaration($parentNode) : Node { $classNode = new ClassDeclaration(); // TODO verify not nested $classNode->parent = $parentNode; - $classNode->abstractOrFinalModifier = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword); + $classNode->abstractOrFinalModifier = $this->eatOptional(TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::ReadonlyKeyword); + $classNode->modifiers = $this->parseClassModifiers(); $classNode->classKeyword = $this->eat1(TokenKind::ClassKeyword); $classNode->name = $this->eat($this->nameOrReservedWordTokens); // TODO should be any $classNode->name->kind = TokenKind::Name; @@ -838,9 +859,6 @@ class Parser { if (end($children) instanceof MissingToken && ($children[\count($children) - 2]->kind ?? null) === TokenKind::AmpersandToken) { array_pop($parameter->typeDeclarationList->children); $parameter->byRefToken = array_pop($parameter->typeDeclarationList->children); - if (!$parameter->typeDeclarationList->children) { - unset($parameter->typeDeclarationList); - } } } elseif ($parameter->questionToken) { // TODO ParameterType? @@ -882,27 +900,22 @@ class Parser { /** * Attempt to parse the return type after the `:` and optional `?` token. * + * TODO: Consider changing the return type to a new class TypeList in a future major release? + * ParenthesizedIntersectionType is not a qualified name. * @return DelimitedList\QualifiedNameList|null */ private function parseReturnTypeDeclarationList($parentNode) { - $result = $this->parseDelimitedList( - DelimitedList\QualifiedNameList::class, - self::TYPE_DELIMITER_TOKENS, - function ($token) { - return \in_array($token->kind, $this->returnTypeDeclarationTokens, true) || $this->isQualifiedNameStart($token); + return $this->parseUnionTypeDeclarationList( + $parentNode, + function ($token): bool { + return \in_array($token->kind, $this->returnTypeDeclarationTokens, true) || + $this->isQualifiedNameStart($token); }, function ($parentNode) { return $this->parseReturnTypeDeclaration($parentNode); }, - $parentNode, - false); - - // Add a MissingToken so that this will warn about `function () : T| {}` - // TODO: Make this a reusable abstraction? - if ($result && in_array(end($result->children)->kind ?? null, self::TYPE_DELIMITER_TOKENS)) { - $result->children[] = new MissingToken(TokenKind::ReturnType, $this->token->fullStart); - } - return $result; + TokenKind::ReturnType + ); } private function parseReturnTypeDeclaration($parentNode) { @@ -917,28 +930,109 @@ class Parser { } /** + * Parse a union type such as A, A|B, A&B, A|(B&C), rejecting invalid syntax combinations. + * * @param Node $parentNode + * @param Closure(Token):bool $isTypeStart + * @param Closure(Node):(Node|Token|null) $parseType + * @param int $expectedTypeKind expected kind for token type + * @return DelimitedList\QualifiedNameList|null + */ + private function parseUnionTypeDeclarationList($parentNode, Closure $isTypeStart, Closure $parseType, int $expectedTypeKind) { + $result = new DelimitedList\QualifiedNameList(); + $token = $this->getCurrentToken(); + $delimiter = self::TYPE_DELIMITER_TOKENS; + do { + if ($token->kind === TokenKind::OpenParenToken || $isTypeStart($token)) { + // Forbid mixing A&(B&C) if '&' was already seen + $openParen = in_array(TokenKind::BarToken, $delimiter, true) + ? $this->eatOptional(TokenKind::OpenParenToken) + : null; + if ($openParen) { + $element = $this->parseParenthesizedIntersectionType($result, $openParen, $isTypeStart, $parseType); + // Forbid mixing (A&B)&C by forbidding `&` separator after a parenthesized intersection type. + $delimiter = [TokenKind::BarToken]; + } else { + $element = $parseType($result); + } + $result->addElement($element); + } else { + break; + } + + $delimiterToken = $this->eatOptional($delimiter); + if ($delimiterToken !== null) { + $result->addElement($delimiterToken); + $delimiter = [$delimiterToken->kind]; + } + $token = $this->getCurrentToken(); + } while ($delimiterToken !== null); + + $result->parent = $parentNode; + if ($result->children === null) { + return null; + } + + if (in_array(end($result->children)->kind ?? null, $delimiter, true)) { + // Add a MissingToken so that this will warn about `function () : T| {}` + $result->children[] = new MissingToken($expectedTypeKind, $this->token->fullStart); + } elseif (count($result->children) === 1 && $result->children[0] instanceof ParenthesizedIntersectionType) { + // dnf types with parenthesized intersection types are a union type of at least 2 types. + $result->children[] = new MissingToken(TokenKind::BarToken, $this->token->fullStart); + } + return $result; + } + + /** + * @param Node $parentNode + * @param Token $openParen + * @param Closure(Token):bool $isTypeStart + * @param Closure(Node):(Node|Token|null) $parseType + */ + private function parseParenthesizedIntersectionType($parentNode, Token $openParen, Closure $isTypeStart, Closure $parseType): ParenthesizedIntersectionType { + $node = new ParenthesizedIntersectionType(); + $node->parent = $parentNode; + $node->openParen = $openParen; + $node->children = $this->parseDelimitedList( + DelimitedList\QualifiedNameList::class, + TokenKind::AmpersandToken, + $isTypeStart, + $parseType, + $node, + true); + if ($node->children) { + // https://wiki.php.net/rfc/dnf_types + if ((end($node->children->children)->kind ?? null) === TokenKind::OpenParenToken) { + // Add a MissingToken so that this will Warn about `function (A|(B&) $x) {}` + $node->children->children[] = new MissingToken(TokenKind::Name, $this->token->fullStart); + } elseif (count($node->children->children) === 1) { + // Must have at least 2 parts for A|(B&C) + $node->children->children[] = new MissingToken(TokenKind::AmpersandToken, $this->token->fullStart); + } + } else { + // Having less than 2 types (no types) in A|() is a parse error + $node->children = new MissingToken(TokenKind::Name, $this->token->fullStart); + } + $node->closeParen = $this->eat(TokenKind::CloseParenToken); + return $node; + } + + /** + * @param Node|null $parentNode * @return DelimitedList\QualifiedNameList|null */ private function tryParseParameterTypeDeclarationList($parentNode) { - $result = $this->parseDelimitedList( - DelimitedList\QualifiedNameList::class, - self::TYPE_DELIMITER_TOKENS, + return $this->parseUnionTypeDeclarationList( + $parentNode, function ($token) { - return \in_array($token->kind, $this->parameterTypeDeclarationTokens, true) || $this->isQualifiedNameStart($token); + return \in_array($token->kind, $this->parameterTypeDeclarationTokens, true) || + $this->isQualifiedNameStart($token); }, function ($parentNode) { return $this->tryParseParameterTypeDeclaration($parentNode); }, - $parentNode, - true); - - // Add a MissingToken so that this will Warn about `function (T| $x) {}` - // TODO: Make this a reusable abstraction? - if ($result && in_array(end($result->children)->kind ?? null, self::TYPE_DELIMITER_TOKENS)) { - $result->children[] = new MissingToken(TokenKind::Name, $this->token->fullStart); - } - return $result; + TokenKind::Name + ); } private function parseCompoundStatement($parentNode) { @@ -950,12 +1044,6 @@ class Parser { return $compoundStatement; } - private function array_push_list(& $array, $list) { - foreach ($list as $item) { - $array[] = $item; - } - } - private function isClassMemberDeclarationStart(Token $token) { switch ($token->kind) { // const-modifier @@ -1036,6 +1124,7 @@ class Parser { case TokenKind::ClassKeyword: case TokenKind::AbstractKeyword: case TokenKind::FinalKeyword: + case TokenKind::ReadonlyKeyword: // interface-declaration case TokenKind::InterfaceKeyword: @@ -1062,6 +1151,9 @@ class Parser { // attributes case TokenKind::AttributeToken: + + // __halt_compiler + case TokenKind::HaltCompilerKeyword: return true; default: @@ -1324,8 +1416,6 @@ class Parser { case TokenKind::DollarOpenBraceToken: case TokenKind::OpenBraceDollarToken: $expression->children[] = $this->eat(TokenKind::DollarOpenBraceToken, TokenKind::OpenBraceDollarToken); - // TODO: Reject ${var->prop} and ${(var->prop)} without rejecting ${var+otherVar} - // Currently, this fails to reject ${var->prop} (because `var` has TokenKind::Name instead of StringVarname) if ($this->getCurrentToken()->kind === TokenKind::StringVarname) { $expression->children[] = $this->parseComplexDollarTemplateStringExpression($expression); } else { @@ -1536,6 +1626,9 @@ class Parser { case TokenKind::ProtectedKeyword: case TokenKind::PrivateKeyword: case TokenKind::AttributeToken: + + // dnf types (A&B)|C + case TokenKind::OpenParenToken: return true; } @@ -1546,7 +1639,7 @@ class Parser { /** * @param string $className (name of subclass of DelimitedList) - * @param int $delimiter + * @param int|int[] $delimiter * @param callable $isElementStartFn * @param callable $parseElementFn * @param Node $parentNode @@ -1560,7 +1653,7 @@ class Parser { do { if ($isElementStartFn($token)) { $node->addElement($parseElementFn($node)); - } elseif (!$allowEmptyElements || ($allowEmptyElements && !$this->checkToken($delimiter))) { + } elseif (!$allowEmptyElements || ($allowEmptyElements && !$this->checkAnyToken($delimiter))) { break; } @@ -1572,7 +1665,6 @@ class Parser { // TODO ERROR CASE - no delimiter, but a param follows } while ($delimiterToken !== null); - $node->parent = $parentNode; if ($node->children === null) { return null; @@ -1772,10 +1864,17 @@ class Parser { return $succeeded; } + /** @param int $expectedKind */ private function checkToken($expectedKind) : bool { return $this->getCurrentToken()->kind === $expectedKind; } + /** @param int|int[] $expectedKind */ + private function checkAnyToken($expectedKind) : bool { + $kind = $this->getCurrentToken()->kind; + return \is_array($expectedKind) ? \in_array($kind, $expectedKind, true) : $kind === $expectedKind; + } + private function parseIfStatement($parentNode) { $ifStatement = new IfStatementNode(); $ifStatement->parent = $parentNode; @@ -2114,7 +2213,7 @@ class Parser { } break; case TokenKind::QuestionToken: - if ($parentNode instanceof TernaryExpression) { + if ($parentNode instanceof TernaryExpression && !isset($parentNode->questionToken)) { // Workaround to parse "a ? b : c ? d : e" as "(a ? b : c) ? d : e" break 2; } @@ -2122,6 +2221,7 @@ class Parser { } if ($shouldOperatorTakePrecedenceOverUnary) { + /** @var UnaryOpExpression $unaryExpression */ $unaryExpression = $leftOperand; $leftOperand = $unaryExpression->operand; } @@ -2143,6 +2243,7 @@ class Parser { // Rebuild the unary expression if we deconstructed it earlier. if ($shouldOperatorTakePrecedenceOverUnary) { + /** @var UnaryOpExpression $unaryExpression */ $leftOperand->parent = $unaryExpression; $unaryExpression->operand = $leftOperand; $leftOperand = $unaryExpression; @@ -2269,6 +2370,14 @@ class Parser { // InstanceOf has other remaining issues, but this heuristic is an improvement for many common cases such as `$x && $y = $z` ]; + /** + * @param Token|Node $leftOperand + * @param Token $operatorToken + * @param Token|null $byRefToken + * @param Token|Node $rightOperand + * @param Node $parentNode + * @return BinaryExpression|AssignmentExpression + */ private function makeBinaryExpression($leftOperand, $operatorToken, $byRefToken, $rightOperand, $parentNode) { $assignmentExpression = $operatorToken->kind === TokenKind::EqualsToken; if ($assignmentExpression || \array_key_exists($operatorToken->kind, self::KNOWN_ASSIGNMENT_TOKEN_SET)) { @@ -2283,8 +2392,12 @@ class Parser { } $binaryExpression = $assignmentExpression ? new AssignmentExpression() : new BinaryExpression(); $binaryExpression->parent = $parentNode; - $leftOperand->parent = $binaryExpression; - $rightOperand->parent = $binaryExpression; + if ($leftOperand instanceof Node) { + $leftOperand->parent = $binaryExpression; + } + if ($rightOperand instanceof Node) { + $rightOperand->parent = $binaryExpression; + } $binaryExpression->leftOperand = $leftOperand; $binaryExpression->operator = $operatorToken; if ($binaryExpression instanceof AssignmentExpression && isset($byRefToken)) { @@ -2744,6 +2857,30 @@ class Parser { return $unsetStatement; } + private function parseHaltCompilerStatement($parentNode) { + $haltCompilerStatement = new HaltCompilerStatement(); + $haltCompilerStatement->parent = $parentNode; + + $haltCompilerStatement->haltCompilerKeyword = $this->eat1(TokenKind::HaltCompilerKeyword); + $haltCompilerStatement->openParen = $this->eat1(TokenKind::OpenParenToken); + $haltCompilerStatement->closeParen = $this->eat1(TokenKind::CloseParenToken); + // There is an implicit ';' before the closing php tag. + $haltCompilerStatement->semicolonOrCloseTag = $this->eat(TokenKind::SemicolonToken, TokenKind::ScriptSectionEndTag); + // token_get_all() will return up to 3 tokens after __halt_compiler regardless of whether they're the right ones. + // For invalid php snippets, combine the remaining tokens into InlineHtml + $remainingTokens = []; + while ($this->token->kind !== TokenKind::EndOfFileToken) { + $remainingTokens[] = $this->token; + $this->advanceToken(); + } + if ($remainingTokens) { + $firstToken = $remainingTokens[0]; + $lastToken = end($remainingTokens); + $haltCompilerStatement->data = new Token(TokenKind::InlineHtml, $firstToken->fullStart, $firstToken->fullStart, $lastToken->fullStart + $lastToken->length - $firstToken->fullStart); + } + return $haltCompilerStatement; + } + private function parseArrayCreationExpression($parentNode) { $arrayExpression = new ArrayCreationExpression(); $arrayExpression->parent = $parentNode; @@ -3207,7 +3344,7 @@ class Parser { if ($classBaseClause->extendsKeyword === null) { return null; } - $classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause); + $classBaseClause->baseClass = $this->parseQualifiedName($classBaseClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart); return $classBaseClause; } @@ -3278,6 +3415,8 @@ class Parser { } /** + * Parse a comma separated qualified name list (e.g. interfaces implemented by a class) + * * @param Node $parentNode * @return DelimitedList\QualifiedNameList */ @@ -3291,6 +3430,7 @@ class Parser { } private function parseQualifiedNameCatchList($parentNode) { + // catch blocks don't support intersection types. $result = $this->parseDelimitedList( DelimitedList\QualifiedNameList::class, TokenKind::BarToken, @@ -3397,12 +3537,18 @@ class Parser { $namespaceDefinition->namespaceKeyword = $this->eat1(TokenKind::NamespaceKeyword); if (!$this->checkToken(TokenKind::NamespaceKeyword)) { - $namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition); // TODO only optional with compound statement block + $namespaceDefinition->name = $this->parseQualifiedName($namespaceDefinition); } - $namespaceDefinition->compoundStatementOrSemicolon = - $this->checkToken(TokenKind::OpenBraceToken) ? - $this->parseCompoundStatement($namespaceDefinition) : $this->eatSemicolonOrAbortStatement(); + if ($this->checkToken(TokenKind::OpenBraceToken)) { + $namespaceDefinition->compoundStatementOrSemicolon = $this->parseCompoundStatement($namespaceDefinition); + } else { + if (!$namespaceDefinition->name) { + // only optional with compound statement block + $namespaceDefinition->name = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart); + } + $namespaceDefinition->compoundStatementOrSemicolon = $this->eatSemicolonOrAbortStatement(); + } return $namespaceDefinition; } @@ -3428,13 +3574,17 @@ class Parser { $namespaceUseClause = new NamespaceUseClause(); $namespaceUseClause->parent = $parentNode; $namespaceUseClause->namespaceName = $this->parseQualifiedName($namespaceUseClause); - if ($this->checkToken(TokenKind::AsKeyword)) { - $namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause); - } - elseif ($this->checkToken(TokenKind::OpenBraceToken)) { + if ($this->checkToken(TokenKind::OpenBraceToken)) { $namespaceUseClause->openBrace = $this->eat1(TokenKind::OpenBraceToken); $namespaceUseClause->groupClauses = $this->parseNamespaceUseGroupClauseList($namespaceUseClause); $namespaceUseClause->closeBrace = $this->eat1(TokenKind::CloseBraceToken); + } else { + if (!$namespaceUseClause->namespaceName) { + $namespaceUseClause->namespaceName = new MissingToken(TokenKind::QualifiedName, $this->token->fullStart); + } + if ($this->checkToken(TokenKind::AsKeyword)) { + $namespaceUseClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseClause); + } } return $namespaceUseClause; @@ -3455,7 +3605,7 @@ class Parser { $namespaceUseGroupClause->parent = $parentNode; $namespaceUseGroupClause->functionOrConst = $this->eatOptional(TokenKind::FunctionKeyword, TokenKind::ConstKeyword); - $namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause); + $namespaceUseGroupClause->namespaceName = $this->parseQualifiedName($namespaceUseGroupClause) ?? new MissingToken(TokenKind::QualifiedName, $this->token->fullStart); if ($this->checkToken(TokenKind::AsKeyword)) { $namespaceUseGroupClause->namespaceAliasingClause = $this->parseNamespaceAliasingClause($namespaceUseGroupClause); } @@ -3513,6 +3663,7 @@ class Parser { case TokenKind::AbstractKeyword: case TokenKind::FinalKeyword: case TokenKind::ReadonlyKeyword: + case TokenKind::ConstKeyword: // method-declaration case TokenKind::FunctionKeyword: @@ -3533,6 +3684,9 @@ class Parser { $token = $this->getCurrentToken(); switch ($token->kind) { + case TokenKind::ConstKeyword: + return $this->parseClassConstDeclaration($parentNode, $modifiers); + case TokenKind::FunctionKeyword: return $this->parseMethodDeclaration($parentNode, $modifiers); diff --git a/vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php b/vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php index be8cd711..08c57884 100644 --- a/vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php +++ b/vendor/microsoft/tolerant-php-parser/src/PhpTokenizer.php @@ -228,7 +228,6 @@ class PhpTokenizer implements TokenStreamProviderInterface { T_DIR => TokenKind::Name, T_FILE => TokenKind::Name, T_FUNC_C => TokenKind::Name, - T_HALT_COMPILER => TokenKind::Name, T_METHOD_C => TokenKind::Name, T_NS_C => TokenKind::Name, T_TRAIT_C => TokenKind::Name, @@ -274,6 +273,7 @@ class PhpTokenizer implements TokenStreamProviderInterface { T_FUNCTION => TokenKind::FunctionKeyword, T_GLOBAL => TokenKind::GlobalKeyword, T_GOTO => TokenKind::GotoKeyword, + T_HALT_COMPILER => TokenKind::HaltCompilerKeyword, T_IF => TokenKind::IfKeyword, T_IMPLEMENTS => TokenKind::ImplementsKeyword, T_INCLUDE => TokenKind::IncludeKeyword, diff --git a/vendor/microsoft/tolerant-php-parser/src/Token.php b/vendor/microsoft/tolerant-php-parser/src/Token.php index 6c9daf74..5fa1595d 100644 --- a/vendor/microsoft/tolerant-php-parser/src/Token.php +++ b/vendor/microsoft/tolerant-php-parser/src/Token.php @@ -18,7 +18,7 @@ class Token implements \JsonSerializable { public $fullStart; /** @var int */ public $start; - /** @var int */ + /** @var int the length is equal to $this->getEndPosition() - $this->fullStart. */ public $length; /** diff --git a/vendor/microsoft/tolerant-php-parser/src/TokenKind.php b/vendor/microsoft/tolerant-php-parser/src/TokenKind.php index 29058057..b4d59c2d 100644 --- a/vendor/microsoft/tolerant-php-parser/src/TokenKind.php +++ b/vendor/microsoft/tolerant-php-parser/src/TokenKind.php @@ -91,6 +91,7 @@ class TokenKind { const IterableKeyword = self::IterableReservedWord; const EnumKeyword = 171; const ReadonlyKeyword = 172; + const HaltCompilerKeyword = 173; const OpenBracketToken = 201; const CloseBracketToken = 202; @@ -175,6 +176,7 @@ class TokenKind { const NullReservedWord = 322; const MixedReservedWord = 340; const IterableReservedWord = 170; + const NeverReservedWord = 341; const ScriptSectionStartTag = 323; const ScriptSectionEndTag = 324; diff --git a/vendor/microsoft/tolerant-php-parser/src/TokenStringMaps.php b/vendor/microsoft/tolerant-php-parser/src/TokenStringMaps.php index 9798bdd9..15249ed1 100644 --- a/vendor/microsoft/tolerant-php-parser/src/TokenStringMaps.php +++ b/vendor/microsoft/tolerant-php-parser/src/TokenStringMaps.php @@ -57,6 +57,7 @@ class TokenStringMaps { "interface" => TokenKind::InterfaceKeyword, "isset" => TokenKind::IsSetKeyword, "list" => TokenKind::ListKeyword, + "match" => TokenKind::MatchKeyword, "namespace" => TokenKind::NamespaceKeyword, "new" => TokenKind::NewKeyword, "or" => TokenKind::OrKeyword, @@ -108,6 +109,7 @@ class TokenStringMaps { "void" => TokenKind::VoidReservedWord, "iterable" => TokenKind::IterableReservedWord, "mixed" => TokenKind::MixedReservedWord, + "never" => TokenKind::NeverReservedWord, ]; const OPERATORS_AND_PUNCTUATORS = [ diff --git a/vendor/phan/phan/.phan/internal_stubs/zip.phan_php b/vendor/phan/phan/.phan/internal_stubs/zip.phan_php new file mode 100644 index 00000000..7985aeff --- /dev/null +++ b/vendor/phan/phan/.phan/internal_stubs/zip.phan_php @@ -0,0 +1,163 @@ +code_base, (clone $this->context)->withLineNumberStart($last_if_elem->children['stmts']->lineno ?? $last_if_elem->lineno), 'PhanPluginEmptyStatementIf', - 'Empty statement list statement detected for the last if/elseif statement', + 'Empty statement list detected for the last if/elseif statement', [] ); } @@ -191,7 +191,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($stmts_node->lineno ?? $node->lineno), 'PhanPluginEmptyStatementForLoop', - 'Empty statement list statement detected for the for loop', + 'Empty statement list detected for the for loop', [] ); } @@ -219,7 +219,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($stmts_node->lineno ?? $node->lineno), 'PhanPluginEmptyStatementWhileLoop', - 'Empty statement list statement detected for the while loop', + 'Empty statement list detected for the while loop', [] ); } @@ -247,7 +247,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($stmts_node->lineno), 'PhanPluginEmptyStatementDoWhileLoop', - 'Empty statement list statement detected for the do-while loop', + 'Empty statement list detected for the do-while loop', [] ); } @@ -276,7 +276,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($stmts_node->lineno), 'PhanPluginEmptyStatementForeachLoop', - 'Empty statement list statement detected for the foreach loop', + 'Empty statement list detected for the foreach loop', [] ); } @@ -295,7 +295,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($try_node->lineno), 'PhanPluginEmptyStatementTryBody', - 'Empty statement list statement detected for the try statement\'s body', + 'Empty statement list detected for the try statement\'s body', [] ); } @@ -315,7 +315,7 @@ final class EmptyStatementListVisitor extends PluginAwarePostAnalysisVisitor $this->code_base, (clone $this->context)->withLineNumberStart($finally_node->lineno), 'PhanPluginEmptyStatementTryFinally', - 'Empty statement list statement detected for the try\'s finally body', + 'Empty statement list detected for the try\'s finally body', [] ); } diff --git a/vendor/phan/phan/.phan/plugins/README.md b/vendor/phan/phan/.phan/plugins/README.md index e8dede46..feed3640 100644 --- a/vendor/phan/phan/.phan/plugins/README.md +++ b/vendor/phan/phan/.phan/plugins/README.md @@ -216,15 +216,15 @@ By default, this plugin won't warn if it can find a TODO/FIXME/"Deliberately emp (This may miss some TODOs due to `php-ast` not providing the end line numbers) The setting `'plugin_config' => ['empty_statement_list_ignore_todos' => true]` can be used to make it unconditionally warn about empty statement lists. -- **PhanPluginEmptyStatementDoWhileLoop** `Empty statement list statement detected for the do-while loop` -- **PhanPluginEmptyStatementForLoop** `Empty statement list statement detected for the for loop` -- **PhanPluginEmptyStatementForeachLoop** `Empty statement list statement detected for the foreach loop` -- **PhanPluginEmptyStatementIf**: `Empty statement list statement detected for the last if/elseif statement` +- **PhanPluginEmptyStatementDoWhileLoop** `Empty statement list detected for the do-while loop` +- **PhanPluginEmptyStatementForLoop** `Empty statement list detected for the for loop` +- **PhanPluginEmptyStatementForeachLoop** `Empty statement list detected for the foreach loop` +- **PhanPluginEmptyStatementIf**: `Empty statement list detected for the last if/elseif statement` - **PhanPluginEmptyStatementSwitch** `No side effects seen for any cases of this switch statement` -- **PhanPluginEmptyStatementTryBody** `Empty statement list statement detected for the try statement's body` +- **PhanPluginEmptyStatementTryBody** `Empty statement list detected for the try statement's body` - **PhanPluginEmptyStatementPossiblyNonThrowingTryBody**: `Found a try block that looks like it might not throw. Note that this check is a heuristic prone to false positives, especially because error handlers, signal handlers, destructors, and other things may all lead to throwing.` -- **PhanPluginEmptyStatementTryFinally** `Empty statement list statement detected for the try's finally body` -- **PhanPluginEmptyStatementWhileLoop** `Empty statement list statement detected for the while loop` +- **PhanPluginEmptyStatementTryFinally** `Empty statement list detected for the try's finally body` +- **PhanPluginEmptyStatementWhileLoop** `Empty statement list detected for the while loop` ### LoopVariableReusePlugin.php diff --git a/vendor/phan/phan/NEWS.md b/vendor/phan/phan/NEWS.md index 8d21080d..cea4591a 100644 --- a/vendor/phan/phan/NEWS.md +++ b/vendor/phan/phan/NEWS.md @@ -1,5 +1,20 @@ Phan NEWS +Mar 03 2023, Phan 5.4.2 +----------------------- + +Miscellaneous: +- Fix wording in EmptyStatementListPlugin issue messages. +- Add a few more functions where the return value should be used. +- Fix signature of exif_read_data() #4759 +- Make allow_missing_properties setting aware of AllowDynamicProperties attribute for PHP 8.2 + +Maintenance: +- Require php-ast 1.1.0 or newer in PHP 8.2+ if php-ast is installed. + This release of php-ast makes the parsing of `AST_ARROW_FUNC` in php 8.2 match older php versions. +- Support parsing of PHP 8.2 syntax such as disjunctive normal form types and `readonly` classes in the polyfill/fallback parser. +- Fix bugs parsing `__halt_compiler()` in the polyfill/fallback parser. + Aug 25 2022, Phan 5.4.1 ----------------------- @@ -14,6 +29,11 @@ New Features(Analysis): Miscellaneous: - Allow `array_filter` `$callback` to be null (#4715) +Bug fixes: +- Fix false positive warning in PHP < 8.0 for inferring the method signature of `new SoapFault`. (#4724) + (The constructor was internally declared in reflection as `SoapFault::SoapFault` until php 8.0) + Adjust the method signature of `SoapFault::__construct` to match the documentation/implementation. + Aug 08 2022, Phan 5.4.0 ----------------------- diff --git a/vendor/phan/phan/composer.json b/vendor/phan/phan/composer.json index a22ad45a..f9210ec2 100644 --- a/vendor/phan/phan/composer.json +++ b/vendor/phan/phan/composer.json @@ -29,7 +29,7 @@ "composer/semver": "^1.4|^2.0|^3.0", "composer/xdebug-handler": "^2.0|^3.0", "felixfbecker/advanced-json-rpc": "^3.0.4", - "microsoft/tolerant-php-parser": "0.1.1", + "microsoft/tolerant-php-parser": "0.1.2", "netresearch/jsonmapper": "^1.6.0|^2.0|^3.0|^4.0", "sabre/event": "^5.1.3", "symfony/console": "^3.2|^4.0|^5.0|^6.0", diff --git a/vendor/phan/phan/composer.lock b/vendor/phan/phan/composer.lock index b308a8f8..5cd7db38 100644 --- a/vendor/phan/phan/composer.lock +++ b/vendor/phan/phan/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "62f4c0f1a6e50535b7c03182832d5c4e", + "content-hash": "301a32dbdfef414765074fc7e60effbb", "packages": [ { "name": "composer/pcre", - "version": "2.0.0", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe" + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/c8e9d27cfc5ed22643c19c160455b473ffd8aabe", - "reference": "c8e9d27cfc5ed22643c19c160455b473ffd8aabe", + "url": "https://api.github.com/repos/composer/pcre/zipball/3fdb2807b31a78a40ad89570e30ec77466c98717", + "reference": "3fdb2807b31a78a40ad89570e30ec77466c98717", "shasum": "" }, "require": { @@ -59,7 +59,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/2.0.0" + "source": "https://github.com/composer/pcre/tree/2.1.0" }, "funding": [ { @@ -75,7 +75,7 @@ "type": "tidelift" } ], - "time": "2022-02-25T20:05:29+00:00" + "time": "2022-11-16T18:32:04+00:00" }, { "name": "composer/semver", @@ -271,16 +271,16 @@ }, { "name": "microsoft/tolerant-php-parser", - "version": "v0.1.1", + "version": "v0.1.2", "source": { "type": "git", "url": "https://github.com/microsoft/tolerant-php-parser.git", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16" + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/6a965617cf484355048ac6d2d3de7b6ec93abb16", - "reference": "6a965617cf484355048ac6d2d3de7b6ec93abb16", + "url": "https://api.github.com/repos/microsoft/tolerant-php-parser/zipball/3eccfd273323aaf69513e2f1c888393f5947804b", + "reference": "3eccfd273323aaf69513e2f1c888393f5947804b", "shasum": "" }, "require": { @@ -310,22 +310,22 @@ "description": "Tolerant PHP-to-AST parser designed for IDE usage scenarios", "support": { "issues": "https://github.com/microsoft/tolerant-php-parser/issues", - "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.1" + "source": "https://github.com/microsoft/tolerant-php-parser/tree/v0.1.2" }, - "time": "2021-07-16T21:28:12+00:00" + "time": "2022-10-05T17:30:19+00:00" }, { "name": "netresearch/jsonmapper", - "version": "v4.0.0", + "version": "v4.1.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d" + "reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", - "reference": "8bbc021a8edb2e4a7ea2f8ad4fa9ec9dce2fcb8d", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/cfa81ea1d35294d64adb9c68aa4cb9e92400e53f", + "reference": "cfa81ea1d35294d64adb9c68aa4cb9e92400e53f", "shasum": "" }, "require": { @@ -361,9 +361,9 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.0.0" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.1.0" }, - "time": "2020-12-01T19:48:11+00:00" + "time": "2022-12-08T20:46:14+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -691,16 +691,16 @@ }, { "name": "symfony/console", - "version": "v5.4.11", + "version": "v5.4.21", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "535846c7ee6bc4dd027ca0d93220601456734b10" + "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/535846c7ee6bc4dd027ca0d93220601456734b10", - "reference": "535846c7ee6bc4dd027ca0d93220601456734b10", + "url": "https://api.github.com/repos/symfony/console/zipball/c77433ddc6cdc689caf48065d9ea22ca0853fbd9", + "reference": "c77433ddc6cdc689caf48065d9ea22ca0853fbd9", "shasum": "" }, "require": { @@ -770,7 +770,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.11" + "source": "https://github.com/symfony/console/tree/v5.4.21" }, "funding": [ { @@ -786,7 +786,7 @@ "type": "tidelift" } ], - "time": "2022-07-22T10:42:43+00:00" + "time": "2023-02-25T16:59:41+00:00" }, { "name": "symfony/deprecation-contracts", @@ -857,16 +857,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -881,7 +881,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -919,7 +919,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -935,20 +935,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "433d05519ce6990bf3530fba6957499d327395c2" + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2", - "reference": "433d05519ce6990bf3530fba6957499d327395c2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", "shasum": "" }, "require": { @@ -960,7 +960,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1000,7 +1000,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" }, "funding": [ { @@ -1016,20 +1016,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -1041,7 +1041,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1084,7 +1084,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -1100,20 +1100,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -1128,7 +1128,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1167,7 +1167,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -1183,20 +1183,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85" + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/e440d35fa0286f77fb45b79a03fedbeda9307e85", - "reference": "e440d35fa0286f77fb45b79a03fedbeda9307e85", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/9e8ecb5f92152187c4799efd3c96b78ccab18ff9", + "reference": "9e8ecb5f92152187c4799efd3c96b78ccab18ff9", "shasum": "" }, "require": { @@ -1205,7 +1205,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1246,7 +1246,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.27.0" }, "funding": [ { @@ -1262,20 +1262,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -1284,7 +1284,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -1329,7 +1329,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -1345,7 +1345,7 @@ "type": "tidelift" } ], - "time": "2022-05-10T07:21:04+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/service-contracts", @@ -1432,16 +1432,16 @@ }, { "name": "symfony/string", - "version": "v5.4.11", + "version": "v5.4.21", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322" + "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/5eb661e49ad389e4ae2b6e4df8d783a8a6548322", - "reference": "5eb661e49ad389e4ae2b6e4df8d783a8a6548322", + "url": "https://api.github.com/repos/symfony/string/zipball/edac10d167b78b1d90f46a80320d632de0bd9f2f", + "reference": "edac10d167b78b1d90f46a80320d632de0bd9f2f", "shasum": "" }, "require": { @@ -1498,7 +1498,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.11" + "source": "https://github.com/symfony/string/tree/v5.4.21" }, "funding": [ { @@ -1514,34 +1514,42 @@ "type": "tidelift" } ], - "time": "2022-07-24T16:15:25+00:00" + "time": "2023-02-22T08:00:55+00:00" }, { "name": "tysonandre/var_representation_polyfill", - "version": "0.1.2", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/TysonAndre/var_representation_polyfill.git", - "reference": "e925b7b0806b39f26aa899202ee065decbabafdb" + "reference": "e9116c2c352bb0835ca428b442dde7767c11ad32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TysonAndre/var_representation_polyfill/zipball/e925b7b0806b39f26aa899202ee065decbabafdb", - "reference": "e925b7b0806b39f26aa899202ee065decbabafdb", + "url": "https://api.github.com/repos/TysonAndre/var_representation_polyfill/zipball/e9116c2c352bb0835ca428b442dde7767c11ad32", + "reference": "e9116c2c352bb0835ca428b442dde7767c11ad32", "shasum": "" }, "require": { "ext-tokenizer": "*", "php": "^7.2.0|^8.0.0" }, + "provide": { + "ext-var_representation": "*" + }, "require-dev": { - "phan/phan": "^5.1", + "phan/phan": "^5.4.1", "phpunit/phpunit": "^8.5.0" }, "suggest": { - "ext-var_representation": "*" + "ext-var_representation": "For best performance" }, "type": "library", + "extra": { + "branch-alias": { + "dev-main": "0.1.3-dev" + } + }, "autoload": { "files": [ "src/var_representation.php" @@ -1566,9 +1574,9 @@ ], "support": { "issues": "https://github.com/TysonAndre/var_representation_polyfill/issues", - "source": "https://github.com/TysonAndre/var_representation_polyfill/tree/0.1.2" + "source": "https://github.com/TysonAndre/var_representation_polyfill/tree/0.1.3" }, - "time": "2022-08-11T12:33:19+00:00" + "time": "2022-08-31T12:59:22+00:00" }, { "name": "webmozart/assert", @@ -1632,30 +1640,30 @@ "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.1", + "version": "1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^9 || ^11", "ext-pdo": "*", "ext-phar": "*", "phpbench/phpbench": "^0.16 || ^1", "phpstan/phpstan": "^1.4", "phpstan/phpstan-phpunit": "^1", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "vimeo/psalm": "^4.30 || ^5.4" }, "type": "library", "autoload": { @@ -1682,7 +1690,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" }, "funding": [ { @@ -1698,7 +1706,7 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:15:36+00:00" }, { "name": "myclabs/deep-copy", @@ -2169,16 +2177,16 @@ }, { "name": "phpunit/phpunit", - "version": "8.5.29", + "version": "8.5.33", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e8c563c47a9a303662955518ca532b022b337f4d" + "reference": "7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e8c563c47a9a303662955518ca532b022b337f4d", - "reference": "e8c563c47a9a303662955518ca532b022b337f4d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e", + "reference": "7d1ff0e8c6b35db78ff13e3e05517d7cbf7aa32e", "shasum": "" }, "require": { @@ -2197,10 +2205,10 @@ "phpunit/php-file-iterator": "^2.0.4", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", + "sebastian/comparator": "^3.0.5", "sebastian/diff": "^3.0.2", "sebastian/environment": "^4.2.3", - "sebastian/exporter": "^3.1.2", + "sebastian/exporter": "^3.1.5", "sebastian/global-state": "^3.0.0", "sebastian/object-enumerator": "^3.0.3", "sebastian/resource-operations": "^2.0.1", @@ -2246,7 +2254,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.29" + "source": "https://github.com/sebastianbergmann/phpunit/tree/8.5.33" }, "funding": [ { @@ -2256,9 +2264,13 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-08-22T13:59:39+00:00" + "time": "2023-02-27T13:04:50+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -2317,16 +2329,16 @@ }, { "name": "sebastian/comparator", - "version": "3.0.3", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758" + "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1071dfcef776a57013124ff35e1fc41ccd294758", - "reference": "1071dfcef776a57013124ff35e1fc41ccd294758", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1dc7ceb4a24aede938c7af2a9ed1de09609ca770", + "reference": "1dc7ceb4a24aede938c7af2a9ed1de09609ca770", "shasum": "" }, "require": { @@ -2379,7 +2391,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.3" + "source": "https://github.com/sebastianbergmann/comparator/tree/3.0.5" }, "funding": [ { @@ -2387,7 +2399,7 @@ "type": "github" } ], - "time": "2020-11-30T08:04:30+00:00" + "time": "2022-09-14T12:31:48+00:00" }, { "name": "sebastian/diff", @@ -2520,16 +2532,16 @@ }, { "name": "sebastian/exporter", - "version": "3.1.4", + "version": "3.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db" + "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", - "reference": "0c32ea2e40dbf59de29f3b49bf375176ce7dd8db", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/73a9676f2833b9a7c36968f9d882589cd75511e6", + "reference": "73a9676f2833b9a7c36968f9d882589cd75511e6", "shasum": "" }, "require": { @@ -2585,7 +2597,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/3.1.5" }, "funding": [ { @@ -2593,7 +2605,7 @@ "type": "github" } ], - "time": "2021-11-11T13:51:24+00:00" + "time": "2022-09-14T06:00:17+00:00" }, { "name": "sebastian/global-state", @@ -3055,5 +3067,5 @@ "platform-overrides": { "php": "7.2.24" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.0.0" } diff --git a/vendor/phan/phan/src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php b/vendor/phan/phan/src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php index 34dfb6e7..819727a2 100644 --- a/vendor/phan/phan/src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php +++ b/vendor/phan/phan/src/Phan/AST/TolerantASTConverter/TolerantASTConverter.php @@ -1269,6 +1269,9 @@ class TolerantASTConverter $variableName !== null ? self::getStartLine($variableName) : $start_line ); }, + 'Microsoft\PhpParser\Node\Statement\HaltCompilerStatement' => static function (PhpParser\Node\Statement\HaltCompilerStatement $n, int $start_line): ast\Node { + return new ast\Node(ast\AST_HALT_COMPILER, 0, ['offset' => $n->getHaltCompilerOffset()], $start_line); + }, 'Microsoft\PhpParser\Node\Statement\InterfaceDeclaration' => static function (PhpParser\Node\Statement\InterfaceDeclaration $n, int $start_line): ast\Node { if ($n->interfaceKeyword) { $start_line = self::getStartLine($n->interfaceKeyword); @@ -1294,7 +1297,7 @@ class TolerantASTConverter $end_line = static::getEndLine($n); $base_class = $n->classBaseClause->baseClass ?? null; return static::astStmtClass( - static::phpParserClassModifierToAstClassFlags($n->abstractOrFinalModifier), + static::phpParserClassModifiersToAstClassFlags($n->abstractOrFinalModifier, $n->modifiers), static::tokenToString($n->name), static::phpParserAttributeGroupsToAstAttributeList($n->attributes), $base_class !== null ? static::phpParserNonValueNodeToAstNode($base_class) : null, @@ -1940,6 +1943,23 @@ class TolerantASTConverter return new ast\Node($is_intersection ? ast\AST_TYPE_INTERSECTION : ast\AST_TYPE_UNION, 0, $types, $types[0]->lineno); } + protected static function phpParserParenthesizedIntersectionTypeToAstNode(PhpParser\Node\ParenthesizedIntersectionType $n, int $start_line): ?ast\Node { + $children = []; + foreach ($n->children->children ?? [] as $c) { + if ($c instanceof Token && $c->kind === TokenKind::AmpersandToken) { + continue; + } + $result = self::phpParserTypeToAstNode($c, $start_line); + if ($result) { + $children[] = $result; + } + } + if (count($children) <= 1) { + return $children[0] ?? null; + } + return new ast\Node(ast\AST_TYPE_INTERSECTION, 0, $children, $start_line); + } + /** * @param PhpParser\Node\QualifiedName|Token|null $type */ @@ -1951,7 +1971,12 @@ class TolerantASTConverter $original_type = $type; if ($type instanceof PhpParser\Node\QualifiedName) { $type = static::phpParserNameToString($type); + } elseif ($type instanceof PhpParser\Node\ParenthesizedIntersectionType) { + return static::phpParserParenthesizedIntersectionTypeToAstNode($type, $line); } elseif ($type instanceof Token) { + if (get_class($type) !== Token::class) { + return null; + } $type = static::tokenToString($type); } if (\is_string($type)) { @@ -2283,24 +2308,35 @@ class TolerantASTConverter ); } - /** - * @param ?Token $flags - * @throws InvalidArgumentException if the class flags were unexpected - */ - private static function phpParserClassModifierToAstClassFlags(?Token $flags): int + private static function phpParserClassModifierToAstClassFlags(?Token $modifier): int { - if ($flags === null) { + if ($modifier === null) { return 0; } - switch ($flags->kind) { + switch ($modifier->kind) { case TokenKind::AbstractKeyword: return flags\CLASS_ABSTRACT; case TokenKind::FinalKeyword: return flags\CLASS_FINAL; + case TokenKind::ReadonlyKeyword: + return flags\CLASS_READONLY; default: - throw new InvalidArgumentException("Unexpected kind '" . Token::getTokenKindNameFromValue($flags->kind) . "'"); + throw new InvalidArgumentException("Unexpected kind '" . Token::getTokenKindNameFromValue($modifier->kind) . "'"); } } + /** + * @param ?Token $modifier + * @param list $modifiers + * @throws InvalidArgumentException if the class flags were unexpected + */ + private static function phpParserClassModifiersToAstClassFlags(?Token $modifier, array $modifiers): int + { + $flags = self::phpParserClassModifierToAstClassFlags($modifier); + foreach ($modifiers as $extra_modifier) { + $flags |= self::phpParserClassModifierToAstClassFlags($extra_modifier); + } + return $flags; + } private static function interfaceBaseClauseToNode(?\Microsoft\PhpParser\Node\InterfaceBaseClause $node): ?\ast\Node { diff --git a/vendor/phan/phan/src/Phan/Bootstrap.php b/vendor/phan/phan/src/Phan/Bootstrap.php index 697a1843..9702f96a 100644 --- a/vendor/phan/phan/src/Phan/Bootstrap.php +++ b/vendor/phan/phan/src/Phan/Bootstrap.php @@ -146,8 +146,8 @@ if (extension_loaded('ast')) { exit(1); }; - if (PHP_VERSION_ID >= 80200 && version_compare($ast_version, '1.0.15') < 0) { - $phan_output_ast_too_old_and_exit('1.0.15', '8.2'); + if (PHP_VERSION_ID >= 80200 && version_compare($ast_version, '1.1.0') < 0) { + $phan_output_ast_too_old_and_exit('1.1.0', '8.2'); } elseif (PHP_VERSION_ID >= 80100 && version_compare($ast_version, '1.0.14') < 0) { $phan_output_ast_too_old_and_exit('1.0.14', '8.1'); } elseif (PHP_VERSION_ID >= 80000 && version_compare($ast_version, '1.0.11') < 0) { @@ -360,6 +360,7 @@ function phan_error_handler(int $errno, string $errstr, string $errfile, int $er } if ($errno === E_DEPRECATED) { // Because php 7.2 is used in CI we're stuck on an unmaintained paratest version. + // NOTE: Known issues with dynamic properties in tolerant-php-parser are fixed in `main` (but not 0.1.1) but there may be remaining unknown ones. if (preg_match('/^Creation of dynamic property (ParaTest\\\\Runners|Microsoft\\\\PhpParser|Phan\\\\LanguageServer\\\\LanguageServer::)/', $errstr)) { return true; } diff --git a/vendor/phan/phan/src/Phan/CLI.php b/vendor/phan/phan/src/Phan/CLI.php index 830ed8b6..9e65f72a 100644 --- a/vendor/phan/phan/src/Phan/CLI.php +++ b/vendor/phan/phan/src/Phan/CLI.php @@ -84,7 +84,7 @@ class CLI /** * This should be updated to x.y.z-dev after every release, and x.y.z before a release. */ - public const PHAN_VERSION = '5.4.1'; + public const PHAN_VERSION = '5.4.2'; /** * List of short flags passed to getopt diff --git a/vendor/phan/phan/src/Phan/Language/Element/Clazz.php b/vendor/phan/phan/src/Phan/Language/Element/Clazz.php index a5c63176..a4513d7a 100644 --- a/vendor/phan/phan/src/Phan/Language/Element/Clazz.php +++ b/vendor/phan/phan/src/Phan/Language/Element/Clazz.php @@ -488,6 +488,10 @@ class Clazz extends AddressableElement foreach ($method_list as $method) { $clazz->addMethod($code_base, $method, None::instance()); } + if (\PHP_VERSION_ID < 80000 && $reflection_method->isConstructor() && \strcasecmp($reflection_method->name, '__construct') !== 0) { + // E.g. SoapFault::SoapFault and other soap classes before PHP 8.0 + $clazz->addMethod($code_base, Method::defaultConstructorForClass($clazz, $code_base), None::instance()); + } } return $clazz; @@ -2298,6 +2302,11 @@ class Clazz extends AddressableElement */ public function hasDynamicProperties(CodeBase $code_base): bool { + foreach($this->attribute_list as $attr) { + if ((string)$attr === '\AllowDynamicProperties') { + return true; + } + } return $this->hasFlagsRecursive($code_base, Flags::CLASS_HAS_DYNAMIC_PROPERTIES); } @@ -2979,6 +2988,16 @@ class Clazz extends AddressableElement $this->warnAboutAmbiguousInheritance($code_base, $class, $next_class_fqsen); } + if ($attribute_list = $class->getAttributeList()) { + foreach($attribute_list as $attr) { + if ((string)$attr === "\AllowDynamicProperties") { + $new_attribute_list = $this->getAttributeList(); + $new_attribute_list[] = $attr; + $this->setAttributeList($new_attribute_list); + break; + } + } + } // Constants should have been imported earlier, but call it again just in case $this->importConstantsFromAncestorClass($code_base, $class); diff --git a/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap.php b/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap.php index e15ed6f7..a0023057 100644 --- a/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap.php +++ b/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap.php @@ -3074,7 +3074,7 @@ return [ 'Exception::getTraceAsString' => ['string'], 'exec' => ['string', 'command'=>'string', '&w_output='=>'array', '&w_result_code='=>'int'], 'exif_imagetype' => ['int|false', 'filename'=>'string'], -'exif_read_data' => ['array|false', 'file'=>'string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'], +'exif_read_data' => ['array|false', 'file'=>'resource|string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'], 'exif_tagname' => ['string|false', 'index'=>'int'], 'exif_thumbnail' => ['string|false', 'file'=>'string', '&w_width='=>'int', '&w_height='=>'int', '&w_image_type='=>'int'], 'exit' => ['', 'status'=>'string|int'], @@ -13136,7 +13136,7 @@ return [ 'SoapClient::__soapCall' => ['', 'name'=>'string', 'args'=>'array', 'options='=>'array', 'inputHeaders='=>'SoapHeader|array', '&w_outputHeaders='=>'array'], 'SoapClient::SoapClient' => ['object', 'wsdl'=>'mixed', 'options='=>'array'], 'SoapFault::__clone' => ['void'], -'SoapFault::__construct' => ['void', 'code'=>'string', 'string'=>'string', 'actor='=>'string', 'details='=>'string', 'name='=>'string', 'headerFault='=>'string'], +'SoapFault::__construct' => ['void', 'code'=>'?string|?array{0:string,1:string}', 'string'=>'string', 'actor='=>'string', 'details='=>'mixed', 'name='=>'string', 'headerFault='=>'string'], 'SoapFault::__toString' => ['string'], 'SoapFault::__wakeup' => ['void'], 'SoapFault::getCode' => ['int'], @@ -13146,7 +13146,7 @@ return [ 'SoapFault::getPrevious' => ['?Exception|?Throwable'], 'SoapFault::getTrace' => ['array'], 'SoapFault::getTraceAsString' => ['string'], -'SoapFault::SoapFault' => ['object', 'faultcode'=>'string', 'faultstring'=>'string', 'faultactor='=>'string', 'detail='=>'string', 'faultname='=>'string', 'headerfault='=>'string'], +'SoapFault::SoapFault' => ['void', 'code'=>'?string|?array{0:string,1:string}', 'string'=>'string', 'actor='=>'string', 'details='=>'mixed', 'name='=>'string', 'headerFault='=>'string'], 'SoapHeader::__construct' => ['void', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustUnderstand='=>'bool', 'actor='=>'string'], 'SoapHeader::SoapHeader' => ['object', 'namespace'=>'string', 'name'=>'string', 'data='=>'mixed', 'mustunderstand='=>'bool', 'actor='=>'string'], 'SoapParam::__construct' => ['void', 'data'=>'mixed', 'name'=>'string'], diff --git a/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap_php72_delta.php b/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap_php72_delta.php index bcd65f52..eccdb651 100644 --- a/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap_php72_delta.php +++ b/vendor/phan/phan/src/Phan/Language/Internal/FunctionSignatureMap_php72_delta.php @@ -131,6 +131,10 @@ return [ 'ZipArchive::setEncryptionName' => ['bool', 'name'=>'string', 'method'=>'int', 'password='=>'string'], ], 'changed' => [ + 'exif_read_data' => [ + 'old' => ['array|false', 'file'=>'string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'], + 'new' => ['array|false', 'file'=>'resource|string', 'required_sections='=>'string', 'as_arrays='=>'bool', 'read_thumbnail='=>'bool'], + ], 'hash_copy' => [ 'old' => ['resource', 'context'=>'resource'], 'new' => ['HashContext', 'context'=>'HashContext'], diff --git a/vendor/phan/phan/src/Phan/Plugin/Internal/UseReturnValuePlugin.php b/vendor/phan/phan/src/Phan/Plugin/Internal/UseReturnValuePlugin.php index 13e46466..2ad8dd21 100644 --- a/vendor/phan/phan/src/Phan/Plugin/Internal/UseReturnValuePlugin.php +++ b/vendor/phan/phan/src/Phan/Plugin/Internal/UseReturnValuePlugin.php @@ -417,6 +417,7 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability 'gethostname' => true, 'getimagesize' => true, 'get_include_path' => true, + 'get_mangled_object_vars' => true, 'get_magic_quotes_gpc' => true, 'get_magic_quotes_gpc_runtime' => true, 'getmypid' => true, @@ -457,7 +458,9 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability 'hypot' => true, 'iconv_strlen' => true, 'iconv' => true, + 'imagecreate' => self::MUST_USE_WITH_SIDE_EFFECTS, 'imagecreatetruecolor' => self::MUST_USE_WITH_SIDE_EFFECTS, + 'imagecreatefromtga' => self::MUST_USE_WITH_SIDE_EFFECTS, 'imagetypes' => true, 'implode' => true, 'in_array' => true, @@ -624,10 +627,12 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability 'openssl_encrypt' => true, 'openssl_error_string' => true, 'openssl_random_pseudo_bytes' => true, + 'openssl_x509_verify' => true, 'ord' => true, 'pack' => true, 'parse_ini_file' => true, 'parse_url' => true, + 'password_algos' => true, 'pathinfo' => true, 'pdo::getattribute' => true, 'pdo::prepare' => true, @@ -742,6 +747,8 @@ class UseReturnValuePlugin extends PluginV3 implements PostAnalyzeNodeCapability 'reflectionproperty::getvalue' => true, 'reflectionproperty::ispublic' => true, 'reflectionproperty::isstatic' => true, + 'reflectionreference::fromarrayelement' => true, + 'reflectionreference::getid' => true, 'reflectiontype::__tostring' => true, 'resourcebundle::geterrorcode' => true, 'round' => true, diff --git a/vendor/phan/phan/tool/make_ctags_for_phan_project b/vendor/phan/phan/tool/make_ctags_for_phan_project index c11d0035..7da3977b 100755 --- a/vendor/phan/phan/tool/make_ctags_for_phan_project +++ b/vendor/phan/phan/tool/make_ctags_for_phan_project @@ -15,6 +15,7 @@ # The resulting tags file may be combined with tags for JS, CSS, etc. function usage() { echo "Usage: $0 [options for phpctags]" 1>&2 + echo "You may wish to run ./phan --dump-ctags=basic instead" 1>&2 } if ! type phpctags ; then diff --git a/vendor/symfony/console/Application.php b/vendor/symfony/console/Application.php index d4ec1be0..41548a3e 100644 --- a/vendor/symfony/console/Application.php +++ b/vendor/symfony/console/Application.php @@ -87,7 +87,7 @@ class Application implements ResetInterface private string $defaultCommand; private bool $singleCommand = false; private bool $initialized = false; - private SignalRegistry $signalRegistry; + private ?SignalRegistry $signalRegistry = null; private array $signalsToDispatchEvent = []; public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') diff --git a/vendor/symfony/console/Helper/ProgressIndicator.php b/vendor/symfony/console/Helper/ProgressIndicator.php index 17203646..b5fa24c4 100644 --- a/vendor/symfony/console/Helper/ProgressIndicator.php +++ b/vendor/symfony/console/Helper/ProgressIndicator.php @@ -123,8 +123,6 @@ class ProgressIndicator /** * Finish the indicator with message. - * - * @param $message */ public function finish(string $message) { diff --git a/vendor/symfony/console/Input/InputArgument.php b/vendor/symfony/console/Input/InputArgument.php index f0867193..a130c412 100644 --- a/vendor/symfony/console/Input/InputArgument.php +++ b/vendor/symfony/console/Input/InputArgument.php @@ -36,10 +36,10 @@ class InputArgument private string $description; /** - * @param string $name The argument name - * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL - * @param string $description A description text - * @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) + * @param string $name The argument name + * @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param string $description A description text + * @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException When argument mode is not valid diff --git a/vendor/symfony/console/Input/InputOption.php b/vendor/symfony/console/Input/InputOption.php index 452c9f7f..9a7032a0 100644 --- a/vendor/symfony/console/Input/InputOption.php +++ b/vendor/symfony/console/Input/InputOption.php @@ -58,9 +58,9 @@ class InputOption private string $description; /** - * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts - * @param int|null $mode The option mode: One of the VALUE_* constants - * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) + * @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int|null $mode The option mode: One of the VALUE_* constants + * @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE) * @param array|\Closure(CompletionInput,CompletionSuggestions):list $suggestedValues The values used for input completion * * @throws InvalidArgumentException If option mode is invalid or incompatible diff --git a/vendor/symfony/console/LICENSE b/vendor/symfony/console/LICENSE index 00837045..0138f8f0 100644 --- a/vendor/symfony/console/LICENSE +++ b/vendor/symfony/console/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/console/Output/ConsoleSectionOutput.php b/vendor/symfony/console/Output/ConsoleSectionOutput.php index 7978a922..c813c811 100644 --- a/vendor/symfony/console/Output/ConsoleSectionOutput.php +++ b/vendor/symfony/console/Output/ConsoleSectionOutput.php @@ -115,7 +115,8 @@ class ConsoleSectionOutput extends StreamOutput // re-add the line break (that has been removed in the above `explode()` for // - every line that is not the last line // - if $newline is required, also add it to the last line - if ($i < $count || $newline) { + // - if it's not new line, but input ending with `\PHP_EOL` + if ($i < $count || $newline || str_ends_with($input, \PHP_EOL)) { $lineContent .= \PHP_EOL; } @@ -149,6 +150,15 @@ class ConsoleSectionOutput extends StreamOutput return $linesAdded; } + /** + * @internal + */ + public function addNewLineOfInputSubmit() + { + $this->content[] = \PHP_EOL; + ++$this->lines; + } + protected function doWrite(string $message, bool $newline) { if (!$this->isDecorated()) { diff --git a/vendor/symfony/console/Style/SymfonyStyle.php b/vendor/symfony/console/Style/SymfonyStyle.php index 997f8627..8fd6f849 100644 --- a/vendor/symfony/console/Style/SymfonyStyle.php +++ b/vendor/symfony/console/Style/SymfonyStyle.php @@ -23,6 +23,7 @@ use Symfony\Component\Console\Helper\TableCell; use Symfony\Component\Console\Helper\TableSeparator; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Console\Output\ConsoleSectionOutput; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\TrimmedBufferOutput; use Symfony\Component\Console\Question\ChoiceQuestion; @@ -298,6 +299,11 @@ class SymfonyStyle extends OutputStyle $answer = $this->questionHelper->ask($this->input, $this, $question); if ($this->input->isInteractive()) { + if ($this->output instanceof ConsoleSectionOutput) { + // add the new line of the `return` to submit the input to ConsoleSectionOutput, because ConsoleSectionOutput is holding all it's lines. + // this is relevant when a `ConsoleSectionOutput::clear` is called. + $this->output->addNewLineOfInputSubmit(); + } $this->newLine(); $this->bufferedOutput->write("\n"); } diff --git a/vendor/symfony/deprecation-contracts/LICENSE b/vendor/symfony/deprecation-contracts/LICENSE index 406242ff..0ed3a246 100644 --- a/vendor/symfony/deprecation-contracts/LICENSE +++ b/vendor/symfony/deprecation-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2020-2022 Fabien Potencier +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/deprecation-contracts/README.md b/vendor/symfony/deprecation-contracts/README.md index 4957933a..9814864c 100644 --- a/vendor/symfony/deprecation-contracts/README.md +++ b/vendor/symfony/deprecation-contracts/README.md @@ -22,5 +22,5 @@ trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use This will generate the following message: `Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` -While not necessarily recommended, the deprecation notices can be completely ignored by declaring an empty +While not recommended, the deprecation notices can be completely ignored by declaring an empty `function trigger_deprecation() {}` in your application. diff --git a/vendor/symfony/service-contracts/LICENSE b/vendor/symfony/service-contracts/LICENSE index 74cdc2db..7536caea 100644 --- a/vendor/symfony/service-contracts/LICENSE +++ b/vendor/symfony/service-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2018-2022 Fabien Potencier +Copyright (c) 2018-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/service-contracts/README.md b/vendor/symfony/service-contracts/README.md index 41e054a1..42841a57 100644 --- a/vendor/symfony/service-contracts/README.md +++ b/vendor/symfony/service-contracts/README.md @@ -3,7 +3,7 @@ Symfony Service Contracts A set of abstractions extracted out of the Symfony components. -Can be used to build on semantics that the Symfony components proved useful - and +Can be used to build on semantics that the Symfony components proved useful and that already have battle tested implementations. See https://github.com/symfony/contracts/blob/main/README.md for more information. diff --git a/vendor/symfony/service-contracts/ResetInterface.php b/vendor/symfony/service-contracts/ResetInterface.php index 1af1075e..a4f389b0 100644 --- a/vendor/symfony/service-contracts/ResetInterface.php +++ b/vendor/symfony/service-contracts/ResetInterface.php @@ -26,5 +26,8 @@ namespace Symfony\Contracts\Service; */ interface ResetInterface { + /** + * @return void + */ public function reset(); } diff --git a/vendor/symfony/service-contracts/ServiceProviderInterface.php b/vendor/symfony/service-contracts/ServiceProviderInterface.php index a28fd82e..c05e4bfe 100644 --- a/vendor/symfony/service-contracts/ServiceProviderInterface.php +++ b/vendor/symfony/service-contracts/ServiceProviderInterface.php @@ -19,7 +19,7 @@ use Psr\Container\ContainerInterface; * @author Nicolas Grekas * @author Mateusz Sip * - * @template T of mixed + * @template-covariant T of mixed */ interface ServiceProviderInterface extends ContainerInterface { diff --git a/vendor/symfony/service-contracts/ServiceSubscriberTrait.php b/vendor/symfony/service-contracts/ServiceSubscriberTrait.php index f7cd3a94..f3b450cd 100644 --- a/vendor/symfony/service-contracts/ServiceSubscriberTrait.php +++ b/vendor/symfony/service-contracts/ServiceSubscriberTrait.php @@ -66,12 +66,13 @@ trait ServiceSubscriberTrait #[Required] public function setContainer(ContainerInterface $container): ?ContainerInterface { - $this->container = $container; - + $ret = null; if (method_exists(get_parent_class(self::class) ?: '', __FUNCTION__)) { - return parent::setContainer($container); + $ret = parent::setContainer($container); } - return null; + $this->container = $container; + + return $ret; } } diff --git a/vendor/symfony/string/AbstractUnicodeString.php b/vendor/symfony/string/AbstractUnicodeString.php index 52912276..2a2bed71 100644 --- a/vendor/symfony/string/AbstractUnicodeString.php +++ b/vendor/symfony/string/AbstractUnicodeString.php @@ -37,8 +37,8 @@ abstract class AbstractUnicodeString extends AbstractString private const ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; // the subset of folded case mappings that is not in lower case mappings - private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'İ', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ']; - private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ']; + private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ']; + private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ']; // the subset of upper case mappings that map one code point to many code points private const UPPER_FROM = ['ß', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', 'ΐ', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ']; diff --git a/vendor/symfony/string/LICENSE b/vendor/symfony/string/LICENSE index 5c7ba055..f37c76b5 100644 --- a/vendor/symfony/string/LICENSE +++ b/vendor/symfony/string/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/www/admin/class_test.admin.backend.php b/www/admin/class_test.admin.backend.php index f3820459..f325e065 100644 --- a/www/admin/class_test.admin.backend.php +++ b/www/admin/class_test.admin.backend.php @@ -11,10 +11,6 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file @@ -35,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, - 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'debug_all' => $DEBUG_ALL, + 'echo_all' => $ECHO_ALL, + 'print_all' => $PRINT_ALL, ]); // db config with logger $db = new CoreLibs\DB\IO(DB_CONFIG, $log); @@ -47,7 +43,15 @@ $l10n = new \CoreLibs\Language\L10n( $locale['domain'], $locale['path'], ); -$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale); +$backend = new CoreLibs\Admin\Backend( + $db, + $log, + $session, + $l10n, + $locale, + DEFAULT_ACL_LEVEL +); +use CoreLibs\Debug\Support; $PAGE_NAME = 'TEST CLASS: ADMIN BACKEND'; print ""; @@ -57,11 +61,14 @@ print ''; print '

' . $PAGE_NAME . '

'; // set acl, from eg login acl -print "SETACL[]: " . $backend->setACL(['EMPTY' => 'EMPTY']) . "
"; -print "ADBEDITLOG: " . $backend->adbEditLog('CLASSTEST-ADMIN', 'Some info stirng') . "
"; -print "ADBTOPMENU(0): " . \CoreLibs\Debug\Support::printAr($backend->adbTopMenu()) . "
"; -print "ADBMSG: " . $backend->adbMsg('info', 'Message: %1$d', [1]) . "
"; -print "Messaes: " . \CoreLibs\Debug\Support::printAr($backend->messages) . "
"; +print "SETACL[]:
"; +$backend->setACL(['EMPTY' => 'EMPTY']); +print "ADBEDITLOG:
"; +$backend->adbEditLog('CLASSTEST-ADMIN', 'Some info string'); +print "ADBTOPMENU(0): " . Support::printAr($backend->adbTopMenu(CONTENT_PATH)) . "
"; +print "ADBMSG:
"; +$backend->adbMsg('info', 'Message: %1$d', [1]); +print "Messaes: " . Support::printAr($backend->messages) . "
"; print "ADBPRINTDATETIME:
" . $backend->adbPrintDateTime(2021, 6, 21, 6, 38, '_test') . "
"; // error message diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php index 3f058470..abc3f8bd 100644 --- a/www/admin/class_test.array.php +++ b/www/admin/class_test.array.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -27,6 +23,7 @@ ob_end_flush(); use CoreLibs\Combined\ArrayHandler; use CoreLibs\Debug\Support as DgS; +use CoreLibs\Convert\SetVarType; $log = new CoreLibs\Debug\Logging([ 'log_folder' => BASE . LOG, @@ -34,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); // $_array = new CoreLibs\Combined\ArrayHandler(); // $array_class = 'CoreLibs\Combination\ArrayHandler'; @@ -92,7 +89,9 @@ $array_3 = [ ] ]; // recusrice merge -print "ARRAYMERGERECURSIVE: " . DgS::printAr(ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3)) . "
"; +print "ARRAYMERGERECURSIVE: " . DgS::printAr(SetVarType::setArray( + ArrayHandler::arrayMergeRecursive($array_1, $array_2, $array_3) +)) . "
"; // array difference $array_left = [ 'same' => 'data', @@ -104,7 +103,9 @@ $array_right = [ ]; print "ARRAYDIFF: " . DgS::printAr(ArrayHandler::arrayDiff($array_left, $array_right)) . "
"; // in array check -print "INARRAYANY([1,3], [array]): " . DgS::printAr(ArrayHandler::inArrayAny([1, 3], $array_2)) . "
"; +print "INARRAYANY([1,3], [array]): " . DgS::printAr(SetVarType::setArray( + ArrayHandler::inArrayAny([1, 3], $array_2) +)) . "
"; // flatten array print "FLATTENARRAY: " . DgS::printAr(ArrayHandler::flattenArray($test_array)) . "
"; print "FLATTENARRAYKEY: " . DgS::printAr(ArrayHandler::flattenArrayKey($test_array)) . "
"; @@ -114,10 +115,10 @@ print "ARRAYFLATFORKEY: " . DgS::printAr(ArrayHandler::arrayFlatForKey($test_arr /** * attach key/value to an array so it becomes nested * - * @param string $pre Attach to new (empty for new root node) - * @param string $cur New node - * @param array $node Previous created array - * @return array Updated array + * @param string $pre Attach to new (empty for new root node) + * @param string $cur New node + * @param array $node Previous created array + * @return array Updated array */ function rec(string $pre, string $cur, array $node = []) { diff --git a/www/admin/class_test.autoloader.php b/www/admin/class_test.autoloader.php index 24d85cf7..c3e2e0bb 100644 --- a/www/admin/class_test.autoloader.php +++ b/www/admin/class_test.autoloader.php @@ -11,10 +11,6 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file define('USE_DATABASE', false); diff --git a/www/admin/class_test.byte.php b/www/admin/class_test.byte.php index 801ddd04..a7d8e7a7 100644 --- a/www/admin/class_test.byte.php +++ b/www/admin/class_test.byte.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $byte_class = 'CoreLibs\Convert\Byte'; diff --git a/www/admin/class_test.check.colors.php b/www/admin/class_test.check.colors.php index 9ca898ad..4fe36974 100644 --- a/www/admin/class_test.check.colors.php +++ b/www/admin/class_test.check.colors.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: CHECK COLORS'; diff --git a/www/admin/class_test.config.direct.php b/www/admin/class_test.config.direct.php index 41a91f51..a3c89b81 100644 --- a/www/admin/class_test.config.direct.php +++ b/www/admin/class_test.config.direct.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: CONFIG DIRECT'; @@ -47,7 +43,7 @@ print "DIR: " . DIR . "
"; print "BASE: " . BASE . "
"; print "ROOT: " . ROOT . "
"; print "BASE NAME: " . BASE_NAME . "
"; -echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "
"; +echo "Config path prefix: " . ($CONFIG_PATH_PREFIX ?? '') . "
"; print "DB Name: " . DB_CONFIG_NAME . "
"; print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "
"; diff --git a/www/admin/class_test.config.link.php b/www/admin/class_test.config.link.php index de977286..28aa233b 100644 --- a/www/admin/class_test.config.link.php +++ b/www/admin/class_test.config.link.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: CONFIG LINK'; @@ -47,7 +43,7 @@ print "DIR: " . DIR . "
"; print "BASE: " . BASE . "
"; print "ROOT: " . ROOT . "
"; print "BASE NAME: " . BASE_NAME . "
"; -echo "Config path prefix: " . $CONFIG_PATH_PREFIX . "
"; +echo "Config path prefix: " . ($CONFIG_PATH_PREFIX ?? '') . "
"; print "DB Name: " . DB_CONFIG_NAME . "
"; print "DB Config: " . \CoreLibs\Debug\Support::printAr(DB_CONFIG) . "
"; diff --git a/www/admin/class_test.convert.colors.php b/www/admin/class_test.convert.colors.php index 9c0312a4..fc0c27d2 100644 --- a/www/admin/class_test.convert.colors.php +++ b/www/admin/class_test.convert.colors.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -27,6 +23,7 @@ ob_end_flush(); use CoreLibs\Convert\Colors; use CoreLibs\Debug\Support as DgS; +use CoreLibs\Convert\SetVarType; $log = new CoreLibs\Debug\Logging([ 'log_folder' => BASE . LOG, @@ -34,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $color_class = 'CoreLibs\Convert\Colors'; @@ -59,24 +56,40 @@ $hsb = [210, 67, 12]; $hsb_f = [210.5, 67.5, 12.5]; $hsl = [210, 50, 7.8]; print "S::COLOR rgb->hex: $rgb[0], $rgb[1], $rgb[2]: " . Colors::rgb2hex($rgb[0], $rgb[1], $rgb[2]) . "
"; -print "S::COLOR hex->rgb: $hex: " . DgS::printAr(Colors::hex2rgb($hex)) . "
"; -print "C::S/COLOR rgb->hext: $hex: " . DgS::printAr(CoreLibs\Convert\Colors::hex2rgb($hex)) . "
"; +print "S::COLOR hex->rgb: $hex: " . DgS::printAr(SetVarType::setArray( + Colors::hex2rgb($hex) +)) . "
"; +print "C::S/COLOR rgb->hext: $hex: " . DgS::printAr(SetVarType::setArray( + CoreLibs\Convert\Colors::hex2rgb($hex) +)) . "
"; // C(to hsb/hsl) print "S::COLOR rgb->hsb: $rgb[0], $rgb[1], $rgb[2]: " - . DgS::printAr(Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2])) . "
"; + . DgS::printAr(SetVarType::setArray( + Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2]) + )) . "
"; print "S::COLOR rgb->hsl: $rgb[0], $rgb[1], $rgb[2]: " - . DgS::printAr(Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2])) . "
"; + . DgS::printAr(SetVarType::setArray( + Colors::rgb2hsl($rgb[0], $rgb[1], $rgb[2]) + )) . "
"; // D(from hsb/hsl) Note that param 2 + 3 is always 0-100 divided print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: " - . DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])) . "
"; - print "S::COLOR hsb_f->rgb: $hsb_f[0], $hsb_f[1], $hsb_f[2]: " - . DgS::printAr(Colors::hsb2rgb($hsb_f[0], $hsb_f[1], $hsb_f[2])) . "
"; + . DgS::printAr(SetVarType::setArray( + Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2]) + )) . "
"; +print "S::COLOR hsb_f->rgb: $hsb_f[0], $hsb_f[1], $hsb_f[2]: " + . DgS::printAr(SetVarType::setArray( + Colors::hsb2rgb($hsb_f[0], $hsb_f[1], $hsb_f[2]) + )) . "
"; print "S::COLOR hsl->rgb: $hsl[0], $hsl[1], $hsl[2]: " - . DgS::printAr(Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2])) . "
"; + . DgS::printAr(SetVarType::setArray( + Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2]) + )) . "
"; $hsb = [0, 0, 5]; print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: " - . DgS::printAr(Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2])) . "
"; + . DgS::printAr(SetVarType::setArray( + Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2]) + )) . "
"; // Random text $h = rand(0, 359); @@ -84,8 +97,8 @@ $s = rand(15, 70); $b = 100; $l = 50; print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "
"; -print "RANDOM hsb->rgb:
" . DgS::printAr(Colors::hsb2rgb($h, $s, $b)) . "

"; -print "RANDOM hsl->rgb:
" . DgS::printAr(Colors::hsl2rgb($h, $s, $l)) . "

"; +print "RANDOM hsb->rgb:
" . DgS::printAr(SetVarType::setArray(Colors::hsb2rgb($h, $s, $b))) . "

"; +print "RANDOM hsl->rgb:
" . DgS::printAr(SetVarType::setArray(Colors::hsl2rgb($h, $s, $l))) . "

"; // TODO: run compare check input must match output diff --git a/www/admin/class_test.create_email.php b/www/admin/class_test.create_email.php index ab55cd36..c48ebd3d 100644 --- a/www/admin/class_test.create_email.php +++ b/www/admin/class_test.create_email.php @@ -13,10 +13,6 @@ $PRINT_ALL = true; $ECHO_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file diff --git a/www/admin/class_test.datetime.php b/www/admin/class_test.datetime.php index 7a09af51..7c2556ab 100644 --- a/www/admin/class_test.datetime.php +++ b/www/admin/class_test.datetime.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $datetime_class = 'CoreLibs\Combined\DateTime'; diff --git a/www/admin/class_test.db.dbReturn.php b/www/admin/class_test.db.dbReturn.php index 9d6827e5..686e394b 100644 --- a/www/admin/class_test.db.dbReturn.php +++ b/www/admin/class_test.db.dbReturn.php @@ -31,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, - 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'debug_all' => $DEBUG_ALL ?? true, + 'echo_all' => $ECHO_ALL, + 'print_all' => $PRINT_ALL ?? true, ]); // db connection and attach logger $db = new CoreLibs\DB\IO(DB_CONFIG, $log); diff --git a/www/admin/class_test.db.php b/www/admin/class_test.db.php index d6804873..3b459152 100644 --- a/www/admin/class_test.db.php +++ b/www/admin/class_test.db.php @@ -24,6 +24,7 @@ ob_end_flush(); use CoreLibs\Debug\Support as DgS; use CoreLibs\DB\IO as DbIo; use CoreLibs\Debug\Support; +use CoreLibs\Convert\SetVarType; $log = new CoreLibs\Debug\Logging([ 'log_folder' => BASE . LOG, @@ -31,9 +32,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, - 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'debug_all' => $DEBUG_ALL ?? true, + 'echo_all' => $ECHO_ALL, + 'print_all' => $PRINT_ALL ?? true, ]); // db connection and attach logger $db = new CoreLibs\DB\IO(DB_CONFIG, $log); @@ -131,7 +132,7 @@ $status = $db->dbExec("INSERT INTO test_foo (test, number_a) VALUES " print "DIRECT INSERT STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" . "DB OBJECT:
" . print_r($status, true) . "
| " - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | " . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "
"; @@ -152,7 +153,7 @@ $status = $db->dbExec($query); print "EOM STRING DIRECT INSERT STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" . "DB OBJECT:
" . print_r($status, true) . "
| " - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING EXT[test]: " . print_r($db->dbGetReturningExt('test'), true) . " | " . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "
"; @@ -164,12 +165,13 @@ var_dump($db->dbGetReturningExt()); $last_insert_pk = $db->dbGetInsertPK(); print "DIRECT INSERT PREVIOUS INSERTED: " . print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo " - . "WHERE test_foo_id = " . $last_insert_pk), true) . "
"; + . "WHERE test_foo_id = " . (int)$last_insert_pk), true) . "
"; +$__last_insert_pk = (int)$last_insert_pk; $q = <<dbReturnRow($q), true) . "
"; print "LAST ERROR: " . $db->dbGetLastError() . "
"; @@ -180,13 +182,13 @@ $db->dbPrepare("ins_test_foo", "INSERT INTO test_foo (test) VALUES ($1) RETURNIN $status = $db->dbExecute("ins_test_foo", ['BAR TEST ' . time()]); print "PREPARE INSERT[ins_test_foo] STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetPrepareCursorValue('ins_test_foo', 'query') . " |
" - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "
"; print "PREPARE INSERT PREVIOUS INSERTED: " . print_r($db->dbReturnRow("SELECT test_foo_id, test FROM test_foo " - . "WHERE test_foo_id = " . $db->dbGetInsertPK()), true) . "
"; + . "WHERE test_foo_id = " . (int)$db->dbGetInsertPK()), true) . "
"; print "PREPARE CURSOR RETURN:
"; foreach (['pk_name', 'count', 'query', 'returning_id'] as $key) { @@ -205,7 +207,7 @@ $db->dbPrepare("ins_test_foo_eom", $query); $status = $db->dbExecute("ins_test_foo_eom", ['EOM BAR TEST ' . time()]); print "EOM STRING PREPARE INSERT[ins_test_foo_eom] STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetPrepareCursorValue('ins_test_foo_eom', 'query') . " |
" - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING RETURN: " . print_r($db->dbGetReturningArray(), true) . "
"; @@ -255,21 +257,21 @@ print "EOM STRING DIRECT MULTIPLE INSERT WITH RETURN STATUS: " . Support::printT $status = $db->dbExec("INSERT INTO test_foo (test) VALUES ('FOO; TEST " . time() . "')"); print "DIRECT INSERT NO RETURN STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "
"; $last_insert_pk = $db->dbGetInsertPK(); // is_array read test -$q = "SELECT test_foo_id, test FROM test_foo WHERE test_foo_id = " . $last_insert_pk; +$q = "SELECT test_foo_id, test FROM test_foo WHERE test_foo_id = " . (int)$last_insert_pk; if (is_array($s_res = $db->dbReturnRow($q)) && !empty($s_res['test'])) { - print "WE HAVE DATA FOR: " . $last_insert_pk . " WITH: " . $s_res['test'] . "
"; + print "WE HAVE DATA FOR: " . Support::printToString($last_insert_pk) . " WITH: " . $s_res['test'] . "
"; } // UPDATE WITH RETURNING $status = $db->dbExec("UPDATE test_foo SET test = 'SOMETHING DIFFERENT' " - . "WHERE test_foo_id = " . $last_insert_pk . " RETURNING test"); -print "UPDATE WITH PK " . $last_insert_pk + . "WHERE test_foo_id = " . (int)$last_insert_pk . " RETURNING test"); +print "UPDATE WITH PK " . Support::printToString($last_insert_pk) . " RETURN STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " @@ -279,14 +281,14 @@ print "UPDATE WITH PK " . $last_insert_pk $status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITHOUT DATA', 456)"); print "INSERT WITH NO PRIMARY KEY NO RETURNING STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "
"; $status = $db->dbExec("INSERT INTO test_foobar (type, integer) VALUES ('WITH DATA', 123) RETURNING type, integer"); print "INSERT WITH NO PRIMARY KEY WITH RETURNING STATUS: " . Support::printToString($status) . " |
" . "QUERY: " . $db->dbGetQuery() . " |
" - . "PRIMARY KEY: " . $db->dbGetInsertPK() . " | " + . "PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . " | " . "RETURNING EXT: " . print_r($db->dbGetReturningExt(), true) . " | " . "RETURNING ARRAY: " . print_r($db->dbGetReturningArray(), true) . "
"; @@ -339,7 +341,7 @@ echo "
"; // NOTE: try to replacate connection still exists if script is run a second time // open pg bouncer connection -$db_pgb = new CoreLibs\DB\IO($DB_CONFIG['test_pgbouncer'], $log); +$db_pgb = new CoreLibs\DB\IO($DB_CONFIG['test_pgbouncer'] ?? [], $log); print "[PGB] DBINFO: " . $db_pgb->dbInfo() . "
"; if ($db->dbPrepare('pgb_sel_test_foo', $q_prep) === false) { print "[PGB] [1] Error in pgb_sel_test_foo prepare
"; @@ -356,7 +358,9 @@ $db_pgb->dbClose(); # db write class test $table = 'test_foo'; -print "TABLE META DATA: " . DgS::printAr($db->dbShowTableMetaData($table)) . "
"; +print "TABLE META DATA: " . DgS::printAr(SetVarType::setArray( + $db->dbShowTableMetaData($table) +)) . "
"; // insert first, then use primary key to update $primary_key = ''; # unset $db_write_table = ['test', 'string_a', 'number_a', 'some_bool']; @@ -379,7 +383,7 @@ $data = [ ]; $primary_key = $db->dbWriteDataExt( $db_write_table, - $primary_key, + (int)$primary_key, $table, $object_fields_not_touch, $object_fields_not_update, @@ -391,7 +395,7 @@ $data = [ ]; $primary_key = $db->dbWriteDataExt( $db_write_table, - $primary_key, + (int)$primary_key, $table, $object_fields_not_touch, $object_fields_not_update, @@ -403,7 +407,7 @@ $data = [ ]; $primary_key = $db->dbWriteDataExt( $db_write_table, - $primary_key, + (int)$primary_key, $table, $object_fields_not_touch, $object_fields_not_update, @@ -508,24 +512,24 @@ while (($ret = $db->dbCheckAsync()) === true) // search path check $q = "SHOW search_path"; $cursor = $db->dbExec($q); -$data = $db->dbFetchArray($cursor)['search_path']; +$data = $db->dbFetchArray($cursor)['search_path'] ?? ''; print "RETURN DATA FOR search_path: " . $data . "
"; // print "RETURN DATA FOR search_path: " . DgS::printAr($data) . "
"; // insert something into test.schema_test and see if we get the PK back $status = $db->dbExec( "INSERT INTO test.schema_test (contents, id) VALUES " - . "('TIME: " . time() . "', " . rand(1, 10) . ")" + . "('TIME: " . (string)time() . "', " . (string)rand(1, 10) . ")" ); print "OTHER SCHEMA INSERT STATUS: " . Support::printToString($status) . " | PK NAME: " . $db->dbGetInsertPKName() - . ", PRIMARY KEY: " . $db->dbGetInsertPK() . "
"; + . ", PRIMARY KEY: " . Support::printToString($db->dbGetInsertPK()) . "
"; print "NULL TEST DB READ
"; $q = "SELECT uid, null_varchar, null_int FROM test_null_data WHERE uid = 'A'"; $res = $db->dbReturnRow($q); var_dump($res); -print "RES: " . DgS::printAr($res) . "
"; +print "RES: " . DgS::printAr(SetVarType::setArray($res)) . "
"; print "ISSET: " . isset($res['null_varchar']) . "
"; print "EMPTY: " . empty($res['null_varchar']) . "
"; diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index c8b037e7..bc42378d 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -13,10 +13,6 @@ $PRINT_ALL = false; $ECHO_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file @@ -51,12 +47,22 @@ print ""; print ''; print '

' . $PAGE_NAME . '

'; -function test() +/** + * Undocumented function + * + * @return string|null + */ +function test(): ?string { return DebugSupport::getCallerMethod(1); } -function test2() +/** + * Undocumented function + * + * @return array + */ +function test2(): array { return DebugSupport::getCallerMethodList(1); } @@ -108,19 +114,28 @@ $new_log = new CoreLibs\Debug\Logging([ $new_log->debug('OPTIONS TYPE', 'New Type error'); print "OPTIONS LOGGER:
" . $new_log->printErrorMsg(); $new_log->setLogLevel('debug', 'on', ['A', 'B', 'C' => false]); -print "LOG LEVEL: " . DebugSupport::printAr($new_log->getLogLevel('debug', 'on')) . "
"; +print "LOG LEVEL: " . DebugSupport::printAr(\CoreLibs\Convert\SetVarType::setArray( + $new_log->getLogLevel('debug', 'on') +)) . "
"; echo "CLASS DEBUG CALL
"; // @codingStandardsIgnoreLine class TestL { + /** @var \CoreLibs\Debug\Logging */ public $log; public function __construct() { $this->log = new CoreLibs\Debug\Logging(); } - public function test(string $ts = null) + /** + * Undocumented function + * + * @param string|null $ts + * @return bool + */ + public function test(?string $ts = null): bool { print "* GETCALLERCLASS(INSIDE CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
"; $this->log->debug('TESTL', 'Logging in class testL' . ($ts !== null ? ': ' . $ts : '')); @@ -131,12 +146,18 @@ class TestL // @codingStandardsIgnoreLine class TestR extends TestL { + /** @var string */ public $foo; public function __construct() { parent::__construct(); } - public function subTest() + /** + * Undocumented function + * + * @return bool + */ + public function subTest(): bool { print "** GETCALLERCLASS(INSIDE EXTND CLASS): " . \CoreLibs\Debug\Support::getCallerClass() . "
"; $this->log->debug('TESTR', 'Logging in class testR (extends testL)'); @@ -160,12 +181,18 @@ print "CLASS EXTEND: PRINTERRORMSG:
" . $tr->log->printErrorMsg() . "
"; // @codingStandardsIgnoreLine class AttachOutside { + /** @var \CoreLibs\Debug\Logging */ public $log; - public function __construct(object $logger_class) + public function __construct(\CoreLibs\Debug\Logging $logger_class) { $this->log = $logger_class; } - public function test() + /** + * Undocumented function + * + * @return string + */ + public function test(): string { $this->log->debug('ATTACHOUTSIDE', 'A test'); return get_class($this); diff --git a/www/admin/class_test.email.php b/www/admin/class_test.email.php index 9652ffe7..6751ff91 100644 --- a/www/admin/class_test.email.php +++ b/www/admin/class_test.email.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: HTML/ELEMENTS'; diff --git a/www/admin/class_test.encoding.php b/www/admin/class_test.encoding.php index 5cb34e16..7bf1dcda 100644 --- a/www/admin/class_test.encoding.php +++ b/www/admin/class_test.encoding.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -35,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); // class type $_chk_enc = new CoreLibs\Check\Encoding(); @@ -102,7 +98,7 @@ foreach ($enc_strings as $_string) { // static use $_string = $enc_strings[1]; $string = $chk_enc::checkConvertEncoding($_string, 'UTF-8', 'ISO-2022-JP-MS'); -print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : $string) . "
"; +print "S::ENC CHECK: $_string: " . ($string === false ? '-OK-' : $log->prAr($string)) . "
"; // error message print $log->printErrorMsg(); diff --git a/www/admin/class_test.file.php b/www/admin/class_test.file.php index 4cb0b0a8..b360054f 100644 --- a/www/admin/class_test.file.php +++ b/www/admin/class_test.file.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: FILE'; diff --git a/www/admin/class_test.hash.php b/www/admin/class_test.hash.php index 5e26c130..2fd40a04 100644 --- a/www/admin/class_test.hash.php +++ b/www/admin/class_test.hash.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $hash_class = 'CoreLibs\Create\Hash'; diff --git a/www/admin/class_test.html.php b/www/admin/class_test.html.php index e009ce23..ad8da3c0 100644 --- a/www/admin/class_test.html.php +++ b/www/admin/class_test.html.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_html = new CoreLibs\Convert\Html(); $_elements = new CoreLibs\Output\Form\Elements(); diff --git a/www/admin/class_test.image.php b/www/admin/class_test.image.php index 170105c6..098b5d6f 100644 --- a/www/admin/class_test.image.php +++ b/www/admin/class_test.image.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_image = new CoreLibs\Output\Image(); $image_class = 'CoreLibs\Output\Image'; @@ -54,12 +50,15 @@ $thumb_width = 250; $thumb_height = 300; // class $image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture_square.jpg'; +// folders +$cache_folder = BASE . LAYOUT . CONTENT_PATH . CACHE . IMAGES; +$web_folder = LAYOUT . CACHE . IMAGES; // rotate image first $_image->correctImageOrientation($image); // thumbnail tests echo "
CLASS->CREATETHUMBNAILSIMPLE: " . basename($image) . ": WIDTH: $thumb_width
"; + . $_image->createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . ">"; // static $image = BASE . LAYOUT . CONTENT_PATH . IMAGES . 'no_picture.jpg'; // rotate image first @@ -67,7 +66,7 @@ $image_class::correctImageOrientation($image); // thumbnail tests echo "
S::CREATETHUMBNAILSIMPLE: " . basename($image) . ": WIDTH: $thumb_width
"; + . $image_class::createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . ">"; echo "U-STATIC VARIOUS:
"; // image thumbnail @@ -92,21 +91,29 @@ $images = array( $finfo = new finfo(FILEINFO_MIME_TYPE); foreach ($images as $image) { $image = BASE . LAYOUT . CONTENT_PATH . IMAGES . $image; - list ($height, $width, $img_type) = getimagesize($image); + list ($height, $width, $img_type) = \CoreLibs\Convert\SetVarType::setArray(getimagesize($image)); echo "
IMAGE INFO: " . $height . "x" . $width . ", TYPE: " - . $img_type . " [" . $finfo->file($image) . "]
"; + . $log->prAr($img_type) . " [" . $finfo->file($image) . "]"; // rotate image first Image::correctImageOrientation($image); // thumbnail tests echo "
" . basename($image) . ": WIDTH: $thumb_width
"; + . Image::createThumbnailSimple($image, $thumb_width, 0, $cache_folder, $web_folder) . ">"; echo "
" . basename($image) . ": HEIGHT: $thumb_height
"; + . Image::createThumbnailSimple($image, 0, $thumb_height, $cache_folder, $web_folder) . ">"; echo "
" . basename($image) . ": WIDTH/HEIGHT: $thumb_width x $thumb_height
"; + . Image::createThumbnailSimple($image, $thumb_width, $thumb_height, $cache_folder, $web_folder) . ">"; // test with dummy echo "
" . basename($image) . ": WIDTH/HEIGHT: $thumb_width x $thumb_height (+DUMMY)
"; + . Image::createThumbnailSimple( + $image, + $thumb_width, + $thumb_height, + $cache_folder, + $web_folder, + true, + false + ) . ">"; echo "
"; } diff --git a/www/admin/class_test.json.php b/www/admin/class_test.json.php index 10cb559a..c07e3228 100644 --- a/www/admin/class_test.json.php +++ b/www/admin/class_test.json.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $json_class = 'CoreLibs\Convert\Json'; diff --git a/www/admin/class_test.lang.php b/www/admin/class_test.lang.php index 3381d76b..8524c501 100644 --- a/www/admin/class_test.lang.php +++ b/www/admin/class_test.lang.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,30 +29,44 @@ print ''; print '

' . $PAGE_NAME . '

'; use CoreLibs\Language\L10n; +use CoreLibs\Language; use CoreLibs\Debug\Support; echo "
LIST LOCALES
"; $locale = 'en_US.UTF-8'; -$locales = CoreLibs\Language\L10n::listLocales($locale); +$locales = L10n::listLocales($locale); print "[" . $locale . "] LOCALES: " . Support::printAr($locales) . "
"; $locale = 'en.UTF-8'; -$locales = CoreLibs\Language\L10n::listLocales($locale); +$locales = L10n::listLocales($locale); print "[" . $locale . "] LOCALES: " . Support::printAr($locales) . "
"; -echo "
LOCALE INFO
"; +echo "
PARSE LOCAL
"; $locale = 'en_US.UTF-8'; -$locale_info = CoreLibs\Language\L10n::parseLocale($locale); +$locale_info = L10n::parseLocale($locale); print "[" . $locale . "] INFO: " . Support::printAr($locale_info) . "
"; $locale = 'en.UTF-8'; -$locale_info = CoreLibs\Language\L10n::parseLocale($locale); +$locale_info = L10n::parseLocale($locale); print "[" . $locale . "] INFO: " . Support::printAr($locale_info) . "
"; echo "
AUTO DETECT
"; -$get_locale = \CoreLibs\Language\GetLocale::setLocale(); -print "[AUTO]: " . Support::printAr($get_locale) . "
"; -$get_locale = \CoreLibs\Language\GetLocale::setLocale('en', 'foo', 'ISO-8895'); +// DEPRECATED +// $get_locale = Language\GetLocale::setLocale(); +// print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "
"; +$get_locale = Language\GetLocale::setLocale( + SITE_LOCALE, + str_replace('/', '', CONTENT_PATH), + null, + BASE . INCLUDES . LOCALE +); +print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "
"; +$get_locale = Language\GetLocale::setLocale( + 'en', + 'foo', + 'ISO-8895', + BASE . INCLUDES . LOCALE +); print "[OVERRIDE]: " . Support::printAr($get_locale) . "
"; // try to load non existing @@ -69,7 +79,7 @@ $domain = 'admin'; $encoding = 'UTF-8'; $path = BASE . INCLUDES . LOCALE; // load direct -$l = new CoreLibs\Language\L10n($lang, $domain, $path); +$l = new L10n($lang, $domain, $path); echo "*
"; echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; diff --git a/www/admin/class_test.login.php b/www/admin/class_test.login.php index 9dae22ac..89bed1b1 100644 --- a/www/admin/class_test.login.php +++ b/www/admin/class_test.login.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -32,13 +28,26 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $db = new CoreLibs\DB\IO(DB_CONFIG, $log); -$login = new CoreLibs\ACL\Login($db, $log, $session); +$login = new CoreLibs\ACL\Login( + $db, + $log, + $session, + [ + 'auto_login' => false, + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'logout_target' => LOGOUT_TARGET, + 'site_locale' => SITE_LOCALE, + 'site_domain' => SITE_DOMAIN, + 'locale_path' => BASE . INCLUDES . LOCALE, + ] +); ob_end_flush(); +$login->loginMainCall(); $PAGE_NAME = 'TEST CLASS: LOGIN'; print ""; @@ -53,7 +62,7 @@ echo "MIN ACCESS BASE: " . ($login->loginCheckAccessBase('admin') ? 'OK' : 'BAD' echo "MIN ACCESS PAGE: " . ($login->loginCheckAccessPage('admin') ? 'OK' : 'BAD') . "
"; echo "ACL: " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()) . "
"; -echo "ACL (MIN): " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()['min']) . "
"; +echo "ACL (MIN): " . \CoreLibs\Debug\Support::printAr($login->loginGetAcl()['min'] ?? []) . "
"; // error message print $log->printErrorMsg(); diff --git a/www/admin/class_test.math.php b/www/admin/class_test.math.php index b84c504c..2adb3a0a 100644 --- a/www/admin/class_test.math.php +++ b/www/admin/class_test.math.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_math = new CoreLibs\Convert\Math(); $math_class = 'CoreLibs\Convert\Math'; diff --git a/www/admin/class_test.memoryusage.php b/www/admin/class_test.memoryusage.php index f4971f76..2b77af97 100644 --- a/www/admin/class_test.memoryusage.php +++ b/www/admin/class_test.memoryusage.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: MEMORY USAGE'; diff --git a/www/admin/class_test.mime.php b/www/admin/class_test.mime.php index 4bd2598d..00e5e878 100644 --- a/www/admin/class_test.mime.php +++ b/www/admin/class_test.mime.php @@ -4,16 +4,12 @@ * @phan-file-suppress PhanTypeSuspiciousStringExpression */ - declare(strict_types=1); +declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_mime = new CoreLibs\Convert\MimeAppName(); diff --git a/www/admin/class_test.output.form.php b/www/admin/class_test.output.form.php index 14120714..0db332b7 100644 --- a/www/admin/class_test.output.form.php +++ b/www/admin/class_test.output.form.php @@ -11,10 +11,6 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file @@ -63,11 +59,28 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, - 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'debug_all' => $DEBUG_ALL, + 'echo_all' => $ECHO_ALL, + 'print_all' => $PRINT_ALL, ]); -$form = new CoreLibs\Output\Form\Generate(DB_CONFIG, $log, table_arrays: $table_arrays); +$locale = CoreLibs\Language\GetLocale::setLocale( + SITE_LOCALE, + SITE_DOMAIN, + SITE_ENCODING, + BASE . INCLUDES . LOCALE +); +$l10n = new CoreLibs\Language\L10n( + SITE_LOCALE, + SITE_DOMAIN, + BASE . INCLUDES . LOCALE +); +$form = new CoreLibs\Output\Form\Generate( + DB_CONFIG, + $log, + $l10n, + $locale, + table_arrays: $table_arrays +); $PAGE_NAME = 'TEST CLASS: FORM GENERATE'; print ""; diff --git a/www/admin/class_test.password.php b/www/admin/class_test.password.php index 891a9838..917ad288 100644 --- a/www/admin/class_test.password.php +++ b/www/admin/class_test.password.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_password = new CoreLibs\Check\Password(); $password_class = 'CoreLibs\Check\Password'; diff --git a/www/admin/class_test.php b/www/admin/class_test.php index c87e860b..3167b971 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -11,9 +11,6 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} ob_start(); @@ -33,19 +30,43 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $db = new CoreLibs\DB\IO(DB_CONFIG, $log); -$login = new CoreLibs\ACL\Login($db, $log, $session); -$locale = \CoreLibs\Language\GetLocale::setLocale(); +$locale = \CoreLibs\Language\GetLocale::setLocale( + SITE_LOCALE, + SITE_DOMAIN, + SITE_ENCODING, + BASE . INCLUDES . LOCALE +); $l10n = new \CoreLibs\Language\L10n( $locale['locale'], $locale['domain'], $locale['path'], ); -$backend = new CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale); +$login = new CoreLibs\ACL\Login( + $db, + $log, + $session, + [ + 'auto_login' => true, + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'logout_target' => LOGOUT_TARGET, + 'site_locale' => $locale['locale'], + 'site_domain' => $locale['domain'], + 'locale_path' => $locale['path'], + ] +); +$backend = new CoreLibs\Admin\Backend( + $db, + $log, + $session, + $l10n, + $locale, + DEFAULT_ACL_LEVEL +); $backend->db->dbInfo(true); ob_end_flush(); @@ -126,7 +147,9 @@ foreach (['on', 'off'] as $flag) { foreach (['debug', 'echo', 'print'] as $type) { $prefix = $flag == 'off' ? 'NOT ' : ''; print $prefix . strtoupper($type) . ' OUT: ' - . \CoreLibs\Debug\Support::printAr($backend->log->getLogLevel($type, $flag)) . '
'; + . \CoreLibs\Debug\Support::printAr(\CoreLibs\Convert\SetVarType::setArray( + $backend->log->getLogLevel($type, $flag) + )) . '
'; } } foreach (['debug', 'echo', 'print'] as $type) { diff --git a/www/admin/class_test.phpv.php b/www/admin/class_test.phpv.php index 79027cdd..218ed8dd 100644 --- a/www/admin/class_test.phpv.php +++ b/www/admin/class_test.phpv.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_phpv = new CoreLibs\Check\PhpVersion(); $phpv_class = 'CoreLibs\Check\PhpVersion'; @@ -71,6 +67,8 @@ print "S::MAX $max_version_ss: " . (string)$phpv_class::checkPHPVersion(null, $m // use stats print "U-S::MIN: $min_version: " . (string)PhpVersion::checkPHPVersion($min_version) . "
"; +print "PHP_VERSION_ID: " . PHP_VERSION_ID . "
"; + // error message print $log->printErrorMsg(); diff --git a/www/admin/class_test.randomkey.php b/www/admin/class_test.randomkey.php index ceec4542..4c8560c5 100644 --- a/www/admin/class_test.randomkey.php +++ b/www/admin/class_test.randomkey.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $array_class = 'CoreLibs\Create\RandomKey'; diff --git a/www/admin/class_test.readenvfile.php b/www/admin/class_test.readenvfile.php index c60ed033..408576b1 100644 --- a/www/admin/class_test.readenvfile.php +++ b/www/admin/class_test.readenvfile.php @@ -24,9 +24,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL ?? true, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL ?? true, ]); $ref_class = 'CoreLibs\Get\ReadEnvFile'; diff --git a/www/admin/class_test.runningtime.php b/www/admin/class_test.runningtime.php index 93472f03..ca821962 100644 --- a/www/admin/class_test.runningtime.php +++ b/www/admin/class_test.runningtime.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: RUNNING TIME'; diff --git a/www/admin/class_test.session.php b/www/admin/class_test.session.php index 95a16cf2..8e0836fe 100644 --- a/www/admin/class_test.session.php +++ b/www/admin/class_test.session.php @@ -2,14 +2,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; /** * Undocumented function @@ -53,9 +49,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); use CoreLibs\Create\Session; $session = new Session(); @@ -128,11 +124,11 @@ $session->unsetS('setwrap'); print "[READ WRAP] unset setwrap: " . $session->getS('setwrap') . "
"; print "[READ WRAP] unset Isset: " . ($session->issetS('setwrap') ? 'Yes' : 'No') . "
"; // test __get/__set -$session->setwrap = 'YES, magic set _SESSION var'; -print "[READ MAGIC] A setwrap: " . $session->setwrap . "
"; +$session->setwrap = 'YES, magic set _SESSION var'; /** @phpstan-ignore-line GET/SETTER */ +print "[READ MAGIC] A setwrap: " . ($session->setwrap ?? '') . "
"; print "[READ MAGIC] Isset: " . (isset($session->setwrap) ? 'Yes' : 'No') . "
"; unset($session->setwrap); -print "[READ MAGIC] unset setwrap: " . $session->setwrap . "
"; +print "[READ MAGIC] unset setwrap: " . ($session->setwrap ?? '') . "
"; print "[READ MAGIC] unset Isset: " . (isset($session->setwrap) ? 'Yes' : 'No') . "
"; // differnt session name diff --git a/www/admin/class_test.session.read.php b/www/admin/class_test.session.read.php index 7af08e61..adc7c323 100644 --- a/www/admin/class_test.session.read.php +++ b/www/admin/class_test.session.read.php @@ -2,14 +2,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; /** * Undocumented function @@ -53,9 +49,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); use CoreLibs\Create\Session; $session = new Session(); diff --git a/www/admin/class_test.smarty.php b/www/admin/class_test.smarty.php index 6a115d5b..b880b3ee 100644 --- a/www/admin/class_test.smarty.php +++ b/www/admin/class_test.smarty.php @@ -11,10 +11,6 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} - ob_start(); // basic class test file @@ -33,9 +29,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, - 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'debug_all' => $DEBUG_ALL, + 'echo_all' => $ECHO_ALL, + 'print_all' => $PRINT_ALL, ]); $locale = \CoreLibs\Language\GetLocale::setLocale(); $l10n = new \CoreLibs\Language\L10n( @@ -43,7 +39,12 @@ $l10n = new \CoreLibs\Language\L10n( $locale['domain'], $locale['path'], ); -$smarty = new CoreLibs\Template\SmartyExtend($l10n, $locale); +$smarty = new CoreLibs\Template\SmartyExtend( + $l10n, + $locale, + CACHE_ID, + COMPILE_ID, +); $PAGE_NAME = 'TEST CLASS: SMARTY'; print ""; @@ -59,7 +60,7 @@ $smarty->CSS_SPECIAL_TEMPLATE_NAME = 'smart_test.css'; $smarty->USE_PROTOTYPE = false; $smarty->USE_JQUERY = true; $smarty->JS_DATEPICKR = false; -if ($smarty->USE_PROTOTYPE) { +if ($smarty->USE_PROTOTYPE) { /** @phpstan-ignore-line for debug purpose */ $smarty->ADMIN_JAVASCRIPT = 'edit.pt.js'; $smarty->JS_SPECIAL_TEMPLATE_NAME = 'prototype.test.js'; } elseif ($smarty->USE_JQUERY) { @@ -67,7 +68,17 @@ if ($smarty->USE_PROTOTYPE) { $smarty->JS_SPECIAL_TEMPLATE_NAME = 'jquery.test.js'; } $smarty->PAGE_WIDTH = '100%'; -$smarty->setSmartyPaths(); +$smarty->setSmartyPaths( + BASE . INCLUDES, + BASE . INCLUDES . TEMPLATES . CONTENT_PATH, + LAYOUT . JS, + LAYOUT . CSS, + LAYOUT . FONT, + LAYOUT . IMAGES, + LAYOUT . CACHE, + ROOT . LAYOUT . CACHE, + null // master template name optional +); // smarty test $smarty->DATA['SMARTY_TEST'] = 'Test Data'; @@ -122,7 +133,18 @@ $smarty->DATA['checkbox_test_selected'] = ['1', '-1']; $smarty->DATA['checkbox_test_pos_selected'] = ['0', '-1']; -$smarty->setSmartyVarsAdmin(); +$smarty->setSmartyVarsAdmin( + BASE . TEMPLATES_C, + BASE . CACHE, + CSS, + FONT, + JS, + DEFAULT_ENCODING, + G_TITLE, + ADMIN_STYLESHEET, + ADMIN_JAVASCRIPT, + PAGE_WIDTH +); // error message print $log->printErrorMsg(); diff --git a/www/admin/class_test.strings.php b/www/admin/class_test.strings.php index ff3f6168..353c7131 100644 --- a/www/admin/class_test.strings.php +++ b/www/admin/class_test.strings.php @@ -2,14 +2,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -27,9 +23,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $byte_class = 'CoreLibs\Convert\Strings'; diff --git a/www/admin/class_test.system.php b/www/admin/class_test.system.php index c36687dc..362e6a11 100644 --- a/www/admin/class_test.system.php +++ b/www/admin/class_test.system.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -34,9 +30,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: SYSTEM'; diff --git a/www/admin/class_test.token.php b/www/admin/class_test.token.php index 577450be..d9aa1425 100644 --- a/www/admin/class_test.token.php +++ b/www/admin/class_test.token.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_token = new CoreLibs\Output\Form\Token(); $token_class = 'CoreLibs\Output\Form\Token'; diff --git a/www/admin/class_test.uids.php b/www/admin/class_test.uids.php index ce9db01b..c4ea25be 100644 --- a/www/admin/class_test.uids.php +++ b/www/admin/class_test.uids.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -31,9 +27,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $_uids = new CoreLibs\Create\Uids(); use CoreLibs\Create\Uids; diff --git a/www/admin/class_test.varistype.php b/www/admin/class_test.varistype.php index 2ae3ecd2..c492d059 100644 --- a/www/admin/class_test.varistype.php +++ b/www/admin/class_test.varistype.php @@ -6,14 +6,10 @@ declare(strict_types=1); -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; - -if ($DEBUG_ALL) { - error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); -} +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; ob_start(); @@ -35,9 +31,9 @@ $log = new CoreLibs\Debug\Logging([ // add file date 'print_file_date' => true, // set debug and print flags - 'debug_all' => $DEBUG_ALL ?? false, + 'debug_all' => $DEBUG_ALL, 'echo_all' => $ECHO_ALL ?? false, - 'print_all' => $PRINT_ALL ?? false, + 'print_all' => $PRINT_ALL, ]); $PAGE_NAME = 'TEST CLASS: CONVERT\VARISTYPE'; diff --git a/www/composer.json b/www/composer.json index ff8404ee..5c05400e 100644 --- a/www/composer.json +++ b/www/composer.json @@ -25,6 +25,7 @@ }, "require": { "egrajp/smarty-extended": "^4.3", - "php": ">=8.1" + "php": ">=8.1", + "gullevek/dotenv": "^2.0" } } diff --git a/www/composer.lock b/www/composer.lock index a947bd06..3af0eac2 100644 --- a/www/composer.lock +++ b/www/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5b803d9f077cbb1b28dcb383f5e89b0a", + "content-hash": "88bf0aa9b348a55a525b96fcaed7b5a9", "packages": [ { "name": "egrajp/smarty-extended", @@ -35,6 +35,60 @@ "templating" ], "time": "2023-02-17T14:14:10+09:00" + }, + { + "name": "gullevek/dotenv", + "version": "v2.0.8", + "source": { + "type": "git", + "url": "https://github.com/gullevek/dotEnv.git", + "reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e", + "reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "require-dev": { + "phan/phan": "^5.4", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9" + }, + "type": "library", + "autoload": { + "psr-4": { + "gullevek\\dotEnv\\": "src/", + "gullevek\\dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Clemens Schwaighofer", + "email": "gullevek@gullevek.org", + "homepage": "http://gullevek.org" + } + ], + "description": "Simple .env file processing and storing in _ENV array", + "homepage": "https://github.com/gullevek/dotEnv", + "keywords": [ + ".env", + "_ENV", + "dotenv", + "environment variables" + ], + "support": { + "issues": "https://github.com/gullevek/dotEnv/issues", + "source": "https://github.com/gullevek/dotEnv/tree/v2.0.8" + }, + "time": "2023-03-03T00:32:02+00:00" } ], "packages-dev": [ @@ -336,23 +390,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.24", + "version": "9.2.25", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" + "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e2b40518197a8c0d4b08bc34dfff1c99c508954", + "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -401,7 +455,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.25" }, "funding": [ { @@ -409,7 +463,7 @@ "type": "github" } ], - "time": "2023-01-26T08:26:55+00:00" + "time": "2023-02-25T05:32:00+00:00" }, { "name": "phpunit/php-file-iterator", @@ -654,16 +708,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.3", + "version": "9.6.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555" + "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555", - "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d", + "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d", "shasum": "" }, "require": { @@ -736,7 +790,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4" }, "funding": [ { @@ -752,7 +806,7 @@ "type": "tidelift" } ], - "time": "2023-02-04T13:37:15+00:00" + "time": "2023-02-27T13:06:37+00:00" }, { "name": "sebastian/cli-parser", @@ -1774,7 +1828,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.1" + }, "platform-dev": [], "plugin-api-version": "2.3.0" } diff --git a/www/configs/config.master.php b/www/configs/config.master.php index 355ab937..551dbb75 100644 --- a/www/configs/config.master.php +++ b/www/configs/config.master.php @@ -100,27 +100,6 @@ define('DEFAULT_ACL_LEVEL', 80); /************* LOGOUT ********************/ // logout target define('LOGOUT_TARGET', ''); -// password change allowed -define('PASSWORD_CHANGE', false); -define('PASSWORD_FORGOT', false); -// min/max password length -define('PASSWORD_MIN_LENGTH', 9); -define('PASSWORD_MAX_LENGTH', 255); -// defines allowed special characters -define('PASSWORD_SPECIAL_RANGE', '@$!%*?&'); -// password must have upper case, lower case, number, special -// comment out for not mandatory -define('PASSWORD_LOWER', '(?=.*[a-z])'); -define('PASSWORD_UPPER', '(?=.*[A-Z])'); -define('PASSWORD_NUMBER', '(?=.*\d)'); -define('PASSWORD_SPECIAL', "(?=.*[" . PASSWORD_SPECIAL_RANGE . "])"); -// define full regex -define('PASSWORD_REGEX', "/^" - . (defined('PASSWORD_LOWER') ? PASSWORD_LOWER : '') - . (defined('PASSWORD_UPPER') ? PASSWORD_UPPER : '') - . (defined('PASSWORD_NUMBER') ? PASSWORD_NUMBER : '') - . (defined('PASSWORD_SPECIAL') ? PASSWORD_SPECIAL : '') - . "[A-Za-z\d" . PASSWORD_SPECIAL_RANGE . "]{" . PASSWORD_MIN_LENGTH . "," . PASSWORD_MAX_LENGTH . "}$/"); /************* AJAX / ACCESS *************/ // ajax request type @@ -264,6 +243,7 @@ $GLOBALS['DB_CONFIG_SET'] = DB_CONFIG; define('TARGET', $SITE_CONFIG[HOST_NAME]['location'] ?? 'test'); define('DEBUG', $SITE_CONFIG[HOST_NAME]['debug_flag'] ?? false); define('SITE_LOCALE', $SITE_CONFIG[HOST_NAME]['site_locale'] ?? DEFAULT_LOCALE); +define('SITE_DOMAIN', str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH)); define('SITE_ENCODING', $SITE_CONFIG[HOST_NAME]['site_encoding'] ?? DEFAULT_ENCODING); define('LOGIN_ENABLED', $SITE_CONFIG[HOST_NAME]['login_enabled'] ?? false); define('AUTH', $SITE_CONFIG[HOST_NAME]['auth'] ?? false); diff --git a/www/configs/config.php b/www/configs/config.php index a1d8eb5b..93e07ea2 100644 --- a/www/configs/config.php +++ b/www/configs/config.php @@ -50,9 +50,22 @@ for ( is_file($__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php') ) { // load enviorment file if it exists - \CoreLibs\Get\DotEnv::readEnvFile( + \gullevek\dotEnv\DotEnv::readEnvFile( $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH ); + // find trigger name "admin/" or "frontend/" in the getcwd() folder + $folder = ''; + foreach (['admin', 'frontend'] as $_folder) { + if (strstr(getcwd() ?: '', DIRECTORY_SEPARATOR . $_folder)) { + $folder = $_folder; + break; + } + } + // if content path is empty, fallback is default + if (empty($folder)) { + $folder = 'default'; + } + define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR); // load master config file that loads all other config files require $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php'; break; @@ -62,18 +75,5 @@ for ( if (!defined('DIR')) { exit('Base config could not be loaded'); } -// find trigger name "admin/" or "frontend/" in the getcwd() folder -$folder = ''; -foreach (['admin', 'frontend'] as $_folder) { - if (strstr(getcwd() ?: '', DIRECTORY_SEPARATOR . $_folder)) { - $folder = $_folder; - break; - } -} -// if content path is empty, fallback is default -if (empty($folder)) { - $folder = 'default'; -} -define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR); // __END__ diff --git a/www/includes/edit_base.php b/www/includes/edit_base.php index 31f07e5c..56df68bb 100644 --- a/www/includes/edit_base.php +++ b/www/includes/edit_base.php @@ -61,6 +61,16 @@ ob_end_flush(); // init smarty and form class $edit_base = new CoreLibs\Admin\EditBase(DB_CONFIG, $log, $l10n, $locale); // creates edit pages and runs actions -$edit_base->editBaseRun(); +$edit_base->editBaseRun( + BASE . INCLUDES . TEMPLATES . CONTENT_PATH, + BASE . TEMPLATES_C, + BASE . CACHE, + ADMIN_STYLESHEET, + DEFAULT_ENCODING, + LAYOUT . CSS, + LAYOUT . JS, + ROOT, + CONTENT_PATH +); // __END__ diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php index 332692ea..b7e490e5 100644 --- a/www/lib/CoreLibs/ACL/Login.php +++ b/www/lib/CoreLibs/ACL/Login.php @@ -131,6 +131,31 @@ class Login // it will be set back to 255 /** @var int */ private $password_max_length = 255; + + /** @var int minum password length */ + public const PASSWORD_MIN_LENGTH = 9; + /** @var int maxium password lenght */ + public const PASSWORD_MAX_LENGTH = 255; + /** @var string special characters for regex */ + public const PASSWORD_SPECIAL_RANGE = '@$!%*?&'; + /** @var string regex for lower case alphabet */ + public const PASSWORD_LOWER = '(?=.*[a-z])'; + /** @var string regex for upper case alphabet */ + public const PASSWORD_UPPER = '(?=.*[A-Z])'; + /** @var string regex for numbers */ + public const PASSWORD_NUMBER = '(?=.*\d)'; + /** @var string regex for special chanagers */ + public const PASSWORD_SPECIAL = "(?=.*[" . self::PASSWORD_SPECIAL_RANGE . "])"; + /** @var string regex for fixed allowed characters password regex */ + public const PASSWORD_REGEX = "/^" + . self::PASSWORD_LOWER + . self::PASSWORD_UPPER + . self::PASSWORD_NUMBER + . self::PASSWORD_SPECIAL + . "[A-Za-z\d" . self::PASSWORD_SPECIAL_RANGE . "]" + . "{" . self::PASSWORD_MIN_LENGTH . "," . self::PASSWORD_MAX_LENGTH . "}" + . "$/"; + /** @var array can have several regexes, if nothing set, all is ok */ private $password_valid_chars = [ // '^(?=.*\d)(?=.*[A-Za-z])[0-9A-Za-z!@#$%]{8,}$', @@ -167,6 +192,12 @@ class Login /** @var bool */ private $login_is_ajax_page = false; + // settings + /** @var array options */ + private $options = []; + /** @var array locale options: locale, domain, encoding (opt), path */ + private $locale = []; + /** @var \CoreLibs\Debug\Logging logger */ public $log; /** @var \CoreLibs\DB\IO database */ @@ -183,15 +214,14 @@ class Login * @param \CoreLibs\DB\IO $db Database connection class * @param \CoreLibs\Debug\Logging $log Logging class * @param \CoreLibs\Create\Session $session Session interface class - * @param bool $auto_login [default true] Auto login flag, legacy - * If set to true will run login - * during construction + * @param array $options Login ACL settings + * $auto_login [default true] DEPRECATED, moved into options */ public function __construct( \CoreLibs\DB\IO $db, \CoreLibs\Debug\Logging $log, \CoreLibs\Create\Session $session, - bool $auto_login = true + array $options = [] ) { // attach db class $this->db = $db; @@ -202,6 +232,13 @@ class Login // attach session class $this->session = $session; + // set and check options + if (false === $this->loginSetOptions($options)) { + // on failure, exit + echo "Could not set options"; + $this->loginTerminate(4000); + } + // string key, msg: string, flag: e (error), o (ok) $this->login_error_msg = [ '0' => [ @@ -339,7 +376,7 @@ class Login $_SESSION['DEFAULT_ACL_LIST_TYPE'] = $this->default_acl_list_type; // this will be deprecated - if ($auto_login === true) { + if ($this->options['auto_login'] === true) { $this->loginMainCall(); } } @@ -384,6 +421,183 @@ class Login // **** PRIVATE INTERNAL // ************************************************************************* + /** + * Set options + * Current allowed + * target : site target + * debug + * auto_login : self start login process + * db_schema + * password_min_length + * default_acl_level + * logout_target : should default be '' or target path to where + * can_change : can change password (NOT IMPLEMENTED) + * forget_flow : reset password on forget (NOT IMPLEMENTED) + * locale_path : absolue path to the locale folder + * site_locale : what locale to load + * site_domain : what domain (locale file name) to use + * + * @param array $options Options array from class load + * @return bool True on ok, False on failure + */ + private function loginSetOptions(array $options): bool + { + // target and debug flag + if ( + empty($options['target']) + ) { + $options['target'] = 'test'; + } + if ( + empty($options['debug']) || + !is_bool($options['debug']) + ) { + $options['debug'] = false; + } + + // AUTO LOGIN + if ( + !isset($options['auto_login']) || + !is_bool($options['auto_login']) + ) { + // if set to true will run login call during class construction + $options['auto_login'] = false; + } + + // DB SCHEMA + if ( + empty($options['db_schema']) || + // TODO more strict check + is_string($options['db_schema']) + ) { + // get scham from db, else fallback to public + if (!empty($this->db->dbGetSchema(true))) { + $options['db_schema'] = $this->db->dbGetSchema(true); + } else { + $options['db_schema'] = 'public'; + } + } + if ($this->db->dbGetSchema() != $options['db_schema']) { + $this->db->dbSetSchema($options['db_schema']); + } + + // MIN PASSWORD LENGTH + // can only be in length of current defined min/max + if ( + !empty($options['password_min_lenght']) && + !is_numeric($options['password_min_length']) && + $options['password_min_length'] >= self::PASSWORD_MIN_LENGTH && + $options['password_min_length'] <= self::PASSWORD_MAX_LENGTH + ) { + if ( + false === $this->loginSetPasswordMinLength( + (int)$options['password_min_length'] + ) + ) { + $options['password_min_length'] = self::PASSWORD_MIN_LENGTH; + } + } + + // DEFAULT ACL LEVEL + if ( + !isset($options['default_acl_level']) || + !is_numeric($options['default_acl_level']) || + $options['default_acl_level'] < 0 || $options['default_acl_level'] > 100 + ) { + $options['default_acl_level'] = 0; + if (defined('DEFAULT_ACL_LEVEL')) { + trigger_error( + 'loginMainCall: DEFAULT_ACL_LEVEL should not be used', + E_USER_DEPRECATED + ); + $options['default_acl_level'] = DEFAULT_ACL_LEVEL; + } + } + $this->default_acl_level = (int)$options['default_acl_level']; + + // LOGOUT TARGET + if (!isset($options['logout_target'])) { + if (defined('LOGOUT_TARGET')) { + trigger_error( + 'loginMainCall: LOGOUT_TARGET should not be used', + E_USER_DEPRECATED + ); + $options['logout_target'] = LOGOUT_TARGET; + $this->logout_target = $options['logout_target']; + } + } + + // *** PASSWORD SETTINGS + // User can change password + if ( + !isset($options['can_change']) || + !is_bool($options['can_change']) + ) { + $options['can_change'] = false; + } + $this->password_change = $options['can_change']; + // User can trigger a forgot password flow + if ( + !isset($options['forgot_flow']) || + !is_bool($options['forgot_flow']) + ) { + $options['forgot_flow'] = false; + } + $this->password_forgot = $options['forgot_flow']; + + // *** LANGUAGE + // LANG: LOCALE PATH + if (empty($options['locale_path'])) { + // trigger deprecation error + trigger_error( + 'loginSetOptions: misssing locale_path entry is deprecated', + E_USER_DEPRECATED + ); + // set path + $options['locale_path'] = BASE . INCLUDES . LOCALE; + $_SESSION['LOCALE_PATH'] = $options['locale_path']; + } + // LANG: LOCALE + if (empty($options['site_locale'])) { + trigger_error( + 'loginMainCall: SITE_LOCALE or DEFAULT_LOCALE should not be used', + E_USER_DEPRECATED + ); + $options['site_locale'] = defined('SITE_LOCALE') && !empty(SITE_LOCALE) ? + SITE_LOCALE : 'en.UTF-8'; + } + // LANG: DOMAIN + if (empty($options['site_domain'])) { + // we need to get domain set from outside + $options['site_domain'] = 'admin'; + if ( + defined('SITE_DOMAIN') + ) { + // trigger deprecation error + trigger_error( + 'loginSetOptions: misssing site_domain entry is deprecated (SITE_DOMAIN)', + E_USER_DEPRECATED + ); + // set domain + $options['site_domain'] = SITE_DOMAIN; + $_SESSION['DEFAULT_DOMAIN'] = $options['site_domain']; + } elseif ( + defined('CONTENT_PATH') + ) { + // trigger deprecation error + trigger_error( + 'loginSetOptions: misssing site_domain entry is deprecated (CONTENT_PATH)', + E_USER_DEPRECATED + ); + $options['set_domain'] = str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH); + } + } + + // write array to options + $this->options = $options; + return true; + } + /** * Checks for all flags and sets error codes for each * In order: @@ -980,6 +1194,34 @@ class Login // $this->debug('ACL', $this->print_ar($this->acl)); } + /** + * set locale and load mo translator + * + * @return void + */ + private function loginSetLocale(): void + { + // ** LANGUAGE SET AFTER LOGIN ** + // set the locale + if ( + !empty($_SESSION['DEFAULT_LOCALE']) + ) { + $locale = $_SESSION['DEFAULT_LOCALE']; + } else { + $locale = $this->options['site_locale']; + } + $this->locale = [ + 'locale' => $locale, + 'domain' => $this->options['site_domain'], + 'path' => $this->options['locale_path'], + ]; + $this->l = new \CoreLibs\Language\L10n( + $this->locale['locale'], + $this->locale['domain'], + $this->locale['path'] + ); + } + /** * checks if the password is in a valid format * @@ -1513,50 +1755,9 @@ EOM; echo 'No active session found'; $this->loginTerminate(2000); } - - // if we have a search path we need to set it, to use the correct DB to login - // check what schema to use. if there is a login schema use this, else check - // if there is a schema set in the config, or fall back to DB_SCHEMA - // if this exists, if this also does not exists use public schema - /** @phpstan-ignore-next-line */ - if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) { - $SCHEMA = LOGIN_DB_SCHEMA; - } elseif (!empty($this->db->dbGetSchema(true))) { - $SCHEMA = $this->db->dbGetSchema(true); - } elseif (defined('PUBLIC_SCHEMA')) { - $SCHEMA = PUBLIC_SCHEMA; - } else { - $SCHEMA = 'public'; - } - // set schema if schema differs to schema set in db conneciton - if ($this->db->dbGetSchema() != $SCHEMA) { - $this->db->dbExec("SET search_path TO " . $SCHEMA); - } - // set internal page name $this->page_name = $this->loginReadPageName(); - // set default ACL Level - if (defined('DEFAULT_ACL_LEVEL')) { - $this->default_acl_level = DEFAULT_ACL_LEVEL; - } - - if (defined('PASSWORD_MIN_LENGTH')) { - $this->password_min_length = PASSWORD_MIN_LENGTH; - $this->password_min_length_max = PASSWORD_MIN_LENGTH; - } - if (defined('PASSWORD_MIN_LENGTH')) { - $this->password_max_length = PASSWORD_MAX_LENGTH; - } - - // pre-check that password min/max lengths are inbetween 1 and 255; - if ($this->password_max_length > 255) { - $this->password_max_length = 255; - } - if ($this->password_min_length < 1) { - $this->password_min_length = 1; - } - // set global is ajax page for if we show the data directly, // or need to pass it back // to the continue AJAX class for output back to the user @@ -1608,20 +1809,8 @@ EOM; $this->pw_old_password = $_POST['pw_old_password'] ?? ''; $this->pw_new_password = $_POST['pw_new_password'] ?? ''; $this->pw_new_password_confirm = $_POST['pw_new_password_confirm'] ?? ''; - // logout target (from config) - if (defined('LOGOUT_TARGET')) { - $this->logout_target = LOGOUT_TARGET; - } // disallow user list for password change $this->pw_change_deny_users = ['admin']; - // set flag if password change is okay - if (defined('PASSWORD_CHANGE')) { - $this->password_change = PASSWORD_CHANGE; - } - // NOTE: forgot password flow with email - if (defined('PASSWORD_FORGOT')) { - $this->password_forgot = PASSWORD_FORGOT; - } // max login counts before error reporting $this->max_login_error_count = 10; // users that never get locked, even if they are set strict @@ -1634,26 +1823,7 @@ EOM; // logsout user $this->loginLogoutUser(); // ** LANGUAGE SET AFTER LOGIN ** - // set the locale - if ( - $this->session->checkActiveSession() === true && - !empty($_SESSION['DEFAULT_LOCALE']) - ) { - $locale = $_SESSION['DEFAULT_LOCALE']; - } else { - $locale = (defined('SITE_LOCALE') && !empty(SITE_LOCALE)) ? - SITE_LOCALE : - /** @phpstan-ignore-next-line DEFAULT_LOCALE could be empty */ - ((defined('DEFAULT_LOCALE') && !empty(DEFAULT_LOCALE)) ? - DEFAULT_LOCALE : 'en.UTF-8'); - } - // set domain - if (defined('CONTENT_PATH')) { - $domain = str_replace('/', '', CONTENT_PATH); - } else { - $domain = 'admin'; - } - $this->l = new \CoreLibs\Language\L10n($locale, $domain); + $this->loginSetLocale(); // if the password change flag is okay, run the password change method if ($this->password_change) { $this->loginPasswordChange(); @@ -1669,18 +1839,21 @@ EOM; // if variable AJAX flag is not set, show output // else pass through for ajax work if ($this->login_is_ajax_page === false) { - // the login screen if we hav no login permission & login screen html data + // the login screen if we hav no login permission and + // login screen html data if ($this->login_html !== null) { // echo $this->login_html; $this->loginPrintLogin(); } // do not go anywhere, quit processing here // do something with possible debug data? - if (TARGET == 'live' || TARGET == 'remote') { + if ( + in_array($this->options['target'], ['live', 'remove']) + ) { // login - $this->log->setLogLevelAll('debug', DEBUG ? true : false); + $this->log->setLogLevelAll('debug', $this->options['debug']); $this->log->setLogLevelAll('echo', false); - $this->log->setLogLevelAll('print', DEBUG ? true : false); + $this->log->setLogLevelAll('print', $this->options['debug']); } $status_msg = $this->log->printErrorMsg(); // if ($this->echo_output_all) { @@ -1802,7 +1975,7 @@ EOM; if ( $length >= $this->password_min_length_max && $length <= $this->password_max_length && - $length <= 255 + $length <= self::PASSWORD_MAX_LENGTH ) { $this->password_min_length = $length; return true; diff --git a/www/lib/CoreLibs/Admin/Backend.php b/www/lib/CoreLibs/Admin/Backend.php index 97d2da80..3f03a463 100644 --- a/www/lib/CoreLibs/Admin/Backend.php +++ b/www/lib/CoreLibs/Admin/Backend.php @@ -128,7 +128,8 @@ class Backend \CoreLibs\Debug\Logging $log, \CoreLibs\Create\Session $session, \CoreLibs\Language\L10n $l10n, - array $locale + array $locale, + ?int $set_default_acl_level = null ) { // attach db class $this->db = $db; @@ -156,7 +157,14 @@ class Backend $this->$_action = $_POST[$_action] ?? ''; } - $this->default_acl = DEFAULT_ACL_LEVEL; + if ($set_default_acl_level === null) { + /** @deprecated Admin::__construct missing default_acl_level parameter */ + trigger_error( + 'Calling Admin::__construct without default_acl_level parameter is deprecated', + E_USER_DEPRECATED + ); + } + $this->default_acl = $set_default_acl_level ?? DEFAULT_ACL_LEVEL; // queue key if (preg_match("/^(add|save|delete|remove|move|up|down|push_live)$/", $this->action)) { @@ -190,35 +198,34 @@ class Backend * @param string $event any kind of event description, * @param string|array $data any kind of data related to that event * @param string $write_type write type can bei STRING or BINARY + * @param string|null $db_schema override target schema * @return void */ public function adbEditLog( string $event = '', string|array $data = '', - string $write_type = 'STRING' + string $write_type = 'STRING', + ?string $db_schema = null ): void { $data_binary = ''; + $data_write = ''; if ($write_type == 'BINARY') { $data_binary = $this->db->dbEscapeBytea((string)bzcompress(serialize($data))); - $data = 'see bzip compressed data_binary field'; + $data_write = 'see bzip compressed data_binary field'; } if ($write_type == 'STRING') { $data_binary = ''; - $data = $this->db->dbEscapeString(serialize($data)); + $data_write = $this->db->dbEscapeString(serialize($data)); } - // check schema - $SCHEMA = 'public'; - /** @phpstan-ignore-next-line */ - if (defined('LOGIN_DB_SCHEMA') && !empty(LOGIN_DB_SCHEMA)) { - $SCHEMA = LOGIN_DB_SCHEMA; - } elseif ($this->db->dbGetSchema()) { - $SCHEMA = $this->db->dbGetSchema(); - } elseif (defined('PUBLIC_SCHEMA')) { - $SCHEMA = PUBLIC_SCHEMA; + /** @var string $DB_SCHEMA check schema */ + $DB_SCHEMA = 'public'; + if ($db_schema !== null) { + $DB_SCHEMA = $db_schema; + } elseif (!empty($this->db->dbGetSchema())) { + $DB_SCHEMA = $this->db->dbGetSchema(); } - /** @phpstan-ignore-next-line for whatever reason $SCHEMA is seen as possible array */ - $q = "INSERT INTO " . $SCHEMA . ".edit_log " + $q = "INSERT INTO " . $DB_SCHEMA . ".edit_log " . "(euid, event_date, event, data, data_binary, page, " . "ip, user_agent, referer, script_name, query_string, server_name, http_host, " . "http_accept, http_accept_charset, http_accept_encoding, session_id, " @@ -229,10 +236,12 @@ class Backend 'NULL') . ", " . "NOW(), " - . "'" . $this->db->dbEscapeString((string)$event) . "', '" . $data . "', " - . "'" . $data_binary . "', '" . $this->db->dbEscapeString((string)$this->page_name) . "', " - . "'" . @$_SERVER["REMOTE_ADDR"] . "', " - . "'" . $this->db->dbEscapeString(@$_SERVER['HTTP_USER_AGENT']) . "', " + . "'" . $this->db->dbEscapeString((string)$event) . "', " + . "'" . $data_write . "', " + . "'" . $data_binary . "', " + . "'" . $this->db->dbEscapeString((string)$this->page_name) . "', " + . "'" . ($_SERVER["REMOTE_ADDR"] ?? '') . "', " + . "'" . $this->db->dbEscapeString($_SERVER['HTTP_USER_AGENT'] ?? '') . "', " . "'" . $this->db->dbEscapeString($_SERVER['HTTP_REFERER'] ?? '') . "', " . "'" . $this->db->dbEscapeString($_SERVER['SCRIPT_FILENAME'] ?? '') . "', " . "'" . $this->db->dbEscapeString($_SERVER['QUERY_STRING'] ?? '') . "', " @@ -282,11 +291,25 @@ class Backend /** * menu creater (from login menu session pages) * - * @param int $flag visible flag trigger + * @param string|null $set_content_path + * @param int $flag visible flag trigger * @return array menu array for output on page (smarty) */ - public function adbTopMenu(int $flag = 0): array - { + public function adbTopMenu( + ?string $set_content_path = null, + int $flag = 0, + ): array { + if ( + $set_content_path === null || + !is_string($set_content_path) + ) { + /** @deprecated adbTopMenu missing set_content_path parameter */ + trigger_error( + 'Calling adbTopMenu without set_content_path parameter is deprecated', + E_USER_DEPRECATED + ); + } + $set_content_path = $set_content_path ?? CONTENT_PATH; if ($this->menu_show_flag) { $flag = $this->menu_show_flag; } @@ -377,7 +400,7 @@ class Backend \CoreLibs\Get\System::getPageName() == $data['filename'] && (!isset($data['hostname']) || ( isset($data['hostname']) && - (!$data['hostname'] || strstr($data['hostname'], CONTENT_PATH) !== false) + (!$data['hostname'] || strstr($data['hostname'], $set_content_path) !== false) )) ) { $selected = 1; @@ -427,69 +450,6 @@ class Backend }; return $enabled; } - - /** - * creates out of a normal db_return array an assoc array - * - * @param array $db_array input array - * @param string|int|bool $key key - * @param string|int|bool $value value - * @return array associative array - * @deprecated \CoreLibs\Combined\ArrayHandler::genAssocArray() - */ - public function adbAssocArray(array $db_array, string|int|bool $key, string|int|bool $value): array - { - trigger_error( - 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Combined\ArrayHandler::genAssocArray', - E_USER_DEPRECATED - ); - return \CoreLibs\Combined\ArrayHandler::genAssocArray($db_array, $key, $value); - } - - /** - * converts bytes into formated string with KB, MB, etc - * - * @param string|int|float $number string or int or number - * @return string formatted string - * @deprecated \CoreLibs\Convert\Byte::humanReadableByteFormat() - */ - public function adbByteStringFormat(string|int|float $number): string - { - trigger_error( - 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Convert\Byte::humanReadableByteFormat()', - E_USER_DEPRECATED - ); - return \CoreLibs\Convert\Byte::humanReadableByteFormat($number); - } - - /** - * converts picture to a thumbnail with max x and max y size - * - * @param string $pic source image file with or without path - * @param int $size_x maximum size width - * @param int $size_y maximum size height - * @param string $dummy empty, or file_type to show an icon - * instead of nothing if file is not found - * @param string $path if source start is not ROOT path - * if empty ROOT is choosen - * @return string|bool thumbnail name, or false for error - * @deprecated \CoreLibs\Output\Image::createThumbnail() - */ - public function adbCreateThumbnail( - string $pic, - int $size_x, - int $size_y, - string $dummy = '', - string $path = '', - string $cache = '' - ): string|bool { - trigger_error( - 'Method ' . __METHOD__ . ' is deprecated: \CoreLibs\Output\Image::createThumbnail()', - E_USER_DEPRECATED - ); - return \CoreLibs\Output\Image::createThumbnail($pic, $size_x, $size_y, $dummy, $path, $cache); - } - /** * wrapper function to fill up the mssages array * @@ -523,15 +483,16 @@ class Backend /** * writes live queue * - * @param string $queue_key string to identfy the queue - * @param string $type [description] - * @param string $target [description] - * @param string $data [description] - * @param string $key_name [description] - * @param string $key_value [description] - * @param ?string $associate [description] - * @param ?string $file [description] - * @return void has no return + * @param string $queue_key string to identfy the queue + * @param string $type [description] + * @param string $target [description] + * @param string $data [description] + * @param string $key_name [description] + * @param string $key_value [description] + * @param string|null $associate [description] + * @param string|null $file [description] + * @param string|null $db_schema override target schema + * @return void */ public function adbLiveQueue( string $queue_key, @@ -541,19 +502,17 @@ class Backend string $key_name, string $key_value, string $associate = null, - string $file = null + string $file = null, + string $db_schema = null, ): void { - /** @phpstan-ignore-next-line */ - if (defined('GLOBAL_DB_SCHEMA') && !empty(GLOBAL_DB_SCHEMA)) { - $SCHEMA = GLOBAL_DB_SCHEMA; - } elseif ($this->db->dbGetSchema()) { - $SCHEMA = $this->db->dbGetSchema(); - } elseif (defined('PUBLIC_SCHEMA')) { - $SCHEMA = PUBLIC_SCHEMA; - } else { - $SCHEMA = 'public'; + /** @var string $DB_SCHEMA check schema */ + $DB_SCHEMA = 'public'; + if ($db_schema !== null) { + $DB_SCHEMA = $db_schema; + } elseif (!empty($this->db->dbGetSchema())) { + $DB_SCHEMA = $this->db->dbGetSchema(); } - $q = "INSERT INTO " . $SCHEMA . ".live_queue (" + $q = "INSERT INTO " . $DB_SCHEMA . ".live_queue (" . "queue_key, key_value, key_name, type, target, data, group_key, action, associate, file" . ") VALUES (" . "'" . $this->db->dbEscapeString($queue_key) . "', '" . $this->db->dbEscapeString($key_value) . "', " diff --git a/www/lib/CoreLibs/Admin/EditBase.php b/www/lib/CoreLibs/Admin/EditBase.php index 74760448..30f71c91 100644 --- a/www/lib/CoreLibs/Admin/EditBase.php +++ b/www/lib/CoreLibs/Admin/EditBase.php @@ -228,10 +228,14 @@ class EditBase /** * all edit pages * + * @param string $set_root + * @param string $set_content_path * @return void */ - private function editPageFlow(): void - { + private function editPageFlow( + string $set_root, + string $set_content_path, + ): void { // set table width $table_width = '100%'; // load call only if id is set @@ -334,7 +338,7 @@ class EditBase $menu_element['filename'] == \CoreLibs\Get\System::getPageName() && (!isset($menu_element['hostname']) || ( isset($menu_element['hostname']) && - (!$menu_element['hostname'] || strstr($menu_element['hostname'], CONTENT_PATH) !== false) + (!$menu_element['hostname'] || strstr($menu_element['hostname'], $set_content_path) !== false) )) ) { $position = $i; @@ -431,7 +435,7 @@ class EditBase $search_glob = []; foreach ($folders as $folder) { // make sure this folder actually exists - if (is_dir(ROOT . $folder)) { + if (is_dir($set_root . $folder)) { foreach ($files as $file) { $search_glob[] = $folder . $file; } @@ -534,31 +538,74 @@ class EditBase * @throws Exception * @throws SmartyException */ - public function editBaseRun(): void - { + public function editBaseRun( + ?string $template_dir = null, + ?string $compile_dir = null, + ?string $cache_dir = null, + ?string $set_admin_stylesheet = null, + ?string $set_default_encoding = null, + ?string $set_css = null, + ?string $set_js = null, + ?string $set_root = null, + ?string $set_content_path = null + ): void { + // trigger deprecated warning + if ( + $template_dir === null || + $compile_dir === null || + $cache_dir === null || + $set_admin_stylesheet === null || + $set_default_encoding === null || + $set_css === null || + $set_js === null || + $set_root === null || + $set_content_path === null + ) { + /** @deprecated editBaseRun call without parameters */ + trigger_error( + 'Calling editBaseRun without paramters is deprecated', + E_USER_DEPRECATED + ); + } + // set vars (to be deprecated) + $template_dir = $template_dir ?? BASE . INCLUDES . TEMPLATES . CONTENT_PATH; + $compile_dir = $compile_dir ?? BASE . TEMPLATES_C; + $cache_dir = $cache_dir ?? BASE . CACHE; + $set_admin_stylesheet = $set_admin_stylesheet ?? ADMIN_STYLESHEET; + $set_default_encoding = $set_default_encoding ?? DEFAULT_ENCODING; + $set_css = $set_css ?? LAYOUT . CSS; + $set_css = $set_js ?? LAYOUT . JS; + $set_root = $set_root ?? ROOT; + $set_content_path = $set_content_path ?? CONTENT_PATH; + // set the template dir - // WARNING: this has a special check for the mailing tool layout (old layout) - if (defined('LAYOUT')) { - $this->smarty->setTemplateDir(BASE . INCLUDES . TEMPLATES . CONTENT_PATH); - $this->DATA['css'] = LAYOUT . CSS; - $this->DATA['js'] = LAYOUT . JS; - } else { + // WARNING: this has a special check for the mailing tool layout (old no layout folder) + if (!defined('LAYOUT')) { + trigger_error( + 'EditBase with unset LAYOUT is deprecated', + E_USER_DEPRECATED + ); $this->smarty->setTemplateDir(TEMPLATES); $this->DATA['css'] = CSS; $this->DATA['js'] = JS; + } else { + $this->smarty->setTemplateDir($template_dir); + $this->DATA['css'] = $set_css; + $this->DATA['js'] = $set_js; } - $ADMIN_STYLESHEET = 'edit.css'; // define all needed smarty stuff for the general HTML/page building - $this->HEADER['CSS'] = CSS; - $this->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; - /** @phpstan-ignore-next-line because ADMIN_STYLESHEET can be null */ - $this->HEADER['STYLESHEET'] = $ADMIN_STYLESHEET ?? ADMIN_STYLESHEET; + $this->HEADER['CSS'] = $set_css; + $this->HEADER['DEFAULT_ENCODING'] = $set_default_encoding; + $this->HEADER['STYLESHEET'] = $set_admin_stylesheet; // main run if ($this->form->my_page_name == 'edit_order') { $this->editOrderPage(); } else { - $this->editPageFlow(); + $this->editPageFlow( + $set_root, + $set_content_path + ); } // debug data, if DEBUG flag is on, this data is print out @@ -571,11 +618,11 @@ class EditBase foreach ($CONTENT_DATA as $key => $value) { $this->smarty->assign($key, $value); } - if (is_dir(BASE . TEMPLATES_C)) { - $this->smarty->setCompileDir(BASE . TEMPLATES_C); + if (is_dir($compile_dir)) { + $this->smarty->setCompileDir($compile_dir); } - if (is_dir(BASE . CACHE)) { - $this->smarty->setCacheDir(BASE . CACHE); + if (is_dir($cache_dir)) { + $this->smarty->setCacheDir($cache_dir); } $this->smarty->display( $this->EDIT_TEMPLATE, diff --git a/www/lib/CoreLibs/Basic.php b/www/lib/CoreLibs/Basic.php index 27d0c3eb..a9a70c52 100644 --- a/www/lib/CoreLibs/Basic.php +++ b/www/lib/CoreLibs/Basic.php @@ -989,7 +989,7 @@ class Basic int $jpeg_quality = 80 ) { trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Output\Image::createThumbnailSimple()', E_USER_DEPRECATED); - return \CoreLibs\Output\Image::createThumbnailSimple($filename, $thumb_width, $thumb_height, $thumbnail_path, $create_dummy, $use_cache, $high_quality, $jpeg_quality); + return \CoreLibs\Output\Image::createThumbnailSimple($filename, $thumb_width, $thumb_height, $thumbnail_path, null, $create_dummy, $use_cache, $high_quality, $jpeg_quality); } /** diff --git a/www/lib/CoreLibs/Create/Hash.php b/www/lib/CoreLibs/Create/Hash.php index 1209b96a..beadac67 100644 --- a/www/lib/CoreLibs/Create/Hash.php +++ b/www/lib/CoreLibs/Create/Hash.php @@ -90,33 +90,6 @@ class Hash { return hash(self::STANDARD_HASH_LONG, $string); } - - /** - * create a unique id with the standard hash type defined in __hash - * - * @return string Unique ID with fixed length of 8 characters - * @deprecated Use \CoreLibs\Create\Uids::uniqIdShort() instead - */ - public static function __uniqId(): string - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, ' - . '\CoreLibs\Create\Uids::uniqIdShort() class', E_USER_DEPRECATED); - return \CoreLibs\Create\Uids::uniqIdShort(); - } - - /** - * create a unique id with the standard long hash type - * defined in __hashLong - * - * @return string Unique ID with length of current default long hash - * @deprecated Use \CoreLibs\Create\Uids::uniqIdLong() instead - */ - public static function __uniqIdLong(): string - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, ' - . '\CoreLibs\Create\Uids::uniqIdLong() class', E_USER_DEPRECATED); - return \CoreLibs\Create\Uids::uniqIdLong(); - } } // __END__ diff --git a/www/lib/CoreLibs/DB/Extended/ArrayIO.php b/www/lib/CoreLibs/DB/Extended/ArrayIO.php index f972e047..5abeac97 100644 --- a/www/lib/CoreLibs/DB/Extended/ArrayIO.php +++ b/www/lib/CoreLibs/DB/Extended/ArrayIO.php @@ -57,7 +57,7 @@ class ArrayIO extends \CoreLibs\DB\IO * @param array $db_config db connection config * @param array $table_array table array config * @param string $table_name table name string - * @param \CoreLibs\Debug\Logging|null $log Logging class, default set if not set + * @param \CoreLibs\Debug\Logging $log Logging class * @param int $base_acl_level Set base acl level, if needed * @param int $acl_admin Flag if this is an admin ACL access level */ @@ -65,12 +65,12 @@ class ArrayIO extends \CoreLibs\DB\IO array $db_config, array $table_array, string $table_name, - \CoreLibs\Debug\Logging $log = null, + \CoreLibs\Debug\Logging $log, int $base_acl_level = 0, int $acl_admin = 0 ) { // instance db_io class - parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging()); + 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['1021'] = 'No Primary Key given'; diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php index 6fc5b993..e593d227 100644 --- a/www/lib/CoreLibs/DB/IO.php +++ b/www/lib/CoreLibs/DB/IO.php @@ -378,16 +378,16 @@ class IO /** * main DB concstructor with auto connection to DB and failure set on failed connection * @param array $db_config DB configuration array - * @param \CoreLibs\Debug\Logging|null $log Logging class + * @param \CoreLibs\Debug\Logging $log Logging class * @param bool|null $db_debug_override Overrides debug settings in db_config */ public function __construct( array $db_config, - ?\CoreLibs\Debug\Logging $log = null, + \CoreLibs\Debug\Logging $log, ?bool $db_debug_override = null ) { // attach logger - $this->log = $log ?? new \CoreLibs\Debug\Logging(); + $this->log = $log; // sets the names (for connect/reconnect) $this->db_name = $db_config['db_name'] ?? ''; $this->db_user = $db_config['db_user'] ?? ''; @@ -3245,114 +3245,6 @@ class IO return $this->dbGetInsertPK(); } - /** - * returns the db init error - * if failed to connect it is set to true - * else false - * @return bool connection failure status - * @deprecated Use dbGetConnectionStatus() and True means correct connection - */ - public function getConnectionStatus(): bool - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, ' - . 'use dbGetConnectionStatus() with True for successful connection', E_USER_DEPRECATED); - // reverse because before it was reverse - return $this->dbGetConnectionStatus() ? false : true; - } - - /** - * Sets error number that was last - * So we always have the last error number stored even if a new one is created - * @return int last error number - * @deprecated Use dbGetLastError() - */ - public function getHadError(): int - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetLastError()', E_USER_DEPRECATED); - return (int)$this->dbGetLastError(); - } - - /** - * Sets warning number that was last - * So we always have the last warning number stored even if a new one is created - * @return int last error number - * @deprecated Use dbGetLastWarning() - */ - public function getHadWarning(): int - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetLastWarning()', E_USER_DEPRECATED); - return (int)$this->dbGetLastWarning(); - } - - /** - * old call for getInserReturnExt - * @param string|null $key See above - * @return array|string|int|bool|null See above - * @deprecated use getReturningExt($key = null) instead - */ - public function getInsertReturn(?string $key = null): array|string|int|bool|null - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use getReturningExt($key = null)', E_USER_DEPRECATED); - return $this->dbGetReturningExt($key); - } - - /** - * DEPRECATED: getReturning - * @return array|string|int|bool|null [DEPRECATED] - * @deprecated use dbGetReturning() instead - */ - public function getReturning(): array|string|int|bool|null - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetReturning()', E_USER_DEPRECATED); - return $this->dbGetInsertPK(); - } - - /** - * DEPRECATED: getInsertPK - * @return array|string|int|bool|null [DEPRECATED] - * @deprecated use dbGetInsertPK() instead - */ - public function getInsertPK(): array|string|int|bool|null - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetInsertPK()', E_USER_DEPRECATED); - return $this->dbGetInsertPK(); - } - - /** - * DEPRECATED: getReturningExt - * @param string|null $key [DEPRECATED] - * @return array|string|bool|int|null [DEPRECATED] - * @deprecated use dbGetReturningExt($key = null) instead - */ - public function getReturningExt(?string $key = null): array|string|int|bool|null - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetReturningExt($key = null)', E_USER_DEPRECATED); - return $this->dbGetReturningExt($key); - } - - /** - * DEPRECATED: getCursorExt - * @param string|null $q [DEPRECATED] - * @return array|string|int|\PgSql\Result|null [DEPRECATED] - * @deprecated use dbGetCursorExt($q = null) instead - */ - public function getCursorExt(?string $q = null): array|string|int|\PgSql\Result|null - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetCursorExt($q = null)', E_USER_DEPRECATED); - return $this->dbGetCursorExt($q); - } - - /** - * DEPRECATED: getNumRows - * @return int|null [DEPRECATED] - * @deprecated use dbGetNumRows() instead - */ - public function getNumRows(): ?int - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use dbGetNumRows()', E_USER_DEPRECATED); - return $this->dbGetNumRows(); - } - // end if db class } diff --git a/www/lib/CoreLibs/Debug/FileWriter.php b/www/lib/CoreLibs/Debug/FileWriter.php index 8ef07d58..27fe3e10 100644 --- a/www/lib/CoreLibs/Debug/FileWriter.php +++ b/www/lib/CoreLibs/Debug/FileWriter.php @@ -75,6 +75,11 @@ class FileWriter empty(self::$debug_folder) && defined('BASE') && defined('LOG') ) { + /** @deprecated Do not use this anymore, define path with fsetFolder */ + trigger_error( + 'fsetFolder must be set first. Setting via LOG_FILE_ID and LOg constants is deprecated', + E_USER_DEPRECATED + ); self::$debug_folder = BASE . LOG; } if (!is_writeable(self::$debug_folder)) { diff --git a/www/lib/CoreLibs/Debug/Logging.php b/www/lib/CoreLibs/Debug/Logging.php index d9ffb343..bae2136f 100644 --- a/www/lib/CoreLibs/Debug/Logging.php +++ b/www/lib/CoreLibs/Debug/Logging.php @@ -136,6 +136,11 @@ class Logging $this->log_folder = $this->options['log_folder'] ?? ''; // legacy flow, check must set constants if (empty($this->log_folder) && defined('BASE') && defined('LOG')) { + /** @deprecated Do not use this anymore, define path on class load */ + trigger_error( + 'options: log_folder must be set. Setting via BASE and LOG constants is deprecated', + E_USER_DEPRECATED + ); // make sure this is writeable, else skip $this->log_folder = BASE . LOG; } @@ -175,6 +180,11 @@ class Logging if (!empty($this->options['file_id'])) { $this->setLogId($this->options['file_id']); } elseif (!empty($GLOBALS['LOG_FILE_ID'])) { + /** @deprecated Do not use this anymore, define file_id on class load */ + trigger_error( + 'options: file_id must be set. Setting via LOG_FILE_ID global variable is deprecated', + E_USER_DEPRECATED + ); // legacy flow, should be removed and only set via options $this->setLogId($GLOBALS['LOG_FILE_ID']); // TODO trigger deprecation error @@ -183,6 +193,11 @@ class Logging // E_USER_DEPRECATED // ); } elseif (defined('LOG_FILE_ID')) { + /** @deprecated Do not use this anymore, define file_id on class load */ + trigger_error( + 'options: file_id must be set. Setting via LOG_FILE_ID constant is deprecated', + E_USER_DEPRECATED + ); // legacy flow, should be removed and only set via options $this->setLogId(LOG_FILE_ID); // trigger deprecation error diff --git a/www/lib/CoreLibs/Get/DotEnv.php b/www/lib/CoreLibs/Get/DotEnv.php index 73b3f2bf..de2dad5b 100644 --- a/www/lib/CoreLibs/Get/DotEnv.php +++ b/www/lib/CoreLibs/Get/DotEnv.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace CoreLibs\Get; +// NOTE: it is recommended to use gullvek\dotenv instead which is a copy of this + class DotEnv { /** @var string constant comment char, set to # */ @@ -29,11 +31,17 @@ class DotEnv * 1 for file loadable, no data or data already loaded * 2 for file not readable or open failed * 3 for file not found + * @deprecated Use composer package gullevek\dotenv instead -> \gullevek\dotenv\DotEnv::readEnvFile(...) */ public static function readEnvFile( string $path = __DIR__, string $env_file = '.env' ): int { + trigger_error( + '\CoreLibs\Get\DotEnv is deprecated in favor for ' + . 'composer package gullevek\dotenv which is a copy of this', + E_USER_DEPRECATED + ); // default -1; $status = -1; $env_file_target = $path . DIRECTORY_SEPARATOR . $env_file; diff --git a/www/lib/CoreLibs/Get/ReadEnvFile.php b/www/lib/CoreLibs/Get/ReadEnvFile.php deleted file mode 100644 index 77da76ce..00000000 --- a/www/lib/CoreLibs/Get/ReadEnvFile.php +++ /dev/null @@ -1,42 +0,0 @@ - Convert\MimeEncode::__mbMimeEncode - * Langauge\Encoding::checkConvertEncoding -> Check\Encoding::checkConvertEncoding - * Langauge\Encoding::setErrorChar -> Check\Encoding::setErrorChar - * Langauge\Encoding::getErrorChar -> Check\Encoding::getErrorChar - * Langauge\Encoding::convertEncoding -> Convert\Encoding::convertEncoding - */ - -declare(strict_types=1); - -namespace CoreLibs\Language; - -class Encoding -{ - /** - * wrapper function for mb mime convert - * for correct conversion with long strings - * - * @param string $string string to encode - * @param string $encoding target encoding - * @param string $line_break default line break is \r\n - * @return string encoded string - * @deprecated Use \CoreLibs\Convert\MimeEncode::__mbMimeEncode(); - */ - public static function __mbMimeEncode( - string $string, - string $encoding, - string $line_break = "\r\n" - ): string { - return \CoreLibs\Convert\MimeEncode::__mbMimeEncode($string, $encoding, $line_break); - } - - /** - * set error char - * - * @param string|int|null $string The character to use to represent - * error chars - * "long" for long, "none" for none - * or a valid code point in int - * like 0x2234 (8756, ∴) - * default character is ? (63) - * if null is set then "none" - * @return void - * @deprecated Use \CoreLibs\Check\Encoding::setErrorChar(); - */ - public static function setErrorChar(string|int|null $string): void - { - \CoreLibs\Check\Encoding::setErrorChar($string); - } - - /** - * get the current set error character - * - * @param bool $return_substitute_func if set to true return the set - * character from the php function - * directly - * @return string|int Set error character - * @deprecated Use \CoreLibs\Check\Encoding::getErrorChar(); - */ - public static function getErrorChar(bool $return_substitute_func = false): string|int - { - return \CoreLibs\Check\Encoding::getErrorChar($return_substitute_func); - } - - /** - * test if a string can be safely convert between encodings. - * mostly utf8 to shift jis - * the default compare has a possibility of failure, especially with windows - * it is recommended to the following in the script which uses this method: - * mb_substitute_character(0x2234); - * $class->mb_error_char = '∴'; - * if check to Shift JIS - * if check to ISO-2022-JP - * if check to ISO-2022-JP-MS - * set three dots (∴) as wrong character for correct convert error detect - * (this char is used, because it is one of the least used ones) - * - * @param string $string string to test - * @param string $from_encoding encoding of string to test - * @param string $to_encoding target encoding - * @return array|false false if no error or - * array with failed characters - * @deprecated Use \CoreLibs\Check\Encoding::checkConvertEncoding(); - */ - public static function checkConvertEncoding( - string $string, - string $from_encoding, - string $to_encoding - ): array|false { - return \CoreLibs\Check\Encoding::checkConvertEncoding($string, $from_encoding, $to_encoding); - } - - /** - * detects the source encoding of the string and if doesn't match - * to the given target encoding it convert is - * if source encoding is set and auto check is true (default) a second - * check is done so that the source string encoding actually matches - * will be skipped if source encoding detection is ascii - * - * @param string $string string to convert - * @param string $to_encoding target encoding - * @param string $source_encoding optional source encoding, will try to auto detect - * @param bool $auto_check default true, if source encoding is set - * check that the source is actually matching - * to what we sav the source is - * @return string encoding converted string - * @deprecated Use \CoreLibs\Convert\Encoding::convertEncoding(); - */ - public static function convertEncoding( - string $string, - string $to_encoding, - string $source_encoding = '', - bool $auto_check = true - ): string { - return \CoreLibs\Convert\Encoding::convertEncoding( - $string, - $to_encoding, - $source_encoding, - $auto_check - ); - } -} - -// __END__ diff --git a/www/lib/CoreLibs/Language/GetLocale.php b/www/lib/CoreLibs/Language/GetLocale.php index 11242508..f10dc4d3 100644 --- a/www/lib/CoreLibs/Language/GetLocale.php +++ b/www/lib/CoreLibs/Language/GetLocale.php @@ -14,6 +14,7 @@ class GetLocale /** * returns locale, lang, domain, encoding, path * from either parameter set or from sessions/config variables + * NOTE: named constant usage is deprecated and will be removed in future * * @param string|null $locale override auto detect * @param string|null $domain override domain @@ -36,6 +37,10 @@ class GetLocale // parse from session (logged in) $locale = $_SESSION['DEFAULT_LOCALE']; } else { + trigger_error( + 'setLocale: Unset $locale or unset SESSION locale is deprecated', + E_USER_DEPRECATED + ); // else parse from site locale $locale = defined('SITE_LOCALE') && !empty(SITE_LOCALE) ? SITE_LOCALE : @@ -50,8 +55,16 @@ class GetLocale empty($domain) || !preg_match("/^\w+$/", $domain) ) { - // if no domain is set, fall back to content path - $domain = str_replace('/', '', CONTENT_PATH); + if (!empty($_SESSION['DEFAULT_DOMAIN'])) { + $domain = $_SESSION['DEFAULT_DOMAIN']; + } else { + trigger_error( + 'setLocale: Unset $domain is deprecated', + E_USER_DEPRECATED + ); + // if no domain is set, fall back to content path + $domain = str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH); + } } // check that override encoding matches locale encoding // if locale encoding is set @@ -71,6 +84,10 @@ class GetLocale // else set from session $encoding = $_SESSION['DEFAULT_CHARSET']; } else { + trigger_error( + 'setLocale: Short $locale with unset $encoding or unset SESSION encoding is deprecated', + E_USER_DEPRECATED + ); // else set from site encoding $encoding = defined('SITE_ENCODING') && !empty(SITE_ENCODING) ? SITE_ENCODING : @@ -85,7 +102,15 @@ class GetLocale empty($path) || !is_dir($path) ) { - $path = BASE . INCLUDES . LOCALE; + if (!empty($_SESSION['LOCALE_PATH'])) { + $path = $_SESSION['LOCALE_PATH']; + } else { + trigger_error( + 'setLocale: Unset $path is deprecated', + E_USER_DEPRECATED + ); + $path = BASE . INCLUDES . LOCALE; + } } // extract lang & country from locale string, else set to en if ( diff --git a/www/lib/CoreLibs/Language/L10n.php b/www/lib/CoreLibs/Language/L10n.php index 9419ae10..09c2cae5 100644 --- a/www/lib/CoreLibs/Language/L10n.php +++ b/www/lib/CoreLibs/Language/L10n.php @@ -82,10 +82,23 @@ class L10n string $path = '' ) { // auto load language only if at least locale and domain is set - if (!empty($locale) && !empty($domain)) { + // New: path must be set too, or we fall through + if (!empty($locale) && !empty($domain) && empty($path)) { + /** @deprecated if locale and domain are set, path must be set too */ + trigger_error( + 'Empty path parameter is no longer allowed if locale and domain are set', + E_USER_DEPRECATED + ); + } + if (!empty($locale) && !empty($domain) && !empty($path)) { // check hack if domain and path is switched // Note this can be removed in future versions if (strstr($domain, DIRECTORY_SEPARATOR) !== false) { + /** @deprecated domain must be 2nd and path must be third parameter */ + trigger_error( + 'L10n constructor parameter switch is no longer supported. domain is 2nd, path is 3rd parameter', + E_USER_DEPRECATED + ); $_domain = $path; $path = $domain; $domain = $_domain; @@ -122,9 +135,9 @@ class L10n /** * loads the mo file base on path, locale and domain set * - * @param string $locale language name (optional), fallback is en - * @param string $domain override CONTENT_PATH . $encoding name for mo file - * @param string $path path, if empty fallback on default internal path + * @param string $locale language name, if not set, try previous set + * @param string $domain set name for mo file, if not set, try previous set + * @param string $path path, if not set try to get from paths array, else self * @return GetTextReader the main gettext reader object */ public function getTranslator( @@ -160,6 +173,11 @@ class L10n } elseif ( defined('BASE') && defined('INCLUDES') && defined('LOCALE') ) { + /** @deprecated Do not use this anymore, define path on class load */ + trigger_error( + 'parameter $path must be set. Setting via BASE, INCLUDES and LOCALE constants is deprecated', + E_USER_DEPRECATED + ); // set fallback base path if constant set $this->base_locale_path = BASE . INCLUDES . LOCALE; } else { @@ -240,6 +258,25 @@ class L10n return $this->l10n; } + /** + * Get the local as array same to the GetLocale::setLocale return + * This does not set from outside, but only what is set in the l10n class + * + * @return array{locale: string, lang: string|null, domain: string, encoding: string|null, path: string} + */ + public function getLocaleAsArray(): array + { + $locale = L10n::parseLocale($this->getLocale()); + return [ + 'locale' => $this->getLocale(), + 'lang' => $locale['lang'] + . (!empty($locale['country']) ? '_' . $locale['country'] : ''), + 'domain' => $this->getDomain(), + 'encoding' => $locale['charset'], + 'path' => $this->getBaseLocalePath(), + ]; + } + /** * parse the locale string for further processing * diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index cfbe8ee2..9c33aa1d 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -305,37 +305,28 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO /** * construct form generator * - * @param array $db_config db config array, mandatory - * @param \CoreLibs\Debug\Logging|null $log Logging class, null auto set - * @param \CoreLibs\Language\L10n|null $l10n l10n language class, null auto set - * @param array|null $locale locale array from ::setLocale, - * null auto set - * @param array|null $table_arrays Override table array data - * instead of try to load from - * include file - * @throws \Exception 1: No table_arrays set/no class found for my page name + * @param array $db_config db config array, mandatory + * @param \CoreLibs\Debug\Logging $log Logging class + * @param \CoreLibs\Language\L10n $l10n l10n language class + * @param array $locale locale array from ::setLocale + * @param array|null $table_arrays Override table array data + * instead of try to load from + * include file + * @throws \Exception 1: No table_arrays set/no class found for my page name */ public function __construct( array $db_config, - ?\CoreLibs\Debug\Logging $log = null, - ?\CoreLibs\Language\L10n $l10n = null, - ?array $locale = null, + \CoreLibs\Debug\Logging $log, + \CoreLibs\Language\L10n $l10n, + array $locale, ?array $table_arrays = null, ) { // init logger if not set - $this->log = $log ?? new \CoreLibs\Debug\Logging(); + $this->log = $log; // don't log per class $this->log->setLogPer('class', false); - // if pass on locale is null - if ($locale === null) { - $locale = \CoreLibs\Language\GetLocale::setLocale(); - } // init the language class - $this->l = $l10n ?? new \CoreLibs\Language\L10n( - $locale['locale'], - $locale['domain'], - $locale['path'], - ); + $this->l = $l10n; // legacy lang vars set $this->encoding = $locale['encoding']; $this->lang = $locale['lang']; diff --git a/www/lib/CoreLibs/Output/Image.php b/www/lib/CoreLibs/Output/Image.php index 20d2a56f..664f3a96 100644 --- a/www/lib/CoreLibs/Output/Image.php +++ b/www/lib/CoreLibs/Output/Image.php @@ -12,6 +12,7 @@ class Image { /** * converts picture to a thumbnail with max x and max y size + * TOOD: needs mandatory options for ImageMagic convert, paths, etc folders * * @param string $pic source image file with or without path * @param int $size_x maximum size width @@ -158,25 +159,27 @@ class Image * if both are set, those are the max sizes (aspect ration is always ekpt) * - if path is not given will cache folder for current path set * - * @param string $filename source file name with full path - * @param int $thumb_width thumbnail width - * @param int $thumb_height thumbnail height - * @param string|null $thumbnail_path altnerative path for thumbnails - * @param bool $create_dummy if we encounter an invalid file - * create a dummy image file and return it - * @param bool $use_cache default to true, set to false to skip - * creating new image if exists - * @param bool $high_quality default to true, uses sample version, - * set to false to not use (default true) - * to use quick but less nice version - * @param int $jpeg_quality default 80, set image quality for jpeg only - * @return string|false thumbnail with path + * @param string $filename source file name with full path + * @param int $thumb_width thumbnail width + * @param int $thumb_height thumbnail height + * @param string|null $cache_folder path for thumbnail cache + * @param string|null $web_folder frontend path for output + * @param bool $create_dummy if we encounter an invalid file + * create a dummy image file and return it + * @param bool $use_cache default to true, set to false to skip + * creating new image if exists + * @param bool $high_quality default to true, uses sample version, + * set to false to not use (default true) + * to use quick but less nice version + * @param int $jpeg_quality default 80, set image quality for jpeg only + * @return string|false thumbnail with path */ public static function createThumbnailSimple( string $filename, int $thumb_width = 0, int $thumb_height = 0, - ?string $thumbnail_path = null, + ?string $cache_folder = null, // will be not null in future + ?string $web_folder = null, bool $create_dummy = true, bool $use_cache = true, bool $high_quality = true, @@ -185,233 +188,246 @@ class Image $thumbnail = false; // $this->debug('IMAGE PREPARE', "FILE: $filename (exists " // .(string)file_exists($filename)."), WIDTH: $thumb_width, HEIGHT: $thumb_height"); + if ( + $cache_folder === null || + $web_folder === null + ) { + /** @deprecated Do use cache folder and web folder parameters */ + trigger_error( + 'params $cache_folder and $web_folder must be set. Setting via constants is deprecated', + E_USER_DEPRECATED + ); + // NOTE: we need to depracte this + $cache_folder = BASE . LAYOUT . CONTENT_PATH . CACHE . IMAGES; + $web_folder = LAYOUT . CACHE . IMAGES; + if (!is_dir($cache_folder)) { + if (false === mkdir($cache_folder)) { + $cache_folder = BASE . LAYOUT . CONTENT_PATH . CACHE; + $web_folder = LAYOUT . CACHE; + } + } + } // check that input image exists and is either jpeg or png // also fail if the basic CACHE folder does not exist at all if ( - file_exists($filename) && - is_dir(BASE . LAYOUT . CONTENT_PATH . CACHE) && - is_writable(BASE . LAYOUT . CONTENT_PATH . CACHE) + !file_exists($filename) || + !is_dir($cache_folder) || + !is_writable($cache_folder) ) { - // $this->debug('IMAGE PREPARE', "FILENAME OK, THUMB WIDTH/HEIGHT OK"); - [$inc_width, $inc_height, $img_type] = getimagesize($filename) ?: []; - $thumbnail_write_path = null; - $thumbnail_web_path = null; - // path set first - if ( - $img_type == IMAGETYPE_JPEG || - $img_type == IMAGETYPE_PNG || - $create_dummy === true - ) { - // $this->debug('IMAGE PREPARE', "IMAGE TYPE OK: ".$inc_width.'x'.$inc_height); - // set thumbnail paths - $thumbnail_write_path = BASE . LAYOUT . CONTENT_PATH . CACHE . IMAGES; - $thumbnail_web_path = LAYOUT . CACHE . IMAGES; - // if images folder in cache does not exist create it, if failed, fall back to base cache folder - if (!is_dir($thumbnail_write_path)) { - if (false === mkdir($thumbnail_write_path)) { - $thumbnail_write_path = BASE . LAYOUT . CONTENT_PATH . CACHE; - $thumbnail_web_path = LAYOUT . CACHE; - } - } + return $thumbnail; + } + // $this->debug('IMAGE PREPARE', "FILENAME OK, THUMB WIDTH/HEIGHT OK"); + [$inc_width, $inc_height, $img_type] = getimagesize($filename) ?: []; + $thumbnail_write_path = null; + $thumbnail_web_path = null; + // path set first + if ( + $img_type == IMAGETYPE_JPEG || + $img_type == IMAGETYPE_PNG || + $create_dummy === true + ) { + // $this->debug('IMAGE PREPARE', "IMAGE TYPE OK: ".$inc_width.'x'.$inc_height); + // set thumbnail paths + $thumbnail_write_path = $cache_folder; + $thumbnail_web_path = $web_folder; + } + // do resize or fall back on dummy run + if ( + $img_type == IMAGETYPE_JPEG || + $img_type == IMAGETYPE_PNG + ) { + // if missing width or height in thumb, use the set one + if ($thumb_width == 0) { + $thumb_width = $inc_width; } - // do resize or fall back on dummy run - if ( - $img_type == IMAGETYPE_JPEG || - $img_type == IMAGETYPE_PNG - ) { - // if missing width or height in thumb, use the set one - if ($thumb_width == 0) { - $thumb_width = $inc_width; - } - if ($thumb_height == 0) { - $thumb_height = $inc_height; - } - // check resize parameters - if ($inc_width > $thumb_width || $inc_height > $thumb_height) { - $thumb_width_r = 0; - $thumb_height_r = 0; - // we need to keep the aspect ration on longest side - if ( - ($inc_height > $inc_width && - // and the height is bigger than thumb set - $inc_height > $thumb_height) || - // or the height is smaller or equal width - // but the width for the thumb is equal to the image height - ($inc_height <= $inc_width && - $inc_width == $thumb_width - ) - ) { - // $this->debug('IMAGE PREPARE', 'HEIGHT > WIDTH'); - $ratio = $inc_height / $thumb_height; - $thumb_width_r = (int)ceil($inc_width / $ratio); - $thumb_height_r = $thumb_height; - } else { - // $this->debug('IMAGE PREPARE', 'WIDTH > HEIGHT'); - $ratio = $inc_width / $thumb_width; - $thumb_width_r = $thumb_width; - $thumb_height_r = (int)ceil($inc_height / $ratio); - } - // $this->debug('IMAGE PREPARE', "Ratio: $ratio, Target size $thumb_width_r x $thumb_height_r"); - // set output thumbnail name - $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' - . $thumb_width_r . 'x' . $thumb_height_r; - if ( - $use_cache === false || - !file_exists($thumbnail_write_path . $thumbnail) - ) { - // image, copy source image, offset in image, source x/y, new size, source image size - $thumb = imagecreatetruecolor($thumb_width_r, $thumb_height_r); - if ($thumb === false) { - return false; - } - if ($img_type == IMAGETYPE_PNG) { - $imagecolorallocatealpha = imagecolorallocatealpha($thumb, 0, 0, 0, 127); - if ($imagecolorallocatealpha === false) { - return false; - } - // preservere transaprency - imagecolortransparent( - $thumb, - $imagecolorallocatealpha - ); - imagealphablending($thumb, false); - imagesavealpha($thumb, true); - } - $source = null; - switch ($img_type) { - case IMAGETYPE_JPEG: - $source = imagecreatefromjpeg($filename); - break; - case IMAGETYPE_PNG: - $source = imagecreatefrompng($filename); - break; - } - // check that we have a source image resource - if ($source !== null && $source !== false) { - // resize no shift - if ($high_quality === true) { - imagecopyresized( - $thumb, - $source, - 0, - 0, - 0, - 0, - $thumb_width_r, - $thumb_height_r, - $inc_width, - $inc_height - ); - } else { - imagecopyresampled( - $thumb, - $source, - 0, - 0, - 0, - 0, - $thumb_width_r, - $thumb_height_r, - $inc_width, - $inc_height - ); - } - // write file - switch ($img_type) { - case IMAGETYPE_JPEG: - imagejpeg($thumb, $thumbnail_write_path . $thumbnail, $jpeg_quality); - break; - case IMAGETYPE_PNG: - imagepng($thumb, $thumbnail_write_path . $thumbnail); - break; - } - // free up resources (in case we are called in a loop) - imagedestroy($source); - imagedestroy($thumb); - } else { - $thumbnail = false; - } - } + if ($thumb_height == 0) { + $thumb_height = $inc_height; + } + // check resize parameters + if ($inc_width > $thumb_width || $inc_height > $thumb_height) { + $thumb_width_r = 0; + $thumb_height_r = 0; + // we need to keep the aspect ration on longest side + if ( + ($inc_height > $inc_width && + // and the height is bigger than thumb set + $inc_height > $thumb_height) || + // or the height is smaller or equal width + // but the width for the thumb is equal to the image height + ($inc_height <= $inc_width && + $inc_width == $thumb_width + ) + ) { + // $this->debug('IMAGE PREPARE', 'HEIGHT > WIDTH'); + $ratio = $inc_height / $thumb_height; + $thumb_width_r = (int)ceil($inc_width / $ratio); + $thumb_height_r = $thumb_height; } else { - // we just copy over the image as is, we never upscale - $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' . $inc_width . 'x' . $inc_height; - if ( - $use_cache === false || - !file_exists($thumbnail_write_path . $thumbnail) - ) { - copy($filename, $thumbnail_write_path . $thumbnail); - } + // $this->debug('IMAGE PREPARE', 'WIDTH > HEIGHT'); + $ratio = $inc_width / $thumb_width; + $thumb_width_r = $thumb_width; + $thumb_height_r = (int)ceil($inc_height / $ratio); } - // add output path - if ($thumbnail !== false) { - $thumbnail = $thumbnail_web_path . $thumbnail; - } - } elseif ($create_dummy === true) { - // create dummy image in the thumbnail size - // if one side is missing, use the other side to create a square - if (!$thumb_width) { - $thumb_width = $thumb_height; - } - if (!$thumb_height) { - $thumb_height = $thumb_width; - } - // do we have an image already? - $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' . $thumb_width . 'x' . $thumb_height; + // $this->debug('IMAGE PREPARE', "Ratio: $ratio, Target size $thumb_width_r x $thumb_height_r"); + // set output thumbnail name + $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' + . $thumb_width_r . 'x' . $thumb_height_r; if ( $use_cache === false || !file_exists($thumbnail_write_path . $thumbnail) ) { - // if both are unset, set to 250 - if ($thumb_height == 0) { - $thumb_height = 250; - } - if ($thumb_width == 0) { - $thumb_width = 250; - } - $thumb = imagecreatetruecolor($thumb_width, $thumb_height); + // image, copy source image, offset in image, source x/y, new size, source image size + $thumb = imagecreatetruecolor($thumb_width_r, $thumb_height_r); if ($thumb === false) { return false; } - // add outside border px = 5% (rounded up) - // eg 50px -> 2.5px - $gray = imagecolorallocate($thumb, 200, 200, 200); - $white = imagecolorallocate($thumb, 255, 255, 255); - if ($gray === false || $white === false) { - return false; + if ($img_type == IMAGETYPE_PNG) { + $imagecolorallocatealpha = imagecolorallocatealpha($thumb, 0, 0, 0, 127); + if ($imagecolorallocatealpha === false) { + return false; + } + // preservere transaprency + imagecolortransparent( + $thumb, + $imagecolorallocatealpha + ); + imagealphablending($thumb, false); + imagesavealpha($thumb, true); } - // fill gray background - imagefill($thumb, 0, 0, $gray); - // now create rectangle - if (imagesx($thumb) < imagesy($thumb)) { - $width = (int)round(imagesx($thumb) / 100 * 5); + $source = null; + switch ($img_type) { + case IMAGETYPE_JPEG: + $source = imagecreatefromjpeg($filename); + break; + case IMAGETYPE_PNG: + $source = imagecreatefrompng($filename); + break; + } + // check that we have a source image resource + if ($source !== null && $source !== false) { + // resize no shift + if ($high_quality === true) { + imagecopyresized( + $thumb, + $source, + 0, + 0, + 0, + 0, + $thumb_width_r, + $thumb_height_r, + $inc_width, + $inc_height + ); + } else { + imagecopyresampled( + $thumb, + $source, + 0, + 0, + 0, + 0, + $thumb_width_r, + $thumb_height_r, + $inc_width, + $inc_height + ); + } + // write file + switch ($img_type) { + case IMAGETYPE_JPEG: + imagejpeg($thumb, $thumbnail_write_path . $thumbnail, $jpeg_quality); + break; + case IMAGETYPE_PNG: + imagepng($thumb, $thumbnail_write_path . $thumbnail); + break; + } + // free up resources (in case we are called in a loop) + imagedestroy($source); + imagedestroy($thumb); } else { - $width = (int)round(imagesy($thumb) / 100 * 5); + $thumbnail = false; } - imagefilledrectangle( - $thumb, - 0 + $width, - 0 + $width, - imagesx($thumb) - $width, - imagesy($thumb) - $width, - $white - ); - // add "No valid images source" - // OR add circle - // * find center - // * width/height is 75% of size - border - // smaller size is taken - $base_width = imagesx($thumb) > imagesy($thumb) ? imagesy($thumb) : imagesx($thumb); - // get 75% width - $cross_width = (int)round((($base_width - ($width * 2)) / 100 * 75) / 2); - $center_x = (int)round(imagesx($thumb) / 2); - $center_y = (int)round(imagesy($thumb) / 2); - imagefilledellipse($thumb, $center_x, $center_y, $cross_width, $cross_width, $gray); - // find top left and bottom left for first line - imagepng($thumb, $thumbnail_write_path . $thumbnail); } - // add web path + } else { + // we just copy over the image as is, we never upscale + $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' . $inc_width . 'x' . $inc_height; + if ( + $use_cache === false || + !file_exists($thumbnail_write_path . $thumbnail) + ) { + copy($filename, $thumbnail_write_path . $thumbnail); + } + } + // add output path + if ($thumbnail !== false) { $thumbnail = $thumbnail_web_path . $thumbnail; } + } elseif ($create_dummy === true) { + // create dummy image in the thumbnail size + // if one side is missing, use the other side to create a square + if (!$thumb_width) { + $thumb_width = $thumb_height; + } + if (!$thumb_height) { + $thumb_height = $thumb_width; + } + // do we have an image already? + $thumbnail = 'thumb-' . pathinfo($filename)['filename'] . '-' . $thumb_width . 'x' . $thumb_height; + if ( + $use_cache === false || + !file_exists($thumbnail_write_path . $thumbnail) + ) { + // if both are unset, set to 250 + if ($thumb_height == 0) { + $thumb_height = 250; + } + if ($thumb_width == 0) { + $thumb_width = 250; + } + $thumb = imagecreatetruecolor($thumb_width, $thumb_height); + if ($thumb === false) { + return false; + } + // add outside border px = 5% (rounded up) + // eg 50px -> 2.5px + $gray = imagecolorallocate($thumb, 200, 200, 200); + $white = imagecolorallocate($thumb, 255, 255, 255); + if ($gray === false || $white === false) { + return false; + } + // fill gray background + imagefill($thumb, 0, 0, $gray); + // now create rectangle + if (imagesx($thumb) < imagesy($thumb)) { + $width = (int)round(imagesx($thumb) / 100 * 5); + } else { + $width = (int)round(imagesy($thumb) / 100 * 5); + } + imagefilledrectangle( + $thumb, + 0 + $width, + 0 + $width, + imagesx($thumb) - $width, + imagesy($thumb) - $width, + $white + ); + // add "No valid images source" + // OR add circle + // * find center + // * width/height is 75% of size - border + // smaller size is taken + $base_width = imagesx($thumb) > imagesy($thumb) ? imagesy($thumb) : imagesx($thumb); + // get 75% width + $cross_width = (int)round((($base_width - ($width * 2)) / 100 * 75) / 2); + $center_x = (int)round(imagesx($thumb) / 2); + $center_y = (int)round(imagesy($thumb) / 2); + imagefilledellipse($thumb, $center_x, $center_y, $cross_width, $cross_width, $gray); + // find top left and bottom left for first line + imagepng($thumb, $thumbnail_write_path . $thumbnail); + } + // add web path + $thumbnail = $thumbnail_web_path . $thumbnail; } // either return false or the thumbnail name + output path web return $thumbnail; diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php index ffbd0280..6e87d9e3 100644 --- a/www/lib/CoreLibs/Template/SmartyExtend.php +++ b/www/lib/CoreLibs/Template/SmartyExtend.php @@ -161,9 +161,31 @@ class SmartyExtend extends \Smarty * * @param \CoreLibs\Language\L10n $l10n l10n language class * @param array $locale locale data read from setLocale + * @param string|null $cache_id + * @param string|null $compile_id */ - public function __construct(\CoreLibs\Language\L10n $l10n, array $locale) - { + public function __construct( + \CoreLibs\Language\L10n $l10n, + array $locale, + ?string $cache_id = null, + ?string $compile_id = null + ) { + // trigger deprecation + if ( + $cache_id === null || + $compile_id === null + ) { + /** @deprecated SmartyExtend::__construct call without parameters */ + trigger_error( + 'Calling SmartyExtend::__construct without paramters is deprecated', + E_USER_DEPRECATED + ); + } + // set variables (to be deprecated) + $cache_id = $cache_id ?? + (defined('CACHE_ID') ? CACHE_ID : ''); + $compile_id = $compile_id ?? + (defined('COMPILE_ID') ? COMPILE_ID : ''); // call basic smarty // or Smarty::__construct(); parent::__construct(); @@ -191,8 +213,8 @@ class SmartyExtend extends \Smarty $this->page_name = \CoreLibs\Get\System::getPageName(); // set internal settings - $this->CACHE_ID = defined('CACHE_ID') ? CACHE_ID : ''; - $this->COMPILE_ID = defined('COMPILE_ID') ? COMPILE_ID : ''; + $this->CACHE_ID = $cache_id; + $this->COMPILE_ID = $compile_id; } /** @@ -256,11 +278,70 @@ class SmartyExtend extends \Smarty * * @return void */ - public function setSmartyPaths(): void - { + + /** + * sets all internal paths and names that need to be passed on + * to the smarty template + * + * @param string|null $set_includes INCLUDES + * @param string|null $set_template_path TEMPLATE_PATH + * @param string|null $set_javascript JAVASCRIPT + * @param string|null $set_css CSS + * @param string|null $set_font FONT + * @param string|null $set_pictures PICTURES + * @param string|null $set_cache_pictures CACHE_PICTURES + * @param string|null $set_cache_pictures_root CACHE_PICTURES_ROOT + * @param string|null $set_master_template_name MASTAER_TEMPLATE_NAME + * @return void + */ + public function setSmartyPaths( + ?string $set_includes = null, + ?string $set_template_path = null, + ?string $set_javascript = null, + ?string $set_css = null, + ?string $set_font = null, + ?string $set_pictures = null, + ?string $set_cache_pictures = null, + ?string $set_cache_pictures_root = null, + ?string $set_master_template_name = null, + ): void { + // trigger deprecation + if ( + $set_includes === null || + $set_template_path === null || + $set_javascript === null || + $set_css === null || + $set_font === null || + $set_pictures === null || + $set_cache_pictures === null || + $set_cache_pictures_root === null + ) { + /** @deprecated setSmartyPaths call without parameters */ + trigger_error( + 'Calling setSmartyPaths without paramters is deprecated', + E_USER_DEPRECATED + ); + } + // set variables (to be deprecated) + $set_master_template_name = $set_master_template_name ?? + (defined('MASTER_TEMPLATE_NAME') ? MASTER_TEMPLATE_NAME : ''); + $set_includes = $set_includes ?? + BASE . INCLUDES; + $set_template_path = $set_template_path ?? + BASE . INCLUDES . TEMPLATES . CONTENT_PATH; + $set_javascript = $set_javascript ?? LAYOUT . JS; + $set_css = $set_css ?? LAYOUT . CSS; + $set_font = $set_font ?? LAYOUT . FONT; + $set_pictures = $set_pictures ?? LAYOUT . IMAGES; + $set_cache_pictures = $set_cache_pictures ?? LAYOUT . CACHE; + $set_cache_pictures_root = $set_cache_pictures_root ?? + ROOT . $set_cache_pictures; + // master template - if (empty($this->MASTER_TEMPLATE_NAME)) { - $this->MASTER_TEMPLATE_NAME = MASTER_TEMPLATE_NAME; + if ( + empty($this->MASTER_TEMPLATE_NAME) + ) { + $this->MASTER_TEMPLATE_NAME = $set_master_template_name; } // set include & template names @@ -276,15 +357,15 @@ class SmartyExtend extends \Smarty $this->CSS_TEMPLATE_NAME = str_replace('.tpl', '.css', $this->CONTENT_INCLUDE); // set basic template path (tmp) - $this->INCLUDES = BASE . INCLUDES; // no longer in templates, only global - $this->TEMPLATE_PATH = BASE . INCLUDES . TEMPLATES . CONTENT_PATH; + $this->INCLUDES = $set_includes; // no longer in templates, only global + $this->TEMPLATE_PATH = $set_template_path; $this->setTemplateDir($this->TEMPLATE_PATH); - $this->JAVASCRIPT = LAYOUT . JS; - $this->CSS = LAYOUT . CSS; - $this->FONT = LAYOUT . FONT; - $this->PICTURES = LAYOUT . IMAGES; - $this->CACHE_PICTURES = LAYOUT . CACHE; - $this->CACHE_PICTURES_ROOT = ROOT . $this->CACHE_PICTURES; + $this->JAVASCRIPT = $set_javascript; + $this->CSS = $set_css; + $this->FONT = $set_font; + $this->PICTURES = $set_pictures; + $this->CACHE_PICTURES = $set_cache_pictures; + $this->CACHE_PICTURES_ROOT = $set_cache_pictures_root; // check if we have an external file with the template name if ( file_exists($this->INCLUDES . $this->INC_TEMPLATE_NAME) && @@ -305,7 +386,7 @@ class SmartyExtend extends \Smarty // set all the additional CSS/JS parths $this->setSmartCoreIncludeCssJs(); // check if template names exist - if (!$this->MASTER_TEMPLATE_NAME) { + if (empty($this->MASTER_TEMPLATE_NAME)) { exit('MASTER TEMPLATE is not set'); } elseif (!file_exists($this->getTemplateDir()[0] . DIRECTORY_SEPARATOR . $this->MASTER_TEMPLATE_NAME)) { // abort if master template could not be found @@ -374,33 +455,191 @@ class SmartyExtend extends \Smarty * wrapper call for setSmartyVars * this is for frontend type and will not set any only admin needed variables * + * @param string|null $compile_dir BASE . TEMPLATES_C + * @param string|null $cache_dir BASE . CACHE + * @param string|null $set_js JS + * @param string|null $set_css CSS + * @param string|null $set_font FONT + * @param string|null $set_default_encoding DEFAULT_ENCODING + * @param string|null $set_g_title G_TITLE + * @param string|null $set_stylesheet STYLESHEET + * @param string|null $set_javascript JAVASCRIPT + * @param \CoreLibs\Admin\Backend|null $cms Optinal Admin Backend for + * smarty variables merge * @return void */ - public function setSmartyVarsFrontend(): void - { - $this->setSmartyVars(); + public function setSmartyVarsFrontend( + ?string $compile_dir = null, + ?string $cache_dir = null, + ?string $set_js = null, + ?string $set_css = null, + ?string $set_font = null, + ?string $set_default_encoding = null, + ?string $set_g_title = null, + ?string $set_stylesheet = null, + ?string $set_javascript = null, + ?\CoreLibs\Admin\Backend $cms = null + ): void { + $this->setSmartyVars( + false, + $cms, + $compile_dir, + $cache_dir, + $set_js, + $set_css, + $set_font, + $set_default_encoding, + $set_g_title, + null, + null, + null, + $set_stylesheet, + $set_javascript + ); } /** * wrapper call for setSmartyVars * this is only for admin interface and will set additional variables + * @param string|null $compile_dir BASE . TEMPLATES_C + * @param string|null $cache_dir BASE . CACHE + * @param string|null $set_js JS + * @param string|null $set_css CSS + * @param string|null $set_font FONT + * @param string|null $set_default_encoding DEFAULT_ENCODING + * @param string|null $set_g_title G_TITLE + * @param string|null $set_admin_stylesheet ADMIN_STYLESHEET + * @param string|null $set_admin_javascript ADMIN_JAVASCRIPT + * @param string|null $set_page_width PAGE_WIDTH + * @param \CoreLibs\Admin\Backend|null $cms Optinal Admin Backend for + * smarty variables merge + * @return void */ - public function setSmartyVarsAdmin(): void - { - $this->setSmartyVars(true); + public function setSmartyVarsAdmin( + ?string $compile_dir = null, + ?string $cache_dir = null, + ?string $set_js = null, + ?string $set_css = null, + ?string $set_font = null, + ?string $set_default_encoding = null, + ?string $set_g_title = null, + ?string $set_admin_stylesheet = null, + ?string $set_admin_javascript = null, + ?string $set_page_width = null, + ?\CoreLibs\Admin\Backend $cms = null + ): void { + $this->setSmartyVars( + true, + $cms, + $compile_dir, + $cache_dir, + $set_js, + $set_css, + $set_font, + $set_g_title, + $set_default_encoding, + $set_admin_stylesheet, + $set_admin_javascript, + $set_page_width, + null, + null + ); } /** - * set smarty pass on variables, sub template names and finally calls the smarty parser + * set smarty pass on variables, sub template names and + * finally calls the smarty parser * - * @param boolean $admin_call default false, will set admin only variables + * @param bool $admin_call default false + * will set admin only variables + * @param \CoreLibs\Admin\Backend|null $cms Optinal Admin Backend for + * smarty variables merge + * @param string|null $compile_dir BASE . TEMPLATES_C + * @param string|null $cache_dir BASE . CACHE + * @param string|null $set_js JS + * @param string|null $set_css CSS + * @param string|null $set_font FONT + * @param string|null $set_default_encoding DEFAULT_ENCODING + * @param string|null $set_g_title G_TITLE + * @param string|null $set_admin_stylesheet ADMIN_STYLESHEET + * @param string|null $set_admin_javascript ADMIN_JAVASCRIPT + * @param string|null $set_page_width PAGE_WIDTH + * @param string|null $set_stylesheet STYLESHEET + * @param string|null $set_javascript JAVASCRIPT * @return void */ - private function setSmartyVars($admin_call = false): void - { - /** @var \CoreLibs\Admin\Backend This is an assumption */ - global $cms; - if (is_object($cms)) { + private function setSmartyVars( + bool $admin_call, + ?\CoreLibs\Admin\Backend $cms = null, + ?string $compile_dir = null, + ?string $cache_dir = null, + ?string $set_js = null, + ?string $set_css = null, + ?string $set_font = null, + ?string $set_default_encoding = null, + ?string $set_g_title = null, + ?string $set_admin_stylesheet = null, + ?string $set_admin_javascript = null, + ?string $set_page_width = null, + ?string $set_stylesheet = null, + ?string $set_javascript = null + ): void { + // trigger deprecation + if ( + $compile_dir === null || + $cache_dir === null || + $set_css === null || + $set_font === null || + $set_js === null || + $set_default_encoding === null || + $set_g_title === null || + ( + $admin_call === true && ( + $set_admin_stylesheet === null || + $set_admin_javascript === null || + $set_page_width === null + ) + ) || + ( + $admin_call === false && ( + $set_stylesheet === null || + $set_javascript === null + ) + ) + ) { + /** @deprecated setSmartyVars call without parameters */ + trigger_error( + 'Calling setSmartyVars without paramters is deprecated', + E_USER_DEPRECATED + ); + } + // set variables (will be deprecated) + $compile_dir = $compile_dir ?? BASE . TEMPLATES_C; + $cache_dir = $cache_dir ?? BASE . CACHE; + $set_css = $set_css ?? CSS; + $set_font = $set_font ?? FONT; + $set_js = $set_js ?? JS; + $set_default_encoding = $set_default_encoding ?? DEFAULT_ENCODING; + $set_g_title = $set_g_title ?? G_TITLE; + $set_admin_stylesheet = $set_admin_stylesheet ?? ADMIN_STYLESHEET; + $set_admin_javascript = $set_admin_javascript ?? ADMIN_JAVASCRIPT; + $set_page_width = $set_page_width ?? PAGE_WIDTH; + $set_stylesheet = $set_stylesheet ?? STYLESHEET; + $set_javascript = $set_javascript ?? JAVASCRIPT; + // depreacte call globals cms on null 4mcs + if ( + $cms === null && + isset($GLOBALS['cms']) + ) { + /** @deprecated setSmartyVars globals cms is deprecated */ + trigger_error( + 'Calling setSmartyVars without cms parameter when needed is deprecated', + E_USER_DEPRECATED + ); + } + // this is ugly + $cms = $cms ?? $GLOBALS['cms'] ?? null; + if ($cms instanceof \CoreLibs\Admin\Backend) { $this->mergeCmsSmartyVars($cms); } @@ -431,11 +670,11 @@ class SmartyExtend extends \Smarty // default CMS settings // define all needed smarty stuff for the general HTML/page building - $this->HEADER['CSS'] = CSS; - $this->HEADER['FONT'] = FONT; - $this->HEADER['JS'] = JS; + $this->HEADER['CSS'] = $set_css; + $this->HEADER['FONT'] = $set_font; + $this->HEADER['JS'] = $set_js; $this->HEADER['ENCODING'] = $this->encoding; - $this->HEADER['DEFAULT_ENCODING'] = DEFAULT_ENCODING; + $this->HEADER['DEFAULT_ENCODING'] = $set_default_encoding; // form name $this->DATA['FORM_NAME'] = !$this->FORM_NAME ? @@ -445,7 +684,7 @@ class SmartyExtend extends \Smarty // special for admin if ($admin_call === true) { // set ACL extra show - if (is_object($cms)) { + if ($cms instanceof \CoreLibs\Admin\Backend) { $this->DATA['show_ea_extra'] = $cms->acl['show_ea_extra'] ?? false; $this->DATA['ADMIN'] = $cms->acl['admin'] ?? 0; // top menu @@ -461,11 +700,13 @@ class SmartyExtend extends \Smarty $this->DATA['messages'] = []; } // set style sheets - $this->HEADER['STYLESHEET'] = $this->ADMIN_STYLESHEET ? $this->ADMIN_STYLESHEET : ADMIN_STYLESHEET; - $this->HEADER['JAVASCRIPT'] = $this->ADMIN_JAVASCRIPT ? $this->ADMIN_JAVASCRIPT : ADMIN_JAVASCRIPT; + $this->HEADER['STYLESHEET'] = !empty($this->ADMIN_STYLESHEET) ? + $this->ADMIN_STYLESHEET : $set_admin_stylesheet; + $this->HEADER['JAVASCRIPT'] = !empty($this->ADMIN_JAVASCRIPT) ? + $this->ADMIN_JAVASCRIPT : $set_admin_javascript; // the page name $this->DATA['page_name'] = $this->page_name; - $this->DATA['table_width'] = !empty($this->PAGE_WIDTH) ?: PAGE_WIDTH; + $this->DATA['table_width'] = !empty($this->PAGE_WIDTH) ?: $set_page_width; $this->DATA['form_name'] = $this->DATA['FORM_NAME']; // for tinymce special $this->DATA['TINYMCE_LANG'] = $this->lang_short; @@ -474,14 +715,16 @@ class SmartyExtend extends \Smarty // debug data, if DEBUG flag is on, this data is print out $this->DEBUG_DATA['DEBUG'] = $this->DEBUG_TMPL; } else { - $this->HEADER['STYLESHEET'] = $this->FRONTEND_STYLESHEET ? $this->FRONTEND_STYLESHEET : STYLESHEET; - $this->HEADER['JAVASCRIPT'] = $this->FRONTEND_JAVASCRIPT ? $this->FRONTEND_JAVASCRIPT : JAVASCRIPT; + $this->HEADER['STYLESHEET'] = !empty($this->FRONTEND_STYLESHEET) ? + $this->FRONTEND_STYLESHEET : $set_stylesheet; + $this->HEADER['JAVASCRIPT'] = !empty($this->FRONTEND_JAVASCRIPT) ? + $this->FRONTEND_JAVASCRIPT : $set_javascript; } // html title // set local page title $this->HEADER['HTML_TITLE'] = !$this->L_TITLE ? ucfirst(str_replace('_', ' ', \CoreLibs\Get\System::getPageName(1))) - . (defined('G_TITLE') ? ' - ' . $this->l10n->__(G_TITLE) : '') : + . (!empty($set_g_title) ? '-' . $this->l10n->__($set_g_title) : '') : $this->l10n->__($this->L_TITLE); // LANG @@ -499,16 +742,16 @@ class SmartyExtend extends \Smarty $this->DATA['JS_TRANSLATE'] = $this->JS_TRANSLATE ?? null; $this->DATA['PAGE_FILE_NAME'] = str_replace('.php', '', $this->page_name) . '.tpl'; // render page - $this->renderSmarty(); + $this->renderSmarty($compile_dir, $cache_dir); } /** * merge outside object HEADER/DATA/DEBUG_DATA vars into the smarty class * - * @param object $cms object that has header/data/debug_data + * @param \CoreLibs\Admin\Backend $cms object that has header/data/debug_data * @return void */ - public function mergeCmsSmartyVars(object $cms): void + public function mergeCmsSmartyVars(\CoreLibs\Admin\Backend $cms): void { // array merge HEADER, DATA, DEBUG DATA foreach (['HEADER', 'DATA', 'DEBUG_DATA'] as $ext_smarty) { @@ -524,21 +767,39 @@ class SmartyExtend extends \Smarty /** * render smarty data (can be called sepparate) * + * @param string|null $compile_dir BASE . TEMPLATES_C + * @param string|null $cache_dir BASE . CACHE * @return void */ - public function renderSmarty(): void - { + public function renderSmarty( + ?string $compile_dir = null, + ?string $cache_dir = null + ): void { + // trigger deprecation + if ( + $compile_dir === null || + $cache_dir === null + ) { + /** @deprecated renderSmarty call without parameters */ + trigger_error( + 'Calling renderSmarty without paramters is deprecated', + E_USER_DEPRECATED + ); + } + // set vars (to be deprecated) + $compile_dir = $compile_dir ?? BASE . TEMPLATES_C; + $cache_dir = $cache_dir ?? BASE . CACHE; // create main data array $this->CONTENT_DATA = array_merge($this->HEADER, $this->DATA, $this->DEBUG_DATA); // data is 1:1 mapping (all vars, values, etc) foreach ($this->CONTENT_DATA as $key => $value) { $this->assign($key, $value); } - if (is_dir(BASE . TEMPLATES_C)) { - $this->setCompileDir(BASE . TEMPLATES_C); + if (is_dir($compile_dir)) { + $this->setCompileDir($compile_dir); } - if (is_dir(BASE . CACHE)) { - $this->setCacheDir(BASE . CACHE); + if (is_dir($cache_dir)) { + $this->setCacheDir($cache_dir); } $this->display( $this->MASTER_TEMPLATE_NAME, diff --git a/www/lib/Error.Handling.php b/www/lib/Error.Handling.php index 5493c034..b7933ae8 100644 --- a/www/lib/Error.Handling.php +++ b/www/lib/Error.Handling.php @@ -79,10 +79,13 @@ function MyErrorHandler( } $LOG = 'log' . DIRECTORY_SEPARATOR; // if the log folder is not found, try to create it + $error = false; if (!is_dir($ROOT . $LOG) && !is_file($ROOT . LOG)) { $ok = mkdir($ROOT . $LOG); + if (!$ok) { + $error = true; + } } - $error = 0; // again, if the folder now exists, else set error flag if (is_dir($ROOT . $LOG)) { $fn = $ROOT . $LOG . 'php_errors-' . date('Y-m-d') . '.log'; @@ -94,10 +97,10 @@ function MyErrorHandler( fwrite($fp, '[' . date("Y-m-d H:i:s") . '] ' . $output . "\n"); fclose($fp); } else { - $error = 1; + $error = true; } } else { - $error = 1; + $error = true; } // if the above writing failed diff --git a/www/lib/Test/DB/TestDB.php b/www/lib/Test/DB/TestDB.php index 32ee7615..4846f2d0 100644 --- a/www/lib/Test/DB/TestDB.php +++ b/www/lib/Test/DB/TestDB.php @@ -17,9 +17,12 @@ class TestDB /** * Undocumented function + * + * @param \CoreLibs\Debug\Logging $log */ - public function __construct() - { + public function __construct( + \CoreLibs\Debug\Logging $log + ) { $this->config = [ 'db_name' => $_ENV['DB_NAME_TEST'] ?? '', 'db_user' => $_ENV['DB_USER_TEST'] ?? '', @@ -31,7 +34,10 @@ class TestDB 'db_encoding' => '', 'db_ssl' => 'allow' ]; - $this->db = new IO($this->config); + $this->db = new IO( + $this->config, + $log + ); } /** diff --git a/www/lib/Test/Test.php b/www/lib/Test/Test.php index b2c631f9..b5033ae5 100644 --- a/www/lib/Test/Test.php +++ b/www/lib/Test/Test.php @@ -23,15 +23,16 @@ class Test /** @var DB\TestDB */ private $test_db; - public function __construct() - { + public function __construct( + \CoreLibs\Debug\Logging $log + ) { // calls all tests $this->testPrivate(); $this->testProtected(); $this->testPublic(); // call intern - $this->test_db = new DB\TestDB(); + $this->test_db = new DB\TestDB($log); } public function __destruct() diff --git a/www/psalm.xml b/www/psalm.xml deleted file mode 100644 index ecdbeb6f..00000000 --- a/www/psalm.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/www/vendor/composer/autoload_classmap.php b/www/vendor/composer/autoload_classmap.php index 7f685d49..8a822ce2 100644 --- a/www/vendor/composer/autoload_classmap.php +++ b/www/vendor/composer/autoload_classmap.php @@ -16,7 +16,6 @@ return array( 'CoreLibs\\Check\\Email' => $baseDir . '/lib/CoreLibs/Check/Email.php', 'CoreLibs\\Check\\Encoding' => $baseDir . '/lib/CoreLibs/Check/Encoding.php', 'CoreLibs\\Check\\File' => $baseDir . '/lib/CoreLibs/Check/File.php', - 'CoreLibs\\Check\\Jason' => $baseDir . '/lib/CoreLibs/Check/Jason.php', 'CoreLibs\\Check\\Password' => $baseDir . '/lib/CoreLibs/Check/Password.php', 'CoreLibs\\Check\\PhpVersion' => $baseDir . '/lib/CoreLibs/Check/PhpVersion.php', 'CoreLibs\\Combined\\ArrayHandler' => $baseDir . '/lib/CoreLibs/Combined/ArrayHandler.php', @@ -48,14 +47,12 @@ return array( 'CoreLibs\\Debug\\RunningTime' => $baseDir . '/lib/CoreLibs/Debug/RunningTime.php', 'CoreLibs\\Debug\\Support' => $baseDir . '/lib/CoreLibs/Debug/Support.php', 'CoreLibs\\Get\\DotEnv' => $baseDir . '/lib/CoreLibs/Get/DotEnv.php', - 'CoreLibs\\Get\\ReadEnvFile' => $baseDir . '/lib/CoreLibs/Get/ReadEnvFile.php', 'CoreLibs\\Get\\System' => $baseDir . '/lib/CoreLibs/Get/System.php', 'CoreLibs\\Language\\Core\\CachedFileReader' => $baseDir . '/lib/CoreLibs/Language/Core/CachedFileReader.php', 'CoreLibs\\Language\\Core\\FileReader' => $baseDir . '/lib/CoreLibs/Language/Core/FileReader.php', 'CoreLibs\\Language\\Core\\GetTextReader' => $baseDir . '/lib/CoreLibs/Language/Core/GetTextReader.php', 'CoreLibs\\Language\\Core\\StreamReader' => $baseDir . '/lib/CoreLibs/Language/Core/StreamReader.php', 'CoreLibs\\Language\\Core\\StringReader' => $baseDir . '/lib/CoreLibs/Language/Core/StringReader.php', - 'CoreLibs\\Language\\Encoding' => $baseDir . '/lib/CoreLibs/Language/Encoding.php', 'CoreLibs\\Language\\GetLocale' => $baseDir . '/lib/CoreLibs/Language/GetLocale.php', 'CoreLibs\\Language\\L10n' => $baseDir . '/lib/CoreLibs/Language/L10n.php', 'CoreLibs\\Output\\Form\\Elements' => $baseDir . '/lib/CoreLibs/Output/Form/Elements.php', diff --git a/www/vendor/composer/autoload_psr4.php b/www/vendor/composer/autoload_psr4.php index 1908da4c..def4fddf 100644 --- a/www/vendor/composer/autoload_psr4.php +++ b/www/vendor/composer/autoload_psr4.php @@ -6,6 +6,8 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'gullevek\\dotenv\\' => array($vendorDir . '/gullevek/dotenv/src'), + 'gullevek\\dotEnv\\' => array($vendorDir . '/gullevek/dotenv/src'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'), diff --git a/www/vendor/composer/autoload_real.php b/www/vendor/composer/autoload_real.php index a7a82972..76f6dc67 100644 --- a/www/vendor/composer/autoload_real.php +++ b/www/vendor/composer/autoload_real.php @@ -22,6 +22,8 @@ class ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9 return self::$loader; } + require __DIR__ . '/platform_check.php'; + spl_autoload_register(array('ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit10fe8fe2ec4017b8644d2b64bcf398b9', 'loadClassLoader')); diff --git a/www/vendor/composer/autoload_static.php b/www/vendor/composer/autoload_static.php index e92239dd..cc3bb35b 100644 --- a/www/vendor/composer/autoload_static.php +++ b/www/vendor/composer/autoload_static.php @@ -12,6 +12,11 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 ); public static $prefixLengthsPsr4 = array ( + 'g' => + array ( + 'gullevek\\dotenv\\' => 16, + 'gullevek\\dotEnv\\' => 16, + ), 'P' => array ( 'PhpParser\\' => 10, @@ -24,6 +29,14 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 ); public static $prefixDirsPsr4 = array ( + 'gullevek\\dotenv\\' => + array ( + 0 => __DIR__ . '/..' . '/gullevek/dotenv/src', + ), + 'gullevek\\dotEnv\\' => + array ( + 0 => __DIR__ . '/..' . '/gullevek/dotenv/src', + ), 'PhpParser\\' => array ( 0 => __DIR__ . '/..' . '/nikic/php-parser/lib/PhpParser', @@ -49,7 +62,6 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 'CoreLibs\\Check\\Email' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Email.php', 'CoreLibs\\Check\\Encoding' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Encoding.php', 'CoreLibs\\Check\\File' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/File.php', - 'CoreLibs\\Check\\Jason' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Jason.php', 'CoreLibs\\Check\\Password' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/Password.php', 'CoreLibs\\Check\\PhpVersion' => __DIR__ . '/../..' . '/lib/CoreLibs/Check/PhpVersion.php', 'CoreLibs\\Combined\\ArrayHandler' => __DIR__ . '/../..' . '/lib/CoreLibs/Combined/ArrayHandler.php', @@ -81,14 +93,12 @@ class ComposerStaticInit10fe8fe2ec4017b8644d2b64bcf398b9 'CoreLibs\\Debug\\RunningTime' => __DIR__ . '/../..' . '/lib/CoreLibs/Debug/RunningTime.php', 'CoreLibs\\Debug\\Support' => __DIR__ . '/../..' . '/lib/CoreLibs/Debug/Support.php', 'CoreLibs\\Get\\DotEnv' => __DIR__ . '/../..' . '/lib/CoreLibs/Get/DotEnv.php', - 'CoreLibs\\Get\\ReadEnvFile' => __DIR__ . '/../..' . '/lib/CoreLibs/Get/ReadEnvFile.php', 'CoreLibs\\Get\\System' => __DIR__ . '/../..' . '/lib/CoreLibs/Get/System.php', 'CoreLibs\\Language\\Core\\CachedFileReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/CachedFileReader.php', 'CoreLibs\\Language\\Core\\FileReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/FileReader.php', 'CoreLibs\\Language\\Core\\GetTextReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/GetTextReader.php', 'CoreLibs\\Language\\Core\\StreamReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/StreamReader.php', 'CoreLibs\\Language\\Core\\StringReader' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Core/StringReader.php', - 'CoreLibs\\Language\\Encoding' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/Encoding.php', 'CoreLibs\\Language\\GetLocale' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/GetLocale.php', 'CoreLibs\\Language\\L10n' => __DIR__ . '/../..' . '/lib/CoreLibs/Language/L10n.php', 'CoreLibs\\Output\\Form\\Elements' => __DIR__ . '/../..' . '/lib/CoreLibs/Output/Form/Elements.php', diff --git a/www/vendor/composer/installed.json b/www/vendor/composer/installed.json index f93bf3a8..976dd13f 100644 --- a/www/vendor/composer/installed.json +++ b/www/vendor/composer/installed.json @@ -106,6 +106,63 @@ ], "install-path": "../egrajp/smarty-extended" }, + { + "name": "gullevek/dotenv", + "version": "v2.0.8", + "version_normalized": "2.0.8.0", + "source": { + "type": "git", + "url": "https://github.com/gullevek/dotEnv.git", + "reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/gullevek/dotEnv/zipball/e29f9fcd8853a09bb89b0eb8ee555b754ecee36e", + "reference": "e29f9fcd8853a09bb89b0eb8ee555b754ecee36e", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "require-dev": { + "phan/phan": "^5.4", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9" + }, + "time": "2023-03-03T00:32:02+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "gullevek\\dotEnv\\": "src/", + "gullevek\\dotenv\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Clemens Schwaighofer", + "email": "gullevek@gullevek.org", + "homepage": "http://gullevek.org" + } + ], + "description": "Simple .env file processing and storing in _ENV array", + "homepage": "https://github.com/gullevek/dotEnv", + "keywords": [ + ".env", + "_ENV", + "dotenv", + "environment variables" + ], + "support": { + "issues": "https://github.com/gullevek/dotEnv/issues", + "source": "https://github.com/gullevek/dotEnv/tree/v2.0.8" + }, + "install-path": "../gullevek/dotenv" + }, { "name": "myclabs/deep-copy", "version": "1.11.0", @@ -346,24 +403,24 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.24", - "version_normalized": "9.2.24.0", + "version": "9.2.25", + "version_normalized": "9.2.25.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" + "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", - "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0e2b40518197a8c0d4b08bc34dfff1c99c508954", + "reference": "0e2b40518197a8c0d4b08bc34dfff1c99c508954", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -381,7 +438,7 @@ "ext-pcov": "*", "ext-xdebug": "*" }, - "time": "2023-01-26T08:26:55+00:00", + "time": "2023-02-25T05:32:00+00:00", "type": "library", "extra": { "branch-alias": { @@ -414,7 +471,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.25" }, "funding": [ { @@ -679,17 +736,17 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.3", - "version_normalized": "9.6.3.0", + "version": "9.6.4", + "version_normalized": "9.6.4.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555" + "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555", - "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9125ee085b6d95e78277dc07aa1f46f9e0607b8d", + "reference": "9125ee085b6d95e78277dc07aa1f46f9e0607b8d", "shasum": "" }, "require": { @@ -725,7 +782,7 @@ "ext-soap": "*", "ext-xdebug": "*" }, - "time": "2023-02-04T13:37:15+00:00", + "time": "2023-02-27T13:06:37+00:00", "bin": [ "phpunit" ], @@ -764,7 +821,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.4" }, "funding": [ { diff --git a/www/vendor/composer/installed.php b/www/vendor/composer/installed.php index d3dd144a..ab21956b 100644 --- a/www/vendor/composer/installed.php +++ b/www/vendor/composer/installed.php @@ -37,6 +37,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'gullevek/dotenv' => array( + 'pretty_version' => 'v2.0.8', + 'version' => '2.0.8.0', + 'reference' => 'e29f9fcd8853a09bb89b0eb8ee555b754ecee36e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../gullevek/dotenv', + 'aliases' => array(), + 'dev_requirement' => false, + ), 'myclabs/deep-copy' => array( 'pretty_version' => '1.11.0', 'version' => '1.11.0.0', @@ -74,9 +83,9 @@ 'dev_requirement' => true, ), 'phpunit/php-code-coverage' => array( - 'pretty_version' => '9.2.24', - 'version' => '9.2.24.0', - 'reference' => '2cf940ebc6355a9d430462811b5aaa308b174bed', + 'pretty_version' => '9.2.25', + 'version' => '9.2.25.0', + 'reference' => '0e2b40518197a8c0d4b08bc34dfff1c99c508954', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', 'aliases' => array(), @@ -119,9 +128,9 @@ 'dev_requirement' => true, ), 'phpunit/phpunit' => array( - 'pretty_version' => '9.6.3', - 'version' => '9.6.3.0', - 'reference' => 'e7b1615e3e887d6c719121c6d4a44b0ab9645555', + 'pretty_version' => '9.6.4', + 'version' => '9.6.4.0', + 'reference' => '9125ee085b6d95e78277dc07aa1f46f9e0607b8d', 'type' => 'library', 'install_path' => __DIR__ . '/../phpunit/phpunit', 'aliases' => array(), diff --git a/www/vendor/composer/platform_check.php b/www/vendor/composer/platform_check.php new file mode 100644 index 00000000..4c3a5d68 --- /dev/null +++ b/www/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/www/vendor/gullevek/dotenv/Readme.md b/www/vendor/gullevek/dotenv/Readme.md new file mode 100644 index 00000000..56a498f6 --- /dev/null +++ b/www/vendor/gullevek/dotenv/Readme.md @@ -0,0 +1,78 @@ +# dotenv: readEnvFile() + +A simple implementation of + +This is not a functional replacement, but a very simple implementation of the basic functions. + +It is recommended to create a `.env.example` example file that is checked into the +repository. The `.env` should *NEVER* be checked into anything + +## How to install + +`composer require gullevek/dotEnv` + +## Run it + +Create a `.env` file in the current folder. +Create a file like below + +```php +require '../vendor/autoload.php'; +gullevek\dotEnv\DotEnv::readEnvFile(__DIR__); +``` + +All data will be in the `$_ENV` array + +## How it works + +Put the function where it is needed or put it in a file and load it. + +if not parameter is given it will use `__DIR__` as base path. +Second parameter is file name override. Default is `.env` + +Data is loaded into _ENV only. + +If there is already an entry in _ENV then it will not be overwritten. + +## .env file example + +A valid entry has to start with an alphanumeric string, underscores are allowed and +then have an equal sign (=). After the equal sign the data block starts. Data can be +quoted with double quotes (") and if this is done can stretch over multiple lines. +The openeing double quote must be on the same lign as the requal sign (=). If double +quoted (") charcters are used it will read each line until another double quote (") +character is found. Everything after that is ignored. + +Any spaces before the variable or before and after the equal sign (=) are ignored. + +Line is read until `PHP_EOL`. So any trailing spaces are read too. + +Any line that is not valid is ignored. + +```ini +# this line is ignored +SOMETHING=A +OTHER="A B C" +MULTI_LINE="1 2 3 +4 5 6 +7 8 9" ; and this is ignored +ESCAPE="String \" inside \" other " +DOUBLE="I will be used" +DOUBLE="This will be ignored" +``` + +## Development + +### Phan + +`vendor/bin/phan --analyze-twice` + +### PHPstan + +`vendor/bin/phpstan` + +### PHPUnit + +Unit tests have to be run from base folder with + +`vendor/bin/phpunit test/phpUnitTests/` diff --git a/www/vendor/gullevek/dotenv/composer.json b/www/vendor/gullevek/dotenv/composer.json new file mode 100644 index 00000000..7d8298c4 --- /dev/null +++ b/www/vendor/gullevek/dotenv/composer.json @@ -0,0 +1,33 @@ +{ + "name": "gullevek/dotenv", + "description": "Simple .env file processing and storing in _ENV array", + "keywords": [".env", "dotenv", "_ENV", "environment variables"], + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "gullevek\\dotEnv\\": "src/", + "gullevek\\dotenv\\": "src/" + } + }, + "authors": [ + { + "name": "Clemens Schwaighofer", + "email": "gullevek@gullevek.org", + "homepage": "http://gullevek.org" + } + ], + "homepage": "https://github.com/gullevek/dotEnv", + "minimum-stability": "dev", + "require": { + "php": ">=7.4.0" + }, + "archive": { + "exclude": ["/test/", "/test/*", "/phpstan.neon", "/psalm.xml", "/.phan/", "/.vscode/", "/phpunit.xml"] + }, + "require-dev": { + "phpunit/phpunit": "^9", + "phpstan/phpstan": "^1.10", + "phan/phan": "^5.4" + } +} diff --git a/www/vendor/gullevek/dotenv/src/DotEnv.php b/www/vendor/gullevek/dotenv/src/DotEnv.php new file mode 100644 index 00000000..6dd878ca --- /dev/null +++ b/www/vendor/gullevek/dotenv/src/DotEnv.php @@ -0,0 +1,110 @@ + abort + if (!is_file($env_file_target)) { + $status = 3; + return $status; + } + // cannot open file -> abort + if (!is_readable($env_file_target)) { + $status = 2; + return $status; + } + // open file + if (($fp = fopen($env_file_target, 'r')) === false) { + $status = 2; + return $status; + } + // set to readable but not yet any data loaded + $status = 1; + $block = false; + $var = ''; + while ($line = fgets($fp)) { + // main match for variable = value part + if (preg_match("/^\s*([\w_.]+)\s*=\s*((\"?).*)/", $line, $matches)) { + $var = $matches[1]; + $value = $matches[2]; + $quotes = $matches[3]; + // write only if env is not set yet, and write only the first time + if (empty($_ENV[$var])) { + if (!empty($quotes)) { + // match greedy for first to last so we move any " if there are + if (preg_match('/^"(.*[^\\\])"/U', $value, $matches)) { + $value = $matches[1]; + } else { + // this is a multi line + $block = true; + // first " in string remove + // add removed new line back because this is a multi line + $value = ltrim($value, '"') . PHP_EOL; + } + } else { + // strip any quotes at end for unquoted single line + // an right hand spaces are removed too + $value = false !== ($pos = strpos($value, self::COMMENT_CHAR)) ? + rtrim(substr($value, 0, $pos)) : $value; + } + // if block is set, we strip line of slashes + $_ENV[$var] = $block === true ? stripslashes($value) : $value; + // set successful load + $status = 0; + } + } elseif ($block === true) { + // read line until there is a unescaped " + // this also strips everything after the last " + if (preg_match("/(.*[^\\\])\"/", $line, $matches)) { + $block = false; + // strip ending " and EVERYTHING that follows after that + $line = $matches[1]; + } + // just be sure it is init before we fill + if (!isset($_ENV[$var])) { + $_ENV[$var] = ''; + } + // strip line of slashes + $_ENV[$var] .= stripslashes($line); + } + } + fclose($fp); + return $status; + } +} + +// __END__ diff --git a/www/vendor/phpunit/php-code-coverage/ChangeLog.md b/www/vendor/phpunit/php-code-coverage/ChangeLog.md index cdf28e0a..35ef8119 100644 --- a/www/vendor/phpunit/php-code-coverage/ChangeLog.md +++ b/www/vendor/phpunit/php-code-coverage/ChangeLog.md @@ -2,6 +2,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles. +## [9.2.25] - 2023-02-25 + +### Fixed + +* [#981](https://github.com/sebastianbergmann/php-code-coverage/issues/981): `CodeUnitFindingVisitor` does not support DNF types + ## [9.2.24] - 2023-01-26 ### Changed @@ -464,6 +470,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt * This component is no longer supported on PHP 7.1 +[9.2.25]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.24...9.2.25 [9.2.24]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.23...9.2.24 [9.2.23]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.22...9.2.23 [9.2.22]: https://github.com/sebastianbergmann/php-code-coverage/compare/9.2.21...9.2.22 diff --git a/www/vendor/phpunit/php-code-coverage/composer.json b/www/vendor/phpunit/php-code-coverage/composer.json index b09bd647..6db6936f 100644 --- a/www/vendor/phpunit/php-code-coverage/composer.json +++ b/www/vendor/phpunit/php-code-coverage/composer.json @@ -32,7 +32,7 @@ "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.14", + "nikic/php-parser": "^4.15", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", "sebastian/code-unit-reverse-lookup": "^2.0.2", diff --git a/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Dashboard.php b/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Dashboard.php index 6672a6ea..b44870b5 100644 --- a/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Dashboard.php +++ b/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/Dashboard.php @@ -117,7 +117,7 @@ final class Dashboard extends Renderer private function coverageDistribution(array $classes): array { $result = [ - 'class' => [ + 'class' => [ '0%' => 0, '0-10%' => 0, '10-20%' => 0, diff --git a/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php b/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php index 69fd8b1d..101a9ada 100644 --- a/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php +++ b/www/vendor/phpunit/php-code-coverage/src/Report/Html/Renderer/File.php @@ -284,19 +284,19 @@ final class File extends Renderer $buffer .= $this->renderItemTemplate( $template, [ - 'name' => $this->abbreviateClassName($name), - 'numClasses' => $numClasses, - 'numTestedClasses' => $numTestedClasses, - 'numMethods' => $numMethods, - 'numTestedMethods' => $numTestedMethods, - 'linesExecutedPercent' => Percentage::fromFractionAndTotal( + 'name' => $this->abbreviateClassName($name), + 'numClasses' => $numClasses, + 'numTestedClasses' => $numTestedClasses, + 'numMethods' => $numMethods, + 'numTestedMethods' => $numTestedMethods, + 'linesExecutedPercent' => Percentage::fromFractionAndTotal( $item['executedLines'], $item['executableLines'], )->asFloat(), - 'linesExecutedPercentAsString' => $linesExecutedPercentAsString, - 'numExecutedLines' => $item['executedLines'], - 'numExecutableLines' => $item['executableLines'], - 'branchesExecutedPercent' => Percentage::fromFractionAndTotal( + 'linesExecutedPercentAsString' => $linesExecutedPercentAsString, + 'numExecutedLines' => $item['executedLines'], + 'numExecutableLines' => $item['executableLines'], + 'branchesExecutedPercent' => Percentage::fromFractionAndTotal( $item['executedBranches'], $item['executableBranches'], )->asFloat(), @@ -307,14 +307,14 @@ final class File extends Renderer $item['executedPaths'], $item['executablePaths'] )->asFloat(), - 'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString, - 'numExecutedPaths' => $item['executedPaths'], - 'numExecutablePaths' => $item['executablePaths'], - 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), - 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), - 'testedClassesPercent' => $testedClassesPercentage->asFloat(), - 'testedClassesPercentAsString' => $testedClassesPercentage->asString(), - 'crap' => $item['crap'], + 'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString, + 'numExecutedPaths' => $item['executedPaths'], + 'numExecutablePaths' => $item['executablePaths'], + 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), + 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), + 'testedClassesPercent' => $testedClassesPercentage->asFloat(), + 'testedClassesPercentAsString' => $testedClassesPercentage->asString(), + 'crap' => $item['crap'], ] ); @@ -384,7 +384,7 @@ final class File extends Renderer return $this->renderItemTemplate( $template, [ - 'name' => sprintf( + 'name' => sprintf( '%s%s', $indent, $item['startLine'], diff --git a/www/vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php b/www/vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php index 8a2003fa..cb85cd61 100644 --- a/www/vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php +++ b/www/vendor/phpunit/php-code-coverage/src/StaticAnalysis/CodeUnitFindingVisitor.php @@ -26,6 +26,7 @@ use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Interface_; use PhpParser\Node\Stmt\Trait_; use PhpParser\Node\UnionType; +use PhpParser\NodeAbstract; use PhpParser\NodeTraverser; use PhpParser\NodeVisitorAbstract; use SebastianBergmann\Complexity\CyclomaticComplexityCalculatingVisitor; @@ -180,8 +181,12 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract return '?' . $type->type; } - if ($type instanceof UnionType || $type instanceof IntersectionType) { - return $this->unionOrIntersectionAsString($type); + if ($type instanceof UnionType) { + return $this->unionTypeAsString($type); + } + + if ($type instanceof IntersectionType) { + return $this->intersectionTypeAsString($type); } return $type->toString(); @@ -298,29 +303,43 @@ final class CodeUnitFindingVisitor extends NodeVisitorAbstract return trim(rtrim($namespacedName, $name), '\\'); } - /** - * @psalm-param UnionType|IntersectionType $type - */ - private function unionOrIntersectionAsString(ComplexType $type): string + private function unionTypeAsString(UnionType $node): string { - if ($type instanceof UnionType) { - $separator = '|'; - } else { - $separator = '&'; - } - $types = []; - foreach ($type->types as $_type) { - if ($_type instanceof Name) { - $types[] = $_type->toCodeString(); - } else { - assert($_type instanceof Identifier); + foreach ($node->types as $type) { + if ($type instanceof IntersectionType) { + $types[] = '(' . $this->intersectionTypeAsString($type) . ')'; - $types[] = $_type->toString(); + continue; } + + $types[] = $this->typeAsString($type); } - return implode($separator, $types); + return implode('|', $types); + } + + private function intersectionTypeAsString(IntersectionType $node): string + { + $types = []; + + foreach ($node->types as $type) { + $types[] = $this->typeAsString($type); + } + + return implode('&', $types); + } + + /** + * @psalm-param Identifier|Name $node $node + */ + private function typeAsString(NodeAbstract $node): string + { + if ($node instanceof Name) { + return $node->toCodeString(); + } + + return $node->toString(); } } diff --git a/www/vendor/phpunit/php-code-coverage/src/Version.php b/www/vendor/phpunit/php-code-coverage/src/Version.php index 8d45b6c6..7feb0a9c 100644 --- a/www/vendor/phpunit/php-code-coverage/src/Version.php +++ b/www/vendor/phpunit/php-code-coverage/src/Version.php @@ -22,7 +22,7 @@ final class Version public static function id(): string { if (self::$version === null) { - self::$version = (new VersionId('9.2.24', dirname(__DIR__)))->getVersion(); + self::$version = (new VersionId('9.2.25', dirname(__DIR__)))->getVersion(); } return self::$version; diff --git a/www/vendor/phpunit/phpunit/ChangeLog-8.5.md b/www/vendor/phpunit/phpunit/ChangeLog-8.5.md index 6485b8e5..a65e6a61 100644 --- a/www/vendor/phpunit/phpunit/ChangeLog-8.5.md +++ b/www/vendor/phpunit/phpunit/ChangeLog-8.5.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [8.5.33] - 2023-02-27 + +### Fixed + +* [#5186](https://github.com/sebastianbergmann/phpunit/issues/5186): SBOM does not validate + ## [8.5.32] - 2023-01-26 ### Fixed @@ -262,6 +268,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil * [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable` * [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside +[8.5.33]: https://github.com/sebastianbergmann/phpunit/compare/8.5.32...8.5.33 [8.5.32]: https://github.com/sebastianbergmann/phpunit/compare/8.5.31...8.5.32 [8.5.31]: https://github.com/sebastianbergmann/phpunit/compare/8.5.30...8.5.31 [8.5.30]: https://github.com/sebastianbergmann/phpunit/compare/8.5.29...8.5.30 diff --git a/www/vendor/phpunit/phpunit/ChangeLog-9.6.md b/www/vendor/phpunit/phpunit/ChangeLog-9.6.md index 2491e303..df27bce7 100644 --- a/www/vendor/phpunit/phpunit/ChangeLog-9.6.md +++ b/www/vendor/phpunit/phpunit/ChangeLog-9.6.md @@ -2,6 +2,12 @@ All notable changes of the PHPUnit 9.6 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles. +## [9.6.4] - 2023-02-27 + +### Fixed + +* [#5186](https://github.com/sebastianbergmann/phpunit/issues/5186): SBOM does not validate + ## [9.6.3] - 2023-02-04 ### Fixed @@ -19,7 +25,7 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil ### Fixed * [#5073](https://github.com/sebastianbergmann/phpunit/issues/5073): `--no-extensions` CLI option only prevents extension PHARs from being loaded -* [#5160](https://github.com/sebastianbergmann/phpunit/issues/5160): PHPUnit 9.6 misses deprecations for assertions and constraints removed in PHPUnit 10 +* [#5160](https://github.com/sebastianbergmann/phpunit/issues/5160): Deprecate `assertClassHasAttribute()`, `assertClassNotHasAttribute()`, `assertClassHasStaticAttribute()`, `assertClassNotHasStaticAttribute()`, `assertObjectHasAttribute()`, `assertObjectNotHasAttribute()`, `classHasAttribute()`, `classHasStaticAttribute()`, and `objectHasAttribute()` ## [9.6.0] - 2023-02-03 @@ -30,6 +36,7 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil * [#5064](https://github.com/sebastianbergmann/phpunit/issues/5064): Deprecate `PHPUnit\Framework\TestCase::getMockClass()` * [#5132](https://github.com/sebastianbergmann/phpunit/issues/5132): Deprecate `Test` suffix for abstract test case classes +[9.6.4]: https://github.com/sebastianbergmann/phpunit/compare/9.6.3...9.6.4 [9.6.3]: https://github.com/sebastianbergmann/phpunit/compare/9.6.2...9.6.3 [9.6.2]: https://github.com/sebastianbergmann/phpunit/compare/9.6.1...9.6.2 [9.6.1]: https://github.com/sebastianbergmann/phpunit/compare/9.6.0...9.6.1 diff --git a/www/vendor/phpunit/phpunit/SECURITY.md b/www/vendor/phpunit/phpunit/SECURITY.md index dcc15385..965e5ed2 100644 --- a/www/vendor/phpunit/phpunit/SECURITY.md +++ b/www/vendor/phpunit/phpunit/SECURITY.md @@ -1,11 +1,33 @@ # Security Policy -PHPUnit is a framework for writing as well as a commandline tool for running tests. Writing and running tests is a development-time activity. There is no reason why PHPUnit should be installed on a webserver. +If you believe you have found a security vulnerability in PHPUnit, please report it to us through coordinated disclosure. + +**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.** + +Instead, please email `sebastian@phpunit.de`. + +Please include as much of the information listed below as you can to help us better understand and resolve the issue: + +* The type of issue +* Full paths of source file(s) related to the manifestation of the issue +* The location of the affected source code (tag/branch/commit or direct URL) +* Any special configuration required to reproduce the issue +* Step-by-step instructions to reproduce the issue +* Proof-of-concept or exploit code (if possible) +* Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Web Context + +PHPUnit is a framework for writing as well as a command-line tool for running tests. Writing and running tests is a development-time activity. There is no reason why PHPUnit should be installed on a webserver and/or in a production environment. **If you upload PHPUnit to a webserver then your deployment process is broken. On a more general note, if your `vendor` directory is publicly accessible on your webserver then your deployment process is also broken.** Please note that if you upload PHPUnit to a webserver "bad things" may happen. [You have been warned.](https://thephp.cc/articles/phpunit-a-security-risk) -## Security Contact Information +PHPUnit is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using PHPUnit in an HTTP or web context or with untrusted input data is performed. PHPUnit might also contain functionality that intentionally exposes internal application data for debugging purposes. -After the above, if you still would like to report a security vulnerability, please email `sebastian@phpunit.de`. +If PHPUnit is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context. + +Vulnerabilities specific to the use outside a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes. diff --git a/www/vendor/phpunit/phpunit/src/Runner/Version.php b/www/vendor/phpunit/phpunit/src/Runner/Version.php index 70de3024..7fda90ba 100644 --- a/www/vendor/phpunit/phpunit/src/Runner/Version.php +++ b/www/vendor/phpunit/phpunit/src/Runner/Version.php @@ -41,7 +41,7 @@ final class Version } if (self::$version === '') { - self::$version = (new VersionId('9.6.3', dirname(__DIR__, 2)))->getVersion(); + self::$version = (new VersionId('9.6.4', dirname(__DIR__, 2)))->getVersion(); } return self::$version;