diff --git a/.phan/config.php b/.phan/config.php index da7adef3..73d1b51f 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -96,8 +96,6 @@ return [ "exclude_analysis_directory_list" => [ 'www/vendor', 'www/tests', - 'www/lib/Smarty', - 'www/lib/smarty-4.3.0', 'www/templates_c', 'www/log', 'www/tmp', @@ -118,10 +116,6 @@ return [ // ignore the old qq tests 'www/admin/qq_file_upload_front.php', 'www/admin/qq_file_upload_ajax.php', - // symlink ignore - 'www/lib/smarty-4.3.0/libs/Smarty.class.php', - // legacy edit base (until removal) - 'www/includes/edit_base.LEGACY.php' ], // what not to show as problem diff --git a/4dev/tests/ACL/CoreLibsACLLoginTest.php b/4dev/tests/ACL/CoreLibsACLLoginTest.php index 361e8edb..8b8b125d 100644 --- a/4dev/tests/ACL/CoreLibsACLLoginTest.php +++ b/4dev/tests/ACL/CoreLibsACLLoginTest.php @@ -1114,6 +1114,7 @@ final class CoreLibsACLLoginTest extends TestCase 'logout_target' => '', 'site_locale' => 'en_US.UTF-8', 'site_domain' => 'admin', + 'site_encoding' => 'UTF-8', 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, @@ -1796,6 +1797,7 @@ final class CoreLibsACLLoginTest extends TestCase 'logout_target' => '', 'site_locale' => 'en_US.UTF-8', 'site_domain' => 'admin', + 'site_encoding' => 'UTF-8', 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, @@ -1909,6 +1911,7 @@ final class CoreLibsACLLoginTest extends TestCase 'logout_target' => '', 'site_locale' => 'en_US.UTF-8', 'site_domain' => 'admin', + 'site_encoding' => 'UTF-8', 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, @@ -1996,6 +1999,7 @@ final class CoreLibsACLLoginTest extends TestCase 'logout_target' => '', 'site_locale' => 'en_US.UTF-8', 'site_domain' => 'admin', + 'site_encoding' => 'UTF-8', 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, @@ -2091,6 +2095,7 @@ final class CoreLibsACLLoginTest extends TestCase 'logout_target' => '', 'site_locale' => 'en_US.UTF-8', 'site_domain' => 'admin', + 'site_encoding' => 'UTF-8', 'locale_path' => __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, diff --git a/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php b/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php index f8c9c454..fa053413 100644 --- a/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php +++ b/4dev/tests/Language/CoreLibsLanguageGetLocaleTest.php @@ -14,6 +14,13 @@ use PHPUnit\Framework\TestCase; */ final class CoreLibsLanguageGetLocaleTest extends TestCase { + public const SITE_ENCODING = 'UTF-8'; + public const SITE_LOCALE = 'en_US.UTF-8'; + public const SITE_DOMAIN = 'admin'; + public const LOCALE_PATH = __DIR__ . DIRECTORY_SEPARATOR + . 'includes' . DIRECTORY_SEPARATOR + . 'locale' . DIRECTORY_SEPARATOR; + /** * set all constant variables that must be set before call * @@ -22,7 +29,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase public static function setUpBeforeClass(): void { // default web page encoding setting - if (!defined('DEFAULT_ENCODING')) { + /* if (!defined('DEFAULT_ENCODING')) { define('DEFAULT_ENCODING', 'UTF-8'); } if (!defined('DEFAULT_LOCALE')) { @@ -35,9 +42,9 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase } if (!defined('SITE_LOCALE')) { define('SITE_LOCALE', DEFAULT_LOCALE); - } + } */ // just set - if (!defined('BASE')) { + /* if (!defined('BASE')) { define('BASE', str_replace('/configs', '', __DIR__) . DIRECTORY_SEPARATOR); } if (!defined('INCLUDES')) { @@ -51,7 +58,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase } if (!defined('CONTENT_PATH')) { define('CONTENT_PATH', 'frontend' . DIRECTORY_SEPARATOR); - } + } */ // array session $_SESSION = []; global $_SESSION; @@ -62,7 +69,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase * * @return array */ - public function setLocaleProvider(): array + /* public function setLocaleProvider(): array { return [ // 0: locale @@ -233,7 +240,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase // TODO invalid params (bad path) (no override) // TODO param calls, but with override set ]; - } + } */ /** * Undocumented function @@ -252,7 +259,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase * @param string|null $deprecation_message * @return void */ - public function testsetLocale( + /* public function testsetLocale( ?string $language, ?string $domain, ?string $encoding, @@ -347,6 +354,214 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase // unset all vars $_SESSION = []; unset($GLOBALS['OVERRIDE_LANG']); + } */ + + /** + * all the test data + * + * @return array + */ + public function setLocaleFromSessionProvider(): array + { + return [ + // 0: locale + // 1: domain + // 2: encoding + // 3: path + // 4: SESSION: DEFAULT_LOCALE + // 5: SESSION: DEFAULT_CHARSET + // 5: SESSION: DEFAULT_DOMAIN + // 6: SESSION: LOCALE_PATH + // 6: expected array + // 7: deprecation message + 'all session vars set' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + 'ja_JP.UTF-8', 'UTF-8', 'admin', __DIR__ . '/locale_other/', + // return array + [ + 'locale' => 'ja_JP.UTF-8', + 'lang' => 'ja_JP', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?locale_other\/$/", + ], + ], + // param lang and domain (no override) + 'no session set, only parameters' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + null, null, null, null, + // return array + [ + 'locale' => 'en_US.UTF-8', + 'lang' => 'en_US', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?includes\/locale\/$/", + ], + ], + // special parse session check for locales + 'all session vars set, short lang' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + 'ja', 'UTF-8', 'admin', __DIR__ . '/locale_other/', + // return array + [ + 'locale' => 'ja', + 'lang' => 'ja', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?locale_other\/$/", + ], + ], + // lang with modifier + // param lang and domain (no override) + 'long locale, domain, encoding params, no sessions' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + 'de_CH.UTF-8@euro', 'admin', 'UTF-8', __DIR__ . '/includes/locale/', + // return array + [ + 'locale' => 'de_CH.UTF-8@euro', + 'lang' => 'de_CH', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?includes\/locale\/$/", + ], + ], + // missing session values check + // special parse session check for locales + 'session missing encoding, set from parameters' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + 'ja', null, 'admin', __DIR__ . '/locale_other/', + // return array + [ + 'locale' => 'ja', + 'lang' => 'ja', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?locale_other\/$/", + ], + ], + // null return check for invalid entries + 'no session set, only parameters, all invalid' => [ + // lang, domain, encoding, path + '###', '&&&&', '$$$$', 'foo_bar_path', + // SESSION SETTINGS: locale, charset, domain, path + null, null, null, null, + // return array + [ + 'locale' => null, + 'lang' => null, + 'domain' => null, + 'encoding' => null, + 'path' => null, + ], + ], + // invalid session names, fall backup + 'all session vars are invalid, fallback' => [ + // lang, domain, encoding, path + self::SITE_LOCALE, self::SITE_DOMAIN, self::SITE_ENCODING, self::LOCALE_PATH, + // SESSION SETTINGS: locale, charset, domain, path + '###', '&&&&', '$$$$', 'foo_bar_path', + // return array + [ + 'locale' => 'en_US.UTF-8', + 'lang' => 'en_US', + 'domain' => 'admin', + 'encoding' => 'UTF-8', + 'path' => "/^\/(.*\/)?includes\/locale\/$/", + ], + ], + ]; + } + + /** + * Undocumented function + * + * @covers ::setLocale + * @dataProvider setLocaleFromSessionProvider + * @testdox lang settings lang $language, domain $domain, encoding $encoding, path $path; session lang: $SESSION_DEFAULT_LOCALE, session char: $SESSION_DEFAULT_CHARSET [$_dataName] + * + * @param string| $language + * @param string| $domain + * @param string| $encoding + * @param string| $path + * @param string|null $SESSION_DEFAULT_LOCALE + * @param string|null $SESSION_DEFAULT_CHARSET + * @param string|null $SESSION_DEFAULT_DOMAIN + * @param string|null $SESSION_LOCALE_PATH + * @param array $expected + * @return void + */ + public function testsetLocaleFromSession( + string $language, + string $domain, + string $encoding, + string $path, + ?string $SESSION_DEFAULT_LOCALE, + ?string $SESSION_DEFAULT_CHARSET, + ?string $SESSION_DEFAULT_DOMAIN, + ?string $SESSION_LOCALE_PATH, + array $expected, + ): void { + $return_lang_settings = []; + global $_SESSION; + // set override + if ($SESSION_DEFAULT_LOCALE !== null) { + $_SESSION['DEFAULT_LOCALE'] = $SESSION_DEFAULT_LOCALE; + } + if ($SESSION_DEFAULT_CHARSET !== null) { + $_SESSION['DEFAULT_CHARSET'] = $SESSION_DEFAULT_CHARSET; + } + if ($SESSION_DEFAULT_DOMAIN !== null) { + $_SESSION['DEFAULT_DOMAIN'] = $SESSION_DEFAULT_DOMAIN; + } + if ($SESSION_LOCALE_PATH !== null) { + $_SESSION['LOCALE_PATH'] = $SESSION_LOCALE_PATH; + } + $return_lang_settings = \CoreLibs\Language\GetLocale::setLocaleFromSession( + $language, + $domain, + $encoding, + $path + ); + // print "RETURN: " . print_r($return_lang_settings, true) . "\n"; + foreach ( + [ + 'locale', 'lang', 'domain', 'encoding', 'path' + ] as $key + ) { + $value = $expected[$key]; + if ( + !empty($value) && + strpos($value, "/") === 0 + ) { + // this is regex + $this->assertMatchesRegularExpression( + $value, + $return_lang_settings[$key] ?? '', + 'assert regex failed for ' . $key + ); + } else { + // assert equal + $this->assertEquals( + $value, + $return_lang_settings[$key], + 'assert equal failed for ' . $key + ); + } + } + // unset all vars + $_SESSION = []; + unset($GLOBALS['OVERRIDE_LANG']); } } diff --git a/4dev/tests/Language/CoreLibsLanguageL10nTest.php b/4dev/tests/Language/CoreLibsLanguageL10nTest.php index 453e188e..ca1e0888 100644 --- a/4dev/tests/Language/CoreLibsLanguageL10nTest.php +++ b/4dev/tests/Language/CoreLibsLanguageL10nTest.php @@ -84,94 +84,141 @@ final class CoreLibsLanguageL10nTest extends TestCase { return [ // 0: locale - // 1: domain - // 2: encoding + // 1: encoding + // 2: domain // 3: path // 4: locale expected // 5: locale set expected // 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) + // 7: lang short expected + // 8: encoding expected + // 9: domain exepcted + // 10: context (null for none) + // 11: test string in + // 12: test translated + // 13: deprecation message (until removed) // new style load 'gettext load en' => [ 'en_US.UTF-8', + 'UTF-8', 'frontend', __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, - // + // 4, 5, 6, 7, 8, 9 'en_US.UTF-8', 'en_US', 'en_US', + 'en', 'UTF-8', 'frontend', + // 10 null, + // 11, 12 'Original', 'Translated frontend en_US', + // 13 null, ], 'gettext load en' => [ 'en_US.UTF-8', + 'UTF-8', 'frontend', __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // 'en_US.UTF-8', 'en_US', 'en_US', + 'en', 'UTF-8', 'frontend', + // 'context', + // 'Original', 'Original context frontend en_US', + // null, ], 'gettext load ja' => [ 'ja_JP.UTF-8', + 'UTF-8', 'admin', __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, // 'ja_JP.UTF-8', 'ja_JP', 'ja_JP', + 'ja', 'UTF-8', 'admin', + // null, + // 'Original', 'Translated admin ja_JP', + // + null, + ], + // load short locale with different encoding + 'gettext load short ja no encoding' => [ + 'ja', + 'SJIS', + 'admin', + __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, + // + 'ja', + 'ja', + 'ja', + 'ja', + 'SJIS', + 'admin', + // + null, + // + 'Original', + 'Translated admin ja_JP', + // null, ], // mixed path and domain [DEPRECATED] 'mixed path and domain [DEPRECATED]' => [ 'en_US.UTF-8', + 'UTF-8', __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'locale' . DIRECTORY_SEPARATOR, 'frontend', // 'en_US.UTF-8', 'en_US', 'en_US', + 'en', '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', + 'UTF-8', 'admin', null, // 'ja_JP.UTF-8', 'ja_JP', 'ja_JP', + 'ja', 'UTF-8', 'admin', + // null, + // 'Original', 'Translated admin ja_JP', + // 'Empty path parameter is no longer allowed if locale and domain are set', ], // null set @@ -179,15 +226,20 @@ final class CoreLibsLanguageL10nTest extends TestCase '', '', '', + '', // '', '', '', '', + '', // unset on empty call '', + // null, + // 'Original', 'Original', + // null, ] ]; @@ -201,11 +253,13 @@ final class CoreLibsLanguageL10nTest extends TestCase * @testdox check l10n init with Locale $locale, Path $path, Domain $domain, Legacy: $legacy with $context [$_dataName] * * @param string|null $locale + * @param string|null $encoding * @param string|null $domain * @param string|null $path * @param string $locale_expected * @param string $locale_set_expected * @param string $lang_expected + * @param string $lang_short_expected * @param string $encoding_expected * @param string $domain_expected * @param string|null $context @@ -216,11 +270,13 @@ final class CoreLibsLanguageL10nTest extends TestCase */ public function testL10nObject( ?string $locale, + ?string $encoding, ?string $domain, ?string $path, string $locale_expected, string $locale_set_expected, string $lang_expected, + string $lang_short_expected, string $encoding_expected, string $domain_expected, ?string $context, @@ -241,16 +297,18 @@ final class CoreLibsLanguageL10nTest extends TestCase if ($locale === null) { $l10n = new \CoreLibs\Language\L10n(); } elseif ($domain === null) { - // same as if locale is null + // deprecated, locale + domain must be set, handled like empty calls $l10n = new \CoreLibs\Language\L10n($locale); } elseif ($path === null) { - // deprecated, path must be set + // deprecated, path must be set, will thow DEPRECATION error, handled like empty $l10n = new \CoreLibs\Language\L10n($locale, $domain); - } else { + } elseif ($encoding === null) { + // if encoding not found will be UTF-8 $l10n = new \CoreLibs\Language\L10n($locale, $domain, $path); + } else { + $l10n = new \CoreLibs\Language\L10n($locale, $domain, $path, $encoding); } restore_error_handler(); - // print "LOC: " . $locale . ", " . $l10n->getLocale() . ", " . $locale_expected . "\n"; // print "MO: " . $l10n->getMoFile() . "\n"; $this->assertEquals( $locale_expected, @@ -286,6 +344,7 @@ final class CoreLibsLanguageL10nTest extends TestCase [ 'locale' => $locale_expected, 'lang' => $lang_expected, + 'lang_short' => $lang_short_expected, 'domain' => $domain_expected, 'encoding' => $encoding_expected, 'path' => $path diff --git a/4dev/tests/Language/includes/locale/ja b/4dev/tests/Language/includes/locale/ja new file mode 120000 index 00000000..5f64dd2b --- /dev/null +++ b/4dev/tests/Language/includes/locale/ja @@ -0,0 +1 @@ +ja_JP \ No newline at end of file diff --git a/composer.json b/composer.json index 082fc3e1..d34abf3b 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "phpstan/phpstan": "^1.10", "phan/phan": "^5.4", "phpstan/extension-installer": "^1.2", - "vimeo/psalm": "^5.7" + "vimeo/psalm": "^5.7", + "phpstan/phpstan-deprecation-rules": "^1.1" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 0ba146ed..2db2d870 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": "0394d224d0f07a238818542e4602ba86", + "content-hash": "c633a27ea30371ec870c8065ca4ae4cd", "packages": [], "packages-dev": [ { @@ -1162,6 +1162,54 @@ ], "time": "2023-03-07T16:48:45+00:00" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865", + "reference": "bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-php-parser": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.2" + }, + "time": "2023-01-17T16:14:21+00:00" + }, { "name": "psr/container", "version": "2.0.2", diff --git a/phpstan.neon b/phpstan.neon index e2711746..5b7b4982 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,23 +10,15 @@ parameters: - %currentWorkingDirectory%/www bootstrapFiles: - %currentWorkingDirectory%/phpstan-bootstrap.php - # - %currentWorkingDirectory%/www/lib/autoloader.php - %currentWorkingDirectory%/www/vendor/autoload.php scanDirectories: - www/vendor scanFiles: - www/configs/config.php - www/configs/config.master.php - # if composer.json autoloader defined, this is not needed - # - www/lib/autoloader.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 - # extra in sub folder - - www/admin/subfolder/class_test*.php - www/admin/error_test.php # admin synlink files - www/admin/edit_*.php @@ -37,10 +29,6 @@ parameters: # ignore admin header stuff # - www/includes/admin_header.php # ignore the admin include stuff - www/includes/admin_footer.php # ignore the admin include stuff - # deprecated files - - www/includes/admin_set_paths.php # ignore the admin include stuff - - www/includes/admin_smarty.php # ignore the admin include stuff - - www/includes/edit_base.LEGACY.php # old style # folders with data no check needed - www/templates_c - www/cache @@ -51,13 +39,9 @@ parameters: - www/vendor # ignore errores with ignoreErrors: - #- # this error is ignore because of the PHP 8.0 to 8.1 change for pg_*, only for 8.0 or lower - # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects resource(\\|null)?, object\\|resource(\\|bool)? given\\.$#" - # path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php - # - # this is for 8.1 or newer - # message: "#^Parameter \\#1 \\$(result|connection) of function pg_\\w+ expects PgSql\\\\(Result|Connection(\\|string)?(\\|null)?), object\\|resource given\\.$#" - # path: %currentWorkingDirectory%/www/lib/CoreLibs/DB/SQL/PgSQL.php - # this is ignored for now + - # in the class_test tree we allow deprecated calls + message: "#^Call to deprecated method #" + path: %currentWorkingDirectory%/www/admin/class_test.*.php # - '#Expression in empty\(\) is always falsy.#' # - # message: '#Reflection error: [a-zA-Z0-9\\_]+ not found.#' diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 2ca6bfbd..e258a565 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -14,8 +14,8 @@ return array( '76cd0796156622033397994f25b0d8fc' => $vendorDir . '/amphp/amp/lib/Internal/functions.php', '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', 'b6b991a57620e2fb6b2f66f03fe9ddc2' => $vendorDir . '/symfony/string/Resources/functions.php', - '6cd5651c4fef5ed6b63e8d8b8ffbf3cc' => $vendorDir . '/amphp/byte-stream/lib/functions.php', '9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php', + '6cd5651c4fef5ed6b63e8d8b8ffbf3cc' => $vendorDir . '/amphp/byte-stream/lib/functions.php', '2b9d0f43f9552984cfa82fee95491826' => $vendorDir . '/sabre/event/lib/coroutine.php', 'd81bab31d3feb45bfe2f283ea3c8fdf7' => $vendorDir . '/sabre/event/lib/Loop/functions.php', 'a1cce3d26cc15c00fcd0b3354bd72c88' => $vendorDir . '/sabre/event/lib/Promise/functions.php', diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 30309c4c..39e53205 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -28,6 +28,7 @@ return array( 'Phan\\' => array($vendorDir . '/phan/phan/src/Phan'), 'PackageVersions\\' => array($vendorDir . '/composer/package-versions-deprecated/src/PackageVersions'), 'PHPStan\\ExtensionInstaller\\' => array($vendorDir . '/phpstan/extension-installer/src'), + 'PHPStan\\' => array($vendorDir . '/phpstan/phpstan-deprecation-rules/src'), 'Microsoft\\PhpParser\\' => array($vendorDir . '/microsoft/tolerant-php-parser/src'), 'LanguageServerProtocol\\' => array($vendorDir . '/felixfbecker/language-server-protocol/src'), 'Fidry\\CpuCoreCounter\\' => array($vendorDir . '/fidry/cpu-core-counter/src'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 47a1f79d..f9cf85b5 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -15,8 +15,8 @@ class ComposerStaticInitdd705c6e8ab22e0d642372dec7767718 '76cd0796156622033397994f25b0d8fc' => __DIR__ . '/..' . '/amphp/amp/lib/Internal/functions.php', '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', 'b6b991a57620e2fb6b2f66f03fe9ddc2' => __DIR__ . '/..' . '/symfony/string/Resources/functions.php', - '6cd5651c4fef5ed6b63e8d8b8ffbf3cc' => __DIR__ . '/..' . '/amphp/byte-stream/lib/functions.php', '9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php', + '6cd5651c4fef5ed6b63e8d8b8ffbf3cc' => __DIR__ . '/..' . '/amphp/byte-stream/lib/functions.php', '2b9d0f43f9552984cfa82fee95491826' => __DIR__ . '/..' . '/sabre/event/lib/coroutine.php', 'd81bab31d3feb45bfe2f283ea3c8fdf7' => __DIR__ . '/..' . '/sabre/event/lib/Loop/functions.php', 'a1cce3d26cc15c00fcd0b3354bd72c88' => __DIR__ . '/..' . '/sabre/event/lib/Promise/functions.php', @@ -64,6 +64,7 @@ class ComposerStaticInitdd705c6e8ab22e0d642372dec7767718 'Phan\\' => 5, 'PackageVersions\\' => 16, 'PHPStan\\ExtensionInstaller\\' => 27, + 'PHPStan\\' => 8, ), 'M' => array ( @@ -182,6 +183,10 @@ class ComposerStaticInitdd705c6e8ab22e0d642372dec7767718 array ( 0 => __DIR__ . '/..' . '/phpstan/extension-installer/src', ), + 'PHPStan\\' => + array ( + 0 => __DIR__ . '/..' . '/phpstan/phpstan-deprecation-rules/src', + ), 'Microsoft\\PhpParser\\' => array ( 0 => __DIR__ . '/..' . '/microsoft/tolerant-php-parser/src', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 53e641da..a47ea436 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1212,6 +1212,57 @@ ], "install-path": "../phpstan/phpstan" }, + { + "name": "phpstan/phpstan-deprecation-rules", + "version": "1.1.2", + "version_normalized": "1.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan-deprecation-rules.git", + "reference": "bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan-deprecation-rules/zipball/bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865", + "reference": "bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-php-parser": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^9.5" + }, + "time": "2023-01-17T16:14:21+00:00", + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "support": { + "issues": "https://github.com/phpstan/phpstan-deprecation-rules/issues", + "source": "https://github.com/phpstan/phpstan-deprecation-rules/tree/1.1.2" + }, + "install-path": "../phpstan/phpstan-deprecation-rules" + }, { "name": "psr/container", "version": "2.0.2", @@ -2621,6 +2672,7 @@ "phpdocumentor/type-resolver", "phpstan/extension-installer", "phpstan/phpstan", + "phpstan/phpstan-deprecation-rules", "psr/container", "psr/log", "sabre/event", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 037198cb..4c12da7f 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -196,6 +196,15 @@ 'aliases' => array(), 'dev_requirement' => true, ), + 'phpstan/phpstan-deprecation-rules' => array( + 'pretty_version' => '1.1.2', + 'version' => '1.1.2.0', + 'reference' => 'bcc1e8cdf81c3da1a2ba9188ee94cd7e2a62e865', + 'type' => 'phpstan-extension', + 'install_path' => __DIR__ . '/../phpstan/phpstan-deprecation-rules', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'psalm/psalm' => array( 'dev_requirement' => true, 'provided' => array( diff --git a/vendor/phpstan/phpstan-deprecation-rules/.editorconfig b/vendor/phpstan/phpstan-deprecation-rules/.editorconfig new file mode 100644 index 00000000..5d66bc42 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/.editorconfig @@ -0,0 +1,27 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true + +[*.{php,phpt}] +indent_style = tab +indent_size = 4 + +[*.xml] +indent_style = tab +indent_size = 4 + +[*.neon] +indent_style = tab +indent_size = 4 + +[*.{yaml,yml}] +indent_style = space +indent_size = 2 + +[composer.json] +indent_style = tab +indent_size = 4 diff --git a/vendor/phpstan/phpstan-deprecation-rules/README.md b/vendor/phpstan/phpstan-deprecation-rules/README.md new file mode 100644 index 00000000..3a93df70 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/README.md @@ -0,0 +1,38 @@ +# Rules for detecting usage of deprecated classes, methods, properties, constants and traits. + +[![Build](https://github.com/phpstan/phpstan-deprecation-rules/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-deprecation-rules/actions) +[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-deprecation-rules/v/stable)](https://packagist.org/packages/phpstan/phpstan-deprecation-rules) +[![License](https://poser.pugx.org/phpstan/phpstan-deprecation-rules/license)](https://packagist.org/packages/phpstan/phpstan-deprecation-rules) + +* [PHPStan](https://phpstan.org/) + +## Installation + +To use this extension, require it in [Composer](https://getcomposer.org/): + +``` +composer require --dev phpstan/phpstan-deprecation-rules +``` + +If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set! + +
+ Manual installation + +If you don't want to use `phpstan/extension-installer`, include rules.neon in your project's PHPStan config: + +``` +includes: + - vendor/phpstan/phpstan-deprecation-rules/rules.neon +``` +
+ +## Deprecating code you don't own + +This extension emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as `@deprecated`. + +In case you don't own the code which you want to be considered deprecated, use [PHPStan Stub Files](https://phpstan.org/user-guide/stub-files) to declare deprecations for vendor files like: +``` +/** @deprecated */ +class ThirdPartyClass {} +``` diff --git a/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.json b/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.json new file mode 100644 index 00000000..e3079710 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.json @@ -0,0 +1,12 @@ +{ + "require-dev": { + "consistence-community/coding-standard": "^3.10", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "slevomat/coding-standard": "^7.0" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + } +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.lock b/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.lock new file mode 100644 index 00000000..4bcc8de4 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/build-cs/composer.lock @@ -0,0 +1,322 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "4485bbedba7bcc71ace5f69dbb9b6c47", + "packages": [], + "packages-dev": [ + { + "name": "consistence-community/coding-standard", + "version": "3.11.1", + "source": { + "type": "git", + "url": "https://github.com/consistence-community/coding-standard.git", + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consistence-community/coding-standard/zipball/4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "reference": "4632fead8c9ee8f50044fcbce9f66c797b34c0df", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "slevomat/coding-standard": "~7.0", + "squizlabs/php_codesniffer": "~3.6.0" + }, + "replace": { + "consistence/coding-standard": "3.10.*" + }, + "require-dev": { + "phing/phing": "2.16.4", + "php-parallel-lint/php-parallel-lint": "1.3.0", + "phpunit/phpunit": "9.5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Consistence\\": [ + "Consistence" + ] + }, + "classmap": [ + "Consistence" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "VaĊĦek Purchart", + "email": "me@vasekpurchart.cz", + "homepage": "http://vasekpurchart.cz" + } + ], + "description": "Consistence - Coding Standard - PHP Code Sniffer rules", + "keywords": [ + "Coding Standard", + "PHPCodeSniffer", + "codesniffer", + "coding", + "cs", + "phpcs", + "ruleset", + "sniffer", + "standard" + ], + "support": { + "issues": "https://github.com/consistence-community/coding-standard/issues", + "source": "https://github.com/consistence-community/coding-standard/tree/3.11.1" + }, + "time": "2021-05-03T18:13:22+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.2", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + }, + { + "name": "Contributors", + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2022-02-04T12:51:07+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "981cc368a216c988e862a75e526b6076987d1b50" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/981cc368a216c988e862a75e526b6076987d1b50", + "reference": "981cc368a216c988e862a75e526b6076987d1b50", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", + "symfony/process": "^5.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.5.1" + }, + "time": "2022-05-05T11:32:40+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "7.2.1", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.2 || ^8.0", + "phpstan/phpdoc-parser": "^1.5.1", + "squizlabs/php_codesniffer": "^3.6.2" + }, + "require-dev": { + "phing/phing": "2.17.3", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpstan/phpstan": "1.4.10|1.7.1", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0|1.1.1", + "phpstan/phpstan-strict-rules": "1.2.3", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2022-05-25T10:58:12+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5e4e71592f69da17871dba6e80dd51bce74a351a", + "reference": "5e4e71592f69da17871dba6e80dd51bce74a351a", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-12-12T21:44:58+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/composer.json b/vendor/phpstan/phpstan-deprecation-rules/composer.json new file mode 100644 index 00000000..0c115d77 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/composer.json @@ -0,0 +1,43 @@ +{ + "name": "phpstan/phpstan-deprecation-rules", + "type": "phpstan-extension", + "description": "PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.", + "license": [ + "MIT" + ], + "require": { + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.10" + }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-phpunit": "^1.0", + "phpstan/phpstan-php-parser": "^1.1", + "phpunit/phpunit": "^9.5" + }, + "config": { + "platform": { + "php": "7.4.6" + }, + "sort-packages": true + }, + "extra": { + "phpstan": { + "includes": [ + "rules.neon" + ] + } + }, + "autoload": { + "psr-4": { + "PHPStan\\": "src/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/rules.neon b/vendor/phpstan/phpstan-deprecation-rules/rules.neon new file mode 100644 index 00000000..9b63b386 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/rules.neon @@ -0,0 +1,24 @@ +parameters: + deprecationRulesInstalled: true + +services: + - + class: PHPStan\Rules\Deprecations\DeprecatedClassHelper + +rules: + - PHPStan\Rules\Deprecations\AccessDeprecatedPropertyRule + - PHPStan\Rules\Deprecations\AccessDeprecatedStaticPropertyRule + - PHPStan\Rules\Deprecations\CallToDeprecatedFunctionRule + - PHPStan\Rules\Deprecations\CallToDeprecatedMethodRule + - PHPStan\Rules\Deprecations\CallToDeprecatedStaticMethodRule + - PHPStan\Rules\Deprecations\FetchingClassConstOfDeprecatedClassRule + - PHPStan\Rules\Deprecations\FetchingDeprecatedConstRule + - PHPStan\Rules\Deprecations\ImplementationOfDeprecatedInterfaceRule + - PHPStan\Rules\Deprecations\InheritanceOfDeprecatedClassRule + - PHPStan\Rules\Deprecations\InheritanceOfDeprecatedInterfaceRule + - PHPStan\Rules\Deprecations\InstantiationOfDeprecatedClassRule + - PHPStan\Rules\Deprecations\TypeHintDeprecatedInClassMethodSignatureRule + - PHPStan\Rules\Deprecations\TypeHintDeprecatedInClosureSignatureRule + - PHPStan\Rules\Deprecations\TypeHintDeprecatedInFunctionSignatureRule + - PHPStan\Rules\Deprecations\UsageOfDeprecatedCastRule + - PHPStan\Rules\Deprecations\UsageOfDeprecatedTraitRule diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php new file mode 100644 index 00000000..3e1f88b9 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedPropertyRule.php @@ -0,0 +1,80 @@ + + */ +class AccessDeprecatedPropertyRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return PropertyFetch::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$node->name instanceof Identifier) { + return []; + } + + $propertyName = $node->name->name; + $propertyAccessedOnType = $scope->getType($node->var); + $referencedClasses = $propertyAccessedOnType->getObjectClassNames(); + + foreach ($referencedClasses as $referencedClass) { + try { + $classReflection = $this->reflectionProvider->getClass($referencedClass); + $propertyReflection = $classReflection->getProperty($propertyName, $scope); + + if ($propertyReflection->isDeprecated()->yes()) { + $description = $propertyReflection->getDeprecatedDescription(); + if ($description === null) { + return [sprintf( + 'Access to deprecated property $%s of class %s.', + $propertyName, + $propertyReflection->getDeclaringClass()->getName() + )]; + } + + return [sprintf( + "Access to deprecated property $%s of class %s:\n%s", + $propertyName, + $propertyReflection->getDeclaringClass()->getName(), + $description + )]; + } + } catch (ClassNotFoundException $e) { + // Other rules will notify if the class is not found + } catch (MissingPropertyFromReflectionException $e) { + // Other rules will notify if the property is not found + } + } + + return []; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php new file mode 100644 index 00000000..db128cc5 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/AccessDeprecatedStaticPropertyRule.php @@ -0,0 +1,106 @@ + + */ +class AccessDeprecatedStaticPropertyRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + /** @var RuleLevelHelper */ + private $ruleLevelHelper; + + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) + { + $this->reflectionProvider = $reflectionProvider; + $this->ruleLevelHelper = $ruleLevelHelper; + } + + public function getNodeType(): string + { + return StaticPropertyFetch::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$node->name instanceof Identifier) { + return []; + } + + $propertyName = $node->name->name; + $referencedClasses = []; + + if ($node->class instanceof Name) { + $referencedClasses[] = (string) $node->class; + } else { + $classTypeResult = $this->ruleLevelHelper->findTypeToCheck( + $scope, + $node->class, + '', // We don't care about the error message + static function (Type $type) use ($propertyName): bool { + return $type->canAccessProperties()->yes() && $type->hasProperty($propertyName)->yes(); + } + ); + + if ($classTypeResult->getType() instanceof ErrorType) { + return []; + } + + $referencedClasses = $classTypeResult->getReferencedClasses(); + } + + foreach ($referencedClasses as $referencedClass) { + try { + $class = $this->reflectionProvider->getClass($referencedClass); + $property = $class->getProperty($propertyName, $scope); + } catch (ClassNotFoundException $e) { + continue; + } catch (MissingPropertyFromReflectionException $e) { + continue; + } + + if ($property->isDeprecated()->yes()) { + $description = $property->getDeprecatedDescription(); + if ($description === null) { + return [sprintf( + 'Access to deprecated static property $%s of class %s.', + $propertyName, + $referencedClass + )]; + } + + return [sprintf( + "Access to deprecated static property $%s of class %s:\n%s", + $propertyName, + $referencedClass, + $description + )]; + } + } + + return []; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php new file mode 100644 index 00000000..f8ccefe0 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedFunctionRule.php @@ -0,0 +1,69 @@ + + */ +class CallToDeprecatedFunctionRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return FuncCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!($node->name instanceof Name)) { + return []; + } + + try { + $function = $this->reflectionProvider->getFunction($node->name, $scope); + } catch (FunctionNotFoundException $e) { + // Other rules will notify if the function is not found + return []; + } + + if ($function->isDeprecated()->yes()) { + $description = $function->getDeprecatedDescription(); + if ($description === null) { + return [sprintf( + 'Call to deprecated function %s().', + $function->getName() + )]; + } + + return [sprintf( + "Call to deprecated function %s():\n%s", + $function->getName(), + $description + )]; + } + + return []; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedMethodRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedMethodRule.php new file mode 100644 index 00000000..6ec4e0cd --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedMethodRule.php @@ -0,0 +1,82 @@ + + */ +class CallToDeprecatedMethodRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return MethodCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$node->name instanceof Identifier) { + return []; + } + + $methodName = $node->name->name; + $methodCalledOnType = $scope->getType($node->var); + $referencedClasses = $methodCalledOnType->getObjectClassNames(); + + foreach ($referencedClasses as $referencedClass) { + try { + $classReflection = $this->reflectionProvider->getClass($referencedClass); + $methodReflection = $classReflection->getMethod($methodName, $scope); + + if (!$methodReflection->isDeprecated()->yes()) { + continue; + } + + $description = $methodReflection->getDeprecatedDescription(); + if ($description === null) { + return [sprintf( + 'Call to deprecated method %s() of class %s.', + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName() + )]; + } + + return [sprintf( + "Call to deprecated method %s() of class %s:\n%s", + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName(), + $description + )]; + } catch (ClassNotFoundException $e) { + // Other rules will notify if the class is not found + } catch (MissingMethodFromReflectionException $e) { + // Other rules will notify if the the method is not found + } + } + + return []; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php new file mode 100644 index 00000000..8b7d995d --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/CallToDeprecatedStaticMethodRule.php @@ -0,0 +1,128 @@ + + */ +class CallToDeprecatedStaticMethodRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + /** @var RuleLevelHelper */ + private $ruleLevelHelper; + + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) + { + $this->reflectionProvider = $reflectionProvider; + $this->ruleLevelHelper = $ruleLevelHelper; + } + + public function getNodeType(): string + { + return StaticCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$node->name instanceof Identifier) { + return []; + } + + $methodName = $node->name->name; + $referencedClasses = []; + + if ($node->class instanceof Name) { + $referencedClasses[] = $scope->resolveName($node->class); + } else { + $classTypeResult = $this->ruleLevelHelper->findTypeToCheck( + $scope, + $node->class, + '', // We don't care about the error message + static function (Type $type) use ($methodName): bool { + return $type->canCallMethods()->yes() && $type->hasMethod($methodName)->yes(); + } + ); + + if ($classTypeResult->getType() instanceof ErrorType) { + return []; + } + + $referencedClasses = $classTypeResult->getReferencedClasses(); + } + + $errors = []; + + foreach ($referencedClasses as $referencedClass) { + try { + $class = $this->reflectionProvider->getClass($referencedClass); + $methodReflection = $class->getMethod($methodName, $scope); + } catch (ClassNotFoundException $e) { + continue; + } catch (MissingMethodFromReflectionException $e) { + continue; + } + + if ($class->isDeprecated()) { + $classDescription = $class->getDeprecatedDescription(); + if ($classDescription === null) { + $errors[] = sprintf( + 'Call to method %s() of deprecated class %s.', + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName() + ); + } else { + $errors[] = sprintf( + "Call to method %s() of deprecated class %s:\n%s", + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName(), + $classDescription + ); + } + } + + if (!$methodReflection->isDeprecated()->yes()) { + continue; + } + + $description = $methodReflection->getDeprecatedDescription(); + if ($description === null) { + $errors[] = sprintf( + 'Call to deprecated method %s() of class %s.', + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName() + ); + } else { + $errors[] = sprintf( + "Call to deprecated method %s() of class %s:\n%s", + $methodReflection->getName(), + $methodReflection->getDeclaringClass()->getName(), + $description + ); + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedClassHelper.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedClassHelper.php new file mode 100644 index 00000000..dbe2a542 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedClassHelper.php @@ -0,0 +1,64 @@ +reflectionProvider = $reflectionProvider; + } + + public function getClassType(ClassReflection $class): string + { + if ($class->isInterface()) { + return 'interface'; + } + + return 'class'; + } + + public function getClassDeprecationDescription(ClassReflection $class): string + { + $description = $class->getDeprecatedDescription(); + if ($description === null) { + return '.'; + } + + return sprintf(":\n%s", $description); + } + + /** + * @param string[] $referencedClasses + * @return ClassReflection[] + */ + public function filterDeprecatedClasses(array $referencedClasses): array + { + $deprecatedClasses = []; + foreach ($referencedClasses as $referencedClass) { + try { + $class = $this->reflectionProvider->getClass($referencedClass); + } catch (ClassNotFoundException $e) { + continue; + } + + if (!$class->isDeprecated()) { + continue; + } + + $deprecatedClasses[] = $class; + } + + return $deprecatedClasses; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedScopeHelper.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedScopeHelper.php new file mode 100644 index 00000000..6b19151e --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/DeprecatedScopeHelper.php @@ -0,0 +1,30 @@ +getClassReflection(); + if ($class !== null && $class->isDeprecated()) { + return true; + } + + $trait = $scope->getTraitReflection(); + if ($trait !== null && $trait->isDeprecated()) { + return true; + } + + $function = $scope->getFunction(); + if ($function !== null && $function->isDeprecated()->yes()) { + return true; + } + + return false; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php new file mode 100644 index 00000000..d9c47d55 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingClassConstOfDeprecatedClassRule.php @@ -0,0 +1,135 @@ + + */ +class FetchingClassConstOfDeprecatedClassRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + /** @var RuleLevelHelper */ + private $ruleLevelHelper; + + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) + { + $this->reflectionProvider = $reflectionProvider; + $this->ruleLevelHelper = $ruleLevelHelper; + } + + public function getNodeType(): string + { + return ClassConstFetch::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$node->name instanceof Identifier) { + return []; + } + + $constantName = $node->name->name; + $referencedClasses = []; + + if ($node->class instanceof Name) { + $referencedClasses[] = $scope->resolveName($node->class); + } else { + $classTypeResult = $this->ruleLevelHelper->findTypeToCheck( + $scope, + $node->class, + '', // We don't care about the error message + static function (Type $type) use ($constantName): bool { + return $type->canAccessConstants()->yes() && $type->hasConstant($constantName)->yes(); + } + ); + + if ($classTypeResult->getType() instanceof ErrorType) { + return []; + } + + $referencedClasses = $classTypeResult->getReferencedClasses(); + } + + $errors = []; + + foreach ($referencedClasses as $referencedClass) { + try { + $class = $this->reflectionProvider->getClass($referencedClass); + } catch (ClassNotFoundException $e) { + continue; + } + + if ($class->isDeprecated()) { + $classDescription = $class->getDeprecatedDescription(); + if ($classDescription === null) { + $errors[] = sprintf( + 'Fetching class constant %s of deprecated class %s.', + $constantName, + $referencedClass + ); + } else { + $errors[] = sprintf( + "Fetching class constant %s of deprecated class %s:\n%s", + $constantName, + $referencedClass, + $classDescription + ); + } + } + + if (strtolower($constantName) === 'class') { + continue; + } + + if (!$class->hasConstant($constantName)) { + continue; + } + + $constantReflection = $class->getConstant($constantName); + + if (!$constantReflection->isDeprecated()->yes()) { + continue; + } + + $description = $constantReflection->getDeprecatedDescription(); + if ($description === null) { + $errors[] = sprintf( + 'Fetching deprecated class constant %s of class %s.', + $constantName, + $referencedClass + ); + } else { + $errors[] = sprintf( + "Fetching deprecated class constant %s of class %s:\n%s", + $constantName, + $referencedClass, + $description + ); + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingDeprecatedConstRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingDeprecatedConstRule.php new file mode 100644 index 00000000..407f9046 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/FetchingDeprecatedConstRule.php @@ -0,0 +1,70 @@ + + */ +class FetchingDeprecatedConstRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + /** @var array */ + private $deprecatedConstants = []; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + + // phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed + if (PHP_VERSION_ID >= 70300) { + $this->deprecatedConstants['FILTER_FLAG_SCHEME_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.'; + $this->deprecatedConstants['FILTER_FLAG_HOST_REQUIRED'] = 'Use of constant %s is deprecated since PHP 7.3.'; + } + } + + public function getNodeType(): string + { + return ConstFetch::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if (!$this->reflectionProvider->hasConstant($node->name, $scope)) { + return []; + } + + $constantReflection = $this->reflectionProvider->getConstant($node->name, $scope); + + if ($constantReflection->isDeprecated()->yes()) { + return [sprintf( + $constantReflection->getDeprecatedDescription() ?? 'Use of constant %s is deprecated.', + $constantReflection->getName() + )]; + } + + if (isset($this->deprecatedConstants[$constantReflection->getName()])) { + return [sprintf( + $this->deprecatedConstants[$constantReflection->getName()], + $constantReflection->getName() + )]; + } + + return []; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php new file mode 100644 index 00000000..3b3cda05 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/ImplementationOfDeprecatedInterfaceRule.php @@ -0,0 +1,100 @@ + + */ +class ImplementationOfDeprecatedInterfaceRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return Class_::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $errors = []; + + $className = isset($node->namespacedName) + ? (string) $node->namespacedName + : (string) $node->name; + + try { + $class = $this->reflectionProvider->getClass($className); + } catch (ClassNotFoundException $e) { + return []; + } + + if ($class->isDeprecated()) { + return []; + } + + foreach ($node->implements as $implement) { + $interfaceName = (string) $implement; + + try { + $interface = $this->reflectionProvider->getClass($interfaceName); + + if ($interface->isDeprecated()) { + $description = $interface->getDeprecatedDescription(); + if (!$class->isAnonymous()) { + if ($description === null) { + $errors[] = sprintf( + 'Class %s implements deprecated interface %s.', + $className, + $interfaceName + ); + } else { + $errors[] = sprintf( + "Class %s implements deprecated interface %s:\n%s", + $className, + $interfaceName, + $description + ); + } + } else { + if ($description === null) { + $errors[] = sprintf( + 'Anonymous class implements deprecated interface %s.', + $interfaceName + ); + } else { + $errors[] = sprintf( + "Anonymous class implements deprecated interface %s:\n%s", + $interfaceName, + $description + ); + } + } + } + } catch (ClassNotFoundException $e) { + // Other rules will notify if the interface is not found + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php new file mode 100644 index 00000000..772cb1ed --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedClassRule.php @@ -0,0 +1,97 @@ + + */ +class InheritanceOfDeprecatedClassRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return Class_::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + if ($node->extends === null) { + return []; + } + + $errors = []; + + $className = isset($node->namespacedName) + ? (string) $node->namespacedName + : (string) $node->name; + + try { + $class = $this->reflectionProvider->getClass($className); + } catch (ClassNotFoundException $e) { + return []; + } + + $parentClassName = (string) $node->extends; + + try { + $parentClass = $this->reflectionProvider->getClass($parentClassName); + $description = $parentClass->getDeprecatedDescription(); + if ($parentClass->isDeprecated()) { + if (!$class->isAnonymous()) { + if ($description === null) { + $errors[] = sprintf( + 'Class %s extends deprecated class %s.', + $className, + $parentClassName + ); + } else { + $errors[] = sprintf( + "Class %s extends deprecated class %s:\n%s", + $className, + $parentClassName, + $description + ); + } + } else { + if ($description === null) { + $errors[] = sprintf( + 'Anonymous class extends deprecated class %s.', + $parentClassName + ); + } else { + $errors[] = sprintf( + "Anonymous class extends deprecated class %s:\n%s", + $parentClassName, + $description + ); + } + } + } + } catch (ClassNotFoundException $e) { + // Other rules will notify if the interface is not found + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php new file mode 100644 index 00000000..8acab060 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InheritanceOfDeprecatedInterfaceRule.php @@ -0,0 +1,87 @@ + + */ +class InheritanceOfDeprecatedInterfaceRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return Interface_::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if ($node->extends === null) { + return []; + } + + $interfaceName = isset($node->namespacedName) + ? (string) $node->namespacedName + : (string) $node->name; + + try { + $interface = $this->reflectionProvider->getClass($interfaceName); + } catch (ClassNotFoundException $e) { + return []; + } + + if ($interface->isDeprecated()) { + return []; + } + + $errors = []; + + foreach ($node->extends as $parentInterfaceName) { + $parentInterfaceName = (string) $parentInterfaceName; + + try { + $parentInterface = $this->reflectionProvider->getClass($parentInterfaceName); + + if (!$parentInterface->isDeprecated()) { + continue; + } + + $description = $parentInterface->getDeprecatedDescription(); + if ($description === null) { + $errors[] = sprintf( + 'Interface %s extends deprecated interface %s.', + $interfaceName, + $parentInterfaceName + ); + } else { + $errors[] = sprintf( + "Interface %s extends deprecated interface %s:\n%s", + $interfaceName, + $parentInterfaceName, + $description + ); + } + } catch (ClassNotFoundException $e) { + // Other rules will notify if the interface is not found + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php new file mode 100644 index 00000000..6450a100 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/InstantiationOfDeprecatedClassRule.php @@ -0,0 +1,104 @@ + + */ +class InstantiationOfDeprecatedClassRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + /** @var RuleLevelHelper */ + private $ruleLevelHelper; + + public function __construct(ReflectionProvider $reflectionProvider, RuleLevelHelper $ruleLevelHelper) + { + $this->reflectionProvider = $reflectionProvider; + $this->ruleLevelHelper = $ruleLevelHelper; + } + + public function getNodeType(): string + { + return New_::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $referencedClasses = []; + + if ($node->class instanceof Name) { + $referencedClasses[] = $scope->resolveName($node->class); + } elseif ($node->class instanceof Class_) { + if (!isset($node->class->namespacedName)) { + return []; + } + + $referencedClasses[] = $scope->resolveName($node->class->namespacedName); + } else { + $classTypeResult = $this->ruleLevelHelper->findTypeToCheck( + $scope, + $node->class, + '', // We don't care about the error message + static function (): bool { + return true; + } + ); + + if ($classTypeResult->getType() instanceof ErrorType) { + return []; + } + + $referencedClasses = $classTypeResult->getReferencedClasses(); + } + + $errors = []; + + foreach ($referencedClasses as $referencedClass) { + try { + $class = $this->reflectionProvider->getClass($referencedClass); + } catch (ClassNotFoundException $e) { + continue; + } + + if (!$class->isDeprecated()) { + continue; + } + + $description = $class->getDeprecatedDescription(); + if ($description === null) { + $errors[] = sprintf( + 'Instantiation of deprecated class %s.', + $referencedClass + ); + } else { + $errors[] = sprintf( + "Instantiation of deprecated class %s:\n%s", + $referencedClass, + $description + ); + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php new file mode 100644 index 00000000..f1165727 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClassMethodSignatureRule.php @@ -0,0 +1,92 @@ + + */ +class TypeHintDeprecatedInClassMethodSignatureRule implements Rule +{ + + /** @var DeprecatedClassHelper */ + private $deprecatedClassHelper; + + public function __construct(DeprecatedClassHelper $deprecatedClassHelper) + { + $this->deprecatedClassHelper = $deprecatedClassHelper; + } + + public function getNodeType(): string + { + return InClassMethodNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $method = $node->getMethodReflection(); + $methodSignature = ParametersAcceptorSelector::selectSingle($method->getVariants()); + + $errors = []; + foreach ($methodSignature->getParameters() as $parameter) { + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($parameter->getType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + if ($method->getDeclaringClass()->isAnonymous()) { + $errors[] = sprintf( + 'Parameter $%s of method %s() in anonymous class has typehint with deprecated %s %s%s', + $parameter->getName(), + $method->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } else { + $errors[] = sprintf( + 'Parameter $%s of method %s::%s() has typehint with deprecated %s %s%s', + $parameter->getName(), + $method->getDeclaringClass()->getName(), + $method->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + } + } + + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($methodSignature->getReturnType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + if ($method->getDeclaringClass()->isAnonymous()) { + $errors[] = sprintf( + 'Return type of method %s() in anonymous class has typehint with deprecated %s %s%s', + $method->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } else { + $errors[] = sprintf( + 'Return type of method %s::%s() has typehint with deprecated %s %s%s', + $method->getDeclaringClass()->getName(), + $method->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRule.php new file mode 100644 index 00000000..bfb83a11 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInClosureSignatureRule.php @@ -0,0 +1,69 @@ + + */ +class TypeHintDeprecatedInClosureSignatureRule implements Rule +{ + + /** @var DeprecatedClassHelper */ + private $deprecatedClassHelper; + + public function __construct(DeprecatedClassHelper $deprecatedClassHelper) + { + $this->deprecatedClassHelper = $deprecatedClassHelper; + } + + public function getNodeType(): string + { + return InClosureNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $functionSignature = $scope->getAnonymousFunctionReflection(); + if ($functionSignature === null) { + throw new ShouldNotHappenException(); + } + + $errors = []; + foreach ($functionSignature->getParameters() as $parameter) { + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($parameter->getType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + $errors[] = sprintf( + 'Parameter $%s of anonymous function has typehint with deprecated %s %s%s', + $parameter->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + } + + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($functionSignature->getReturnType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + $errors[] = sprintf( + 'Return type of anonymous function has typehint with deprecated %s %s%s', + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php new file mode 100644 index 00000000..9c91ec90 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/TypeHintDeprecatedInFunctionSignatureRule.php @@ -0,0 +1,73 @@ + + */ +class TypeHintDeprecatedInFunctionSignatureRule implements Rule +{ + + /** @var DeprecatedClassHelper */ + private $deprecatedClassHelper; + + public function __construct(DeprecatedClassHelper $deprecatedClassHelper) + { + $this->deprecatedClassHelper = $deprecatedClassHelper; + } + + public function getNodeType(): string + { + return InFunctionNode::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $function = $scope->getFunction(); + if ($function === null) { + throw new ShouldNotHappenException(); + } + $functionSignature = ParametersAcceptorSelector::selectSingle($function->getVariants()); + + $errors = []; + foreach ($functionSignature->getParameters() as $parameter) { + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($parameter->getType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + $errors[] = sprintf( + 'Parameter $%s of function %s() has typehint with deprecated %s %s%s', + $parameter->getName(), + $function->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + } + + $deprecatedClasses = $this->deprecatedClassHelper->filterDeprecatedClasses($functionSignature->getReturnType()->getReferencedClasses()); + foreach ($deprecatedClasses as $deprecatedClass) { + $errors[] = sprintf( + 'Return type of function %s() has typehint with deprecated %s %s%s', + $function->getName(), + $this->deprecatedClassHelper->getClassType($deprecatedClass), + $deprecatedClass->getName(), + $this->deprecatedClassHelper->getClassDeprecationDescription($deprecatedClass) + ); + } + + return $errors; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedCastRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedCastRule.php new file mode 100644 index 00000000..04ff91fe --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedCastRule.php @@ -0,0 +1,52 @@ + + */ +class UsageOfDeprecatedCastRule implements Rule +{ + + public function getNodeType(): string + { + return Cast::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $castedType = $scope->getType($node->expr); + if (! $castedType->hasMethod('__toString')->yes()) { + return []; + } + $method = $castedType->getMethod('__toString', $scope); + + if (! $method->isDeprecated()->yes()) { + return []; + } + $description = $method->getDeprecatedDescription(); + if ($description === null) { + return [sprintf( + 'Casting class %s to string is deprecated.', + $method->getDeclaringClass()->getName() + )]; + } + + return [sprintf( + "Casting class %s to string is deprecated.:\n%s", + $method->getDeclaringClass()->getName(), + $description + )]; + } + +} diff --git a/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php new file mode 100644 index 00000000..cd06f7a3 --- /dev/null +++ b/vendor/phpstan/phpstan-deprecation-rules/src/Rules/Deprecations/UsageOfDeprecatedTraitRule.php @@ -0,0 +1,79 @@ + + */ +class UsageOfDeprecatedTraitRule implements Rule +{ + + /** @var ReflectionProvider */ + private $reflectionProvider; + + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } + + public function getNodeType(): string + { + return TraitUse::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (DeprecatedScopeHelper::isScopeDeprecated($scope)) { + return []; + } + + $classReflection = $scope->getClassReflection(); + if ($classReflection === null) { + throw new ShouldNotHappenException(); + } + + $errors = []; + $className = $classReflection->getName(); + + foreach ($node->traits as $traitNameNode) { + $traitName = (string) $traitNameNode; + + try { + $trait = $this->reflectionProvider->getClass($traitName); + if (!$trait->isDeprecated()) { + continue; + } + + $description = $trait->getDeprecatedDescription(); + if ($description === null) { + $errors[] = sprintf( + 'Usage of deprecated trait %s in class %s.', + $traitName, + $className + ); + } else { + $errors[] = sprintf( + "Usage of deprecated trait %s in class %s:\n%s", + $traitName, + $className, + $description + ); + } + } catch (ClassNotFoundException $e) { + continue; + } + } + + return $errors; + } + +} diff --git a/www/admin/class_test.admin.backend.php b/www/admin/class_test.admin.backend.php index f325e065..a37fe5fe 100644 --- a/www/admin/class_test.admin.backend.php +++ b/www/admin/class_test.admin.backend.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + ob_start(); // basic class test file @@ -37,18 +39,17 @@ $log = new CoreLibs\Debug\Logging([ ]); // db config with logger $db = new CoreLibs\DB\IO(DB_CONFIG, $log); -$locale = \CoreLibs\Language\GetLocale::setLocale(); $l10n = new \CoreLibs\Language\L10n( - $locale['locale'], - $locale['domain'], - $locale['path'], + SITE_LOCALE, + SITE_DOMAIN, + BASE . INCLUDES . LOCALE, + SITE_ENCODING ); $backend = new CoreLibs\Admin\Backend( $db, $log, $session, $l10n, - $locale, DEFAULT_ACL_LEVEL ); use CoreLibs\Debug\Support; diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php index abc3f8bd..faa3677b 100644 --- a/www/admin/class_test.array.php +++ b/www/admin/class_test.array.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.autoloader.php b/www/admin/class_test.autoloader.php index c3e2e0bb..97835ec1 100644 --- a/www/admin/class_test.autoloader.php +++ b/www/admin/class_test.autoloader.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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 a7d8e7a7..1e5e0340 100644 --- a/www/admin/class_test.byte.php +++ b/www/admin/class_test.byte.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.check.colors.php b/www/admin/class_test.check.colors.php index 4fe36974..69b1195a 100644 --- a/www/admin/class_test.check.colors.php +++ b/www/admin/class_test.check.colors.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.config.direct.php b/www/admin/class_test.config.direct.php index a3c89b81..9653d4df 100644 --- a/www/admin/class_test.config.direct.php +++ b/www/admin/class_test.config.direct.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.config.link.php b/www/admin/class_test.config.link.php index 28aa233b..a1efad74 100644 --- a/www/admin/class_test.config.link.php +++ b/www/admin/class_test.config.link.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.convert.colors.php b/www/admin/class_test.convert.colors.php index fc0c27d2..e1b88241 100644 --- a/www/admin/class_test.convert.colors.php +++ b/www/admin/class_test.convert.colors.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.create_email.php b/www/admin/class_test.create_email.php index c48ebd3d..9ea99671 100644 --- a/www/admin/class_test.create_email.php +++ b/www/admin/class_test.create_email.php @@ -13,6 +13,8 @@ $PRINT_ALL = true; $ECHO_ALL = true; $DB_DEBUG = true; +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 7c2556ab..a723ca52 100644 --- a/www/admin/class_test.datetime.php +++ b/www/admin/class_test.datetime.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.debug.php b/www/admin/class_test.debug.php index bc42378d..2ab7dd5b 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -13,6 +13,8 @@ $PRINT_ALL = false; $ECHO_ALL = true; $DB_DEBUG = true; +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.email.php b/www/admin/class_test.email.php index 6751ff91..40d5c964 100644 --- a/www/admin/class_test.email.php +++ b/www/admin/class_test.email.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.encoding.php b/www/admin/class_test.encoding.php index 7bf1dcda..56193bbb 100644 --- a/www/admin/class_test.encoding.php +++ b/www/admin/class_test.encoding.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.file.php b/www/admin/class_test.file.php index b360054f..fa002b09 100644 --- a/www/admin/class_test.file.php +++ b/www/admin/class_test.file.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.hash.php b/www/admin/class_test.hash.php index 2fd40a04..78e47aa9 100644 --- a/www/admin/class_test.hash.php +++ b/www/admin/class_test.hash.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.html.php b/www/admin/class_test.html.php index ad8da3c0..368498f9 100644 --- a/www/admin/class_test.html.php +++ b/www/admin/class_test.html.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.image.php b/www/admin/class_test.image.php index 098b5d6f..43ca790d 100644 --- a/www/admin/class_test.image.php +++ b/www/admin/class_test.image.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.json.php b/www/admin/class_test.json.php index c07e3228..6b6f46a3 100644 --- a/www/admin/class_test.json.php +++ b/www/admin/class_test.json.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.lang.php b/www/admin/class_test.lang.php index 8524c501..622df97d 100644 --- a/www/admin/class_test.lang.php +++ b/www/admin/class_test.lang.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + ob_start(); // basic class test file @@ -54,20 +56,52 @@ echo "
AUTO DETECT
"; // DEPRECATED // $get_locale = Language\GetLocale::setLocale(); // print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "
"; -$get_locale = Language\GetLocale::setLocale( +$get_locale = Language\GetLocale::setLocaleFromSession( SITE_LOCALE, str_replace('/', '', CONTENT_PATH), - null, + '', BASE . INCLUDES . LOCALE ); print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "
"; -$get_locale = Language\GetLocale::setLocale( +$get_locale = Language\GetLocale::setLocaleFromSession( 'en', 'foo', 'ISO-8895', BASE . INCLUDES . LOCALE ); print "[OVERRIDE]: " . Support::printAr($get_locale) . "
"; +// must set session vars for setLangFromSession +// DEFAULT_LOCALE +// DEFAULT_DOMAIN +// DEFAULT_CHARSET (should be set from DEFAULT_LOCALE) +// LOCALE_PATH +$_SESSION['DEFAULT_LOCALE'] = 'ja_JP.UTF-8'; +$_SESSION['DEFAULT_CHARSET'] = 'UTF-8'; +$_SESSION['DEFAULT_DOMAIN'] = 'admin'; +$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE; +$get_locale = Language\GetLocale::setLocaleFromSession( + SITE_LOCALE, + SITE_DOMAIN, + SITE_ENCODING, + BASE . INCLUDES . LOCALE +); +print "[SESSION SET]: " . Support::printAr($get_locale) . "
"; +// must set session vars for setLangFromSession +// DEFAULT_LOCALE +// DEFAULT_DOMAIN +// DEFAULT_CHARSET (should be set from DEFAULT_LOCALE) +// LOCALE_PATH +$_SESSION['DEFAULT_LOCALE'] = '00000#####'; +$_SESSION['DEFAULT_CHARSET'] = ''; +$_SESSION['DEFAULT_DOMAIN'] = 'admin'; +$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE; +$get_locale = Language\GetLocale::setLocaleFromSession( + SITE_LOCALE, + SITE_DOMAIN, + SITE_ENCODING, + BASE . INCLUDES . LOCALE +); +print "[SESSION SET INVALID]: " . Support::printAr($get_locale) . "
"; // try to load non existing echo "
NEW TYPE
"; @@ -79,8 +113,8 @@ $domain = 'admin'; $encoding = 'UTF-8'; $path = BASE . INCLUDES . LOCALE; // load direct -$l = new L10n($lang, $domain, $path); -echo "*
"; +echo "* NEW CLASS SET
"; +$l = new L10n($lang, $domain, $path, $encoding); echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; echo "LANGUAGE FILE: " . $l->getMoFile() . "
"; @@ -105,10 +139,11 @@ for ($n = 0; $n <= 3; $n++) { echo "CONTEXT MULTI TEST $n: " . $single_string . "/" . $multi_string . " => " . $l->__np($context, $single_string, $multi_string, $n) . "
"; } +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; // change domain $domain = 'frontend'; +echo "* CHANGE DOMAIN $domain
"; $l->getTranslator('', $domain, $path); -echo "*
"; echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; echo "LANGUAGE FILE: " . $l->getMoFile() . "
"; @@ -118,11 +153,12 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "
"; echo "LOAD ERROR: " . $l->getLoadError() . "
"; echo "INPUT TEST: " . $string . " => " . $l->__($string) . "
"; echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "
"; +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; // change language short type $lang = 'en'; $domain = 'admin'; +echo "* CHANGE LANG $lang AND DOMAIN $domain
"; $l->getTranslator($lang, $domain, $path); -echo "*
"; echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; echo "LANGUAGE FILE: " . $l->getMoFile() . "
"; @@ -132,10 +168,24 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "
"; echo "LOAD ERROR: " . $l->getLoadError() . "
"; echo "INPUT TEST: " . $string . " => " . $l->__($string) . "
"; echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "
"; +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; +$encoding = 'SJIS'; +echo "* SET DIFFERENT CHARSET $encoding
"; +$l->getTranslator($lang, $domain, $path, $encoding); +echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; +echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; +echo "LANGUAGE FILE: " . $l->getMoFile() . "
"; +echo "CONTENT PATH: " . $l->getBaseContentPath() . "
"; +echo "DOMAIN PATH: " . $l->getTextDomain($domain) . "
"; +echo "BASE PATH: " . $l->getBaseLocalePath() . "
"; +echo "LOAD ERROR: " . $l->getLoadError() . "
"; +echo "INPUT TEST: " . $string . " => " . $l->__($string) . "
"; +echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "
"; +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; // chang to wrong language $lang = 'tr'; +echo "* CHANGE NOT FOUND LANG $lang
"; $l->getTranslator($lang, $domain, $path); -echo "*
"; echo "LANGUAGE WANT/SET: " . $lang . '/' . $l->getLocale() . "
"; echo "DOMAIN WANT/SET: " . $domain . '/' . $l->getDomain() . "
"; echo "LANGUAGE FILE: " . $l->getMoFile() . "
"; @@ -145,6 +195,25 @@ echo "BASE PATH: " . $l->getBaseLocalePath() . "
"; echo "LOAD ERROR: " . $l->getLoadError() . "
"; echo "INPUT TEST: " . $string . " => " . $l->__($string) . "
"; echo "TROUGH LOAD: " . $l->getTranslatorClass()->gettext($string) . "
"; +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; +// set different encoding +$lang = 'ja'; +$domain = 'admin'; +$encoding = 'SJIS'; +echo "* CLASS NEW LAUNCH: $lang / $encoding
"; +$path = BASE . INCLUDES . LOCALE; +// load direct +$l = new L10n($lang, $domain, $path, $encoding); +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; +// lang with full set +$lang = 'ja_JP.UTF-8'; +$domain = 'admin'; +$encoding = 'SJIS'; +echo "* CLASS NEW LAUNCH: $lang / $encoding
"; +$path = BASE . INCLUDES . LOCALE; +// load direct +$l = new L10n($lang, $domain, $path, $encoding); +echo "LOCALE: " . Support::printAr($l->getLocaleAsArray()) . "
"; $lang = 'en'; $domain = 'admin'; @@ -156,8 +225,10 @@ L10n::getInstance()->setDomain($domain); echo "SET DOMAIN: " . L10n::getInstance()->getDomain() . "
"; L10n::getInstance()->setTextDomain($domain, $path); echo "SET TEXT DOMAIN: " . L10n::getInstance()->getTextDomain($domain) . "
"; +// L10n::getInstance()->setOverrideEncoding('SJIS'); // null call __bind_textdomain_codeset echo "INPUT TEST: " . $string . " => " . L10n::getInstance()->getTranslator()->gettext($string) . "
"; +echo "LOCALE: " . Support::printAr(L10n::getInstance()->getLocaleAsArray()) . "
"; echo "
FUNCTIONS
"; // real statisc test diff --git a/www/admin/class_test.login.php b/www/admin/class_test.login.php index 89bed1b1..6525561d 100644 --- a/www/admin/class_test.login.php +++ b/www/admin/class_test.login.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + ob_start(); // basic class test file @@ -40,9 +42,10 @@ $login = new CoreLibs\ACL\Login( [ 'auto_login' => false, 'default_acl_level' => DEFAULT_ACL_LEVEL, - 'logout_target' => LOGOUT_TARGET, + 'logout_target' => '', 'site_locale' => SITE_LOCALE, 'site_domain' => SITE_DOMAIN, + 'site_encoding' => SITE_ENCODING, 'locale_path' => BASE . INCLUDES . LOCALE, ] ); @@ -63,6 +66,7 @@ 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 "LOCALE: " . \CoreLibs\Debug\Support::printAr($login->loginGetLocale()) . "
"; // error message print $log->printErrorMsg(); diff --git a/www/admin/class_test.math.php b/www/admin/class_test.math.php index 2adb3a0a..7175c596 100644 --- a/www/admin/class_test.math.php +++ b/www/admin/class_test.math.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.memoryusage.php b/www/admin/class_test.memoryusage.php index 2b77af97..f178fa11 100644 --- a/www/admin/class_test.memoryusage.php +++ b/www/admin/class_test.memoryusage.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.mime.php b/www/admin/class_test.mime.php index 00e5e878..798ddca7 100644 --- a/www/admin/class_test.mime.php +++ b/www/admin/class_test.mime.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.output.form.php b/www/admin/class_test.output.form.php index 0db332b7..47ec04cc 100644 --- a/www/admin/class_test.output.form.php +++ b/www/admin/class_test.output.form.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + ob_start(); // basic class test file @@ -63,22 +65,16 @@ $log = new CoreLibs\Debug\Logging([ 'echo_all' => $ECHO_ALL, 'print_all' => $PRINT_ALL, ]); -$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 + BASE . INCLUDES . LOCALE, + SITE_ENCODING ); $form = new CoreLibs\Output\Form\Generate( DB_CONFIG, $log, $l10n, - $locale, table_arrays: $table_arrays ); diff --git a/www/admin/class_test.password.php b/www/admin/class_test.password.php index 917ad288..73312bb2 100644 --- a/www/admin/class_test.password.php +++ b/www/admin/class_test.password.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.php b/www/admin/class_test.php index 3167b971..5fd5ec47 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -11,6 +11,7 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); ob_start(); @@ -35,17 +36,6 @@ $log = new CoreLibs\Debug\Logging([ 'print_all' => $PRINT_ALL, ]); $db = new CoreLibs\DB\IO(DB_CONFIG, $log); -$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'], -); $login = new CoreLibs\ACL\Login( $db, $log, @@ -53,18 +43,26 @@ $login = new CoreLibs\ACL\Login( [ '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'], + 'logout_target' => '', + 'site_locale' => SITE_LOCALE, + 'site_domain' => SITE_DOMAIN, + 'site_encoding' => SITE_ENCODING, + 'locale_path' => BASE . INCLUDES . LOCALE, ] ); +$locale = $login->loginGetLocale(); +$l10n = new \CoreLibs\Language\L10n( + $locale['locale'], + $locale['domain'], + $locale['path'], + $locale['encoding'], +); + $backend = new CoreLibs\Admin\Backend( $db, $log, $session, $l10n, - $locale, DEFAULT_ACL_LEVEL ); $backend->db->dbInfo(true); diff --git a/www/admin/class_test.phpv.php b/www/admin/class_test.phpv.php index 218ed8dd..20014b61 100644 --- a/www/admin/class_test.phpv.php +++ b/www/admin/class_test.phpv.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.randomkey.php b/www/admin/class_test.randomkey.php index 4c8560c5..5193374d 100644 --- a/www/admin/class_test.randomkey.php +++ b/www/admin/class_test.randomkey.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.runningtime.php b/www/admin/class_test.runningtime.php index ca821962..54220947 100644 --- a/www/admin/class_test.runningtime.php +++ b/www/admin/class_test.runningtime.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.session.php b/www/admin/class_test.session.php index 8e0836fe..116cc11c 100644 --- a/www/admin/class_test.session.php +++ b/www/admin/class_test.session.php @@ -7,6 +7,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + /** * Undocumented function * diff --git a/www/admin/class_test.session.read.php b/www/admin/class_test.session.read.php index adc7c323..6a8700b8 100644 --- a/www/admin/class_test.session.read.php +++ b/www/admin/class_test.session.read.php @@ -7,6 +7,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + /** * Undocumented function * diff --git a/www/admin/class_test.smarty.php b/www/admin/class_test.smarty.php index b880b3ee..ba536a46 100644 --- a/www/admin/class_test.smarty.php +++ b/www/admin/class_test.smarty.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); + ob_start(); // basic class test file @@ -33,15 +35,14 @@ $log = new CoreLibs\Debug\Logging([ 'echo_all' => $ECHO_ALL, 'print_all' => $PRINT_ALL, ]); -$locale = \CoreLibs\Language\GetLocale::setLocale(); $l10n = new \CoreLibs\Language\L10n( - $locale['locale'], - $locale['domain'], - $locale['path'], + SITE_LOCALE, + SITE_DOMAIN, + BASE . INCLUDES . LOCALE, + SITE_ENCODING ); $smarty = new CoreLibs\Template\SmartyExtend( $l10n, - $locale, CACHE_ID, COMPILE_ID, ); diff --git a/www/admin/class_test.strings.php b/www/admin/class_test.strings.php index 353c7131..ae302fa5 100644 --- a/www/admin/class_test.strings.php +++ b/www/admin/class_test.strings.php @@ -7,6 +7,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.system.php b/www/admin/class_test.system.php index 362e6a11..fa92d68e 100644 --- a/www/admin/class_test.system.php +++ b/www/admin/class_test.system.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.token.php b/www/admin/class_test.token.php index d9aa1425..38c5f9da 100644 --- a/www/admin/class_test.token.php +++ b/www/admin/class_test.token.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.uids.php b/www/admin/class_test.uids.php index c4ea25be..04162765 100644 --- a/www/admin/class_test.uids.php +++ b/www/admin/class_test.uids.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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.varistype.php b/www/admin/class_test.varistype.php index c492d059..9ea875ff 100644 --- a/www/admin/class_test.varistype.php +++ b/www/admin/class_test.varistype.php @@ -11,6 +11,8 @@ $DEBUG_ALL = true; $PRINT_ALL = true; $DB_DEBUG = true; +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/subfolder/class_test.config.direct.php b/www/admin/subfolder/class_test.config.direct.php index d526f348..3b9bcbf8 100644 --- a/www/admin/subfolder/class_test.config.direct.php +++ b/www/admin/subfolder/class_test.config.direct.php @@ -11,9 +11,7 @@ $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); -} +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); ob_start(); @@ -31,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: CONFIG DIRECT SUB'; @@ -47,7 +45,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/edit_groups_test.php b/www/admin/test_edit_base.php similarity index 72% rename from www/admin/edit_groups_test.php rename to www/admin/test_edit_base.php index d9465fe0..eb429e6d 100644 --- a/www/admin/edit_groups_test.php +++ b/www/admin/test_edit_base.php @@ -9,9 +9,7 @@ $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); -} +error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); ob_start(); @@ -31,17 +29,31 @@ $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(); +$login = new CoreLibs\ACL\Login( + $db, + $log, + $session, + [ + 'auto_login' => true, + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'logout_target' => '', + 'site_locale' => SITE_LOCALE, + 'site_domain' => SITE_DOMAIN, + 'site_encoding' => SITE_ENCODING, + 'locale_path' => BASE . INCLUDES . LOCALE, + ] +); +$locale = $login->loginGetLocale(); $l10n = new \CoreLibs\Language\L10n( $locale['locale'], $locale['domain'], $locale['path'], + $locale['encoding'] ); print ""; diff --git a/www/includes/admin_header.php b/www/includes/admin_header.php index c5ff0681..7ba8f52f 100644 --- a/www/includes/admin_header.php +++ b/www/includes/admin_header.php @@ -74,20 +74,35 @@ if ( // db config with logger $db = new \CoreLibs\DB\IO(DB_CONFIG, $log); // login & page access check -$login = new \CoreLibs\ACL\Login($db, $log, $session); +$login = new \CoreLibs\ACL\Login( + $db, + $log, + $session, + [ + 'auto_login' => true, + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'logout_target' => '', + 'site_locale' => SITE_LOCALE, + 'site_domain' => SITE_DOMAIN, + 'site_encoding' => SITE_ENCODING, + 'locale_path' => BASE . INCLUDES . LOCALE, + ] +); // lang, path, domain // pre auto detect language after login -$locale = \CoreLibs\Language\GetLocale::setLocale(); +$locale = $login->loginGetLocale(); // set lang and pass to smarty/backend $l10n = new \CoreLibs\Language\L10n( $locale['locale'], $locale['domain'], $locale['path'], + $locale['encoding'] ); + // create smarty object -$smarty = new \CoreLibs\Template\SmartyExtend($l10n, $locale); +$smarty = new \CoreLibs\Template\SmartyExtend($l10n, CACHE_ID, COMPILE_ID); // create new Backend class with db and loger attached -$cms = new \CoreLibs\Admin\Backend($db, $log, $session, $l10n, $locale); +$cms = new \CoreLibs\Admin\Backend($db, $log, $session, $l10n, DEFAULT_ACL_LEVEL); // the menu show flag (what menu to show) $cms->menu_show_flag = 'main'; // db info diff --git a/www/includes/edit_base.php b/www/includes/edit_base.php index 56df68bb..6834ab54 100644 --- a/www/includes/edit_base.php +++ b/www/includes/edit_base.php @@ -43,23 +43,46 @@ $log = new CoreLibs\Debug\Logging([ // db connection $db = new CoreLibs\DB\IO(DB_CONFIG, $log); // login page -$login = new CoreLibs\ACL\Login($db, $log, $session); +$login = new CoreLibs\ACL\Login( + $db, + $log, + $session, + [ + 'auto_login' => true, + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'logout_target' => '', + 'site_locale' => SITE_LOCALE, + 'site_domain' => SITE_DOMAIN, + 'site_encoding' => SITE_ENCODING, + 'locale_path' => BASE . INCLUDES . LOCALE, + ] +); // space for setting special debug flags // $login->log->setLogLevelAll('debug', true); // lang, path, domain // pre auto detect language after login -$locale = \CoreLibs\Language\GetLocale::setLocale(); +$locale = $login->loginGetLocale(); // set lang and pass to smarty/backend $l10n = new \CoreLibs\Language\L10n( $locale['locale'], $locale['domain'], $locale['path'], + $locale['encoding'] ); // flush and start ob_end_flush(); // init smarty and form class -$edit_base = new CoreLibs\Admin\EditBase(DB_CONFIG, $log, $l10n, $locale); +$edit_base = new CoreLibs\Admin\EditBase( + DB_CONFIG, + $log, + $l10n, + [ + 'default_acl_level' => DEFAULT_ACL_LEVEL, + 'cache_id' => CACHE_ID, + 'compile_id' => COMPILE_ID + ] +); // creates edit pages and runs actions $edit_base->editBaseRun( BASE . INCLUDES . TEMPLATES . CONTENT_PATH, diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php index b7e490e5..4d8d795a 100644 --- a/www/lib/CoreLibs/ACL/Login.php +++ b/www/lib/CoreLibs/ACL/Login.php @@ -196,7 +196,12 @@ class Login /** @var array options */ private $options = []; /** @var array locale options: locale, domain, encoding (opt), path */ - private $locale = []; + private $locale = [ + 'locale' => '', + 'domain' => '', + 'encoding' => '', + 'path' => '', + ]; /** @var \CoreLibs\Debug\Logging logger */ public $log; @@ -555,12 +560,12 @@ class Login ); // set path $options['locale_path'] = BASE . INCLUDES . LOCALE; - $_SESSION['LOCALE_PATH'] = $options['locale_path']; } + $_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', + 'loginMainCall: SITE_LOCALE should not be used', E_USER_DEPRECATED ); $options['site_locale'] = defined('SITE_LOCALE') && !empty(SITE_LOCALE) ? @@ -580,7 +585,6 @@ class Login ); // set domain $options['site_domain'] = SITE_DOMAIN; - $_SESSION['DEFAULT_DOMAIN'] = $options['site_domain']; } elseif ( defined('CONTENT_PATH') ) { @@ -592,6 +596,16 @@ class Login $options['set_domain'] = str_replace(DIRECTORY_SEPARATOR, '', CONTENT_PATH); } } + $_SESSION['DEFAULT_DOMAIN'] = $options['site_domain']; + // LANG: ENCODING + if (empty($options['site_encoding'])) { + trigger_error( + 'loginMainCall: SITE_ENCODING should not be used', + E_USER_DEPRECATED + ); + $options['site_encoding'] = defined('SITE_ENCODING') && !empty(SITE_ENCODING) ? + SITE_ENCODING : 'UTF-8'; + } // write array to options $this->options = $options; @@ -905,6 +919,7 @@ class Login // rgb: nnn.n for each // hsl: nnn.n for first, nnn.n% for 2nd, 3rd // Check\Colors::validateColor() + // LANGUAGE/LOCALE/ENCODING: $_SESSION['LANG'] = $res['locale'] ?? 'en'; $_SESSION['DEFAULT_CHARSET'] = $res['encoding'] ?? 'UTF-8'; $_SESSION['DEFAULT_LOCALE'] = $_SESSION['LANG'] @@ -1195,7 +1210,8 @@ class Login } /** - * set locale and load mo translator + * set locale + * if invalid, set to empty string * * @return void */ @@ -1204,22 +1220,52 @@ class Login // ** LANGUAGE SET AFTER LOGIN ** // set the locale if ( - !empty($_SESSION['DEFAULT_LOCALE']) + !empty($_SESSION['DEFAULT_LOCALE']) && + preg_match("/^[-A-Za-z0-9_.@]+$/", $_SESSION['DEFAULT_LOCALE']) ) { $locale = $_SESSION['DEFAULT_LOCALE']; - } else { + } elseif ( + !preg_match("/^[-A-Za-z0-9_.@]+$/", $this->options['site_locale']) + ) { $locale = $this->options['site_locale']; + } else { + $locale = ''; } + // set the charset + preg_match('/(?:\\.(?P[-A-Za-z0-9_]+))/', $locale, $matches); + $locale_encoding = $matches['charset'] ?? ''; + if (!empty($locale_encoding)) { + $encoding = strtoupper($locale_encoding); + } elseif ( + !empty($_SESSION['DEFAULT_CHARSET']) && + preg_match("/^[-A-Za-z0-9_]+$/", $_SESSION['DEFAULT_CHARSET']) + ) { + $encoding = $_SESSION['DEFAULT_CHARSET']; + } elseif ( + !preg_match("/^[-A-Za-z0-9_]+$/", $this->options['site_encoding']) + ) { + $encoding = $this->options['site_encoding']; + } else { + $encoding = ''; + } + // check domain + $domain = $this->options['site_domain']; + if ( + !preg_match("/^\w+$/", $this->options['site_domain']) + ) { + $domain = ''; + } + $path = $this->options['locale_path']; + if (!is_dir($path)) { + $path = ''; + } + // domain and path are a must set from class options $this->locale = [ 'locale' => $locale, - 'domain' => $this->options['site_domain'], - 'path' => $this->options['locale_path'], + 'domain' => $domain, + 'encoding' => $encoding, + 'path' => $path, ]; - $this->l = new \CoreLibs\Language\L10n( - $this->locale['locale'], - $this->locale['domain'], - $this->locale['path'] - ); } /** @@ -1824,6 +1870,12 @@ EOM; $this->loginLogoutUser(); // ** LANGUAGE SET AFTER LOGIN ** $this->loginSetLocale(); + // load translator + $this->l = new \CoreLibs\Language\L10n( + $this->locale['locale'], + $this->locale['domain'], + $this->locale['path'] + ); // if the password change flag is okay, run the password change method if ($this->password_change) { $this->loginPasswordChange(); @@ -2396,6 +2448,22 @@ EOM; ): bool|string { return $this->loginGetEditAccessData($edit_access_id, $data_key); } + + /** + * Return locale settings with + * locale + * domain + * encoding + * path + * + * empty string if not set + * + * @return array Locale settings + */ + public function loginGetLocale(): array + { + return $this->locale; + } } // __END__ diff --git a/www/lib/CoreLibs/Admin/Backend.php b/www/lib/CoreLibs/Admin/Backend.php index 3f03a463..2ea48041 100644 --- a/www/lib/CoreLibs/Admin/Backend.php +++ b/www/lib/CoreLibs/Admin/Backend.php @@ -121,14 +121,13 @@ class Backend * @param \CoreLibs\Debug\Logging $log Logging class * @param \CoreLibs\Create\Session $session Session interface class * @param \CoreLibs\Language\L10n $l10n l10n language class - * @param array $locale locale data read from setLocale + * @param int|null $set_default_acl_level Default ACL level */ public function __construct( \CoreLibs\DB\IO $db, \CoreLibs\Debug\Logging $log, \CoreLibs\Create\Session $session, \CoreLibs\Language\L10n $l10n, - array $locale, ?int $set_default_acl_level = null ) { // attach db class @@ -142,12 +141,12 @@ class Backend // get the language sub class & init it $this->l = $l10n; // parse and read, legacy stuff + $locale = $this->l->getLocaleAsArray(); $this->encoding = $locale['encoding']; $this->lang = $locale['lang']; - // get first part from lang - $this->lang_short = explode('_', $locale['lang'])[0]; - $this->domain = $this->l->getDomain(); - $this->lang_dir = $this->l->getBaseLocalePath(); + $this->lang_short = $locale['lang_short']; + $this->domain = $locale['domain']; + $this->lang_dir = $locale['path']; // set the page name $this->page_name = \CoreLibs\Get\System::getPageName(); diff --git a/www/lib/CoreLibs/Admin/EditBase.php b/www/lib/CoreLibs/Admin/EditBase.php index 30f71c91..c96786c4 100644 --- a/www/lib/CoreLibs/Admin/EditBase.php +++ b/www/lib/CoreLibs/Admin/EditBase.php @@ -42,18 +42,21 @@ class EditBase * @param array $db_config db config array, mandatory * @param \CoreLibs\Debug\Logging $log Logging class, null auto set * @param \CoreLibs\Language\L10n $l10n l10n language class, null auto set - * @param array $locale locale array from ::setLocale, - * null auto set + * @param array $options Various settings options */ public function __construct( array $db_config, \CoreLibs\Debug\Logging $log, \CoreLibs\Language\L10n $l10n, - array $locale + array $options ) { $this->log = $log; // smarty template engine (extended Translation version) - $this->smarty = new \CoreLibs\Template\SmartyExtend($l10n, $locale); + $this->smarty = new \CoreLibs\Template\SmartyExtend( + $l10n, + $options['cache_id'] ?? '', + $options['compile_id'] ?? '', + ); // turn off set log per class $log->setLogPer('class', false); @@ -61,8 +64,7 @@ class EditBase $this->form = new \CoreLibs\Output\Form\Generate( $db_config, $log, - $l10n, - $locale + $l10n ); if ($this->form->mobile_phone) { echo "I am sorry, but this page cannot be viewed by a mobile phone"; @@ -574,7 +576,7 @@ class EditBase $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_js = $set_js ?? LAYOUT . JS; $set_root = $set_root ?? ROOT; $set_content_path = $set_content_path ?? CONTENT_PATH; diff --git a/www/lib/CoreLibs/Language/GetLocale.php b/www/lib/CoreLibs/Language/GetLocale.php index f10dc4d3..1f7842fc 100644 --- a/www/lib/CoreLibs/Language/GetLocale.php +++ b/www/lib/CoreLibs/Language/GetLocale.php @@ -21,6 +21,7 @@ class GetLocale * @param string|null $encoding override encoding * @param string|null $path override path * @return array locale, domain, encoding, path + * @deprecated use GetLocale::setLocaleSession(...) instead */ public static function setLocale( ?string $locale = null, @@ -28,6 +29,10 @@ class GetLocale ?string $encoding = null, ?string $path = null ): array { + trigger_error( + 'Use \CoreLibs\Language\GetLocale::setLocaleSession(...) instead', + E_USER_DEPRECATED + ); // locale must match at least basic rules if ( empty($locale) || @@ -137,6 +142,113 @@ class GetLocale 'path' => $path, ]; } + + /** + * NOTE: For getting the login info via login class use ->loginGetLocale() + * + * Set locale from session or from override parameters + * This is the prefered version to setLocale + * It usese the following SESSION VARIABLES + * DEFAULT_LOCALE + * DEFAULT_DOMAIN + * DEFAULT_CHARSET (should be set from DEFAULT_LOCALE) + * LOCALE_PATH + * in the return array, null set invalid information + * + * @param string $locale override locale + * @param string $domain override domain + * @param string $encoding override encoding + * @param string $path override path + * @return array locale, domain, encoding, path + * @return array Return list of set locale information + * @deprecated This version will be removed in a future version use ACL\Login->loginGetLocale() instead + */ + public static function setLocaleFromSession( + string $locale, + string $domain, + string $encoding, + string $path + ): array { + // locale must match at least basic rules + if ( + !empty($_SESSION['DEFAULT_LOCALE']) && + preg_match("/^[-A-Za-z0-9_.@]+$/", $_SESSION['DEFAULT_LOCALE']) + ) { + // parse from session (logged in) + $locale = $_SESSION['DEFAULT_LOCALE']; + } elseif ( + empty($locale) || + !preg_match("/^[-A-Za-z0-9_.@]+$/", $locale) + ) { + $locale = null; + } + // if domain is set, must be alphanumeric, if not unset + if ( + !empty($_SESSION['DEFAULT_DOMAIN']) && + preg_match("/^\w+$/", $_SESSION['DEFAULT_DOMAIN']) + ) { + $domain = $_SESSION['DEFAULT_DOMAIN']; + } elseif ( + empty($domain) || + !preg_match("/^\w+$/", $domain) + ) { + $domain = null; + } + // check that override encoding matches locale encoding + // if locale encoding is set + preg_match('/(?:\\.(?P[-A-Za-z0-9_]+))/', $locale ?? '', $matches); + $locale_encoding = $matches['charset'] ?? null; + if (!empty($locale_encoding)) { + $encoding = strtoupper($locale_encoding); + } elseif ( + !empty($_SESSION['DEFAULT_CHARSET']) && + preg_match("/^[-A-Za-z0-9_]+$/", $_SESSION['DEFAULT_CHARSET']) + ) { + $encoding = $_SESSION['DEFAULT_CHARSET']; + } elseif ( + empty($encoding) || + // not valid encoding + !preg_match("/^[-A-Za-z0-9_]+$/", $encoding) + ) { + $encoding = null; + } + // path checks if set, if not valid path unset to default BASE path + if ( + !empty($_SESSION['LOCALE_PATH']) && + is_dir($_SESSION['LOCALE_PATH']) + ) { + $path = $_SESSION['LOCALE_PATH']; + } elseif ( + empty($path) || + !is_dir($path) + ) { + $path = null; + } + // extract lang & country from locale string, else set to en + if ( + preg_match( + // lang + '/^(?P[a-z]{2,3})' + // country code + . '(?:_(?P[A-Z]{2}))?/', + $locale ?? '', + $matches + ) + ) { + $lang = ($matches['lang'] ?? 'en') + // add country only if set + . (!empty($matches['country']) ? '_' . $matches['country'] : ''); + } else { + $lang = null; + } + return [ + 'locale' => $locale, + 'lang' => $lang, + 'domain' => $domain, + 'encoding' => $encoding, + 'path' => $path, + ]; + } } // __END__ diff --git a/www/lib/CoreLibs/Language/L10n.php b/www/lib/CoreLibs/Language/L10n.php index 09c2cae5..75db228a 100644 --- a/www/lib/CoreLibs/Language/L10n.php +++ b/www/lib/CoreLibs/Language/L10n.php @@ -32,12 +32,18 @@ use CoreLibs\Language\Core\GetTextReader; class L10n { + /** @var string the default fallback encoding if nothing is set */ + public const DEFAULT_CHARSET = 'UTF-8'; /** @var string the current locale */ private $locale = ''; /** @var string the SET locale as WHERE the domain file is */ private $locale_set = ''; /** @var string the default selected/active domain */ private $domain = ''; + /** @var string encoding, as from locale or set from outside */ + private $override_encoding = self::DEFAULT_CHARSET; + /** @var string encoding set during the parse Locale */ + private $encoding = ''; /** @var array> locale > domain = translator */ private $domains = []; /** @var array bound paths for domains */ @@ -71,15 +77,18 @@ class L10n * if locale is not empty will load translation * else getTranslator needs to be called * - * @param string $locale language name, default empty string - * will return self instance - * @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, default empty string + * will return self instance + * @param string $domain override CONTENT_PATH . $encoding name for mo file + * @param string $path path, if empty fallback on default internal path + * @param string $encoding Optional encoding, should be set if locale has + * no encoding, defaults to UTF-8 */ public function __construct( string $locale = '', string $domain = '', - string $path = '' + string $path = '', + string $encoding = '' ) { // auto load language only if at least locale and domain is set // New: path must be set too, or we fall through @@ -103,7 +112,7 @@ class L10n $path = $domain; $domain = $_domain; } - $this->getTranslator($locale, $domain, $path); + $this->getTranslator($locale, $domain, $path, $encoding); } } @@ -137,13 +146,15 @@ class L10n * * @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 + * @param string $path path, if not set try to get from paths array, else self + * @param string $override_encoding if locale does not env encoding set, use this one * @return GetTextReader the main gettext reader object */ public function getTranslator( string $locale = '', string $domain = '', - string $path = '' + string $path = '', + string $override_encoding = '', ): GetTextReader { // set local if not from parameter if (empty($locale)) { @@ -153,11 +164,16 @@ class L10n if (empty($domain)) { $domain = $this->domain; } + // override encoding for unset + if (!empty($override_encoding)) { + $this->override_encoding = $override_encoding; + } // store old settings $old_mofile = $this->mofile; $old_lang = $this->locale; $old_lang_set = $this->locale_set; $old_domain = $this->domain; + $old_encoding = $this->encoding; $old_base_locale_path = $this->base_locale_path; $old_base_content_path = $this->base_content_path; @@ -186,6 +202,7 @@ class L10n // now we loop over lang compositions to get the base path // then we check $locales = $this->listLocales($locale); + $encoding = $this->getEncodingFromLocale($locale); foreach ($locales as $_locale) { $this->base_content_path = $_locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; @@ -202,6 +219,7 @@ class L10n if (is_readable($this->mofile)) { // locale and domain current wanted $this->locale = $locale; + $this->encoding = $encoding; $this->domain = $domain; // set empty domains path with current locale if (empty($this->domains[$locale])) { @@ -225,6 +243,7 @@ class L10n $this->mofile = $old_mofile; $this->locale = $old_lang; $this->locale_set = $old_lang_set; + $this->encoding = $old_encoding; $this->domain = $old_domain; $this->base_locale_path = $old_base_locale_path; $this->base_content_path = $old_base_content_path; @@ -258,21 +277,36 @@ class L10n return $this->l10n; } + /** + * Extract encoding from Locale, or fallback to override one if not set + * + * @param string $locale + * @return string + */ + private function getEncodingFromLocale(string $locale): string + { + // extract charset from $locale + // if not set get override encoding + preg_match('/(?:\\.(?P[-A-Za-z0-9_]+))/', $locale, $matches); + return $matches['charset'] ?? $this->override_encoding; + } + /** * 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} + * @return array{locale: string, lang: string, lang_short: string, domain: string, encoding: string, path: string} */ public function getLocaleAsArray(): array { $locale = L10n::parseLocale($this->getLocale()); return [ 'locale' => $this->getLocale(), - 'lang' => $locale['lang'] + 'lang' => ($locale['lang'] ?? '') . (!empty($locale['country']) ? '_' . $locale['country'] : ''), + 'lang_short' => $locale['lang'] ?? '', 'domain' => $this->getDomain(), - 'encoding' => $locale['charset'], + 'encoding' => $this->getEncoding(), 'path' => $this->getBaseLocalePath(), ]; } @@ -515,6 +549,37 @@ class L10n return $this->locale_set; } + /** + * Set override encoding + * + * @param string $encoding + * @return void + */ + public function setOverrideEncoding(string $encoding): void + { + $this->override_encoding = $encoding; + } + + /** + * return current set override encoding + * + * @return string + */ + public function getOverrideEncoding(): string + { + return $this->override_encoding; + } + + /** + * Current set encoding + * + * @return string + */ + public function getEncoding(): string + { + return $this->encoding; + } + /** * get current set language * diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index 9c33aa1d..8014141b 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -308,7 +308,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO * @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 @@ -318,7 +317,6 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO array $db_config, \CoreLibs\Debug\Logging $log, \CoreLibs\Language\L10n $l10n, - array $locale, ?array $table_arrays = null, ) { // init logger if not set @@ -327,13 +325,13 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->log->setLogPer('class', false); // init the language class $this->l = $l10n; - // legacy lang vars set + // parse and read, legacy stuff + $locale = $this->l->getLocaleAsArray(); $this->encoding = $locale['encoding']; $this->lang = $locale['lang']; - // get first part from lang - $this->lang_short = explode('_', $locale['lang'])[0]; - $this->domain = $this->l->getDomain(); - $this->lang_dir = $this->l->getBaseLocalePath(); + $this->lang_short = $locale['lang_short']; + $this->domain = $locale['domain']; + $this->lang_dir = $locale['path']; // load config array // get table array definitions for current page name diff --git a/www/lib/CoreLibs/Template/SmartyExtend.php b/www/lib/CoreLibs/Template/SmartyExtend.php index 6e87d9e3..981c7fec 100644 --- a/www/lib/CoreLibs/Template/SmartyExtend.php +++ b/www/lib/CoreLibs/Template/SmartyExtend.php @@ -160,13 +160,11 @@ class SmartyExtend extends \Smarty * also registers the getvar caller plugin * * @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, ?string $cache_id = null, ?string $compile_id = null ) { @@ -192,13 +190,12 @@ class SmartyExtend extends \Smarty // iinit lang $this->l10n = $l10n; // parse and read, legacy stuff + $locale = $this->l10n->getLocaleAsArray(); $this->encoding = $locale['encoding']; $this->lang = $locale['lang']; - // get first part from lang - $this->lang_short = explode('_', $locale['lang'])[0]; - $this->domain = $this->l10n->getDomain(); - $this->locale_set = $this->l10n->getLocaleSet(); - $this->lang_dir = $this->l10n->getBaseLocalePath(); + $this->lang_short = $locale['lang_short']; + $this->domain = $locale['domain']; + $this->lang_dir = $locale['path']; // opt load functions so we can use legacy init for smarty run perhaps \CoreLibs\Language\L10n::loadFunctions();