Use anonymous functions instead of create_function

Adds PHP 8.1.x compatability
This commit is contained in:
celestora 2022-08-19 16:40:03 +03:00
parent c98841af56
commit e3706234e7
3 changed files with 51 additions and 50 deletions

View File

@ -68,11 +68,12 @@ class ExtensionManager
private function init(): void
{
foreach($this->getExtensions(true) as $name => $configuration) {
spl_autoload_register(@create_function("\$class", "
if(!substr(\$class, 0, " . iconv_strlen("$name\\") . ") === \"$name\\\\\") return false;
spl_autoload_register(function($class) use ($name) {
if(substr($class, 0, strlen("$name\\")) !== "$name\\")
return false;
include_once CHANDLER_EXTENSIONS_ENABLED . \"/\" . str_replace(\"\\\\\", \"/\", \$class) . \".php\";
"));
include_once CHANDLER_EXTENSIONS_ENABLED . "/" . str_replace("\\", "/", $class) . ".php";
});
define(str_replace("-", "_", mb_strtoupper($name)) . "_ROOT", CHANDLER_EXTENSIONS_ENABLED . "/$name", false);
define(str_replace("-", "_", mb_strtoupper($name)) . "_ROOT_CONF", chandler_parse_yaml(CHANDLER_EXTENSIONS_ENABLED . "/$name/$name.yml"), false);

View File

@ -1,6 +1,6 @@
{
"require": {
"php": "~7.3",
"php": "~7.3||~8.1",
"nette/utils": "^3.0",
"nette/di": "^3.0",

90
composer.lock generated
View File

@ -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": "5bb45343c700f6c8f81690249da21dae",
"content-hash": "c026b58926dd87cadb6e0b1752759893",
"packages": [
{
"name": "doctrine/lexer",
@ -84,16 +84,16 @@
},
{
"name": "egulias/email-validator",
"version": "3.2",
"version": "3.2.1",
"source": {
"type": "git",
"url": "https://github.com/egulias/EmailValidator.git",
"reference": "a5ed8d58ed0c340a7c2109f587951b1c84cf6286"
"reference": "f88dcf4b14af14a98ad96b14b2b317969eab6715"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/a5ed8d58ed0c340a7c2109f587951b1c84cf6286",
"reference": "a5ed8d58ed0c340a7c2109f587951b1c84cf6286",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/f88dcf4b14af14a98ad96b14b2b317969eab6715",
"reference": "f88dcf4b14af14a98ad96b14b2b317969eab6715",
"shasum": ""
},
"require": {
@ -140,7 +140,7 @@
],
"support": {
"issues": "https://github.com/egulias/EmailValidator/issues",
"source": "https://github.com/egulias/EmailValidator/tree/3.2"
"source": "https://github.com/egulias/EmailValidator/tree/3.2.1"
},
"funding": [
{
@ -148,7 +148,7 @@
"type": "github"
}
],
"time": "2022-05-28T22:19:18+00:00"
"time": "2022-06-18T20:57:19+00:00"
},
{
"name": "firebase/php-jwt",
@ -960,35 +960,35 @@
},
{
"name": "nette/php-generator",
"version": "v3.6.7",
"version": "v4.0.2",
"source": {
"type": "git",
"url": "https://github.com/nette/php-generator.git",
"reference": "b9ba414c9895fd9420887f20eeb4eabde123677f"
"reference": "f19b7975c7c4d729be5b64fce7eb72f0d4aac6fc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nette/php-generator/zipball/b9ba414c9895fd9420887f20eeb4eabde123677f",
"reference": "b9ba414c9895fd9420887f20eeb4eabde123677f",
"url": "https://api.github.com/repos/nette/php-generator/zipball/f19b7975c7c4d729be5b64fce7eb72f0d4aac6fc",
"reference": "f19b7975c7c4d729be5b64fce7eb72f0d4aac6fc",
"shasum": ""
},
"require": {
"nette/utils": "^3.1.2",
"php": ">=7.2 <8.2"
"nette/utils": "^3.2.7 || ^4.0",
"php": ">=8.0 <8.2"
},
"require-dev": {
"nette/tester": "^2.4",
"nikic/php-parser": "^4.13",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "^1.0",
"tracy/tracy": "^2.8"
},
"suggest": {
"nikic/php-parser": "to use ClassType::withBodiesFrom() & GlobalFunction::withBodyFrom()"
"nikic/php-parser": "to use ClassType::from(withBodies: true) & ClassType::fromCode()"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.6-dev"
"dev-master": "4.0-dev"
}
},
"autoload": {
@ -1022,9 +1022,9 @@
],
"support": {
"issues": "https://github.com/nette/php-generator/issues",
"source": "https://github.com/nette/php-generator/tree/v3.6.7"
"source": "https://github.com/nette/php-generator/tree/v4.0.2"
},
"time": "2022-03-10T01:51:00+00:00"
"time": "2022-06-17T12:20:08+00:00"
},
{
"name": "nette/robot-loader",
@ -1537,25 +1537,25 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v2.5.1",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66"
"reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
"reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918",
"reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918",
"shasum": ""
},
"require": {
"php": ">=7.1"
"php": ">=8.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "2.5-dev"
"dev-main": "3.1-dev"
},
"thanks": {
"name": "symfony/contracts",
@ -1584,7 +1584,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.1"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.1.1"
},
"funding": [
{
@ -1600,7 +1600,7 @@
"type": "tidelift"
}
],
"time": "2022-01-02T09:53:40+00:00"
"time": "2022-02-25T11:15:52+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -2182,16 +2182,16 @@
},
{
"name": "symfony/translation",
"version": "v5.4.9",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "1639abc1177d26bcd4320e535e664cef067ab0ca"
"reference": "7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/1639abc1177d26bcd4320e535e664cef067ab0ca",
"reference": "1639abc1177d26bcd4320e535e664cef067ab0ca",
"url": "https://api.github.com/repos/symfony/translation/zipball/7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21",
"reference": "7a1a8f6bbff269f434a83343a0a5d36a4f8cfa21",
"shasum": ""
},
"require": {
@ -2259,7 +2259,7 @@
"description": "Provides tools to internationalize your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/translation/tree/v5.4.9"
"source": "https://github.com/symfony/translation/tree/v5.4.11"
},
"funding": [
{
@ -2275,20 +2275,20 @@
"type": "tidelift"
}
],
"time": "2022-05-06T12:33:37+00:00"
"time": "2022-07-20T13:00:38+00:00"
},
{
"name": "symfony/translation-contracts",
"version": "v2.5.1",
"version": "v2.5.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
"reference": "1211df0afa701e45a04253110e959d4af4ef0f07"
"reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1211df0afa701e45a04253110e959d4af4ef0f07",
"reference": "1211df0afa701e45a04253110e959d4af4ef0f07",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
"reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe",
"shasum": ""
},
"require": {
@ -2337,7 +2337,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/translation-contracts/tree/v2.5.1"
"source": "https://github.com/symfony/translation-contracts/tree/v2.5.2"
},
"funding": [
{
@ -2353,20 +2353,20 @@
"type": "tidelift"
}
],
"time": "2022-01-02T09:53:40+00:00"
"time": "2022-06-27T16:58:25+00:00"
},
{
"name": "symfony/yaml",
"version": "v5.4.3",
"version": "v5.4.11",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "e80f87d2c9495966768310fc531b487ce64237a2"
"reference": "05d4ea560f3402c6c116afd99fdc66e60eda227e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/e80f87d2c9495966768310fc531b487ce64237a2",
"reference": "e80f87d2c9495966768310fc531b487ce64237a2",
"url": "https://api.github.com/repos/symfony/yaml/zipball/05d4ea560f3402c6c116afd99fdc66e60eda227e",
"reference": "05d4ea560f3402c6c116afd99fdc66e60eda227e",
"shasum": ""
},
"require": {
@ -2412,7 +2412,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v5.4.3"
"source": "https://github.com/symfony/yaml/tree/v5.4.11"
},
"funding": [
{
@ -2428,7 +2428,7 @@
"type": "tidelift"
}
],
"time": "2022-01-26T16:32:32+00:00"
"time": "2022-06-27T16:58:25+00:00"
},
{
"name": "tracy/tracy",
@ -2550,7 +2550,7 @@
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "~7.3"
"php": "~7.3||~8.1"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"