el bebra
This commit is contained in:
parent
fc2a1f2cca
commit
414f71824f
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "mirzaev/tordv-calculator",
|
"name": "mirzaev/tordv-calculator",
|
||||||
"description": "Калькулятор стоимости услуг по обработке металла",
|
"description": "Калькулятор стоимости услуг по обработке металла",
|
||||||
"readme": "README.md",
|
"type": "site",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"site",
|
"site",
|
||||||
"calculator"
|
"calculator"
|
||||||
],
|
],
|
||||||
"type": "site",
|
"readme": "README.md",
|
||||||
"homepage": "https://git.mirzaev.sexy/mirzaev/tordv-calculator",
|
"homepage": "https://git.mirzaev.sexy/mirzaev/tordv-calculator",
|
||||||
"license": "WTFPL",
|
"license": "WTFPL",
|
||||||
"authors": [
|
"authors": [
|
||||||
|
@ -19,23 +19,24 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"email": "arsen@mirzaev.sexy",
|
"email": "arsen@mirzaev.sexy",
|
||||||
"wiki": "https://git.mirzaev.sexy/mirzaev/tordv-calculator/wiki",
|
"docs": "https://git.mirzaev.sexy/mirzaev/tordv-calculator/wiki",
|
||||||
"issues": "https://git.mirzaev.sexy/mirzaev/tordv-calculator/issues"
|
"issues": "https://git.mirzaev.sexy/mirzaev/tordv-calculator/issues"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "funding",
|
"type": "funding",
|
||||||
"url": "https://fund.mirzaev.sexy"
|
"url": "https://fund.mirzaev.sexy"
|
||||||
],
|
}
|
||||||
"require": {
|
],
|
||||||
"php": "^8.0.0",
|
"require": {
|
||||||
"mirzaev/minimal": "^2.0.x-dev",
|
"php": "^8.0.0",
|
||||||
"twig/twig": "^3.3",
|
"mirzaev/minimal": "^2.0.x-dev",
|
||||||
"phpoffice/phpspreadsheet": "^1.20"
|
"twig/twig": "^3.3",
|
||||||
},
|
"phpoffice/phpspreadsheet": "^1.20"
|
||||||
"autoload": {
|
},
|
||||||
"psr-4": {
|
"autoload": {
|
||||||
"mirzaev\\tordv\\calculator\\": "mirzaev/tordv/calculator/system"
|
"psr-4": {
|
||||||
}
|
"mirzaev\\tordv\\calculator\\": "mirzaev/tordv/calculator/system"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -4,33 +4,43 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "cdf791cfa902c191370bbff40d9edc04",
|
"content-hash": "d63372480c8f1c3719fb9e69026eef21",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "ezyang/htmlpurifier",
|
"name": "ezyang/htmlpurifier",
|
||||||
"version": "v4.14.0",
|
"version": "v4.16.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/ezyang/htmlpurifier.git",
|
"url": "https://github.com/ezyang/htmlpurifier.git",
|
||||||
"reference": "12ab42bd6e742c70c0a52f7b82477fcd44e64b75"
|
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/12ab42bd6e742c70c0a52f7b82477fcd44e64b75",
|
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/523407fb06eb9e5f3d59889b3978d5bfe94299c8",
|
||||||
"reference": "12ab42bd6e742c70c0a52f7b82477fcd44e64b75",
|
"reference": "523407fb06eb9e5f3d59889b3978d5bfe94299c8",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.2"
|
"php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"cerdic/css-tidy": "^1.7 || ^2.0",
|
||||||
|
"simpletest/simpletest": "dev-master"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.",
|
||||||
|
"ext-bcmath": "Used for unit conversion and imagecrash protection",
|
||||||
|
"ext-iconv": "Converts text to and from non-UTF-8 encodings",
|
||||||
|
"ext-tidy": "Used for pretty-printing HTML"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
|
||||||
"HTMLPurifier": "library/"
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"library/HTMLPurifier.composer.php"
|
"library/HTMLPurifier.composer.php"
|
||||||
],
|
],
|
||||||
|
"psr-0": {
|
||||||
|
"HTMLPurifier": "library/"
|
||||||
|
},
|
||||||
"exclude-from-classmap": [
|
"exclude-from-classmap": [
|
||||||
"/library/HTMLPurifier/Language/"
|
"/library/HTMLPurifier/Language/"
|
||||||
]
|
]
|
||||||
|
@ -53,35 +63,38 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/ezyang/htmlpurifier/issues",
|
"issues": "https://github.com/ezyang/htmlpurifier/issues",
|
||||||
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.14.0"
|
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.16.0"
|
||||||
},
|
},
|
||||||
"time": "2021-12-25T01:21:49+00:00"
|
"time": "2022-09-18T07:06:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "maennchen/zipstream-php",
|
"name": "maennchen/zipstream-php",
|
||||||
"version": "2.1.0",
|
"version": "v2.4.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
||||||
"reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58"
|
"reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58",
|
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
|
||||||
"reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58",
|
"reference": "3fa72e4c71a43f9e9118752a5c90e476a8dc9eb3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
"ext-mbstring": "*",
|
||||||
"myclabs/php-enum": "^1.5",
|
"myclabs/php-enum": "^1.5",
|
||||||
"php": ">= 7.1",
|
"php": "^8.0",
|
||||||
"psr/http-message": "^1.0",
|
"psr/http-message": "^1.0"
|
||||||
"symfony/polyfill-mbstring": "^1.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"guzzlehttp/guzzle": ">= 6.3",
|
"friendsofphp/php-cs-fixer": "^3.9",
|
||||||
|
"guzzlehttp/guzzle": "^6.5.3 || ^7.2.0",
|
||||||
"mikey179/vfsstream": "^1.6",
|
"mikey179/vfsstream": "^1.6",
|
||||||
"phpunit/phpunit": ">= 7.5"
|
"php-coveralls/php-coveralls": "^2.4",
|
||||||
|
"phpunit/phpunit": "^8.5.8 || ^9.4.2",
|
||||||
|
"vimeo/psalm": "^5.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -118,38 +131,42 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
|
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
|
||||||
"source": "https://github.com/maennchen/ZipStream-PHP/tree/master"
|
"source": "https://github.com/maennchen/ZipStream-PHP/tree/v2.4.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/maennchen",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"url": "https://opencollective.com/zipstream",
|
"url": "https://opencollective.com/zipstream",
|
||||||
"type": "open_collective"
|
"type": "open_collective"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2020-05-30T13:11:16+00:00"
|
"time": "2022-12-08T12:29:14+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "markbaker/complex",
|
"name": "markbaker/complex",
|
||||||
"version": "3.0.1",
|
"version": "3.0.2",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
||||||
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22"
|
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/ab8bc271e404909db09ff2d5ffa1e538085c0f22",
|
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
||||||
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22",
|
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2 || ^8.0"
|
"php": "^7.2 || ^8.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||||
"phpcompatibility/php-compatibility": "^9.0",
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
|
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||||
"squizlabs/php_codesniffer": "^3.4"
|
"squizlabs/php_codesniffer": "^3.7"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -175,36 +192,36 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
|
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
|
||||||
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.1"
|
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
|
||||||
},
|
},
|
||||||
"time": "2021-06-29T15:32:53+00:00"
|
"time": "2022-12-06T16:21:08+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "markbaker/matrix",
|
"name": "markbaker/matrix",
|
||||||
"version": "3.0.0",
|
"version": "3.0.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
||||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576"
|
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/c66aefcafb4f6c269510e9ac46b82619a904c576",
|
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
|
||||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576",
|
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1 || ^8.0"
|
"php": "^7.1 || ^8.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||||
"phpcompatibility/php-compatibility": "^9.0",
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
"phpdocumentor/phpdocumentor": "2.*",
|
"phpdocumentor/phpdocumentor": "2.*",
|
||||||
"phploc/phploc": "^4.0",
|
"phploc/phploc": "^4.0",
|
||||||
"phpmd/phpmd": "2.*",
|
"phpmd/phpmd": "2.*",
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
|
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
|
||||||
"sebastian/phpcpd": "^4.0",
|
"sebastian/phpcpd": "^4.0",
|
||||||
"squizlabs/php_codesniffer": "^3.4"
|
"squizlabs/php_codesniffer": "^3.7"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -231,23 +248,23 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
||||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.0"
|
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
|
||||||
},
|
},
|
||||||
"time": "2021-07-01T19:01:15+00:00"
|
"time": "2022-12-02T22:17:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "mirzaev/minimal",
|
"name": "mirzaev/minimal",
|
||||||
"version": "2.0.x-dev",
|
"version": "2.0.x-dev",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.hood.su/mirzaev/minimal",
|
"url": "https://git.mirzaev.sexy/mirzaev/minimal",
|
||||||
"reference": "b6f90b700116f20fe48725166ddfb8f6d27ae52d"
|
"reference": "1f5685a20d41c1c11742f33138764b835ddd0198"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": "~8.0"
|
"php": "~8.1"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-PDO": "Для работы с базами данных на SQL (MySQL, PostreSQL...)"
|
"ext-PDO": "To work with SQL-based databases (MySQL, PostreSQL...)"
|
||||||
},
|
},
|
||||||
"type": "framework",
|
"type": "framework",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -267,30 +284,30 @@
|
||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Легковесный MVC фреймворк который следует твоим правилам, а не диктует свои",
|
"description": "Lightweight MVC framework that manages only the basic mechanisms, leaving the development of the programmer and not overloading the project",
|
||||||
"homepage": "https://git.hood.su/mirzaev/minimal",
|
"homepage": "https://git.mirzaev.sexy/mirzaev/minimal",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"framework",
|
"framework",
|
||||||
"mvc"
|
"mvc"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"docs": "https://git.hood.su/mirzaev/minimal/manual",
|
"docs": "https://git.mirzaev.sexy/mirzaev/minimal/wiki",
|
||||||
"issues": "https://git.hood.su/mirzaev/minimal/issues"
|
"issues": "https://git.mirzaev.sexy/mirzaev/minimal/issues"
|
||||||
},
|
},
|
||||||
"time": "2021-11-12T13:20:13+00:00"
|
"time": "2022-11-03T06:09:32+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "myclabs/php-enum",
|
"name": "myclabs/php-enum",
|
||||||
"version": "1.8.3",
|
"version": "1.8.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/myclabs/php-enum.git",
|
"url": "https://github.com/myclabs/php-enum.git",
|
||||||
"reference": "b942d263c641ddb5190929ff840c68f78713e937"
|
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937",
|
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/a867478eae49c9f59ece437ae7f9506bfaa27483",
|
||||||
"reference": "b942d263c641ddb5190929ff840c68f78713e937",
|
"reference": "a867478eae49c9f59ece437ae7f9506bfaa27483",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -306,7 +323,10 @@
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"MyCLabs\\Enum\\": "src/"
|
"MyCLabs\\Enum\\": "src/"
|
||||||
}
|
},
|
||||||
|
"classmap": [
|
||||||
|
"stubs/Stringable.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -325,7 +345,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/myclabs/php-enum/issues",
|
"issues": "https://github.com/myclabs/php-enum/issues",
|
||||||
"source": "https://github.com/myclabs/php-enum/tree/1.8.3"
|
"source": "https://github.com/myclabs/php-enum/tree/1.8.4"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -337,20 +357,20 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-07-05T08:18:36+00:00"
|
"time": "2022-08-04T09:53:51+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpoffice/phpspreadsheet",
|
"name": "phpoffice/phpspreadsheet",
|
||||||
"version": "1.20.0",
|
"version": "1.26.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
||||||
"reference": "44436f270bb134b4a94670f3d020a85dfa0a3c02"
|
"reference": "5b6ceea9705b068f993e268e4debc566c2637063"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/44436f270bb134b4a94670f3d020a85dfa0a3c02",
|
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/5b6ceea9705b068f993e268e4debc566c2637063",
|
||||||
"reference": "44436f270bb134b4a94670f3d020a85dfa0a3c02",
|
"reference": "5b6ceea9705b068f993e268e4debc566c2637063",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -367,33 +387,34 @@
|
||||||
"ext-xmlwriter": "*",
|
"ext-xmlwriter": "*",
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
"ext-zlib": "*",
|
"ext-zlib": "*",
|
||||||
"ezyang/htmlpurifier": "^4.13",
|
"ezyang/htmlpurifier": "^4.15",
|
||||||
"maennchen/zipstream-php": "^2.1",
|
"maennchen/zipstream-php": "^2.1",
|
||||||
"markbaker/complex": "^3.0",
|
"markbaker/complex": "^3.0",
|
||||||
"markbaker/matrix": "^3.0",
|
"markbaker/matrix": "^3.0",
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.4 || ^8.0",
|
||||||
"psr/http-client": "^1.0",
|
"psr/http-client": "^1.0",
|
||||||
"psr/http-factory": "^1.0",
|
"psr/http-factory": "^1.0",
|
||||||
"psr/simple-cache": "^1.0"
|
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
||||||
"dompdf/dompdf": "^1.0",
|
"dompdf/dompdf": "^1.0 || ^2.0",
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
"friendsofphp/php-cs-fixer": "^3.2",
|
||||||
"jpgraph/jpgraph": "^4.0",
|
"mitoteam/jpgraph": "^10.2.4",
|
||||||
"mpdf/mpdf": "^8.0",
|
"mpdf/mpdf": "^8.1.1",
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
"phpcompatibility/php-compatibility": "^9.3",
|
||||||
"phpstan/phpstan": "^1.1",
|
"phpstan/phpstan": "^1.1",
|
||||||
"phpstan/phpstan-phpunit": "^1.0",
|
"phpstan/phpstan-phpunit": "^1.0",
|
||||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
"phpunit/phpunit": "^8.5 || ^9.0",
|
||||||
"squizlabs/php_codesniffer": "^3.6",
|
"squizlabs/php_codesniffer": "^3.7",
|
||||||
"tecnickcom/tcpdf": "^6.4"
|
"tecnickcom/tcpdf": "^6.5"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
|
||||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
"ext-intl": "PHP Internationalization Functions",
|
||||||
|
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
||||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
||||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)"
|
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -439,9 +460,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
|
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
|
||||||
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.20.0"
|
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.26.0"
|
||||||
},
|
},
|
||||||
"time": "2021-11-23T15:23:42+00:00"
|
"time": "2022-12-21T12:22:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/http-client",
|
"name": "psr/http-client",
|
||||||
|
@ -605,25 +626,25 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/simple-cache",
|
"name": "psr/simple-cache",
|
||||||
"version": "1.0.1",
|
"version": "3.0.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/php-fig/simple-cache.git",
|
"url": "https://github.com/php-fig/simple-cache.git",
|
||||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865",
|
||||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
"reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0"
|
"php": ">=8.0.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.0.x-dev"
|
"dev-master": "3.0.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -638,7 +659,7 @@
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "PHP-FIG",
|
"name": "PHP-FIG",
|
||||||
"homepage": "http://www.php-fig.org/"
|
"homepage": "https://www.php-fig.org/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Common interfaces for simple caching",
|
"description": "Common interfaces for simple caching",
|
||||||
|
@ -650,34 +671,37 @@
|
||||||
"simple-cache"
|
"simple-cache"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/php-fig/simple-cache/tree/master"
|
"source": "https://github.com/php-fig/simple-cache/tree/3.0.0"
|
||||||
},
|
},
|
||||||
"time": "2017-10-23T01:57:42+00:00"
|
"time": "2021-10-29T13:26:27+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
"version": "v1.23.0",
|
"version": "v1.27.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
"url": "https://github.com/symfony/polyfill-ctype.git",
|
||||||
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
|
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
|
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
|
||||||
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
|
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1"
|
"php": ">=7.1"
|
||||||
},
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-ctype": "*"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-ctype": "For best performance"
|
"ext-ctype": "For best performance"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "1.23-dev"
|
"dev-main": "1.27-dev"
|
||||||
},
|
},
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/polyfill",
|
"name": "symfony/polyfill",
|
||||||
|
@ -685,12 +709,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Ctype\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"bootstrap.php"
|
"bootstrap.php"
|
||||||
]
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Ctype\\": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -715,7 +739,7 @@
|
||||||
"portable"
|
"portable"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -731,32 +755,35 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-02-19T12:13:01+00:00"
|
"time": "2022-11-03T14:55:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-mbstring",
|
"name": "symfony/polyfill-mbstring",
|
||||||
"version": "v1.23.1",
|
"version": "v1.27.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
|
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1"
|
"php": ">=7.1"
|
||||||
},
|
},
|
||||||
|
"provide": {
|
||||||
|
"ext-mbstring": "*"
|
||||||
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-mbstring": "For best performance"
|
"ext-mbstring": "For best performance"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "1.23-dev"
|
"dev-main": "1.27-dev"
|
||||||
},
|
},
|
||||||
"thanks": {
|
"thanks": {
|
||||||
"name": "symfony/polyfill",
|
"name": "symfony/polyfill",
|
||||||
|
@ -764,12 +791,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"bootstrap.php"
|
"bootstrap.php"
|
||||||
]
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Polyfill\\Mbstring\\": ""
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
"license": [
|
"license": [
|
||||||
|
@ -795,7 +822,7 @@
|
||||||
"shim"
|
"shim"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
|
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -811,20 +838,20 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-05-27T12:26:48+00:00"
|
"time": "2022-11-03T14:55:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.3.3",
|
"version": "v3.4.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569"
|
"reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a27fa056df8a6384316288ca8b0fa3a35fdeb569",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/c38fd6b0b7f370c198db91ffd02e23b517426b58",
|
||||||
"reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569",
|
"reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -839,7 +866,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.3-dev"
|
"dev-master": "3.4-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -875,7 +902,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.3.3"
|
"source": "https://github.com/twigphp/Twig/tree/v3.4.3"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -887,7 +914,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-09-17T08:44:23+00:00"
|
"time": "2022-09-28T08:42:51+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
|
@ -902,5 +929,5 @@
|
||||||
"php": "^8.0.0"
|
"php": "^8.0.0"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.0.0"
|
"plugin-api-version": "2.3.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
index.php
|
|
@ -16,7 +16,7 @@ define('LOGIN', 'root');
|
||||||
define('PASSWORD', '');
|
define('PASSWORD', '');
|
||||||
|
|
||||||
// Автозагрузка
|
// Автозагрузка
|
||||||
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
|
||||||
// Инициализация маршрутазитора
|
// Инициализация маршрутазитора
|
||||||
$router = new router;
|
$router = new router;
|
|
@ -1,7 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload.php @generated by Composer
|
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
|
||||||
|
|
||||||
return ComposerAutoloaderInitd3c0e906485ab41f428834e64f63b2f8::getLoader();
|
|
|
@ -1,479 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
|
||||||
*
|
|
||||||
* $loader = new \Composer\Autoload\ClassLoader();
|
|
||||||
*
|
|
||||||
* // register classes with namespaces
|
|
||||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
|
||||||
* $loader->add('Symfony', __DIR__.'/framework');
|
|
||||||
*
|
|
||||||
* // activate the autoloader
|
|
||||||
* $loader->register();
|
|
||||||
*
|
|
||||||
* // to enable searching the include path (eg. for PEAR packages)
|
|
||||||
* $loader->setUseIncludePath(true);
|
|
||||||
*
|
|
||||||
* In this example, if you try to use a class in the Symfony\Component
|
|
||||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
|
||||||
* the autoloader will first look for the class under the component/
|
|
||||||
* directory, and it will then fallback to the framework/ directory if not
|
|
||||||
* found before giving up.
|
|
||||||
*
|
|
||||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
|
||||||
*
|
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
|
||||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
* @see https://www.php-fig.org/psr/psr-0/
|
|
||||||
* @see https://www.php-fig.org/psr/psr-4/
|
|
||||||
*/
|
|
||||||
class ClassLoader
|
|
||||||
{
|
|
||||||
private $vendorDir;
|
|
||||||
|
|
||||||
// PSR-4
|
|
||||||
private $prefixLengthsPsr4 = array();
|
|
||||||
private $prefixDirsPsr4 = array();
|
|
||||||
private $fallbackDirsPsr4 = array();
|
|
||||||
|
|
||||||
// PSR-0
|
|
||||||
private $prefixesPsr0 = array();
|
|
||||||
private $fallbackDirsPsr0 = array();
|
|
||||||
|
|
||||||
private $useIncludePath = false;
|
|
||||||
private $classMap = array();
|
|
||||||
private $classMapAuthoritative = false;
|
|
||||||
private $missingClasses = array();
|
|
||||||
private $apcuPrefix;
|
|
||||||
|
|
||||||
private static $registeredLoaders = array();
|
|
||||||
|
|
||||||
public function __construct($vendorDir = null)
|
|
||||||
{
|
|
||||||
$this->vendorDir = $vendorDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrefixes()
|
|
||||||
{
|
|
||||||
if (!empty($this->prefixesPsr0)) {
|
|
||||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
|
||||||
}
|
|
||||||
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrefixesPsr4()
|
|
||||||
{
|
|
||||||
return $this->prefixDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFallbackDirs()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFallbackDirsPsr4()
|
|
||||||
{
|
|
||||||
return $this->fallbackDirsPsr4;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getClassMap()
|
|
||||||
{
|
|
||||||
return $this->classMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $classMap Class to filename map
|
|
||||||
*/
|
|
||||||
public function addClassMap(array $classMap)
|
|
||||||
{
|
|
||||||
if ($this->classMap) {
|
|
||||||
$this->classMap = array_merge($this->classMap, $classMap);
|
|
||||||
} else {
|
|
||||||
$this->classMap = $classMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix, either
|
|
||||||
* appending or prepending to the ones previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param array|string $paths The PSR-0 root directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*/
|
|
||||||
public function add($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
(array) $paths,
|
|
||||||
$this->fallbackDirsPsr0
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr0 = array_merge(
|
|
||||||
$this->fallbackDirsPsr0,
|
|
||||||
(array) $paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$first = $prefix[0];
|
|
||||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ($prepend) {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
(array) $paths,
|
|
||||||
$this->prefixesPsr0[$first][$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
|
||||||
$this->prefixesPsr0[$first][$prefix],
|
|
||||||
(array) $paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace, either
|
|
||||||
* appending or prepending to the ones previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param array|string $paths The PSR-4 base directories
|
|
||||||
* @param bool $prepend Whether to prepend the directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function addPsr4($prefix, $paths, $prepend = false)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
// Register directories for the root namespace.
|
|
||||||
if ($prepend) {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
(array) $paths,
|
|
||||||
$this->fallbackDirsPsr4
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$this->fallbackDirsPsr4 = array_merge(
|
|
||||||
$this->fallbackDirsPsr4,
|
|
||||||
(array) $paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
|
||||||
// Register directories for a new namespace.
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
||||||
} elseif ($prepend) {
|
|
||||||
// Prepend directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
(array) $paths,
|
|
||||||
$this->prefixDirsPsr4[$prefix]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Append directories for an already registered namespace.
|
|
||||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
|
||||||
$this->prefixDirsPsr4[$prefix],
|
|
||||||
(array) $paths
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-0 directories for a given prefix,
|
|
||||||
* replacing any others previously set for this prefix.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix
|
|
||||||
* @param array|string $paths The PSR-0 base directories
|
|
||||||
*/
|
|
||||||
public function set($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr0 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a set of PSR-4 directories for a given namespace,
|
|
||||||
* replacing any others previously set for this namespace.
|
|
||||||
*
|
|
||||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
|
||||||
* @param array|string $paths The PSR-4 base directories
|
|
||||||
*
|
|
||||||
* @throws \InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function setPsr4($prefix, $paths)
|
|
||||||
{
|
|
||||||
if (!$prefix) {
|
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
|
||||||
} else {
|
|
||||||
$length = strlen($prefix);
|
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
|
||||||
}
|
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns on searching the include path for class files.
|
|
||||||
*
|
|
||||||
* @param bool $useIncludePath
|
|
||||||
*/
|
|
||||||
public function setUseIncludePath($useIncludePath)
|
|
||||||
{
|
|
||||||
$this->useIncludePath = $useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Can be used to check if the autoloader uses the include path to check
|
|
||||||
* for classes.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function getUseIncludePath()
|
|
||||||
{
|
|
||||||
return $this->useIncludePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Turns off searching the prefix and fallback directories for classes
|
|
||||||
* that have not been registered with the class map.
|
|
||||||
*
|
|
||||||
* @param bool $classMapAuthoritative
|
|
||||||
*/
|
|
||||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
|
||||||
{
|
|
||||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should class lookup fail if not found in the current class map?
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isClassMapAuthoritative()
|
|
||||||
{
|
|
||||||
return $this->classMapAuthoritative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
|
||||||
*
|
|
||||||
* @param string|null $apcuPrefix
|
|
||||||
*/
|
|
||||||
public function setApcuPrefix($apcuPrefix)
|
|
||||||
{
|
|
||||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getApcuPrefix()
|
|
||||||
{
|
|
||||||
return $this->apcuPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers this instance as an autoloader.
|
|
||||||
*
|
|
||||||
* @param bool $prepend Whether to prepend the autoloader or not
|
|
||||||
*/
|
|
||||||
public function register($prepend = false)
|
|
||||||
{
|
|
||||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
|
||||||
|
|
||||||
if (null === $this->vendorDir) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($prepend) {
|
|
||||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
|
||||||
} else {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters this instance as an autoloader.
|
|
||||||
*/
|
|
||||||
public function unregister()
|
|
||||||
{
|
|
||||||
spl_autoload_unregister(array($this, 'loadClass'));
|
|
||||||
|
|
||||||
if (null !== $this->vendorDir) {
|
|
||||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the given class or interface.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
* @return bool|null True if loaded, null otherwise
|
|
||||||
*/
|
|
||||||
public function loadClass($class)
|
|
||||||
{
|
|
||||||
if ($file = $this->findFile($class)) {
|
|
||||||
includeFile($file);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the path to the file where the class is defined.
|
|
||||||
*
|
|
||||||
* @param string $class The name of the class
|
|
||||||
*
|
|
||||||
* @return string|false The path if found, false otherwise
|
|
||||||
*/
|
|
||||||
public function findFile($class)
|
|
||||||
{
|
|
||||||
// class map lookup
|
|
||||||
if (isset($this->classMap[$class])) {
|
|
||||||
return $this->classMap[$class];
|
|
||||||
}
|
|
||||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
|
||||||
if ($hit) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = $this->findFileWithExtension($class, '.php');
|
|
||||||
|
|
||||||
// Search for Hack files if we are running on HHVM
|
|
||||||
if (false === $file && defined('HHVM_VERSION')) {
|
|
||||||
$file = $this->findFileWithExtension($class, '.hh');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $this->apcuPrefix) {
|
|
||||||
apcu_add($this->apcuPrefix.$class, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (false === $file) {
|
|
||||||
// Remember that this class does not exist.
|
|
||||||
$this->missingClasses[$class] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
|
||||||
*
|
|
||||||
* @return self[]
|
|
||||||
*/
|
|
||||||
public static function getRegisteredLoaders()
|
|
||||||
{
|
|
||||||
return self::$registeredLoaders;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function findFileWithExtension($class, $ext)
|
|
||||||
{
|
|
||||||
// PSR-4 lookup
|
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
|
|
||||||
$first = $class[0];
|
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
|
||||||
$subPath = $class;
|
|
||||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
|
||||||
$subPath = substr($subPath, 0, $lastPos);
|
|
||||||
$search = $subPath . '\\';
|
|
||||||
if (isset($this->prefixDirsPsr4[$search])) {
|
|
||||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
|
||||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
|
||||||
if (file_exists($file = $dir . $pathEnd)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-4 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 lookup
|
|
||||||
if (false !== $pos = strrpos($class, '\\')) {
|
|
||||||
// namespaced class name
|
|
||||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
|
||||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
|
||||||
} else {
|
|
||||||
// PEAR-like class name
|
|
||||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->prefixesPsr0[$first])) {
|
|
||||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
|
||||||
if (0 === strpos($class, $prefix)) {
|
|
||||||
foreach ($dirs as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 fallback dirs
|
|
||||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PSR-0 include paths.
|
|
||||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
|
||||||
return $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope isolated include.
|
|
||||||
*
|
|
||||||
* Prevents access to $this/self from included files.
|
|
||||||
*/
|
|
||||||
function includeFile($file)
|
|
||||||
{
|
|
||||||
include $file;
|
|
||||||
}
|
|
|
@ -1,409 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Composer;
|
|
||||||
|
|
||||||
use Composer\Autoload\ClassLoader;
|
|
||||||
use Composer\Semver\VersionParser;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class InstalledVersions
|
|
||||||
{
|
|
||||||
private static $installed = array (
|
|
||||||
'root' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'dev-stable',
|
|
||||||
'version' => 'dev-stable',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
|
|
||||||
'name' => 'mirzaev/calculator',
|
|
||||||
),
|
|
||||||
'versions' =>
|
|
||||||
array (
|
|
||||||
'ezyang/htmlpurifier' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v4.14.0',
|
|
||||||
'version' => '4.14.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '12ab42bd6e742c70c0a52f7b82477fcd44e64b75',
|
|
||||||
),
|
|
||||||
'maennchen/zipstream-php' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '2.1.0',
|
|
||||||
'version' => '2.1.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'c4c5803cc1f93df3d2448478ef79394a5981cc58',
|
|
||||||
),
|
|
||||||
'markbaker/complex' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '3.0.1',
|
|
||||||
'version' => '3.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'ab8bc271e404909db09ff2d5ffa1e538085c0f22',
|
|
||||||
),
|
|
||||||
'markbaker/matrix' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '3.0.0',
|
|
||||||
'version' => '3.0.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'c66aefcafb4f6c269510e9ac46b82619a904c576',
|
|
||||||
),
|
|
||||||
'mirzaev/calculator' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'dev-stable',
|
|
||||||
'version' => 'dev-stable',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
|
|
||||||
),
|
|
||||||
'mirzaev/minimal' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '2.0.x-dev',
|
|
||||||
'version' => '2.0.9999999.9999999-dev',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'b6f90b700116f20fe48725166ddfb8f6d27ae52d',
|
|
||||||
),
|
|
||||||
'myclabs/php-enum' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.8.3',
|
|
||||||
'version' => '1.8.3.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'b942d263c641ddb5190929ff840c68f78713e937',
|
|
||||||
),
|
|
||||||
'phpoffice/phpspreadsheet' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.20.0',
|
|
||||||
'version' => '1.20.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '44436f270bb134b4a94670f3d020a85dfa0a3c02',
|
|
||||||
),
|
|
||||||
'psr/http-client' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
|
|
||||||
),
|
|
||||||
'psr/http-factory' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
|
|
||||||
),
|
|
||||||
'psr/http-message' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363',
|
|
||||||
),
|
|
||||||
'psr/simple-cache' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
|
|
||||||
),
|
|
||||||
'symfony/polyfill-ctype' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v1.23.0',
|
|
||||||
'version' => '1.23.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce',
|
|
||||||
),
|
|
||||||
'symfony/polyfill-mbstring' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v1.23.1',
|
|
||||||
'version' => '1.23.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '9174a3d80210dca8daa7f31fec659150bbeabfc6',
|
|
||||||
),
|
|
||||||
'twig/twig' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v3.3.3',
|
|
||||||
'version' => '3.3.3.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'a27fa056df8a6384316288ca8b0fa3a35fdeb569',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
private static $canGetVendors;
|
|
||||||
private static $installedByVendor = array();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getInstalledPackages()
|
|
||||||
{
|
|
||||||
$packages = array();
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
$packages[] = array_keys($installed['versions']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (1 === \count($packages)) {
|
|
||||||
return $packages[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function isInstalled($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (isset($installed['versions'][$packageName])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
|
||||||
{
|
|
||||||
$constraint = $parser->parseConstraints($constraint);
|
|
||||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
|
||||||
|
|
||||||
return $provided->matches($constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getVersionRanges($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ranges = array();
|
|
||||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
|
||||||
}
|
|
||||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
|
||||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(' || ', $ranges);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getPrettyVersion($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['pretty_version'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getReference($packageName)
|
|
||||||
{
|
|
||||||
foreach (self::getInstalled() as $installed) {
|
|
||||||
if (!isset($installed['versions'][$packageName])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $installed['versions'][$packageName]['reference'];
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getRootPackage()
|
|
||||||
{
|
|
||||||
$installed = self::getInstalled();
|
|
||||||
|
|
||||||
return $installed[0]['root'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function getRawData()
|
|
||||||
{
|
|
||||||
return self::$installed;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function reload($data)
|
|
||||||
{
|
|
||||||
self::$installed = $data;
|
|
||||||
self::$installedByVendor = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static function getInstalled()
|
|
||||||
{
|
|
||||||
if (null === self::$canGetVendors) {
|
|
||||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
|
||||||
}
|
|
||||||
|
|
||||||
$installed = array();
|
|
||||||
|
|
||||||
if (self::$canGetVendors) {
|
|
||||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
|
||||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
|
||||||
$installed[] = self::$installedByVendor[$vendorDir];
|
|
||||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
|
||||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$installed[] = self::$installed;
|
|
||||||
|
|
||||||
return $installed;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
|
|
||||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_classmap.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
|
||||||
);
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_files.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
|
|
||||||
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
|
|
||||||
);
|
|
|
@ -1,10 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_namespaces.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
|
|
||||||
);
|
|
|
@ -1,22 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_psr4.php @generated by Composer
|
|
||||||
|
|
||||||
$vendorDir = dirname(dirname(__FILE__));
|
|
||||||
$baseDir = dirname($vendorDir);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
'mirzaev\\minimal\\' => array($vendorDir . '/mirzaev/minimal/mirzaev/minimal/system'),
|
|
||||||
'mirzaev\\calculator\\' => array($baseDir . '/mirzaev/calculator/system'),
|
|
||||||
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
|
|
||||||
'Twig\\' => array($vendorDir . '/twig/twig/src'),
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
|
|
||||||
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
|
|
||||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
|
|
||||||
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
|
|
||||||
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
|
|
||||||
'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
|
|
||||||
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
|
|
||||||
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
|
|
||||||
);
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
|
||||||
|
|
||||||
class ComposerAutoloaderInitd3c0e906485ab41f428834e64f63b2f8
|
|
||||||
{
|
|
||||||
private static $loader;
|
|
||||||
|
|
||||||
public static function loadClassLoader($class)
|
|
||||||
{
|
|
||||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
|
||||||
require __DIR__ . '/ClassLoader.php';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Composer\Autoload\ClassLoader
|
|
||||||
*/
|
|
||||||
public static function getLoader()
|
|
||||||
{
|
|
||||||
if (null !== self::$loader) {
|
|
||||||
return self::$loader;
|
|
||||||
}
|
|
||||||
|
|
||||||
require __DIR__ . '/platform_check.php';
|
|
||||||
|
|
||||||
spl_autoload_register(array('ComposerAutoloaderInitd3c0e906485ab41f428834e64f63b2f8', 'loadClassLoader'), true, true);
|
|
||||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
|
||||||
spl_autoload_unregister(array('ComposerAutoloaderInitd3c0e906485ab41f428834e64f63b2f8', 'loadClassLoader'));
|
|
||||||
|
|
||||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
|
||||||
if ($useStaticLoader) {
|
|
||||||
require __DIR__ . '/autoload_static.php';
|
|
||||||
|
|
||||||
call_user_func(\Composer\Autoload\ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::getInitializer($loader));
|
|
||||||
} else {
|
|
||||||
$map = require __DIR__ . '/autoload_namespaces.php';
|
|
||||||
foreach ($map as $namespace => $path) {
|
|
||||||
$loader->set($namespace, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$map = require __DIR__ . '/autoload_psr4.php';
|
|
||||||
foreach ($map as $namespace => $path) {
|
|
||||||
$loader->setPsr4($namespace, $path);
|
|
||||||
}
|
|
||||||
|
|
||||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
|
||||||
if ($classMap) {
|
|
||||||
$loader->addClassMap($classMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$loader->register(true);
|
|
||||||
|
|
||||||
if ($useStaticLoader) {
|
|
||||||
$includeFiles = Composer\Autoload\ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::$files;
|
|
||||||
} else {
|
|
||||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
|
||||||
}
|
|
||||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
|
||||||
composerRequired3c0e906485ab41f428834e64f63b2f8($fileIdentifier, $file);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $loader;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function composerRequired3c0e906485ab41f428834e64f63b2f8($fileIdentifier, $file)
|
|
||||||
{
|
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
|
||||||
require $file;
|
|
||||||
|
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,132 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// autoload_static.php @generated by Composer
|
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
|
||||||
|
|
||||||
class ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8
|
|
||||||
{
|
|
||||||
public static $files = array (
|
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
|
||||||
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
|
|
||||||
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixLengthsPsr4 = array (
|
|
||||||
'm' =>
|
|
||||||
array (
|
|
||||||
'mirzaev\\minimal\\' => 16,
|
|
||||||
'mirzaev\\calculator\\' => 19,
|
|
||||||
),
|
|
||||||
'Z' =>
|
|
||||||
array (
|
|
||||||
'ZipStream\\' => 10,
|
|
||||||
),
|
|
||||||
'T' =>
|
|
||||||
array (
|
|
||||||
'Twig\\' => 5,
|
|
||||||
),
|
|
||||||
'S' =>
|
|
||||||
array (
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' => 23,
|
|
||||||
),
|
|
||||||
'P' =>
|
|
||||||
array (
|
|
||||||
'Psr\\SimpleCache\\' => 16,
|
|
||||||
'Psr\\Http\\Message\\' => 17,
|
|
||||||
'Psr\\Http\\Client\\' => 16,
|
|
||||||
'PhpOffice\\PhpSpreadsheet\\' => 25,
|
|
||||||
),
|
|
||||||
'M' =>
|
|
||||||
array (
|
|
||||||
'MyCLabs\\Enum\\' => 13,
|
|
||||||
'Matrix\\' => 7,
|
|
||||||
),
|
|
||||||
'C' =>
|
|
||||||
array (
|
|
||||||
'Complex\\' => 8,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixDirsPsr4 = array (
|
|
||||||
'mirzaev\\minimal\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/mirzaev/minimal/mirzaev/minimal/system',
|
|
||||||
),
|
|
||||||
'mirzaev\\calculator\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/../..' . '/mirzaev/calculator/system',
|
|
||||||
),
|
|
||||||
'ZipStream\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/maennchen/zipstream-php/src',
|
|
||||||
),
|
|
||||||
'Twig\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/twig/twig/src',
|
|
||||||
),
|
|
||||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
|
||||||
),
|
|
||||||
'Symfony\\Polyfill\\Ctype\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
|
|
||||||
),
|
|
||||||
'Psr\\SimpleCache\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/psr/simple-cache/src',
|
|
||||||
),
|
|
||||||
'Psr\\Http\\Message\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
|
||||||
1 => __DIR__ . '/..' . '/psr/http-factory/src',
|
|
||||||
),
|
|
||||||
'Psr\\Http\\Client\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/psr/http-client/src',
|
|
||||||
),
|
|
||||||
'PhpOffice\\PhpSpreadsheet\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet',
|
|
||||||
),
|
|
||||||
'MyCLabs\\Enum\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/myclabs/php-enum/src',
|
|
||||||
),
|
|
||||||
'Matrix\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src',
|
|
||||||
),
|
|
||||||
'Complex\\' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/markbaker/complex/classes/src',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $prefixesPsr0 = array (
|
|
||||||
'H' =>
|
|
||||||
array (
|
|
||||||
'HTMLPurifier' =>
|
|
||||||
array (
|
|
||||||
0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
public static $classMap = array (
|
|
||||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
||||||
);
|
|
||||||
|
|
||||||
public static function getInitializer(ClassLoader $loader)
|
|
||||||
{
|
|
||||||
return \Closure::bind(function () use ($loader) {
|
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::$prefixLengthsPsr4;
|
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::$prefixDirsPsr4;
|
|
||||||
$loader->prefixesPsr0 = ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::$prefixesPsr0;
|
|
||||||
$loader->classMap = ComposerStaticInitd3c0e906485ab41f428834e64f63b2f8::$classMap;
|
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,931 +0,0 @@
|
||||||
{
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "ezyang/htmlpurifier",
|
|
||||||
"version": "v4.14.0",
|
|
||||||
"version_normalized": "4.14.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/ezyang/htmlpurifier.git",
|
|
||||||
"reference": "12ab42bd6e742c70c0a52f7b82477fcd44e64b75"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/12ab42bd6e742c70c0a52f7b82477fcd44e64b75",
|
|
||||||
"reference": "12ab42bd6e742c70c0a52f7b82477fcd44e64b75",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.2"
|
|
||||||
},
|
|
||||||
"time": "2021-12-25T01:21:49+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"HTMLPurifier": "library/"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"library/HTMLPurifier.composer.php"
|
|
||||||
],
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/library/HTMLPurifier/Language/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"LGPL-2.1-or-later"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Edward Z. Yang",
|
|
||||||
"email": "admin@htmlpurifier.org",
|
|
||||||
"homepage": "http://ezyang.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Standards compliant HTML filter written in PHP",
|
|
||||||
"homepage": "http://htmlpurifier.org/",
|
|
||||||
"keywords": [
|
|
||||||
"html"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/ezyang/htmlpurifier/issues",
|
|
||||||
"source": "https://github.com/ezyang/htmlpurifier/tree/v4.14.0"
|
|
||||||
},
|
|
||||||
"install-path": "../ezyang/htmlpurifier"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "maennchen/zipstream-php",
|
|
||||||
"version": "2.1.0",
|
|
||||||
"version_normalized": "2.1.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/maennchen/ZipStream-PHP.git",
|
|
||||||
"reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/c4c5803cc1f93df3d2448478ef79394a5981cc58",
|
|
||||||
"reference": "c4c5803cc1f93df3d2448478ef79394a5981cc58",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"myclabs/php-enum": "^1.5",
|
|
||||||
"php": ">= 7.1",
|
|
||||||
"psr/http-message": "^1.0",
|
|
||||||
"symfony/polyfill-mbstring": "^1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ext-zip": "*",
|
|
||||||
"guzzlehttp/guzzle": ">= 6.3",
|
|
||||||
"mikey179/vfsstream": "^1.6",
|
|
||||||
"phpunit/phpunit": ">= 7.5"
|
|
||||||
},
|
|
||||||
"time": "2020-05-30T13:11:16+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"ZipStream\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Paul Duncan",
|
|
||||||
"email": "pabs@pablotron.org"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jonatan Männchen",
|
|
||||||
"email": "jonatan@maennchen.ch"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Jesse Donat",
|
|
||||||
"email": "donatj@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "András Kolesár",
|
|
||||||
"email": "kolesar@kolesar.hu"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
|
|
||||||
"keywords": [
|
|
||||||
"stream",
|
|
||||||
"zip"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
|
|
||||||
"source": "https://github.com/maennchen/ZipStream-PHP/tree/master"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://opencollective.com/zipstream",
|
|
||||||
"type": "open_collective"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../maennchen/zipstream-php"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "markbaker/complex",
|
|
||||||
"version": "3.0.1",
|
|
||||||
"version_normalized": "3.0.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/MarkBaker/PHPComplex.git",
|
|
||||||
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/ab8bc271e404909db09ff2d5ffa1e538085c0f22",
|
|
||||||
"reference": "ab8bc271e404909db09ff2d5ffa1e538085c0f22",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.2 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.0",
|
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
|
|
||||||
"squizlabs/php_codesniffer": "^3.4"
|
|
||||||
},
|
|
||||||
"time": "2021-06-29T15:32:53+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Complex\\": "classes/src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"email": "mark@lange.demon.co.uk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Class for working with complex numbers",
|
|
||||||
"homepage": "https://github.com/MarkBaker/PHPComplex",
|
|
||||||
"keywords": [
|
|
||||||
"complex",
|
|
||||||
"mathematics"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
|
|
||||||
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.1"
|
|
||||||
},
|
|
||||||
"install-path": "../markbaker/complex"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "markbaker/matrix",
|
|
||||||
"version": "3.0.0",
|
|
||||||
"version_normalized": "3.0.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/MarkBaker/PHPMatrix.git",
|
|
||||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/c66aefcafb4f6c269510e9ac46b82619a904c576",
|
|
||||||
"reference": "c66aefcafb4f6c269510e9ac46b82619a904c576",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.1 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.0",
|
|
||||||
"phpdocumentor/phpdocumentor": "2.*",
|
|
||||||
"phploc/phploc": "^4.0",
|
|
||||||
"phpmd/phpmd": "2.*",
|
|
||||||
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.3",
|
|
||||||
"sebastian/phpcpd": "^4.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.4"
|
|
||||||
},
|
|
||||||
"time": "2021-07-01T19:01:15+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Matrix\\": "classes/src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"email": "mark@demon-angel.eu"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Class for working with matrices",
|
|
||||||
"homepage": "https://github.com/MarkBaker/PHPMatrix",
|
|
||||||
"keywords": [
|
|
||||||
"mathematics",
|
|
||||||
"matrix",
|
|
||||||
"vector"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
|
|
||||||
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.0"
|
|
||||||
},
|
|
||||||
"install-path": "../markbaker/matrix"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mirzaev/minimal",
|
|
||||||
"version": "2.0.x-dev",
|
|
||||||
"version_normalized": "2.0.9999999.9999999-dev",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.hood.su/mirzaev/minimal",
|
|
||||||
"reference": "b6f90b700116f20fe48725166ddfb8f6d27ae52d"
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "~8.0"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-PDO": "Для работы с базами данных на SQL (MySQL, PostreSQL...)"
|
|
||||||
},
|
|
||||||
"time": "2021-11-12T13:20:13+00:00",
|
|
||||||
"type": "framework",
|
|
||||||
"installation-source": "source",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"mirzaev\\minimal\\": "mirzaev/minimal/system"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"WTFPL"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Arsen Mirzaev Tatyano-Muradovich",
|
|
||||||
"email": "arsen@mirzaev.sexy",
|
|
||||||
"homepage": "https://mirzaev.sexy",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Легковесный MVC фреймворк который следует твоим правилам, а не диктует свои",
|
|
||||||
"homepage": "https://git.hood.su/mirzaev/minimal",
|
|
||||||
"keywords": [
|
|
||||||
"framework",
|
|
||||||
"mvc"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"docs": "https://git.hood.su/mirzaev/minimal/manual",
|
|
||||||
"issues": "https://git.hood.su/mirzaev/minimal/issues"
|
|
||||||
},
|
|
||||||
"install-path": "../mirzaev/minimal"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "myclabs/php-enum",
|
|
||||||
"version": "1.8.3",
|
|
||||||
"version_normalized": "1.8.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/myclabs/php-enum.git",
|
|
||||||
"reference": "b942d263c641ddb5190929ff840c68f78713e937"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/myclabs/php-enum/zipball/b942d263c641ddb5190929ff840c68f78713e937",
|
|
||||||
"reference": "b942d263c641ddb5190929ff840c68f78713e937",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-json": "*",
|
|
||||||
"php": "^7.3 || ^8.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "^9.5",
|
|
||||||
"squizlabs/php_codesniffer": "1.*",
|
|
||||||
"vimeo/psalm": "^4.6.2"
|
|
||||||
},
|
|
||||||
"time": "2021-07-05T08:18:36+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"MyCLabs\\Enum\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP Enum contributors",
|
|
||||||
"homepage": "https://github.com/myclabs/php-enum/graphs/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHP Enum implementation",
|
|
||||||
"homepage": "http://github.com/myclabs/php-enum",
|
|
||||||
"keywords": [
|
|
||||||
"enum"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/myclabs/php-enum/issues",
|
|
||||||
"source": "https://github.com/myclabs/php-enum/tree/1.8.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/mnapoli",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../myclabs/php-enum"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "phpoffice/phpspreadsheet",
|
|
||||||
"version": "1.20.0",
|
|
||||||
"version_normalized": "1.20.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
|
|
||||||
"reference": "44436f270bb134b4a94670f3d020a85dfa0a3c02"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/44436f270bb134b4a94670f3d020a85dfa0a3c02",
|
|
||||||
"reference": "44436f270bb134b4a94670f3d020a85dfa0a3c02",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"ext-ctype": "*",
|
|
||||||
"ext-dom": "*",
|
|
||||||
"ext-fileinfo": "*",
|
|
||||||
"ext-gd": "*",
|
|
||||||
"ext-iconv": "*",
|
|
||||||
"ext-libxml": "*",
|
|
||||||
"ext-mbstring": "*",
|
|
||||||
"ext-simplexml": "*",
|
|
||||||
"ext-xml": "*",
|
|
||||||
"ext-xmlreader": "*",
|
|
||||||
"ext-xmlwriter": "*",
|
|
||||||
"ext-zip": "*",
|
|
||||||
"ext-zlib": "*",
|
|
||||||
"ezyang/htmlpurifier": "^4.13",
|
|
||||||
"maennchen/zipstream-php": "^2.1",
|
|
||||||
"markbaker/complex": "^3.0",
|
|
||||||
"markbaker/matrix": "^3.0",
|
|
||||||
"php": "^7.3 || ^8.0",
|
|
||||||
"psr/http-client": "^1.0",
|
|
||||||
"psr/http-factory": "^1.0",
|
|
||||||
"psr/simple-cache": "^1.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
|
|
||||||
"dompdf/dompdf": "^1.0",
|
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
|
||||||
"jpgraph/jpgraph": "^4.0",
|
|
||||||
"mpdf/mpdf": "^8.0",
|
|
||||||
"phpcompatibility/php-compatibility": "^9.3",
|
|
||||||
"phpstan/phpstan": "^1.1",
|
|
||||||
"phpstan/phpstan-phpunit": "^1.0",
|
|
||||||
"phpunit/phpunit": "^8.5 || ^9.0",
|
|
||||||
"squizlabs/php_codesniffer": "^3.6",
|
|
||||||
"tecnickcom/tcpdf": "^6.4"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"dompdf/dompdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)",
|
|
||||||
"jpgraph/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
|
|
||||||
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
|
|
||||||
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer (doesn't yet support PHP8)"
|
|
||||||
},
|
|
||||||
"time": "2021-11-23T15:23:42+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Maarten Balliauw",
|
|
||||||
"homepage": "https://blog.maartenballiauw.be"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Mark Baker",
|
|
||||||
"homepage": "https://markbakeruk.net"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Franck Lefevre",
|
|
||||||
"homepage": "https://rootslabs.net"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Erik Tilt"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Adrien Crivelli"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
|
||||||
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
|
|
||||||
"keywords": [
|
|
||||||
"OpenXML",
|
|
||||||
"excel",
|
|
||||||
"gnumeric",
|
|
||||||
"ods",
|
|
||||||
"php",
|
|
||||||
"spreadsheet",
|
|
||||||
"xls",
|
|
||||||
"xlsx"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
|
|
||||||
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.20.0"
|
|
||||||
},
|
|
||||||
"install-path": "../phpoffice/phpspreadsheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psr/http-client",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"version_normalized": "1.0.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/http-client.git",
|
|
||||||
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
|
|
||||||
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^7.0 || ^8.0",
|
|
||||||
"psr/http-message": "^1.0"
|
|
||||||
},
|
|
||||||
"time": "2020-06-29T06:28:15+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\Http\\Client\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common interface for HTTP clients",
|
|
||||||
"homepage": "https://github.com/php-fig/http-client",
|
|
||||||
"keywords": [
|
|
||||||
"http",
|
|
||||||
"http-client",
|
|
||||||
"psr",
|
|
||||||
"psr-18"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/php-fig/http-client/tree/master"
|
|
||||||
},
|
|
||||||
"install-path": "../psr/http-client"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psr/http-factory",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"version_normalized": "1.0.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/http-factory.git",
|
|
||||||
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
|
|
||||||
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.0.0",
|
|
||||||
"psr/http-message": "^1.0"
|
|
||||||
},
|
|
||||||
"time": "2019-04-30T12:38:16+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\Http\\Message\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common interfaces for PSR-7 HTTP message factories",
|
|
||||||
"keywords": [
|
|
||||||
"factory",
|
|
||||||
"http",
|
|
||||||
"message",
|
|
||||||
"psr",
|
|
||||||
"psr-17",
|
|
||||||
"psr-7",
|
|
||||||
"request",
|
|
||||||
"response"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/php-fig/http-factory/tree/master"
|
|
||||||
},
|
|
||||||
"install-path": "../psr/http-factory"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psr/http-message",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"version_normalized": "1.0.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/http-message.git",
|
|
||||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
|
|
||||||
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"time": "2016-08-06T14:39:51+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\Http\\Message\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common interface for HTTP messages",
|
|
||||||
"homepage": "https://github.com/php-fig/http-message",
|
|
||||||
"keywords": [
|
|
||||||
"http",
|
|
||||||
"http-message",
|
|
||||||
"psr",
|
|
||||||
"psr-7",
|
|
||||||
"request",
|
|
||||||
"response"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/php-fig/http-message/tree/master"
|
|
||||||
},
|
|
||||||
"install-path": "../psr/http-message"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "psr/simple-cache",
|
|
||||||
"version": "1.0.1",
|
|
||||||
"version_normalized": "1.0.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/php-fig/simple-cache.git",
|
|
||||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
|
||||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"time": "2017-10-23T01:57:42+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Psr\\SimpleCache\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "PHP-FIG",
|
|
||||||
"homepage": "http://www.php-fig.org/"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Common interfaces for simple caching",
|
|
||||||
"keywords": [
|
|
||||||
"cache",
|
|
||||||
"caching",
|
|
||||||
"psr",
|
|
||||||
"psr-16",
|
|
||||||
"simple-cache"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/php-fig/simple-cache/tree/master"
|
|
||||||
},
|
|
||||||
"install-path": "../psr/simple-cache"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-ctype",
|
|
||||||
"version": "v1.23.0",
|
|
||||||
"version_normalized": "1.23.0.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-ctype.git",
|
|
||||||
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce",
|
|
||||||
"reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-ctype": "For best performance"
|
|
||||||
},
|
|
||||||
"time": "2021-02-19T12:13:01+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.23-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Ctype\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gert de Pagter",
|
|
||||||
"email": "BackEndTea@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for ctype functions",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"ctype",
|
|
||||||
"polyfill",
|
|
||||||
"portable"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../symfony/polyfill-ctype"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-mbstring",
|
|
||||||
"version": "v1.23.1",
|
|
||||||
"version_normalized": "1.23.1.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/polyfill-mbstring.git",
|
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
|
||||||
"reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-mbstring": "For best performance"
|
|
||||||
},
|
|
||||||
"time": "2021-05-27T12:26:48+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.23-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Symfony\\Polyfill\\Mbstring\\": ""
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bootstrap.php"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony polyfill for the Mbstring extension",
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"compatibility",
|
|
||||||
"mbstring",
|
|
||||||
"polyfill",
|
|
||||||
"portable",
|
|
||||||
"shim"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://symfony.com/sponsor",
|
|
||||||
"type": "custom"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../symfony/polyfill-mbstring"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "twig/twig",
|
|
||||||
"version": "v3.3.3",
|
|
||||||
"version_normalized": "3.3.3.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
|
||||||
"reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a27fa056df8a6384316288ca8b0fa3a35fdeb569",
|
|
||||||
"reference": "a27fa056df8a6384316288ca8b0fa3a35fdeb569",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2.5",
|
|
||||||
"symfony/polyfill-ctype": "^1.8",
|
|
||||||
"symfony/polyfill-mbstring": "^1.3"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"psr/container": "^1.0",
|
|
||||||
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0"
|
|
||||||
},
|
|
||||||
"time": "2021-09-17T08:44:23+00:00",
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.3-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"installation-source": "dist",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Twig\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com",
|
|
||||||
"homepage": "http://fabien.potencier.org",
|
|
||||||
"role": "Lead Developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Twig Team",
|
|
||||||
"role": "Contributors"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Armin Ronacher",
|
|
||||||
"email": "armin.ronacher@active-4.com",
|
|
||||||
"role": "Project Founder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
|
||||||
"homepage": "https://twig.symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"templating"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.3.3"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"install-path": "../twig/twig"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"dev": true,
|
|
||||||
"dev-package-names": []
|
|
||||||
}
|
|
|
@ -1,150 +0,0 @@
|
||||||
<?php return array (
|
|
||||||
'root' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'dev-stable',
|
|
||||||
'version' => 'dev-stable',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
|
|
||||||
'name' => 'mirzaev/calculator',
|
|
||||||
),
|
|
||||||
'versions' =>
|
|
||||||
array (
|
|
||||||
'ezyang/htmlpurifier' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v4.14.0',
|
|
||||||
'version' => '4.14.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '12ab42bd6e742c70c0a52f7b82477fcd44e64b75',
|
|
||||||
),
|
|
||||||
'maennchen/zipstream-php' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '2.1.0',
|
|
||||||
'version' => '2.1.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'c4c5803cc1f93df3d2448478ef79394a5981cc58',
|
|
||||||
),
|
|
||||||
'markbaker/complex' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '3.0.1',
|
|
||||||
'version' => '3.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'ab8bc271e404909db09ff2d5ffa1e538085c0f22',
|
|
||||||
),
|
|
||||||
'markbaker/matrix' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '3.0.0',
|
|
||||||
'version' => '3.0.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'c66aefcafb4f6c269510e9ac46b82619a904c576',
|
|
||||||
),
|
|
||||||
'mirzaev/calculator' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'dev-stable',
|
|
||||||
'version' => 'dev-stable',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '503e25647cabfd80c98a1ca571a98e4b0595b729',
|
|
||||||
),
|
|
||||||
'mirzaev/minimal' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '2.0.x-dev',
|
|
||||||
'version' => '2.0.9999999.9999999-dev',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'b6f90b700116f20fe48725166ddfb8f6d27ae52d',
|
|
||||||
),
|
|
||||||
'myclabs/php-enum' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.8.3',
|
|
||||||
'version' => '1.8.3.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'b942d263c641ddb5190929ff840c68f78713e937',
|
|
||||||
),
|
|
||||||
'phpoffice/phpspreadsheet' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.20.0',
|
|
||||||
'version' => '1.20.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '44436f270bb134b4a94670f3d020a85dfa0a3c02',
|
|
||||||
),
|
|
||||||
'psr/http-client' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
|
|
||||||
),
|
|
||||||
'psr/http-factory' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
|
|
||||||
),
|
|
||||||
'psr/http-message' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363',
|
|
||||||
),
|
|
||||||
'psr/simple-cache' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => '1.0.1',
|
|
||||||
'version' => '1.0.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
|
|
||||||
),
|
|
||||||
'symfony/polyfill-ctype' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v1.23.0',
|
|
||||||
'version' => '1.23.0.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '46cd95797e9df938fdd2b03693b5fca5e64b01ce',
|
|
||||||
),
|
|
||||||
'symfony/polyfill-mbstring' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v1.23.1',
|
|
||||||
'version' => '1.23.1.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => '9174a3d80210dca8daa7f31fec659150bbeabfc6',
|
|
||||||
),
|
|
||||||
'twig/twig' =>
|
|
||||||
array (
|
|
||||||
'pretty_version' => 'v3.3.3',
|
|
||||||
'version' => '3.3.3.0',
|
|
||||||
'aliases' =>
|
|
||||||
array (
|
|
||||||
),
|
|
||||||
'reference' => 'a27fa056df8a6384316288ca8b0fa3a35fdeb569',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
|
@ -1,26 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// platform_check.php @generated by Composer
|
|
||||||
|
|
||||||
$issues = array();
|
|
||||||
|
|
||||||
if (!(PHP_VERSION_ID >= 80000)) {
|
|
||||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.0". You are running ' . PHP_VERSION . '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($issues) {
|
|
||||||
if (!headers_sent()) {
|
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
|
||||||
}
|
|
||||||
if (!ini_get('display_errors')) {
|
|
||||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
|
||||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
|
||||||
} elseif (!headers_sent()) {
|
|
||||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
trigger_error(
|
|
||||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
|
||||||
E_USER_ERROR
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,227 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Polyfill\Ctype;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ctype implementation through regex.
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*
|
|
||||||
* @author Gert de Pagter <BackEndTea@gmail.com>
|
|
||||||
*/
|
|
||||||
final class Ctype
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-alnum
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_alnum($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a letter, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-alpha
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_alpha($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-cntrl
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_cntrl($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-digit
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_digit($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-graph
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_graph($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a lowercase letter.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-lower
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_lower($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-print
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_print($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-punct
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_punct($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-space
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_space($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is an uppercase letter.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-upper
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_upper($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise.
|
|
||||||
*
|
|
||||||
* @see https://php.net/ctype-xdigit
|
|
||||||
*
|
|
||||||
* @param string|int $text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public static function ctype_xdigit($text)
|
|
||||||
{
|
|
||||||
$text = self::convert_int_to_char_for_ctype($text);
|
|
||||||
|
|
||||||
return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts integers to their char versions according to normal ctype behaviour, if needed.
|
|
||||||
*
|
|
||||||
* If an integer between -128 and 255 inclusive is provided,
|
|
||||||
* it is interpreted as the ASCII value of a single character
|
|
||||||
* (negative values have 256 added in order to allow characters in the Extended ASCII range).
|
|
||||||
* Any other integer is interpreted as a string containing the decimal digits of the integer.
|
|
||||||
*
|
|
||||||
* @param string|int $int
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private static function convert_int_to_char_for_ctype($int)
|
|
||||||
{
|
|
||||||
if (!\is_int($int)) {
|
|
||||||
return $int;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($int < -128 || $int > 255) {
|
|
||||||
return (string) $int;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($int < 0) {
|
|
||||||
$int += 256;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \chr($int);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2018-2019 Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
|
@ -1,12 +0,0 @@
|
||||||
Symfony Polyfill / Ctype
|
|
||||||
========================
|
|
||||||
|
|
||||||
This component provides `ctype_*` functions to users who run php versions without the ctype extension.
|
|
||||||
|
|
||||||
More information can be found in the
|
|
||||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
This library is released under the [MIT license](LICENSE).
|
|
|
@ -1,50 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Ctype as p;
|
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 80000) {
|
|
||||||
return require __DIR__.'/bootstrap80.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('ctype_alnum')) {
|
|
||||||
function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_alpha')) {
|
|
||||||
function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_cntrl')) {
|
|
||||||
function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_digit')) {
|
|
||||||
function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_graph')) {
|
|
||||||
function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_lower')) {
|
|
||||||
function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_print')) {
|
|
||||||
function ctype_print($text) { return p\Ctype::ctype_print($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_punct')) {
|
|
||||||
function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_space')) {
|
|
||||||
function ctype_space($text) { return p\Ctype::ctype_space($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_upper')) {
|
|
||||||
function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_xdigit')) {
|
|
||||||
function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Ctype as p;
|
|
||||||
|
|
||||||
if (!function_exists('ctype_alnum')) {
|
|
||||||
function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_alpha')) {
|
|
||||||
function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_cntrl')) {
|
|
||||||
function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_digit')) {
|
|
||||||
function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_graph')) {
|
|
||||||
function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_lower')) {
|
|
||||||
function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_print')) {
|
|
||||||
function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_punct')) {
|
|
||||||
function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_space')) {
|
|
||||||
function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_upper')) {
|
|
||||||
function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); }
|
|
||||||
}
|
|
||||||
if (!function_exists('ctype_xdigit')) {
|
|
||||||
function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); }
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-ctype",
|
|
||||||
"type": "library",
|
|
||||||
"description": "Symfony polyfill for ctype functions",
|
|
||||||
"keywords": ["polyfill", "compatibility", "portable", "ctype"],
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gert de Pagter",
|
|
||||||
"email": "BackEndTea@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": { "Symfony\\Polyfill\\Ctype\\": "" },
|
|
||||||
"files": [ "bootstrap.php" ]
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-ctype": "For best performance"
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.23-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
Copyright (c) 2015-2019 Fabien Potencier
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
|
@ -1,870 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Polyfill\Mbstring;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
|
|
||||||
*
|
|
||||||
* Implemented:
|
|
||||||
* - mb_chr - Returns a specific character from its Unicode code point
|
|
||||||
* - mb_convert_encoding - Convert character encoding
|
|
||||||
* - mb_convert_variables - Convert character code in variable(s)
|
|
||||||
* - mb_decode_mimeheader - Decode string in MIME header field
|
|
||||||
* - mb_encode_mimeheader - Encode string for MIME header XXX NATIVE IMPLEMENTATION IS REALLY BUGGED
|
|
||||||
* - mb_decode_numericentity - Decode HTML numeric string reference to character
|
|
||||||
* - mb_encode_numericentity - Encode character to HTML numeric string reference
|
|
||||||
* - mb_convert_case - Perform case folding on a string
|
|
||||||
* - mb_detect_encoding - Detect character encoding
|
|
||||||
* - mb_get_info - Get internal settings of mbstring
|
|
||||||
* - mb_http_input - Detect HTTP input character encoding
|
|
||||||
* - mb_http_output - Set/Get HTTP output character encoding
|
|
||||||
* - mb_internal_encoding - Set/Get internal character encoding
|
|
||||||
* - mb_list_encodings - Returns an array of all supported encodings
|
|
||||||
* - mb_ord - Returns the Unicode code point of a character
|
|
||||||
* - mb_output_handler - Callback function converts character encoding in output buffer
|
|
||||||
* - mb_scrub - Replaces ill-formed byte sequences with substitute characters
|
|
||||||
* - mb_strlen - Get string length
|
|
||||||
* - mb_strpos - Find position of first occurrence of string in a string
|
|
||||||
* - mb_strrpos - Find position of last occurrence of a string in a string
|
|
||||||
* - mb_str_split - Convert a string to an array
|
|
||||||
* - mb_strtolower - Make a string lowercase
|
|
||||||
* - mb_strtoupper - Make a string uppercase
|
|
||||||
* - mb_substitute_character - Set/Get substitution character
|
|
||||||
* - mb_substr - Get part of string
|
|
||||||
* - mb_stripos - Finds position of first occurrence of a string within another, case insensitive
|
|
||||||
* - mb_stristr - Finds first occurrence of a string within another, case insensitive
|
|
||||||
* - mb_strrchr - Finds the last occurrence of a character in a string within another
|
|
||||||
* - mb_strrichr - Finds the last occurrence of a character in a string within another, case insensitive
|
|
||||||
* - mb_strripos - Finds position of last occurrence of a string within another, case insensitive
|
|
||||||
* - mb_strstr - Finds first occurrence of a string within another
|
|
||||||
* - mb_strwidth - Return width of string
|
|
||||||
* - mb_substr_count - Count the number of substring occurrences
|
|
||||||
*
|
|
||||||
* Not implemented:
|
|
||||||
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
|
||||||
* - mb_ereg_* - Regular expression with multibyte support
|
|
||||||
* - mb_parse_str - Parse GET/POST/COOKIE data and set global variable
|
|
||||||
* - mb_preferred_mime_name - Get MIME charset string
|
|
||||||
* - mb_regex_encoding - Returns current encoding for multibyte regex as string
|
|
||||||
* - mb_regex_set_options - Set/Get the default options for mbregex functions
|
|
||||||
* - mb_send_mail - Send encoded mail
|
|
||||||
* - mb_split - Split multibyte string using regular expression
|
|
||||||
* - mb_strcut - Get part of string
|
|
||||||
* - mb_strimwidth - Get truncated string with specified width
|
|
||||||
*
|
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*/
|
|
||||||
final class Mbstring
|
|
||||||
{
|
|
||||||
public const MB_CASE_FOLD = \PHP_INT_MAX;
|
|
||||||
|
|
||||||
private const CASE_FOLD = [
|
|
||||||
['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
|
|
||||||
['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'],
|
|
||||||
];
|
|
||||||
|
|
||||||
private static $encodingList = ['ASCII', 'UTF-8'];
|
|
||||||
private static $language = 'neutral';
|
|
||||||
private static $internalEncoding = 'UTF-8';
|
|
||||||
|
|
||||||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
|
||||||
{
|
|
||||||
if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
|
|
||||||
$fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
|
|
||||||
} else {
|
|
||||||
$fromEncoding = self::getEncoding($fromEncoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
$toEncoding = self::getEncoding($toEncoding);
|
|
||||||
|
|
||||||
if ('BASE64' === $fromEncoding) {
|
|
||||||
$s = base64_decode($s);
|
|
||||||
$fromEncoding = $toEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('BASE64' === $toEncoding) {
|
|
||||||
return base64_encode($s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
|
|
||||||
if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
|
|
||||||
$fromEncoding = 'Windows-1252';
|
|
||||||
}
|
|
||||||
if ('UTF-8' !== $fromEncoding) {
|
|
||||||
$s = \iconv($fromEncoding, 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return preg_replace_callback('/[\x80-\xFF]+/', [__CLASS__, 'html_encoding_callback'], $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('HTML-ENTITIES' === $fromEncoding) {
|
|
||||||
$s = html_entity_decode($s, \ENT_COMPAT, 'UTF-8');
|
|
||||||
$fromEncoding = 'UTF-8';
|
|
||||||
}
|
|
||||||
|
|
||||||
return \iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_convert_variables($toEncoding, $fromEncoding, &...$vars)
|
|
||||||
{
|
|
||||||
$ok = true;
|
|
||||||
array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
|
|
||||||
if (false === $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
|
|
||||||
$ok = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return $ok ? $fromEncoding : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_decode_mimeheader($s)
|
|
||||||
{
|
|
||||||
return \iconv_mime_decode($s, 2, self::$internalEncoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
|
|
||||||
{
|
|
||||||
trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', \E_USER_WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_decode_numericentity($s, $convmap, $encoding = null)
|
|
||||||
{
|
|
||||||
if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
|
|
||||||
trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $encoding && !is_scalar($encoding)) {
|
|
||||||
trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return ''; // Instead of null (cf. mb_encode_numericentity).
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = (string) $s;
|
|
||||||
if ('' === $s) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
|
|
||||||
if ('UTF-8' === $encoding) {
|
|
||||||
$encoding = null;
|
|
||||||
if (!preg_match('//u', $s)) {
|
|
||||||
$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
$cnt = floor(\count($convmap) / 4) * 4;
|
|
||||||
|
|
||||||
for ($i = 0; $i < $cnt; $i += 4) {
|
|
||||||
// collector_decode_htmlnumericentity ignores $convmap[$i + 3]
|
|
||||||
$convmap[$i] += $convmap[$i + 2];
|
|
||||||
$convmap[$i + 1] += $convmap[$i + 2];
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
|
|
||||||
$c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
|
|
||||||
for ($i = 0; $i < $cnt; $i += 4) {
|
|
||||||
if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
|
|
||||||
return self::mb_chr($c - $convmap[$i + 2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $m[0];
|
|
||||||
}, $s);
|
|
||||||
|
|
||||||
if (null === $encoding) {
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \iconv('UTF-8', $encoding.'//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
|
|
||||||
{
|
|
||||||
if (null !== $s && !is_scalar($s) && !(\is_object($s) && method_exists($s, '__toString'))) {
|
|
||||||
trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_array($convmap) || (80000 > \PHP_VERSION_ID && !$convmap)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $encoding && !is_scalar($encoding)) {
|
|
||||||
trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return null; // Instead of '' (cf. mb_decode_numericentity).
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $is_hex && !is_scalar($is_hex)) {
|
|
||||||
trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = (string) $s;
|
|
||||||
if ('' === $s) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
|
|
||||||
if ('UTF-8' === $encoding) {
|
|
||||||
$encoding = null;
|
|
||||||
if (!preg_match('//u', $s)) {
|
|
||||||
$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
|
|
||||||
|
|
||||||
$cnt = floor(\count($convmap) / 4) * 4;
|
|
||||||
$i = 0;
|
|
||||||
$len = \strlen($s);
|
|
||||||
$result = '';
|
|
||||||
|
|
||||||
while ($i < $len) {
|
|
||||||
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
|
||||||
$uchr = substr($s, $i, $ulen);
|
|
||||||
$i += $ulen;
|
|
||||||
$c = self::mb_ord($uchr);
|
|
||||||
|
|
||||||
for ($j = 0; $j < $cnt; $j += 4) {
|
|
||||||
if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
|
|
||||||
$cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
|
|
||||||
$result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
|
|
||||||
continue 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$result .= $uchr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $encoding) {
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \iconv('UTF-8', $encoding.'//IGNORE', $result);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_convert_case($s, $mode, $encoding = null)
|
|
||||||
{
|
|
||||||
$s = (string) $s;
|
|
||||||
if ('' === $s) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
|
|
||||||
if ('UTF-8' === $encoding) {
|
|
||||||
$encoding = null;
|
|
||||||
if (!preg_match('//u', $s)) {
|
|
||||||
$s = @\iconv('UTF-8', 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\MB_CASE_TITLE == $mode) {
|
|
||||||
static $titleRegexp = null;
|
|
||||||
if (null === $titleRegexp) {
|
|
||||||
$titleRegexp = self::getData('titleCaseRegexp');
|
|
||||||
}
|
|
||||||
$s = preg_replace_callback($titleRegexp, [__CLASS__, 'title_case'], $s);
|
|
||||||
} else {
|
|
||||||
if (\MB_CASE_UPPER == $mode) {
|
|
||||||
static $upper = null;
|
|
||||||
if (null === $upper) {
|
|
||||||
$upper = self::getData('upperCase');
|
|
||||||
}
|
|
||||||
$map = $upper;
|
|
||||||
} else {
|
|
||||||
if (self::MB_CASE_FOLD === $mode) {
|
|
||||||
$s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static $lower = null;
|
|
||||||
if (null === $lower) {
|
|
||||||
$lower = self::getData('lowerCase');
|
|
||||||
}
|
|
||||||
$map = $lower;
|
|
||||||
}
|
|
||||||
|
|
||||||
static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4];
|
|
||||||
|
|
||||||
$i = 0;
|
|
||||||
$len = \strlen($s);
|
|
||||||
|
|
||||||
while ($i < $len) {
|
|
||||||
$ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
|
|
||||||
$uchr = substr($s, $i, $ulen);
|
|
||||||
$i += $ulen;
|
|
||||||
|
|
||||||
if (isset($map[$uchr])) {
|
|
||||||
$uchr = $map[$uchr];
|
|
||||||
$nlen = \strlen($uchr);
|
|
||||||
|
|
||||||
if ($nlen == $ulen) {
|
|
||||||
$nlen = $i;
|
|
||||||
do {
|
|
||||||
$s[--$nlen] = $uchr[--$ulen];
|
|
||||||
} while ($ulen);
|
|
||||||
} else {
|
|
||||||
$s = substr_replace($s, $uchr, $i - $ulen, $ulen);
|
|
||||||
$len += $nlen - $ulen;
|
|
||||||
$i += $nlen - $ulen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $encoding) {
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \iconv('UTF-8', $encoding.'//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_internal_encoding($encoding = null)
|
|
||||||
{
|
|
||||||
if (null === $encoding) {
|
|
||||||
return self::$internalEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
$normalizedEncoding = self::getEncoding($encoding);
|
|
||||||
|
|
||||||
if ('UTF-8' === $normalizedEncoding || false !== @\iconv($normalizedEncoding, $normalizedEncoding, ' ')) {
|
|
||||||
self::$internalEncoding = $normalizedEncoding;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (80000 > \PHP_VERSION_ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \ValueError(sprintf('Argument #1 ($encoding) must be a valid encoding, "%s" given', $encoding));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_language($lang = null)
|
|
||||||
{
|
|
||||||
if (null === $lang) {
|
|
||||||
return self::$language;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($normalizedLang = strtolower($lang)) {
|
|
||||||
case 'uni':
|
|
||||||
case 'neutral':
|
|
||||||
self::$language = $normalizedLang;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (80000 > \PHP_VERSION_ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \ValueError(sprintf('Argument #1 ($language) must be a valid language, "%s" given', $lang));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_list_encodings()
|
|
||||||
{
|
|
||||||
return ['UTF-8'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_encoding_aliases($encoding)
|
|
||||||
{
|
|
||||||
switch (strtoupper($encoding)) {
|
|
||||||
case 'UTF8':
|
|
||||||
case 'UTF-8':
|
|
||||||
return ['utf8'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_check_encoding($var = null, $encoding = null)
|
|
||||||
{
|
|
||||||
if (null === $encoding) {
|
|
||||||
if (null === $var) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
$encoding = self::$internalEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::mb_detect_encoding($var, [$encoding]) || false !== @\iconv($encoding, $encoding, $var);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
|
|
||||||
{
|
|
||||||
if (null === $encodingList) {
|
|
||||||
$encodingList = self::$encodingList;
|
|
||||||
} else {
|
|
||||||
if (!\is_array($encodingList)) {
|
|
||||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
|
||||||
}
|
|
||||||
$encodingList = array_map('strtoupper', $encodingList);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($encodingList as $enc) {
|
|
||||||
switch ($enc) {
|
|
||||||
case 'ASCII':
|
|
||||||
if (!preg_match('/[\x80-\xFF]/', $str)) {
|
|
||||||
return $enc;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'UTF8':
|
|
||||||
case 'UTF-8':
|
|
||||||
if (preg_match('//u', $str)) {
|
|
||||||
return 'UTF-8';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (0 === strncmp($enc, 'ISO-8859-', 9)) {
|
|
||||||
return $enc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_detect_order($encodingList = null)
|
|
||||||
{
|
|
||||||
if (null === $encodingList) {
|
|
||||||
return self::$encodingList;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\is_array($encodingList)) {
|
|
||||||
$encodingList = array_map('trim', explode(',', $encodingList));
|
|
||||||
}
|
|
||||||
$encodingList = array_map('strtoupper', $encodingList);
|
|
||||||
|
|
||||||
foreach ($encodingList as $enc) {
|
|
||||||
switch ($enc) {
|
|
||||||
default:
|
|
||||||
if (strncmp($enc, 'ISO-8859-', 9)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// no break
|
|
||||||
case 'ASCII':
|
|
||||||
case 'UTF8':
|
|
||||||
case 'UTF-8':
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$encodingList = $encodingList;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strlen($s, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
|
||||||
return \strlen($s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return @\iconv_strlen($s, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
|
||||||
return strpos($haystack, $needle, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
$needle = (string) $needle;
|
|
||||||
if ('' === $needle) {
|
|
||||||
if (80000 > \PHP_VERSION_ID) {
|
|
||||||
trigger_error(__METHOD__.': Empty delimiter', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return \iconv_strpos($haystack, $needle, $offset, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
|
||||||
return strrpos($haystack, $needle, $offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($offset != (int) $offset) {
|
|
||||||
$offset = 0;
|
|
||||||
} elseif ($offset = (int) $offset) {
|
|
||||||
if ($offset < 0) {
|
|
||||||
if (0 > $offset += self::mb_strlen($needle)) {
|
|
||||||
$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
|
|
||||||
}
|
|
||||||
$offset = 0;
|
|
||||||
} else {
|
|
||||||
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$pos = '' !== $needle || 80000 > \PHP_VERSION_ID
|
|
||||||
? \iconv_strrpos($haystack, $needle, $encoding)
|
|
||||||
: self::mb_strlen($haystack, $encoding);
|
|
||||||
|
|
||||||
return false !== $pos ? $offset + $pos : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_str_split($string, $split_length = 1, $encoding = null)
|
|
||||||
{
|
|
||||||
if (null !== $string && !is_scalar($string) && !(\is_object($string) && method_exists($string, '__toString'))) {
|
|
||||||
trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', \E_USER_WARNING);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 > $split_length = (int) $split_length) {
|
|
||||||
if (80000 > \PHP_VERSION_ID) {
|
|
||||||
trigger_error('The length of each segment must be greater than zero', \E_USER_WARNING);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \ValueError('Argument #2 ($length) must be greater than 0');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $encoding) {
|
|
||||||
$encoding = mb_internal_encoding();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
|
|
||||||
$rx = '/(';
|
|
||||||
while (65535 < $split_length) {
|
|
||||||
$rx .= '.{65535}';
|
|
||||||
$split_length -= 65535;
|
|
||||||
}
|
|
||||||
$rx .= '.{'.$split_length.'})/us';
|
|
||||||
|
|
||||||
return preg_split($rx, $string, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = [];
|
|
||||||
$length = mb_strlen($string, $encoding);
|
|
||||||
|
|
||||||
for ($i = 0; $i < $length; $i += $split_length) {
|
|
||||||
$result[] = mb_substr($string, $i, $split_length, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strtolower($s, $encoding = null)
|
|
||||||
{
|
|
||||||
return self::mb_convert_case($s, \MB_CASE_LOWER, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strtoupper($s, $encoding = null)
|
|
||||||
{
|
|
||||||
return self::mb_convert_case($s, \MB_CASE_UPPER, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_substitute_character($c = null)
|
|
||||||
{
|
|
||||||
if (null === $c) {
|
|
||||||
return 'none';
|
|
||||||
}
|
|
||||||
if (0 === strcasecmp($c, 'none')) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (80000 > \PHP_VERSION_ID) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new \ValueError('Argument #1 ($substitute_character) must be "none", "long", "entity" or a valid codepoint');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_substr($s, $start, $length = null, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
|
||||||
return (string) substr($s, $start, null === $length ? 2147483647 : $length);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($start < 0) {
|
|
||||||
$start = \iconv_strlen($s, $encoding) + $start;
|
|
||||||
if ($start < 0) {
|
|
||||||
$start = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null === $length) {
|
|
||||||
$length = 2147483647;
|
|
||||||
} elseif ($length < 0) {
|
|
||||||
$length = \iconv_strlen($s, $encoding) + $length - $start;
|
|
||||||
if ($length < 0) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (string) \iconv_substr($s, $start, $length, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
|
|
||||||
{
|
|
||||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
|
||||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
|
||||||
|
|
||||||
return self::mb_strpos($haystack, $needle, $offset, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
|
|
||||||
{
|
|
||||||
$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
|
|
||||||
|
|
||||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
if ('CP850' === $encoding || 'ASCII' === $encoding) {
|
|
||||||
$pos = strrpos($haystack, $needle);
|
|
||||||
} else {
|
|
||||||
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
|
||||||
$pos = \iconv_strrpos($haystack, $needle, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
|
|
||||||
{
|
|
||||||
$needle = self::mb_substr($needle, 0, 1, $encoding);
|
|
||||||
$pos = self::mb_strripos($haystack, $needle, $encoding);
|
|
||||||
|
|
||||||
return self::getSubpart($pos, $part, $haystack, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
|
|
||||||
{
|
|
||||||
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
|
|
||||||
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
|
|
||||||
|
|
||||||
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
|
|
||||||
{
|
|
||||||
$pos = strpos($haystack, $needle);
|
|
||||||
if (false === $pos) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($part) {
|
|
||||||
return substr($haystack, 0, $pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
return substr($haystack, $pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_get_info($type = 'all')
|
|
||||||
{
|
|
||||||
$info = [
|
|
||||||
'internal_encoding' => self::$internalEncoding,
|
|
||||||
'http_output' => 'pass',
|
|
||||||
'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
|
|
||||||
'func_overload' => 0,
|
|
||||||
'func_overload_list' => 'no overload',
|
|
||||||
'mail_charset' => 'UTF-8',
|
|
||||||
'mail_header_encoding' => 'BASE64',
|
|
||||||
'mail_body_encoding' => 'BASE64',
|
|
||||||
'illegal_chars' => 0,
|
|
||||||
'encoding_translation' => 'Off',
|
|
||||||
'language' => self::$language,
|
|
||||||
'detect_order' => self::$encodingList,
|
|
||||||
'substitute_character' => 'none',
|
|
||||||
'strict_detection' => 'Off',
|
|
||||||
];
|
|
||||||
|
|
||||||
if ('all' === $type) {
|
|
||||||
return $info;
|
|
||||||
}
|
|
||||||
if (isset($info[$type])) {
|
|
||||||
return $info[$type];
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_http_input($type = '')
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_http_output($encoding = null)
|
|
||||||
{
|
|
||||||
return null !== $encoding ? 'pass' === $encoding : 'pass';
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_strwidth($s, $encoding = null)
|
|
||||||
{
|
|
||||||
$encoding = self::getEncoding($encoding);
|
|
||||||
|
|
||||||
if ('UTF-8' !== $encoding) {
|
|
||||||
$s = \iconv($encoding, 'UTF-8//IGNORE', $s);
|
|
||||||
}
|
|
||||||
|
|
||||||
$s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
|
|
||||||
|
|
||||||
return ($wide << 1) + \iconv_strlen($s, 'UTF-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_substr_count($haystack, $needle, $encoding = null)
|
|
||||||
{
|
|
||||||
return substr_count($haystack, $needle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_output_handler($contents, $status)
|
|
||||||
{
|
|
||||||
return $contents;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_chr($code, $encoding = null)
|
|
||||||
{
|
|
||||||
if (0x80 > $code %= 0x200000) {
|
|
||||||
$s = \chr($code);
|
|
||||||
} elseif (0x800 > $code) {
|
|
||||||
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
|
|
||||||
} elseif (0x10000 > $code) {
|
|
||||||
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
|
||||||
} else {
|
|
||||||
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
|
||||||
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function mb_ord($s, $encoding = null)
|
|
||||||
{
|
|
||||||
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
|
|
||||||
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (1 === \strlen($s)) {
|
|
||||||
return \ord($s);
|
|
||||||
}
|
|
||||||
|
|
||||||
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
|
|
||||||
if (0xF0 <= $code) {
|
|
||||||
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
|
|
||||||
}
|
|
||||||
if (0xE0 <= $code) {
|
|
||||||
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
|
|
||||||
}
|
|
||||||
if (0xC0 <= $code) {
|
|
||||||
return (($code - 0xC0) << 6) + $s[2] - 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $code;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getSubpart($pos, $part, $haystack, $encoding)
|
|
||||||
{
|
|
||||||
if (false === $pos) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($part) {
|
|
||||||
return self::mb_substr($haystack, 0, $pos, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::mb_substr($haystack, $pos, null, $encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function html_encoding_callback(array $m)
|
|
||||||
{
|
|
||||||
$i = 1;
|
|
||||||
$entities = '';
|
|
||||||
$m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
|
|
||||||
|
|
||||||
while (isset($m[$i])) {
|
|
||||||
if (0x80 > $m[$i]) {
|
|
||||||
$entities .= \chr($m[$i++]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (0xF0 <= $m[$i]) {
|
|
||||||
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
|
||||||
} elseif (0xE0 <= $m[$i]) {
|
|
||||||
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
|
|
||||||
} else {
|
|
||||||
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
|
|
||||||
}
|
|
||||||
|
|
||||||
$entities .= '&#'.$c.';';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $entities;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function title_case(array $s)
|
|
||||||
{
|
|
||||||
return self::mb_convert_case($s[1], \MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], \MB_CASE_LOWER, 'UTF-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getData($file)
|
|
||||||
{
|
|
||||||
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
|
|
||||||
return require $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function getEncoding($encoding)
|
|
||||||
{
|
|
||||||
if (null === $encoding) {
|
|
||||||
return self::$internalEncoding;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('UTF-8' === $encoding) {
|
|
||||||
return 'UTF-8';
|
|
||||||
}
|
|
||||||
|
|
||||||
$encoding = strtoupper($encoding);
|
|
||||||
|
|
||||||
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
|
|
||||||
return 'CP850';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('UTF8' === $encoding) {
|
|
||||||
return 'UTF-8';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $encoding;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
Symfony Polyfill / Mbstring
|
|
||||||
===========================
|
|
||||||
|
|
||||||
This component provides a partial, native PHP implementation for the
|
|
||||||
[Mbstring](https://php.net/mbstring) extension.
|
|
||||||
|
|
||||||
More information can be found in the
|
|
||||||
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md).
|
|
||||||
|
|
||||||
License
|
|
||||||
=======
|
|
||||||
|
|
||||||
This library is released under the [MIT license](LICENSE).
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,147 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Mbstring as p;
|
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 80000) {
|
|
||||||
return require __DIR__.'/bootstrap80.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('mb_convert_encoding')) {
|
|
||||||
function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_decode_mimeheader')) {
|
|
||||||
function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encode_mimeheader')) {
|
|
||||||
function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = "\r\n", $indent = 0) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_decode_numericentity')) {
|
|
||||||
function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encode_numericentity')) {
|
|
||||||
function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_convert_case')) {
|
|
||||||
function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_internal_encoding')) {
|
|
||||||
function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_language')) {
|
|
||||||
function mb_language($language = null) { return p\Mbstring::mb_language($language); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_list_encodings')) {
|
|
||||||
function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encoding_aliases')) {
|
|
||||||
function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_check_encoding')) {
|
|
||||||
function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_detect_encoding')) {
|
|
||||||
function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_detect_order')) {
|
|
||||||
function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_parse_str')) {
|
|
||||||
function mb_parse_str($string, &$result = []) { parse_str($string, $result); return (bool) $result; }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strlen')) {
|
|
||||||
function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strpos')) {
|
|
||||||
function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strtolower')) {
|
|
||||||
function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strtoupper')) {
|
|
||||||
function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substitute_character')) {
|
|
||||||
function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substr')) {
|
|
||||||
function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_stripos')) {
|
|
||||||
function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_stristr')) {
|
|
||||||
function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrchr')) {
|
|
||||||
function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrichr')) {
|
|
||||||
function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strripos')) {
|
|
||||||
function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrpos')) {
|
|
||||||
function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strstr')) {
|
|
||||||
function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_get_info')) {
|
|
||||||
function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_http_output')) {
|
|
||||||
function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strwidth')) {
|
|
||||||
function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substr_count')) {
|
|
||||||
function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_output_handler')) {
|
|
||||||
function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_http_input')) {
|
|
||||||
function mb_http_input($type = null) { return p\Mbstring::mb_http_input($type); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('mb_convert_variables')) {
|
|
||||||
function mb_convert_variables($to_encoding, $from_encoding, &...$vars) { return p\Mbstring::mb_convert_variables($to_encoding, $from_encoding, ...$vars); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('mb_ord')) {
|
|
||||||
function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_chr')) {
|
|
||||||
function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_scrub')) {
|
|
||||||
function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_str_split')) {
|
|
||||||
function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_loaded('mbstring')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined('MB_CASE_UPPER')) {
|
|
||||||
define('MB_CASE_UPPER', 0);
|
|
||||||
}
|
|
||||||
if (!defined('MB_CASE_LOWER')) {
|
|
||||||
define('MB_CASE_LOWER', 1);
|
|
||||||
}
|
|
||||||
if (!defined('MB_CASE_TITLE')) {
|
|
||||||
define('MB_CASE_TITLE', 2);
|
|
||||||
}
|
|
|
@ -1,143 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Symfony\Polyfill\Mbstring as p;
|
|
||||||
|
|
||||||
if (!function_exists('mb_convert_encoding')) {
|
|
||||||
function mb_convert_encoding(array|string|null $string, ?string $to_encoding, array|string|null $from_encoding = null): array|string|false { return p\Mbstring::mb_convert_encoding($string ?? '', (string) $to_encoding, $from_encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_decode_mimeheader')) {
|
|
||||||
function mb_decode_mimeheader(?string $string): string { return p\Mbstring::mb_decode_mimeheader((string) $string); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encode_mimeheader')) {
|
|
||||||
function mb_encode_mimeheader(?string $string, ?string $charset = null, ?string $transfer_encoding = null, ?string $newline = "\r\n", ?int $indent = 0): string { return p\Mbstring::mb_encode_mimeheader((string) $string, $charset, $transfer_encoding, (string) $newline, (int) $indent); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_decode_numericentity')) {
|
|
||||||
function mb_decode_numericentity(?string $string, array $map, ?string $encoding = null): string { return p\Mbstring::mb_decode_numericentity((string) $string, $map, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encode_numericentity')) {
|
|
||||||
function mb_encode_numericentity(?string $string, array $map, ?string $encoding = null, ?bool $hex = false): string { return p\Mbstring::mb_encode_numericentity((string) $string, $map, $encoding, (bool) $hex); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_convert_case')) {
|
|
||||||
function mb_convert_case(?string $string, ?int $mode, ?string $encoding = null): string { return p\Mbstring::mb_convert_case((string) $string, (int) $mode, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_internal_encoding')) {
|
|
||||||
function mb_internal_encoding(?string $encoding = null): string|bool { return p\Mbstring::mb_internal_encoding($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_language')) {
|
|
||||||
function mb_language(?string $language = null): string|bool { return p\Mbstring::mb_language($language); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_list_encodings')) {
|
|
||||||
function mb_list_encodings(): array { return p\Mbstring::mb_list_encodings(); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_encoding_aliases')) {
|
|
||||||
function mb_encoding_aliases(?string $encoding): array { return p\Mbstring::mb_encoding_aliases((string) $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_check_encoding')) {
|
|
||||||
function mb_check_encoding(array|string|null $value = null, ?string $encoding = null): bool { return p\Mbstring::mb_check_encoding($value, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_detect_encoding')) {
|
|
||||||
function mb_detect_encoding(?string $string, array|string|null $encodings = null, ?bool $strict = false): string|false { return p\Mbstring::mb_detect_encoding((string) $string, $encodings, (bool) $strict); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_detect_order')) {
|
|
||||||
function mb_detect_order(array|string|null $encoding = null): array|bool { return p\Mbstring::mb_detect_order($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_parse_str')) {
|
|
||||||
function mb_parse_str(?string $string, &$result = []): bool { parse_str((string) $string, $result); return (bool) $result; }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strlen')) {
|
|
||||||
function mb_strlen(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strlen((string) $string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strpos')) {
|
|
||||||
function mb_strpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strtolower')) {
|
|
||||||
function mb_strtolower(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtolower((string) $string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strtoupper')) {
|
|
||||||
function mb_strtoupper(?string $string, ?string $encoding = null): string { return p\Mbstring::mb_strtoupper((string) $string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substitute_character')) {
|
|
||||||
function mb_substitute_character(string|int|null $substitute_character = null): string|int|bool { return p\Mbstring::mb_substitute_character($substitute_character); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substr')) {
|
|
||||||
function mb_substr(?string $string, ?int $start, ?int $length = null, ?string $encoding = null): string { return p\Mbstring::mb_substr((string) $string, (int) $start, $length, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_stripos')) {
|
|
||||||
function mb_stripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_stripos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_stristr')) {
|
|
||||||
function mb_stristr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_stristr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrchr')) {
|
|
||||||
function mb_strrchr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrchr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrichr')) {
|
|
||||||
function mb_strrichr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strrichr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strripos')) {
|
|
||||||
function mb_strripos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strripos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strrpos')) {
|
|
||||||
function mb_strrpos(?string $haystack, ?string $needle, ?int $offset = 0, ?string $encoding = null): int|false { return p\Mbstring::mb_strrpos((string) $haystack, (string) $needle, (int) $offset, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strstr')) {
|
|
||||||
function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_get_info')) {
|
|
||||||
function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_http_output')) {
|
|
||||||
function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_strwidth')) {
|
|
||||||
function mb_strwidth(?string $string, ?string $encoding = null): int { return p\Mbstring::mb_strwidth((string) $string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_substr_count')) {
|
|
||||||
function mb_substr_count(?string $haystack, ?string $needle, ?string $encoding = null): int { return p\Mbstring::mb_substr_count((string) $haystack, (string) $needle, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_output_handler')) {
|
|
||||||
function mb_output_handler(?string $string, ?int $status): string { return p\Mbstring::mb_output_handler((string) $string, (int) $status); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_http_input')) {
|
|
||||||
function mb_http_input(?string $type = null): array|string|false { return p\Mbstring::mb_http_input($type); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('mb_convert_variables')) {
|
|
||||||
function mb_convert_variables(?string $to_encoding, array|string|null $from_encoding, mixed &$var, mixed &...$vars): string|false { return p\Mbstring::mb_convert_variables((string) $to_encoding, $from_encoding ?? '', $var, ...$vars); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('mb_ord')) {
|
|
||||||
function mb_ord(?string $string, ?string $encoding = null): int|false { return p\Mbstring::mb_ord((string) $string, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_chr')) {
|
|
||||||
function mb_chr(?int $codepoint, ?string $encoding = null): string|false { return p\Mbstring::mb_chr((int) $codepoint, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_scrub')) {
|
|
||||||
function mb_scrub(?string $string, ?string $encoding = null): string { $encoding ??= mb_internal_encoding(); return mb_convert_encoding((string) $string, $encoding, $encoding); }
|
|
||||||
}
|
|
||||||
if (!function_exists('mb_str_split')) {
|
|
||||||
function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_loaded('mbstring')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined('MB_CASE_UPPER')) {
|
|
||||||
define('MB_CASE_UPPER', 0);
|
|
||||||
}
|
|
||||||
if (!defined('MB_CASE_LOWER')) {
|
|
||||||
define('MB_CASE_LOWER', 1);
|
|
||||||
}
|
|
||||||
if (!defined('MB_CASE_TITLE')) {
|
|
||||||
define('MB_CASE_TITLE', 2);
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
"name": "symfony/polyfill-mbstring",
|
|
||||||
"type": "library",
|
|
||||||
"description": "Symfony polyfill for the Mbstring extension",
|
|
||||||
"keywords": ["polyfill", "shim", "compatibility", "portable", "mbstring"],
|
|
||||||
"homepage": "https://symfony.com",
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Nicolas Grekas",
|
|
||||||
"email": "p@tchwork.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "https://symfony.com/contributors"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.1"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" },
|
|
||||||
"files": [ "bootstrap.php" ]
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"ext-mbstring": "For best performance"
|
|
||||||
},
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-main": "1.23-dev"
|
|
||||||
},
|
|
||||||
"thanks": {
|
|
||||||
"name": "symfony/polyfill",
|
|
||||||
"url": "https://github.com/symfony/polyfill"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
; top-most EditorConfig file
|
|
||||||
root = true
|
|
||||||
|
|
||||||
; Unix-style newlines
|
|
||||||
[*]
|
|
||||||
end_of_line = LF
|
|
||||||
|
|
||||||
[*.php]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
[*.test]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
[*.rst]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 4
|
|
|
@ -1,3 +0,0 @@
|
||||||
/extra/** export-ignore
|
|
||||||
/tests export-ignore
|
|
||||||
/phpunit.xml.dist export-ignore
|
|
|
@ -1,173 +0,0 @@
|
||||||
name: "CI"
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '3.x'
|
|
||||||
|
|
||||||
env:
|
|
||||||
SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE: 1
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
name: "PHP ${{ matrix.php-version }}"
|
|
||||||
|
|
||||||
runs-on: 'ubuntu-latest'
|
|
||||||
|
|
||||||
continue-on-error: ${{ matrix.experimental }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
php-version:
|
|
||||||
- '7.2.5'
|
|
||||||
- '7.3'
|
|
||||||
- '7.4'
|
|
||||||
- '8.0'
|
|
||||||
composer-options: ['']
|
|
||||||
experimental: [false]
|
|
||||||
include:
|
|
||||||
- { php-version: '8.1', experimental: true, composer-options: '--ignore-platform-req=php' }
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Checkout code"
|
|
||||||
uses: actions/checkout@v2.3.3
|
|
||||||
|
|
||||||
- name: "Install PHP with extensions"
|
|
||||||
uses: shivammathur/setup-php@2.7.0
|
|
||||||
with:
|
|
||||||
coverage: "none"
|
|
||||||
php-version: ${{ matrix.php-version }}
|
|
||||||
ini-values: memory_limit=-1
|
|
||||||
tools: composer:v2
|
|
||||||
|
|
||||||
- name: "Add PHPUnit matcher"
|
|
||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
|
||||||
|
|
||||||
- name: "Set composer cache directory"
|
|
||||||
id: composer-cache
|
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
||||||
|
|
||||||
- name: "Cache composer"
|
|
||||||
uses: actions/cache@v2.1.2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-${{ matrix.php-version }}-composer-${{ hashFiles('composer.json') }}
|
|
||||||
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-composer-
|
|
||||||
|
|
||||||
- run: composer install ${{ matrix.composer-options }}
|
|
||||||
|
|
||||||
- name: "Install PHPUnit"
|
|
||||||
run: vendor/bin/simple-phpunit install
|
|
||||||
|
|
||||||
- name: "PHPUnit version"
|
|
||||||
run: vendor/bin/simple-phpunit --version
|
|
||||||
|
|
||||||
- name: "Run tests"
|
|
||||||
run: vendor/bin/simple-phpunit
|
|
||||||
|
|
||||||
extension-tests:
|
|
||||||
needs:
|
|
||||||
- 'tests'
|
|
||||||
|
|
||||||
name: "${{ matrix.extension }} with PHP ${{ matrix.php-version }}"
|
|
||||||
|
|
||||||
runs-on: 'ubuntu-latest'
|
|
||||||
|
|
||||||
continue-on-error: true
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
php-version:
|
|
||||||
- '7.2.5'
|
|
||||||
- '7.3'
|
|
||||||
- '7.4'
|
|
||||||
- '8.0'
|
|
||||||
extension:
|
|
||||||
- 'extra/cache-extra'
|
|
||||||
- 'extra/cssinliner-extra'
|
|
||||||
- 'extra/html-extra'
|
|
||||||
- 'extra/inky-extra'
|
|
||||||
- 'extra/intl-extra'
|
|
||||||
- 'extra/markdown-extra'
|
|
||||||
- 'extra/string-extra'
|
|
||||||
- 'extra/twig-extra-bundle'
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Checkout code"
|
|
||||||
uses: actions/checkout@v2.3.3
|
|
||||||
|
|
||||||
- name: "Install PHP with extensions"
|
|
||||||
uses: shivammathur/setup-php@2.7.0
|
|
||||||
with:
|
|
||||||
coverage: "none"
|
|
||||||
php-version: ${{ matrix.php-version }}
|
|
||||||
ini-values: memory_limit=-1
|
|
||||||
tools: composer:v2
|
|
||||||
|
|
||||||
- name: "Add PHPUnit matcher"
|
|
||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
|
||||||
|
|
||||||
- name: "Set composer cache directory"
|
|
||||||
id: composer-cache
|
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
||||||
|
|
||||||
- name: "Cache composer"
|
|
||||||
uses: actions/cache@v2.1.2
|
|
||||||
with:
|
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
|
||||||
key: ${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.extension }}-${{ hashFiles('composer.json') }}
|
|
||||||
restore-keys: ${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.extension }}-
|
|
||||||
|
|
||||||
- run: composer install
|
|
||||||
|
|
||||||
- name: "Install PHPUnit"
|
|
||||||
run: vendor/bin/simple-phpunit install
|
|
||||||
|
|
||||||
- name: "PHPUnit version"
|
|
||||||
run: vendor/bin/simple-phpunit --version
|
|
||||||
|
|
||||||
- if: matrix.extension == 'extra/markdown-extra' && matrix.php-version == '8.0'
|
|
||||||
working-directory: ${{ matrix.extension}}
|
|
||||||
run: composer config platform.php 7.4.99
|
|
||||||
|
|
||||||
- name: "Composer install"
|
|
||||||
working-directory: ${{ matrix.extension}}
|
|
||||||
run: composer install
|
|
||||||
|
|
||||||
- name: "Run tests"
|
|
||||||
working-directory: ${{ matrix.extension}}
|
|
||||||
run: ../../vendor/bin/simple-phpunit
|
|
||||||
#
|
|
||||||
# Drupal does not support Twig 3 now!
|
|
||||||
#
|
|
||||||
# integration-tests:
|
|
||||||
# needs:
|
|
||||||
# - 'tests'
|
|
||||||
#
|
|
||||||
# name: "Integration tests with PHP ${{ matrix.php-version }}"
|
|
||||||
#
|
|
||||||
# runs-on: 'ubuntu-20.04'
|
|
||||||
#
|
|
||||||
# continue-on-error: true
|
|
||||||
#
|
|
||||||
# strategy:
|
|
||||||
# matrix:
|
|
||||||
# php-version:
|
|
||||||
# - '7.3'
|
|
||||||
#
|
|
||||||
# steps:
|
|
||||||
# - name: "Checkout code"
|
|
||||||
# uses: actions/checkout@v2.3.3
|
|
||||||
#
|
|
||||||
# - name: "Install PHP with extensions"
|
|
||||||
# uses: shivammathur/setup-php@2.7.0
|
|
||||||
# with:
|
|
||||||
# coverage: "none"
|
|
||||||
# extensions: "gd, pdo_sqlite"
|
|
||||||
# php-version: ${{ matrix.php-version }}
|
|
||||||
# ini-values: memory_limit=-1
|
|
||||||
# tools: composer:v2
|
|
||||||
#
|
|
||||||
# - run: bash ./tests/drupal_test.sh
|
|
||||||
# shell: "bash"
|
|
|
@ -1,60 +0,0 @@
|
||||||
name: "Documentation"
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '3.x'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: "Build"
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Checkout code"
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: "Set up Python 3.7"
|
|
||||||
uses: actions/setup-python@v1
|
|
||||||
with:
|
|
||||||
python-version: '3.7' # Semantic version range syntax or exact version of a Python version
|
|
||||||
|
|
||||||
- name: "Display Python version"
|
|
||||||
run: python -c "import sys; print(sys.version)"
|
|
||||||
|
|
||||||
- name: "Install Sphinx dependencies"
|
|
||||||
run: sudo apt-get install python-dev build-essential
|
|
||||||
|
|
||||||
- name: "Cache pip"
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.cache/pip
|
|
||||||
key: ${{ runner.os }}-pip-${{ hashFiles('_build/.requirements.txt') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-pip-
|
|
||||||
|
|
||||||
- name: "Install Sphinx + requirements via pip"
|
|
||||||
working-directory: "doc"
|
|
||||||
run: pip install -r _build/.requirements.txt
|
|
||||||
|
|
||||||
- name: "Build documentation"
|
|
||||||
working-directory: "doc"
|
|
||||||
run: make -C _build SPHINXOPTS="-nqW -j auto" html
|
|
||||||
|
|
||||||
doctor-rst:
|
|
||||||
name: "DOCtor-RST"
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "Checkout code"
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: "Run DOCtor-RST"
|
|
||||||
uses: docker://oskarstark/doctor-rst
|
|
||||||
with:
|
|
||||||
args: --short
|
|
||||||
env:
|
|
||||||
DOCS_DIR: 'doc/'
|
|
|
@ -1,4 +0,0 @@
|
||||||
/composer.lock
|
|
||||||
/phpunit.xml
|
|
||||||
/vendor
|
|
||||||
.phpunit.result.cache
|
|
|
@ -1,20 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
return (new PhpCsFixer\Config())
|
|
||||||
->setRules([
|
|
||||||
'@Symfony' => true,
|
|
||||||
'@Symfony:risky' => true,
|
|
||||||
'@PHPUnit75Migration:risky' => true,
|
|
||||||
'php_unit_dedicate_assert' => ['target' => '5.6'],
|
|
||||||
'array_syntax' => ['syntax' => 'short'],
|
|
||||||
'php_unit_fqcn_annotation' => true,
|
|
||||||
'no_unreachable_default_argument_value' => false,
|
|
||||||
'braces' => ['allow_single_line_closure' => true],
|
|
||||||
'heredoc_to_nowdoc' => false,
|
|
||||||
'ordered_imports' => true,
|
|
||||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
|
||||||
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'all'],
|
|
||||||
])
|
|
||||||
->setRiskyAllowed(true)
|
|
||||||
->setFinder((new PhpCsFixer\Finder())->in(__DIR__))
|
|
||||||
;
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,27 +0,0 @@
|
||||||
Copyright (c) 2009-2021 by the Twig Team.
|
|
||||||
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
* Neither the name of Twig nor the names of its contributors
|
|
||||||
may be used to endorse or promote products derived from this software
|
|
||||||
without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
@ -1,24 +0,0 @@
|
||||||
Twig, the flexible, fast, and secure template language for PHP
|
|
||||||
==============================================================
|
|
||||||
|
|
||||||
Twig is a template language for PHP, released under the new BSD license (code
|
|
||||||
and documentation).
|
|
||||||
|
|
||||||
Twig uses a syntax similar to the Django and Jinja template languages which
|
|
||||||
inspired the Twig runtime environment.
|
|
||||||
|
|
||||||
Sponsors
|
|
||||||
--------
|
|
||||||
|
|
||||||
.. raw:: html
|
|
||||||
|
|
||||||
<a href="https://blackfire.io/docs/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
|
|
||||||
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
More Information
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Read the `documentation`_ for more information.
|
|
||||||
|
|
||||||
.. _documentation: https://twig.symfony.com/documentation
|
|
|
@ -1,50 +0,0 @@
|
||||||
{
|
|
||||||
"name": "twig/twig",
|
|
||||||
"type": "library",
|
|
||||||
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
|
||||||
"keywords": ["templating"],
|
|
||||||
"homepage": "https://twig.symfony.com",
|
|
||||||
"license": "BSD-3-Clause",
|
|
||||||
"minimum-stability": "dev",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com",
|
|
||||||
"homepage": "http://fabien.potencier.org",
|
|
||||||
"role": "Lead Developer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Twig Team",
|
|
||||||
"role": "Contributors"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Armin Ronacher",
|
|
||||||
"email": "armin.ronacher@active-4.com",
|
|
||||||
"role": "Project Founder"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"require": {
|
|
||||||
"php": ">=7.2.5",
|
|
||||||
"symfony/polyfill-mbstring": "^1.3",
|
|
||||||
"symfony/polyfill-ctype": "^1.8"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0",
|
|
||||||
"psr/container": "^1.0"
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4" : {
|
|
||||||
"Twig\\" : "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload-dev": {
|
|
||||||
"psr-4" : {
|
|
||||||
"Twig\\Tests\\" : "tests/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.3-dev"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
rules:
|
|
||||||
american_english: ~
|
|
||||||
avoid_repetetive_words: ~
|
|
||||||
blank_line_after_directive: ~
|
|
||||||
blank_line_before_directive: ~
|
|
||||||
composer_dev_option_not_at_the_end: ~
|
|
||||||
correct_code_block_directive_based_on_the_content: ~
|
|
||||||
deprecated_directive_should_have_version: ~
|
|
||||||
ensure_order_of_code_blocks_in_configuration_block: ~
|
|
||||||
extension_xlf_instead_of_xliff: ~
|
|
||||||
indention: ~
|
|
||||||
lowercase_as_in_use_statements: ~
|
|
||||||
max_blank_lines:
|
|
||||||
max: 2
|
|
||||||
no_blank_line_after_filepath_in_php_code_block: ~
|
|
||||||
no_blank_line_after_filepath_in_twig_code_block: ~
|
|
||||||
no_blank_line_after_filepath_in_xml_code_block: ~
|
|
||||||
no_blank_line_after_filepath_in_yaml_code_block: ~
|
|
||||||
no_composer_req: ~
|
|
||||||
no_explicit_use_of_code_block_php: ~
|
|
||||||
no_inheritdoc: ~
|
|
||||||
no_namespace_after_use_statements: ~
|
|
||||||
no_php_open_tag_in_code_block_php_directive: ~
|
|
||||||
no_space_before_self_xml_closing_tag: ~
|
|
||||||
ordered_use_statements: ~
|
|
||||||
php_prefix_before_bin_console: ~
|
|
||||||
replace_code_block_types: ~
|
|
||||||
replacement: ~
|
|
||||||
short_array_syntax: ~
|
|
||||||
typo: ~
|
|
||||||
unused_links: ~
|
|
||||||
use_deprecated_directive_instead_of_versionadded: ~
|
|
||||||
use_https_xsd_urls: ~
|
|
||||||
valid_inline_highlighted_namespaces: ~
|
|
||||||
valid_use_statements: ~
|
|
||||||
versionadded_directive_should_have_version: ~
|
|
||||||
yaml_instead_of_yml_suffix: ~
|
|
||||||
yarn_dev_option_at_the_end: ~
|
|
||||||
|
|
||||||
versionadded_directive_major_version:
|
|
||||||
major_version: 3
|
|
||||||
|
|
||||||
versionadded_directive_min_version:
|
|
||||||
min_version: '3.0'
|
|
||||||
|
|
||||||
deprecated_directive_major_version:
|
|
||||||
major_version: 3
|
|
||||||
|
|
||||||
deprecated_directive_min_version:
|
|
||||||
min_version: '3.0'
|
|
||||||
|
|
||||||
whitelist:
|
|
||||||
lines:
|
|
||||||
- 'I like Twig.<br />'
|
|
|
@ -1,6 +0,0 @@
|
||||||
docutils==0.13.1
|
|
||||||
Pygments==2.2.0
|
|
||||||
sphinx==1.8.5
|
|
||||||
git+https://github.com/fabpot/sphinx-php.git@v2.0.0#egg_name=sphinx-php
|
|
||||||
jsx-lexer===0.0.8
|
|
||||||
sphinx_rtd_theme==0.5.0
|
|
|
@ -1,153 +0,0 @@
|
||||||
# Makefile for Sphinx documentation
|
|
||||||
#
|
|
||||||
|
|
||||||
# You can set these variables from the command line.
|
|
||||||
SPHINXOPTS =
|
|
||||||
SPHINXBUILD = sphinx-build
|
|
||||||
PAPER =
|
|
||||||
BUILDDIR = .
|
|
||||||
|
|
||||||
# Internal variables.
|
|
||||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
|
||||||
PAPEROPT_letter = -D latex_paper_size=letter
|
|
||||||
ALLSPHINXOPTS = -c $(BUILDDIR) -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) ../
|
|
||||||
# the i18n builder cannot share the environment and doctrees with the others
|
|
||||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
|
|
||||||
|
|
||||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
|
||||||
|
|
||||||
help:
|
|
||||||
@echo "Please use \`make <target>' where <target> is one of"
|
|
||||||
@echo " html to make standalone HTML files"
|
|
||||||
@echo " dirhtml to make HTML files named index.html in directories"
|
|
||||||
@echo " singlehtml to make a single large HTML file"
|
|
||||||
@echo " pickle to make pickle files"
|
|
||||||
@echo " json to make JSON files"
|
|
||||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
|
||||||
@echo " qthelp to make HTML files and a qthelp project"
|
|
||||||
@echo " devhelp to make HTML files and a Devhelp project"
|
|
||||||
@echo " epub to make an epub"
|
|
||||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
|
||||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
|
||||||
@echo " text to make text files"
|
|
||||||
@echo " man to make manual pages"
|
|
||||||
@echo " texinfo to make Texinfo files"
|
|
||||||
@echo " info to make Texinfo files and run them through makeinfo"
|
|
||||||
@echo " gettext to make PO message catalogs"
|
|
||||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
|
||||||
@echo " linkcheck to check all external links for integrity"
|
|
||||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm -rf $(BUILDDIR)/*
|
|
||||||
|
|
||||||
html:
|
|
||||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
|
||||||
|
|
||||||
dirhtml:
|
|
||||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
|
||||||
|
|
||||||
singlehtml:
|
|
||||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
|
||||||
|
|
||||||
pickle:
|
|
||||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can process the pickle files."
|
|
||||||
|
|
||||||
json:
|
|
||||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can process the JSON files."
|
|
||||||
|
|
||||||
htmlhelp:
|
|
||||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
|
||||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
|
||||||
|
|
||||||
qthelp:
|
|
||||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
|
||||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
|
||||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Symfony.qhcp"
|
|
||||||
@echo "To view the help file:"
|
|
||||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Symfony.qhc"
|
|
||||||
|
|
||||||
devhelp:
|
|
||||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
|
||||||
@echo
|
|
||||||
@echo "Build finished."
|
|
||||||
@echo "To view the help file:"
|
|
||||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/Symfony"
|
|
||||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Symfony"
|
|
||||||
@echo "# devhelp"
|
|
||||||
|
|
||||||
epub:
|
|
||||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
|
||||||
|
|
||||||
latex:
|
|
||||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
||||||
@echo
|
|
||||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
|
||||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
|
||||||
"(use \`make latexpdf' here to do that automatically)."
|
|
||||||
|
|
||||||
latexpdf:
|
|
||||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
|
||||||
@echo "Running LaTeX files through pdflatex..."
|
|
||||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
|
||||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
|
||||||
|
|
||||||
text:
|
|
||||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
|
||||||
|
|
||||||
man:
|
|
||||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
|
||||||
|
|
||||||
texinfo:
|
|
||||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
|
||||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
|
||||||
"(use \`make info' here to do that automatically)."
|
|
||||||
|
|
||||||
info:
|
|
||||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
|
||||||
@echo "Running Texinfo files through makeinfo..."
|
|
||||||
make -C $(BUILDDIR)/texinfo info
|
|
||||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
|
||||||
|
|
||||||
gettext:
|
|
||||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
|
||||||
@echo
|
|
||||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
|
||||||
|
|
||||||
changes:
|
|
||||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
|
||||||
@echo
|
|
||||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
|
||||||
|
|
||||||
linkcheck:
|
|
||||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
|
||||||
@echo
|
|
||||||
@echo "Link check complete; look for any errors in the above output " \
|
|
||||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
|
||||||
|
|
||||||
doctest:
|
|
||||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
|
||||||
@echo "Testing of doctests in the sources finished, look at the " \
|
|
||||||
"results in $(BUILDDIR)/doctest/output.txt."
|
|
|
@ -1,271 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Symfony documentation build configuration file, created by
|
|
||||||
# sphinx-quickstart on Sat Jul 28 21:58:57 2012.
|
|
||||||
#
|
|
||||||
# This file is execfile()d with the current directory set to its containing dir.
|
|
||||||
#
|
|
||||||
# Note that not all possible configuration values are present in this
|
|
||||||
# autogenerated file.
|
|
||||||
#
|
|
||||||
# All configuration values have a default; values that are commented out
|
|
||||||
# serve to show the default.
|
|
||||||
|
|
||||||
import sys, os
|
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
||||||
#sys.path.append(os.path.abspath('_exts'))
|
|
||||||
|
|
||||||
# adding PhpLexer
|
|
||||||
from sphinx.highlighting import lexers
|
|
||||||
from pygments.lexers.special import TextLexer
|
|
||||||
from pygments.lexers.text import RstLexer
|
|
||||||
from pygments.lexers.web import PhpLexer
|
|
||||||
|
|
||||||
# -- General configuration -----------------------------------------------------
|
|
||||||
|
|
||||||
# If your documentation needs a minimal Sphinx version, state it here.
|
|
||||||
needs_sphinx = '1.8.5'
|
|
||||||
|
|
||||||
# Add any Sphinx extension module names here, as strings. They can be extensions
|
|
||||||
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
|
||||||
extensions = [
|
|
||||||
'sphinx.ext.autodoc', 'sphinx.ext.doctest',
|
|
||||||
'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.ifconfig',
|
|
||||||
'sphinx.ext.viewcode', 'sphinx.ext.extlinks',
|
|
||||||
'sensio.sphinx.codeblock', 'sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode', 'sensio.sphinx.bestpractice'
|
|
||||||
]
|
|
||||||
|
|
||||||
#spelling_show_sugestions=True
|
|
||||||
#spelling_lang='en_US'
|
|
||||||
#spelling_word_list_filename='_build/spelling_word_list.txt'
|
|
||||||
|
|
||||||
# Add any paths that contain templates here, relative to this directory.
|
|
||||||
# templates_path = ['_theme/_templates']
|
|
||||||
|
|
||||||
# The suffix of source filenames.
|
|
||||||
source_suffix = '.rst'
|
|
||||||
|
|
||||||
# The encoding of source files.
|
|
||||||
#source_encoding = 'utf-8-sig'
|
|
||||||
|
|
||||||
# The master toctree document.
|
|
||||||
master_doc = 'index'
|
|
||||||
|
|
||||||
# General information about the project.
|
|
||||||
project = 'Twig'
|
|
||||||
copyright = ''
|
|
||||||
|
|
||||||
# The version info for the project you're documenting, acts as replacement for
|
|
||||||
# |version| and |release|, also used in various other places throughout the
|
|
||||||
# built documents.
|
|
||||||
#
|
|
||||||
# The short X.Y version.
|
|
||||||
# version = '2.2'
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
|
||||||
# release = '2.2.13'
|
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
|
||||||
# for a list of supported languages.
|
|
||||||
#language = None
|
|
||||||
|
|
||||||
# There are two options for replacing |today|: either, you set today to some
|
|
||||||
# non-false value, then it is used:
|
|
||||||
#today = ''
|
|
||||||
# Else, today_fmt is used as the format for a strftime call.
|
|
||||||
#today_fmt = '%B %d, %Y'
|
|
||||||
|
|
||||||
# List of patterns, relative to source directory, that match files and
|
|
||||||
# directories to ignore when looking for source files.
|
|
||||||
exclude_patterns = ['_build']
|
|
||||||
|
|
||||||
# The reST default role (used for this markup: `text`) to use for all documents.
|
|
||||||
#default_role = None
|
|
||||||
|
|
||||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
|
||||||
#add_function_parentheses = True
|
|
||||||
|
|
||||||
# If true, the current module name will be prepended to all description
|
|
||||||
# unit titles (such as .. function::).
|
|
||||||
#add_module_names = True
|
|
||||||
|
|
||||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
|
||||||
# output. They are ignored by default.
|
|
||||||
#show_authors = False
|
|
||||||
|
|
||||||
# The name of the Pygments (syntax highlighting) style to use.
|
|
||||||
#pygments_style = 'symfonycom.sphinx.SensioStyle'
|
|
||||||
|
|
||||||
# A list of ignored prefixes for module index sorting.
|
|
||||||
#modindex_common_prefix = []
|
|
||||||
|
|
||||||
# -- Settings for symfony doc extension ---------------------------------------------------
|
|
||||||
|
|
||||||
# enable highlighting for PHP code not between ``<?php ... ?>`` by default
|
|
||||||
lexers['php'] = PhpLexer(startinline=True)
|
|
||||||
lexers['rst'] = RstLexer()
|
|
||||||
|
|
||||||
config_block = {
|
|
||||||
'rst': 'reStructuredText',
|
|
||||||
}
|
|
||||||
|
|
||||||
# don't enable Sphinx Domains
|
|
||||||
primary_domain = None
|
|
||||||
|
|
||||||
# set url for API links
|
|
||||||
#api_url = 'https://github.com/symfony/symfony/blob/master/src/%s.php'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for HTML output ---------------------------------------------------
|
|
||||||
|
|
||||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
|
||||||
# a list of builtin themes.
|
|
||||||
html_theme = "sphinx_rtd_theme"
|
|
||||||
|
|
||||||
# Theme options are theme-specific and customize the look and feel of a theme
|
|
||||||
# further. For a list of options available for each theme, see the
|
|
||||||
# documentation.
|
|
||||||
html_theme_options = {
|
|
||||||
'logo_only': True,
|
|
||||||
'prev_next_buttons_location': None,
|
|
||||||
'style_nav_header_background': '#f0f0f0'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Add any paths that contain custom themes here, relative to this directory.
|
|
||||||
#html_theme_path = []
|
|
||||||
|
|
||||||
# The name for this set of Sphinx documents. If None, it defaults to
|
|
||||||
# "<project> v<release> documentation".
|
|
||||||
#html_title = None
|
|
||||||
|
|
||||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
|
||||||
#html_short_title = None
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top
|
|
||||||
# of the sidebar.
|
|
||||||
#html_logo = '_static/symfony-logo.svg'
|
|
||||||
|
|
||||||
# The name of an image file (within the static path) to use as favicon of the
|
|
||||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
|
||||||
# pixels large.
|
|
||||||
#html_favicon = None
|
|
||||||
|
|
||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
|
||||||
#html_static_path = ['_static']
|
|
||||||
#html_css_files = ['rtd_custom.css']
|
|
||||||
|
|
||||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
|
||||||
# using the given strftime format.
|
|
||||||
#html_last_updated_fmt = '%b %d, %Y'
|
|
||||||
|
|
||||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
|
||||||
# typographically correct entities.
|
|
||||||
#html_use_smartypants = True
|
|
||||||
|
|
||||||
# Custom sidebar templates, maps document names to template names.
|
|
||||||
#html_sidebars = {}
|
|
||||||
|
|
||||||
# Additional templates that should be rendered to pages, maps page names to
|
|
||||||
# template names.
|
|
||||||
#html_additional_pages = {}
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#html_domain_indices = True
|
|
||||||
|
|
||||||
# If false, no index is generated.
|
|
||||||
#html_use_index = True
|
|
||||||
|
|
||||||
# If true, the index is split into individual pages for each letter.
|
|
||||||
#html_split_index = False
|
|
||||||
|
|
||||||
# If true, links to the reST sources are added to the pages.
|
|
||||||
#html_show_sourcelink = True
|
|
||||||
|
|
||||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
|
||||||
#html_show_sphinx = True
|
|
||||||
|
|
||||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
|
||||||
#html_show_copyright = True
|
|
||||||
|
|
||||||
# If true, an OpenSearch description file will be output, and all pages will
|
|
||||||
# contain a <link> tag referring to it. The value of this option must be the
|
|
||||||
# base URL from which the finished HTML is served.
|
|
||||||
#html_use_opensearch = ''
|
|
||||||
|
|
||||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
|
||||||
#html_file_suffix = None
|
|
||||||
|
|
||||||
# Output file base name for HTML help builder.
|
|
||||||
htmlhelp_basename = 'Twig'
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for LaTeX output --------------------------------------------------
|
|
||||||
|
|
||||||
latex_elements = {
|
|
||||||
# The paper size ('letterpaper' or 'a4paper').
|
|
||||||
#'papersize': 'letterpaper',
|
|
||||||
|
|
||||||
# The font size ('10pt', '11pt' or '12pt').
|
|
||||||
#'pointsize': '10pt',
|
|
||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
|
||||||
#'preamble': '',
|
|
||||||
}
|
|
||||||
|
|
||||||
# Grouping the document tree into LaTeX files. List of tuples
|
|
||||||
# (source start file, target name, title, author, documentclass [howto/manual]).
|
|
||||||
#latex_documents = []
|
|
||||||
|
|
||||||
# The name of an image file (relative to this directory) to place at the top of
|
|
||||||
# the title page.
|
|
||||||
#latex_logo = None
|
|
||||||
|
|
||||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
|
||||||
# not chapters.
|
|
||||||
#latex_use_parts = False
|
|
||||||
|
|
||||||
# If true, show page references after internal links.
|
|
||||||
#latex_show_pagerefs = False
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
#latex_show_urls = False
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
#latex_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#latex_domain_indices = True
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for manual page output --------------------------------------------
|
|
||||||
|
|
||||||
# One entry per manual page. List of tuples
|
|
||||||
# (source start file, name, description, authors, manual section).
|
|
||||||
#man_pages = []
|
|
||||||
|
|
||||||
# If true, show URL addresses after external links.
|
|
||||||
#man_show_urls = False
|
|
||||||
|
|
||||||
|
|
||||||
# -- Options for Texinfo output ------------------------------------------------
|
|
||||||
|
|
||||||
# Grouping the document tree into Texinfo files. List of tuples
|
|
||||||
# (source start file, target name, title, author,
|
|
||||||
# dir menu entry, description, category)
|
|
||||||
#texinfo_documents = []
|
|
||||||
|
|
||||||
# Documents to append as an appendix to all manuals.
|
|
||||||
#texinfo_appendices = []
|
|
||||||
|
|
||||||
# If false, no module index is generated.
|
|
||||||
#texinfo_domain_indices = True
|
|
||||||
|
|
||||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
|
||||||
#texinfo_show_urls = 'footnote'
|
|
||||||
|
|
||||||
# Use PHP syntax highlighting in code examples by default
|
|
||||||
highlight_language='php'
|
|
|
@ -1,911 +0,0 @@
|
||||||
Extending Twig
|
|
||||||
==============
|
|
||||||
|
|
||||||
Twig can be extended in many ways; you can add extra tags, filters, tests,
|
|
||||||
operators, global variables, and functions. You can even extend the parser
|
|
||||||
itself with node visitors.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The first section of this chapter describes how to extend Twig. If you want
|
|
||||||
to reuse your changes in different projects or if you want to share them
|
|
||||||
with others, you should then create an extension as described in the
|
|
||||||
following section.
|
|
||||||
|
|
||||||
.. caution::
|
|
||||||
|
|
||||||
When extending Twig without creating an extension, Twig won't be able to
|
|
||||||
recompile your templates when the PHP code is updated. To see your changes
|
|
||||||
in real-time, either disable template caching or package your code into an
|
|
||||||
extension (see the next section of this chapter).
|
|
||||||
|
|
||||||
Before extending Twig, you must understand the differences between all the
|
|
||||||
different possible extension points and when to use them.
|
|
||||||
|
|
||||||
First, remember that Twig has two main language constructs:
|
|
||||||
|
|
||||||
* ``{{ }}``: used to print the result of an expression evaluation;
|
|
||||||
|
|
||||||
* ``{% %}``: used to execute statements.
|
|
||||||
|
|
||||||
To understand why Twig exposes so many extension points, let's see how to
|
|
||||||
implement a *Lorem ipsum* generator (it needs to know the number of words to
|
|
||||||
generate).
|
|
||||||
|
|
||||||
You can use a ``lipsum`` *tag*:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% lipsum 40 %}
|
|
||||||
|
|
||||||
That works, but using a tag for ``lipsum`` is not a good idea for at least
|
|
||||||
three main reasons:
|
|
||||||
|
|
||||||
* ``lipsum`` is not a language construct;
|
|
||||||
* The tag outputs something;
|
|
||||||
* The tag is not flexible as you cannot use it in an expression:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'some text' ~ {% lipsum 40 %} ~ 'some more text' }}
|
|
||||||
|
|
||||||
In fact, you rarely need to create tags; and that's good news because tags are
|
|
||||||
the most complex extension point.
|
|
||||||
|
|
||||||
Now, let's use a ``lipsum`` *filter*:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 40|lipsum }}
|
|
||||||
|
|
||||||
Again, it works. But a filter should transform the passed value to something
|
|
||||||
else. Here, we use the value to indicate the number of words to generate (so,
|
|
||||||
``40`` is an argument of the filter, not the value we want to transform).
|
|
||||||
|
|
||||||
Next, let's use a ``lipsum`` *function*:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ lipsum(40) }}
|
|
||||||
|
|
||||||
Here we go. For this specific example, the creation of a function is the
|
|
||||||
extension point to use. And you can use it anywhere an expression is accepted:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'some text' ~ lipsum(40) ~ 'some more text' }}
|
|
||||||
|
|
||||||
{% set lipsum = lipsum(40) %}
|
|
||||||
|
|
||||||
Lastly, you can also use a *global* object with a method able to generate lorem
|
|
||||||
ipsum text:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ text.lipsum(40) }}
|
|
||||||
|
|
||||||
As a rule of thumb, use functions for frequently used features and global
|
|
||||||
objects for everything else.
|
|
||||||
|
|
||||||
Keep in mind the following when you want to extend Twig:
|
|
||||||
|
|
||||||
========== ========================== ========== =========================
|
|
||||||
What? Implementation difficulty? How often? When?
|
|
||||||
========== ========================== ========== =========================
|
|
||||||
*macro* simple frequent Content generation
|
|
||||||
*global* simple frequent Helper object
|
|
||||||
*function* simple frequent Content generation
|
|
||||||
*filter* simple frequent Value transformation
|
|
||||||
*tag* complex rare DSL language construct
|
|
||||||
*test* simple rare Boolean decision
|
|
||||||
*operator* simple rare Values transformation
|
|
||||||
========== ========================== ========== =========================
|
|
||||||
|
|
||||||
Globals
|
|
||||||
-------
|
|
||||||
|
|
||||||
A global variable is like any other template variable, except that it's
|
|
||||||
available in all templates and macros::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->addGlobal('text', new Text());
|
|
||||||
|
|
||||||
You can then use the ``text`` variable anywhere in a template:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ text.lipsum(40) }}
|
|
||||||
|
|
||||||
Filters
|
|
||||||
-------
|
|
||||||
|
|
||||||
Creating a filter consists of associating a name with a PHP callable::
|
|
||||||
|
|
||||||
// an anonymous function
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', function ($string) {
|
|
||||||
return str_rot13($string);
|
|
||||||
});
|
|
||||||
|
|
||||||
// or a simple PHP function
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', 'str_rot13');
|
|
||||||
|
|
||||||
// or a class static method
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', ['SomeClass', 'rot13Filter']);
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', 'SomeClass::rot13Filter');
|
|
||||||
|
|
||||||
// or a class method
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', [$this, 'rot13Filter']);
|
|
||||||
// the one below needs a runtime implementation (see below for more information)
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', ['SomeClass', 'rot13Filter']);
|
|
||||||
|
|
||||||
The first argument passed to the ``\Twig\TwigFilter`` constructor is the name of the
|
|
||||||
filter you will use in templates and the second one is the PHP callable to
|
|
||||||
associate with it.
|
|
||||||
|
|
||||||
Then, add the filter to the Twig environment::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->addFilter($filter);
|
|
||||||
|
|
||||||
And here is how to use it in a template:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'Twig'|rot13 }}
|
|
||||||
|
|
||||||
{# will output Gjvt #}
|
|
||||||
|
|
||||||
When called by Twig, the PHP callable receives the left side of the filter
|
|
||||||
(before the pipe ``|``) as the first argument and the extra arguments passed
|
|
||||||
to the filter (within parentheses ``()``) as extra arguments.
|
|
||||||
|
|
||||||
For instance, the following code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'TWIG'|lower }}
|
|
||||||
{{ now|date('d/m/Y') }}
|
|
||||||
|
|
||||||
is compiled to something like the following::
|
|
||||||
|
|
||||||
<?php echo strtolower('TWIG') ?>
|
|
||||||
<?php echo twig_date_format_filter($now, 'd/m/Y') ?>
|
|
||||||
|
|
||||||
The ``\Twig\TwigFilter`` class takes an array of options as its last argument::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', 'str_rot13', $options);
|
|
||||||
|
|
||||||
Environment-aware Filters
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
If you want to access the current environment instance in your filter, set the
|
|
||||||
``needs_environment`` option to ``true``; Twig will pass the current
|
|
||||||
environment as the first argument to the filter call::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', function (\Twig\Environment $env, $string) {
|
|
||||||
// get the current charset for instance
|
|
||||||
$charset = $env->getCharset();
|
|
||||||
|
|
||||||
return str_rot13($string);
|
|
||||||
}, ['needs_environment' => true]);
|
|
||||||
|
|
||||||
Context-aware Filters
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
If you want to access the current context in your filter, set the
|
|
||||||
``needs_context`` option to ``true``; Twig will pass the current context as
|
|
||||||
the first argument to the filter call (or the second one if
|
|
||||||
``needs_environment`` is also set to ``true``)::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', function ($context, $string) {
|
|
||||||
// ...
|
|
||||||
}, ['needs_context' => true]);
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('rot13', function (\Twig\Environment $env, $context, $string) {
|
|
||||||
// ...
|
|
||||||
}, ['needs_context' => true, 'needs_environment' => true]);
|
|
||||||
|
|
||||||
Automatic Escaping
|
|
||||||
~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
If automatic escaping is enabled, the output of the filter may be escaped
|
|
||||||
before printing. If your filter acts as an escaper (or explicitly outputs HTML
|
|
||||||
or JavaScript code), you will want the raw output to be printed. In such a
|
|
||||||
case, set the ``is_safe`` option::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('nl2br', 'nl2br', ['is_safe' => ['html']]);
|
|
||||||
|
|
||||||
Some filters may need to work on input that is already escaped or safe, for
|
|
||||||
example when adding (safe) HTML tags to originally unsafe output. In such a
|
|
||||||
case, set the ``pre_escape`` option to escape the input data before it is run
|
|
||||||
through your filter::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('somefilter', 'somefilter', ['pre_escape' => 'html', 'is_safe' => ['html']]);
|
|
||||||
|
|
||||||
Variadic Filters
|
|
||||||
~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
When a filter should accept an arbitrary number of arguments, set the
|
|
||||||
``is_variadic`` option to ``true``; Twig will pass the extra arguments as the
|
|
||||||
last argument to the filter call as an array::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('thumbnail', function ($file, array $options = []) {
|
|
||||||
// ...
|
|
||||||
}, ['is_variadic' => true]);
|
|
||||||
|
|
||||||
Be warned that :ref:`named arguments <named-arguments>` passed to a variadic
|
|
||||||
filter cannot be checked for validity as they will automatically end up in the
|
|
||||||
option array.
|
|
||||||
|
|
||||||
Dynamic Filters
|
|
||||||
~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
A filter name containing the special ``*`` character is a dynamic filter and
|
|
||||||
the ``*`` part will match any string::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('*_path', function ($name, $arguments) {
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
|
|
||||||
The following filters are matched by the above defined dynamic filter:
|
|
||||||
|
|
||||||
* ``product_path``
|
|
||||||
* ``category_path``
|
|
||||||
|
|
||||||
A dynamic filter can define more than one dynamic parts::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('*_path_*', function ($name, $suffix, $arguments) {
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
|
|
||||||
The filter receives all dynamic part values before the normal filter arguments,
|
|
||||||
but after the environment and the context. For instance, a call to
|
|
||||||
``'foo'|a_path_b()`` will result in the following arguments to be passed to the
|
|
||||||
filter: ``('a', 'b', 'foo')``.
|
|
||||||
|
|
||||||
Deprecated Filters
|
|
||||||
~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
You can mark a filter as being deprecated by setting the ``deprecated`` option
|
|
||||||
to ``true``. You can also give an alternative filter that replaces the
|
|
||||||
deprecated one when that makes sense::
|
|
||||||
|
|
||||||
$filter = new \Twig\TwigFilter('obsolete', function () {
|
|
||||||
// ...
|
|
||||||
}, ['deprecated' => true, 'alternative' => 'new_one']);
|
|
||||||
|
|
||||||
When a filter is deprecated, Twig emits a deprecation notice when compiling a
|
|
||||||
template using it. See :ref:`deprecation-notices` for more information.
|
|
||||||
|
|
||||||
Functions
|
|
||||||
---------
|
|
||||||
|
|
||||||
Functions are defined in the exact same way as filters, but you need to create
|
|
||||||
an instance of ``\Twig\TwigFunction``::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$function = new \Twig\TwigFunction('function_name', function () {
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
$twig->addFunction($function);
|
|
||||||
|
|
||||||
Functions support the same features as filters, except for the ``pre_escape``
|
|
||||||
and ``preserves_safety`` options.
|
|
||||||
|
|
||||||
Tests
|
|
||||||
-----
|
|
||||||
|
|
||||||
Tests are defined in the exact same way as filters and functions, but you need
|
|
||||||
to create an instance of ``\Twig\TwigTest``::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$test = new \Twig\TwigTest('test_name', function () {
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
$twig->addTest($test);
|
|
||||||
|
|
||||||
Tests allow you to create custom application specific logic for evaluating
|
|
||||||
boolean conditions. As a simple example, let's create a Twig test that checks if
|
|
||||||
objects are 'red'::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$test = new \Twig\TwigTest('red', function ($value) {
|
|
||||||
if (isset($value->color) && $value->color == 'red') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isset($value->paint) && $value->paint == 'red') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$twig->addTest($test);
|
|
||||||
|
|
||||||
Test functions must always return ``true``/``false``.
|
|
||||||
|
|
||||||
When creating tests you can use the ``node_class`` option to provide custom test
|
|
||||||
compilation. This is useful if your test can be compiled into PHP primitives.
|
|
||||||
This is used by many of the tests built into Twig::
|
|
||||||
|
|
||||||
namespace App;
|
|
||||||
|
|
||||||
use Twig\Environment;
|
|
||||||
use Twig\Node\Expression\TestExpression;
|
|
||||||
use Twig\TwigTest;
|
|
||||||
|
|
||||||
$twig = new Environment($loader);
|
|
||||||
$test = new TwigTest(
|
|
||||||
'odd',
|
|
||||||
null,
|
|
||||||
['node_class' => OddTestExpression::class]);
|
|
||||||
$twig->addTest($test);
|
|
||||||
|
|
||||||
class OddTestExpression extends TestExpression
|
|
||||||
{
|
|
||||||
public function compile(\Twig\Compiler $compiler)
|
|
||||||
{
|
|
||||||
$compiler
|
|
||||||
->raw('(')
|
|
||||||
->subcompile($this->getNode('node'))
|
|
||||||
->raw(' % 2 != 0')
|
|
||||||
->raw(')')
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
The above example shows how you can create tests that use a node class. The node
|
|
||||||
class has access to one sub-node called ``node``. This sub-node contains the
|
|
||||||
value that is being tested. When the ``odd`` filter is used in code such as:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% if my_value is odd %}
|
|
||||||
|
|
||||||
The ``node`` sub-node will contain an expression of ``my_value``. Node-based
|
|
||||||
tests also have access to the ``arguments`` node. This node will contain the
|
|
||||||
various other arguments that have been provided to your test.
|
|
||||||
|
|
||||||
If you want to pass a variable number of positional or named arguments to the
|
|
||||||
test, set the ``is_variadic`` option to ``true``. Tests support dynamic
|
|
||||||
names (see dynamic filters for the syntax).
|
|
||||||
|
|
||||||
Tags
|
|
||||||
----
|
|
||||||
|
|
||||||
One of the most exciting features of a template engine like Twig is the
|
|
||||||
possibility to define new **language constructs**. This is also the most complex
|
|
||||||
feature as you need to understand how Twig's internals work.
|
|
||||||
|
|
||||||
Most of the time though, a tag is not needed:
|
|
||||||
|
|
||||||
* If your tag generates some output, use a **function** instead.
|
|
||||||
|
|
||||||
* If your tag modifies some content and returns it, use a **filter** instead.
|
|
||||||
|
|
||||||
For instance, if you want to create a tag that converts a Markdown formatted
|
|
||||||
text to HTML, create a ``markdown`` filter instead:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ '**markdown** text'|markdown }}
|
|
||||||
|
|
||||||
If you want use this filter on large amounts of text, wrap it with the
|
|
||||||
:doc:`apply <tags/apply>` tag:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% apply markdown %}
|
|
||||||
Title
|
|
||||||
=====
|
|
||||||
|
|
||||||
Much better than creating a tag as you can **compose** filters.
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
* If your tag does not output anything, but only exists because of a side
|
|
||||||
effect, create a **function** that returns nothing and call it via the
|
|
||||||
:doc:`filter <tags/do>` tag.
|
|
||||||
|
|
||||||
For instance, if you want to create a tag that logs text, create a ``log``
|
|
||||||
function instead and call it via the :doc:`do <tags/do>` tag:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% do log('Log some things') %}
|
|
||||||
|
|
||||||
If you still want to create a tag for a new language construct, great!
|
|
||||||
|
|
||||||
Let's create a ``set`` tag that allows the definition of simple variables from
|
|
||||||
within a template. The tag can be used like follows:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set name = "value" %}
|
|
||||||
|
|
||||||
{{ name }}
|
|
||||||
|
|
||||||
{# should output value #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``set`` tag is part of the Core extension and as such is always
|
|
||||||
available. The built-in version is slightly more powerful and supports
|
|
||||||
multiple assignments by default.
|
|
||||||
|
|
||||||
Three steps are needed to define a new tag:
|
|
||||||
|
|
||||||
* Defining a Token Parser class (responsible for parsing the template code);
|
|
||||||
|
|
||||||
* Defining a Node class (responsible for converting the parsed code to PHP);
|
|
||||||
|
|
||||||
* Registering the tag.
|
|
||||||
|
|
||||||
Registering a new tag
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Add a tag by calling the ``addTokenParser`` method on the ``\Twig\Environment``
|
|
||||||
instance::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->addTokenParser(new Project_Set_TokenParser());
|
|
||||||
|
|
||||||
Defining a Token Parser
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Now, let's see the actual code of this class::
|
|
||||||
|
|
||||||
class Project_Set_TokenParser extends \Twig\TokenParser\AbstractTokenParser
|
|
||||||
{
|
|
||||||
public function parse(\Twig\Token $token)
|
|
||||||
{
|
|
||||||
$parser = $this->parser;
|
|
||||||
$stream = $parser->getStream();
|
|
||||||
|
|
||||||
$name = $stream->expect(\Twig\Token::NAME_TYPE)->getValue();
|
|
||||||
$stream->expect(\Twig\Token::OPERATOR_TYPE, '=');
|
|
||||||
$value = $parser->getExpressionParser()->parseExpression();
|
|
||||||
$stream->expect(\Twig\Token::BLOCK_END_TYPE);
|
|
||||||
|
|
||||||
return new Project_Set_Node($name, $value, $token->getLine(), $this->getTag());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTag()
|
|
||||||
{
|
|
||||||
return 'set';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
The ``getTag()`` method must return the tag we want to parse, here ``set``.
|
|
||||||
|
|
||||||
The ``parse()`` method is invoked whenever the parser encounters a ``set``
|
|
||||||
tag. It should return a ``\Twig\Node\Node`` instance that represents the node (the
|
|
||||||
``Project_Set_Node`` calls creating is explained in the next section).
|
|
||||||
|
|
||||||
The parsing process is simplified thanks to a bunch of methods you can call
|
|
||||||
from the token stream (``$this->parser->getStream()``):
|
|
||||||
|
|
||||||
* ``getCurrent()``: Gets the current token in the stream.
|
|
||||||
|
|
||||||
* ``next()``: Moves to the next token in the stream, *but returns the old one*.
|
|
||||||
|
|
||||||
* ``test($type)``, ``test($value)`` or ``test($type, $value)``: Determines whether
|
|
||||||
the current token is of a particular type or value (or both). The value may be an
|
|
||||||
array of several possible values.
|
|
||||||
|
|
||||||
* ``expect($type[, $value[, $message]])``: If the current token isn't of the given
|
|
||||||
type/value a syntax error is thrown. Otherwise, if the type and value are correct,
|
|
||||||
the token is returned and the stream moves to the next token.
|
|
||||||
|
|
||||||
* ``look()``: Looks at the next token without consuming it.
|
|
||||||
|
|
||||||
Parsing expressions is done by calling the ``parseExpression()`` like we did for
|
|
||||||
the ``set`` tag.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
Reading the existing ``TokenParser`` classes is the best way to learn all
|
|
||||||
the nitty-gritty details of the parsing process.
|
|
||||||
|
|
||||||
Defining a Node
|
|
||||||
~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``Project_Set_Node`` class itself is quite short::
|
|
||||||
|
|
||||||
class Project_Set_Node extends \Twig\Node\Node
|
|
||||||
{
|
|
||||||
public function __construct($name, \Twig\Node\Expression\AbstractExpression $value, $line, $tag = null)
|
|
||||||
{
|
|
||||||
parent::__construct(['value' => $value], ['name' => $name], $line, $tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function compile(\Twig\Compiler $compiler)
|
|
||||||
{
|
|
||||||
$compiler
|
|
||||||
->addDebugInfo($this)
|
|
||||||
->write('$context[\''.$this->getAttribute('name').'\'] = ')
|
|
||||||
->subcompile($this->getNode('value'))
|
|
||||||
->raw(";\n")
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
The compiler implements a fluid interface and provides methods that helps the
|
|
||||||
developer generate beautiful and readable PHP code:
|
|
||||||
|
|
||||||
* ``subcompile()``: Compiles a node.
|
|
||||||
|
|
||||||
* ``raw()``: Writes the given string as is.
|
|
||||||
|
|
||||||
* ``write()``: Writes the given string by adding indentation at the beginning
|
|
||||||
of each line.
|
|
||||||
|
|
||||||
* ``string()``: Writes a quoted string.
|
|
||||||
|
|
||||||
* ``repr()``: Writes a PHP representation of a given value (see
|
|
||||||
``\Twig\Node\ForNode`` for a usage example).
|
|
||||||
|
|
||||||
* ``addDebugInfo()``: Adds the line of the original template file related to
|
|
||||||
the current node as a comment.
|
|
||||||
|
|
||||||
* ``indent()``: Indents the generated code (see ``\Twig\Node\BlockNode`` for a
|
|
||||||
usage example).
|
|
||||||
|
|
||||||
* ``outdent()``: Outdents the generated code (see ``\Twig\Node\BlockNode`` for a
|
|
||||||
usage example).
|
|
||||||
|
|
||||||
.. _creating_extensions:
|
|
||||||
|
|
||||||
Creating an Extension
|
|
||||||
---------------------
|
|
||||||
|
|
||||||
The main motivation for writing an extension is to move often used code into a
|
|
||||||
reusable class like adding support for internationalization. An extension can
|
|
||||||
define tags, filters, tests, operators, functions, and node visitors.
|
|
||||||
|
|
||||||
Most of the time, it is useful to create a single extension for your project,
|
|
||||||
to host all the specific tags and filters you want to add to Twig.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
When packaging your code into an extension, Twig is smart enough to
|
|
||||||
recompile your templates whenever you make a change to it (when
|
|
||||||
``auto_reload`` is enabled).
|
|
||||||
|
|
||||||
An extension is a class that implements the following interface::
|
|
||||||
|
|
||||||
interface \Twig\Extension\ExtensionInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns the token parser instances to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return \Twig\TokenParser\TokenParserInterface[]
|
|
||||||
*/
|
|
||||||
public function getTokenParsers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the node visitor instances to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return \Twig\NodeVisitor\NodeVisitorInterface[]
|
|
||||||
*/
|
|
||||||
public function getNodeVisitors();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of filters to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return \Twig\TwigFilter[]
|
|
||||||
*/
|
|
||||||
public function getFilters();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of tests to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return \Twig\TwigTest[]
|
|
||||||
*/
|
|
||||||
public function getTests();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of functions to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return \Twig\TwigFunction[]
|
|
||||||
*/
|
|
||||||
public function getFunctions();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of operators to add to the existing list.
|
|
||||||
*
|
|
||||||
* @return array<array> First array of unary operators, second array of binary operators
|
|
||||||
*/
|
|
||||||
public function getOperators();
|
|
||||||
}
|
|
||||||
|
|
||||||
To keep your extension class clean and lean, inherit from the built-in
|
|
||||||
``\Twig\Extension\AbstractExtension`` class instead of implementing the interface as it provides
|
|
||||||
empty implementations for all methods::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
This extension does nothing for now. We will customize it in the next sections.
|
|
||||||
|
|
||||||
You can save your extension anywhere on the filesystem, as all extensions must
|
|
||||||
be registered explicitly to be available in your templates.
|
|
||||||
|
|
||||||
You can register an extension by using the ``addExtension()`` method on your
|
|
||||||
main ``Environment`` object::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->addExtension(new Project_Twig_Extension());
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
The Twig core extensions are great examples of how extensions work.
|
|
||||||
|
|
||||||
Globals
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
Global variables can be registered in an extension via the ``getGlobals()``
|
|
||||||
method::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension implements \Twig\Extension\GlobalsInterface
|
|
||||||
{
|
|
||||||
public function getGlobals(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'text' => new Text(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
Functions
|
|
||||||
~~~~~~~~~
|
|
||||||
|
|
||||||
Functions can be registered in an extension via the ``getFunctions()``
|
|
||||||
method::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getFunctions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new \Twig\TwigFunction('lipsum', 'generate_lipsum'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
Filters
|
|
||||||
~~~~~~~
|
|
||||||
|
|
||||||
To add a filter to an extension, you need to override the ``getFilters()``
|
|
||||||
method. This method must return an array of filters to add to the Twig
|
|
||||||
environment::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getFilters()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new \Twig\TwigFilter('rot13', 'str_rot13'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
Tags
|
|
||||||
~~~~
|
|
||||||
|
|
||||||
Adding a tag in an extension can be done by overriding the
|
|
||||||
``getTokenParsers()`` method. This method must return an array of tags to add
|
|
||||||
to the Twig environment::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getTokenParsers()
|
|
||||||
{
|
|
||||||
return [new Project_Set_TokenParser()];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
In the above code, we have added a single new tag, defined by the
|
|
||||||
``Project_Set_TokenParser`` class. The ``Project_Set_TokenParser`` class is
|
|
||||||
responsible for parsing the tag and compiling it to PHP.
|
|
||||||
|
|
||||||
Operators
|
|
||||||
~~~~~~~~~
|
|
||||||
|
|
||||||
The ``getOperators()`` methods lets you add new operators. Here is how to add
|
|
||||||
the ``!``, ``||``, and ``&&`` operators::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getOperators()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'!' => ['precedence' => 50, 'class' => \Twig\Node\Expression\Unary\NotUnary::class],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'||' => ['precedence' => 10, 'class' => \Twig\Node\Expression\Binary\OrBinary::class, 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT],
|
|
||||||
'&&' => ['precedence' => 15, 'class' => \Twig\Node\Expression\Binary\AndBinary::class, 'associativity' => \Twig\ExpressionParser::OPERATOR_LEFT],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
Tests
|
|
||||||
~~~~~
|
|
||||||
|
|
||||||
The ``getTests()`` method lets you add new test functions::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getTests()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new \Twig\TwigTest('even', 'twig_test_even'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
|
|
||||||
Definition vs Runtime
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Twig filters, functions, and tests runtime implementations can be defined as
|
|
||||||
any valid PHP callable:
|
|
||||||
|
|
||||||
* **functions/static methods**: Simple to implement and fast (used by all Twig
|
|
||||||
core extensions); but it is hard for the runtime to depend on external
|
|
||||||
objects;
|
|
||||||
|
|
||||||
* **closures**: Simple to implement;
|
|
||||||
|
|
||||||
* **object methods**: More flexible and required if your runtime code depends
|
|
||||||
on external objects.
|
|
||||||
|
|
||||||
The simplest way to use methods is to define them on the extension itself::
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
private $rot13Provider;
|
|
||||||
|
|
||||||
public function __construct($rot13Provider)
|
|
||||||
{
|
|
||||||
$this->rot13Provider = $rot13Provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFunctions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new \Twig\TwigFunction('rot13', [$this, 'rot13']),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rot13($value)
|
|
||||||
{
|
|
||||||
return $this->rot13Provider->rot13($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
This is very convenient but not recommended as it makes template compilation
|
|
||||||
depend on runtime dependencies even if they are not needed (think for instance
|
|
||||||
as a dependency that connects to a database engine).
|
|
||||||
|
|
||||||
You can decouple the extension definitions from their runtime implementations by
|
|
||||||
registering a ``\Twig\RuntimeLoader\RuntimeLoaderInterface`` instance on the
|
|
||||||
environment that knows how to instantiate such runtime classes (runtime classes
|
|
||||||
must be autoload-able)::
|
|
||||||
|
|
||||||
class RuntimeLoader implements \Twig\RuntimeLoader\RuntimeLoaderInterface
|
|
||||||
{
|
|
||||||
public function load($class)
|
|
||||||
{
|
|
||||||
// implement the logic to create an instance of $class
|
|
||||||
// and inject its dependencies
|
|
||||||
// most of the time, it means using your dependency injection container
|
|
||||||
if ('Project_Twig_RuntimeExtension' === $class) {
|
|
||||||
return new $class(new Rot13Provider());
|
|
||||||
} else {
|
|
||||||
// ...
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$twig->addRuntimeLoader(new RuntimeLoader());
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Twig comes with a PSR-11 compatible runtime loader
|
|
||||||
(``\Twig\RuntimeLoader\ContainerRuntimeLoader``).
|
|
||||||
|
|
||||||
It is now possible to move the runtime logic to a new
|
|
||||||
``Project_Twig_RuntimeExtension`` class and use it directly in the extension::
|
|
||||||
|
|
||||||
class Project_Twig_RuntimeExtension
|
|
||||||
{
|
|
||||||
private $rot13Provider;
|
|
||||||
|
|
||||||
public function __construct($rot13Provider)
|
|
||||||
{
|
|
||||||
$this->rot13Provider = $rot13Provider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function rot13($value)
|
|
||||||
{
|
|
||||||
return $this->rot13Provider->rot13($value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Project_Twig_Extension extends \Twig\Extension\AbstractExtension
|
|
||||||
{
|
|
||||||
public function getFunctions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new \Twig\TwigFunction('rot13', ['Project_Twig_RuntimeExtension', 'rot13']),
|
|
||||||
// or
|
|
||||||
new \Twig\TwigFunction('rot13', 'Project_Twig_RuntimeExtension::rot13'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Testing an Extension
|
|
||||||
--------------------
|
|
||||||
|
|
||||||
Functional Tests
|
|
||||||
~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
You can create functional tests for extensions by creating the following file
|
|
||||||
structure in your test directory::
|
|
||||||
|
|
||||||
Fixtures/
|
|
||||||
filters/
|
|
||||||
foo.test
|
|
||||||
bar.test
|
|
||||||
functions/
|
|
||||||
foo.test
|
|
||||||
bar.test
|
|
||||||
tags/
|
|
||||||
foo.test
|
|
||||||
bar.test
|
|
||||||
IntegrationTest.php
|
|
||||||
|
|
||||||
The ``IntegrationTest.php`` file should look like this::
|
|
||||||
|
|
||||||
use Twig\Test\IntegrationTestCase;
|
|
||||||
|
|
||||||
class Project_Tests_IntegrationTest extends IntegrationTestCase
|
|
||||||
{
|
|
||||||
public function getExtensions()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
new Project_Twig_Extension1(),
|
|
||||||
new Project_Twig_Extension2(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFixturesDir()
|
|
||||||
{
|
|
||||||
return __DIR__.'/Fixtures/';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Fixtures examples can be found within the Twig repository
|
|
||||||
`tests/Twig/Fixtures`_ directory.
|
|
||||||
|
|
||||||
Node Tests
|
|
||||||
~~~~~~~~~~
|
|
||||||
|
|
||||||
Testing the node visitors can be complex, so extend your test cases from
|
|
||||||
``\Twig\Test\NodeTestCase``. Examples can be found in the Twig repository
|
|
||||||
`tests/Twig/Node`_ directory.
|
|
||||||
|
|
||||||
.. _`tests/Twig/Fixtures`: https://github.com/twigphp/Twig/tree/3.x/tests/Fixtures
|
|
||||||
.. _`tests/Twig/Node`: https://github.com/twigphp/Twig/tree/3.x/tests/Node
|
|
|
@ -1,583 +0,0 @@
|
||||||
Twig for Developers
|
|
||||||
===================
|
|
||||||
|
|
||||||
This chapter describes the API to Twig and not the template language. It will
|
|
||||||
be most useful as reference to those implementing the template interface to
|
|
||||||
the application and not those who are creating Twig templates.
|
|
||||||
|
|
||||||
Basics
|
|
||||||
------
|
|
||||||
|
|
||||||
Twig uses a central object called the **environment** (of class
|
|
||||||
``\Twig\Environment``). Instances of this class are used to store the
|
|
||||||
configuration and extensions, and are used to load templates.
|
|
||||||
|
|
||||||
Most applications create one ``\Twig\Environment`` object on application
|
|
||||||
initialization and use that to load templates. In some cases, it might be useful
|
|
||||||
to have multiple environments side by side, with different configurations.
|
|
||||||
|
|
||||||
The typical way to configure Twig to load templates for an application looks
|
|
||||||
roughly like this::
|
|
||||||
|
|
||||||
require_once '/path/to/vendor/autoload.php';
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\FilesystemLoader('/path/to/templates');
|
|
||||||
$twig = new \Twig\Environment($loader, [
|
|
||||||
'cache' => '/path/to/compilation_cache',
|
|
||||||
]);
|
|
||||||
|
|
||||||
This creates a template environment with a default configuration and a loader
|
|
||||||
that looks up templates in the ``/path/to/templates/`` directory. Different
|
|
||||||
loaders are available and you can also write your own if you want to load
|
|
||||||
templates from a database or other resources.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Notice that the second argument of the environment is an array of options.
|
|
||||||
The ``cache`` option is a compilation cache directory, where Twig caches
|
|
||||||
the compiled templates to avoid the parsing phase for sub-sequent
|
|
||||||
requests. It is very different from the cache you might want to add for
|
|
||||||
the evaluated templates. For such a need, you can use any available PHP
|
|
||||||
cache library.
|
|
||||||
|
|
||||||
Rendering Templates
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
To load a template from a Twig environment, call the ``load()`` method which
|
|
||||||
returns a ``\Twig\TemplateWrapper`` instance::
|
|
||||||
|
|
||||||
$template = $twig->load('index.html');
|
|
||||||
|
|
||||||
To render the template with some variables, call the ``render()`` method::
|
|
||||||
|
|
||||||
echo $template->render(['the' => 'variables', 'go' => 'here']);
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``display()`` method is a shortcut to output the rendered template.
|
|
||||||
|
|
||||||
You can also load and render the template in one fell swoop::
|
|
||||||
|
|
||||||
echo $twig->render('index.html', ['the' => 'variables', 'go' => 'here']);
|
|
||||||
|
|
||||||
If a template defines blocks, they can be rendered individually via the
|
|
||||||
``renderBlock()`` call::
|
|
||||||
|
|
||||||
echo $template->renderBlock('block_name', ['the' => 'variables', 'go' => 'here']);
|
|
||||||
|
|
||||||
.. _environment_options:
|
|
||||||
|
|
||||||
Environment Options
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
When creating a new ``\Twig\Environment`` instance, you can pass an array of
|
|
||||||
options as the constructor second argument::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader, ['debug' => true]);
|
|
||||||
|
|
||||||
The following options are available:
|
|
||||||
|
|
||||||
* ``debug`` *boolean*
|
|
||||||
|
|
||||||
When set to ``true``, the generated templates have a
|
|
||||||
``__toString()`` method that you can use to display the generated nodes
|
|
||||||
(default to ``false``).
|
|
||||||
|
|
||||||
* ``charset`` *string* (defaults to ``utf-8``)
|
|
||||||
|
|
||||||
The charset used by the templates.
|
|
||||||
|
|
||||||
* ``cache`` *string* or ``false``
|
|
||||||
|
|
||||||
An absolute path where to store the compiled templates, or
|
|
||||||
``false`` to disable caching (which is the default).
|
|
||||||
|
|
||||||
* ``auto_reload`` *boolean*
|
|
||||||
|
|
||||||
When developing with Twig, it's useful to recompile the
|
|
||||||
template whenever the source code changes. If you don't provide a value for
|
|
||||||
the ``auto_reload`` option, it will be determined automatically based on the
|
|
||||||
``debug`` value.
|
|
||||||
|
|
||||||
* ``strict_variables`` *boolean*
|
|
||||||
|
|
||||||
If set to ``false``, Twig will silently ignore invalid
|
|
||||||
variables (variables and or attributes/methods that do not exist) and
|
|
||||||
replace them with a ``null`` value. When set to ``true``, Twig throws an
|
|
||||||
exception instead (default to ``false``).
|
|
||||||
|
|
||||||
* ``autoescape`` *string*
|
|
||||||
|
|
||||||
Sets the default auto-escaping strategy (``name``, ``html``, ``js``, ``css``,
|
|
||||||
``url``, ``html_attr``, or a PHP callback that takes the template "filename"
|
|
||||||
and returns the escaping strategy to use -- the callback cannot be a function
|
|
||||||
name to avoid collision with built-in escaping strategies); set it to
|
|
||||||
``false`` to disable auto-escaping. The ``name`` escaping strategy determines
|
|
||||||
the escaping strategy to use for a template based on the template filename
|
|
||||||
extension (this strategy does not incur any overhead at runtime as
|
|
||||||
auto-escaping is done at compilation time.)
|
|
||||||
|
|
||||||
* ``optimizations`` *integer*
|
|
||||||
|
|
||||||
A flag that indicates which optimizations to apply
|
|
||||||
(default to ``-1`` -- all optimizations are enabled; set it to ``0`` to
|
|
||||||
disable).
|
|
||||||
|
|
||||||
Loaders
|
|
||||||
-------
|
|
||||||
|
|
||||||
Loaders are responsible for loading templates from a resource such as the file
|
|
||||||
system.
|
|
||||||
|
|
||||||
Compilation Cache
|
|
||||||
~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
All template loaders can cache the compiled templates on the filesystem for
|
|
||||||
future reuse. It speeds up Twig a lot as templates are only compiled once.
|
|
||||||
|
|
||||||
Built-in Loaders
|
|
||||||
~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
Here is a list of the built-in loaders:
|
|
||||||
|
|
||||||
``\Twig\Loader\FilesystemLoader``
|
|
||||||
.................................
|
|
||||||
|
|
||||||
``\Twig\Loader\FilesystemLoader`` loads templates from the file system. This loader
|
|
||||||
can find templates in folders on the file system and is the preferred way to
|
|
||||||
load them::
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\FilesystemLoader($templateDir);
|
|
||||||
|
|
||||||
It can also look for templates in an array of directories::
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\FilesystemLoader([$templateDir1, $templateDir2]);
|
|
||||||
|
|
||||||
With such a configuration, Twig will first look for templates in
|
|
||||||
``$templateDir1`` and if they do not exist, it will fallback to look for them
|
|
||||||
in the ``$templateDir2``.
|
|
||||||
|
|
||||||
You can add or prepend paths via the ``addPath()`` and ``prependPath()``
|
|
||||||
methods::
|
|
||||||
|
|
||||||
$loader->addPath($templateDir3);
|
|
||||||
$loader->prependPath($templateDir4);
|
|
||||||
|
|
||||||
The filesystem loader also supports namespaced templates. This allows to group
|
|
||||||
your templates under different namespaces which have their own template paths.
|
|
||||||
|
|
||||||
When using the ``setPaths()``, ``addPath()``, and ``prependPath()`` methods,
|
|
||||||
specify the namespace as the second argument (when not specified, these
|
|
||||||
methods act on the "main" namespace)::
|
|
||||||
|
|
||||||
$loader->addPath($templateDir, 'admin');
|
|
||||||
|
|
||||||
Namespaced templates can be accessed via the special
|
|
||||||
``@namespace_name/template_path`` notation::
|
|
||||||
|
|
||||||
$twig->render('@admin/index.html', []);
|
|
||||||
|
|
||||||
``\Twig\Loader\FilesystemLoader`` support absolute and relative paths. Using relative
|
|
||||||
paths is preferred as it makes the cache keys independent of the project root
|
|
||||||
directory (for instance, it allows warming the cache from a build server where
|
|
||||||
the directory might be different from the one used on production servers)::
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\FilesystemLoader('templates', getcwd().'/..');
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
When not passing the root path as a second argument, Twig uses ``getcwd()``
|
|
||||||
for relative paths.
|
|
||||||
|
|
||||||
``\Twig\Loader\ArrayLoader``
|
|
||||||
............................
|
|
||||||
|
|
||||||
``\Twig\Loader\ArrayLoader`` loads a template from a PHP array. It is passed an
|
|
||||||
array of strings bound to template names::
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\ArrayLoader([
|
|
||||||
'index.html' => 'Hello {{ name }}!',
|
|
||||||
]);
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
|
|
||||||
echo $twig->render('index.html', ['name' => 'Fabien']);
|
|
||||||
|
|
||||||
This loader is very useful for unit testing. It can also be used for small
|
|
||||||
projects where storing all templates in a single PHP file might make sense.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
When using the ``Array`` loader with a cache mechanism, you should know that
|
|
||||||
a new cache key is generated each time a template content "changes" (the
|
|
||||||
cache key being the source code of the template). If you don't want to see
|
|
||||||
your cache grows out of control, you need to take care of clearing the old
|
|
||||||
cache file by yourself.
|
|
||||||
|
|
||||||
``\Twig\Loader\ChainLoader``
|
|
||||||
............................
|
|
||||||
|
|
||||||
``\Twig\Loader\ChainLoader`` delegates the loading of templates to other loaders::
|
|
||||||
|
|
||||||
$loader1 = new \Twig\Loader\ArrayLoader([
|
|
||||||
'base.html' => '{% block content %}{% endblock %}',
|
|
||||||
]);
|
|
||||||
$loader2 = new \Twig\Loader\ArrayLoader([
|
|
||||||
'index.html' => '{% extends "base.html" %}{% block content %}Hello {{ name }}{% endblock %}',
|
|
||||||
'base.html' => 'Will never be loaded',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$loader = new \Twig\Loader\ChainLoader([$loader1, $loader2]);
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
|
|
||||||
When looking for a template, Twig tries each loader in turn and returns as soon
|
|
||||||
as the template is found. When rendering the ``index.html`` template from the
|
|
||||||
above example, Twig will load it with ``$loader2`` but the ``base.html``
|
|
||||||
template will be loaded from ``$loader1``.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
You can also add loaders via the ``addLoader()`` method.
|
|
||||||
|
|
||||||
Create your own Loader
|
|
||||||
~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
All loaders implement the ``\Twig\Loader\LoaderInterface``::
|
|
||||||
|
|
||||||
interface \Twig\Loader\LoaderInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Returns the source context for a given template logical name.
|
|
||||||
*
|
|
||||||
* @param string $name The template logical name
|
|
||||||
*
|
|
||||||
* @return \Twig\Source
|
|
||||||
*
|
|
||||||
* @throws \Twig\Error\LoaderError When $name is not found
|
|
||||||
*/
|
|
||||||
public function getSourceContext($name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the cache key to use for the cache for a given template name.
|
|
||||||
*
|
|
||||||
* @param string $name The name of the template to load
|
|
||||||
*
|
|
||||||
* @return string The cache key
|
|
||||||
*
|
|
||||||
* @throws \Twig\Error\LoaderError When $name is not found
|
|
||||||
*/
|
|
||||||
public function getCacheKey($name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the template is still fresh.
|
|
||||||
*
|
|
||||||
* @param string $name The template name
|
|
||||||
* @param timestamp $time The last modification time of the cached template
|
|
||||||
*
|
|
||||||
* @return bool true if the template is fresh, false otherwise
|
|
||||||
*
|
|
||||||
* @throws \Twig\Error\LoaderError When $name is not found
|
|
||||||
*/
|
|
||||||
public function isFresh($name, $time);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we have the source code of a template, given its name.
|
|
||||||
*
|
|
||||||
* @param string $name The name of the template to check if we can load
|
|
||||||
*
|
|
||||||
* @return bool If the template source code is handled by this loader or not
|
|
||||||
*/
|
|
||||||
public function exists($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
The ``isFresh()`` method must return ``true`` if the current cached template
|
|
||||||
is still fresh, given the last modification time, or ``false`` otherwise.
|
|
||||||
|
|
||||||
The ``getSourceContext()`` method must return an instance of ``\Twig\Source``.
|
|
||||||
|
|
||||||
Using Extensions
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Twig extensions are packages that add new features to Twig. Register an
|
|
||||||
extension via the ``addExtension()`` method::
|
|
||||||
|
|
||||||
$twig->addExtension(new \Twig\Extension\SandboxExtension());
|
|
||||||
|
|
||||||
Twig comes bundled with the following extensions:
|
|
||||||
|
|
||||||
* *Twig\Extension\CoreExtension*: Defines all the core features of Twig.
|
|
||||||
|
|
||||||
* *Twig\Extension\DebugExtension*: Defines the ``dump`` function to help debug
|
|
||||||
template variables.
|
|
||||||
|
|
||||||
* *Twig\Extension\EscaperExtension*: Adds automatic output-escaping and the
|
|
||||||
possibility to escape/unescape blocks of code.
|
|
||||||
|
|
||||||
* *Twig\Extension\SandboxExtension*: Adds a sandbox mode to the default Twig
|
|
||||||
environment, making it safe to evaluate untrusted code.
|
|
||||||
|
|
||||||
* *Twig\Extension\ProfilerExtension*: Enables the built-in Twig profiler.
|
|
||||||
|
|
||||||
* *Twig\Extension\OptimizerExtension*: Optimizes the node tree before
|
|
||||||
compilation.
|
|
||||||
|
|
||||||
* *Twig\Extension\StringLoaderExtension*: Defines the ``template_from_string``
|
|
||||||
function to allow loading templates from string in a template.
|
|
||||||
|
|
||||||
The Core, Escaper, and Optimizer extensions are registered by default.
|
|
||||||
|
|
||||||
Built-in Extensions
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
This section describes the features added by the built-in extensions.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
Read the chapter about :doc:`extending Twig <advanced>` to learn how to
|
|
||||||
create your own extensions.
|
|
||||||
|
|
||||||
Core Extension
|
|
||||||
~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``core`` extension defines all the core features of Twig:
|
|
||||||
|
|
||||||
* :doc:`Tags <tags/index>`;
|
|
||||||
* :doc:`Filters <filters/index>`;
|
|
||||||
* :doc:`Functions <functions/index>`;
|
|
||||||
* :doc:`Tests <tests/index>`.
|
|
||||||
|
|
||||||
Escaper Extension
|
|
||||||
~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``escaper`` extension adds automatic output escaping to Twig. It defines a
|
|
||||||
tag, ``autoescape``, and a filter, ``raw``.
|
|
||||||
|
|
||||||
When creating the escaper extension, you can switch on or off the global
|
|
||||||
output escaping strategy::
|
|
||||||
|
|
||||||
$escaper = new \Twig\Extension\EscaperExtension('html');
|
|
||||||
$twig->addExtension($escaper);
|
|
||||||
|
|
||||||
If set to ``html``, all variables in templates are escaped (using the ``html``
|
|
||||||
escaping strategy), except those using the ``raw`` filter:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ article.to_html|raw }}
|
|
||||||
|
|
||||||
You can also change the escaping mode locally by using the ``autoescape`` tag:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% autoescape 'html' %}
|
|
||||||
{{ var }}
|
|
||||||
{{ var|raw }} {# var won't be escaped #}
|
|
||||||
{{ var|escape }} {# var won't be double-escaped #}
|
|
||||||
{% endautoescape %}
|
|
||||||
|
|
||||||
.. warning::
|
|
||||||
|
|
||||||
The ``autoescape`` tag has no effect on included files.
|
|
||||||
|
|
||||||
The escaping rules are implemented as follows:
|
|
||||||
|
|
||||||
* Literals (integers, booleans, arrays, ...) used in the template directly as
|
|
||||||
variables or filter arguments are never automatically escaped:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{ "Twig<br/>" }} {# won't be escaped #}
|
|
||||||
|
|
||||||
{% set text = "Twig<br/>" %}
|
|
||||||
{{ text }} {# will be escaped #}
|
|
||||||
|
|
||||||
* Expressions which the result is a literal or a variable marked safe
|
|
||||||
are never automatically escaped:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{ foo ? "Twig<br/>" : "<br/>Twig" }} {# won't be escaped #}
|
|
||||||
|
|
||||||
{% set text = "Twig<br/>" %}
|
|
||||||
{{ true ? text : "<br/>Twig" }} {# will be escaped #}
|
|
||||||
{{ false ? text : "<br/>Twig" }} {# won't be escaped #}
|
|
||||||
|
|
||||||
{% set text = "Twig<br/>" %}
|
|
||||||
{{ foo ? text|raw : "<br/>Twig" }} {# won't be escaped #}
|
|
||||||
|
|
||||||
* Objects with a ``__toString`` method are converted to strings and
|
|
||||||
escaped. You can mark some classes and/or interfaces as being safe for some
|
|
||||||
strategies via ``EscaperExtension::addSafeClass()``:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
// mark object of class Foo as safe for the HTML strategy
|
|
||||||
$escaper->addSafeClass('Foo', ['html']);
|
|
||||||
|
|
||||||
// mark object of interface Foo as safe for the HTML strategy
|
|
||||||
$escaper->addSafeClass('FooInterface', ['html']);
|
|
||||||
|
|
||||||
// mark object of class Foo as safe for the HTML and JS strategies
|
|
||||||
$escaper->addSafeClass('Foo', ['html', 'js']);
|
|
||||||
|
|
||||||
// mark object of class Foo as safe for all strategies
|
|
||||||
$escaper->addSafeClass('Foo', ['all']);
|
|
||||||
|
|
||||||
* Escaping is applied before printing, after any other filter is applied:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ var|upper }} {# is equivalent to {{ var|upper|escape }} #}
|
|
||||||
|
|
||||||
* The `raw` filter should only be used at the end of the filter chain:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ var|raw|upper }} {# will be escaped #}
|
|
||||||
|
|
||||||
{{ var|upper|raw }} {# won't be escaped #}
|
|
||||||
|
|
||||||
* Automatic escaping is not applied if the last filter in the chain is marked
|
|
||||||
safe for the current context (e.g. ``html`` or ``js``). ``escape`` and
|
|
||||||
``escape('html')`` are marked safe for HTML, ``escape('js')`` is marked
|
|
||||||
safe for JavaScript, ``raw`` is marked safe for everything.
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% autoescape 'js' %}
|
|
||||||
{{ var|escape('html') }} {# will be escaped for HTML and JavaScript #}
|
|
||||||
{{ var }} {# will be escaped for JavaScript #}
|
|
||||||
{{ var|escape('js') }} {# won't be double-escaped #}
|
|
||||||
{% endautoescape %}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Note that autoescaping has some limitations as escaping is applied on
|
|
||||||
expressions after evaluation. For instance, when working with
|
|
||||||
concatenation, ``{{ foo|raw ~ bar }}`` won't give the expected result as
|
|
||||||
escaping is applied on the result of the concatenation, not on the
|
|
||||||
individual variables (so, the ``raw`` filter won't have any effect here).
|
|
||||||
|
|
||||||
Sandbox Extension
|
|
||||||
~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``sandbox`` extension can be used to evaluate untrusted code. Access to
|
|
||||||
unsafe attributes and methods is prohibited. The sandbox security is managed
|
|
||||||
by a policy instance. By default, Twig comes with one policy class:
|
|
||||||
``\Twig\Sandbox\SecurityPolicy``. This class allows you to white-list some
|
|
||||||
tags, filters, properties, and methods::
|
|
||||||
|
|
||||||
$tags = ['if'];
|
|
||||||
$filters = ['upper'];
|
|
||||||
$methods = [
|
|
||||||
'Article' => ['getTitle', 'getBody'],
|
|
||||||
];
|
|
||||||
$properties = [
|
|
||||||
'Article' => ['title', 'body'],
|
|
||||||
];
|
|
||||||
$functions = ['range'];
|
|
||||||
$policy = new \Twig\Sandbox\SecurityPolicy($tags, $filters, $methods, $properties, $functions);
|
|
||||||
|
|
||||||
With the previous configuration, the security policy will only allow usage of
|
|
||||||
the ``if`` tag, and the ``upper`` filter. Moreover, the templates will only be
|
|
||||||
able to call the ``getTitle()`` and ``getBody()`` methods on ``Article``
|
|
||||||
objects, and the ``title`` and ``body`` public properties. Everything else
|
|
||||||
won't be allowed and will generate a ``\Twig\Sandbox\SecurityError`` exception.
|
|
||||||
|
|
||||||
The policy object is the first argument of the sandbox constructor::
|
|
||||||
|
|
||||||
$sandbox = new \Twig\Extension\SandboxExtension($policy);
|
|
||||||
$twig->addExtension($sandbox);
|
|
||||||
|
|
||||||
By default, the sandbox mode is disabled and should be enabled when including
|
|
||||||
untrusted template code by using the ``sandbox`` tag:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% sandbox %}
|
|
||||||
{% include 'user.html' %}
|
|
||||||
{% endsandbox %}
|
|
||||||
|
|
||||||
You can sandbox all templates by passing ``true`` as the second argument of
|
|
||||||
the extension constructor::
|
|
||||||
|
|
||||||
$sandbox = new \Twig\Extension\SandboxExtension($policy, true);
|
|
||||||
|
|
||||||
Profiler Extension
|
|
||||||
~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``profiler`` extension enables a profiler for Twig templates; it should
|
|
||||||
only be used on your development machines as it adds some overhead::
|
|
||||||
|
|
||||||
$profile = new \Twig\Profiler\Profile();
|
|
||||||
$twig->addExtension(new \Twig\Extension\ProfilerExtension($profile));
|
|
||||||
|
|
||||||
$dumper = new \Twig\Profiler\Dumper\TextDumper();
|
|
||||||
echo $dumper->dump($profile);
|
|
||||||
|
|
||||||
A profile contains information about time and memory consumption for template,
|
|
||||||
block, and macro executions.
|
|
||||||
|
|
||||||
You can also dump the data in a `Blackfire.io <https://blackfire.io/>`_
|
|
||||||
compatible format::
|
|
||||||
|
|
||||||
$dumper = new \Twig\Profiler\Dumper\BlackfireDumper();
|
|
||||||
file_put_contents('/path/to/profile.prof', $dumper->dump($profile));
|
|
||||||
|
|
||||||
Upload the profile to visualize it (create a `free account
|
|
||||||
<https://blackfire.io/signup?utm_source=twig&utm_medium=doc&utm_campaign=profiler>`_
|
|
||||||
first):
|
|
||||||
|
|
||||||
.. code-block:: sh
|
|
||||||
|
|
||||||
blackfire --slot=7 upload /path/to/profile.prof
|
|
||||||
|
|
||||||
Optimizer Extension
|
|
||||||
~~~~~~~~~~~~~~~~~~~
|
|
||||||
|
|
||||||
The ``optimizer`` extension optimizes the node tree before compilation::
|
|
||||||
|
|
||||||
$twig->addExtension(new \Twig\Extension\OptimizerExtension());
|
|
||||||
|
|
||||||
By default, all optimizations are turned on. You can select the ones you want
|
|
||||||
to enable by passing them to the constructor::
|
|
||||||
|
|
||||||
$optimizer = new \Twig\Extension\OptimizerExtension(\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_FOR);
|
|
||||||
|
|
||||||
$twig->addExtension($optimizer);
|
|
||||||
|
|
||||||
Twig supports the following optimizations:
|
|
||||||
|
|
||||||
* ``\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_ALL``, enables all optimizations
|
|
||||||
(this is the default value).
|
|
||||||
|
|
||||||
* ``\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_NONE``, disables all optimizations.
|
|
||||||
This reduces the compilation time, but it can increase the execution time
|
|
||||||
and the consumed memory.
|
|
||||||
|
|
||||||
* ``\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_FOR``, optimizes the ``for`` tag by
|
|
||||||
removing the ``loop`` variable creation whenever possible.
|
|
||||||
|
|
||||||
* ``\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_RAW_FILTER``, removes the ``raw``
|
|
||||||
filter whenever possible.
|
|
||||||
|
|
||||||
* ``\Twig\NodeVisitor\OptimizerNodeVisitor::OPTIMIZE_VAR_ACCESS``, simplifies the creation
|
|
||||||
and access of variables in the compiled templates whenever possible.
|
|
||||||
|
|
||||||
Exceptions
|
|
||||||
----------
|
|
||||||
|
|
||||||
Twig can throw exceptions:
|
|
||||||
|
|
||||||
* ``\Twig\Error\Error``: The base exception for all errors.
|
|
||||||
|
|
||||||
* ``\Twig\Error\SyntaxError``: Thrown to tell the user that there is a problem with
|
|
||||||
the template syntax.
|
|
||||||
|
|
||||||
* ``\Twig\Error\RuntimeError``: Thrown when an error occurs at runtime (when a filter
|
|
||||||
does not exist for instance).
|
|
||||||
|
|
||||||
* ``\Twig\Error\LoaderError``: Thrown when an error occurs during template loading.
|
|
||||||
|
|
||||||
* ``\Twig\Sandbox\SecurityError``: Thrown when an unallowed tag, filter, or
|
|
||||||
method is called in a sandboxed template.
|
|
|
@ -1,101 +0,0 @@
|
||||||
Coding Standards
|
|
||||||
================
|
|
||||||
|
|
||||||
When writing Twig templates, we recommend you to follow these official coding
|
|
||||||
standards:
|
|
||||||
|
|
||||||
* Put one (and only one) space after the start of a delimiter (``{{``, ``{%``,
|
|
||||||
and ``{#``) and before the end of a delimiter (``}}``, ``%}``, and ``#}``):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ foo }}
|
|
||||||
{# comment #}
|
|
||||||
{% if foo %}{% endif %}
|
|
||||||
|
|
||||||
When using the whitespace control character, do not put any spaces between
|
|
||||||
it and the delimiter:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{- foo -}}
|
|
||||||
{#- comment -#}
|
|
||||||
{%- if foo -%}{%- endif -%}
|
|
||||||
|
|
||||||
* Put one (and only one) space before and after the following operators:
|
|
||||||
comparison operators (``==``, ``!=``, ``<``, ``>``, ``>=``, ``<=``), math
|
|
||||||
operators (``+``, ``-``, ``/``, ``*``, ``%``, ``//``, ``**``), logic
|
|
||||||
operators (``not``, ``and``, ``or``), ``~``, ``is``, ``in``, and the ternary
|
|
||||||
operator (``?:``):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 1 + 2 }}
|
|
||||||
{{ foo ~ bar }}
|
|
||||||
{{ true ? true : false }}
|
|
||||||
|
|
||||||
* Put one (and only one) space after the ``:`` sign in hashes and ``,`` in
|
|
||||||
arrays and hashes:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3] }}
|
|
||||||
{{ {'foo': 'bar'} }}
|
|
||||||
|
|
||||||
* Do not put any spaces after an opening parenthesis and before a closing
|
|
||||||
parenthesis in expressions:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 1 + (2 * 3) }}
|
|
||||||
|
|
||||||
* Do not put any spaces before and after string delimiters:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'foo' }}
|
|
||||||
{{ "foo" }}
|
|
||||||
|
|
||||||
* Do not put any spaces before and after the following operators: ``|``,
|
|
||||||
``.``, ``..``, ``[]``:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ foo|upper|lower }}
|
|
||||||
{{ user.name }}
|
|
||||||
{{ user[name] }}
|
|
||||||
{% for i in 1..12 %}{% endfor %}
|
|
||||||
|
|
||||||
* Do not put any spaces before and after the parenthesis used for filter and
|
|
||||||
function calls:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ foo|default('foo') }}
|
|
||||||
{{ range(1..10) }}
|
|
||||||
|
|
||||||
* Do not put any spaces before and after the opening and the closing of arrays
|
|
||||||
and hashes:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3] }}
|
|
||||||
{{ {'foo': 'bar'} }}
|
|
||||||
|
|
||||||
* Use lower cased and underscored variable names:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set foo = 'foo' %}
|
|
||||||
{% set foo_bar = 'foo' %}
|
|
||||||
|
|
||||||
* Indent your code inside tags (use the same indentation as the one used for
|
|
||||||
the target language of the rendered template):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% block foo %}
|
|
||||||
{% if true %}
|
|
||||||
true
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
|
@ -1,6 +0,0 @@
|
||||||
Deprecated Features
|
|
||||||
===================
|
|
||||||
|
|
||||||
This document lists deprecated features in Twig 3.x. Deprecated features are
|
|
||||||
kept for backward compatibility and removed in the next major release (a
|
|
||||||
feature that was deprecated in Twig 3.x is removed in Twig 4.0).
|
|
|
@ -1,18 +0,0 @@
|
||||||
``abs``
|
|
||||||
=======
|
|
||||||
|
|
||||||
The ``abs`` filter returns the absolute value.
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# number = -5 #}
|
|
||||||
|
|
||||||
{{ number|abs }}
|
|
||||||
|
|
||||||
{# outputs 5 #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `abs`_ function.
|
|
||||||
|
|
||||||
.. _`abs`: https://www.php.net/abs
|
|
|
@ -1,44 +0,0 @@
|
||||||
``batch``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``batch`` filter "batches" items by returning a list of lists with the
|
|
||||||
given number of items. A second parameter can be provided and used to fill in
|
|
||||||
missing items:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% set items = ['a', 'b', 'c', 'd'] %}
|
|
||||||
|
|
||||||
<table>
|
|
||||||
{% for row in items|batch(3, 'No item') %}
|
|
||||||
<tr>
|
|
||||||
{% for column in row %}
|
|
||||||
<td>{{ column }}</td>
|
|
||||||
{% endfor %}
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
The above example will be rendered as:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>a</td>
|
|
||||||
<td>b</td>
|
|
||||||
<td>c</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>d</td>
|
|
||||||
<td>No item</td>
|
|
||||||
<td>No item</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``size``: The size of the batch; fractional numbers will be rounded up
|
|
||||||
* ``fill``: Used to fill in missing items
|
|
||||||
* ``preserve_keys``: Whether to preserve keys or not
|
|
|
@ -1,11 +0,0 @@
|
||||||
``capitalize``
|
|
||||||
==============
|
|
||||||
|
|
||||||
The ``capitalize`` filter capitalizes a value. The first character will be
|
|
||||||
uppercase, all others lowercase:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'my first car'|capitalize }}
|
|
||||||
|
|
||||||
{# outputs 'My first car' #}
|
|
|
@ -1,24 +0,0 @@
|
||||||
``column``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``column`` filter returns the values from a single column in the input
|
|
||||||
array.
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set items = [{ 'fruit' : 'apple'}, {'fruit' : 'orange' }] %}
|
|
||||||
|
|
||||||
{% set fruits = items|column('fruit') %}
|
|
||||||
|
|
||||||
{# fruits now contains ['apple', 'orange'] #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `array_column`_ function.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``name``: The column name to extract
|
|
||||||
|
|
||||||
.. _`array_column`: https://www.php.net/array_column
|
|
|
@ -1,22 +0,0 @@
|
||||||
``convert_encoding``
|
|
||||||
====================
|
|
||||||
|
|
||||||
The ``convert_encoding`` filter converts a string from one encoding to
|
|
||||||
another. The first argument is the expected output charset and the second one
|
|
||||||
is the input charset:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ data|convert_encoding('UTF-8', 'iso-2022-jp') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
This filter relies on the `iconv`_ extension.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``to``: The output charset
|
|
||||||
* ``from``: The input charset
|
|
||||||
|
|
||||||
.. _`iconv`: https://www.php.net/iconv
|
|
|
@ -1,44 +0,0 @@
|
||||||
``country_name``
|
|
||||||
================
|
|
||||||
|
|
||||||
The ``country_name`` filter returns the country name given its ISO-3166
|
|
||||||
two-letter code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# France #}
|
|
||||||
{{ 'FR'|country_name }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# États-Unis #}
|
|
||||||
{{ 'US'|country_name('fr') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``country_name`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,47 +0,0 @@
|
||||||
``currency_name``
|
|
||||||
=================
|
|
||||||
|
|
||||||
The ``currency_name`` filter returns the currency name given its three-letter
|
|
||||||
code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# Euro #}
|
|
||||||
{{ 'EUR'|currency_name }}
|
|
||||||
|
|
||||||
{# Japanese Yen #}
|
|
||||||
{{ 'JPY'|currency_name }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# yen japonais #}
|
|
||||||
{{ 'JPY'|currency_name('fr_FR') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``currency_name`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,47 +0,0 @@
|
||||||
``currency_symbol``
|
|
||||||
===================
|
|
||||||
|
|
||||||
The ``currency_symbol`` filter returns the currency symbol given its three-letter
|
|
||||||
code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# € #}
|
|
||||||
{{ 'EUR'|currency_symbol }}
|
|
||||||
|
|
||||||
{# ¥ #}
|
|
||||||
{{ 'JPY'|currency_symbol }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# ¥ #}
|
|
||||||
{{ 'JPY'|currency_symbol('fr') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``currency_symbol`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,55 +0,0 @@
|
||||||
``data_uri``
|
|
||||||
============
|
|
||||||
|
|
||||||
The ``data_uri`` filter generates a URL using the data scheme as defined in
|
|
||||||
`RFC 2397`_:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{ image_data|data_uri }}
|
|
||||||
|
|
||||||
{{ source('path_to_image')|data_uri }}
|
|
||||||
|
|
||||||
{# force the mime type, disable the guessing of the mime type #}
|
|
||||||
{{ image_data|data_uri(mime="image/svg") }}
|
|
||||||
|
|
||||||
{# also works with plain text #}
|
|
||||||
{{ '<b>foobar</b>'|data_uri(mime="text/html") }}
|
|
||||||
|
|
||||||
{# add some extra parameters #}
|
|
||||||
{{ '<b>foobar</b>'|data_uri(mime="text/html", parameters={charset: "ascii"}) }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``data_uri`` filter is part of the ``HtmlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/html-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Html\HtmlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new HtmlExtension());
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The filter does not perform any length validation on purpose (limit depends
|
|
||||||
on the usage context), validation should be done before calling this filter.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``mime``: The mime type
|
|
||||||
* ``parameters``: An array of parameters
|
|
||||||
|
|
||||||
.. _RFC 2397: https://tools.ietf.org/html/rfc2397
|
|
|
@ -1,78 +0,0 @@
|
||||||
``date``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``date`` filter formats a date to a given format:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at|date("m/d/Y") }}
|
|
||||||
|
|
||||||
The format specifier is the same as supported by `date`_,
|
|
||||||
except when the filtered data is of type `DateInterval`_, when the format must conform to
|
|
||||||
`DateInterval::format`_ instead.
|
|
||||||
|
|
||||||
The ``date`` filter accepts strings (it must be in a format supported by the
|
|
||||||
`strtotime`_ function), `DateTime`_ instances, or `DateInterval`_ instances. For
|
|
||||||
instance, to display the current date, filter the word "now":
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ "now"|date("m/d/Y") }}
|
|
||||||
|
|
||||||
To escape words and characters in the date format use ``\\`` in front of each
|
|
||||||
character:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at|date("F jS \\a\\t g:ia") }}
|
|
||||||
|
|
||||||
If the value passed to the ``date`` filter is ``null``, it will return the
|
|
||||||
current date by default. If an empty string is desired instead of the current
|
|
||||||
date, use a ternary operator:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at is empty ? "" : post.published_at|date("m/d/Y") }}
|
|
||||||
|
|
||||||
If no format is provided, Twig will use the default one: ``F j, Y H:i``. This
|
|
||||||
default can be changed by calling the ``setDateFormat()`` method on the
|
|
||||||
``core`` extension instance. The first argument is the default format for
|
|
||||||
dates and the second one is the default format for date intervals::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setDateFormat('d/m/Y', '%d days');
|
|
||||||
|
|
||||||
Timezone
|
|
||||||
--------
|
|
||||||
|
|
||||||
By default, the date is displayed by applying the default timezone (the one
|
|
||||||
specified in php.ini or declared in Twig -- see below), but you can override
|
|
||||||
it by explicitly specifying a timezone:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at|date("m/d/Y", "Europe/Paris") }}
|
|
||||||
|
|
||||||
If the date is already a DateTime object, and if you want to keep its current
|
|
||||||
timezone, pass ``false`` as the timezone value:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at|date("m/d/Y", false) }}
|
|
||||||
|
|
||||||
The default timezone can also be set globally by calling ``setTimezone()``::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris');
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``format``: The date format
|
|
||||||
* ``timezone``: The date timezone
|
|
||||||
|
|
||||||
.. _`strtotime`: https://www.php.net/strtotime
|
|
||||||
.. _`DateTime`: https://www.php.net/DateTime
|
|
||||||
.. _`DateInterval`: https://www.php.net/DateInterval
|
|
||||||
.. _`date`: https://www.php.net/date
|
|
||||||
.. _`DateInterval::format`: https://www.php.net/DateInterval.format
|
|
|
@ -1,20 +0,0 @@
|
||||||
``date_modify``
|
|
||||||
===============
|
|
||||||
|
|
||||||
The ``date_modify`` filter modifies a date with a given modifier string:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ post.published_at|date_modify("+1 day")|date("m/d/Y") }}
|
|
||||||
|
|
||||||
The ``date_modify`` filter accepts strings (it must be in a format supported
|
|
||||||
by the `strtotime`_ function) or `DateTime`_ instances. You can combine
|
|
||||||
it with the :doc:`date<date>` filter for formatting.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``modifier``: The modifier
|
|
||||||
|
|
||||||
.. _`strtotime`: https://www.php.net/strtotime
|
|
||||||
.. _`DateTime`: https://www.php.net/DateTime
|
|
|
@ -1,42 +0,0 @@
|
||||||
``default``
|
|
||||||
===========
|
|
||||||
|
|
||||||
The ``default`` filter returns the passed default value if the value is
|
|
||||||
undefined or empty, otherwise the value of the variable:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ var|default('var is not defined') }}
|
|
||||||
|
|
||||||
{{ var.foo|default('foo item on var is not defined') }}
|
|
||||||
|
|
||||||
{{ var['foo']|default('foo item on var is not defined') }}
|
|
||||||
|
|
||||||
{{ ''|default('passed var is empty') }}
|
|
||||||
|
|
||||||
When using the ``default`` filter on an expression that uses variables in some
|
|
||||||
method calls, be sure to use the ``default`` filter whenever a variable can be
|
|
||||||
undefined:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ var.method(foo|default('foo'))|default('foo') }}
|
|
||||||
|
|
||||||
Using the ``default`` filter on a boolean variable might trigger unexpected behavior, as
|
|
||||||
``false`` is treated as an empty value. Consider using ``??`` instead:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set foo = false %}
|
|
||||||
{{ foo|default(true) }} {# true #}
|
|
||||||
{{ foo ?? true }} {# false #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Read the documentation for the :doc:`defined<../tests/defined>` and
|
|
||||||
:doc:`empty<../tests/empty>` tests to learn more about their semantics.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``default``: The default value
|
|
|
@ -1,117 +0,0 @@
|
||||||
``escape``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``escape`` filter escapes a string using strategies that depend on the
|
|
||||||
context.
|
|
||||||
|
|
||||||
By default, it uses the HTML escaping strategy:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{{ user.username|escape }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
For convenience, the ``e`` filter is defined as an alias:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{{ user.username|e }}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
The ``escape`` filter can also be used in other contexts than HTML thanks to
|
|
||||||
an optional argument which defines the escaping strategy to use:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ user.username|e }}
|
|
||||||
{# is equivalent to #}
|
|
||||||
{{ user.username|e('html') }}
|
|
||||||
|
|
||||||
And here is how to escape variables included in JavaScript code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ user.username|escape('js') }}
|
|
||||||
{{ user.username|e('js') }}
|
|
||||||
|
|
||||||
The ``escape`` filter supports the following escaping strategies for HTML
|
|
||||||
documents:
|
|
||||||
|
|
||||||
* ``html``: escapes a string for the **HTML body** context.
|
|
||||||
|
|
||||||
* ``js``: escapes a string for the **JavaScript** context.
|
|
||||||
|
|
||||||
* ``css``: escapes a string for the **CSS** context. CSS escaping can be
|
|
||||||
applied to any string being inserted into CSS and escapes everything except
|
|
||||||
alphanumerics.
|
|
||||||
|
|
||||||
* ``url``: escapes a string for the **URI or parameter** contexts. This should
|
|
||||||
not be used to escape an entire URI; only a subcomponent being inserted.
|
|
||||||
|
|
||||||
* ``html_attr``: escapes a string for the **HTML attribute** context.
|
|
||||||
|
|
||||||
Note that doing contextual escaping in HTML documents is hard and choosing the
|
|
||||||
right escaping strategy depends on a lot of factors. Please, read related
|
|
||||||
documentation like `the OWASP prevention cheat sheet
|
|
||||||
<https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.md>`_
|
|
||||||
to learn more about this topic.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, ``escape`` uses the PHP native `htmlspecialchars`_ function
|
|
||||||
for the HTML escaping strategy.
|
|
||||||
|
|
||||||
.. caution::
|
|
||||||
|
|
||||||
When using automatic escaping, Twig tries to not double-escape a variable
|
|
||||||
when the automatic escaping strategy is the same as the one applied by the
|
|
||||||
escape filter; but that does not work when using a variable as the
|
|
||||||
escaping strategy:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set strategy = 'html' %}
|
|
||||||
|
|
||||||
{% autoescape 'html' %}
|
|
||||||
{{ var|escape('html') }} {# won't be double-escaped #}
|
|
||||||
{{ var|escape(strategy) }} {# will be double-escaped #}
|
|
||||||
{% endautoescape %}
|
|
||||||
|
|
||||||
When using a variable as the escaping strategy, you should disable
|
|
||||||
automatic escaping:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set strategy = 'html' %}
|
|
||||||
|
|
||||||
{% autoescape 'html' %}
|
|
||||||
{{ var|escape(strategy)|raw }} {# won't be double-escaped #}
|
|
||||||
{% endautoescape %}
|
|
||||||
|
|
||||||
Custom Escapers
|
|
||||||
---------------
|
|
||||||
|
|
||||||
You can define custom escapers by calling the ``setEscaper()`` method on the
|
|
||||||
escaper extension instance. The first argument is the escaper name (to be
|
|
||||||
used in the ``escape`` call) and the second one must be a valid PHP callable::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->getExtension(\Twig\Extension\EscaperExtension::class)->setEscaper('csv', 'csv_escaper');
|
|
||||||
|
|
||||||
When called by Twig, the callable receives the Twig environment instance, the
|
|
||||||
string to escape, and the charset.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Built-in escapers cannot be overridden mainly because they should be
|
|
||||||
considered as the final implementation and also for better performance.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``strategy``: The escaping strategy
|
|
||||||
* ``charset``: The string charset
|
|
||||||
|
|
||||||
.. _`htmlspecialchars`: https://www.php.net/htmlspecialchars
|
|
|
@ -1,55 +0,0 @@
|
||||||
``filter``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``filter`` filter filters elements of a sequence or a mapping using an arrow
|
|
||||||
function. The arrow function receives the value of the sequence or mapping:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set sizes = [34, 36, 38, 40, 42] %}
|
|
||||||
|
|
||||||
{{ sizes|filter(v => v > 38)|join(', ') }}
|
|
||||||
{# output 40, 42 #}
|
|
||||||
|
|
||||||
Combined with the ``for`` tag, it allows to filter the items to iterate over:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for v in sizes|filter(v => v > 38) -%}
|
|
||||||
{{ v }}
|
|
||||||
{% endfor %}
|
|
||||||
{# output 40 42 #}
|
|
||||||
|
|
||||||
It also works with mappings:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set sizes = {
|
|
||||||
xs: 34,
|
|
||||||
s: 36,
|
|
||||||
m: 38,
|
|
||||||
l: 40,
|
|
||||||
xl: 42,
|
|
||||||
} %}
|
|
||||||
|
|
||||||
{% for k, v in sizes|filter(v => v > 38) -%}
|
|
||||||
{{ k }} = {{ v }}
|
|
||||||
{% endfor %}
|
|
||||||
{# output l = 40 xl = 42 #}
|
|
||||||
|
|
||||||
The arrow function also receives the key as a second argument:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for k, v in sizes|filter((v, k) => v > 38 and k != "xl") -%}
|
|
||||||
{{ k }} = {{ v }}
|
|
||||||
{% endfor %}
|
|
||||||
{# output l = 40 #}
|
|
||||||
|
|
||||||
Note that the arrow function has access to the current context.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``array``: The sequence or mapping
|
|
||||||
* ``arrow``: The arrow function
|
|
|
@ -1,22 +0,0 @@
|
||||||
``first``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``first`` filter returns the first "element" of a sequence, a mapping, or
|
|
||||||
a string:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3, 4]|first }}
|
|
||||||
{# outputs 1 #}
|
|
||||||
|
|
||||||
{{ { a: 1, b: 2, c: 3, d: 4 }|first }}
|
|
||||||
{# outputs 1 #}
|
|
||||||
|
|
||||||
{{ '1234'|first }}
|
|
||||||
{# outputs 1 #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
It also works with objects implementing the `Traversable`_ interface.
|
|
||||||
|
|
||||||
.. _`Traversable`: https://www.php.net/manual/en/class.traversable.php
|
|
|
@ -1,18 +0,0 @@
|
||||||
``format``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``format`` filter formats a given string by replacing the placeholders
|
|
||||||
(placeholders follows the `sprintf`_ notation):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ "I like %s and %s."|format(foo, "bar") }}
|
|
||||||
|
|
||||||
{# outputs I like foo and bar
|
|
||||||
if the foo parameter equals to the foo string. #}
|
|
||||||
|
|
||||||
.. seealso::
|
|
||||||
|
|
||||||
:doc:`replace<replace>`
|
|
||||||
|
|
||||||
.. _`sprintf`: https://www.php.net/sprintf
|
|
|
@ -1,77 +0,0 @@
|
||||||
``format_currency``
|
|
||||||
===================
|
|
||||||
|
|
||||||
The ``format_currency`` filter formats a number as a currency:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# €1,000,000.00 #}
|
|
||||||
{{ '1000000'|format_currency('EUR') }}
|
|
||||||
|
|
||||||
You can pass attributes to tweak the output:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# €12.34 #}
|
|
||||||
{{ '12.345'|format_currency('EUR', {rounding_mode: 'floor'}) }}
|
|
||||||
|
|
||||||
{# €1,000,000.0000 #}
|
|
||||||
{{ '1000000'|format_currency('EUR', {fraction_digit: 4}) }}
|
|
||||||
|
|
||||||
The list of supported options:
|
|
||||||
|
|
||||||
* ``grouping_used``;
|
|
||||||
* ``decimal_always_shown``;
|
|
||||||
* ``max_integer_digit``;
|
|
||||||
* ``min_integer_digit``;
|
|
||||||
* ``integer_digit``;
|
|
||||||
* ``max_fraction_digit``;
|
|
||||||
* ``min_fraction_digit``;
|
|
||||||
* ``fraction_digit``;
|
|
||||||
* ``multiplier``;
|
|
||||||
* ``grouping_size``;
|
|
||||||
* ``rounding_mode``;
|
|
||||||
* ``rounding_increment``;
|
|
||||||
* ``format_width``;
|
|
||||||
* ``padding_position``;
|
|
||||||
* ``secondary_grouping_size``;
|
|
||||||
* ``significant_digits_used``;
|
|
||||||
* ``min_significant_digits_used``;
|
|
||||||
* ``max_significant_digits_used``;
|
|
||||||
* ``lenient_parse``.
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 1.000.000,00 € #}
|
|
||||||
{{ '1000000'|format_currency('EUR', locale='de') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``format_currency`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``currency``: The currency
|
|
||||||
* ``attrs``: A map of attributes
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,36 +0,0 @@
|
||||||
``format_date``
|
|
||||||
===============
|
|
||||||
|
|
||||||
The ``format_date`` filter formats a date. It behaves in the exact same way as
|
|
||||||
the :doc:`format_datetime<format_datetime>` filter, but without the time.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``format_date`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
||||||
* ``dateFormat``: The date format
|
|
||||||
* ``pattern``: A date time pattern
|
|
||||||
* ``timezone``: The date timezone
|
|
||||||
* ``calendar``: The calendar (Gregorian by default)
|
|
|
@ -1,73 +0,0 @@
|
||||||
``format_datetime``
|
|
||||||
===================
|
|
||||||
|
|
||||||
The ``format_datetime`` filter formats a date time:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# Aug 7, 2019, 11:39:12 PM #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime() }}
|
|
||||||
|
|
||||||
You can tweak the output for the date part and the time part:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 23:39 #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime('none', 'short', locale='fr') }}
|
|
||||||
|
|
||||||
{# 07/08/2019 #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime('short', 'none', locale='fr') }}
|
|
||||||
|
|
||||||
{# mercredi 7 août 2019 23:39:12 UTC #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime('full', 'full', locale='fr') }}
|
|
||||||
|
|
||||||
Supported values are: ``none``, ``short``, ``medium``, ``long``, and ``full``.
|
|
||||||
|
|
||||||
For greater flexiblity, you can even define your own pattern (see the `ICU user
|
|
||||||
guide
|
|
||||||
<https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax>`_
|
|
||||||
for supported patterns).
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 11 oclock PM, GMT #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime(pattern="hh 'oclock' a, zzzz") }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 7 août 2019 23:39:12 #}
|
|
||||||
{{ '2019-08-07 23:39:12'|format_datetime(locale='fr') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``format_datetime`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
||||||
* ``dateFormat``: The date format
|
|
||||||
* ``timeFormat``: The time format
|
|
||||||
* ``pattern``: A date time pattern
|
|
||||||
* ``timezone``: The date timezone
|
|
||||||
* ``calendar``: The calendar (Gregorian by default)
|
|
|
@ -1,117 +0,0 @@
|
||||||
``format_number``
|
|
||||||
=================
|
|
||||||
|
|
||||||
The ``format_number`` filter formats a number:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ '12.345'|format_number }}
|
|
||||||
|
|
||||||
You can pass attributes to tweak the output:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 12.34 #}
|
|
||||||
{{ '12.345'|format_number({rounding_mode: 'floor'}) }}
|
|
||||||
|
|
||||||
{# 1000000.0000 #}
|
|
||||||
{{ '1000000'|format_number({fraction_digit: 4}) }}
|
|
||||||
|
|
||||||
The list of supported options:
|
|
||||||
|
|
||||||
* ``grouping_used``;
|
|
||||||
* ``decimal_always_shown``;
|
|
||||||
* ``max_integer_digit``;
|
|
||||||
* ``min_integer_digit``;
|
|
||||||
* ``integer_digit``;
|
|
||||||
* ``max_fraction_digit``;
|
|
||||||
* ``min_fraction_digit``;
|
|
||||||
* ``fraction_digit``;
|
|
||||||
* ``multiplier``;
|
|
||||||
* ``grouping_size``;
|
|
||||||
* ``rounding_mode``;
|
|
||||||
* ``rounding_increment``;
|
|
||||||
* ``format_width``;
|
|
||||||
* ``padding_position``;
|
|
||||||
* ``secondary_grouping_size``;
|
|
||||||
* ``significant_digits_used``;
|
|
||||||
* ``min_significant_digits_used``;
|
|
||||||
* ``max_significant_digits_used``;
|
|
||||||
* ``lenient_parse``.
|
|
||||||
|
|
||||||
Besides plain numbers, the filter can also format numbers in various styles:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 1,234% #}
|
|
||||||
{{ '12.345'|format_number(style='percent') }}
|
|
||||||
|
|
||||||
{# twelve point three four five #}
|
|
||||||
{{ '12.345'|format_number(style='spellout') }}
|
|
||||||
|
|
||||||
{# 12 sec. #}
|
|
||||||
{{ '12'|format_duration_number }}
|
|
||||||
|
|
||||||
The list of supported styles:
|
|
||||||
|
|
||||||
* ``decimal``;
|
|
||||||
* ``currency``;
|
|
||||||
* ``percent``;
|
|
||||||
* ``scientific``;
|
|
||||||
* ``spellout``;
|
|
||||||
* ``ordinal``;
|
|
||||||
* ``duration``.
|
|
||||||
|
|
||||||
As a shortcut, you can use the ``format_*_number`` filters by replacing `*` with
|
|
||||||
a style:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 1,234% #}
|
|
||||||
{{ '12.345'|format_percent_number }}
|
|
||||||
|
|
||||||
{# twelve point three four five #}
|
|
||||||
{{ '12.345'|format_spellout_number }}
|
|
||||||
|
|
||||||
You can pass attributes to tweak the output:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 12.3% #}
|
|
||||||
{{ '0.12345'|format_percent_number({rounding_mode: 'floor', fraction_digit: 1}) }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# 12,345 #}
|
|
||||||
{{ '12.345'|format_number(locale='fr') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``format_number`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
||||||
* ``attrs``: A map of attributes
|
|
||||||
* ``style``: The style of the number output
|
|
|
@ -1,36 +0,0 @@
|
||||||
``format_time``
|
|
||||||
===============
|
|
||||||
|
|
||||||
The ``format_time`` filter formats a time. It behaves in the exact same way as
|
|
||||||
the :doc:`format_datetime<format_datetime>` filter, but without the date.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``format_time`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
||||||
* ``timeFormat``: The time format
|
|
||||||
* ``pattern``: A date time pattern
|
|
||||||
* ``timezone``: The date timezone
|
|
||||||
* ``calendar``: The calendar (Gregorian by default)
|
|
|
@ -1,77 +0,0 @@
|
||||||
``html_to_markdown``
|
|
||||||
====================
|
|
||||||
|
|
||||||
The ``html_to_markdown`` filter converts a block of HTML to Markdown:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply html_to_markdown %}
|
|
||||||
<html>
|
|
||||||
<h1>Hello!</h1>
|
|
||||||
</html>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
You can also use the filter on an entire template which you ``include``:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ include('some_template.html.twig')|html_to_markdown }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``html_to_markdown`` filter is part of the ``MarkdownExtension`` which
|
|
||||||
is not installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/markdown-extra
|
|
||||||
|
|
||||||
On Symfony projects, you can automatically enable it by installing the
|
|
||||||
``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Or add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Markdown\MarkdownExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new MarkdownExtension());
|
|
||||||
|
|
||||||
If you are not using Symfony, you must also register the extension runtime::
|
|
||||||
|
|
||||||
use Twig\Extra\Markdown\DefaultMarkdown;
|
|
||||||
use Twig\Extra\Markdown\MarkdownRuntime;
|
|
||||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
|
||||||
|
|
||||||
$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
|
|
||||||
public function load($class) {
|
|
||||||
if (MarkdownRuntime::class === $class) {
|
|
||||||
return new MarkdownRuntime(new DefaultMarkdown());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
``html_to_markdown`` is just a frontend; the actual conversion is done by one of
|
|
||||||
the following compatible libraries, from which you can choose:
|
|
||||||
|
|
||||||
* `league/html-to-markdown`_
|
|
||||||
* `michelf/php-markdown`_
|
|
||||||
* `erusev/parsedown`_
|
|
||||||
|
|
||||||
Depending on the library, you can also add some options by passing them as an argument
|
|
||||||
to the filter. Example for ``league/html-to-markdown``:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply html_to_markdown({hard_break: false}) %}
|
|
||||||
<html>
|
|
||||||
<h1>Hello!</h1>
|
|
||||||
</html>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
.. _league/html-to-markdown: https://github.com/thephpleague/html-to-markdown
|
|
||||||
.. _michelf/php-markdown: https://github.com/michelf/php-markdown
|
|
||||||
.. _erusev/parsedown: https://github.com/erusev/parsedown
|
|
|
@ -1,60 +0,0 @@
|
||||||
Filters
|
|
||||||
=======
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
|
|
||||||
abs
|
|
||||||
batch
|
|
||||||
capitalize
|
|
||||||
column
|
|
||||||
convert_encoding
|
|
||||||
country_name
|
|
||||||
currency_name
|
|
||||||
currency_symbol
|
|
||||||
data_uri
|
|
||||||
date
|
|
||||||
date_modify
|
|
||||||
default
|
|
||||||
escape
|
|
||||||
filter
|
|
||||||
first
|
|
||||||
format
|
|
||||||
format_currency
|
|
||||||
format_date
|
|
||||||
format_datetime
|
|
||||||
format_number
|
|
||||||
format_time
|
|
||||||
html_to_markdown
|
|
||||||
inline_css
|
|
||||||
inky_to_html
|
|
||||||
join
|
|
||||||
json_encode
|
|
||||||
keys
|
|
||||||
language_name
|
|
||||||
last
|
|
||||||
length
|
|
||||||
locale_name
|
|
||||||
lower
|
|
||||||
map
|
|
||||||
markdown_to_html
|
|
||||||
merge
|
|
||||||
nl2br
|
|
||||||
number_format
|
|
||||||
raw
|
|
||||||
reduce
|
|
||||||
replace
|
|
||||||
reverse
|
|
||||||
round
|
|
||||||
slice
|
|
||||||
slug
|
|
||||||
sort
|
|
||||||
spaceless
|
|
||||||
split
|
|
||||||
striptags
|
|
||||||
timezone_name
|
|
||||||
title
|
|
||||||
trim
|
|
||||||
u
|
|
||||||
upper
|
|
||||||
url_encode
|
|
|
@ -1,42 +0,0 @@
|
||||||
``inky_to_html``
|
|
||||||
================
|
|
||||||
|
|
||||||
The ``inky_to_html`` filter processes an `inky email template
|
|
||||||
<https://github.com/zurb/inky>`_:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply inky_to_html %}
|
|
||||||
<row>
|
|
||||||
<columns large="6"></columns>
|
|
||||||
<columns large="6"></columns>
|
|
||||||
</row>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
You can also use the filter on an included file:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ include('some_template.inky.twig')|inky_to_html }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``inky_to_html`` filter is part of the ``InkyExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/inky-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Inky\InkyExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new InkyExtension());
|
|
|
@ -1,66 +0,0 @@
|
||||||
``inline_css``
|
|
||||||
==============
|
|
||||||
|
|
||||||
The ``inline_css`` filter inline CSS styles in HTML documents:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply inline_css %}
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<style>
|
|
||||||
p { color: red; }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Hello CSS!</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
You can also add some stylesheets by passing them as arguments to the filter:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply inline_css(source("some_styles.css"), source("another.css")) %}
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<p>Hello CSS!</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
Styles loaded via the filter override the styles defined in the ``<style>`` tag
|
|
||||||
of the HTML document.
|
|
||||||
|
|
||||||
You can also use the filter on an included file:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ include('some_template.html.twig')|inline_css }}
|
|
||||||
|
|
||||||
{{ include('some_template.html.twig')|inline_css(source("some_styles.css")) }}
|
|
||||||
|
|
||||||
Note that the CSS inliner works on an entire HTML document, not a fragment.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``inline_css`` filter is part of the ``CssInlinerExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/cssinliner-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\CssInliner\CssInlinerExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new CssInlinerExtension());
|
|
|
@ -1,32 +0,0 @@
|
||||||
``join``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``join`` filter returns a string which is the concatenation of the items
|
|
||||||
of a sequence:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3]|join }}
|
|
||||||
{# returns 123 #}
|
|
||||||
|
|
||||||
The separator between elements is an empty string per default, but you can
|
|
||||||
define it with the optional first parameter:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3]|join('|') }}
|
|
||||||
{# outputs 1|2|3 #}
|
|
||||||
|
|
||||||
A second parameter can also be provided that will be the separator used between
|
|
||||||
the last two items of the sequence:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3]|join(', ', ' and ') }}
|
|
||||||
{# outputs 1, 2 and 3 #}
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``glue``: The separator
|
|
||||||
* ``and``: The separator for the last pair of input items
|
|
|
@ -1,23 +0,0 @@
|
||||||
``json_encode``
|
|
||||||
===============
|
|
||||||
|
|
||||||
The ``json_encode`` filter returns the JSON representation of a value:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ data|json_encode() }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `json_encode`_ function.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``options``: A bitmask of `json_encode options`_: ``{{
|
|
||||||
data|json_encode(constant('JSON_PRETTY_PRINT')) }}``.
|
|
||||||
Combine constants using :ref:`bitwise operators<template_logic>`:
|
|
||||||
``{{ data|json_encode(constant('JSON_PRETTY_PRINT') b-or constant('JSON_HEX_QUOT')) }}``
|
|
||||||
|
|
||||||
.. _`json_encode`: https://www.php.net/json_encode
|
|
||||||
.. _`json_encode options`: https://www.php.net/manual/en/json.constants.php
|
|
|
@ -1,11 +0,0 @@
|
||||||
``keys``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``keys`` filter returns the keys of an array. It is useful when you want to
|
|
||||||
iterate over the keys of an array:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for key in array|keys %}
|
|
||||||
...
|
|
||||||
{% endfor %}
|
|
|
@ -1,47 +0,0 @@
|
||||||
``language_name``
|
|
||||||
=================
|
|
||||||
|
|
||||||
The ``language_name`` filter returns the language name given its two-letter
|
|
||||||
code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# German #}
|
|
||||||
{{ 'de'|language_name }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# allemand #}
|
|
||||||
{{ 'de'|language_name('fr') }}
|
|
||||||
|
|
||||||
{# français canadien #}
|
|
||||||
{{ 'fr_CA'|language_name('fr_FR') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``language_name`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,22 +0,0 @@
|
||||||
``last``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``last`` filter returns the last "element" of a sequence, a mapping, or
|
|
||||||
a string:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ [1, 2, 3, 4]|last }}
|
|
||||||
{# outputs 4 #}
|
|
||||||
|
|
||||||
{{ { a: 1, b: 2, c: 3, d: 4 }|last }}
|
|
||||||
{# outputs 4 #}
|
|
||||||
|
|
||||||
{{ '1234'|last }}
|
|
||||||
{# outputs 4 #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
It also works with objects implementing the `Traversable`_ interface.
|
|
||||||
|
|
||||||
.. _`Traversable`: https://www.php.net/manual/en/class.traversable.php
|
|
|
@ -1,19 +0,0 @@
|
||||||
``length``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``length`` filter returns the number of items of a sequence or mapping, or
|
|
||||||
the length of a string.
|
|
||||||
|
|
||||||
For objects that implement the ``Countable`` interface, ``length`` will use the
|
|
||||||
return value of the ``count()`` method.
|
|
||||||
|
|
||||||
For objects that implement the ``__toString()`` magic method (and not ``Countable``),
|
|
||||||
it will return the length of the string provided by that method.
|
|
||||||
|
|
||||||
For objects that implement the ``Traversable`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% if users|length > 10 %}
|
|
||||||
...
|
|
||||||
{% endif %}
|
|
|
@ -1,47 +0,0 @@
|
||||||
``locale_name``
|
|
||||||
===============
|
|
||||||
|
|
||||||
The ``locale_name`` filter returns the locale name given its two-letter
|
|
||||||
code:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# German #}
|
|
||||||
{{ 'de'|locale_name }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# allemand #}
|
|
||||||
{{ 'de'|locale_name('fr') }}
|
|
||||||
|
|
||||||
{# français (Canada) #}
|
|
||||||
{{ 'fr_CA'|locale_name('fr_FR') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``locale_name`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
|
@ -1,10 +0,0 @@
|
||||||
``lower``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``lower`` filter converts a value to lowercase:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'WELCOME'|lower }}
|
|
||||||
|
|
||||||
{# outputs 'welcome' #}
|
|
|
@ -1,34 +0,0 @@
|
||||||
``map``
|
|
||||||
=======
|
|
||||||
|
|
||||||
The ``map`` filter applies an arrow function to the elements of a sequence or a
|
|
||||||
mapping. The arrow function receives the value of the sequence or mapping:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set people = [
|
|
||||||
{first: "Bob", last: "Smith"},
|
|
||||||
{first: "Alice", last: "Dupond"},
|
|
||||||
] %}
|
|
||||||
|
|
||||||
{{ people|map(p => "#{p.first} #{p.last}")|join(', ') }}
|
|
||||||
{# outputs Bob Smith, Alice Dupond #}
|
|
||||||
|
|
||||||
The arrow function also receives the key as a second argument:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set people = {
|
|
||||||
"Bob": "Smith",
|
|
||||||
"Alice": "Dupond",
|
|
||||||
} %}
|
|
||||||
|
|
||||||
{{ people|map((last, first) => "#{first} #{last}")|join(', ') }}
|
|
||||||
{# outputs Bob Smith, Alice Dupond #}
|
|
||||||
|
|
||||||
Note that the arrow function has access to the current context.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``arrow``: The arrow function
|
|
|
@ -1,72 +0,0 @@
|
||||||
``markdown_to_html``
|
|
||||||
====================
|
|
||||||
|
|
||||||
The ``markdown_to_html`` filter converts a block of Markdown to HTML:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% apply markdown_to_html %}
|
|
||||||
Title
|
|
||||||
======
|
|
||||||
|
|
||||||
Hello!
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
Note that you can indent the Markdown content as leading whitespaces will be
|
|
||||||
removed consistently before conversion:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% apply markdown_to_html %}
|
|
||||||
Title
|
|
||||||
======
|
|
||||||
|
|
||||||
Hello!
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
You can also use the filter on an included file or a variable:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ include('some_template.markdown.twig')|markdown_to_html }}
|
|
||||||
|
|
||||||
{{ changelog|markdown_to_html }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``markdown_to_html`` filter is part of the ``MarkdownExtension`` which
|
|
||||||
is not installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/markdown-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Markdown\MarkdownExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new MarkdownExtension());
|
|
||||||
|
|
||||||
If you are not using Symfony, you must also register the extension runtime::
|
|
||||||
|
|
||||||
use Twig\Extra\Markdown\DefaultMarkdown;
|
|
||||||
use Twig\Extra\Markdown\MarkdownRuntime;
|
|
||||||
use Twig\RuntimeLoader\RuntimeLoaderInterface;
|
|
||||||
|
|
||||||
$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
|
|
||||||
public function load($class) {
|
|
||||||
if (MarkdownRuntime::class === $class) {
|
|
||||||
return new MarkdownRuntime(new DefaultMarkdown());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Afterwards you need to install a markdown library of your choice. Some of them are
|
|
||||||
mentioned in the ``require-dev`` section of the ``twig/markdown-extra`` package.
|
|
|
@ -1,48 +0,0 @@
|
||||||
``merge``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``merge`` filter merges an array with another array:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set values = [1, 2] %}
|
|
||||||
|
|
||||||
{% set values = values|merge(['apple', 'orange']) %}
|
|
||||||
|
|
||||||
{# values now contains [1, 2, 'apple', 'orange'] #}
|
|
||||||
|
|
||||||
New values are added at the end of the existing ones.
|
|
||||||
|
|
||||||
The ``merge`` filter also works on hashes:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set items = { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'unknown' } %}
|
|
||||||
|
|
||||||
{% set items = items|merge({ 'peugeot': 'car', 'renault': 'car' }) %}
|
|
||||||
|
|
||||||
{# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car', 'renault': 'car' } #}
|
|
||||||
|
|
||||||
For hashes, the merging process occurs on the keys: if the key does not
|
|
||||||
already exist, it is added but if the key already exists, its value is
|
|
||||||
overridden.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
If you want to ensure that some values are defined in an array (by given
|
|
||||||
default values), reverse the two elements in the call:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
|
|
||||||
|
|
||||||
{% set items = { 'apple': 'unknown' }|merge(items) %}
|
|
||||||
|
|
||||||
{# items now contains { 'apple': 'fruit', 'orange': 'fruit' } #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `array_merge`_ function. It supports
|
|
||||||
Traversable objects by transforming those to arrays.
|
|
||||||
|
|
||||||
.. _`array_merge`: https://www.php.net/array_merge
|
|
|
@ -1,19 +0,0 @@
|
||||||
``nl2br``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``nl2br`` filter inserts HTML line breaks before all newlines in a string:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{ "I like Twig.\nYou will like it too."|nl2br }}
|
|
||||||
{# outputs
|
|
||||||
|
|
||||||
I like Twig.<br />
|
|
||||||
You will like it too.
|
|
||||||
|
|
||||||
#}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``nl2br`` filter pre-escapes the input before applying the
|
|
||||||
transformation.
|
|
|
@ -1,51 +0,0 @@
|
||||||
``number_format``
|
|
||||||
=================
|
|
||||||
|
|
||||||
The ``number_format`` filter formats numbers. It is a wrapper around PHP's
|
|
||||||
`number_format`_ function:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 200.35|number_format }}
|
|
||||||
|
|
||||||
You can control the number of decimal places, decimal point, and thousands
|
|
||||||
separator using the additional arguments:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 9800.333|number_format(2, '.', ',') }}
|
|
||||||
|
|
||||||
To format negative numbers or math calculation, wrap the previous statement
|
|
||||||
with parentheses (needed because of Twig's :ref:`precedence of operators
|
|
||||||
<twig-expressions>`):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ -9800.333|number_format(2, '.', ',') }} {# outputs : -9 #}
|
|
||||||
{{ (-9800.333)|number_format(2, '.', ',') }} {# outputs : -9,800.33 #}
|
|
||||||
{{ 1 + 0.2|number_format(2) }} {# outputs : 1.2 #}
|
|
||||||
{{ (1 + 0.2)|number_format(2) }} {# outputs : 1.20 #}
|
|
||||||
|
|
||||||
If no formatting options are provided then Twig will use the default formatting
|
|
||||||
options of:
|
|
||||||
|
|
||||||
* 0 decimal places.
|
|
||||||
* ``.`` as the decimal point.
|
|
||||||
* ``,`` as the thousands separator.
|
|
||||||
|
|
||||||
These defaults can be changed through the core extension::
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment($loader);
|
|
||||||
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setNumberFormat(3, '.', ',');
|
|
||||||
|
|
||||||
The defaults set for ``number_format`` can be over-ridden upon each call using the
|
|
||||||
additional parameters.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``decimal``: The number of decimal points to display
|
|
||||||
* ``decimal_point``: The character(s) to use for the decimal point
|
|
||||||
* ``thousand_sep``: The character(s) to use for the thousands separator
|
|
||||||
|
|
||||||
.. _`number_format`: https://www.php.net/number_format
|
|
|
@ -1,12 +0,0 @@
|
||||||
``raw``
|
|
||||||
=======
|
|
||||||
|
|
||||||
The ``raw`` filter marks the value as being "safe", which means that in an
|
|
||||||
environment with automatic escaping enabled this variable will not be escaped
|
|
||||||
if ``raw`` is the last filter applied to it:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% autoescape %}
|
|
||||||
{{ var|raw }} {# var won't be escaped #}
|
|
||||||
{% endautoescape %}
|
|
|
@ -1,29 +0,0 @@
|
||||||
``reduce``
|
|
||||||
==========
|
|
||||||
|
|
||||||
The ``reduce`` filter iteratively reduces a sequence or a mapping to a single
|
|
||||||
value using an arrow function, so as to reduce it to a single value. The arrow
|
|
||||||
function receives the return value of the previous iteration and the current
|
|
||||||
value of the sequence or mapping:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set numbers = [1, 2, 3] %}
|
|
||||||
|
|
||||||
{{ numbers|reduce((carry, v) => carry + v) }}
|
|
||||||
{# output 6 #}
|
|
||||||
|
|
||||||
The ``reduce`` filter takes an ``initial`` value as a second argument:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ numbers|reduce((carry, v) => carry + v, 10) }}
|
|
||||||
{# output 16 #}
|
|
||||||
|
|
||||||
Note that the arrow function has access to the current context.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``arrow``: The arrow function
|
|
||||||
* ``initial``: The initial value
|
|
|
@ -1,27 +0,0 @@
|
||||||
``replace``
|
|
||||||
===========
|
|
||||||
|
|
||||||
The ``replace`` filter formats a given string by replacing the placeholders
|
|
||||||
(placeholders are free-form):
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ "I like %this% and %that%."|replace({'%this%': foo, '%that%': "bar"}) }}
|
|
||||||
|
|
||||||
{# outputs I like foo and bar
|
|
||||||
if the foo parameter equals to the foo string. #}
|
|
||||||
|
|
||||||
{# using % as a delimiter is purely conventional and optional #}
|
|
||||||
|
|
||||||
{{ "I like this and --that--."|replace({'this': foo, '--that--': "bar"}) }}
|
|
||||||
|
|
||||||
{# outputs I like foo and bar #}
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``from``: The placeholder values
|
|
||||||
|
|
||||||
.. seealso::
|
|
||||||
|
|
||||||
:doc:`format<format>`
|
|
|
@ -1,44 +0,0 @@
|
||||||
``reverse``
|
|
||||||
===========
|
|
||||||
|
|
||||||
The ``reverse`` filter reverses a sequence, a mapping, or a string:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for user in users|reverse %}
|
|
||||||
...
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{{ '1234'|reverse }}
|
|
||||||
|
|
||||||
{# outputs 4321 #}
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
For sequences and mappings, numeric keys are not preserved. To reverse
|
|
||||||
them as well, pass ``true`` as an argument to the ``reverse`` filter:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for key, value in {1: "a", 2: "b", 3: "c"}|reverse %}
|
|
||||||
{{ key }}: {{ value }}
|
|
||||||
{%- endfor %}
|
|
||||||
|
|
||||||
{# output: 0: c 1: b 2: a #}
|
|
||||||
|
|
||||||
{% for key, value in {1: "a", 2: "b", 3: "c"}|reverse(true) %}
|
|
||||||
{{ key }}: {{ value }}
|
|
||||||
{%- endfor %}
|
|
||||||
|
|
||||||
{# output: 3: c 2: b 1: a #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
It also works with objects implementing the `Traversable`_ interface.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``preserve_keys``: Preserve keys when reversing a mapping or a sequence.
|
|
||||||
|
|
||||||
.. _`Traversable`: https://www.php.net/Traversable
|
|
|
@ -1,34 +0,0 @@
|
||||||
``round``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``round`` filter rounds a number to a given precision:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 42.55|round }}
|
|
||||||
{# outputs 43 #}
|
|
||||||
|
|
||||||
{{ 42.55|round(1, 'floor') }}
|
|
||||||
{# outputs 42.5 #}
|
|
||||||
|
|
||||||
The ``round`` filter takes two optional arguments; the first one specifies the
|
|
||||||
precision (default is ``0``) and the second the rounding method (default is
|
|
||||||
``common``):
|
|
||||||
|
|
||||||
* ``common`` rounds either up or down (rounds the value up to precision decimal
|
|
||||||
places away from zero, when it is half way there -- making 1.5 into 2 and
|
|
||||||
-1.5 into -2);
|
|
||||||
|
|
||||||
* ``ceil`` always rounds up;
|
|
||||||
|
|
||||||
* ``floor`` always rounds down.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``//`` operator is equivalent to ``|round(0, 'floor')``.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``precision``: The rounding precision
|
|
||||||
* ``method``: The rounding method
|
|
|
@ -1,68 +0,0 @@
|
||||||
``slice``
|
|
||||||
===========
|
|
||||||
|
|
||||||
The ``slice`` filter extracts a slice of a sequence, a mapping, or a string:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for i in [1, 2, 3, 4, 5]|slice(1, 2) %}
|
|
||||||
{# will iterate over 2 and 3 #}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{{ '12345'|slice(1, 2) }}
|
|
||||||
|
|
||||||
{# outputs 23 #}
|
|
||||||
|
|
||||||
You can use any valid expression for both the start and the length:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for i in [1, 2, 3, 4, 5]|slice(start, length) %}
|
|
||||||
{# ... #}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
As syntactic sugar, you can also use the ``[]`` notation:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for i in [1, 2, 3, 4, 5][start:length] %}
|
|
||||||
{# ... #}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{{ '12345'[1:2] }} {# will display "23" #}
|
|
||||||
|
|
||||||
{# you can omit the first argument -- which is the same as 0 #}
|
|
||||||
{{ '12345'[:2] }} {# will display "12" #}
|
|
||||||
|
|
||||||
{# you can omit the last argument -- which will select everything till the end #}
|
|
||||||
{{ '12345'[2:] }} {# will display "345" #}
|
|
||||||
|
|
||||||
The ``slice`` filter works as the `array_slice`_ PHP function for arrays and
|
|
||||||
`mb_substr`_ for strings with a fallback to `substr`_.
|
|
||||||
|
|
||||||
If the start is non-negative, the sequence will start at that start in the
|
|
||||||
variable. If start is negative, the sequence will start that far from the end
|
|
||||||
of the variable.
|
|
||||||
|
|
||||||
If length is given and is positive, then the sequence will have up to that
|
|
||||||
many elements in it. If the variable is shorter than the length, then only the
|
|
||||||
available variable elements will be present. If length is given and is
|
|
||||||
negative then the sequence will stop that many elements from the end of the
|
|
||||||
variable. If it is omitted, then the sequence will have everything from offset
|
|
||||||
up until the end of the variable.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
It also works with objects implementing the `Traversable`_ interface.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``start``: The start of the slice
|
|
||||||
* ``length``: The size of the slice
|
|
||||||
* ``preserve_keys``: Whether to preserve key or not (when the input is an array)
|
|
||||||
|
|
||||||
.. _`Traversable`: https://www.php.net/manual/en/class.traversable.php
|
|
||||||
.. _`array_slice`: https://www.php.net/array_slice
|
|
||||||
.. _`mb_substr`: https://www.php.net/mb-substr
|
|
||||||
.. _`substr`: https://www.php.net/substr
|
|
|
@ -1,59 +0,0 @@
|
||||||
``slug``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``slug`` filter transforms a given string into another string that
|
|
||||||
only includes safe ASCII characters.
|
|
||||||
|
|
||||||
Here is an example:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'Wôrķšƥáçè ~~sèťtïñğš~~'|slug }}
|
|
||||||
Workspace-settings
|
|
||||||
|
|
||||||
The default separator between words is a dash (``-``), but you can
|
|
||||||
define a selector of your choice by passing it as an argument:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ 'Wôrķšƥáçè ~~sèťtïñğš~~'|slug('/') }}
|
|
||||||
Workspace/settings
|
|
||||||
|
|
||||||
The slugger automatically detects the language of the original
|
|
||||||
string, but you can also specify it explicitly using the second
|
|
||||||
argument:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ '...'|slug('-', 'ko') }}
|
|
||||||
|
|
||||||
The ``slug`` filter uses the method by the same name in Symfony's
|
|
||||||
`AsciiSlugger <https://symfony.com/doc/current/components/string.html#slugger>`_.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``slug`` filter is part of the ``StringExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/string-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\String\StringExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new StringExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``separator``: The separator that is used to join words (defaults to ``-``)
|
|
||||||
* ``locale``: The locale of the original string (if none is specified, it will be automatically detected)
|
|
|
@ -1,42 +0,0 @@
|
||||||
``sort``
|
|
||||||
========
|
|
||||||
|
|
||||||
The ``sort`` filter sorts an array:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% for user in users|sort %}
|
|
||||||
...
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `asort`_ function to maintain index
|
|
||||||
association. It supports Traversable objects by transforming
|
|
||||||
those to arrays.
|
|
||||||
|
|
||||||
You can pass an arrow function to sort the array:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% set fruits = [
|
|
||||||
{ name: 'Apples', quantity: 5 },
|
|
||||||
{ name: 'Oranges', quantity: 2 },
|
|
||||||
{ name: 'Grapes', quantity: 4 },
|
|
||||||
] %}
|
|
||||||
|
|
||||||
{% for fruit in fruits|sort((a, b) => a.quantity <=> b.quantity)|column('name') %}
|
|
||||||
{{ fruit }}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{# output in this order: Oranges, Grapes, Apples #}
|
|
||||||
|
|
||||||
Note the usage of the `spaceship`_ operator to simplify the comparison.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``arrow``: An arrow function
|
|
||||||
|
|
||||||
.. _`asort`: https://www.php.net/asort
|
|
||||||
.. _`spaceship`: https://www.php.net/manual/en/language.operators.comparison.php
|
|
|
@ -1,56 +0,0 @@
|
||||||
``spaceless``
|
|
||||||
=============
|
|
||||||
|
|
||||||
Use the ``spaceless`` filter to remove whitespace *between HTML tags*, not
|
|
||||||
whitespace within HTML tags or whitespace in plain text:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{
|
|
||||||
"<div>
|
|
||||||
<strong>foo</strong>
|
|
||||||
</div>
|
|
||||||
"|spaceless }}
|
|
||||||
|
|
||||||
{# output will be <div><strong>foo</strong></div> #}
|
|
||||||
|
|
||||||
You can combine ``spaceless`` with the ``apply`` tag to apply the transformation
|
|
||||||
on large amounts of HTML:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{% apply spaceless %}
|
|
||||||
<div>
|
|
||||||
<strong>foo</strong>
|
|
||||||
</div>
|
|
||||||
{% endapply %}
|
|
||||||
|
|
||||||
{# output will be <div><strong>foo</strong></div> #}
|
|
||||||
|
|
||||||
This tag is not meant to "optimize" the size of the generated HTML content but
|
|
||||||
merely to avoid extra whitespace between HTML tags to avoid browser rendering
|
|
||||||
quirks under some circumstances.
|
|
||||||
|
|
||||||
.. caution::
|
|
||||||
|
|
||||||
As the filter uses a regular expression behind the scenes, its performance
|
|
||||||
is directly related to the text size you are working on (remember that
|
|
||||||
filters are executed at runtime).
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
If you want to optimize the size of the generated HTML content, gzip
|
|
||||||
compress the output instead.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
If you want to create a tag that actually removes all extra whitespace in
|
|
||||||
an HTML string, be warned that this is not as easy as it seems to be
|
|
||||||
(think of ``textarea`` or ``pre`` tags for instance). Using a third-party
|
|
||||||
library like Tidy is probably a better idea.
|
|
||||||
|
|
||||||
.. tip::
|
|
||||||
|
|
||||||
For more information on whitespace control, read the
|
|
||||||
:ref:`dedicated section <templates-whitespace-control>` of the documentation and learn how
|
|
||||||
you can also use the whitespace control modifier on your tags.
|
|
|
@ -1,50 +0,0 @@
|
||||||
``split``
|
|
||||||
=========
|
|
||||||
|
|
||||||
The ``split`` filter splits a string by the given delimiter and returns a list
|
|
||||||
of strings:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set foo = "one,two,three"|split(',') %}
|
|
||||||
{# foo contains ['one', 'two', 'three'] #}
|
|
||||||
|
|
||||||
You can also pass a ``limit`` argument:
|
|
||||||
|
|
||||||
* If ``limit`` is positive, the returned array will contain a maximum of
|
|
||||||
limit elements with the last element containing the rest of string;
|
|
||||||
|
|
||||||
* If ``limit`` is negative, all components except the last -limit are
|
|
||||||
returned;
|
|
||||||
|
|
||||||
* If ``limit`` is zero, then this is treated as 1.
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set foo = "one,two,three,four,five"|split(',', 3) %}
|
|
||||||
{# foo contains ['one', 'two', 'three,four,five'] #}
|
|
||||||
|
|
||||||
If the ``delimiter`` is an empty string, then value will be split by equal
|
|
||||||
chunks. Length is set by the ``limit`` argument (one character by default).
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{% set foo = "123"|split('') %}
|
|
||||||
{# foo contains ['1', '2', '3'] #}
|
|
||||||
|
|
||||||
{% set bar = "aabbcc"|split('', 2) %}
|
|
||||||
{# bar contains ['aa', 'bb', 'cc'] #}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `explode`_ or `str_split`_ (if delimiter is
|
|
||||||
empty) functions for string splitting.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``delimiter``: The delimiter
|
|
||||||
* ``limit``: The limit argument
|
|
||||||
|
|
||||||
.. _`explode`: https://www.php.net/explode
|
|
||||||
.. _`str_split`: https://www.php.net/str_split
|
|
|
@ -1,29 +0,0 @@
|
||||||
``striptags``
|
|
||||||
=============
|
|
||||||
|
|
||||||
The ``striptags`` filter strips SGML/XML tags and replace adjacent whitespace
|
|
||||||
by one space:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{{ some_html|striptags }}
|
|
||||||
|
|
||||||
You can also provide tags which should not be stripped:
|
|
||||||
|
|
||||||
.. code-block:: html+twig
|
|
||||||
|
|
||||||
{{ some_html|striptags('<br><p>') }}
|
|
||||||
|
|
||||||
In this example, the ``<br/>``, ``<br>``, ``<p>``, and ``</p>`` tags won't be
|
|
||||||
removed from the string.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Internally, Twig uses the PHP `strip_tags`_ function.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``allowable_tags``: Tags which should not be stripped
|
|
||||||
|
|
||||||
.. _`strip_tags`: https://www.php.net/strip_tags
|
|
|
@ -1,46 +0,0 @@
|
||||||
``timezone_name``
|
|
||||||
=================
|
|
||||||
|
|
||||||
The ``timezone_name`` filter returns the timezone name given a timezone identifier:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# Central European Time (Paris) #}
|
|
||||||
{{ 'Europe/Paris'|timezone_name }}
|
|
||||||
|
|
||||||
{# Pacific Time (Los Angeles) #}
|
|
||||||
{{ 'America/Los_Angeles'|timezone_name }}
|
|
||||||
|
|
||||||
By default, the filter uses the current locale. You can pass it explicitly:
|
|
||||||
|
|
||||||
.. code-block:: twig
|
|
||||||
|
|
||||||
{# heure du Pacifique nord-américain (Los Angeles) #}
|
|
||||||
{{ 'America/Los_Angeles'|timezone_name('fr') }}
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
The ``timezone_name`` filter is part of the ``IntlExtension`` which is not
|
|
||||||
installed by default. Install it first:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/intl-extra
|
|
||||||
|
|
||||||
Then, on Symfony projects, install the ``twig/extra-bundle``:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ composer require twig/extra-bundle
|
|
||||||
|
|
||||||
Otherwise, add the extension explicitly on the Twig environment::
|
|
||||||
|
|
||||||
use Twig\Extra\Intl\IntlExtension;
|
|
||||||
|
|
||||||
$twig = new \Twig\Environment(...);
|
|
||||||
$twig->addExtension(new IntlExtension());
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
---------
|
|
||||||
|
|
||||||
* ``locale``: The locale
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue