diff --git a/composer.json b/composer.json index 9ca524c..21179f9 100644 --- a/composer.json +++ b/composer.json @@ -16,34 +16,18 @@ } ], "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0.0", - "topthink/think-orm": "^2.0", + "php": ">=8.0.0", + "topthink/framework": "^8.0.1", + "topthink/think-orm": "^3.0", "topthink/think-multi-app": "^1.0", - "taoser/think-auth": "^1.0", - "topthink/think-view": "^1.0", + "topthink/think-view": "^2.0", "topthink/think-captcha": "^3.0", - "phpmailer/phpmailer": "^6.1", - "lotofbadcode/phpspirit_databackup": "^1.1", - "wamkj/thinkphp6.0-databackup": "^1.0", - "taoser/think-addons": "^1.0", - "liliuwei/thinkphp-social": "^1.3", - "taoser/think-setarr": "^0.0.3", - "topthink/think-migration": "^3.0", - "workerman/workerman": "^4.0", - "endroid/qr-code": "^4.4", - "yansongda/pay": "~3.1.0", - "guzzlehttp/guzzle": "7.0", - "php-di/php-di": "^6.4", - "workerman/phpsocket.io": "^1.1", - "jaeger/querylist": "^4.2", - "symfony/var-exporter": "^5.4", + "taoser/think-auth": "^2.0", + "taoser/think-addons": "^2.0", + "taoser/think-setarr": "^0.0.5", + "phpmailer/phpmailer": "^6.8", "yzh52521/easyhttp": "^1.0" }, - "require-dev": { - "symfony/var-dumper": "^4.2", - "topthink/think-trace":"^1.0" - }, "autoload": { "psr-4": { "app\\": "app" diff --git a/composer.lock b/composer.lock index 301ab4b..1220e16 100644 --- a/composer.lock +++ b/composer.lock @@ -4,409 +4,40 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "20dad4ba0451f20b1191711c63ad21c7", + "content-hash": "fec5a4fd1603393ed4fdce0056d1f06b", "packages": [ - { - "name": "bacon/bacon-qr-code", - "version": "2.0.8", - "source": { - "type": "git", - "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22", - "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22", - "shasum": "" - }, - "require": { - "dasprid/enum": "^1.0.3", - "ext-iconv": "*", - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "phly/keep-a-changelog": "^2.1", - "phpunit/phpunit": "^7 | ^8 | ^9", - "spatie/phpunit-snapshot-assertions": "^4.2.9", - "squizlabs/php_codesniffer": "^3.4" - }, - "suggest": { - "ext-imagick": "to generate QR code images" - }, - "type": "library", - "autoload": { - "psr-4": { - "BaconQrCode\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "BaconQrCode is a QR code generator for PHP.", - "homepage": "https://github.com/Bacon/BaconQrCode", - "support": { - "issues": "https://github.com/Bacon/BaconQrCode/issues", - "source": "https://github.com/Bacon/BaconQrCode/tree/2.0.8" - }, - "time": "2022-12-07T17:46:57+00:00" - }, - { - "name": "cache/adapter-common", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/adapter-common.git", - "reference": "8788309be72aa7be69b88cdc0687549c74a7d479" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/adapter-common/zipball/8788309be72aa7be69b88cdc0687549c74a7d479", - "reference": "8788309be72aa7be69b88cdc0687549c74a7d479", - "shasum": "" - }, - "require": { - "cache/tag-interop": "^1.0", - "php": ">=7.4", - "psr/cache": "^1.0 || ^2.0", - "psr/log": "^1.0 || ^2.0 || ^3.0", - "psr/simple-cache": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Cache\\Adapter\\Common\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "description": "Common classes for PSR-6 adapters", - "homepage": "http://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "psr-6", - "tag" - ], - "support": { - "source": "https://github.com/php-cache/adapter-common/tree/1.3.0" - }, - "time": "2022-01-15T15:47:19+00:00" - }, - { - "name": "cache/filesystem-adapter", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/filesystem-adapter.git", - "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/filesystem-adapter/zipball/f1faaae40aaa696ef899cef6f6888aedb90b419b", - "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b", - "shasum": "" - }, - "require": { - "cache/adapter-common": "^1.0", - "league/flysystem": "^1.0", - "php": ">=7.4", - "psr/cache": "^1.0 || ^2.0", - "psr/simple-cache": "^1.0" - }, - "provide": { - "psr/cache-implementation": "^1.0", - "psr/simple-cache-implementation": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Cache\\Adapter\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "description": "A PSR-6 cache implementation using filesystem. This implementation supports tags", - "homepage": "http://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "filesystem", - "psr-6", - "tag" - ], - "support": { - "source": "https://github.com/php-cache/filesystem-adapter/tree/1.2.0" - }, - "time": "2022-01-15T15:47:19+00:00" - }, - { - "name": "cache/tag-interop", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/tag-interop.git", - "reference": "b062b1d735357da50edf8387f7a8696f3027d328" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/tag-interop/zipball/b062b1d735357da50edf8387f7a8696f3027d328", - "reference": "b062b1d735357da50edf8387f7a8696f3027d328", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0 || ^8.0", - "psr/cache": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "Cache\\TagInterop\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com", - "homepage": "https://github.com/nicolas-grekas" - } - ], - "description": "Framework interoperable interfaces for tags", - "homepage": "https://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "psr", - "psr6", - "tag" - ], - "support": { - "issues": "https://github.com/php-cache/tag-interop/issues", - "source": "https://github.com/php-cache/tag-interop/tree/1.1.0" - }, - "time": "2021-12-31T10:03:23+00:00" - }, - { - "name": "dasprid/enum", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/DASPRiD/Enum.git", - "reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8e6b6ea76eabbf19ea2bf5b67b98e1860474012f", - "reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f", - "shasum": "" - }, - "require": { - "php": ">=7.1 <9.0" - }, - "require-dev": { - "phpunit/phpunit": "^7 | ^8 | ^9", - "squizlabs/php_codesniffer": "*" - }, - "type": "library", - "autoload": { - "psr-4": { - "DASPRiD\\Enum\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "PHP 7.1 enum implementation", - "keywords": [ - "enum", - "map" - ], - "support": { - "issues": "https://github.com/DASPRiD/Enum/issues", - "source": "https://github.com/DASPRiD/Enum/tree/1.0.4" - }, - "time": "2023-03-01T18:44:03+00:00" - }, - { - "name": "endroid/qr-code", - "version": "4.6.1", - "source": { - "type": "git", - "url": "https://github.com/endroid/qr-code.git", - "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184", - "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184", - "shasum": "" - }, - "require": { - "bacon/bacon-qr-code": "^2.0.5", - "php": "^7.4||^8.0" - }, - "require-dev": { - "endroid/quality": "dev-master", - "ext-gd": "*", - "khanamiryan/qrcode-detector-decoder": "^1.0.4", - "setasign/fpdf": "^1.8.2" - }, - "suggest": { - "ext-gd": "Enables you to write PNG images", - "khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator", - "roave/security-advisories": "Makes sure package versions with known security issues are not installed", - "setasign/fpdf": "Enables you to use the PDF writer" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "autoload": { - "psr-4": { - "Endroid\\QrCode\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeroen van den Enden", - "email": "info@endroid.nl" - } - ], - "description": "Endroid QR Code", - "homepage": "https://github.com/endroid/qr-code", - "keywords": [ - "code", - "endroid", - "php", - "qr", - "qrcode" - ], - "support": { - "issues": "https://github.com/endroid/qr-code/issues", - "source": "https://github.com/endroid/qr-code/tree/4.6.1" - }, - "funding": [ - { - "url": "https://github.com/endroid", - "type": "github" - } - ], - "time": "2022-10-26T08:48:17+00:00" - }, { "name": "guzzlehttp/guzzle", - "version": "7.0.0", + "version": "7.7.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "414c24961042f6616fb43e23fa69a785f9fc053e" + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/414c24961042f6616fb43e23fa69a785f9fc053e", - "reference": "414c24961042f6616fb43e23fa69a785f9fc053e", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": "^7.2.5", - "psr/http-client": "^1.0" + "guzzlehttp/promises": "^1.5.3 || ^2.0", + "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.0", + "bamarni/composer-bin-plugin": "^1.8.1", "ext-curl": "*", - "php-http/client-integration-tests": "dev-phpunit8", - "phpunit/phpunit": "^8.5.5", - "psr/log": "^1.1" + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -415,8 +46,9 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "7.0-dev" + "bamarni-bin": { + "bin-links": true, + "forward-command": false } }, "autoload": { @@ -432,19 +64,43 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", "keywords": [ "client", "curl", @@ -458,35 +114,53 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/master" + "source": "https://github.com/guzzle/guzzle/tree/7.7.0" }, - "time": "2020-06-27T08:47:54+00:00" + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "time": "2023-05-21T14:04:53+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.5.3", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", + "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -523,7 +197,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.3" + "source": "https://github.com/guzzle/promises/tree/2.0.0" }, "funding": [ { @@ -539,42 +213,48 @@ "type": "tidelift" } ], - "time": "2023-05-21T12:31:43+00:00" + "time": "2023-05-21T13:50:22+00:00" }, { "name": "guzzlehttp/psr7", - "version": "1.9.1", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b" + "reference": "b635f279edd83fc275f822a1188157ffea568ff6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", + "reference": "b635f279edd83fc275f822a1188157ffea568ff6", "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" + "bamarni/composer-bin-plugin": "^1.8.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Psr7\\": "src/" } @@ -613,6 +293,11 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "PSR-7 message implementation that also provides common utility methods", @@ -628,7 +313,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.9.1" + "source": "https://github.com/guzzle/psr7/tree/2.5.0" }, "funding": [ { @@ -644,657 +329,7 @@ "type": "tidelift" } ], - "time": "2023-04-17T16:00:37+00:00" - }, - { - "name": "jaeger/g-http", - "version": "V1.7.2", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/GHttp.git", - "reference": "82585ddd5e2c6651e37ab1d8166efcdbb6b293d4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/GHttp/zipball/82585ddd5e2c6651e37ab1d8166efcdbb6b293d4", - "reference": "82585ddd5e2c6651e37ab1d8166efcdbb6b293d4", - "shasum": "" - }, - "require": { - "cache/filesystem-adapter": "^1", - "guzzlehttp/guzzle": "^6.0 | ^7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Jaeger\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "description": "Simple Http client base on GuzzleHttp", - "support": { - "issues": "https://github.com/jae-jae/GHttp/issues", - "source": "https://github.com/jae-jae/GHttp/tree/V1.7.2" - }, - "time": "2021-08-08T04:59:44+00:00" - }, - { - "name": "jaeger/phpquery-single", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/phpQuery-single.git", - "reference": "39a650ade692a6b480c22220dce0c198d6a946fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/phpQuery-single/zipball/39a650ade692a6b480c22220dce0c198d6a946fb", - "reference": "39a650ade692a6b480c22220dce0c198d6a946fb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "phpQuery.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobiasz Cudnik", - "email": "tobiasz.cudnik@gmail.com", - "homepage": "https://github.com/TobiaszCudnik", - "role": "Developer" - }, - { - "name": "Jaeger", - "role": "Packager" - } - ], - "description": "phpQuery单文件版本,是Querylist的依赖(http://querylist.cc/),phpQuery项目主页:http://code.google.com/p/phpquery/", - "homepage": "http://code.google.com/p/phpquery/", - "support": { - "issues": "https://github.com/jae-jae/phpQuery-single/issues", - "source": "https://github.com/jae-jae/phpQuery-single/tree/1.1.1" - }, - "time": "2022-03-26T15:01:16+00:00" - }, - { - "name": "jaeger/querylist", - "version": "V4.2.8", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/QueryList.git", - "reference": "39dc0ca9c668bec7a793e20472ccd7d26ef89ea4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/QueryList/zipball/39dc0ca9c668bec7a793e20472ccd7d26ef89ea4", - "reference": "39dc0ca9c668bec7a793e20472ccd7d26ef89ea4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "jaeger/g-http": "^1.1", - "jaeger/phpquery-single": "^1", - "php": ">=7.1", - "tightenco/collect": ">5.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.5", - "symfony/var-dumper": "^3.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "QL\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "description": "Simple, elegant, extensible PHP Web Scraper (crawler/spider),Use the css3 dom selector,Based on phpQuery! 简洁、优雅、可扩展的PHP采集工具(爬虫),基于phpQuery。", - "homepage": "http://querylist.cc", - "keywords": [ - "QueryList", - "phpQuery", - "spider" - ], - "support": { - "issues": "https://github.com/jae-jae/QueryList/issues", - "source": "https://github.com/jae-jae/QueryList/tree/V4.2.8" - }, - "funding": [ - { - "url": "https://opencollective.com/querylist", - "type": "open_collective" - } - ], - "time": "2021-07-05T06:07:58+00:00" - }, - { - "name": "laravel/serializable-closure", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/laravel/serializable-closure.git", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "nesbot/carbon": "^2.61", - "pestphp/pest": "^1.21.3", - "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Laravel\\SerializableClosure\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Nuno Maduro", - "email": "nuno@laravel.com" - } - ], - "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", - "keywords": [ - "closure", - "laravel", - "serializable" - ], - "support": { - "issues": "https://github.com/laravel/serializable-closure/issues", - "source": "https://github.com/laravel/serializable-closure" - }, - "time": "2023-01-30T18:31:20+00:00" - }, - { - "name": "league/flysystem", - "version": "1.1.10", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/flysystem.git", - "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1", - "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "league/mime-type-detection": "^1.3", - "php": "^7.2.5 || ^8.0" - }, - "conflict": { - "league/flysystem-sftp": "<1.0.6" - }, - "require-dev": { - "phpspec/prophecy": "^1.11.1", - "phpunit/phpunit": "^8.5.8" - }, - "suggest": { - "ext-ftp": "Allows you to use FTP server storage", - "ext-openssl": "Allows you to use FTPS server storage", - "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", - "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", - "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", - "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", - "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", - "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", - "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", - "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", - "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", - "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Flysystem\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "description": "Filesystem abstraction: Many filesystems, one API.", - "keywords": [ - "Cloud Files", - "WebDAV", - "abstraction", - "aws", - "cloud", - "copy.com", - "dropbox", - "file systems", - "files", - "filesystem", - "filesystems", - "ftp", - "rackspace", - "remote", - "s3", - "sftp", - "storage" - ], - "support": { - "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/1.1.10" - }, - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], - "time": "2022-10-04T09:16:37+00:00" - }, - { - "name": "league/mime-type-detection", - "version": "1.11.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ff6248ea87a9f116e78edd6002e39e5128a0d4dd", - "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.2", - "phpstan/phpstan": "^0.12.68", - "phpunit/phpunit": "^8.5.8 || ^9.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "League\\MimeTypeDetection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frankdejonge.nl" - } - ], - "description": "Mime-type detection for Flysystem", - "support": { - "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.11.0" - }, - "funding": [ - { - "url": "https://github.com/frankdejonge", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/league/flysystem", - "type": "tidelift" - } - ], - "time": "2022-04-17T13:12:02+00:00" - }, - { - "name": "liliuwei/thinkphp-social", - "version": "v1.3", - "source": { - "type": "git", - "url": "https://github.com/liliuwei/thinkphp-social.git", - "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/liliuwei/thinkphp-social/zipball/2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", - "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", - "shasum": "" - }, - "require": { - "php": ">=5.6.0", - "topthink/framework": "^5.1 || ^6.0", - "topthink/think-installer": "^2.0" - }, - "type": "think-extend", - "extra": { - "think-config": { - "social": "src/config/config.php" - }, - "think": { - "config": { - "social": "src/config/config.php" - } - } - }, - "autoload": { - "psr-4": { - "liliuwei\\social\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "liliuwei", - "email": "974829947@qq.com" - } - ], - "description": "适用于thinkphp5.1和6.0的社会化登录扩展", - "keywords": [ - "Facebook登录", - "Gitee登录", - "Github登录", - "Google登录", - "Oschina登录", - "QQ登录", - "oauth", - "think-social", - "thinkphp", - "thinkphp-social", - "thinkphp5.1", - "thinkphp6.0", - "小米登录", - "微信登录", - "抖音登录", - "新浪登录", - "淘宝登录", - "百度登录", - "第三方授权登录", - "谷歌登录", - "钉钉登录" - ], - "support": { - "issues": "https://github.com/liliuwei/thinkphp-social/issues", - "source": "https://github.com/liliuwei/thinkphp-social/tree/v1.3" - }, - "time": "2021-01-13T05:11:12+00:00" - }, - { - "name": "lotofbadcode/phpspirit_databackup", - "version": "v1.2", - "source": { - "type": "git", - "url": "https://github.com/lotofbadcode/phpspirit_databackup.git", - "reference": "77c2421f8461392c044cf8c29918f495c22a5612" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lotofbadcode/phpspirit_databackup/zipball/77c2421f8461392c044cf8c29918f495c22a5612", - "reference": "77c2421f8461392c044cf8c29918f495c22a5612", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "phpspirit\\databackup\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "代码庸医", - "email": "3359964266@qq.com" - } - ], - "description": "一个PHP数据库备份恢复的插件", - "keywords": [ - "library", - "php" - ], - "support": { - "issues": "https://github.com/lotofbadcode/phpspirit_databackup/issues", - "source": "https://github.com/lotofbadcode/phpspirit_databackup/tree/v1.2" - }, - "time": "2023-05-12T12:02:05+00:00" - }, - { - "name": "php-di/invoker", - "version": "2.3.3", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/Invoker.git", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "psr/container": "^1.0|^2.0" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Invoker\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Generic and extensible callable invoker", - "homepage": "https://github.com/PHP-DI/Invoker", - "keywords": [ - "callable", - "dependency", - "dependency-injection", - "injection", - "invoke", - "invoker" - ], - "support": { - "issues": "https://github.com/PHP-DI/Invoker/issues", - "source": "https://github.com/PHP-DI/Invoker/tree/2.3.3" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - } - ], - "time": "2021-12-13T09:22:56+00:00" - }, - { - "name": "php-di/php-di", - "version": "6.4.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PHP-DI.git", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/ae0f1b3b03d8b29dff81747063cbfd6276246cc4", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4", - "shasum": "" - }, - "require": { - "laravel/serializable-closure": "^1.0", - "php": ">=7.4.0", - "php-di/invoker": "^2.0", - "php-di/phpdoc-reader": "^2.0.1", - "psr/container": "^1.0" - }, - "provide": { - "psr/container-implementation": "^1.0" - }, - "require-dev": { - "doctrine/annotations": "~1.10", - "friendsofphp/php-cs-fixer": "^2.4", - "mnapoli/phpunit-easymock": "^1.2", - "ocramius/proxy-manager": "^2.11.2", - "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^9.5" - }, - "suggest": { - "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", - "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "DI\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "The dependency injection container for humans", - "homepage": "https://php-di.org/", - "keywords": [ - "PSR-11", - "container", - "container-interop", - "dependency injection", - "di", - "ioc", - "psr11" - ], - "support": { - "issues": "https://github.com/PHP-DI/PHP-DI/issues", - "source": "https://github.com/PHP-DI/PHP-DI/tree/6.4.0" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/php-di/php-di", - "type": "tidelift" - } - ], - "time": "2022-04-09T16:46:38+00:00" - }, - { - "name": "php-di/phpdoc-reader", - "version": "2.2.1", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PhpDocReader.git", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "require-dev": { - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^8.5|^9.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "PhpDocReader\\": "src/PhpDocReader" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", - "keywords": [ - "phpdoc", - "reflection" - ], - "support": { - "issues": "https://github.com/PHP-DI/PhpDocReader/issues", - "source": "https://github.com/PHP-DI/PhpDocReader/tree/2.2.1" - }, - "time": "2020-10-12T12:39:22+00:00" + "time": "2023-04-17T16:11:26+00:00" }, { "name": "phpmailer/phpmailer", @@ -1376,73 +411,29 @@ ], "time": "2023-03-06T14:43:22+00:00" }, - { - "name": "psr/cache", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/master" - }, - "time": "2016-08-06T20:24:11+00:00" - }, { "name": "psr/container", - "version": "1.1.2", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", "shasum": "" }, "require": { "php": ">=7.4.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -1469,59 +460,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, - "time": "2021-11-05T16:50:12+00:00" - }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "support": { - "issues": "https://github.com/php-fig/event-dispatcher/issues", - "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" - }, - "time": "2019-01-08T18:20:26+00:00" + "time": "2021-11-05T16:47:00+00:00" }, { "name": "psr/http-client", @@ -1575,6 +516,61 @@ }, "time": "2023-04-10T20:12:12+00:00" }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://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/1.0.2" + }, + "time": "2023-04-10T20:10:41+00:00" + }, { "name": "psr/http-message", "version": "1.1", @@ -1630,30 +626,30 @@ }, { "name": "psr/log", - "version": "1.1.4", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1674,31 +670,31 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, - "time": "2021-05-03T11:20:27+00:00" + "time": "2021-07-14T16:46:02+00:00" }, { "name": "psr/simple-cache", - "version": "1.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -1713,7 +709,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interfaces for simple caching", @@ -1725,9 +721,9 @@ "simple-cache" ], "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": "ralouphie/getallheaders", @@ -1774,295 +770,35 @@ "time": "2019-03-08T08:55:37+00:00" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "name": "symfony/deprecation-contracts", + "version": "v3.3.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" + "php": ">=8.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "3.4-dev" }, "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "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.27.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" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php72", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - } - }, - "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 backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.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" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.27.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.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" - } - ], - "time": "2022-11-03T14:55:06+00:00" - }, - { - "name": "symfony/var-dumper", - "version": "v4.4.47", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "1069c7a3fca74578022fab6f81643248d02f8e63" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1069c7a3fca74578022fab6f81643248d02f8e63", - "reference": "1069c7a3fca74578022fab6f81643248d02f8e63", - "shasum": "" - }, - "require": { - "php": ">=7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php72": "~1.5", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/console": "<3.4" - }, - "require-dev": { - "ext-iconv": "*", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/process": "^4.4|^5.0", - "twig/twig": "^1.43|^2.13|^3.0.4" - }, - "suggest": { - "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", - "ext-intl": "To show region name in time zone dump", - "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" - }, - "bin": [ - "Resources/bin/var-dump-server" - ], - "type": "library", - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-4": { - "Symfony\\Component\\VarDumper\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "function.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2079,14 +815,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Provides mechanisms for walking through any arbitrary PHP variable", + "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", - "keywords": [ - "debug", - "dump" - ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v4.4.47" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -2102,28 +834,27 @@ "type": "tidelift" } ], - "time": "2022-10-03T15:15:11+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/var-exporter", - "version": "v5.4.21", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/3400949782c0cb5b3e73aa64cfd71dde000beccc", + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" }, "require-dev": { - "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + "symfony/var-dumper": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -2156,10 +887,12 @@ "export", "hydrate", "instantiate", + "lazy-loading", + "proxy", "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + "source": "https://github.com/symfony/var-exporter/tree/v6.3.2" }, "funding": [ { @@ -2175,28 +908,28 @@ "type": "tidelift" } ], - "time": "2023-02-21T19:46:44+00:00" + "time": "2023-07-26T17:39:03+00:00" }, { "name": "taoser/think-addons", - "version": "v1.0.9", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/taoser/think-addons.git", - "reference": "00112adf200b897deecbd1bbabc33ad22377b008" + "reference": "ef97225aca7f0ec1da275c4ae025686899a91ad2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-addons/zipball/00112adf200b897deecbd1bbabc33ad22377b008", - "reference": "00112adf200b897deecbd1bbabc33ad22377b008", + "url": "https://api.github.com/repos/taoser/think-addons/zipball/ef97225aca7f0ec1da275c4ae025686899a91ad2", + "reference": "ef97225aca7f0ec1da275c4ae025686899a91ad2", "shasum": "" }, "require": { - "php": ">=7.1.0", - "symfony/var-exporter": "^5.4", - "topthink/framework": "^6.0", + "php": ">=8.0.0", + "symfony/var-exporter": "^6.0", + "topthink/framework": "^8.0", "topthink/think-helper": "^3.0.0", - "topthink/think-view": "^1.0" + "topthink/think-view": "^2.0" }, "type": "library", "extra": { @@ -2227,30 +960,30 @@ "email": "changlin_zhao@qq.com" } ], - "description": "The ThinkPHP6 Addons Package", + "description": "The ThinkPHP8 Addons Package", "support": { "issues": "https://github.com/taoser/think-addons/issues", - "source": "https://github.com/taoser/think-addons/tree/v1.0.9" + "source": "https://github.com/taoser/think-addons/tree/v2.0.0" }, - "time": "2023-06-10T05:08:45+00:00" + "time": "2023-08-02T06:40:11+00:00" }, { "name": "taoser/think-auth", - "version": "v1.0.1", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/taoser/think-auth.git", - "reference": "d3aa853b7d2a34624bcc566150105f2815e68ad0" + "reference": "db57156530dd8e2c020afc6e64abc1ad64e9e06c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-auth/zipball/d3aa853b7d2a34624bcc566150105f2815e68ad0", - "reference": "d3aa853b7d2a34624bcc566150105f2815e68ad0", + "url": "https://api.github.com/repos/taoser/think-auth/zipball/db57156530dd8e2c020afc6e64abc1ad64e9e06c", + "reference": "db57156530dd8e2c020afc6e64abc1ad64e9e06c", "shasum": "" }, "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" + "php": ">=8.0.0", + "topthink/framework": "^8.0" }, "type": "think-extend", "extra": { @@ -2279,26 +1012,26 @@ "homepage": "https://github.com/taoser/think-auth", "keywords": [ "think-auth", - "thinkphp6" + "thinkphp8" ], "support": { "issues": "https://github.com/taoser/think-auth/issues", - "source": "https://github.com/taoser/think-auth/tree/v1.0.1" + "source": "https://github.com/taoser/think-auth/tree/v2.0.0" }, - "time": "2023-02-26T03:08:39+00:00" + "time": "2023-08-02T06:28:49+00:00" }, { "name": "taoser/think-setarr", - "version": "v0.0.3", + "version": "v0.0.5", "source": { "type": "git", "url": "https://github.com/taoser/think-setarr.git", - "reference": "6651c31ef42417a6294ef08e6fb970917b7e7f86" + "reference": "e436e2d855c2014dae19cbdecfd3d6c57c04aca8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-setarr/zipball/6651c31ef42417a6294ef08e6fb970917b7e7f86", - "reference": "6651c31ef42417a6294ef08e6fb970917b7e7f86", + "url": "https://api.github.com/repos/taoser/think-setarr/zipball/e436e2d855c2014dae19cbdecfd3d6c57c04aca8", + "reference": "e436e2d855c2014dae19cbdecfd3d6c57c04aca8", "shasum": "" }, "require": { @@ -2323,94 +1056,40 @@ "description": "php confing", "support": { "issues": "https://github.com/taoser/think-setarr/issues", - "source": "https://github.com/taoser/think-setarr/tree/v0.0.3" + "source": "https://github.com/taoser/think-setarr/tree/v0.0.5" }, - "time": "2022-04-16T23:08:43+00:00" - }, - { - "name": "tightenco/collect", - "version": "v8.83.27", - "source": { - "type": "git", - "url": "https://github.com/tighten/collect.git", - "reference": "07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tighten/collect/zipball/07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6", - "reference": "07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0", - "symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "nesbot/carbon": "^2.23.0", - "phpunit/phpunit": "^8.3" - }, - "type": "library", - "autoload": { - "files": [ - "src/Collect/Support/helpers.php", - "src/Collect/Support/alias.php" - ], - "psr-4": { - "Tightenco\\Collect\\": "src/Collect" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - } - ], - "description": "Collect - Illuminate Collections as a separate package.", - "keywords": [ - "collection", - "laravel" - ], - "support": { - "issues": "https://github.com/tighten/collect/issues", - "source": "https://github.com/tighten/collect/tree/v8.83.27" - }, - "time": "2023-01-13T18:05:42+00:00" + "time": "2022-05-09T04:22:56+00:00" }, { "name": "topthink/framework", - "version": "v6.1.3", + "version": "v8.0.1", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041" + "reference": "23101f0ad7581de32442553e045cffd7686a337b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041", + "url": "https://api.github.com/repos/top-think/framework/zipball/23101f0ad7581de32442553e045cffd7686a337b", + "reference": "23101f0ad7581de32442553e045cffd7686a337b", "shasum": "" }, "require": { "ext-json": "*", "ext-mbstring": "*", - "php": ">=7.2.5", - "psr/container": "~1.0", + "php": ">=8.0.0", + "psr/container": "^2.0", "psr/http-message": "^1.0", - "psr/log": "~1.0", - "psr/simple-cache": "^1.0", - "topthink/think-helper": "^3.1.1", - "topthink/think-orm": "^2.0|^3.0" + "psr/log": "^3.0", + "psr/simple-cache": "^3.0", + "topthink/think-helper": "^3.1", + "topthink/think-orm": "^3.0" }, "require-dev": { "guzzlehttp/psr7": "^2.1.0", "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.2", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.5" }, "type": "library", "autoload": { @@ -2442,9 +1121,9 @@ ], "support": { "issues": "https://github.com/top-think/framework/issues", - "source": "https://github.com/top-think/framework/tree/v6.1.3" + "source": "https://github.com/top-think/framework/tree/v8.0.1" }, - "time": "2023-05-22T03:02:08+00:00" + "time": "2023-07-09T09:12:43+00:00" }, { "name": "topthink/think-captcha", @@ -2545,105 +1224,6 @@ }, "time": "2021-12-15T04:27:55+00:00" }, - { - "name": "topthink/think-installer", - "version": "v2.0.5", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-installer.git", - "reference": "38ba647706e35d6704b5d370c06f8a160b635f88" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-installer/zipball/38ba647706e35d6704b5d370c06f8a160b635f88", - "reference": "38ba647706e35d6704b5d370c06f8a160b635f88", - "shasum": "" - }, - "require": { - "composer-plugin-api": "^1.0||^2.0" - }, - "require-dev": { - "composer/composer": "^1.0||^2.0" - }, - "type": "composer-plugin", - "extra": { - "class": "think\\composer\\Plugin" - }, - "autoload": { - "psr-4": { - "think\\composer\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "support": { - "issues": "https://github.com/top-think/think-installer/issues", - "source": "https://github.com/top-think/think-installer/tree/v2.0.5" - }, - "time": "2021-01-14T12:12:14+00:00" - }, - { - "name": "topthink/think-migration", - "version": "v3.0.5", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-migration.git", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "shasum": "" - }, - "require": { - "topthink/framework": "^6.0", - "topthink/think-helper": "^3.0.3" - }, - "require-dev": { - "fzaninotto/faker": "^1.8" - }, - "suggest": { - "fzaninotto/faker": "Required to use the factory builder (^1.8)." - }, - "type": "library", - "extra": { - "think": { - "services": [ - "think\\migration\\Service" - ] - } - }, - "autoload": { - "psr-4": { - "Phinx\\": "phinx/src/Phinx", - "think\\migration\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "support": { - "issues": "https://github.com/top-think/think-migration/issues", - "source": "https://github.com/top-think/think-migration/tree/v3.0.5" - }, - "time": "2023-02-26T13:16:22+00:00" - }, { "name": "topthink/think-multi-app", "version": "v1.0.17", @@ -2694,28 +1274,28 @@ }, { "name": "topthink/think-orm", - "version": "v2.0.61", + "version": "v3.0.11", "source": { "type": "git", "url": "https://github.com/top-think/think-orm.git", - "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6" + "reference": "38a6da3ae03bcae4ea2f484a4cf05687a88a5488" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-orm/zipball/10528ebf4a5106b19c3bac9c6deae7a67ff49de6", - "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6", + "url": "https://api.github.com/repos/top-think/think-orm/zipball/38a6da3ae03bcae4ea2f484a4cf05687a88a5488", + "reference": "38a6da3ae03bcae4ea2f484a4cf05687a88a5488", "shasum": "" }, "require": { "ext-json": "*", "ext-pdo": "*", - "php": ">=7.1.0", - "psr/log": "^1.0|^2.0", - "psr/simple-cache": "^1.0|^2.0", + "php": ">=8.0.0", + "psr/log": ">=1.0", + "psr/simple-cache": ">=1.0", "topthink/think-helper": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^7|^8|^9.5" + "phpunit/phpunit": "^8|^9.5|^10" }, "type": "library", "autoload": { @@ -2736,34 +1316,34 @@ "email": "liu21st@gmail.com" } ], - "description": "think orm", + "description": "the PHP Database&ORM Framework", "keywords": [ "database", "orm" ], "support": { "issues": "https://github.com/top-think/think-orm/issues", - "source": "https://github.com/top-think/think-orm/tree/v2.0.61" + "source": "https://github.com/top-think/think-orm/tree/v3.0.11" }, - "time": "2023-04-20T14:27:51+00:00" + "time": "2023-07-18T11:04:31+00:00" }, { "name": "topthink/think-template", - "version": "v2.0.9", + "version": "v3.0.0", "source": { "type": "git", "url": "https://github.com/top-think/think-template.git", - "reference": "6d25642ae0e306166742fd7073dc7a159e18073c" + "reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-template/zipball/6d25642ae0e306166742fd7073dc7a159e18073c", - "reference": "6d25642ae0e306166742fd7073dc7a159e18073c", + "url": "https://api.github.com/repos/top-think/think-template/zipball/4352d2cf627abfb8b49f830686c25c02f59c23f2", + "reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2", "shasum": "" }, "require": { - "php": ">=7.1.0", - "psr/simple-cache": "^1.0" + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" }, "type": "library", "autoload": { @@ -2784,27 +1364,27 @@ "description": "the php template engine", "support": { "issues": "https://github.com/top-think/think-template/issues", - "source": "https://github.com/top-think/think-template/tree/v2.0.9" + "source": "https://github.com/top-think/think-template/tree/v3.0.0" }, - "time": "2023-02-14T10:50:39+00:00" + "time": "2023-02-25T12:11:14+00:00" }, { "name": "topthink/think-view", - "version": "v1.0.14", + "version": "v2.0.0", "source": { "type": "git", "url": "https://github.com/top-think/think-view.git", - "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d" + "reference": "d2a076011c96d2edd8016703a827fb54b2683c62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-view/zipball/edce0ae2c9551ab65f9e94a222604b0dead3576d", - "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d", + "url": "https://api.github.com/repos/top-think/think-view/zipball/d2a076011c96d2edd8016703a827fb54b2683c62", + "reference": "d2a076011c96d2edd8016703a827fb54b2683c62", "shasum": "" }, "require": { - "php": ">=7.1.0", - "topthink/think-template": "^2.0" + "php": ">=8.0.0", + "topthink/think-template": "^3.0" }, "type": "library", "autoload": { @@ -2825,337 +1405,9 @@ "description": "thinkphp template driver", "support": { "issues": "https://github.com/top-think/think-view/issues", - "source": "https://github.com/top-think/think-view/tree/v1.0.14" + "source": "https://github.com/top-think/think-view/tree/v2.0.0" }, - "time": "2019-11-06T11:40:13+00:00" - }, - { - "name": "wamkj/thinkphp6.0-databackup", - "version": "v1.0", - "source": { - "type": "git", - "url": "https://github.com/wamkj/thinkphp6.0-databackup.git", - "reference": "28a0e406d827132942723a3c9f69bb20c98e652f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wamkj/thinkphp6.0-databackup/zipball/28a0e406d827132942723a3c9f69bb20c98e652f", - "reference": "28a0e406d827132942723a3c9f69bb20c98e652f", - "shasum": "" - }, - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "wamkj\\thinkphp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "wamkj", - "email": "1149183529@qq.com" - } - ], - "description": "thinkphp6.0的数据库自动备份扩展", - "keywords": [ - "think-databackup", - "thinkphp" - ], - "support": { - "issues": "https://github.com/wamkj/thinkphp6.0-databackup/issues", - "source": "https://github.com/wamkj/thinkphp6.0-databackup/tree/v1.0" - }, - "time": "2020-02-15T13:04:16+00:00" - }, - { - "name": "workerman/channel", - "version": "v1.2.0", - "source": { - "type": "git", - "url": "https://github.com/walkor/channel.git", - "reference": "fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/channel/zipball/fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e", - "reference": "fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e", - "shasum": "" - }, - "require": { - "workerman/workerman": ">=4.0.12" - }, - "type": "library", - "autoload": { - "psr-4": { - "Channel\\": "./src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "homepage": "http://www.workerman.net", - "support": { - "issues": "https://github.com/walkor/channel/issues", - "source": "https://github.com/walkor/channel/tree/v1.2.0" - }, - "time": "2023-04-04T02:47:35+00:00" - }, - { - "name": "workerman/phpsocket.io", - "version": "v1.1.18", - "source": { - "type": "git", - "url": "https://github.com/walkor/phpsocket.io.git", - "reference": "b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b", - "reference": "b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b", - "shasum": "" - }, - "require": { - "workerman/channel": ">=1.0.0", - "workerman/workerman": "^4.0.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPSocketIO\\": "./src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "homepage": "http://www.workerman.net", - "keywords": [ - "Socket.io" - ], - "support": { - "issues": "https://github.com/walkor/phpsocket.io/issues", - "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.18" - }, - "funding": [ - { - "url": "https://opencollective.com/walkor", - "type": "open_collective" - }, - { - "url": "https://www.patreon.com/walkor", - "type": "patreon" - } - ], - "time": "2023-06-16T01:41:34+00:00" - }, - { - "name": "workerman/workerman", - "version": "v4.1.10", - "source": { - "type": "git", - "url": "https://github.com/walkor/workerman.git", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83", - "shasum": "" - }, - "require": { - "php": ">=7.0" - }, - "suggest": { - "ext-event": "For better performance. " - }, - "type": "library", - "autoload": { - "psr-4": { - "Workerman\\": "./" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "walkor", - "email": "walkor@workerman.net", - "homepage": "http://www.workerman.net", - "role": "Developer" - } - ], - "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.", - "homepage": "http://www.workerman.net", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "email": "walkor@workerman.net", - "forum": "http://wenda.workerman.net/", - "issues": "https://github.com/walkor/workerman/issues", - "source": "https://github.com/walkor/workerman", - "wiki": "http://doc.workerman.net/" - }, - "funding": [ - { - "url": "https://opencollective.com/workerman", - "type": "open_collective" - }, - { - "url": "https://www.patreon.com/walkor", - "type": "patreon" - } - ], - "time": "2023-05-01T02:12:20+00:00" - }, - { - "name": "yansongda/pay", - "version": "v3.1.12", - "source": { - "type": "git", - "url": "https://github.com/yansongda/pay.git", - "reference": "7ff004f05f9d6e288ff9b4deef585d30395f37f2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/yansongda/pay/zipball/7ff004f05f9d6e288ff9b4deef585d30395f37f2", - "reference": "7ff004f05f9d6e288ff9b4deef585d30395f37f2", - "shasum": "" - }, - "require": { - "ext-bcmath": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-openssl": "*", - "ext-simplexml": "*", - "php": ">=7.4", - "psr/container": "^1.1 | ^2.0", - "psr/event-dispatcher": "^1.0", - "psr/http-client": "^1.0", - "psr/http-message": "^1.0", - "psr/log": "^1.1 | ^2.0 | ^3.0", - "yansongda/supports": "~3.2.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "guzzlehttp/guzzle": "^7.0", - "mockery/mockery": "^1.4", - "monolog/monolog": "^2.2", - "phpstan/phpstan": "^1.0.0", - "phpunit/phpunit": "^9.0", - "symfony/event-dispatcher": "^5.2.0", - "symfony/http-foundation": "^5.2.0", - "symfony/psr-http-message-bridge": "^2.1", - "symfony/var-dumper": "^5.1" - }, - "suggest": { - "hyperf/utils": "Hyperf 框架下使用 SDK,请安装", - "illuminate/container": "Laravel 框架下使用 SDK,请安装", - "php-di/php-di": "其它/无框架下使用 SDK,请安装" - }, - "type": "library", - "autoload": { - "files": [ - "src/Functions.php" - ], - "psr-4": { - "Yansongda\\Pay\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "yansongda", - "email": "me@yansongda.cn" - } - ], - "description": "可能是我用过的最优雅的 Alipay 和 WeChat 的支付 SDK 扩展包了", - "keywords": [ - "alipay", - "pay", - "wechat" - ], - "support": { - "homepage": "https://pay.yansongda.cn", - "issues": "https://github.com/yansongda/pay/issues", - "source": "https://github.com/yansongda/pay" - }, - "time": "2022-09-03T05:39:21+00:00" - }, - { - "name": "yansongda/supports", - "version": "v3.2.5", - "source": { - "type": "git", - "url": "https://github.com/yansongda/supports.git", - "reference": "c3f736efe169696cef94730976e604a61c345b5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/yansongda/supports/zipball/c3f736efe169696cef94730976e604a61c345b5c", - "reference": "c3f736efe169696cef94730976e604a61c345b5c", - "shasum": "" - }, - "require": { - "php": ">=7.4" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "mockery/mockery": "^1.4", - "monolog/monolog": "^2.0", - "phpstan/phpstan": "^1.1.0", - "phpunit/phpunit": "^9.0", - "symfony/console": "^5.1" - }, - "suggest": { - "monolog/monolog": "Use logger", - "symfony/console": "Use stdout logger" - }, - "type": "library", - "autoload": { - "files": [ - "src/Functions.php" - ], - "psr-4": { - "Yansongda\\Supports\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "yansongda", - "email": "me@yansongda.cn" - } - ], - "description": "common components", - "keywords": [ - "array", - "collection", - "config", - "support" - ], - "support": { - "issues": "https://github.com/yansongda/supports/issues", - "source": "https://github.com/yansongda/supports" - }, - "time": "2022-03-28T10:25:04+00:00" + "time": "2023-02-25T12:18:09+00:00" }, { "name": "yzh52521/easyhttp", @@ -3210,66 +1462,14 @@ "time": "2023-02-16T03:04:02+00:00" } ], - "packages-dev": [ - { - "name": "topthink/think-trace", - "version": "v1.6", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-trace.git", - "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", - "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", - "shasum": "" - }, - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0|^8.0" - }, - "type": "library", - "extra": { - "think": { - "services": [ - "think\\trace\\Service" - ], - "config": { - "trace": "src/config.php" - } - } - }, - "autoload": { - "psr-4": { - "think\\trace\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - } - ], - "description": "thinkphp debug trace", - "support": { - "issues": "https://github.com/top-think/think-trace/issues", - "source": "https://github.com/top-think/think-trace/tree/v1.6" - }, - "time": "2023-02-07T08:36:32+00:00" - } - ], + "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.1.0" + "php": ">=8.0.0" }, "platform-dev": [], "plugin-api-version": "2.3.0" diff --git a/config/taoler.php b/config/taoler.php index 5a0ecd3..3ae4c2b 100644 --- a/config/taoler.php +++ b/config/taoler.php @@ -16,7 +16,7 @@ return [ // 应用名,此项不可更改 'appname' => 'TaoLer', // 版本配置 - 'version' => '2.3.9', + 'version' => '3.0.0', // 加盐 'salt' => 'taoler', // 数据库备份目录 diff --git a/vendor/autoload.php b/vendor/autoload.php index 6a8a999..232434e 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit1b32198725235c8d6500c87262ef30c2::getLoader(); +return ComposerAutoloaderInitbd5d3d6d2646baf3ad0aa6db972a53b0::getLoader(); diff --git a/vendor/bacon/bacon-qr-code/LICENSE b/vendor/bacon/bacon-qr-code/LICENSE deleted file mode 100644 index d45a356..0000000 --- a/vendor/bacon/bacon-qr-code/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2017, Ben Scholzen 'DASPRiD' -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. 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. - -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. diff --git a/vendor/bacon/bacon-qr-code/README.md b/vendor/bacon/bacon-qr-code/README.md deleted file mode 100644 index 9c099fe..0000000 --- a/vendor/bacon/bacon-qr-code/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# QR Code generator - -[![PHP CI](https://github.com/Bacon/BaconQrCode/actions/workflows/ci.yml/badge.svg)](https://github.com/Bacon/BaconQrCode/actions/workflows/ci.yml) -[![codecov](https://codecov.io/gh/Bacon/BaconQrCode/branch/master/graph/badge.svg?token=rD0HcAiEEx)](https://codecov.io/gh/Bacon/BaconQrCode) -[![Latest Stable Version](https://poser.pugx.org/bacon/bacon-qr-code/v/stable)](https://packagist.org/packages/bacon/bacon-qr-code) -[![Total Downloads](https://poser.pugx.org/bacon/bacon-qr-code/downloads)](https://packagist.org/packages/bacon/bacon-qr-code) -[![License](https://poser.pugx.org/bacon/bacon-qr-code/license)](https://packagist.org/packages/bacon/bacon-qr-code) - - -## Introduction -BaconQrCode is a port of QR code portion of the ZXing library. It currently -only features the encoder part, but could later receive the decoder part as -well. - -As the Reed Solomon codec implementation of the ZXing library performs quite -slow in PHP, it was exchanged with the implementation by Phil Karn. - - -## Example usage -```php -use BaconQrCode\Renderer\ImageRenderer; -use BaconQrCode\Renderer\Image\ImagickImageBackEnd; -use BaconQrCode\Renderer\RendererStyle\RendererStyle; -use BaconQrCode\Writer; - -$renderer = new ImageRenderer( - new RendererStyle(400), - new ImagickImageBackEnd() -); -$writer = new Writer($renderer); -$writer->writeFile('Hello World!', 'qrcode.png'); -``` - -## Available image renderer back ends -BaconQrCode comes with multiple back ends for rendering images. Currently included are the following: - -- `ImagickImageBackEnd`: renders raster images using the Imagick library -- `SvgImageBackEnd`: renders SVG files using XMLWriter -- `EpsImageBackEnd`: renders EPS files diff --git a/vendor/bacon/bacon-qr-code/composer.json b/vendor/bacon/bacon-qr-code/composer.json deleted file mode 100644 index 7f193da..0000000 --- a/vendor/bacon/bacon-qr-code/composer.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "bacon/bacon-qr-code", - "description": "BaconQrCode is a QR code generator for PHP.", - "license" : "BSD-2-Clause", - "homepage": "https://github.com/Bacon/BaconQrCode", - "require": { - "php": "^7.1 || ^8.0", - "ext-iconv": "*", - "dasprid/enum": "^1.0.3" - }, - "suggest": { - "ext-imagick": "to generate QR code images" - }, - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "autoload": { - "psr-4": { - "BaconQrCode\\": "src/" - } - }, - "require-dev": { - "phpunit/phpunit": "^7 | ^8 | ^9", - "spatie/phpunit-snapshot-assertions": "^4.2.9", - "squizlabs/php_codesniffer": "^3.4", - "phly/keep-a-changelog": "^2.1" - }, - "config": { - "allow-plugins": { - "ocramius/package-versions": true - } - }, - "archive": { - "exclude": [ - "/test", - "/phpunit.xml.dist" - ] - } -} diff --git a/vendor/bacon/bacon-qr-code/phpunit.xml.dist b/vendor/bacon/bacon-qr-code/phpunit.xml.dist deleted file mode 100644 index d9e4d57..0000000 --- a/vendor/bacon/bacon-qr-code/phpunit.xml.dist +++ /dev/null @@ -1,13 +0,0 @@ - - - - - src - - - - - ./test - - - diff --git a/vendor/bacon/bacon-qr-code/src/Common/BitArray.php b/vendor/bacon/bacon-qr-code/src/Common/BitArray.php deleted file mode 100644 index 158384f..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/BitArray.php +++ /dev/null @@ -1,372 +0,0 @@ - - */ - private $bits; - - /** - * Size of the bit array in bits. - * - * @var int - */ - private $size; - - /** - * Creates a new bit array with a given size. - */ - public function __construct(int $size = 0) - { - $this->size = $size; - $this->bits = SplFixedArray::fromArray(array_fill(0, ($this->size + 31) >> 3, 0)); - } - - /** - * Gets the size in bits. - */ - public function getSize() : int - { - return $this->size; - } - - /** - * Gets the size in bytes. - */ - public function getSizeInBytes() : int - { - return ($this->size + 7) >> 3; - } - - /** - * Ensures that the array has a minimum capacity. - */ - public function ensureCapacity(int $size) : void - { - if ($size > count($this->bits) << 5) { - $this->bits->setSize(($size + 31) >> 5); - } - } - - /** - * Gets a specific bit. - */ - public function get(int $i) : bool - { - return 0 !== ($this->bits[$i >> 5] & (1 << ($i & 0x1f))); - } - - /** - * Sets a specific bit. - */ - public function set(int $i) : void - { - $this->bits[$i >> 5] = $this->bits[$i >> 5] | 1 << ($i & 0x1f); - } - - /** - * Flips a specific bit. - */ - public function flip(int $i) : void - { - $this->bits[$i >> 5] ^= 1 << ($i & 0x1f); - } - - /** - * Gets the next set bit position from a given position. - */ - public function getNextSet(int $from) : int - { - if ($from >= $this->size) { - return $this->size; - } - - $bitsOffset = $from >> 5; - $currentBits = $this->bits[$bitsOffset]; - $bitsLength = count($this->bits); - $currentBits &= ~((1 << ($from & 0x1f)) - 1); - - while (0 === $currentBits) { - if (++$bitsOffset === $bitsLength) { - return $this->size; - } - - $currentBits = $this->bits[$bitsOffset]; - } - - $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits); - return $result > $this->size ? $this->size : $result; - } - - /** - * Gets the next unset bit position from a given position. - */ - public function getNextUnset(int $from) : int - { - if ($from >= $this->size) { - return $this->size; - } - - $bitsOffset = $from >> 5; - $currentBits = ~$this->bits[$bitsOffset]; - $bitsLength = count($this->bits); - $currentBits &= ~((1 << ($from & 0x1f)) - 1); - - while (0 === $currentBits) { - if (++$bitsOffset === $bitsLength) { - return $this->size; - } - - $currentBits = ~$this->bits[$bitsOffset]; - } - - $result = ($bitsOffset << 5) + BitUtils::numberOfTrailingZeros($currentBits); - return $result > $this->size ? $this->size : $result; - } - - /** - * Sets a bulk of bits. - */ - public function setBulk(int $i, int $newBits) : void - { - $this->bits[$i >> 5] = $newBits; - } - - /** - * Sets a range of bits. - * - * @throws InvalidArgumentException if end is smaller than start - */ - public function setRange(int $start, int $end) : void - { - if ($end < $start) { - throw new InvalidArgumentException('End must be greater or equal to start'); - } - - if ($end === $start) { - return; - } - - --$end; - - $firstInt = $start >> 5; - $lastInt = $end >> 5; - - for ($i = $firstInt; $i <= $lastInt; ++$i) { - $firstBit = $i > $firstInt ? 0 : $start & 0x1f; - $lastBit = $i < $lastInt ? 31 : $end & 0x1f; - - if (0 === $firstBit && 31 === $lastBit) { - $mask = 0x7fffffff; - } else { - $mask = 0; - - for ($j = $firstBit; $j < $lastBit; ++$j) { - $mask |= 1 << $j; - } - } - - $this->bits[$i] = $this->bits[$i] | $mask; - } - } - - /** - * Clears the bit array, unsetting every bit. - */ - public function clear() : void - { - $bitsLength = count($this->bits); - - for ($i = 0; $i < $bitsLength; ++$i) { - $this->bits[$i] = 0; - } - } - - /** - * Checks if a range of bits is set or not set. - - * @throws InvalidArgumentException if end is smaller than start - */ - public function isRange(int $start, int $end, bool $value) : bool - { - if ($end < $start) { - throw new InvalidArgumentException('End must be greater or equal to start'); - } - - if ($end === $start) { - return true; - } - - --$end; - - $firstInt = $start >> 5; - $lastInt = $end >> 5; - - for ($i = $firstInt; $i <= $lastInt; ++$i) { - $firstBit = $i > $firstInt ? 0 : $start & 0x1f; - $lastBit = $i < $lastInt ? 31 : $end & 0x1f; - - if (0 === $firstBit && 31 === $lastBit) { - $mask = 0x7fffffff; - } else { - $mask = 0; - - for ($j = $firstBit; $j <= $lastBit; ++$j) { - $mask |= 1 << $j; - } - } - - if (($this->bits[$i] & $mask) !== ($value ? $mask : 0)) { - return false; - } - } - - return true; - } - - /** - * Appends a bit to the array. - */ - public function appendBit(bool $bit) : void - { - $this->ensureCapacity($this->size + 1); - - if ($bit) { - $this->bits[$this->size >> 5] = $this->bits[$this->size >> 5] | (1 << ($this->size & 0x1f)); - } - - ++$this->size; - } - - /** - * Appends a number of bits (up to 32) to the array. - - * @throws InvalidArgumentException if num bits is not between 0 and 32 - */ - public function appendBits(int $value, int $numBits) : void - { - if ($numBits < 0 || $numBits > 32) { - throw new InvalidArgumentException('Num bits must be between 0 and 32'); - } - - $this->ensureCapacity($this->size + $numBits); - - for ($numBitsLeft = $numBits; $numBitsLeft > 0; $numBitsLeft--) { - $this->appendBit((($value >> ($numBitsLeft - 1)) & 0x01) === 1); - } - } - - /** - * Appends another bit array to this array. - */ - public function appendBitArray(self $other) : void - { - $otherSize = $other->getSize(); - $this->ensureCapacity($this->size + $other->getSize()); - - for ($i = 0; $i < $otherSize; ++$i) { - $this->appendBit($other->get($i)); - } - } - - /** - * Makes an exclusive-or comparision on the current bit array. - * - * @throws InvalidArgumentException if sizes don't match - */ - public function xorBits(self $other) : void - { - $bitsLength = count($this->bits); - $otherBits = $other->getBitArray(); - - if ($bitsLength !== count($otherBits)) { - throw new InvalidArgumentException('Sizes don\'t match'); - } - - for ($i = 0; $i < $bitsLength; ++$i) { - $this->bits[$i] = $this->bits[$i] ^ $otherBits[$i]; - } - } - - /** - * Converts the bit array to a byte array. - * - * @return SplFixedArray - */ - public function toBytes(int $bitOffset, int $numBytes) : SplFixedArray - { - $bytes = new SplFixedArray($numBytes); - - for ($i = 0; $i < $numBytes; ++$i) { - $byte = 0; - - for ($j = 0; $j < 8; ++$j) { - if ($this->get($bitOffset)) { - $byte |= 1 << (7 - $j); - } - - ++$bitOffset; - } - - $bytes[$i] = $byte; - } - - return $bytes; - } - - /** - * Gets the internal bit array. - * - * @return SplFixedArray - */ - public function getBitArray() : SplFixedArray - { - return $this->bits; - } - - /** - * Reverses the array. - */ - public function reverse() : void - { - $newBits = new SplFixedArray(count($this->bits)); - - for ($i = 0; $i < $this->size; ++$i) { - if ($this->get($this->size - $i - 1)) { - $newBits[$i >> 5] = $newBits[$i >> 5] | (1 << ($i & 0x1f)); - } - } - - $this->bits = $newBits; - } - - /** - * Returns a string representation of the bit array. - */ - public function __toString() : string - { - $result = ''; - - for ($i = 0; $i < $this->size; ++$i) { - if (0 === ($i & 0x07)) { - $result .= ' '; - } - - $result .= $this->get($i) ? 'X' : '.'; - } - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/BitMatrix.php b/vendor/bacon/bacon-qr-code/src/Common/BitMatrix.php deleted file mode 100644 index 10bf8fe..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/BitMatrix.php +++ /dev/null @@ -1,313 +0,0 @@ - - */ - private $bits; - - /** - * @throws InvalidArgumentException if a dimension is smaller than zero - */ - public function __construct(int $width, int $height = null) - { - if (null === $height) { - $height = $width; - } - - if ($width < 1 || $height < 1) { - throw new InvalidArgumentException('Both dimensions must be greater than zero'); - } - - $this->width = $width; - $this->height = $height; - $this->rowSize = ($width + 31) >> 5; - $this->bits = SplFixedArray::fromArray(array_fill(0, $this->rowSize * $height, 0)); - } - - /** - * Gets the requested bit, where true means black. - */ - public function get(int $x, int $y) : bool - { - $offset = $y * $this->rowSize + ($x >> 5); - return 0 !== (BitUtils::unsignedRightShift($this->bits[$offset], ($x & 0x1f)) & 1); - } - - /** - * Sets the given bit to true. - */ - public function set(int $x, int $y) : void - { - $offset = $y * $this->rowSize + ($x >> 5); - $this->bits[$offset] = $this->bits[$offset] | (1 << ($x & 0x1f)); - } - - /** - * Flips the given bit. - */ - public function flip(int $x, int $y) : void - { - $offset = $y * $this->rowSize + ($x >> 5); - $this->bits[$offset] = $this->bits[$offset] ^ (1 << ($x & 0x1f)); - } - - /** - * Clears all bits (set to false). - */ - public function clear() : void - { - $max = count($this->bits); - - for ($i = 0; $i < $max; ++$i) { - $this->bits[$i] = 0; - } - } - - /** - * Sets a square region of the bit matrix to true. - * - * @throws InvalidArgumentException if left or top are negative - * @throws InvalidArgumentException if width or height are smaller than 1 - * @throws InvalidArgumentException if region does not fit into the matix - */ - public function setRegion(int $left, int $top, int $width, int $height) : void - { - if ($top < 0 || $left < 0) { - throw new InvalidArgumentException('Left and top must be non-negative'); - } - - if ($height < 1 || $width < 1) { - throw new InvalidArgumentException('Width and height must be at least 1'); - } - - $right = $left + $width; - $bottom = $top + $height; - - if ($bottom > $this->height || $right > $this->width) { - throw new InvalidArgumentException('The region must fit inside the matrix'); - } - - for ($y = $top; $y < $bottom; ++$y) { - $offset = $y * $this->rowSize; - - for ($x = $left; $x < $right; ++$x) { - $index = $offset + ($x >> 5); - $this->bits[$index] = $this->bits[$index] | (1 << ($x & 0x1f)); - } - } - } - - /** - * A fast method to retrieve one row of data from the matrix as a BitArray. - */ - public function getRow(int $y, BitArray $row = null) : BitArray - { - if (null === $row || $row->getSize() < $this->width) { - $row = new BitArray($this->width); - } - - $offset = $y * $this->rowSize; - - for ($x = 0; $x < $this->rowSize; ++$x) { - $row->setBulk($x << 5, $this->bits[$offset + $x]); - } - - return $row; - } - - /** - * Sets a row of data from a BitArray. - */ - public function setRow(int $y, BitArray $row) : void - { - $bits = $row->getBitArray(); - - for ($i = 0; $i < $this->rowSize; ++$i) { - $this->bits[$y * $this->rowSize + $i] = $bits[$i]; - } - } - - /** - * This is useful in detecting the enclosing rectangle of a 'pure' barcode. - * - * @return int[]|null - */ - public function getEnclosingRectangle() : ?array - { - $left = $this->width; - $top = $this->height; - $right = -1; - $bottom = -1; - - for ($y = 0; $y < $this->height; ++$y) { - for ($x32 = 0; $x32 < $this->rowSize; ++$x32) { - $bits = $this->bits[$y * $this->rowSize + $x32]; - - if (0 !== $bits) { - if ($y < $top) { - $top = $y; - } - - if ($y > $bottom) { - $bottom = $y; - } - - if ($x32 * 32 < $left) { - $bit = 0; - - while (($bits << (31 - $bit)) === 0) { - $bit++; - } - - if (($x32 * 32 + $bit) < $left) { - $left = $x32 * 32 + $bit; - } - } - } - - if ($x32 * 32 + 31 > $right) { - $bit = 31; - - while (0 === BitUtils::unsignedRightShift($bits, $bit)) { - --$bit; - } - - if (($x32 * 32 + $bit) > $right) { - $right = $x32 * 32 + $bit; - } - } - } - } - - $width = $right - $left; - $height = $bottom - $top; - - if ($width < 0 || $height < 0) { - return null; - } - - return [$left, $top, $width, $height]; - } - - /** - * Gets the most top left set bit. - * - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return int[]|null - */ - public function getTopLeftOnBit() : ?array - { - $bitsOffset = 0; - - while ($bitsOffset < count($this->bits) && 0 === $this->bits[$bitsOffset]) { - ++$bitsOffset; - } - - if (count($this->bits) === $bitsOffset) { - return null; - } - - $x = intdiv($bitsOffset, $this->rowSize); - $y = ($bitsOffset % $this->rowSize) << 5; - - $bits = $this->bits[$bitsOffset]; - $bit = 0; - - while (0 === ($bits << (31 - $bit))) { - ++$bit; - } - - $x += $bit; - - return [$x, $y]; - } - - /** - * Gets the most bottom right set bit. - * - * This is useful in detecting a corner of a 'pure' barcode. - * - * @return int[]|null - */ - public function getBottomRightOnBit() : ?array - { - $bitsOffset = count($this->bits) - 1; - - while ($bitsOffset >= 0 && 0 === $this->bits[$bitsOffset]) { - --$bitsOffset; - } - - if ($bitsOffset < 0) { - return null; - } - - $x = intdiv($bitsOffset, $this->rowSize); - $y = ($bitsOffset % $this->rowSize) << 5; - - $bits = $this->bits[$bitsOffset]; - $bit = 0; - - while (0 === BitUtils::unsignedRightShift($bits, $bit)) { - --$bit; - } - - $x += $bit; - - return [$x, $y]; - } - - /** - * Gets the width of the matrix, - */ - public function getWidth() : int - { - return $this->width; - } - - /** - * Gets the height of the matrix. - */ - public function getHeight() : int - { - return $this->height; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/BitUtils.php b/vendor/bacon/bacon-qr-code/src/Common/BitUtils.php deleted file mode 100644 index 0c575b4..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/BitUtils.php +++ /dev/null @@ -1,41 +0,0 @@ ->>" in other - * languages. - */ - public static function unsignedRightShift(int $a, int $b) : int - { - return ( - $a >= 0 - ? $a >> $b - : (($a & 0x7fffffff) >> $b) | (0x40000000 >> ($b - 1)) - ); - } - - /** - * Gets the number of trailing zeros. - */ - public static function numberOfTrailingZeros(int $i) : int - { - $lastPos = strrpos(str_pad(decbin($i), 32, '0', STR_PAD_LEFT), '1'); - return $lastPos === false ? 32 : 31 - $lastPos; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/CharacterSetEci.php b/vendor/bacon/bacon-qr-code/src/Common/CharacterSetEci.php deleted file mode 100644 index 9049ccb..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/CharacterSetEci.php +++ /dev/null @@ -1,183 +0,0 @@ -|null - */ - private static $valueToEci; - - /** - * @var array|null - */ - private static $nameToEci; - - /** - * @param int[] $values - */ - public function __construct(array $values, string ...$otherEncodingNames) - { - $this->values = $values; - $this->otherEncodingNames = $otherEncodingNames; - } - - /** - * Returns the primary value. - */ - public function getValue() : int - { - return $this->values[0]; - } - - /** - * Gets character set ECI by value. - * - * Returns the representing ECI of a given value, or null if it is legal but unsupported. - * - * @throws InvalidArgumentException if value is not between 0 and 900 - */ - public static function getCharacterSetEciByValue(int $value) : ?self - { - if ($value < 0 || $value >= 900) { - throw new InvalidArgumentException('Value must be between 0 and 900'); - } - - $valueToEci = self::valueToEci(); - - if (! array_key_exists($value, $valueToEci)) { - return null; - } - - return $valueToEci[$value]; - } - - /** - * Returns character set ECI by name. - * - * Returns the representing ECI of a given name, or null if it is legal but unsupported - */ - public static function getCharacterSetEciByName(string $name) : ?self - { - $nameToEci = self::nameToEci(); - $name = strtolower($name); - - if (! array_key_exists($name, $nameToEci)) { - return null; - } - - return $nameToEci[$name]; - } - - private static function valueToEci() : array - { - if (null !== self::$valueToEci) { - return self::$valueToEci; - } - - self::$valueToEci = []; - - foreach (self::values() as $eci) { - foreach ($eci->values as $value) { - self::$valueToEci[$value] = $eci; - } - } - - return self::$valueToEci; - } - - private static function nameToEci() : array - { - if (null !== self::$nameToEci) { - return self::$nameToEci; - } - - self::$nameToEci = []; - - foreach (self::values() as $eci) { - self::$nameToEci[strtolower($eci->name())] = $eci; - - foreach ($eci->otherEncodingNames as $name) { - self::$nameToEci[strtolower($name)] = $eci; - } - } - - return self::$nameToEci; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/EcBlock.php b/vendor/bacon/bacon-qr-code/src/Common/EcBlock.php deleted file mode 100644 index a9a1d07..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/EcBlock.php +++ /dev/null @@ -1,49 +0,0 @@ -count = $count; - $this->dataCodewords = $dataCodewords; - } - - /** - * Returns how many times the block is used. - */ - public function getCount() : int - { - return $this->count; - } - - /** - * Returns the number of data codewords. - */ - public function getDataCodewords() : int - { - return $this->dataCodewords; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/EcBlocks.php b/vendor/bacon/bacon-qr-code/src/Common/EcBlocks.php deleted file mode 100644 index 172b5f2..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/EcBlocks.php +++ /dev/null @@ -1,74 +0,0 @@ -ecCodewordsPerBlock = $ecCodewordsPerBlock; - $this->ecBlocks = $ecBlocks; - } - - /** - * Returns the number of EC codewords per block. - */ - public function getEcCodewordsPerBlock() : int - { - return $this->ecCodewordsPerBlock; - } - - /** - * Returns the total number of EC block appearances. - */ - public function getNumBlocks() : int - { - $total = 0; - - foreach ($this->ecBlocks as $ecBlock) { - $total += $ecBlock->getCount(); - } - - return $total; - } - - /** - * Returns the total count of EC codewords. - */ - public function getTotalEcCodewords() : int - { - return $this->ecCodewordsPerBlock * $this->getNumBlocks(); - } - - /** - * Returns the EC blocks included in this collection. - * - * @return EcBlock[] - */ - public function getEcBlocks() : array - { - return $this->ecBlocks; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/ErrorCorrectionLevel.php b/vendor/bacon/bacon-qr-code/src/Common/ErrorCorrectionLevel.php deleted file mode 100644 index 9bbf440..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/ErrorCorrectionLevel.php +++ /dev/null @@ -1,63 +0,0 @@ -bits = $bits; - } - - /** - * @throws OutOfBoundsException if number of bits is invalid - */ - public static function forBits(int $bits) : self - { - switch ($bits) { - case 0: - return self::M(); - - case 1: - return self::L(); - - case 2: - return self::H(); - - case 3: - return self::Q(); - } - - throw new OutOfBoundsException('Invalid number of bits'); - } - - /** - * Returns the two bits used to encode this error correction level. - */ - public function getBits() : int - { - return $this->bits; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/FormatInformation.php b/vendor/bacon/bacon-qr-code/src/Common/FormatInformation.php deleted file mode 100644 index 38295fc..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/FormatInformation.php +++ /dev/null @@ -1,203 +0,0 @@ -ecLevel = ErrorCorrectionLevel::forBits(($formatInfo >> 3) & 0x3); - $this->dataMask = $formatInfo & 0x7; - } - - /** - * Checks how many bits are different between two integers. - */ - public static function numBitsDiffering(int $a, int $b) : int - { - $a ^= $b; - - return ( - self::BITS_SET_IN_HALF_BYTE[$a & 0xf] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 4) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 8) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 12) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 16) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 20) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 24) & 0xf)] - + self::BITS_SET_IN_HALF_BYTE[(BitUtils::unsignedRightShift($a, 28) & 0xf)] - ); - } - - /** - * Decodes format information. - */ - public static function decodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : ?self - { - $formatInfo = self::doDecodeFormatInformation($maskedFormatInfo1, $maskedFormatInfo2); - - if (null !== $formatInfo) { - return $formatInfo; - } - - // Should return null, but, some QR codes apparently do not mask this info. Try again by actually masking the - // pattern first. - return self::doDecodeFormatInformation( - $maskedFormatInfo1 ^ self::FORMAT_INFO_MASK_QR, - $maskedFormatInfo2 ^ self::FORMAT_INFO_MASK_QR - ); - } - - /** - * Internal method for decoding format information. - */ - private static function doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : ?self - { - $bestDifference = PHP_INT_MAX; - $bestFormatInfo = 0; - - foreach (self::FORMAT_INFO_DECODE_LOOKUP as $decodeInfo) { - $targetInfo = $decodeInfo[0]; - - if ($targetInfo === $maskedFormatInfo1 || $targetInfo === $maskedFormatInfo2) { - // Found an exact match - return new self($decodeInfo[1]); - } - - $bitsDifference = self::numBitsDiffering($maskedFormatInfo1, $targetInfo); - - if ($bitsDifference < $bestDifference) { - $bestFormatInfo = $decodeInfo[1]; - $bestDifference = $bitsDifference; - } - - if ($maskedFormatInfo1 !== $maskedFormatInfo2) { - // Also try the other option - $bitsDifference = self::numBitsDiffering($maskedFormatInfo2, $targetInfo); - - if ($bitsDifference < $bestDifference) { - $bestFormatInfo = $decodeInfo[1]; - $bestDifference = $bitsDifference; - } - } - } - - // Hamming distance of the 32 masked codes is 7, by construction, so <= 3 bits differing means we found a match. - if ($bestDifference <= 3) { - return new self($bestFormatInfo); - } - - return null; - } - - /** - * Returns the error correction level. - */ - public function getErrorCorrectionLevel() : ErrorCorrectionLevel - { - return $this->ecLevel; - } - - /** - * Returns the data mask. - */ - public function getDataMask() : int - { - return $this->dataMask; - } - - /** - * Hashes the code of the EC level. - */ - public function hashCode() : int - { - return ($this->ecLevel->getBits() << 3) | $this->dataMask; - } - - /** - * Verifies if this instance equals another one. - */ - public function equals(self $other) : bool - { - return ( - $this->ecLevel === $other->ecLevel - && $this->dataMask === $other->dataMask - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/Mode.php b/vendor/bacon/bacon-qr-code/src/Common/Mode.php deleted file mode 100644 index af5a113..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/Mode.php +++ /dev/null @@ -1,79 +0,0 @@ -characterCountBitsForVersions = $characterCountBitsForVersions; - $this->bits = $bits; - } - - /** - * Returns the number of bits used in a specific QR code version. - */ - public function getCharacterCountBits(Version $version) : int - { - $number = $version->getVersionNumber(); - - if ($number <= 9) { - $offset = 0; - } elseif ($number <= 26) { - $offset = 1; - } else { - $offset = 2; - } - - return $this->characterCountBitsForVersions[$offset]; - } - - /** - * Returns the four bits used to encode this mode. - */ - public function getBits() : int - { - return $this->bits; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/ReedSolomonCodec.php b/vendor/bacon/bacon-qr-code/src/Common/ReedSolomonCodec.php deleted file mode 100644 index a5aad0b..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/ReedSolomonCodec.php +++ /dev/null @@ -1,468 +0,0 @@ - 8) { - throw new InvalidArgumentException('Symbol size must be between 0 and 8'); - } - - if ($firstRoot < 0 || $firstRoot >= (1 << $symbolSize)) { - throw new InvalidArgumentException('First root must be between 0 and ' . (1 << $symbolSize)); - } - - if ($numRoots < 0 || $numRoots >= (1 << $symbolSize)) { - throw new InvalidArgumentException('Num roots must be between 0 and ' . (1 << $symbolSize)); - } - - if ($padding < 0 || $padding >= ((1 << $symbolSize) - 1 - $numRoots)) { - throw new InvalidArgumentException( - 'Padding must be between 0 and ' . ((1 << $symbolSize) - 1 - $numRoots) - ); - } - - $this->symbolSize = $symbolSize; - $this->blockSize = (1 << $symbolSize) - 1; - $this->padding = $padding; - $this->alphaTo = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false); - $this->indexOf = SplFixedArray::fromArray(array_fill(0, $this->blockSize + 1, 0), false); - - // Generate galous field lookup table - $this->indexOf[0] = $this->blockSize; - $this->alphaTo[$this->blockSize] = 0; - - $sr = 1; - - for ($i = 0; $i < $this->blockSize; ++$i) { - $this->indexOf[$sr] = $i; - $this->alphaTo[$i] = $sr; - - $sr <<= 1; - - if ($sr & (1 << $symbolSize)) { - $sr ^= $gfPoly; - } - - $sr &= $this->blockSize; - } - - if (1 !== $sr) { - throw new RuntimeException('Field generator polynomial is not primitive'); - } - - // Form RS code generator polynomial from its roots - $this->generatorPoly = SplFixedArray::fromArray(array_fill(0, $numRoots + 1, 0), false); - $this->firstRoot = $firstRoot; - $this->primitive = $primitive; - $this->numRoots = $numRoots; - - // Find prim-th root of 1, used in decoding - for ($iPrimitive = 1; ($iPrimitive % $primitive) !== 0; $iPrimitive += $this->blockSize) { - } - - $this->iPrimitive = intdiv($iPrimitive, $primitive); - - $this->generatorPoly[0] = 1; - - for ($i = 0, $root = $firstRoot * $primitive; $i < $numRoots; ++$i, $root += $primitive) { - $this->generatorPoly[$i + 1] = 1; - - for ($j = $i; $j > 0; $j--) { - if ($this->generatorPoly[$j] !== 0) { - $this->generatorPoly[$j] = $this->generatorPoly[$j - 1] ^ $this->alphaTo[ - $this->modNn($this->indexOf[$this->generatorPoly[$j]] + $root) - ]; - } else { - $this->generatorPoly[$j] = $this->generatorPoly[$j - 1]; - } - } - - $this->generatorPoly[$j] = $this->alphaTo[$this->modNn($this->indexOf[$this->generatorPoly[0]] + $root)]; - } - - // Convert generator poly to index form for quicker encoding - for ($i = 0; $i <= $numRoots; ++$i) { - $this->generatorPoly[$i] = $this->indexOf[$this->generatorPoly[$i]]; - } - } - - /** - * Encodes data and writes result back into parity array. - */ - public function encode(SplFixedArray $data, SplFixedArray $parity) : void - { - for ($i = 0; $i < $this->numRoots; ++$i) { - $parity[$i] = 0; - } - - $iterations = $this->blockSize - $this->numRoots - $this->padding; - - for ($i = 0; $i < $iterations; ++$i) { - $feedback = $this->indexOf[$data[$i] ^ $parity[0]]; - - if ($feedback !== $this->blockSize) { - // Feedback term is non-zero - $feedback = $this->modNn($this->blockSize - $this->generatorPoly[$this->numRoots] + $feedback); - - for ($j = 1; $j < $this->numRoots; ++$j) { - $parity[$j] = $parity[$j] ^ $this->alphaTo[ - $this->modNn($feedback + $this->generatorPoly[$this->numRoots - $j]) - ]; - } - } - - for ($j = 0; $j < $this->numRoots - 1; ++$j) { - $parity[$j] = $parity[$j + 1]; - } - - if ($feedback !== $this->blockSize) { - $parity[$this->numRoots - 1] = $this->alphaTo[$this->modNn($feedback + $this->generatorPoly[0])]; - } else { - $parity[$this->numRoots - 1] = 0; - } - } - } - - /** - * Decodes received data. - */ - public function decode(SplFixedArray $data, SplFixedArray $erasures = null) : ?int - { - // This speeds up the initialization a bit. - $numRootsPlusOne = SplFixedArray::fromArray(array_fill(0, $this->numRoots + 1, 0), false); - $numRoots = SplFixedArray::fromArray(array_fill(0, $this->numRoots, 0), false); - - $lambda = clone $numRootsPlusOne; - $b = clone $numRootsPlusOne; - $t = clone $numRootsPlusOne; - $omega = clone $numRootsPlusOne; - $root = clone $numRoots; - $loc = clone $numRoots; - - $numErasures = (null !== $erasures ? count($erasures) : 0); - - // Form the Syndromes; i.e., evaluate data(x) at roots of g(x) - $syndromes = SplFixedArray::fromArray(array_fill(0, $this->numRoots, $data[0]), false); - - for ($i = 1; $i < $this->blockSize - $this->padding; ++$i) { - for ($j = 0; $j < $this->numRoots; ++$j) { - if ($syndromes[$j] === 0) { - $syndromes[$j] = $data[$i]; - } else { - $syndromes[$j] = $data[$i] ^ $this->alphaTo[ - $this->modNn($this->indexOf[$syndromes[$j]] + ($this->firstRoot + $j) * $this->primitive) - ]; - } - } - } - - // Convert syndromes to index form, checking for nonzero conditions - $syndromeError = 0; - - for ($i = 0; $i < $this->numRoots; ++$i) { - $syndromeError |= $syndromes[$i]; - $syndromes[$i] = $this->indexOf[$syndromes[$i]]; - } - - if (! $syndromeError) { - // If syndrome is zero, data[] is a codeword and there are no errors to correct, so return data[] - // unmodified. - return 0; - } - - $lambda[0] = 1; - - if ($numErasures > 0) { - // Init lambda to be the erasure locator polynomial - $lambda[1] = $this->alphaTo[$this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[0]))]; - - for ($i = 1; $i < $numErasures; ++$i) { - $u = $this->modNn($this->primitive * ($this->blockSize - 1 - $erasures[$i])); - - for ($j = $i + 1; $j > 0; --$j) { - $tmp = $this->indexOf[$lambda[$j - 1]]; - - if ($tmp !== $this->blockSize) { - $lambda[$j] = $lambda[$j] ^ $this->alphaTo[$this->modNn($u + $tmp)]; - } - } - } - } - - for ($i = 0; $i <= $this->numRoots; ++$i) { - $b[$i] = $this->indexOf[$lambda[$i]]; - } - - // Begin Berlekamp-Massey algorithm to determine error+erasure locator polynomial - $r = $numErasures; - $el = $numErasures; - - while (++$r <= $this->numRoots) { - // Compute discrepancy at the r-th step in poly form - $discrepancyR = 0; - - for ($i = 0; $i < $r; ++$i) { - if ($lambda[$i] !== 0 && $syndromes[$r - $i - 1] !== $this->blockSize) { - $discrepancyR ^= $this->alphaTo[ - $this->modNn($this->indexOf[$lambda[$i]] + $syndromes[$r - $i - 1]) - ]; - } - } - - $discrepancyR = $this->indexOf[$discrepancyR]; - - if ($discrepancyR === $this->blockSize) { - $tmp = $b->toArray(); - array_unshift($tmp, $this->blockSize); - array_pop($tmp); - $b = SplFixedArray::fromArray($tmp, false); - continue; - } - - $t[0] = $lambda[0]; - - for ($i = 0; $i < $this->numRoots; ++$i) { - if ($b[$i] !== $this->blockSize) { - $t[$i + 1] = $lambda[$i + 1] ^ $this->alphaTo[$this->modNn($discrepancyR + $b[$i])]; - } else { - $t[$i + 1] = $lambda[$i + 1]; - } - } - - if (2 * $el <= $r + $numErasures - 1) { - $el = $r + $numErasures - $el; - - for ($i = 0; $i <= $this->numRoots; ++$i) { - $b[$i] = ( - $lambda[$i] === 0 - ? $this->blockSize - : $this->modNn($this->indexOf[$lambda[$i]] - $discrepancyR + $this->blockSize) - ); - } - } else { - $tmp = $b->toArray(); - array_unshift($tmp, $this->blockSize); - array_pop($tmp); - $b = SplFixedArray::fromArray($tmp, false); - } - - $lambda = clone $t; - } - - // Convert lambda to index form and compute deg(lambda(x)) - $degLambda = 0; - - for ($i = 0; $i <= $this->numRoots; ++$i) { - $lambda[$i] = $this->indexOf[$lambda[$i]]; - - if ($lambda[$i] !== $this->blockSize) { - $degLambda = $i; - } - } - - // Find roots of the error+erasure locator polynomial by Chien search. - $reg = clone $lambda; - $reg[0] = 0; - $count = 0; - $i = 1; - - for ($k = $this->iPrimitive - 1; $i <= $this->blockSize; ++$i, $k = $this->modNn($k + $this->iPrimitive)) { - $q = 1; - - for ($j = $degLambda; $j > 0; $j--) { - if ($reg[$j] !== $this->blockSize) { - $reg[$j] = $this->modNn($reg[$j] + $j); - $q ^= $this->alphaTo[$reg[$j]]; - } - } - - if ($q !== 0) { - // Not a root - continue; - } - - // Store root (index-form) and error location number - $root[$count] = $i; - $loc[$count] = $k; - - if (++$count === $degLambda) { - break; - } - } - - if ($degLambda !== $count) { - // deg(lambda) unequal to number of roots: uncorrectable error detected - return null; - } - - // Compute err+eras evaluate poly omega(x) = s(x)*lambda(x) (modulo x**numRoots). In index form. Also find - // deg(omega). - $degOmega = $degLambda - 1; - - for ($i = 0; $i <= $degOmega; ++$i) { - $tmp = 0; - - for ($j = $i; $j >= 0; --$j) { - if ($syndromes[$i - $j] !== $this->blockSize && $lambda[$j] !== $this->blockSize) { - $tmp ^= $this->alphaTo[$this->modNn($syndromes[$i - $j] + $lambda[$j])]; - } - } - - $omega[$i] = $this->indexOf[$tmp]; - } - - // Compute error values in poly-form. num1 = omega(inv(X(l))), num2 = inv(X(l))**(firstRoot-1) and - // den = lambda_pr(inv(X(l))) all in poly form. - for ($j = $count - 1; $j >= 0; --$j) { - $num1 = 0; - - for ($i = $degOmega; $i >= 0; $i--) { - if ($omega[$i] !== $this->blockSize) { - $num1 ^= $this->alphaTo[$this->modNn($omega[$i] + $i * $root[$j])]; - } - } - - $num2 = $this->alphaTo[$this->modNn($root[$j] * ($this->firstRoot - 1) + $this->blockSize)]; - $den = 0; - - // lambda[i+1] for i even is the formal derivativelambda_pr of lambda[i] - for ($i = min($degLambda, $this->numRoots - 1) & ~1; $i >= 0; $i -= 2) { - if ($lambda[$i + 1] !== $this->blockSize) { - $den ^= $this->alphaTo[$this->modNn($lambda[$i + 1] + $i * $root[$j])]; - } - } - - // Apply error to data - if ($num1 !== 0 && $loc[$j] >= $this->padding) { - $data[$loc[$j] - $this->padding] = $data[$loc[$j] - $this->padding] ^ ( - $this->alphaTo[ - $this->modNn( - $this->indexOf[$num1] + $this->indexOf[$num2] + $this->blockSize - $this->indexOf[$den] - ) - ] - ); - } - } - - if (null !== $erasures) { - if (count($erasures) < $count) { - $erasures->setSize($count); - } - - for ($i = 0; $i < $count; $i++) { - $erasures[$i] = $loc[$i]; - } - } - - return $count; - } - - /** - * Computes $x % GF_SIZE, where GF_SIZE is 2**GF_BITS - 1, without a slow divide. - */ - private function modNn(int $x) : int - { - while ($x >= $this->blockSize) { - $x -= $this->blockSize; - $x = ($x >> $this->symbolSize) + ($x & $this->blockSize); - } - - return $x; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Common/Version.php b/vendor/bacon/bacon-qr-code/src/Common/Version.php deleted file mode 100644 index 917d048..0000000 --- a/vendor/bacon/bacon-qr-code/src/Common/Version.php +++ /dev/null @@ -1,596 +0,0 @@ -|null - */ - private static $versions; - - /** - * @param int[] $alignmentPatternCenters - */ - private function __construct( - int $versionNumber, - array $alignmentPatternCenters, - EcBlocks ...$ecBlocks - ) { - $this->versionNumber = $versionNumber; - $this->alignmentPatternCenters = $alignmentPatternCenters; - $this->ecBlocks = $ecBlocks; - - $totalCodewords = 0; - $ecCodewords = $ecBlocks[0]->getEcCodewordsPerBlock(); - - foreach ($ecBlocks[0]->getEcBlocks() as $ecBlock) { - $totalCodewords += $ecBlock->getCount() * ($ecBlock->getDataCodewords() + $ecCodewords); - } - - $this->totalCodewords = $totalCodewords; - } - - /** - * Returns the version number. - */ - public function getVersionNumber() : int - { - return $this->versionNumber; - } - - /** - * Returns the alignment pattern centers. - * - * @return int[] - */ - public function getAlignmentPatternCenters() : array - { - return $this->alignmentPatternCenters; - } - - /** - * Returns the total number of codewords. - */ - public function getTotalCodewords() : int - { - return $this->totalCodewords; - } - - /** - * Calculates the dimension for the current version. - */ - public function getDimensionForVersion() : int - { - return 17 + 4 * $this->versionNumber; - } - - /** - * Returns the number of EC blocks for a specific EC level. - */ - public function getEcBlocksForLevel(ErrorCorrectionLevel $ecLevel) : EcBlocks - { - return $this->ecBlocks[$ecLevel->ordinal()]; - } - - /** - * Gets a provisional version number for a specific dimension. - * - * @throws InvalidArgumentException if dimension is not 1 mod 4 - */ - public static function getProvisionalVersionForDimension(int $dimension) : self - { - if (1 !== $dimension % 4) { - throw new InvalidArgumentException('Dimension is not 1 mod 4'); - } - - return self::getVersionForNumber(intdiv($dimension - 17, 4)); - } - - /** - * Gets a version instance for a specific version number. - * - * @throws InvalidArgumentException if version number is out of range - */ - public static function getVersionForNumber(int $versionNumber) : self - { - if ($versionNumber < 1 || $versionNumber > 40) { - throw new InvalidArgumentException('Version number must be between 1 and 40'); - } - - return self::versions()[$versionNumber - 1]; - } - - /** - * Decodes version information from an integer and returns the version. - */ - public static function decodeVersionInformation(int $versionBits) : ?self - { - $bestDifference = PHP_INT_MAX; - $bestVersion = 0; - - foreach (self::VERSION_DECODE_INFO as $i => $targetVersion) { - if ($targetVersion === $versionBits) { - return self::getVersionForNumber($i + 7); - } - - $bitsDifference = FormatInformation::numBitsDiffering($versionBits, $targetVersion); - - if ($bitsDifference < $bestDifference) { - $bestVersion = $i + 7; - $bestDifference = $bitsDifference; - } - } - - if ($bestDifference <= 3) { - return self::getVersionForNumber($bestVersion); - } - - return null; - } - - /** - * Builds the function pattern for the current version. - */ - public function buildFunctionPattern() : BitMatrix - { - $dimension = $this->getDimensionForVersion(); - $bitMatrix = new BitMatrix($dimension); - - // Top left finder pattern + separator + format - $bitMatrix->setRegion(0, 0, 9, 9); - // Top right finder pattern + separator + format - $bitMatrix->setRegion($dimension - 8, 0, 8, 9); - // Bottom left finder pattern + separator + format - $bitMatrix->setRegion(0, $dimension - 8, 9, 8); - - // Alignment patterns - $max = count($this->alignmentPatternCenters); - - for ($x = 0; $x < $max; ++$x) { - $i = $this->alignmentPatternCenters[$x] - 2; - - for ($y = 0; $y < $max; ++$y) { - if (($x === 0 && ($y === 0 || $y === $max - 1)) || ($x === $max - 1 && $y === 0)) { - // No alignment patterns near the three finder paterns - continue; - } - - $bitMatrix->setRegion($this->alignmentPatternCenters[$y] - 2, $i, 5, 5); - } - } - - // Vertical timing pattern - $bitMatrix->setRegion(6, 9, 1, $dimension - 17); - // Horizontal timing pattern - $bitMatrix->setRegion(9, 6, $dimension - 17, 1); - - if ($this->versionNumber > 6) { - // Version info, top right - $bitMatrix->setRegion($dimension - 11, 0, 3, 6); - // Version info, bottom left - $bitMatrix->setRegion(0, $dimension - 11, 6, 3); - } - - return $bitMatrix; - } - - /** - * Returns a string representation for the version. - */ - public function __toString() : string - { - return (string) $this->versionNumber; - } - - /** - * Build and cache a specific version. - * - * See ISO 18004:2006 6.5.1 Table 9. - * - * @return array - */ - private static function versions() : array - { - if (null !== self::$versions) { - return self::$versions; - } - - return self::$versions = [ - new self( - 1, - [], - new EcBlocks(7, new EcBlock(1, 19)), - new EcBlocks(10, new EcBlock(1, 16)), - new EcBlocks(13, new EcBlock(1, 13)), - new EcBlocks(17, new EcBlock(1, 9)) - ), - new self( - 2, - [6, 18], - new EcBlocks(10, new EcBlock(1, 34)), - new EcBlocks(16, new EcBlock(1, 28)), - new EcBlocks(22, new EcBlock(1, 22)), - new EcBlocks(28, new EcBlock(1, 16)) - ), - new self( - 3, - [6, 22], - new EcBlocks(15, new EcBlock(1, 55)), - new EcBlocks(26, new EcBlock(1, 44)), - new EcBlocks(18, new EcBlock(2, 17)), - new EcBlocks(22, new EcBlock(2, 13)) - ), - new self( - 4, - [6, 26], - new EcBlocks(20, new EcBlock(1, 80)), - new EcBlocks(18, new EcBlock(2, 32)), - new EcBlocks(26, new EcBlock(3, 24)), - new EcBlocks(16, new EcBlock(4, 9)) - ), - new self( - 5, - [6, 30], - new EcBlocks(26, new EcBlock(1, 108)), - new EcBlocks(24, new EcBlock(2, 43)), - new EcBlocks(18, new EcBlock(2, 15), new EcBlock(2, 16)), - new EcBlocks(22, new EcBlock(2, 11), new EcBlock(2, 12)) - ), - new self( - 6, - [6, 34], - new EcBlocks(18, new EcBlock(2, 68)), - new EcBlocks(16, new EcBlock(4, 27)), - new EcBlocks(24, new EcBlock(4, 19)), - new EcBlocks(28, new EcBlock(4, 15)) - ), - new self( - 7, - [6, 22, 38], - new EcBlocks(20, new EcBlock(2, 78)), - new EcBlocks(18, new EcBlock(4, 31)), - new EcBlocks(18, new EcBlock(2, 14), new EcBlock(4, 15)), - new EcBlocks(26, new EcBlock(4, 13), new EcBlock(1, 14)) - ), - new self( - 8, - [6, 24, 42], - new EcBlocks(24, new EcBlock(2, 97)), - new EcBlocks(22, new EcBlock(2, 38), new EcBlock(2, 39)), - new EcBlocks(22, new EcBlock(4, 18), new EcBlock(2, 19)), - new EcBlocks(26, new EcBlock(4, 14), new EcBlock(2, 15)) - ), - new self( - 9, - [6, 26, 46], - new EcBlocks(30, new EcBlock(2, 116)), - new EcBlocks(22, new EcBlock(3, 36), new EcBlock(2, 37)), - new EcBlocks(20, new EcBlock(4, 16), new EcBlock(4, 17)), - new EcBlocks(24, new EcBlock(4, 12), new EcBlock(4, 13)) - ), - new self( - 10, - [6, 28, 50], - new EcBlocks(18, new EcBlock(2, 68), new EcBlock(2, 69)), - new EcBlocks(26, new EcBlock(4, 43), new EcBlock(1, 44)), - new EcBlocks(24, new EcBlock(6, 19), new EcBlock(2, 20)), - new EcBlocks(28, new EcBlock(6, 15), new EcBlock(2, 16)) - ), - new self( - 11, - [6, 30, 54], - new EcBlocks(20, new EcBlock(4, 81)), - new EcBlocks(30, new EcBlock(1, 50), new EcBlock(4, 51)), - new EcBlocks(28, new EcBlock(4, 22), new EcBlock(4, 23)), - new EcBlocks(24, new EcBlock(3, 12), new EcBlock(8, 13)) - ), - new self( - 12, - [6, 32, 58], - new EcBlocks(24, new EcBlock(2, 92), new EcBlock(2, 93)), - new EcBlocks(22, new EcBlock(6, 36), new EcBlock(2, 37)), - new EcBlocks(26, new EcBlock(4, 20), new EcBlock(6, 21)), - new EcBlocks(28, new EcBlock(7, 14), new EcBlock(4, 15)) - ), - new self( - 13, - [6, 34, 62], - new EcBlocks(26, new EcBlock(4, 107)), - new EcBlocks(22, new EcBlock(8, 37), new EcBlock(1, 38)), - new EcBlocks(24, new EcBlock(8, 20), new EcBlock(4, 21)), - new EcBlocks(22, new EcBlock(12, 11), new EcBlock(4, 12)) - ), - new self( - 14, - [6, 26, 46, 66], - new EcBlocks(30, new EcBlock(3, 115), new EcBlock(1, 116)), - new EcBlocks(24, new EcBlock(4, 40), new EcBlock(5, 41)), - new EcBlocks(20, new EcBlock(11, 16), new EcBlock(5, 17)), - new EcBlocks(24, new EcBlock(11, 12), new EcBlock(5, 13)) - ), - new self( - 15, - [6, 26, 48, 70], - new EcBlocks(22, new EcBlock(5, 87), new EcBlock(1, 88)), - new EcBlocks(24, new EcBlock(5, 41), new EcBlock(5, 42)), - new EcBlocks(30, new EcBlock(5, 24), new EcBlock(7, 25)), - new EcBlocks(24, new EcBlock(11, 12), new EcBlock(7, 13)) - ), - new self( - 16, - [6, 26, 50, 74], - new EcBlocks(24, new EcBlock(5, 98), new EcBlock(1, 99)), - new EcBlocks(28, new EcBlock(7, 45), new EcBlock(3, 46)), - new EcBlocks(24, new EcBlock(15, 19), new EcBlock(2, 20)), - new EcBlocks(30, new EcBlock(3, 15), new EcBlock(13, 16)) - ), - new self( - 17, - [6, 30, 54, 78], - new EcBlocks(28, new EcBlock(1, 107), new EcBlock(5, 108)), - new EcBlocks(28, new EcBlock(10, 46), new EcBlock(1, 47)), - new EcBlocks(28, new EcBlock(1, 22), new EcBlock(15, 23)), - new EcBlocks(28, new EcBlock(2, 14), new EcBlock(17, 15)) - ), - new self( - 18, - [6, 30, 56, 82], - new EcBlocks(30, new EcBlock(5, 120), new EcBlock(1, 121)), - new EcBlocks(26, new EcBlock(9, 43), new EcBlock(4, 44)), - new EcBlocks(28, new EcBlock(17, 22), new EcBlock(1, 23)), - new EcBlocks(28, new EcBlock(2, 14), new EcBlock(19, 15)) - ), - new self( - 19, - [6, 30, 58, 86], - new EcBlocks(28, new EcBlock(3, 113), new EcBlock(4, 114)), - new EcBlocks(26, new EcBlock(3, 44), new EcBlock(11, 45)), - new EcBlocks(26, new EcBlock(17, 21), new EcBlock(4, 22)), - new EcBlocks(26, new EcBlock(9, 13), new EcBlock(16, 14)) - ), - new self( - 20, - [6, 34, 62, 90], - new EcBlocks(28, new EcBlock(3, 107), new EcBlock(5, 108)), - new EcBlocks(26, new EcBlock(3, 41), new EcBlock(13, 42)), - new EcBlocks(30, new EcBlock(15, 24), new EcBlock(5, 25)), - new EcBlocks(28, new EcBlock(15, 15), new EcBlock(10, 16)) - ), - new self( - 21, - [6, 28, 50, 72, 94], - new EcBlocks(28, new EcBlock(4, 116), new EcBlock(4, 117)), - new EcBlocks(26, new EcBlock(17, 42)), - new EcBlocks(28, new EcBlock(17, 22), new EcBlock(6, 23)), - new EcBlocks(30, new EcBlock(19, 16), new EcBlock(6, 17)) - ), - new self( - 22, - [6, 26, 50, 74, 98], - new EcBlocks(28, new EcBlock(2, 111), new EcBlock(7, 112)), - new EcBlocks(28, new EcBlock(17, 46)), - new EcBlocks(30, new EcBlock(7, 24), new EcBlock(16, 25)), - new EcBlocks(24, new EcBlock(34, 13)) - ), - new self( - 23, - [6, 30, 54, 78, 102], - new EcBlocks(30, new EcBlock(4, 121), new EcBlock(5, 122)), - new EcBlocks(28, new EcBlock(4, 47), new EcBlock(14, 48)), - new EcBlocks(30, new EcBlock(11, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(16, 15), new EcBlock(14, 16)) - ), - new self( - 24, - [6, 28, 54, 80, 106], - new EcBlocks(30, new EcBlock(6, 117), new EcBlock(4, 118)), - new EcBlocks(28, new EcBlock(6, 45), new EcBlock(14, 46)), - new EcBlocks(30, new EcBlock(11, 24), new EcBlock(16, 25)), - new EcBlocks(30, new EcBlock(30, 16), new EcBlock(2, 17)) - ), - new self( - 25, - [6, 32, 58, 84, 110], - new EcBlocks(26, new EcBlock(8, 106), new EcBlock(4, 107)), - new EcBlocks(28, new EcBlock(8, 47), new EcBlock(13, 48)), - new EcBlocks(30, new EcBlock(7, 24), new EcBlock(22, 25)), - new EcBlocks(30, new EcBlock(22, 15), new EcBlock(13, 16)) - ), - new self( - 26, - [6, 30, 58, 86, 114], - new EcBlocks(28, new EcBlock(10, 114), new EcBlock(2, 115)), - new EcBlocks(28, new EcBlock(19, 46), new EcBlock(4, 47)), - new EcBlocks(28, new EcBlock(28, 22), new EcBlock(6, 23)), - new EcBlocks(30, new EcBlock(33, 16), new EcBlock(4, 17)) - ), - new self( - 27, - [6, 34, 62, 90, 118], - new EcBlocks(30, new EcBlock(8, 122), new EcBlock(4, 123)), - new EcBlocks(28, new EcBlock(22, 45), new EcBlock(3, 46)), - new EcBlocks(30, new EcBlock(8, 23), new EcBlock(26, 24)), - new EcBlocks(30, new EcBlock(12, 15), new EcBlock(28, 16)) - ), - new self( - 28, - [6, 26, 50, 74, 98, 122], - new EcBlocks(30, new EcBlock(3, 117), new EcBlock(10, 118)), - new EcBlocks(28, new EcBlock(3, 45), new EcBlock(23, 46)), - new EcBlocks(30, new EcBlock(4, 24), new EcBlock(31, 25)), - new EcBlocks(30, new EcBlock(11, 15), new EcBlock(31, 16)) - ), - new self( - 29, - [6, 30, 54, 78, 102, 126], - new EcBlocks(30, new EcBlock(7, 116), new EcBlock(7, 117)), - new EcBlocks(28, new EcBlock(21, 45), new EcBlock(7, 46)), - new EcBlocks(30, new EcBlock(1, 23), new EcBlock(37, 24)), - new EcBlocks(30, new EcBlock(19, 15), new EcBlock(26, 16)) - ), - new self( - 30, - [6, 26, 52, 78, 104, 130], - new EcBlocks(30, new EcBlock(5, 115), new EcBlock(10, 116)), - new EcBlocks(28, new EcBlock(19, 47), new EcBlock(10, 48)), - new EcBlocks(30, new EcBlock(15, 24), new EcBlock(25, 25)), - new EcBlocks(30, new EcBlock(23, 15), new EcBlock(25, 16)) - ), - new self( - 31, - [6, 30, 56, 82, 108, 134], - new EcBlocks(30, new EcBlock(13, 115), new EcBlock(3, 116)), - new EcBlocks(28, new EcBlock(2, 46), new EcBlock(29, 47)), - new EcBlocks(30, new EcBlock(42, 24), new EcBlock(1, 25)), - new EcBlocks(30, new EcBlock(23, 15), new EcBlock(28, 16)) - ), - new self( - 32, - [6, 34, 60, 86, 112, 138], - new EcBlocks(30, new EcBlock(17, 115)), - new EcBlocks(28, new EcBlock(10, 46), new EcBlock(23, 47)), - new EcBlocks(30, new EcBlock(10, 24), new EcBlock(35, 25)), - new EcBlocks(30, new EcBlock(19, 15), new EcBlock(35, 16)) - ), - new self( - 33, - [6, 30, 58, 86, 114, 142], - new EcBlocks(30, new EcBlock(17, 115), new EcBlock(1, 116)), - new EcBlocks(28, new EcBlock(14, 46), new EcBlock(21, 47)), - new EcBlocks(30, new EcBlock(29, 24), new EcBlock(19, 25)), - new EcBlocks(30, new EcBlock(11, 15), new EcBlock(46, 16)) - ), - new self( - 34, - [6, 34, 62, 90, 118, 146], - new EcBlocks(30, new EcBlock(13, 115), new EcBlock(6, 116)), - new EcBlocks(28, new EcBlock(14, 46), new EcBlock(23, 47)), - new EcBlocks(30, new EcBlock(44, 24), new EcBlock(7, 25)), - new EcBlocks(30, new EcBlock(59, 16), new EcBlock(1, 17)) - ), - new self( - 35, - [6, 30, 54, 78, 102, 126, 150], - new EcBlocks(30, new EcBlock(12, 121), new EcBlock(7, 122)), - new EcBlocks(28, new EcBlock(12, 47), new EcBlock(26, 48)), - new EcBlocks(30, new EcBlock(39, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(22, 15), new EcBlock(41, 16)) - ), - new self( - 36, - [6, 24, 50, 76, 102, 128, 154], - new EcBlocks(30, new EcBlock(6, 121), new EcBlock(14, 122)), - new EcBlocks(28, new EcBlock(6, 47), new EcBlock(34, 48)), - new EcBlocks(30, new EcBlock(46, 24), new EcBlock(10, 25)), - new EcBlocks(30, new EcBlock(2, 15), new EcBlock(64, 16)) - ), - new self( - 37, - [6, 28, 54, 80, 106, 132, 158], - new EcBlocks(30, new EcBlock(17, 122), new EcBlock(4, 123)), - new EcBlocks(28, new EcBlock(29, 46), new EcBlock(14, 47)), - new EcBlocks(30, new EcBlock(49, 24), new EcBlock(10, 25)), - new EcBlocks(30, new EcBlock(24, 15), new EcBlock(46, 16)) - ), - new self( - 38, - [6, 32, 58, 84, 110, 136, 162], - new EcBlocks(30, new EcBlock(4, 122), new EcBlock(18, 123)), - new EcBlocks(28, new EcBlock(13, 46), new EcBlock(32, 47)), - new EcBlocks(30, new EcBlock(48, 24), new EcBlock(14, 25)), - new EcBlocks(30, new EcBlock(42, 15), new EcBlock(32, 16)) - ), - new self( - 39, - [6, 26, 54, 82, 110, 138, 166], - new EcBlocks(30, new EcBlock(20, 117), new EcBlock(4, 118)), - new EcBlocks(28, new EcBlock(40, 47), new EcBlock(7, 48)), - new EcBlocks(30, new EcBlock(43, 24), new EcBlock(22, 25)), - new EcBlocks(30, new EcBlock(10, 15), new EcBlock(67, 16)) - ), - new self( - 40, - [6, 30, 58, 86, 114, 142, 170], - new EcBlocks(30, new EcBlock(19, 118), new EcBlock(6, 119)), - new EcBlocks(28, new EcBlock(18, 47), new EcBlock(31, 48)), - new EcBlocks(30, new EcBlock(34, 24), new EcBlock(34, 25)), - new EcBlocks(30, new EcBlock(20, 15), new EcBlock(61, 16)) - ), - ]; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/BlockPair.php b/vendor/bacon/bacon-qr-code/src/Encoder/BlockPair.php deleted file mode 100644 index be54afa..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/BlockPair.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ - private $dataBytes; - - /** - * Error correction bytes in the block. - * - * @var SplFixedArray - */ - private $errorCorrectionBytes; - - /** - * Creates a new block pair. - * - * @param SplFixedArray $data - * @param SplFixedArray $errorCorrection - */ - public function __construct(SplFixedArray $data, SplFixedArray $errorCorrection) - { - $this->dataBytes = $data; - $this->errorCorrectionBytes = $errorCorrection; - } - - /** - * Gets the data bytes. - * - * @return SplFixedArray - */ - public function getDataBytes() : SplFixedArray - { - return $this->dataBytes; - } - - /** - * Gets the error correction bytes. - * - * @return SplFixedArray - */ - public function getErrorCorrectionBytes() : SplFixedArray - { - return $this->errorCorrectionBytes; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/ByteMatrix.php b/vendor/bacon/bacon-qr-code/src/Encoder/ByteMatrix.php deleted file mode 100644 index b58cc0a..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/ByteMatrix.php +++ /dev/null @@ -1,150 +0,0 @@ -> - */ - private $bytes; - - /** - * Width of the matrix. - * - * @var int - */ - private $width; - - /** - * Height of the matrix. - * - * @var int - */ - private $height; - - public function __construct(int $width, int $height) - { - $this->height = $height; - $this->width = $width; - $this->bytes = new SplFixedArray($height); - - for ($y = 0; $y < $height; ++$y) { - $this->bytes[$y] = SplFixedArray::fromArray(array_fill(0, $width, 0)); - } - } - - /** - * Gets the width of the matrix. - */ - public function getWidth() : int - { - return $this->width; - } - - /** - * Gets the height of the matrix. - */ - public function getHeight() : int - { - return $this->height; - } - - /** - * Gets the internal representation of the matrix. - * - * @return SplFixedArray> - */ - public function getArray() : SplFixedArray - { - return $this->bytes; - } - - /** - * @return Traversable - */ - public function getBytes() : Traversable - { - foreach ($this->bytes as $row) { - foreach ($row as $byte) { - yield $byte; - } - } - } - - /** - * Gets the byte for a specific position. - */ - public function get(int $x, int $y) : int - { - return $this->bytes[$y][$x]; - } - - /** - * Sets the byte for a specific position. - */ - public function set(int $x, int $y, int $value) : void - { - $this->bytes[$y][$x] = $value; - } - - /** - * Clears the matrix with a specific value. - */ - public function clear(int $value) : void - { - for ($y = 0; $y < $this->height; ++$y) { - for ($x = 0; $x < $this->width; ++$x) { - $this->bytes[$y][$x] = $value; - } - } - } - - public function __clone() - { - $this->bytes = clone $this->bytes; - - foreach ($this->bytes as $index => $row) { - $this->bytes[$index] = clone $row; - } - } - - /** - * Returns a string representation of the matrix. - */ - public function __toString() : string - { - $result = ''; - - for ($y = 0; $y < $this->height; $y++) { - for ($x = 0; $x < $this->width; $x++) { - switch ($this->bytes[$y][$x]) { - case 0: - $result .= ' 0'; - break; - - case 1: - $result .= ' 1'; - break; - - default: - $result .= ' '; - break; - } - } - - $result .= "\n"; - } - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php b/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php deleted file mode 100644 index 3208460..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php +++ /dev/null @@ -1,668 +0,0 @@ - - */ - private static $codecs = []; - - /** - * Encodes "content" with the error correction level "ecLevel". - */ - public static function encode( - string $content, - ErrorCorrectionLevel $ecLevel, - string $encoding = self::DEFAULT_BYTE_MODE_ECODING, - ?Version $forcedVersion = null - ) : QrCode { - // Pick an encoding mode appropriate for the content. Note that this - // will not attempt to use multiple modes / segments even if that were - // more efficient. Would be nice. - $mode = self::chooseMode($content, $encoding); - - // This will store the header information, like mode and length, as well - // as "header" segments like an ECI segment. - $headerBits = new BitArray(); - - // Append ECI segment if applicable - if (Mode::BYTE() === $mode && self::DEFAULT_BYTE_MODE_ECODING !== $encoding) { - $eci = CharacterSetEci::getCharacterSetEciByName($encoding); - - if (null !== $eci) { - self::appendEci($eci, $headerBits); - } - } - - // (With ECI in place,) Write the mode marker - self::appendModeInfo($mode, $headerBits); - - // Collect data within the main segment, separately, to count its size - // if needed. Don't add it to main payload yet. - $dataBits = new BitArray(); - self::appendBytes($content, $mode, $dataBits, $encoding); - - // Hard part: need to know version to know how many bits length takes. - // But need to know how many bits it takes to know version. First we - // take a guess at version by assuming version will be the minimum, 1: - $provisionalBitsNeeded = $headerBits->getSize() - + $mode->getCharacterCountBits(Version::getVersionForNumber(1)) - + $dataBits->getSize(); - $provisionalVersion = self::chooseVersion($provisionalBitsNeeded, $ecLevel); - - // Use that guess to calculate the right version. I am still not sure - // this works in 100% of cases. - $bitsNeeded = $headerBits->getSize() - + $mode->getCharacterCountBits($provisionalVersion) - + $dataBits->getSize(); - $version = self::chooseVersion($bitsNeeded, $ecLevel); - - if (null !== $forcedVersion) { - // Forced version check - if ($version->getVersionNumber() <= $forcedVersion->getVersionNumber()) { - // Calculated minimum version is same or equal as forced version - $version = $forcedVersion; - } else { - throw new WriterException( - 'Invalid version! Calculated version: ' - . $version->getVersionNumber() - . ', requested version: ' - . $forcedVersion->getVersionNumber() - ); - } - } - - $headerAndDataBits = new BitArray(); - $headerAndDataBits->appendBitArray($headerBits); - - // Find "length" of main segment and write it. - $numLetters = (Mode::BYTE() === $mode ? $dataBits->getSizeInBytes() : strlen($content)); - self::appendLengthInfo($numLetters, $version, $mode, $headerAndDataBits); - - // Put data together into the overall payload. - $headerAndDataBits->appendBitArray($dataBits); - $ecBlocks = $version->getEcBlocksForLevel($ecLevel); - $numDataBytes = $version->getTotalCodewords() - $ecBlocks->getTotalEcCodewords(); - - // Terminate the bits properly. - self::terminateBits($numDataBytes, $headerAndDataBits); - - // Interleave data bits with error correction code. - $finalBits = self::interleaveWithEcBytes( - $headerAndDataBits, - $version->getTotalCodewords(), - $numDataBytes, - $ecBlocks->getNumBlocks() - ); - - // Choose the mask pattern. - $dimension = $version->getDimensionForVersion(); - $matrix = new ByteMatrix($dimension, $dimension); - $maskPattern = self::chooseMaskPattern($finalBits, $ecLevel, $version, $matrix); - - // Build the matrix. - MatrixUtil::buildMatrix($finalBits, $ecLevel, $version, $maskPattern, $matrix); - - return new QrCode($mode, $ecLevel, $version, $maskPattern, $matrix); - } - - /** - * Gets the alphanumeric code for a byte. - */ - private static function getAlphanumericCode(int $code) : int - { - if (isset(self::ALPHANUMERIC_TABLE[$code])) { - return self::ALPHANUMERIC_TABLE[$code]; - } - - return -1; - } - - /** - * Chooses the best mode for a given content. - */ - private static function chooseMode(string $content, string $encoding = null) : Mode - { - if (null !== $encoding && 0 === strcasecmp($encoding, 'SHIFT-JIS')) { - return self::isOnlyDoubleByteKanji($content) ? Mode::KANJI() : Mode::BYTE(); - } - - $hasNumeric = false; - $hasAlphanumeric = false; - $contentLength = strlen($content); - - for ($i = 0; $i < $contentLength; ++$i) { - $char = $content[$i]; - - if (ctype_digit($char)) { - $hasNumeric = true; - } elseif (-1 !== self::getAlphanumericCode(ord($char))) { - $hasAlphanumeric = true; - } else { - return Mode::BYTE(); - } - } - - if ($hasAlphanumeric) { - return Mode::ALPHANUMERIC(); - } elseif ($hasNumeric) { - return Mode::NUMERIC(); - } - - return Mode::BYTE(); - } - - /** - * Calculates the mask penalty for a matrix. - */ - private static function calculateMaskPenalty(ByteMatrix $matrix) : int - { - return ( - MaskUtil::applyMaskPenaltyRule1($matrix) - + MaskUtil::applyMaskPenaltyRule2($matrix) - + MaskUtil::applyMaskPenaltyRule3($matrix) - + MaskUtil::applyMaskPenaltyRule4($matrix) - ); - } - - /** - * Checks if content only consists of double-byte kanji characters. - */ - private static function isOnlyDoubleByteKanji(string $content) : bool - { - $bytes = @iconv('utf-8', 'SHIFT-JIS', $content); - - if (false === $bytes) { - return false; - } - - $length = strlen($bytes); - - if (0 !== $length % 2) { - return false; - } - - for ($i = 0; $i < $length; $i += 2) { - $byte = $bytes[$i] & 0xff; - - if (($byte < 0x81 || $byte > 0x9f) && $byte < 0xe0 || $byte > 0xeb) { - return false; - } - } - - return true; - } - - /** - * Chooses the best mask pattern for a matrix. - */ - private static function chooseMaskPattern( - BitArray $bits, - ErrorCorrectionLevel $ecLevel, - Version $version, - ByteMatrix $matrix - ) : int { - $minPenalty = PHP_INT_MAX; - $bestMaskPattern = -1; - - for ($maskPattern = 0; $maskPattern < QrCode::NUM_MASK_PATTERNS; ++$maskPattern) { - MatrixUtil::buildMatrix($bits, $ecLevel, $version, $maskPattern, $matrix); - $penalty = self::calculateMaskPenalty($matrix); - - if ($penalty < $minPenalty) { - $minPenalty = $penalty; - $bestMaskPattern = $maskPattern; - } - } - - return $bestMaskPattern; - } - - /** - * Chooses the best version for the input. - * - * @throws WriterException if data is too big - */ - private static function chooseVersion(int $numInputBits, ErrorCorrectionLevel $ecLevel) : Version - { - for ($versionNum = 1; $versionNum <= 40; ++$versionNum) { - $version = Version::getVersionForNumber($versionNum); - $numBytes = $version->getTotalCodewords(); - - $ecBlocks = $version->getEcBlocksForLevel($ecLevel); - $numEcBytes = $ecBlocks->getTotalEcCodewords(); - - $numDataBytes = $numBytes - $numEcBytes; - $totalInputBytes = intdiv($numInputBits + 8, 8); - - if ($numDataBytes >= $totalInputBytes) { - return $version; - } - } - - throw new WriterException('Data too big'); - } - - /** - * Terminates the bits in a bit array. - * - * @throws WriterException if data bits cannot fit in the QR code - * @throws WriterException if bits size does not equal the capacity - */ - private static function terminateBits(int $numDataBytes, BitArray $bits) : void - { - $capacity = $numDataBytes << 3; - - if ($bits->getSize() > $capacity) { - throw new WriterException('Data bits cannot fit in the QR code'); - } - - for ($i = 0; $i < 4 && $bits->getSize() < $capacity; ++$i) { - $bits->appendBit(false); - } - - $numBitsInLastByte = $bits->getSize() & 0x7; - - if ($numBitsInLastByte > 0) { - for ($i = $numBitsInLastByte; $i < 8; ++$i) { - $bits->appendBit(false); - } - } - - $numPaddingBytes = $numDataBytes - $bits->getSizeInBytes(); - - for ($i = 0; $i < $numPaddingBytes; ++$i) { - $bits->appendBits(0 === ($i & 0x1) ? 0xec : 0x11, 8); - } - - if ($bits->getSize() !== $capacity) { - throw new WriterException('Bits size does not equal capacity'); - } - } - - /** - * Gets number of data- and EC bytes for a block ID. - * - * @return int[] - * @throws WriterException if block ID is too large - * @throws WriterException if EC bytes mismatch - * @throws WriterException if RS blocks mismatch - * @throws WriterException if total bytes mismatch - */ - private static function getNumDataBytesAndNumEcBytesForBlockId( - int $numTotalBytes, - int $numDataBytes, - int $numRsBlocks, - int $blockId - ) : array { - if ($blockId >= $numRsBlocks) { - throw new WriterException('Block ID too large'); - } - - $numRsBlocksInGroup2 = $numTotalBytes % $numRsBlocks; - $numRsBlocksInGroup1 = $numRsBlocks - $numRsBlocksInGroup2; - $numTotalBytesInGroup1 = intdiv($numTotalBytes, $numRsBlocks); - $numTotalBytesInGroup2 = $numTotalBytesInGroup1 + 1; - $numDataBytesInGroup1 = intdiv($numDataBytes, $numRsBlocks); - $numDataBytesInGroup2 = $numDataBytesInGroup1 + 1; - $numEcBytesInGroup1 = $numTotalBytesInGroup1 - $numDataBytesInGroup1; - $numEcBytesInGroup2 = $numTotalBytesInGroup2 - $numDataBytesInGroup2; - - if ($numEcBytesInGroup1 !== $numEcBytesInGroup2) { - throw new WriterException('EC bytes mismatch'); - } - - if ($numRsBlocks !== $numRsBlocksInGroup1 + $numRsBlocksInGroup2) { - throw new WriterException('RS blocks mismatch'); - } - - if ($numTotalBytes !== - (($numDataBytesInGroup1 + $numEcBytesInGroup1) * $numRsBlocksInGroup1) - + (($numDataBytesInGroup2 + $numEcBytesInGroup2) * $numRsBlocksInGroup2) - ) { - throw new WriterException('Total bytes mismatch'); - } - - if ($blockId < $numRsBlocksInGroup1) { - return [$numDataBytesInGroup1, $numEcBytesInGroup1]; - } else { - return [$numDataBytesInGroup2, $numEcBytesInGroup2]; - } - } - - /** - * Interleaves data with EC bytes. - * - * @throws WriterException if number of bits and data bytes does not match - * @throws WriterException if data bytes does not match offset - * @throws WriterException if an interleaving error occurs - */ - private static function interleaveWithEcBytes( - BitArray $bits, - int $numTotalBytes, - int $numDataBytes, - int $numRsBlocks - ) : BitArray { - if ($bits->getSizeInBytes() !== $numDataBytes) { - throw new WriterException('Number of bits and data bytes does not match'); - } - - $dataBytesOffset = 0; - $maxNumDataBytes = 0; - $maxNumEcBytes = 0; - - $blocks = new SplFixedArray($numRsBlocks); - - for ($i = 0; $i < $numRsBlocks; ++$i) { - list($numDataBytesInBlock, $numEcBytesInBlock) = self::getNumDataBytesAndNumEcBytesForBlockId( - $numTotalBytes, - $numDataBytes, - $numRsBlocks, - $i - ); - - $size = $numDataBytesInBlock; - $dataBytes = $bits->toBytes(8 * $dataBytesOffset, $size); - $ecBytes = self::generateEcBytes($dataBytes, $numEcBytesInBlock); - $blocks[$i] = new BlockPair($dataBytes, $ecBytes); - - $maxNumDataBytes = max($maxNumDataBytes, $size); - $maxNumEcBytes = max($maxNumEcBytes, count($ecBytes)); - $dataBytesOffset += $numDataBytesInBlock; - } - - if ($numDataBytes !== $dataBytesOffset) { - throw new WriterException('Data bytes does not match offset'); - } - - $result = new BitArray(); - - for ($i = 0; $i < $maxNumDataBytes; ++$i) { - foreach ($blocks as $block) { - $dataBytes = $block->getDataBytes(); - - if ($i < count($dataBytes)) { - $result->appendBits($dataBytes[$i], 8); - } - } - } - - for ($i = 0; $i < $maxNumEcBytes; ++$i) { - foreach ($blocks as $block) { - $ecBytes = $block->getErrorCorrectionBytes(); - - if ($i < count($ecBytes)) { - $result->appendBits($ecBytes[$i], 8); - } - } - } - - if ($numTotalBytes !== $result->getSizeInBytes()) { - throw new WriterException( - 'Interleaving error: ' . $numTotalBytes . ' and ' . $result->getSizeInBytes() . ' differ' - ); - } - - return $result; - } - - /** - * Generates EC bytes for given data. - * - * @param SplFixedArray $dataBytes - * @return SplFixedArray - */ - private static function generateEcBytes(SplFixedArray $dataBytes, int $numEcBytesInBlock) : SplFixedArray - { - $numDataBytes = count($dataBytes); - $toEncode = new SplFixedArray($numDataBytes + $numEcBytesInBlock); - - for ($i = 0; $i < $numDataBytes; $i++) { - $toEncode[$i] = $dataBytes[$i] & 0xff; - } - - $ecBytes = new SplFixedArray($numEcBytesInBlock); - $codec = self::getCodec($numDataBytes, $numEcBytesInBlock); - $codec->encode($toEncode, $ecBytes); - - return $ecBytes; - } - - /** - * Gets an RS codec and caches it. - */ - private static function getCodec(int $numDataBytes, int $numEcBytesInBlock) : ReedSolomonCodec - { - $cacheId = $numDataBytes . '-' . $numEcBytesInBlock; - - if (isset(self::$codecs[$cacheId])) { - return self::$codecs[$cacheId]; - } - - return self::$codecs[$cacheId] = new ReedSolomonCodec( - 8, - 0x11d, - 0, - 1, - $numEcBytesInBlock, - 255 - $numDataBytes - $numEcBytesInBlock - ); - } - - /** - * Appends mode information to a bit array. - */ - private static function appendModeInfo(Mode $mode, BitArray $bits) : void - { - $bits->appendBits($mode->getBits(), 4); - } - - /** - * Appends length information to a bit array. - * - * @throws WriterException if num letters is bigger than expected - */ - private static function appendLengthInfo(int $numLetters, Version $version, Mode $mode, BitArray $bits) : void - { - $numBits = $mode->getCharacterCountBits($version); - - if ($numLetters >= (1 << $numBits)) { - throw new WriterException($numLetters . ' is bigger than ' . ((1 << $numBits) - 1)); - } - - $bits->appendBits($numLetters, $numBits); - } - - /** - * Appends bytes to a bit array in a specific mode. - * - * @throws WriterException if an invalid mode was supplied - */ - private static function appendBytes(string $content, Mode $mode, BitArray $bits, string $encoding) : void - { - switch ($mode) { - case Mode::NUMERIC(): - self::appendNumericBytes($content, $bits); - break; - - case Mode::ALPHANUMERIC(): - self::appendAlphanumericBytes($content, $bits); - break; - - case Mode::BYTE(): - self::append8BitBytes($content, $bits, $encoding); - break; - - case Mode::KANJI(): - self::appendKanjiBytes($content, $bits); - break; - - default: - throw new WriterException('Invalid mode: ' . $mode); - } - } - - /** - * Appends numeric bytes to a bit array. - */ - private static function appendNumericBytes(string $content, BitArray $bits) : void - { - $length = strlen($content); - $i = 0; - - while ($i < $length) { - $num1 = (int) $content[$i]; - - if ($i + 2 < $length) { - // Encode three numeric letters in ten bits. - $num2 = (int) $content[$i + 1]; - $num3 = (int) $content[$i + 2]; - $bits->appendBits($num1 * 100 + $num2 * 10 + $num3, 10); - $i += 3; - } elseif ($i + 1 < $length) { - // Encode two numeric letters in seven bits. - $num2 = (int) $content[$i + 1]; - $bits->appendBits($num1 * 10 + $num2, 7); - $i += 2; - } else { - // Encode one numeric letter in four bits. - $bits->appendBits($num1, 4); - ++$i; - } - } - } - - /** - * Appends alpha-numeric bytes to a bit array. - * - * @throws WriterException if an invalid alphanumeric code was found - */ - private static function appendAlphanumericBytes(string $content, BitArray $bits) : void - { - $length = strlen($content); - $i = 0; - - while ($i < $length) { - $code1 = self::getAlphanumericCode(ord($content[$i])); - - if (-1 === $code1) { - throw new WriterException('Invalid alphanumeric code'); - } - - if ($i + 1 < $length) { - $code2 = self::getAlphanumericCode(ord($content[$i + 1])); - - if (-1 === $code2) { - throw new WriterException('Invalid alphanumeric code'); - } - - // Encode two alphanumeric letters in 11 bits. - $bits->appendBits($code1 * 45 + $code2, 11); - $i += 2; - } else { - // Encode one alphanumeric letter in six bits. - $bits->appendBits($code1, 6); - ++$i; - } - } - } - - /** - * Appends regular 8-bit bytes to a bit array. - * - * @throws WriterException if content cannot be encoded to target encoding - */ - private static function append8BitBytes(string $content, BitArray $bits, string $encoding) : void - { - $bytes = @iconv('utf-8', $encoding, $content); - - if (false === $bytes) { - throw new WriterException('Could not encode content to ' . $encoding); - } - - $length = strlen($bytes); - - for ($i = 0; $i < $length; $i++) { - $bits->appendBits(ord($bytes[$i]), 8); - } - } - - /** - * Appends KANJI bytes to a bit array. - * - * @throws WriterException if content does not seem to be encoded in SHIFT-JIS - * @throws WriterException if an invalid byte sequence occurs - */ - private static function appendKanjiBytes(string $content, BitArray $bits) : void - { - if (strlen($content) % 2 > 0) { - // We just do a simple length check here. The for loop will check - // individual characters. - throw new WriterException('Content does not seem to be encoded in SHIFT-JIS'); - } - - $length = strlen($content); - - for ($i = 0; $i < $length; $i += 2) { - $byte1 = ord($content[$i]) & 0xff; - $byte2 = ord($content[$i + 1]) & 0xff; - $code = ($byte1 << 8) | $byte2; - - if ($code >= 0x8140 && $code <= 0x9ffc) { - $subtracted = $code - 0x8140; - } elseif ($code >= 0xe040 && $code <= 0xebbf) { - $subtracted = $code - 0xc140; - } else { - throw new WriterException('Invalid byte sequence'); - } - - $encoded = (($subtracted >> 8) * 0xc0) + ($subtracted & 0xff); - - $bits->appendBits($encoded, 13); - } - } - - /** - * Appends ECI information to a bit array. - */ - private static function appendEci(CharacterSetEci $eci, BitArray $bits) : void - { - $mode = Mode::ECI(); - $bits->appendBits($mode->getBits(), 4); - $bits->appendBits($eci->getValue(), 8); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php b/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php deleted file mode 100644 index ba97dfb..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php +++ /dev/null @@ -1,271 +0,0 @@ -getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height - 1; ++$y) { - for ($x = 0; $x < $width - 1; ++$x) { - $value = $array[$y][$x]; - - if ($value === $array[$y][$x + 1] - && $value === $array[$y + 1][$x] - && $value === $array[$y + 1][$x + 1] - ) { - ++$penalty; - } - } - } - - return self::N2 * $penalty; - } - - /** - * Applies mask penalty rule 3 and returns the penalty. - * - * Finds consecutive cells of 00001011101 or 10111010000, and gives penalty - * to them. If we find patterns like 000010111010000, we give penalties - * twice (i.e. 40 * 2). - */ - public static function applyMaskPenaltyRule3(ByteMatrix $matrix) : int - { - $penalty = 0; - $array = $matrix->getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height; ++$y) { - for ($x = 0; $x < $width; ++$x) { - if ($x + 6 < $width - && 1 === $array[$y][$x] - && 0 === $array[$y][$x + 1] - && 1 === $array[$y][$x + 2] - && 1 === $array[$y][$x + 3] - && 1 === $array[$y][$x + 4] - && 0 === $array[$y][$x + 5] - && 1 === $array[$y][$x + 6] - && ( - ( - $x + 10 < $width - && 0 === $array[$y][$x + 7] - && 0 === $array[$y][$x + 8] - && 0 === $array[$y][$x + 9] - && 0 === $array[$y][$x + 10] - ) - || ( - $x - 4 >= 0 - && 0 === $array[$y][$x - 1] - && 0 === $array[$y][$x - 2] - && 0 === $array[$y][$x - 3] - && 0 === $array[$y][$x - 4] - ) - ) - ) { - $penalty += self::N3; - } - - if ($y + 6 < $height - && 1 === $array[$y][$x] - && 0 === $array[$y + 1][$x] - && 1 === $array[$y + 2][$x] - && 1 === $array[$y + 3][$x] - && 1 === $array[$y + 4][$x] - && 0 === $array[$y + 5][$x] - && 1 === $array[$y + 6][$x] - && ( - ( - $y + 10 < $height - && 0 === $array[$y + 7][$x] - && 0 === $array[$y + 8][$x] - && 0 === $array[$y + 9][$x] - && 0 === $array[$y + 10][$x] - ) - || ( - $y - 4 >= 0 - && 0 === $array[$y - 1][$x] - && 0 === $array[$y - 2][$x] - && 0 === $array[$y - 3][$x] - && 0 === $array[$y - 4][$x] - ) - ) - ) { - $penalty += self::N3; - } - } - } - - return $penalty; - } - - /** - * Applies mask penalty rule 4 and returns the penalty. - * - * Calculates the ratio of dark cells and gives penalty if the ratio is far - * from 50%. It gives 10 penalty for 5% distance. - */ - public static function applyMaskPenaltyRule4(ByteMatrix $matrix) : int - { - $numDarkCells = 0; - - $array = $matrix->getArray(); - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - - for ($y = 0; $y < $height; ++$y) { - $arrayY = $array[$y]; - - for ($x = 0; $x < $width; ++$x) { - if (1 === $arrayY[$x]) { - ++$numDarkCells; - } - } - } - - $numTotalCells = $height * $width; - $darkRatio = $numDarkCells / $numTotalCells; - $fixedPercentVariances = (int) (abs($darkRatio - 0.5) * 20); - - return $fixedPercentVariances * self::N4; - } - - /** - * Returns the mask bit for "getMaskPattern" at "x" and "y". - * - * See 8.8 of JISX0510:2004 for mask pattern conditions. - * - * @throws InvalidArgumentException if an invalid mask pattern was supplied - */ - public static function getDataMaskBit(int $maskPattern, int $x, int $y) : bool - { - switch ($maskPattern) { - case 0: - $intermediate = ($y + $x) & 0x1; - break; - - case 1: - $intermediate = $y & 0x1; - break; - - case 2: - $intermediate = $x % 3; - break; - - case 3: - $intermediate = ($y + $x) % 3; - break; - - case 4: - $intermediate = (BitUtils::unsignedRightShift($y, 1) + (int) ($x / 3)) & 0x1; - break; - - case 5: - $temp = $y * $x; - $intermediate = ($temp & 0x1) + ($temp % 3); - break; - - case 6: - $temp = $y * $x; - $intermediate = (($temp & 0x1) + ($temp % 3)) & 0x1; - break; - - case 7: - $temp = $y * $x; - $intermediate = (($temp % 3) + (($y + $x) & 0x1)) & 0x1; - break; - - default: - throw new InvalidArgumentException('Invalid mask pattern: ' . $maskPattern); - } - - return 0 == $intermediate; - } - - /** - * Helper function for applyMaskPenaltyRule1. - * - * We need this for doing this calculation in both vertical and horizontal - * orders respectively. - */ - private static function applyMaskPenaltyRule1Internal(ByteMatrix $matrix, bool $isHorizontal) : int - { - $penalty = 0; - $iLimit = $isHorizontal ? $matrix->getHeight() : $matrix->getWidth(); - $jLimit = $isHorizontal ? $matrix->getWidth() : $matrix->getHeight(); - $array = $matrix->getArray(); - - for ($i = 0; $i < $iLimit; ++$i) { - $numSameBitCells = 0; - $prevBit = -1; - - for ($j = 0; $j < $jLimit; $j++) { - $bit = $isHorizontal ? $array[$i][$j] : $array[$j][$i]; - - if ($bit === $prevBit) { - ++$numSameBitCells; - } else { - if ($numSameBitCells >= 5) { - $penalty += self::N1 + ($numSameBitCells - 5); - } - - $numSameBitCells = 1; - $prevBit = $bit; - } - } - - if ($numSameBitCells >= 5) { - $penalty += self::N1 + ($numSameBitCells - 5); - } - } - - return $penalty; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/MatrixUtil.php b/vendor/bacon/bacon-qr-code/src/Encoder/MatrixUtil.php deleted file mode 100644 index 0967e29..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/MatrixUtil.php +++ /dev/null @@ -1,513 +0,0 @@ -clear(-1); - } - - /** - * Builds a complete matrix. - */ - public static function buildMatrix( - BitArray $dataBits, - ErrorCorrectionLevel $level, - Version $version, - int $maskPattern, - ByteMatrix $matrix - ) : void { - self::clearMatrix($matrix); - self::embedBasicPatterns($version, $matrix); - self::embedTypeInfo($level, $maskPattern, $matrix); - self::maybeEmbedVersionInfo($version, $matrix); - self::embedDataBits($dataBits, $maskPattern, $matrix); - } - - /** - * Removes the position detection patterns from a matrix. - * - * This can be useful if you need to render those patterns separately. - */ - public static function removePositionDetectionPatterns(ByteMatrix $matrix) : void - { - $pdpWidth = count(self::POSITION_DETECTION_PATTERN[0]); - - self::removePositionDetectionPattern(0, 0, $matrix); - self::removePositionDetectionPattern($matrix->getWidth() - $pdpWidth, 0, $matrix); - self::removePositionDetectionPattern(0, $matrix->getWidth() - $pdpWidth, $matrix); - } - - /** - * Embeds type information into a matrix. - */ - private static function embedTypeInfo(ErrorCorrectionLevel $level, int $maskPattern, ByteMatrix $matrix) : void - { - $typeInfoBits = new BitArray(); - self::makeTypeInfoBits($level, $maskPattern, $typeInfoBits); - - $typeInfoBitsSize = $typeInfoBits->getSize(); - - for ($i = 0; $i < $typeInfoBitsSize; ++$i) { - $bit = $typeInfoBits->get($typeInfoBitsSize - 1 - $i); - - $x1 = self::TYPE_INFO_COORDINATES[$i][0]; - $y1 = self::TYPE_INFO_COORDINATES[$i][1]; - - $matrix->set($x1, $y1, (int) $bit); - - if ($i < 8) { - $x2 = $matrix->getWidth() - $i - 1; - $y2 = 8; - } else { - $x2 = 8; - $y2 = $matrix->getHeight() - 7 + ($i - 8); - } - - $matrix->set($x2, $y2, (int) $bit); - } - } - - /** - * Generates type information bits and appends them to a bit array. - * - * @throws RuntimeException if bit array resulted in invalid size - */ - private static function makeTypeInfoBits(ErrorCorrectionLevel $level, int $maskPattern, BitArray $bits) : void - { - $typeInfo = ($level->getBits() << 3) | $maskPattern; - $bits->appendBits($typeInfo, 5); - - $bchCode = self::calculateBchCode($typeInfo, self::TYPE_INFO_POLY); - $bits->appendBits($bchCode, 10); - - $maskBits = new BitArray(); - $maskBits->appendBits(self::TYPE_INFO_MASK_PATTERN, 15); - $bits->xorBits($maskBits); - - if (15 !== $bits->getSize()) { - throw new RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize()); - } - } - - /** - * Embeds version information if required. - */ - private static function maybeEmbedVersionInfo(Version $version, ByteMatrix $matrix) : void - { - if ($version->getVersionNumber() < 7) { - return; - } - - $versionInfoBits = new BitArray(); - self::makeVersionInfoBits($version, $versionInfoBits); - - $bitIndex = 6 * 3 - 1; - - for ($i = 0; $i < 6; ++$i) { - for ($j = 0; $j < 3; ++$j) { - $bit = $versionInfoBits->get($bitIndex); - --$bitIndex; - - $matrix->set($i, $matrix->getHeight() - 11 + $j, (int) $bit); - $matrix->set($matrix->getHeight() - 11 + $j, $i, (int) $bit); - } - } - } - - /** - * Generates version information bits and appends them to a bit array. - * - * @throws RuntimeException if bit array resulted in invalid size - */ - private static function makeVersionInfoBits(Version $version, BitArray $bits) : void - { - $bits->appendBits($version->getVersionNumber(), 6); - - $bchCode = self::calculateBchCode($version->getVersionNumber(), self::VERSION_INFO_POLY); - $bits->appendBits($bchCode, 12); - - if (18 !== $bits->getSize()) { - throw new RuntimeException('Bit array resulted in invalid size: ' . $bits->getSize()); - } - } - - /** - * Calculates the BCH code for a value and a polynomial. - */ - private static function calculateBchCode(int $value, int $poly) : int - { - $msbSetInPoly = self::findMsbSet($poly); - $value <<= $msbSetInPoly - 1; - - while (self::findMsbSet($value) >= $msbSetInPoly) { - $value ^= $poly << (self::findMsbSet($value) - $msbSetInPoly); - } - - return $value; - } - - /** - * Finds and MSB set. - */ - private static function findMsbSet(int $value) : int - { - $numDigits = 0; - - while (0 !== $value) { - $value >>= 1; - ++$numDigits; - } - - return $numDigits; - } - - /** - * Embeds basic patterns into a matrix. - */ - private static function embedBasicPatterns(Version $version, ByteMatrix $matrix) : void - { - self::embedPositionDetectionPatternsAndSeparators($matrix); - self::embedDarkDotAtLeftBottomCorner($matrix); - self::maybeEmbedPositionAdjustmentPatterns($version, $matrix); - self::embedTimingPatterns($matrix); - } - - /** - * Embeds position detection patterns and separators into a byte matrix. - */ - private static function embedPositionDetectionPatternsAndSeparators(ByteMatrix $matrix) : void - { - $pdpWidth = count(self::POSITION_DETECTION_PATTERN[0]); - - self::embedPositionDetectionPattern(0, 0, $matrix); - self::embedPositionDetectionPattern($matrix->getWidth() - $pdpWidth, 0, $matrix); - self::embedPositionDetectionPattern(0, $matrix->getWidth() - $pdpWidth, $matrix); - - $hspWidth = 8; - - self::embedHorizontalSeparationPattern(0, $hspWidth - 1, $matrix); - self::embedHorizontalSeparationPattern($matrix->getWidth() - $hspWidth, $hspWidth - 1, $matrix); - self::embedHorizontalSeparationPattern(0, $matrix->getWidth() - $hspWidth, $matrix); - - $vspSize = 7; - - self::embedVerticalSeparationPattern($vspSize, 0, $matrix); - self::embedVerticalSeparationPattern($matrix->getHeight() - $vspSize - 1, 0, $matrix); - self::embedVerticalSeparationPattern($vspSize, $matrix->getHeight() - $vspSize, $matrix); - } - - /** - * Embeds a single position detection pattern into a byte matrix. - */ - private static function embedPositionDetectionPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void - { - for ($y = 0; $y < 7; ++$y) { - for ($x = 0; $x < 7; ++$x) { - $matrix->set($xStart + $x, $yStart + $y, self::POSITION_DETECTION_PATTERN[$y][$x]); - } - } - } - - private static function removePositionDetectionPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void - { - for ($y = 0; $y < 7; ++$y) { - for ($x = 0; $x < 7; ++$x) { - $matrix->set($xStart + $x, $yStart + $y, 0); - } - } - } - - /** - * Embeds a single horizontal separation pattern. - * - * @throws RuntimeException if a byte was already set - */ - private static function embedHorizontalSeparationPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void - { - for ($x = 0; $x < 8; $x++) { - if (-1 !== $matrix->get($xStart + $x, $yStart)) { - throw new RuntimeException('Byte already set'); - } - - $matrix->set($xStart + $x, $yStart, 0); - } - } - - /** - * Embeds a single vertical separation pattern. - * - * @throws RuntimeException if a byte was already set - */ - private static function embedVerticalSeparationPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void - { - for ($y = 0; $y < 7; $y++) { - if (-1 !== $matrix->get($xStart, $yStart + $y)) { - throw new RuntimeException('Byte already set'); - } - - $matrix->set($xStart, $yStart + $y, 0); - } - } - - /** - * Embeds a dot at the left bottom corner. - * - * @throws RuntimeException if a byte was already set to 0 - */ - private static function embedDarkDotAtLeftBottomCorner(ByteMatrix $matrix) : void - { - if (0 === $matrix->get(8, $matrix->getHeight() - 8)) { - throw new RuntimeException('Byte already set to 0'); - } - - $matrix->set(8, $matrix->getHeight() - 8, 1); - } - - /** - * Embeds position adjustment patterns if required. - */ - private static function maybeEmbedPositionAdjustmentPatterns(Version $version, ByteMatrix $matrix) : void - { - if ($version->getVersionNumber() < 2) { - return; - } - - $index = $version->getVersionNumber() - 1; - - $coordinates = self::POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[$index]; - $numCoordinates = count($coordinates); - - for ($i = 0; $i < $numCoordinates; ++$i) { - for ($j = 0; $j < $numCoordinates; ++$j) { - $y = $coordinates[$i]; - $x = $coordinates[$j]; - - if (null === $x || null === $y) { - continue; - } - - if (-1 === $matrix->get($x, $y)) { - self::embedPositionAdjustmentPattern($x - 2, $y - 2, $matrix); - } - } - } - } - - /** - * Embeds a single position adjustment pattern. - */ - private static function embedPositionAdjustmentPattern(int $xStart, int $yStart, ByteMatrix $matrix) : void - { - for ($y = 0; $y < 5; $y++) { - for ($x = 0; $x < 5; $x++) { - $matrix->set($xStart + $x, $yStart + $y, self::POSITION_ADJUSTMENT_PATTERN[$y][$x]); - } - } - } - - /** - * Embeds timing patterns into a matrix. - */ - private static function embedTimingPatterns(ByteMatrix $matrix) : void - { - $matrixWidth = $matrix->getWidth(); - - for ($i = 8; $i < $matrixWidth - 8; ++$i) { - $bit = ($i + 1) % 2; - - if (-1 === $matrix->get($i, 6)) { - $matrix->set($i, 6, $bit); - } - - if (-1 === $matrix->get(6, $i)) { - $matrix->set(6, $i, $bit); - } - } - } - - /** - * Embeds "dataBits" using "getMaskPattern". - * - * For debugging purposes, it skips masking process if "getMaskPattern" is -1. See 8.7 of JISX0510:2004 (p.38) for - * how to embed data bits. - * - * @throws WriterException if not all bits could be consumed - */ - private static function embedDataBits(BitArray $dataBits, int $maskPattern, ByteMatrix $matrix) : void - { - $bitIndex = 0; - $direction = -1; - - // Start from the right bottom cell. - $x = $matrix->getWidth() - 1; - $y = $matrix->getHeight() - 1; - - while ($x > 0) { - // Skip vertical timing pattern. - if (6 === $x) { - --$x; - } - - while ($y >= 0 && $y < $matrix->getHeight()) { - for ($i = 0; $i < 2; $i++) { - $xx = $x - $i; - - // Skip the cell if it's not empty. - if (-1 !== $matrix->get($xx, $y)) { - continue; - } - - if ($bitIndex < $dataBits->getSize()) { - $bit = $dataBits->get($bitIndex); - ++$bitIndex; - } else { - // Padding bit. If there is no bit left, we'll fill the - // left cells with 0, as described in 8.4.9 of - // JISX0510:2004 (p. 24). - $bit = false; - } - - // Skip masking if maskPattern is -1. - if (-1 !== $maskPattern && MaskUtil::getDataMaskBit($maskPattern, $xx, $y)) { - $bit = ! $bit; - } - - $matrix->set($xx, $y, (int) $bit); - } - - $y += $direction; - } - - $direction = -$direction; - $y += $direction; - $x -= 2; - } - - // All bits should be consumed - if ($dataBits->getSize() !== $bitIndex) { - throw new WriterException('Not all bits consumed (' . $bitIndex . ' out of ' . $dataBits->getSize() .')'); - } - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Encoder/QrCode.php b/vendor/bacon/bacon-qr-code/src/Encoder/QrCode.php deleted file mode 100644 index f568e88..0000000 --- a/vendor/bacon/bacon-qr-code/src/Encoder/QrCode.php +++ /dev/null @@ -1,141 +0,0 @@ -mode = $mode; - $this->errorCorrectionLevel = $errorCorrectionLevel; - $this->version = $version; - $this->maskPattern = $maskPattern; - $this->matrix = $matrix; - } - - /** - * Gets the mode. - */ - public function getMode() : Mode - { - return $this->mode; - } - - /** - * Gets the EC level. - */ - public function getErrorCorrectionLevel() : ErrorCorrectionLevel - { - return $this->errorCorrectionLevel; - } - - /** - * Gets the version. - */ - public function getVersion() : Version - { - return $this->version; - } - - /** - * Gets the mask pattern. - */ - public function getMaskPattern() : int - { - return $this->maskPattern; - } - - /** - * Gets the matrix. - * - * @return ByteMatrix - */ - public function getMatrix() - { - return $this->matrix; - } - - /** - * Validates whether a mask pattern is valid. - */ - public static function isValidMaskPattern(int $maskPattern) : bool - { - return $maskPattern > 0 && $maskPattern < self::NUM_MASK_PATTERNS; - } - - /** - * Returns a string representation of the QR code. - */ - public function __toString() : string - { - $result = "<<\n" - . ' mode: ' . $this->mode . "\n" - . ' ecLevel: ' . $this->errorCorrectionLevel . "\n" - . ' version: ' . $this->version . "\n" - . ' maskPattern: ' . $this->maskPattern . "\n"; - - if ($this->matrix === null) { - $result .= " matrix: null\n"; - } else { - $result .= " matrix:\n"; - $result .= $this->matrix; - } - - $result .= ">>\n"; - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Exception/ExceptionInterface.php b/vendor/bacon/bacon-qr-code/src/Exception/ExceptionInterface.php deleted file mode 100644 index 6f70c20..0000000 --- a/vendor/bacon/bacon-qr-code/src/Exception/ExceptionInterface.php +++ /dev/null @@ -1,10 +0,0 @@ - 100) { - throw new Exception\InvalidArgumentException('Alpha must be between 0 and 100'); - } - - $this->alpha = $alpha; - $this->baseColor = $baseColor; - } - - public function getAlpha() : int - { - return $this->alpha; - } - - public function getBaseColor() : ColorInterface - { - return $this->baseColor; - } - - public function toRgb() : Rgb - { - return $this->baseColor->toRgb(); - } - - public function toCmyk() : Cmyk - { - return $this->baseColor->toCmyk(); - } - - public function toGray() : Gray - { - return $this->baseColor->toGray(); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Color/Cmyk.php b/vendor/bacon/bacon-qr-code/src/Renderer/Color/Cmyk.php deleted file mode 100644 index d6de390..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Color/Cmyk.php +++ /dev/null @@ -1,103 +0,0 @@ - 100) { - throw new Exception\InvalidArgumentException('Cyan must be between 0 and 100'); - } - - if ($magenta < 0 || $magenta > 100) { - throw new Exception\InvalidArgumentException('Magenta must be between 0 and 100'); - } - - if ($yellow < 0 || $yellow > 100) { - throw new Exception\InvalidArgumentException('Yellow must be between 0 and 100'); - } - - if ($black < 0 || $black > 100) { - throw new Exception\InvalidArgumentException('Black must be between 0 and 100'); - } - - $this->cyan = $cyan; - $this->magenta = $magenta; - $this->yellow = $yellow; - $this->black = $black; - } - - public function getCyan() : int - { - return $this->cyan; - } - - public function getMagenta() : int - { - return $this->magenta; - } - - public function getYellow() : int - { - return $this->yellow; - } - - public function getBlack() : int - { - return $this->black; - } - - public function toRgb() : Rgb - { - $k = $this->black / 100; - $c = (-$k * $this->cyan + $k * 100 + $this->cyan) / 100; - $m = (-$k * $this->magenta + $k * 100 + $this->magenta) / 100; - $y = (-$k * $this->yellow + $k * 100 + $this->yellow) / 100; - - return new Rgb( - (int) (-$c * 255 + 255), - (int) (-$m * 255 + 255), - (int) (-$y * 255 + 255) - ); - } - - public function toCmyk() : Cmyk - { - return $this; - } - - public function toGray() : Gray - { - return $this->toRgb()->toGray(); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Color/ColorInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/Color/ColorInterface.php deleted file mode 100644 index b50d1ca..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Color/ColorInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - 100) { - throw new Exception\InvalidArgumentException('Gray must be between 0 and 100'); - } - - $this->gray = (int) $gray; - } - - public function getGray() : int - { - return $this->gray; - } - - public function toRgb() : Rgb - { - return new Rgb((int) ($this->gray * 2.55), (int) ($this->gray * 2.55), (int) ($this->gray * 2.55)); - } - - public function toCmyk() : Cmyk - { - return new Cmyk(0, 0, 0, 100 - $this->gray); - } - - public function toGray() : Gray - { - return $this; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Color/Rgb.php b/vendor/bacon/bacon-qr-code/src/Renderer/Color/Rgb.php deleted file mode 100644 index 7935406..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Color/Rgb.php +++ /dev/null @@ -1,88 +0,0 @@ - 255) { - throw new Exception\InvalidArgumentException('Red must be between 0 and 255'); - } - - if ($green < 0 || $green > 255) { - throw new Exception\InvalidArgumentException('Green must be between 0 and 255'); - } - - if ($blue < 0 || $blue > 255) { - throw new Exception\InvalidArgumentException('Blue must be between 0 and 255'); - } - - $this->red = $red; - $this->green = $green; - $this->blue = $blue; - } - - public function getRed() : int - { - return $this->red; - } - - public function getGreen() : int - { - return $this->green; - } - - public function getBlue() : int - { - return $this->blue; - } - - public function toRgb() : Rgb - { - return $this; - } - - public function toCmyk() : Cmyk - { - $c = 1 - ($this->red / 255); - $m = 1 - ($this->green / 255); - $y = 1 - ($this->blue / 255); - $k = min($c, $m, $y); - - return new Cmyk( - (int) (100 * ($c - $k) / (1 - $k)), - (int) (100 * ($m - $k) / (1 - $k)), - (int) (100 * ($y - $k) / (1 - $k)), - (int) (100 * $k) - ); - } - - public function toGray() : Gray - { - return new Gray((int) (($this->red * 0.21 + $this->green * 0.71 + $this->blue * 0.07) / 2.55)); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/CompositeEye.php b/vendor/bacon/bacon-qr-code/src/Renderer/Eye/CompositeEye.php deleted file mode 100644 index 0d03125..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/CompositeEye.php +++ /dev/null @@ -1,38 +0,0 @@ -externalEye = $externalEye; - $this->internalEye = $internalEye; - } - - public function getExternalPath() : Path - { - return $this->externalEye->getExternalPath(); - } - - public function getInternalPath() : Path - { - return $this->internalEye->getInternalPath(); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/EyeInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/Eye/EyeInterface.php deleted file mode 100644 index ab68f3c..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/EyeInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -module = $module; - } - - public function getExternalPath() : Path - { - $matrix = new ByteMatrix(7, 7); - - for ($x = 0; $x < 7; ++$x) { - $matrix->set($x, 0, 1); - $matrix->set($x, 6, 1); - } - - for ($y = 1; $y < 6; ++$y) { - $matrix->set(0, $y, 1); - $matrix->set(6, $y, 1); - } - - return $this->module->createPath($matrix)->translate(-3.5, -3.5); - } - - public function getInternalPath() : Path - { - $matrix = new ByteMatrix(3, 3); - - for ($x = 0; $x < 3; ++$x) { - for ($y = 0; $y < 3; ++$y) { - $matrix->set($x, $y, 1); - } - } - - return $this->module->createPath($matrix)->translate(-1.5, -1.5); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SimpleCircleEye.php b/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SimpleCircleEye.php deleted file mode 100644 index 64d54ee..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SimpleCircleEye.php +++ /dev/null @@ -1,54 +0,0 @@ -move(-3.5, -3.5) - ->line(3.5, -3.5) - ->line(3.5, 3.5) - ->line(-3.5, 3.5) - ->close() - ->move(-2.5, -2.5) - ->line(-2.5, 2.5) - ->line(2.5, 2.5) - ->line(2.5, -2.5) - ->close() - ; - } - - public function getInternalPath() : Path - { - return (new Path()) - ->move(1.5, 0) - ->ellipticArc(1.5, 1.5, 0., false, true, 0., 1.5) - ->ellipticArc(1.5, 1.5, 0., false, true, -1.5, 0.) - ->ellipticArc(1.5, 1.5, 0., false, true, 0., -1.5) - ->ellipticArc(1.5, 1.5, 0., false, true, 1.5, 0.) - ->close() - ; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SquareEye.php b/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SquareEye.php deleted file mode 100644 index a3892b4..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Eye/SquareEye.php +++ /dev/null @@ -1,53 +0,0 @@ -move(-3.5, -3.5) - ->line(3.5, -3.5) - ->line(3.5, 3.5) - ->line(-3.5, 3.5) - ->close() - ->move(-2.5, -2.5) - ->line(-2.5, 2.5) - ->line(2.5, 2.5) - ->line(2.5, -2.5) - ->close() - ; - } - - public function getInternalPath() : Path - { - return (new Path()) - ->move(-1.5, -1.5) - ->line(1.5, -1.5) - ->line(1.5, 1.5) - ->line(-1.5, 1.5) - ->close() - ; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Image/EpsImageBackEnd.php b/vendor/bacon/bacon-qr-code/src/Renderer/Image/EpsImageBackEnd.php deleted file mode 100644 index b581b54..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Image/EpsImageBackEnd.php +++ /dev/null @@ -1,376 +0,0 @@ -eps = "%!PS-Adobe-3.0 EPSF-3.0\n" - . "%%Creator: BaconQrCode\n" - . sprintf("%%%%BoundingBox: 0 0 %d %d \n", $size, $size) - . "%%BeginProlog\n" - . "save\n" - . "50 dict begin\n" - . "/q { gsave } bind def\n" - . "/Q { grestore } bind def\n" - . "/s { scale } bind def\n" - . "/t { translate } bind def\n" - . "/r { rotate } bind def\n" - . "/n { newpath } bind def\n" - . "/m { moveto } bind def\n" - . "/l { lineto } bind def\n" - . "/c { curveto } bind def\n" - . "/z { closepath } bind def\n" - . "/f { eofill } bind def\n" - . "/rgb { setrgbcolor } bind def\n" - . "/cmyk { setcmykcolor } bind def\n" - . "/gray { setgray } bind def\n" - . "%%EndProlog\n" - . "1 -1 s\n" - . sprintf("0 -%d t\n", $size); - - if ($backgroundColor instanceof Alpha && 0 === $backgroundColor->getAlpha()) { - return; - } - - $this->eps .= wordwrap( - '0 0 m' - . sprintf(' %s 0 l', (string) $size) - . sprintf(' %s %s l', (string) $size, (string) $size) - . sprintf(' 0 %s l', (string) $size) - . ' z' - . ' ' .$this->getColorSetString($backgroundColor) . " f\n", - 75, - "\n " - ); - } - - public function scale(float $size) : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= sprintf("%1\$s %1\$s s\n", round($size, self::PRECISION)); - } - - public function translate(float $x, float $y) : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= sprintf("%s %s t\n", round($x, self::PRECISION), round($y, self::PRECISION)); - } - - public function rotate(int $degrees) : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= sprintf("%d r\n", $degrees); - } - - public function push() : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= "q\n"; - } - - public function pop() : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= "Q\n"; - } - - public function drawPathWithColor(Path $path, ColorInterface $color) : void - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $fromX = 0; - $fromY = 0; - $this->eps .= wordwrap( - 'n ' - . $this->drawPathOperations($path, $fromX, $fromY) - . ' ' . $this->getColorSetString($color) . " f\n", - 75, - "\n " - ); - } - - public function drawPathWithGradient( - Path $path, - Gradient $gradient, - float $x, - float $y, - float $width, - float $height - ) : void { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $fromX = 0; - $fromY = 0; - $this->eps .= wordwrap( - 'q n ' . $this->drawPathOperations($path, $fromX, $fromY) . "\n", - 75, - "\n " - ); - - $this->createGradientFill($gradient, $x, $y, $width, $height); - } - - public function done() : string - { - if (null === $this->eps) { - throw new RuntimeException('No image has been started'); - } - - $this->eps .= "%%TRAILER\nend restore\n%%EOF"; - $blob = $this->eps; - $this->eps = null; - - return $blob; - } - - private function drawPathOperations(Iterable $ops, &$fromX, &$fromY) : string - { - $pathData = []; - - foreach ($ops as $op) { - switch (true) { - case $op instanceof Move: - $fromX = $toX = round($op->getX(), self::PRECISION); - $fromY = $toY = round($op->getY(), self::PRECISION); - $pathData[] = sprintf('%s %s m', $toX, $toY); - break; - - case $op instanceof Line: - $fromX = $toX = round($op->getX(), self::PRECISION); - $fromY = $toY = round($op->getY(), self::PRECISION); - $pathData[] = sprintf('%s %s l', $toX, $toY); - break; - - case $op instanceof EllipticArc: - $pathData[] = $this->drawPathOperations($op->toCurves($fromX, $fromY), $fromX, $fromY); - break; - - case $op instanceof Curve: - $x1 = round($op->getX1(), self::PRECISION); - $y1 = round($op->getY1(), self::PRECISION); - $x2 = round($op->getX2(), self::PRECISION); - $y2 = round($op->getY2(), self::PRECISION); - $fromX = $x3 = round($op->getX3(), self::PRECISION); - $fromY = $y3 = round($op->getY3(), self::PRECISION); - $pathData[] = sprintf('%s %s %s %s %s %s c', $x1, $y1, $x2, $y2, $x3, $y3); - break; - - case $op instanceof Close: - $pathData[] = 'z'; - break; - - default: - throw new RuntimeException('Unexpected draw operation: ' . get_class($op)); - } - } - - return implode(' ', $pathData); - } - - private function createGradientFill(Gradient $gradient, float $x, float $y, float $width, float $height) : void - { - $startColor = $gradient->getStartColor(); - $endColor = $gradient->getEndColor(); - - if ($startColor instanceof Alpha) { - $startColor = $startColor->getBaseColor(); - } - - $startColorType = get_class($startColor); - - if (! in_array($startColorType, [Rgb::class, Cmyk::class, Gray::class])) { - $startColorType = Cmyk::class; - $startColor = $startColor->toCmyk(); - } - - if (get_class($endColor) !== $startColorType) { - switch ($startColorType) { - case Cmyk::class: - $endColor = $endColor->toCmyk(); - break; - - case Rgb::class: - $endColor = $endColor->toRgb(); - break; - - case Gray::class: - $endColor = $endColor->toGray(); - break; - } - } - - $this->eps .= "eoclip\n<<\n"; - - if ($gradient->getType() === GradientType::RADIAL()) { - $this->eps .= " /ShadingType 3\n"; - } else { - $this->eps .= " /ShadingType 2\n"; - } - - $this->eps .= " /Extend [ true true ]\n" - . " /AntiAlias true\n"; - - switch ($startColorType) { - case Cmyk::class: - $this->eps .= " /ColorSpace /DeviceCMYK\n"; - break; - - case Rgb::class: - $this->eps .= " /ColorSpace /DeviceRGB\n"; - break; - - case Gray::class: - $this->eps .= " /ColorSpace /DeviceGray\n"; - break; - } - - switch ($gradient->getType()) { - case GradientType::HORIZONTAL(): - $this->eps .= sprintf( - " /Coords [ %s %s %s %s ]\n", - round($x, self::PRECISION), - round($y, self::PRECISION), - round($x + $width, self::PRECISION), - round($y, self::PRECISION) - ); - break; - - case GradientType::VERTICAL(): - $this->eps .= sprintf( - " /Coords [ %s %s %s %s ]\n", - round($x, self::PRECISION), - round($y, self::PRECISION), - round($x, self::PRECISION), - round($y + $height, self::PRECISION) - ); - break; - - case GradientType::DIAGONAL(): - $this->eps .= sprintf( - " /Coords [ %s %s %s %s ]\n", - round($x, self::PRECISION), - round($y, self::PRECISION), - round($x + $width, self::PRECISION), - round($y + $height, self::PRECISION) - ); - break; - - case GradientType::INVERSE_DIAGONAL(): - $this->eps .= sprintf( - " /Coords [ %s %s %s %s ]\n", - round($x, self::PRECISION), - round($y + $height, self::PRECISION), - round($x + $width, self::PRECISION), - round($y, self::PRECISION) - ); - break; - - case GradientType::RADIAL(): - $centerX = ($x + $width) / 2; - $centerY = ($y + $height) / 2; - - $this->eps .= sprintf( - " /Coords [ %s %s 0 %s %s %s ]\n", - round($centerX, self::PRECISION), - round($centerY, self::PRECISION), - round($centerX, self::PRECISION), - round($centerY, self::PRECISION), - round(max($width, $height) / 2, self::PRECISION) - ); - break; - } - - $this->eps .= " /Function\n" - . " <<\n" - . " /FunctionType 2\n" - . " /Domain [ 0 1 ]\n" - . sprintf(" /C0 [ %s ]\n", $this->getColorString($startColor)) - . sprintf(" /C1 [ %s ]\n", $this->getColorString($endColor)) - . " /N 1\n" - . " >>\n>>\nshfill\nQ\n"; - } - - private function getColorSetString(ColorInterface $color) : string - { - if ($color instanceof Rgb) { - return $this->getColorString($color) . ' rgb'; - } - - if ($color instanceof Cmyk) { - return $this->getColorString($color) . ' cmyk'; - } - - if ($color instanceof Gray) { - return $this->getColorString($color) . ' gray'; - } - - return $this->getColorSetString($color->toCmyk()); - } - - private function getColorString(ColorInterface $color) : string - { - if ($color instanceof Rgb) { - return sprintf('%s %s %s', $color->getRed() / 255, $color->getGreen() / 255, $color->getBlue() / 255); - } - - if ($color instanceof Cmyk) { - return sprintf( - '%s %s %s %s', - $color->getCyan() / 100, - $color->getMagenta() / 100, - $color->getYellow() / 100, - $color->getBlack() / 100 - ); - } - - if ($color instanceof Gray) { - return sprintf('%s', $color->getGray() / 100); - } - - return $this->getColorString($color->toCmyk()); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Image/ImageBackEndInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/Image/ImageBackEndInterface.php deleted file mode 100644 index 0935819..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Image/ImageBackEndInterface.php +++ /dev/null @@ -1,87 +0,0 @@ -imageFormat = $imageFormat; - $this->compressionQuality = $compressionQuality; - } - - public function new(int $size, ColorInterface $backgroundColor) : void - { - $this->image = new Imagick(); - $this->image->newImage($size, $size, $this->getColorPixel($backgroundColor)); - $this->image->setImageFormat($this->imageFormat); - $this->image->setCompressionQuality($this->compressionQuality); - $this->draw = new ImagickDraw(); - $this->gradientCount = 0; - $this->matrices = [new TransformationMatrix()]; - $this->matrixIndex = 0; - } - - public function scale(float $size) : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->scale($size, $size); - $this->matrices[$this->matrixIndex] = $this->matrices[$this->matrixIndex] - ->multiply(TransformationMatrix::scale($size)); - } - - public function translate(float $x, float $y) : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->translate($x, $y); - $this->matrices[$this->matrixIndex] = $this->matrices[$this->matrixIndex] - ->multiply(TransformationMatrix::translate($x, $y)); - } - - public function rotate(int $degrees) : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->rotate($degrees); - $this->matrices[$this->matrixIndex] = $this->matrices[$this->matrixIndex] - ->multiply(TransformationMatrix::rotate($degrees)); - } - - public function push() : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->push(); - $this->matrices[++$this->matrixIndex] = $this->matrices[$this->matrixIndex - 1]; - } - - public function pop() : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->pop(); - unset($this->matrices[$this->matrixIndex--]); - } - - public function drawPathWithColor(Path $path, ColorInterface $color) : void - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->setFillColor($this->getColorPixel($color)); - $this->drawPath($path); - } - - public function drawPathWithGradient( - Path $path, - Gradient $gradient, - float $x, - float $y, - float $width, - float $height - ) : void { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->draw->setFillPatternURL('#' . $this->createGradientFill($gradient, $x, $y, $width, $height)); - $this->drawPath($path); - } - - public function done() : string - { - if (null === $this->draw) { - throw new RuntimeException('No image has been started'); - } - - $this->image->drawImage($this->draw); - $blob = $this->image->getImageBlob(); - $this->draw->clear(); - $this->image->clear(); - $this->draw = null; - $this->image = null; - $this->gradientCount = null; - - return $blob; - } - - private function drawPath(Path $path) : void - { - $this->draw->pathStart(); - - foreach ($path as $op) { - switch (true) { - case $op instanceof Move: - $this->draw->pathMoveToAbsolute($op->getX(), $op->getY()); - break; - - case $op instanceof Line: - $this->draw->pathLineToAbsolute($op->getX(), $op->getY()); - break; - - case $op instanceof EllipticArc: - $this->draw->pathEllipticArcAbsolute( - $op->getXRadius(), - $op->getYRadius(), - $op->getXAxisAngle(), - $op->isLargeArc(), - $op->isSweep(), - $op->getX(), - $op->getY() - ); - break; - - case $op instanceof Curve: - $this->draw->pathCurveToAbsolute( - $op->getX1(), - $op->getY1(), - $op->getX2(), - $op->getY2(), - $op->getX3(), - $op->getY3() - ); - break; - - case $op instanceof Close: - $this->draw->pathClose(); - break; - - default: - throw new RuntimeException('Unexpected draw operation: ' . get_class($op)); - } - } - - $this->draw->pathFinish(); - } - - private function createGradientFill(Gradient $gradient, float $x, float $y, float $width, float $height) : string - { - list($width, $height) = $this->matrices[$this->matrixIndex]->apply($width, $height); - - $startColor = $this->getColorPixel($gradient->getStartColor())->getColorAsString(); - $endColor = $this->getColorPixel($gradient->getEndColor())->getColorAsString(); - $gradientImage = new Imagick(); - - switch ($gradient->getType()) { - case GradientType::HORIZONTAL(): - $gradientImage->newPseudoImage((int) $height, (int) $width, sprintf( - 'gradient:%s-%s', - $startColor, - $endColor - )); - $gradientImage->rotateImage('transparent', -90); - break; - - case GradientType::VERTICAL(): - $gradientImage->newPseudoImage((int) $width, (int) $height, sprintf( - 'gradient:%s-%s', - $startColor, - $endColor - )); - break; - - case GradientType::DIAGONAL(): - case GradientType::INVERSE_DIAGONAL(): - $gradientImage->newPseudoImage((int) ($width * sqrt(2)), (int) ($height * sqrt(2)), sprintf( - 'gradient:%s-%s', - $startColor, - $endColor - )); - - if (GradientType::DIAGONAL() === $gradient->getType()) { - $gradientImage->rotateImage('transparent', -45); - } else { - $gradientImage->rotateImage('transparent', -135); - } - - $rotatedWidth = $gradientImage->getImageWidth(); - $rotatedHeight = $gradientImage->getImageHeight(); - - $gradientImage->setImagePage($rotatedWidth, $rotatedHeight, 0, 0); - $gradientImage->cropImage( - intdiv($rotatedWidth, 2) - 2, - intdiv($rotatedHeight, 2) - 2, - intdiv($rotatedWidth, 4) + 1, - intdiv($rotatedWidth, 4) + 1 - ); - break; - - case GradientType::RADIAL(): - $gradientImage->newPseudoImage((int) $width, (int) $height, sprintf( - 'radial-gradient:%s-%s', - $startColor, - $endColor - )); - break; - } - - $id = sprintf('g%d', ++$this->gradientCount); - $this->draw->pushPattern($id, 0, 0, $width, $height); - $this->draw->composite(Imagick::COMPOSITE_COPY, 0, 0, $width, $height, $gradientImage); - $this->draw->popPattern(); - return $id; - } - - private function getColorPixel(ColorInterface $color) : ImagickPixel - { - $alpha = 100; - - if ($color instanceof Alpha) { - $alpha = $color->getAlpha(); - $color = $color->getBaseColor(); - } - - if ($color instanceof Rgb) { - return new ImagickPixel(sprintf( - 'rgba(%d, %d, %d, %F)', - $color->getRed(), - $color->getGreen(), - $color->getBlue(), - $alpha / 100 - )); - } - - if ($color instanceof Cmyk) { - return new ImagickPixel(sprintf( - 'cmyka(%d, %d, %d, %d, %F)', - $color->getCyan(), - $color->getMagenta(), - $color->getYellow(), - $color->getBlack(), - $alpha / 100 - )); - } - - if ($color instanceof Gray) { - return new ImagickPixel(sprintf( - 'graya(%d%%, %F)', - $color->getGray(), - $alpha / 100 - )); - } - - return $this->getColorPixel(new Alpha($alpha, $color->toRgb())); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Image/SvgImageBackEnd.php b/vendor/bacon/bacon-qr-code/src/Renderer/Image/SvgImageBackEnd.php deleted file mode 100644 index cb37a9f..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Image/SvgImageBackEnd.php +++ /dev/null @@ -1,369 +0,0 @@ -xmlWriter = new XMLWriter(); - $this->xmlWriter->openMemory(); - - $this->xmlWriter->startDocument('1.0', 'UTF-8'); - $this->xmlWriter->startElement('svg'); - $this->xmlWriter->writeAttribute('xmlns', 'http://www.w3.org/2000/svg'); - $this->xmlWriter->writeAttribute('version', '1.1'); - $this->xmlWriter->writeAttribute('width', (string) $size); - $this->xmlWriter->writeAttribute('height', (string) $size); - $this->xmlWriter->writeAttribute('viewBox', '0 0 '. $size . ' ' . $size); - - $this->gradientCount = 0; - $this->currentStack = 0; - $this->stack[0] = 0; - - $alpha = 1; - - if ($backgroundColor instanceof Alpha) { - $alpha = $backgroundColor->getAlpha() / 100; - } - - if (0 === $alpha) { - return; - } - - $this->xmlWriter->startElement('rect'); - $this->xmlWriter->writeAttribute('x', '0'); - $this->xmlWriter->writeAttribute('y', '0'); - $this->xmlWriter->writeAttribute('width', (string) $size); - $this->xmlWriter->writeAttribute('height', (string) $size); - $this->xmlWriter->writeAttribute('fill', $this->getColorString($backgroundColor)); - - if ($alpha < 1) { - $this->xmlWriter->writeAttribute('fill-opacity', (string) $alpha); - } - - $this->xmlWriter->endElement(); - } - - public function scale(float $size) : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $this->xmlWriter->startElement('g'); - $this->xmlWriter->writeAttribute( - 'transform', - sprintf('scale(%s)', round($size, self::PRECISION)) - ); - ++$this->stack[$this->currentStack]; - } - - public function translate(float $x, float $y) : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $this->xmlWriter->startElement('g'); - $this->xmlWriter->writeAttribute( - 'transform', - sprintf('translate(%s,%s)', round($x, self::PRECISION), round($y, self::PRECISION)) - ); - ++$this->stack[$this->currentStack]; - } - - public function rotate(int $degrees) : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $this->xmlWriter->startElement('g'); - $this->xmlWriter->writeAttribute('transform', sprintf('rotate(%d)', $degrees)); - ++$this->stack[$this->currentStack]; - } - - public function push() : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $this->xmlWriter->startElement('g'); - $this->stack[] = 1; - ++$this->currentStack; - } - - public function pop() : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - for ($i = 0; $i < $this->stack[$this->currentStack]; ++$i) { - $this->xmlWriter->endElement(); - } - - array_pop($this->stack); - --$this->currentStack; - } - - public function drawPathWithColor(Path $path, ColorInterface $color) : void - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $alpha = 1; - - if ($color instanceof Alpha) { - $alpha = $color->getAlpha() / 100; - } - - $this->startPathElement($path); - $this->xmlWriter->writeAttribute('fill', $this->getColorString($color)); - - if ($alpha < 1) { - $this->xmlWriter->writeAttribute('fill-opacity', (string) $alpha); - } - - $this->xmlWriter->endElement(); - } - - public function drawPathWithGradient( - Path $path, - Gradient $gradient, - float $x, - float $y, - float $width, - float $height - ) : void { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - $gradientId = $this->createGradientFill($gradient, $x, $y, $width, $height); - $this->startPathElement($path); - $this->xmlWriter->writeAttribute('fill', 'url(#' . $gradientId . ')'); - $this->xmlWriter->endElement(); - } - - public function done() : string - { - if (null === $this->xmlWriter) { - throw new RuntimeException('No image has been started'); - } - - foreach ($this->stack as $openElements) { - for ($i = $openElements; $i > 0; --$i) { - $this->xmlWriter->endElement(); - } - } - - $this->xmlWriter->endDocument(); - $blob = $this->xmlWriter->outputMemory(true); - $this->xmlWriter = null; - $this->stack = null; - $this->currentStack = null; - $this->gradientCount = null; - - return $blob; - } - - private function startPathElement(Path $path) : void - { - $pathData = []; - - foreach ($path as $op) { - switch (true) { - case $op instanceof Move: - $pathData[] = sprintf( - 'M%s %s', - round($op->getX(), self::PRECISION), - round($op->getY(), self::PRECISION) - ); - break; - - case $op instanceof Line: - $pathData[] = sprintf( - 'L%s %s', - round($op->getX(), self::PRECISION), - round($op->getY(), self::PRECISION) - ); - break; - - case $op instanceof EllipticArc: - $pathData[] = sprintf( - 'A%s %s %s %u %u %s %s', - round($op->getXRadius(), self::PRECISION), - round($op->getYRadius(), self::PRECISION), - round($op->getXAxisAngle(), self::PRECISION), - $op->isLargeArc(), - $op->isSweep(), - round($op->getX(), self::PRECISION), - round($op->getY(), self::PRECISION) - ); - break; - - case $op instanceof Curve: - $pathData[] = sprintf( - 'C%s %s %s %s %s %s', - round($op->getX1(), self::PRECISION), - round($op->getY1(), self::PRECISION), - round($op->getX2(), self::PRECISION), - round($op->getY2(), self::PRECISION), - round($op->getX3(), self::PRECISION), - round($op->getY3(), self::PRECISION) - ); - break; - - case $op instanceof Close: - $pathData[] = 'Z'; - break; - - default: - throw new RuntimeException('Unexpected draw operation: ' . get_class($op)); - } - } - - $this->xmlWriter->startElement('path'); - $this->xmlWriter->writeAttribute('fill-rule', 'evenodd'); - $this->xmlWriter->writeAttribute('d', implode('', $pathData)); - } - - private function createGradientFill(Gradient $gradient, float $x, float $y, float $width, float $height) : string - { - $this->xmlWriter->startElement('defs'); - - $startColor = $gradient->getStartColor(); - $endColor = $gradient->getEndColor(); - - if ($gradient->getType() === GradientType::RADIAL()) { - $this->xmlWriter->startElement('radialGradient'); - } else { - $this->xmlWriter->startElement('linearGradient'); - } - - $this->xmlWriter->writeAttribute('gradientUnits', 'userSpaceOnUse'); - - switch ($gradient->getType()) { - case GradientType::HORIZONTAL(): - $this->xmlWriter->writeAttribute('x1', (string) round($x, self::PRECISION)); - $this->xmlWriter->writeAttribute('y1', (string) round($y, self::PRECISION)); - $this->xmlWriter->writeAttribute('x2', (string) round($x + $width, self::PRECISION)); - $this->xmlWriter->writeAttribute('y2', (string) round($y, self::PRECISION)); - break; - - case GradientType::VERTICAL(): - $this->xmlWriter->writeAttribute('x1', (string) round($x, self::PRECISION)); - $this->xmlWriter->writeAttribute('y1', (string) round($y, self::PRECISION)); - $this->xmlWriter->writeAttribute('x2', (string) round($x, self::PRECISION)); - $this->xmlWriter->writeAttribute('y2', (string) round($y + $height, self::PRECISION)); - break; - - case GradientType::DIAGONAL(): - $this->xmlWriter->writeAttribute('x1', (string) round($x, self::PRECISION)); - $this->xmlWriter->writeAttribute('y1', (string) round($y, self::PRECISION)); - $this->xmlWriter->writeAttribute('x2', (string) round($x + $width, self::PRECISION)); - $this->xmlWriter->writeAttribute('y2', (string) round($y + $height, self::PRECISION)); - break; - - case GradientType::INVERSE_DIAGONAL(): - $this->xmlWriter->writeAttribute('x1', (string) round($x, self::PRECISION)); - $this->xmlWriter->writeAttribute('y1', (string) round($y + $height, self::PRECISION)); - $this->xmlWriter->writeAttribute('x2', (string) round($x + $width, self::PRECISION)); - $this->xmlWriter->writeAttribute('y2', (string) round($y, self::PRECISION)); - break; - - case GradientType::RADIAL(): - $this->xmlWriter->writeAttribute('cx', (string) round(($x + $width) / 2, self::PRECISION)); - $this->xmlWriter->writeAttribute('cy', (string) round(($y + $height) / 2, self::PRECISION)); - $this->xmlWriter->writeAttribute('r', (string) round(max($width, $height) / 2, self::PRECISION)); - break; - } - - $id = sprintf('g%d', ++$this->gradientCount); - $this->xmlWriter->writeAttribute('id', $id); - - $this->xmlWriter->startElement('stop'); - $this->xmlWriter->writeAttribute('offset', '0%'); - $this->xmlWriter->writeAttribute('stop-color', $this->getColorString($startColor)); - - if ($startColor instanceof Alpha) { - $this->xmlWriter->writeAttribute('stop-opacity', (string) $startColor->getAlpha()); - } - - $this->xmlWriter->endElement(); - - $this->xmlWriter->startElement('stop'); - $this->xmlWriter->writeAttribute('offset', '100%'); - $this->xmlWriter->writeAttribute('stop-color', $this->getColorString($endColor)); - - if ($endColor instanceof Alpha) { - $this->xmlWriter->writeAttribute('stop-opacity', (string) $endColor->getAlpha()); - } - - $this->xmlWriter->endElement(); - - $this->xmlWriter->endElement(); - $this->xmlWriter->endElement(); - - return $id; - } - - private function getColorString(ColorInterface $color) : string - { - $color = $color->toRgb(); - - return sprintf( - '#%02x%02x%02x', - $color->getRed(), - $color->getGreen(), - $color->getBlue() - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Image/TransformationMatrix.php b/vendor/bacon/bacon-qr-code/src/Renderer/Image/TransformationMatrix.php deleted file mode 100644 index 7e88da6..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Image/TransformationMatrix.php +++ /dev/null @@ -1,68 +0,0 @@ -values = [1, 0, 0, 1, 0, 0]; - } - - public function multiply(self $other) : self - { - $matrix = new self(); - $matrix->values[0] = $this->values[0] * $other->values[0] + $this->values[2] * $other->values[1]; - $matrix->values[1] = $this->values[1] * $other->values[0] + $this->values[3] * $other->values[1]; - $matrix->values[2] = $this->values[0] * $other->values[2] + $this->values[2] * $other->values[3]; - $matrix->values[3] = $this->values[1] * $other->values[2] + $this->values[3] * $other->values[3]; - $matrix->values[4] = $this->values[0] * $other->values[4] + $this->values[2] * $other->values[5] - + $this->values[4]; - $matrix->values[5] = $this->values[1] * $other->values[4] + $this->values[3] * $other->values[5] - + $this->values[5]; - - return $matrix; - } - - public static function scale(float $size) : self - { - $matrix = new self(); - $matrix->values = [$size, 0, 0, $size, 0, 0]; - return $matrix; - } - - public static function translate(float $x, float $y) : self - { - $matrix = new self(); - $matrix->values = [1, 0, 0, 1, $x, $y]; - return $matrix; - } - - public static function rotate(int $degrees) : self - { - $matrix = new self(); - $rad = deg2rad($degrees); - $matrix->values = [cos($rad), sin($rad), -sin($rad), cos($rad), 0, 0]; - return $matrix; - } - - - /** - * Applies this matrix onto a point and returns the resulting viewport point. - * - * @return float[] - */ - public function apply(float $x, float $y) : array - { - return [ - $x * $this->values[0] + $y * $this->values[2] + $this->values[4], - $x * $this->values[1] + $y * $this->values[3] + $this->values[5], - ]; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php b/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php deleted file mode 100644 index ab16276..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php +++ /dev/null @@ -1,152 +0,0 @@ -rendererStyle = $rendererStyle; - $this->imageBackEnd = $imageBackEnd; - } - - /** - * @throws InvalidArgumentException if matrix width doesn't match height - */ - public function render(QrCode $qrCode) : string - { - $size = $this->rendererStyle->getSize(); - $margin = $this->rendererStyle->getMargin(); - $matrix = $qrCode->getMatrix(); - $matrixSize = $matrix->getWidth(); - - if ($matrixSize !== $matrix->getHeight()) { - throw new InvalidArgumentException('Matrix must have the same width and height'); - } - - $totalSize = $matrixSize + ($margin * 2); - $moduleSize = $size / $totalSize; - $fill = $this->rendererStyle->getFill(); - - $this->imageBackEnd->new($size, $fill->getBackgroundColor()); - $this->imageBackEnd->scale((float) $moduleSize); - $this->imageBackEnd->translate((float) $margin, (float) $margin); - - $module = $this->rendererStyle->getModule(); - $moduleMatrix = clone $matrix; - MatrixUtil::removePositionDetectionPatterns($moduleMatrix); - $modulePath = $this->drawEyes($matrixSize, $module->createPath($moduleMatrix)); - - if ($fill->hasGradientFill()) { - $this->imageBackEnd->drawPathWithGradient( - $modulePath, - $fill->getForegroundGradient(), - 0, - 0, - $matrixSize, - $matrixSize - ); - } else { - $this->imageBackEnd->drawPathWithColor($modulePath, $fill->getForegroundColor()); - } - - return $this->imageBackEnd->done(); - } - - private function drawEyes(int $matrixSize, Path $modulePath) : Path - { - $fill = $this->rendererStyle->getFill(); - - $eye = $this->rendererStyle->getEye(); - $externalPath = $eye->getExternalPath(); - $internalPath = $eye->getInternalPath(); - - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getTopLeftEyeFill(), - 3.5, - 3.5, - 0, - $modulePath - ); - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getTopRightEyeFill(), - $matrixSize - 3.5, - 3.5, - 90, - $modulePath - ); - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getBottomLeftEyeFill(), - 3.5, - $matrixSize - 3.5, - -90, - $modulePath - ); - - return $modulePath; - } - - private function drawEye( - Path $externalPath, - Path $internalPath, - EyeFill $fill, - float $xTranslation, - float $yTranslation, - int $rotation, - Path $modulePath - ) : Path { - if ($fill->inheritsBothColors()) { - return $modulePath - ->append($externalPath->translate($xTranslation, $yTranslation)) - ->append($internalPath->translate($xTranslation, $yTranslation)); - } - - $this->imageBackEnd->push(); - $this->imageBackEnd->translate($xTranslation, $yTranslation); - - if (0 !== $rotation) { - $this->imageBackEnd->rotate($rotation); - } - - if ($fill->inheritsExternalColor()) { - $modulePath = $modulePath->append($externalPath->translate($xTranslation, $yTranslation)); - } else { - $this->imageBackEnd->drawPathWithColor($externalPath, $fill->getExternalColor()); - } - - if ($fill->inheritsInternalColor()) { - $modulePath = $modulePath->append($internalPath->translate($xTranslation, $yTranslation)); - } else { - $this->imageBackEnd->drawPathWithColor($internalPath, $fill->getInternalColor()); - } - - $this->imageBackEnd->pop(); - - return $modulePath; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Module/DotsModule.php b/vendor/bacon/bacon-qr-code/src/Renderer/Module/DotsModule.php deleted file mode 100644 index f536e5a..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Module/DotsModule.php +++ /dev/null @@ -1,63 +0,0 @@ - 1) { - throw new InvalidArgumentException('Size must between 0 (exclusive) and 1 (inclusive)'); - } - - $this->size = $size; - } - - public function createPath(ByteMatrix $matrix) : Path - { - $width = $matrix->getWidth(); - $height = $matrix->getHeight(); - $path = new Path(); - $halfSize = $this->size / 2; - $margin = (1 - $this->size) / 2; - - for ($y = 0; $y < $height; ++$y) { - for ($x = 0; $x < $width; ++$x) { - if (! $matrix->get($x, $y)) { - continue; - } - - $pathX = $x + $margin; - $pathY = $y + $margin; - - $path = $path - ->move($pathX + $this->size, $pathY + $halfSize) - ->ellipticArc($halfSize, $halfSize, 0, false, true, $pathX + $halfSize, $pathY + $this->size) - ->ellipticArc($halfSize, $halfSize, 0, false, true, $pathX, $pathY + $halfSize) - ->ellipticArc($halfSize, $halfSize, 0, false, true, $pathX + $halfSize, $pathY) - ->ellipticArc($halfSize, $halfSize, 0, false, true, $pathX + $this->size, $pathY + $halfSize) - ->close() - ; - } - } - - return $path; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/Edge.php b/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/Edge.php deleted file mode 100644 index 90482f2..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/Edge.php +++ /dev/null @@ -1,100 +0,0 @@ - - */ - private $points = []; - - /** - * @var array|null - */ - private $simplifiedPoints; - - /** - * @var int - */ - private $minX = PHP_INT_MAX; - - /** - * @var int - */ - private $minY = PHP_INT_MAX; - - /** - * @var int - */ - private $maxX = -1; - - /** - * @var int - */ - private $maxY = -1; - - public function __construct(bool $positive) - { - $this->positive = $positive; - } - - public function addPoint(int $x, int $y) : void - { - $this->points[] = [$x, $y]; - $this->minX = min($this->minX, $x); - $this->minY = min($this->minY, $y); - $this->maxX = max($this->maxX, $x); - $this->maxY = max($this->maxY, $y); - } - - public function isPositive() : bool - { - return $this->positive; - } - - /** - * @return array - */ - public function getPoints() : array - { - return $this->points; - } - - public function getMaxX() : int - { - return $this->maxX; - } - - public function getSimplifiedPoints() : array - { - if (null !== $this->simplifiedPoints) { - return $this->simplifiedPoints; - } - - $points = []; - $length = count($this->points); - - for ($i = 0; $i < $length; ++$i) { - $previousPoint = $this->points[(0 === $i ? $length : $i) - 1]; - $nextPoint = $this->points[($length - 1 === $i ? -1 : $i) + 1]; - $currentPoint = $this->points[$i]; - - if (($previousPoint[0] === $currentPoint[0] && $currentPoint[0] === $nextPoint[0]) - || ($previousPoint[1] === $currentPoint[1] && $currentPoint[1] === $nextPoint[1]) - ) { - continue; - } - - $points[] = $currentPoint; - } - - return $this->simplifiedPoints = $points; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/EdgeIterator.php b/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/EdgeIterator.php deleted file mode 100644 index eb29dc6..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Module/EdgeIterator/EdgeIterator.php +++ /dev/null @@ -1,169 +0,0 @@ -bytes = iterator_to_array($matrix->getBytes()); - $this->size = count($this->bytes); - $this->width = $matrix->getWidth(); - $this->height = $matrix->getHeight(); - } - - /** - * @return Traversable - */ - public function getIterator() : Traversable - { - $originalBytes = $this->bytes; - $point = $this->findNext(0, 0); - - while (null !== $point) { - $edge = $this->findEdge($point[0], $point[1]); - $this->xorEdge($edge); - - yield $edge; - - $point = $this->findNext($point[0], $point[1]); - } - - $this->bytes = $originalBytes; - } - - /** - * @return int[]|null - */ - private function findNext(int $x, int $y) : ?array - { - $i = $this->width * $y + $x; - - while ($i < $this->size && 1 !== $this->bytes[$i]) { - ++$i; - } - - if ($i < $this->size) { - return $this->pointOf($i); - } - - return null; - } - - private function findEdge(int $x, int $y) : Edge - { - $edge = new Edge($this->isSet($x, $y)); - $startX = $x; - $startY = $y; - $dirX = 0; - $dirY = 1; - - while (true) { - $edge->addPoint($x, $y); - $x += $dirX; - $y += $dirY; - - if ($x === $startX && $y === $startY) { - break; - } - - $left = $this->isSet($x + ($dirX + $dirY - 1 ) / 2, $y + ($dirY - $dirX - 1) / 2); - $right = $this->isSet($x + ($dirX - $dirY - 1) / 2, $y + ($dirY + $dirX - 1) / 2); - - if ($right && ! $left) { - $tmp = $dirX; - $dirX = -$dirY; - $dirY = $tmp; - } elseif ($right) { - $tmp = $dirX; - $dirX = -$dirY; - $dirY = $tmp; - } elseif (! $left) { - $tmp = $dirX; - $dirX = $dirY; - $dirY = -$tmp; - } - } - - return $edge; - } - - private function xorEdge(Edge $path) : void - { - $points = $path->getPoints(); - $y1 = $points[0][1]; - $length = count($points); - $maxX = $path->getMaxX(); - - for ($i = 1; $i < $length; ++$i) { - $y = $points[$i][1]; - - if ($y === $y1) { - continue; - } - - $x = $points[$i][0]; - $minY = min($y1, $y); - - for ($j = $x; $j < $maxX; ++$j) { - $this->flip($j, $minY); - } - - $y1 = $y; - } - } - - private function isSet(int $x, int $y) : bool - { - return ( - $x >= 0 - && $x < $this->width - && $y >= 0 - && $y < $this->height - ) && 1 === $this->bytes[$this->width * $y + $x]; - } - - /** - * @return int[] - */ - private function pointOf(int $i) : array - { - $y = intdiv($i, $this->width); - return [$i - $y * $this->width, $y]; - } - - private function flip(int $x, int $y) : void - { - $this->bytes[$this->width * $y + $x] = ( - $this->isSet($x, $y) ? 0 : 1 - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Module/ModuleInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/Module/ModuleInterface.php deleted file mode 100644 index 0ccb0e0..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Module/ModuleInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - 1) { - throw new InvalidArgumentException('Intensity must between 0 (exclusive) and 1 (inclusive)'); - } - - $this->intensity = $intensity / 2; - } - - public function createPath(ByteMatrix $matrix) : Path - { - $path = new Path(); - - foreach (new EdgeIterator($matrix) as $edge) { - $points = $edge->getSimplifiedPoints(); - $length = count($points); - - $currentPoint = $points[0]; - $nextPoint = $points[1]; - $horizontal = ($currentPoint[1] === $nextPoint[1]); - - if ($horizontal) { - $right = $nextPoint[0] > $currentPoint[0]; - $path = $path->move( - $currentPoint[0] + ($right ? $this->intensity : -$this->intensity), - $currentPoint[1] - ); - } else { - $up = $nextPoint[0] < $currentPoint[0]; - $path = $path->move( - $currentPoint[0], - $currentPoint[1] + ($up ? -$this->intensity : $this->intensity) - ); - } - - for ($i = 1; $i <= $length; ++$i) { - if ($i === $length) { - $previousPoint = $points[$length - 1]; - $currentPoint = $points[0]; - $nextPoint = $points[1]; - } else { - $previousPoint = $points[(0 === $i ? $length : $i) - 1]; - $currentPoint = $points[$i]; - $nextPoint = $points[($length - 1 === $i ? -1 : $i) + 1]; - } - - $horizontal = ($previousPoint[1] === $currentPoint[1]); - - if ($horizontal) { - $right = $previousPoint[0] < $currentPoint[0]; - $up = $nextPoint[1] < $currentPoint[1]; - $sweep = ($up xor $right); - - if ($this->intensity < 0.5 - || ($right && $previousPoint[0] !== $currentPoint[0] - 1) - || (! $right && $previousPoint[0] - 1 !== $currentPoint[0]) - ) { - $path = $path->line( - $currentPoint[0] + ($right ? -$this->intensity : $this->intensity), - $currentPoint[1] - ); - } - - $path = $path->ellipticArc( - $this->intensity, - $this->intensity, - 0, - false, - $sweep, - $currentPoint[0], - $currentPoint[1] + ($up ? -$this->intensity : $this->intensity) - ); - } else { - $up = $previousPoint[1] > $currentPoint[1]; - $right = $nextPoint[0] > $currentPoint[0]; - $sweep = ! ($up xor $right); - - if ($this->intensity < 0.5 - || ($up && $previousPoint[1] !== $currentPoint[1] + 1) - || (! $up && $previousPoint[0] + 1 !== $currentPoint[0]) - ) { - $path = $path->line( - $currentPoint[0], - $currentPoint[1] + ($up ? $this->intensity : -$this->intensity) - ); - } - - $path = $path->ellipticArc( - $this->intensity, - $this->intensity, - 0, - false, - $sweep, - $currentPoint[0] + ($right ? $this->intensity : -$this->intensity), - $currentPoint[1] - ); - } - } - - $path = $path->close(); - } - - return $path; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Module/SquareModule.php b/vendor/bacon/bacon-qr-code/src/Renderer/Module/SquareModule.php deleted file mode 100644 index 9ab4607..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Module/SquareModule.php +++ /dev/null @@ -1,47 +0,0 @@ -getSimplifiedPoints(); - $length = count($points); - $path = $path->move($points[0][0], $points[0][1]); - - for ($i = 1; $i < $length; ++$i) { - $path = $path->line($points[$i][0], $points[$i][1]); - } - - $path = $path->close(); - } - - return $path; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Close.php b/vendor/bacon/bacon-qr-code/src/Renderer/Path/Close.php deleted file mode 100644 index b07feb0..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Close.php +++ /dev/null @@ -1,29 +0,0 @@ -x1 = $x1; - $this->y1 = $y1; - $this->x2 = $x2; - $this->y2 = $y2; - $this->x3 = $x3; - $this->y3 = $y3; - } - - public function getX1() : float - { - return $this->x1; - } - - public function getY1() : float - { - return $this->y1; - } - - public function getX2() : float - { - return $this->x2; - } - - public function getY2() : float - { - return $this->y2; - } - - public function getX3() : float - { - return $this->x3; - } - - public function getY3() : float - { - return $this->y3; - } - - /** - * @return self - */ - public function translate(float $x, float $y) : OperationInterface - { - return new self( - $this->x1 + $x, - $this->y1 + $y, - $this->x2 + $x, - $this->y2 + $y, - $this->x3 + $x, - $this->y3 + $y - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Path/EllipticArc.php b/vendor/bacon/bacon-qr-code/src/Renderer/Path/EllipticArc.php deleted file mode 100644 index 9f2385a..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Path/EllipticArc.php +++ /dev/null @@ -1,278 +0,0 @@ -xRadius = abs($xRadius); - $this->yRadius = abs($yRadius); - $this->xAxisAngle = $xAxisAngle % 360; - $this->largeArc = $largeArc; - $this->sweep = $sweep; - $this->x = $x; - $this->y = $y; - } - - public function getXRadius() : float - { - return $this->xRadius; - } - - public function getYRadius() : float - { - return $this->yRadius; - } - - public function getXAxisAngle() : float - { - return $this->xAxisAngle; - } - - public function isLargeArc() : bool - { - return $this->largeArc; - } - - public function isSweep() : bool - { - return $this->sweep; - } - - public function getX() : float - { - return $this->x; - } - - public function getY() : float - { - return $this->y; - } - - /** - * @return self - */ - public function translate(float $x, float $y) : OperationInterface - { - return new self( - $this->xRadius, - $this->yRadius, - $this->xAxisAngle, - $this->largeArc, - $this->sweep, - $this->x + $x, - $this->y + $y - ); - } - - /** - * Converts the elliptic arc to multiple curves. - * - * Since not all image back ends support elliptic arcs, this method allows to convert the arc into multiple curves - * resembling the same result. - * - * @see https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ - * @return array - */ - public function toCurves(float $fromX, float $fromY) : array - { - if (sqrt(($fromX - $this->x) ** 2 + ($fromY - $this->y) ** 2) < self::ZERO_TOLERANCE) { - return []; - } - - if ($this->xRadius < self::ZERO_TOLERANCE || $this->yRadius < self::ZERO_TOLERANCE) { - return [new Line($this->x, $this->y)]; - } - - return $this->createCurves($fromX, $fromY); - } - - /** - * @return Curve[] - */ - private function createCurves(float $fromX, float $fromY) : array - { - $xAngle = deg2rad($this->xAxisAngle); - list($centerX, $centerY, $radiusX, $radiusY, $startAngle, $deltaAngle) = - $this->calculateCenterPointParameters($fromX, $fromY, $xAngle); - - $s = $startAngle; - $e = $s + $deltaAngle; - $sign = ($e < $s) ? -1 : 1; - $remain = abs($e - $s); - $p1 = self::point($centerX, $centerY, $radiusX, $radiusY, $xAngle, $s); - $curves = []; - - while ($remain > self::ZERO_TOLERANCE) { - $step = min($remain, pi() / 2); - $signStep = $step * $sign; - $p2 = self::point($centerX, $centerY, $radiusX, $radiusY, $xAngle, $s + $signStep); - - $alphaT = tan($signStep / 2); - $alpha = sin($signStep) * (sqrt(4 + 3 * $alphaT ** 2) - 1) / 3; - $d1 = self::derivative($radiusX, $radiusY, $xAngle, $s); - $d2 = self::derivative($radiusX, $radiusY, $xAngle, $s + $signStep); - - $curves[] = new Curve( - $p1[0] + $alpha * $d1[0], - $p1[1] + $alpha * $d1[1], - $p2[0] - $alpha * $d2[0], - $p2[1] - $alpha * $d2[1], - $p2[0], - $p2[1] - ); - - $s += $signStep; - $remain -= $step; - $p1 = $p2; - } - - return $curves; - } - - /** - * @return float[] - */ - private function calculateCenterPointParameters(float $fromX, float $fromY, float $xAngle) - { - $rX = $this->xRadius; - $rY = $this->yRadius; - - // F.6.5.1 - $dx2 = ($fromX - $this->x) / 2; - $dy2 = ($fromY - $this->y) / 2; - $x1p = cos($xAngle) * $dx2 + sin($xAngle) * $dy2; - $y1p = -sin($xAngle) * $dx2 + cos($xAngle) * $dy2; - - // F.6.5.2 - $rxs = $rX ** 2; - $rys = $rY ** 2; - $x1ps = $x1p ** 2; - $y1ps = $y1p ** 2; - $cr = $x1ps / $rxs + $y1ps / $rys; - - if ($cr > 1) { - $s = sqrt($cr); - $rX *= $s; - $rY *= $s; - $rxs = $rX ** 2; - $rys = $rY ** 2; - } - - $dq = ($rxs * $y1ps + $rys * $x1ps); - $pq = ($rxs * $rys - $dq) / $dq; - $q = sqrt(max(0, $pq)); - - if ($this->largeArc === $this->sweep) { - $q = -$q; - } - - $cxp = $q * $rX * $y1p / $rY; - $cyp = -$q * $rY * $x1p / $rX; - - // F.6.5.3 - $cx = cos($xAngle) * $cxp - sin($xAngle) * $cyp + ($fromX + $this->x) / 2; - $cy = sin($xAngle) * $cxp + cos($xAngle) * $cyp + ($fromY + $this->y) / 2; - - // F.6.5.5 - $theta = self::angle(1, 0, ($x1p - $cxp) / $rX, ($y1p - $cyp) / $rY); - - // F.6.5.6 - $delta = self::angle(($x1p - $cxp) / $rX, ($y1p - $cyp) / $rY, (-$x1p - $cxp) / $rX, (-$y1p - $cyp) / $rY); - $delta = fmod($delta, pi() * 2); - - if (! $this->sweep) { - $delta -= 2 * pi(); - } - - return [$cx, $cy, $rX, $rY, $theta, $delta]; - } - - private static function angle(float $ux, float $uy, float $vx, float $vy) : float - { - // F.6.5.4 - $dot = $ux * $vx + $uy * $vy; - $length = sqrt($ux ** 2 + $uy ** 2) * sqrt($vx ** 2 + $vy ** 2); - $angle = acos(min(1, max(-1, $dot / $length))); - - if (($ux * $vy - $uy * $vx) < 0) { - return -$angle; - } - - return $angle; - } - - /** - * @return float[] - */ - private static function point( - float $centerX, - float $centerY, - float $radiusX, - float $radiusY, - float $xAngle, - float $angle - ) : array { - return [ - $centerX + $radiusX * cos($xAngle) * cos($angle) - $radiusY * sin($xAngle) * sin($angle), - $centerY + $radiusX * sin($xAngle) * cos($angle) + $radiusY * cos($xAngle) * sin($angle), - ]; - } - - /** - * @return float[] - */ - private static function derivative(float $radiusX, float $radiusY, float $xAngle, float $angle) : array - { - return [ - -$radiusX * cos($xAngle) * sin($angle) - $radiusY * sin($xAngle) * cos($angle), - -$radiusX * sin($xAngle) * sin($angle) + $radiusY * cos($xAngle) * cos($angle), - ]; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Line.php b/vendor/bacon/bacon-qr-code/src/Renderer/Path/Line.php deleted file mode 100644 index 3149a39..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Line.php +++ /dev/null @@ -1,41 +0,0 @@ -x = $x; - $this->y = $y; - } - - public function getX() : float - { - return $this->x; - } - - public function getY() : float - { - return $this->y; - } - - /** - * @return self - */ - public function translate(float $x, float $y) : OperationInterface - { - return new self($this->x + $x, $this->y + $y); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Move.php b/vendor/bacon/bacon-qr-code/src/Renderer/Path/Move.php deleted file mode 100644 index 481d0dd..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Path/Move.php +++ /dev/null @@ -1,41 +0,0 @@ -x = $x; - $this->y = $y; - } - - public function getX() : float - { - return $this->x; - } - - public function getY() : float - { - return $this->y; - } - - /** - * @return self - */ - public function translate(float $x, float $y) : OperationInterface - { - return new self($this->x + $x, $this->y + $y); - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/Path/OperationInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/Path/OperationInterface.php deleted file mode 100644 index a5fa0ed..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/Path/OperationInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -operations[] = new Move($x, $y); - return $path; - } - - /** - * Draws a line from the current position to another position. - */ - public function line(float $x, float $y) : self - { - $path = clone $this; - $path->operations[] = new Line($x, $y); - return $path; - } - - /** - * Draws an elliptic arc from the current position to another position. - */ - public function ellipticArc( - float $xRadius, - float $yRadius, - float $xAxisRotation, - bool $largeArc, - bool $sweep, - float $x, - float $y - ) : self { - $path = clone $this; - $path->operations[] = new EllipticArc($xRadius, $yRadius, $xAxisRotation, $largeArc, $sweep, $x, $y); - return $path; - } - - /** - * Draws a curve from the current position to another position. - */ - public function curve(float $x1, float $y1, float $x2, float $y2, float $x3, float $y3) : self - { - $path = clone $this; - $path->operations[] = new Curve($x1, $y1, $x2, $y2, $x3, $y3); - return $path; - } - - /** - * Closes a sub-path. - */ - public function close() : self - { - $path = clone $this; - $path->operations[] = Close::instance(); - return $path; - } - - /** - * Appends another path to this one. - */ - public function append(self $other) : self - { - $path = clone $this; - $path->operations = array_merge($this->operations, $other->operations); - return $path; - } - - public function translate(float $x, float $y) : self - { - $path = new self(); - - foreach ($this->operations as $operation) { - $path->operations[] = $operation->translate($x, $y); - } - - return $path; - } - - /** - * @return OperationInterface[]|Traversable - */ - public function getIterator() : Traversable - { - foreach ($this->operations as $operation) { - yield $operation; - } - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/PlainTextRenderer.php b/vendor/bacon/bacon-qr-code/src/Renderer/PlainTextRenderer.php deleted file mode 100644 index 8aa7652..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/PlainTextRenderer.php +++ /dev/null @@ -1,86 +0,0 @@ -margin = $margin; - } - - /** - * @throws InvalidArgumentException if matrix width doesn't match height - */ - public function render(QrCode $qrCode) : string - { - $matrix = $qrCode->getMatrix(); - $matrixSize = $matrix->getWidth(); - - if ($matrixSize !== $matrix->getHeight()) { - throw new InvalidArgumentException('Matrix must have the same width and height'); - } - - $rows = $matrix->getArray()->toArray(); - - if (0 !== $matrixSize % 2) { - $rows[] = array_fill(0, $matrixSize, 0); - } - - $horizontalMargin = str_repeat(self::EMPTY_BLOCK, $this->margin); - $result = str_repeat("\n", (int) ceil($this->margin / 2)); - - for ($i = 0; $i < $matrixSize; $i += 2) { - $result .= $horizontalMargin; - - $upperRow = $rows[$i]; - $lowerRow = $rows[$i + 1]; - - for ($j = 0; $j < $matrixSize; ++$j) { - $upperBit = $upperRow[$j]; - $lowerBit = $lowerRow[$j]; - - if ($upperBit) { - $result .= $lowerBit ? self::FULL_BLOCK : self::UPPER_HALF_BLOCK; - } else { - $result .= $lowerBit ? self::LOWER_HALF_BLOCK : self::EMPTY_BLOCK; - } - } - - $result .= $horizontalMargin . "\n"; - } - - $result .= str_repeat("\n", (int) ceil($this->margin / 2)); - - return $result; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/RendererInterface.php b/vendor/bacon/bacon-qr-code/src/Renderer/RendererInterface.php deleted file mode 100644 index b0aae39..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/RendererInterface.php +++ /dev/null @@ -1,11 +0,0 @@ -externalColor = $externalColor; - $this->internalColor = $internalColor; - } - - public static function uniform(ColorInterface $color) : self - { - return new self($color, $color); - } - - public static function inherit() : self - { - return self::$inherit ?: self::$inherit = new self(null, null); - } - - public function inheritsBothColors() : bool - { - return null === $this->externalColor && null === $this->internalColor; - } - - public function inheritsExternalColor() : bool - { - return null === $this->externalColor; - } - - public function inheritsInternalColor() : bool - { - return null === $this->internalColor; - } - - public function getExternalColor() : ColorInterface - { - if (null === $this->externalColor) { - throw new RuntimeException('External eye color inherits foreground color'); - } - - return $this->externalColor; - } - - public function getInternalColor() : ColorInterface - { - if (null === $this->internalColor) { - throw new RuntimeException('Internal eye color inherits foreground color'); - } - - return $this->internalColor; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php b/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php deleted file mode 100644 index d54268e..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php +++ /dev/null @@ -1,168 +0,0 @@ -backgroundColor = $backgroundColor; - $this->foregroundColor = $foregroundColor; - $this->foregroundGradient = $foregroundGradient; - $this->topLeftEyeFill = $topLeftEyeFill; - $this->topRightEyeFill = $topRightEyeFill; - $this->bottomLeftEyeFill = $bottomLeftEyeFill; - } - - public static function default() : self - { - return self::$default ?: self::$default = self::uniformColor(new Gray(100), new Gray(0)); - } - - public static function withForegroundColor( - ColorInterface $backgroundColor, - ColorInterface $foregroundColor, - EyeFill $topLeftEyeFill, - EyeFill $topRightEyeFill, - EyeFill $bottomLeftEyeFill - ) : self { - return new self( - $backgroundColor, - $foregroundColor, - null, - $topLeftEyeFill, - $topRightEyeFill, - $bottomLeftEyeFill - ); - } - - public static function withForegroundGradient( - ColorInterface $backgroundColor, - Gradient $foregroundGradient, - EyeFill $topLeftEyeFill, - EyeFill $topRightEyeFill, - EyeFill $bottomLeftEyeFill - ) : self { - return new self( - $backgroundColor, - null, - $foregroundGradient, - $topLeftEyeFill, - $topRightEyeFill, - $bottomLeftEyeFill - ); - } - - public static function uniformColor(ColorInterface $backgroundColor, ColorInterface $foregroundColor) : self - { - return new self( - $backgroundColor, - $foregroundColor, - null, - EyeFill::inherit(), - EyeFill::inherit(), - EyeFill::inherit() - ); - } - - public static function uniformGradient(ColorInterface $backgroundColor, Gradient $foregroundGradient) : self - { - return new self( - $backgroundColor, - null, - $foregroundGradient, - EyeFill::inherit(), - EyeFill::inherit(), - EyeFill::inherit() - ); - } - - public function hasGradientFill() : bool - { - return null !== $this->foregroundGradient; - } - - public function getBackgroundColor() : ColorInterface - { - return $this->backgroundColor; - } - - public function getForegroundColor() : ColorInterface - { - if (null === $this->foregroundColor) { - throw new RuntimeException('Fill uses a gradient, thus no foreground color is available'); - } - - return $this->foregroundColor; - } - - public function getForegroundGradient() : Gradient - { - if (null === $this->foregroundGradient) { - throw new RuntimeException('Fill uses a single color, thus no foreground gradient is available'); - } - - return $this->foregroundGradient; - } - - public function getTopLeftEyeFill() : EyeFill - { - return $this->topLeftEyeFill; - } - - public function getTopRightEyeFill() : EyeFill - { - return $this->topRightEyeFill; - } - - public function getBottomLeftEyeFill() : EyeFill - { - return $this->bottomLeftEyeFill; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php b/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php deleted file mode 100644 index 3813dfd..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php +++ /dev/null @@ -1,46 +0,0 @@ -startColor = $startColor; - $this->endColor = $endColor; - $this->type = $type; - } - - public function getStartColor() : ColorInterface - { - return $this->startColor; - } - - public function getEndColor() : ColorInterface - { - return $this->endColor; - } - - public function getType() : GradientType - { - return $this->type; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php b/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php deleted file mode 100644 index c1ca754..0000000 --- a/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php +++ /dev/null @@ -1,22 +0,0 @@ -margin = $margin; - $this->size = $size; - $this->module = $module ?: SquareModule::instance(); - $this->eye = $eye ?: new ModuleEye($this->module); - $this->fill = $fill ?: Fill::default(); - } - - public function withSize(int $size) : self - { - $style = clone $this; - $style->size = $size; - return $style; - } - - public function withMargin(int $margin) : self - { - $style = clone $this; - $style->margin = $margin; - return $style; - } - - public function getSize() : int - { - return $this->size; - } - - public function getMargin() : int - { - return $this->margin; - } - - public function getModule() : ModuleInterface - { - return $this->module; - } - - public function getEye() : EyeInterface - { - return $this->eye; - } - - public function getFill() : Fill - { - return $this->fill; - } -} diff --git a/vendor/bacon/bacon-qr-code/src/Writer.php b/vendor/bacon/bacon-qr-code/src/Writer.php deleted file mode 100644 index d5bdc5c..0000000 --- a/vendor/bacon/bacon-qr-code/src/Writer.php +++ /dev/null @@ -1,71 +0,0 @@ -renderer = $renderer; - } - - /** - * Writes QR code and returns it as string. - * - * Content is a string which *should* be encoded in UTF-8, in case there are - * non ASCII-characters present. - * - * @throws InvalidArgumentException if the content is empty - */ - public function writeString( - string $content, - string $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING, - ?ErrorCorrectionLevel $ecLevel = null, - ?Version $forcedVersion = null - ) : string { - if (strlen($content) === 0) { - throw new InvalidArgumentException('Found empty contents'); - } - - if (null === $ecLevel) { - $ecLevel = ErrorCorrectionLevel::L(); - } - - return $this->renderer->render(Encoder::encode($content, $ecLevel, $encoding, $forcedVersion)); - } - - /** - * Writes QR code to a file. - * - * @see Writer::writeString() - */ - public function writeFile( - string $content, - string $filename, - string $encoding = Encoder::DEFAULT_BYTE_MODE_ECODING, - ?ErrorCorrectionLevel $ecLevel = null, - ?Version $forcedVersion = null - ) : void { - file_put_contents($filename, $this->writeString($content, $encoding, $ecLevel, $forcedVersion)); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/BitArrayTest.php b/vendor/bacon/bacon-qr-code/test/Common/BitArrayTest.php deleted file mode 100644 index add798b..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/BitArrayTest.php +++ /dev/null @@ -1,222 +0,0 @@ -assertFalse($array->get($i)); - $array->set($i); - $this->assertTrue($array->get($i)); - } - } - - public function testGetNextSet1() : void - { - $array = new BitArray(32); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, 32, $array->getNextSet($i)); - } - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, 33, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, 33, $array->getNextSet($i)); - } - } - } - - public function testGetNextSet2() : void - { - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, $i <= 31 ? 31 : 33, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, $i <= 31 ? 31 : 33, $array->getNextSet($i)); - } - } - - $array = new BitArray(33); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, 32, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, 32, $array->getNextSet($i)); - } - } - } - - public function testGetNextSet3() : void - { - $array = new BitArray(63); - $array->set(31); - $array->set(32); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($i <= 31) { - $expected = 31; - } elseif ($i <= 32) { - $expected = 32; - } else { - $expected = 63; - } - - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, $expected, $array->getNextSet($i)); - } - } - } - - public function testGetNextSet4() : void - { - $array = new BitArray(63); - $array->set(33); - $array->set(40); - - for ($i = 0; $i < $array->getSize(); ++$i) { - if ($i <= 33) { - $expected = 33; - } elseif ($i <= 40) { - $expected = 40; - } else { - $expected = 63; - } - - if ($this->getPhpUnitMajorVersion() === 7) { - $this->assertEquals($i, $expected, '', $array->getNextSet($i)); - } else { - $this->assertEqualsWithDelta($i, $expected, $array->getNextSet($i)); - } - } - } - - public function testGetNextSet5() : void - { - mt_srand(0xdeadbeef, MT_RAND_PHP); - - for ($i = 0; $i < 10; ++$i) { - $array = new BitArray(mt_rand(1, 100)); - $numSet = mt_rand(0, 19); - - for ($j = 0; $j < $numSet; ++$j) { - $array->set(mt_rand(0, $array->getSize() - 1)); - } - - $numQueries = mt_rand(0, 19); - - for ($j = 0; $j < $numQueries; ++$j) { - $query = mt_rand(0, $array->getSize() - 1); - $expected = $query; - - while ($expected < $array->getSize() && ! $array->get($expected)) { - ++$expected; - } - - $actual = $array->getNextSet($query); - - if ($actual !== $expected) { - $array->getNextSet($query); - } - - $this->assertEquals($expected, $actual); - } - } - } - - public function testSetBulk() : void - { - $array = new BitArray(64); - $array->setBulk(32, 0xFFFF0000); - - for ($i = 0; $i < 48; ++$i) { - $this->assertFalse($array->get($i)); - } - - for ($i = 48; $i < 64; ++$i) { - $this->assertTrue($array->get($i)); - } - } - - public function testClear() : void - { - $array = new BitArray(32); - - for ($i = 0; $i < 32; ++$i) { - $array->set($i); - } - - $array->clear(); - - for ($i = 0; $i < 32; ++$i) { - $this->assertFalse($array->get($i)); - } - } - - public function testGetArray() : void - { - $array = new BitArray(64); - $array->set(0); - $array->set(63); - - $ints = $array->getBitArray(); - - $this->assertSame(1, $ints[0]); - $this->assertSame(0x80000000, $ints[1]); - } - - public function testIsRange() : void - { - $array = new BitArray(64); - $this->assertTrue($array->isRange(0, 64, false)); - $this->assertFalse($array->isRange(0, 64, true)); - - $array->set(32); - $this->assertTrue($array->isRange(32, 33, true)); - - $array->set(31); - $this->assertTrue($array->isRange(31, 33, true)); - - $array->set(34); - $this->assertFalse($array->isRange(31, 35, true)); - - for ($i = 0; $i < 31; ++$i) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 33, true)); - - for ($i = 33; $i < 64; ++$i) { - $array->set($i); - } - - $this->assertTrue($array->isRange(0, 64, true)); - $this->assertFalse($array->isRange(0, 64, false)); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/BitMatrixTest.php b/vendor/bacon/bacon-qr-code/test/Common/BitMatrixTest.php deleted file mode 100644 index 8ad86d4..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/BitMatrixTest.php +++ /dev/null @@ -1,115 +0,0 @@ -assertEquals(33, $matrix->getHeight()); - - for ($y = 0; $y < 33; ++$y) { - for ($x = 0; $x < 33; ++$x) { - if ($y * $x % 3 === 0) { - $matrix->set($x, $y); - } - } - } - - for ($y = 0; $y < 33; $y++) { - for ($x = 0; $x < 33; ++$x) { - $this->assertSame(0 === $x * $y % 3, $matrix->get($x, $y)); - } - } - } - - public function testSetRegion() : void - { - $matrix = new BitMatrix(5); - $matrix->setRegion(1, 1, 3, 3); - - for ($y = 0; $y < 5; ++$y) { - for ($x = 0; $x < 5; ++$x) { - $this->assertSame($y >= 1 && $y <= 3 && $x >= 1 && $x <= 3, $matrix->get($x, $y)); - } - } - } - - public function testRectangularMatrix() : void - { - $matrix = new BitMatrix(75, 20); - $this->assertSame(75, $matrix->getWidth()); - $this->assertSame(20, $matrix->getHeight()); - - $matrix->set(10, 0); - $matrix->set(11, 1); - $matrix->set(50, 2); - $matrix->set(51, 3); - $matrix->flip(74, 4); - $matrix->flip(0, 5); - - $this->assertTrue($matrix->get(10, 0)); - $this->assertTrue($matrix->get(11, 1)); - $this->assertTrue($matrix->get(50, 2)); - $this->assertTrue($matrix->get(51, 3)); - $this->assertTrue($matrix->get(74, 4)); - $this->assertTrue($matrix->get(0, 5)); - - $matrix->flip(50, 2); - $matrix->flip(51, 3); - - $this->assertFalse($matrix->get(50, 2)); - $this->assertFalse($matrix->get(51, 3)); - } - - public function testRectangularSetRegion() : void - { - $matrix = new BitMatrix(320, 240); - $this->assertSame(320, $matrix->getWidth()); - $this->assertSame(240, $matrix->getHeight()); - - $matrix->setRegion(105, 22, 80, 12); - - for ($y = 0; $y < 240; ++$y) { - for ($x = 0; $x < 320; ++$x) { - $this->assertEquals($y >= 22 && $y < 34 && $x >= 105 && $x < 185, $matrix->get($x, $y)); - } - } - } - - public function testGetRow() : void - { - $matrix = new BitMatrix(102, 5); - - for ($x = 0; $x < 102; ++$x) { - if (0 === ($x & 3)) { - $matrix->set($x, 2); - } - } - - $array1 = $matrix->getRow(2, null); - $this->assertSame(102, $array1->getSize()); - - $array2 = new BitArray(60); - $array2 = $matrix->getRow(2, $array2); - $this->assertSame(102, $array2->getSize()); - - $array3 = new BitArray(200); - $array3 = $matrix->getRow(2, $array3); - $this->assertSame(200, $array3->getSize()); - - for ($x = 0; $x < 102; ++$x) { - $on = (0 === ($x & 3)); - - $this->assertSame($on, $array1->get($x)); - $this->assertSame($on, $array2->get($x)); - $this->assertSame($on, $array3->get($x)); - } - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/BitUtilsTest.php b/vendor/bacon/bacon-qr-code/test/Common/BitUtilsTest.php deleted file mode 100644 index 2904d31..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/BitUtilsTest.php +++ /dev/null @@ -1,25 +0,0 @@ -assertSame(1, BitUtils::unsignedRightShift(1, 0)); - $this->assertSame(1, BitUtils::unsignedRightShift(10, 3)); - $this->assertSame(536870910, BitUtils::unsignedRightShift(-10, 3)); - } - - public function testNumberOfTrailingZeros() : void - { - $this->assertSame(32, BitUtils::numberOfTrailingZeros(0)); - $this->assertSame(1, BitUtils::numberOfTrailingZeros(10)); - $this->assertSame(0, BitUtils::numberOfTrailingZeros(15)); - $this->assertSame(2, BitUtils::numberOfTrailingZeros(20)); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/ErrorCorrectionLevelTest.php b/vendor/bacon/bacon-qr-code/test/Common/ErrorCorrectionLevelTest.php deleted file mode 100644 index 369b5d9..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/ErrorCorrectionLevelTest.php +++ /dev/null @@ -1,25 +0,0 @@ -assertSame(0x0, ErrorCorrectionLevel::M()->getBits()); - $this->assertSame(0x1, ErrorCorrectionLevel::L()->getBits()); - $this->assertSame(0x2, ErrorCorrectionLevel::H()->getBits()); - $this->assertSame(0x3, ErrorCorrectionLevel::Q()->getBits()); - } - - public function testInvalidErrorCorrectionLevelThrowsException() : void - { - $this->expectException(OutOfBoundsException::class); - ErrorCorrectionLevel::forBits(4); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/FormatInformationTest.php b/vendor/bacon/bacon-qr-code/test/Common/FormatInformationTest.php deleted file mode 100644 index 39534a2..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/FormatInformationTest.php +++ /dev/null @@ -1,94 +0,0 @@ -assertSame(0, FormatInformation::numBitsDiffering(1, 1)); - $this->assertSame(1, FormatInformation::numBitsDiffering(0, 2)); - $this->assertSame(2, FormatInformation::numBitsDiffering(1, 2)); - $this->assertEquals(32, FormatInformation::numBitsDiffering(-1, 0)); - } - - public function testDecode() : void - { - $expected = FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO, - self::MASKED_TEST_FORMAT_INFO - ); - - $this->assertNotNull($expected); - $this->assertSame(7, $expected->getDataMask()); - $this->assertSame(ErrorCorrectionLevel::Q(), $expected->getErrorCorrectionLevel()); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - self::UNMAKSED_TEST_FORMAT_INFO, - self::MASKED_TEST_FORMAT_INFO - ) - ); - } - - public function testDecodeWithBitDifference() : void - { - $expected = FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO, - self::MASKED_TEST_FORMAT_INFO - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO ^ 0x1, - self::MASKED_TEST_FORMAT_INFO ^ 0x1 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO ^ 0x3, - self::MASKED_TEST_FORMAT_INFO ^ 0x3 - ) - ); - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO ^ 0x7, - self::MASKED_TEST_FORMAT_INFO ^ 0x7 - ) - ); - $this->assertNull( - FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO ^ 0xf, - self::MASKED_TEST_FORMAT_INFO ^ 0xf - ) - ); - } - - public function testDecodeWithMisRead() : void - { - $expected = FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO, - self::MASKED_TEST_FORMAT_INFO - ); - - $this->assertEquals( - $expected, - FormatInformation::decodeFormatInformation( - self::MASKED_TEST_FORMAT_INFO ^ 0x3, - self::MASKED_TEST_FORMAT_INFO ^ 0xf - ) - ); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/ModeTest.php b/vendor/bacon/bacon-qr-code/test/Common/ModeTest.php deleted file mode 100644 index 51fcb3e..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/ModeTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertSame(0x0, Mode::TERMINATOR()->getBits()); - $this->assertSame(0x1, Mode::NUMERIC()->getBits()); - $this->assertSame(0x2, Mode::ALPHANUMERIC()->getBits()); - $this->assertSame(0x4, Mode::BYTE()->getBits()); - $this->assertSame(0x8, Mode::KANJI()->getBits()); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/ReedSolomonCodecTest.php b/vendor/bacon/bacon-qr-code/test/Common/ReedSolomonCodecTest.php deleted file mode 100644 index 47975b5..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/ReedSolomonCodecTest.php +++ /dev/null @@ -1,96 +0,0 @@ -encode($block, $parity); - - // Copy parity into test blocks - for ($i = 0; $i < $numRoots; ++$i) { - $block[$i + $dataSize] = $parity[$i]; - $tBlock[$i + $dataSize] = $parity[$i]; - } - - // Seed with errors - for ($i = 0; $i < $errors; ++$i) { - $errorValue = mt_rand(1, $blockSize); - - do { - $errorLocation = mt_rand(0, $blockSize); - } while (0 !== $errorLocations[$errorLocation]); - - $errorLocations[$errorLocation] = 1; - - if (mt_rand(0, 1)) { - $erasures[] = $errorLocation; - } - - $tBlock[$errorLocation] ^= $errorValue; - } - - $erasures = SplFixedArray::fromArray($erasures, false); - - // Decode the errored block - $foundErrors = $codec->decode($tBlock, $erasures); - - if ($errors > 0 && null === $foundErrors) { - $this->assertSame($block, $tBlock, 'Decoder failed to correct errors'); - } - - $this->assertSame($errors, $foundErrors, 'Found errors do not equal expected errors'); - - for ($i = 0; $i < $foundErrors; ++$i) { - if (0 === $errorLocations[$erasures[$i]]) { - $this->fail(sprintf('Decoder indicates error in location %d without error', $erasures[$i])); - } - } - - $this->assertEquals($block, $tBlock, 'Decoder did not correct errors'); - } - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Common/VersionTest.php b/vendor/bacon/bacon-qr-code/test/Common/VersionTest.php deleted file mode 100644 index f6f038b..0000000 --- a/vendor/bacon/bacon-qr-code/test/Common/VersionTest.php +++ /dev/null @@ -1,78 +0,0 @@ -assertNotNull($version); - $this->assertEquals($versionNumber, $version->getVersionNumber()); - $this->assertNotNull($version->getAlignmentPatternCenters()); - - if ($versionNumber > 1) { - $this->assertTrue(count($version->getAlignmentPatternCenters()) > 0); - } - - $this->assertEquals($dimension, $version->getDimensionForVersion()); - $this->assertNotNull($version->getEcBlocksForLevel(ErrorCorrectionLevel::H())); - $this->assertNotNull($version->getEcBlocksForLevel(ErrorCorrectionLevel::L())); - $this->assertNotNull($version->getEcBlocksForLevel(ErrorCorrectionLevel::M())); - $this->assertNotNull($version->getEcBlocksForLevel(ErrorCorrectionLevel::Q())); - $this->assertNotNull($version->buildFunctionPattern()); - } - - /** - * @dataProvider versions - */ - public function testGetProvisionalVersionForDimension(int $versionNumber, int $dimension) : void - { - $this->assertSame( - $versionNumber, - Version::getProvisionalVersionForDimension($dimension)->getVersionNumber() - ); - } - - /** - * @dataProvider decodeInformation - */ - public function testDecodeVersionInformation(int $expectedVersion, int $mask) : void - { - $version = Version::decodeVersionInformation($mask); - $this->assertNotNull($version); - $this->assertSame($expectedVersion, $version->getVersionNumber()); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Encoder/EncoderTest.php b/vendor/bacon/bacon-qr-code/test/Encoder/EncoderTest.php deleted file mode 100644 index 9baa66b..0000000 --- a/vendor/bacon/bacon-qr-code/test/Encoder/EncoderTest.php +++ /dev/null @@ -1,487 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testGetAlphanumericCode() : void - { - // The first ten code points are numbers. - for ($i = 0; $i < 10; ++$i) { - $this->assertSame($i, $this->methods['getAlphanumericCode']->invoke(null, ord('0') + $i)); - } - - // The next 26 code points are capital alphabet letters. - for ($i = 10; $i < 36; ++$i) { - // The first ten code points are numbers - $this->assertSame($i, $this->methods['getAlphanumericCode']->invoke(null, ord('A') + $i - 10)); - } - - // Others are symbol letters. - $this->assertSame(36, $this->methods['getAlphanumericCode']->invoke(null, ord(' '))); - $this->assertSame(37, $this->methods['getAlphanumericCode']->invoke(null, ord('$'))); - $this->assertSame(38, $this->methods['getAlphanumericCode']->invoke(null, ord('%'))); - $this->assertSame(39, $this->methods['getAlphanumericCode']->invoke(null, ord('*'))); - $this->assertSame(40, $this->methods['getAlphanumericCode']->invoke(null, ord('+'))); - $this->assertSame(41, $this->methods['getAlphanumericCode']->invoke(null, ord('-'))); - $this->assertSame(42, $this->methods['getAlphanumericCode']->invoke(null, ord('.'))); - $this->assertSame(43, $this->methods['getAlphanumericCode']->invoke(null, ord('/'))); - $this->assertSame(44, $this->methods['getAlphanumericCode']->invoke(null, ord(':'))); - - // Should return -1 for other letters. - $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord('a'))); - $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord('#'))); - $this->assertSame(-1, $this->methods['getAlphanumericCode']->invoke(null, ord("\0"))); - } - - public function testChooseMode() : void - { - // Numeric mode - $this->assertSame(Mode::NUMERIC(), $this->methods['chooseMode']->invoke(null, '0')); - $this->assertSame(Mode::NUMERIC(), $this->methods['chooseMode']->invoke(null, '0123456789')); - - // Alphanumeric mode - $this->assertSame(Mode::ALPHANUMERIC(), $this->methods['chooseMode']->invoke(null, 'A')); - $this->assertSame( - Mode::ALPHANUMERIC(), - $this->methods['chooseMode']->invoke(null, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:') - ); - - // 8-bit byte mode - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, 'a')); - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, '#')); - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, '')); - - // AIUE in Hiragana in SHIFT-JIS - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\x8\xa\x8\xa\x8\xa\x8\xa6")); - - // Nihon in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\x9\xf\x9\x7b")); - - // Sou-Utso-Byou in Kanji in SHIFT-JIS - $this->assertSame(Mode::BYTE(), $this->methods['chooseMode']->invoke(null, "\xe\x4\x9\x5\x9\x61")); - } - - public function testEncode() : void - { - $qrCode = Encoder::encode('ABCDEF', ErrorCorrectionLevel::H()); - $expected = "<<\n" - . " mode: ALPHANUMERIC\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 0\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 0 1 1 1 0 1 1 0 0 1 1 0 0 0 1 0 0 1\n" - . " 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 0 1 0 0 0 1 0 1 0 1 0 1 1 0\n" - . " 1 1 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 0\n" - . " 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 0 1 1 1 1 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 1 0 1 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 0 1 0 1 1 0 0 0 0 1\n" - . " 1 0 0 0 0 0 1 0 1 1 1 1 0 1 0 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 0 1 0\n" - . " 1 0 1 1 1 0 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 1 0 1 1 0 1 0 0 0 1 1\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 0 1 0 1\n" - . ">>\n"; - - $this->assertSame($expected, (string) $qrCode); - } - - public function testSimpleUtf8Eci() : void - { - $qrCode = Encoder::encode('hello', ErrorCorrectionLevel::H(), 'utf-8'); - $expected = "<<\n" - . " mode: BYTE\n" - . " ecLevel: H\n" - . " version: 1\n" - . " maskPattern: 3\n" - . " matrix:\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 1 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0\n" - . " 0 0 1 1 1 0 0 0 0 0 1 1 0 0 0 1 0 1 1 1 0\n" - . " 0 1 0 1 0 1 1 1 0 1 0 1 0 0 0 0 0 1 1 1 1\n" - . " 1 1 0 0 1 0 0 1 1 0 0 1 1 1 1 0 1 0 1 1 0\n" - . " 0 0 0 0 1 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0\n" - . " 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 0 0 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 0 0 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 0 0 0\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 0 1 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 1 1 0\n" - . " 1 1 1 1 1 1 1 0 0 1 0 1 1 1 0 1 1 0 0 0 0\n" - . ">>\n"; - - $this->assertSame($expected, (string) $qrCode); - } - - public function testAppendModeInfo() : void - { - $bits = new BitArray(); - $this->methods['appendModeInfo']->invoke(null, Mode::NUMERIC(), $bits); - $this->assertSame(' ...X', (string) $bits); - } - - public function testAppendLengthInfo() : void - { - // 1 letter (1/1), 10 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 1, - Version::getVersionForNumber(1), - Mode::NUMERIC(), - $bits - ); - $this->assertSame(' ........ .X', (string) $bits); - - // 2 letters (2/1), 11 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 2, - Version::getVersionForNumber(10), - Mode::ALPHANUMERIC(), - $bits - ); - $this->assertSame(' ........ .X.', (string) $bits); - - // 255 letters (255/1), 16 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 255, - Version::getVersionForNumber(27), - Mode::BYTE(), - $bits - ); - $this->assertSame(' ........ XXXXXXXX', (string) $bits); - - // 512 letters (1024/2), 12 bits. - $bits = new BitArray(); - $this->methods['appendLengthInfo']->invoke( - null, - 512, - Version::getVersionForNumber(40), - Mode::KANJI(), - $bits - ); - $this->assertSame(' ..X..... ....', (string) $bits); - } - - public function testAppendBytes() : void - { - // Should use appendNumericBytes. - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - '1', - Mode::NUMERIC(), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertSame(' ...X', (string) $bits); - - // Should use appendAlphaNumericBytes. - // A = 10 = 0xa = 001010 in 6 bits. - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'A', - Mode::ALPHANUMERIC(), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertSame(' ..X.X.', (string) $bits); - - // Should use append8BitBytes. - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - 'abc', - Mode::BYTE(), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertSame(' .XX....X .XX...X. .XX...XX', (string) $bits); - - // Should use appendKanjiBytes. - // 0x93, 0x5f - $bits = new BitArray(); - $this->methods['appendBytes']->invoke( - null, - "\x93\x5f", - Mode::KANJI(), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - $this->assertSame(' .XX.XX.. XXXXX', (string) $bits); - - // Lower letters such as 'a' cannot be encoded in alphanumeric mode. - $this->expectException(WriterException::class); - $this->methods['appendBytes']->invoke( - null, - 'a', - Mode::ALPHANUMERIC(), - $bits, - Encoder::DEFAULT_BYTE_MODE_ECODING - ); - } - - public function testTerminateBits() : void - { - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 0, $bits); - $this->assertSame('', (string) $bits); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertSame(' ........', (string) $bits); - - $bits = new BitArray(); - $bits->appendBits(0, 3); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertSame(' ........', (string) $bits); - - $bits = new BitArray(); - $bits->appendBits(0, 5); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertSame(' ........', (string) $bits); - - $bits = new BitArray(); - $bits->appendBits(0, 8); - $this->methods['terminateBits']->invoke(null, 1, $bits); - $this->assertSame(' ........', (string) $bits); - - $bits = new BitArray(); - $this->methods['terminateBits']->invoke(null, 2, $bits); - $this->assertSame(' ........ XXX.XX..', (string) $bits); - - $bits = new BitArray(); - $bits->appendBits(0, 1); - $this->methods['terminateBits']->invoke(null, 3, $bits); - $this->assertSame(' ........ XXX.XX.. ...X...X', (string) $bits); - } - - public function testGetNumDataBytesAndNumEcBytesForBlockId() : void - { - // Version 1-H. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 26, 9, 1, 0); - $this->assertSame(9, $numDataBytes); - $this->assertSame(17, $numEcBytes); - - // Version 3-H. 2 blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 70, 26, 2, 0); - $this->assertSame(13, $numDataBytes); - $this->assertSame(22, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 70, 26, 2, 1); - $this->assertSame(13, $numDataBytes); - $this->assertSame(22, $numEcBytes); - - // Version 7-H. (4 + 1) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 196, 66, 5, 0); - $this->assertSame(13, $numDataBytes); - $this->assertSame(26, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 196, 66, 5, 4); - $this->assertSame(14, $numDataBytes); - $this->assertSame(26, $numEcBytes); - - // Version 40-H. (20 + 61) blocks. - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 3706, 1276, 81, 0); - $this->assertSame(15, $numDataBytes); - $this->assertSame(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 3706, 1276, 81, 20); - $this->assertSame(16, $numDataBytes); - $this->assertSame(30, $numEcBytes); - list($numDataBytes, $numEcBytes) = $this->methods['getNumDataBytesAndNumEcBytesForBlockId'] - ->invoke(null, 3706, 1276, 81, 80); - $this->assertSame(16, $numDataBytes); - $this->assertSame(30, $numEcBytes); - } - - public function testInterleaveWithEcBytes() : void - { - $dataBytes = SplFixedArray::fromArray([32, 65, 205, 69, 41, 220, 46, 128, 236], false); - $in = new BitArray(); - - foreach ($dataBytes as $dataByte) { - $in->appendBits($dataByte, 8); - } - - $outBits = $this->methods['interleaveWithEcBytes']->invoke(null, $in, 26, 9, 1); - $expected = SplFixedArray::fromArray([ - // Data bytes. - 32, 65, 205, 69, 41, 220, 46, 128, 236, - // Error correction bytes. - 42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61, - ], false); - - $out = $outBits->toBytes(0, count($expected)); - - $this->assertEquals($expected, $out); - } - - public function testAppendNumericBytes() : void - { - // 1 = 01 = 0001 in 4 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1', $bits); - $this->assertSame(' ...X', (string) $bits); - - // 12 = 0xc = 0001100 in 7 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '12', $bits); - $this->assertSame(' ...XX..', (string) $bits); - - // 123 = 0x7b = 0001111011 in 10 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '123', $bits); - $this->assertSame(' ...XXXX. XX', (string) $bits); - - // 1234 = "123" + "4" = 0001111011 + 0100 in 14 bits. - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '1234', $bits); - $this->assertSame(' ...XXXX. XX.X..', (string) $bits); - - // Empty - $bits = new BitArray(); - $this->methods['appendNumericBytes']->invoke(null, '', $bits); - $this->assertSame('', (string) $bits); - } - - public function testAppendAlphanumericBytes() : void - { - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'A', $bits); - $this->assertSame(' ..X.X.', (string) $bits); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'AB', $bits); - $this->assertSame(' ..XXX..X X.X', (string) $bits); - - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'ABC', $bits); - $this->assertSame(' ..XXX..X X.X..XX. .', (string) $bits); - - // Empty - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, '', $bits); - $this->assertSame('', (string) $bits); - - // Invalid data - $this->expectException(WriterException::class); - $bits = new BitArray(); - $this->methods['appendAlphanumericBytes']->invoke(null, 'abc', $bits); - } - - public function testAppend8BitBytes() : void - { - // 0x61, 0x62, 0x63 - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, 'abc', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertSame(' .XX....X .XX...X. .XX...XX', (string) $bits); - - // Empty - $bits = new BitArray(); - $this->methods['append8BitBytes']->invoke(null, '', $bits, Encoder::DEFAULT_BYTE_MODE_ECODING); - $this->assertSame('', (string) $bits); - } - - public function testAppendKanjiBytes() : void - { - // Numbers are from page 21 of JISX0510:2004 - $bits = new BitArray(); - $this->methods['appendKanjiBytes']->invoke(null, "\x93\x5f", $bits); - $this->assertSame(' .XX.XX.. XXXXX', (string) $bits); - - $this->methods['appendKanjiBytes']->invoke(null, "\xe4\xaa", $bits); - $this->assertSame(' .XX.XX.. XXXXXXX. X.X.X.X. X.', (string) $bits); - } - - public function testGenerateEcBytes() : void - { - // Numbers are from http://www.swetake.com/qr/qr3.html and - // http://www.swetake.com/qr/qr9.html - $dataBytes = SplFixedArray::fromArray([32, 65, 205, 69, 41, 220, 46, 128, 236], false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray( - [42, 159, 74, 221, 244, 169, 239, 150, 138, 70, 237, 85, 224, 96, 74, 219, 61], - false - ); - $this->assertEquals($expected, $ecBytes); - - $dataBytes = SplFixedArray::fromArray( - [67, 70, 22, 38, 54, 70, 86, 102, 118, 134, 150, 166, 182, 198, 214], - false - ); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 18); - $expected = SplFixedArray::fromArray( - [175, 80, 155, 64, 178, 45, 214, 233, 65, 209, 12, 155, 117, 31, 140, 214, 27, 187], - false - ); - $this->assertEquals($expected, $ecBytes); - - // High-order zero coefficient case. - $dataBytes = SplFixedArray::fromArray([32, 49, 205, 69, 42, 20, 0, 236, 17], false); - $ecBytes = $this->methods['generateEcBytes']->invoke(null, $dataBytes, 17); - $expected = SplFixedArray::fromArray( - [0, 3, 130, 179, 194, 0, 55, 211, 110, 79, 98, 72, 170, 96, 211, 137, 213], - false - ); - $this->assertEquals($expected, $ecBytes); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Encoder/MaskUtilTest.php b/vendor/bacon/bacon-qr-code/test/Encoder/MaskUtilTest.php deleted file mode 100644 index 46670fc..0000000 --- a/vendor/bacon/bacon-qr-code/test/Encoder/MaskUtilTest.php +++ /dev/null @@ -1,251 +0,0 @@ -assertSame( - 1 === $expected[$y][$x], - MaskUtil::getDataMaskBit($maskPattern, $x, $y) - ); - } - } - } - - public function testApplyMaskPenaltyRule1() : void - { - $matrix = new ByteMatrix(4, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - - $this->assertSame(0, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Horizontal - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 0); - $matrix->set(5, 0, 1); - $this->assertSame(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(5, 0, 0); - $this->assertSame(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - - // Vertical - $matrix = new ByteMatrix(1, 6); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 0); - $matrix->set(0, 5, 1); - $this->assertSame(3, MaskUtil::applyMaskPenaltyRule1($matrix)); - $matrix->set(0, 5, 0); - $this->assertSame(4, MaskUtil::applyMaskPenaltyRule1($matrix)); - } - - public function testApplyMaskPenaltyRule2() : void - { - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertSame(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 1); - $this->assertSame(0, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(2, 2); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $this->assertSame(3, MaskUtil::applyMaskPenaltyRule2($matrix)); - - $matrix = new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(1, 2, 0); - $matrix->set(2, 2, 0); - $this->assertSame(3 * 4, MaskUtil::applyMaskPenaltyRule2($matrix)); - } - - public function testApplyMaskPenalty3() : void - { - // Horizontal 00001011101 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 0); - $matrix->set(3, 0, 0); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 1); - $matrix->set(8, 0, 1); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 1); - $this->assertSame(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Horizontal 10111010000 - $matrix = new ByteMatrix(11, 1); - $matrix->set(0, 0, 1); - $matrix->set(1, 0, 0); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $matrix->set(6, 0, 1); - $matrix->set(7, 0, 0); - $matrix->set(8, 0, 0); - $matrix->set(9, 0, 0); - $matrix->set(10, 0, 0); - $this->assertSame(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 00001011101 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 0); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 0); - $matrix->set(0, 3, 0); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 1); - $matrix->set(0, 8, 1); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 1); - $this->assertSame(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - - // Vertical 10111010000 - $matrix = new ByteMatrix(1, 11); - $matrix->set(0, 0, 1); - $matrix->set(0, 1, 0); - $matrix->set(0, 2, 1); - $matrix->set(0, 3, 1); - $matrix->set(0, 4, 1); - $matrix->set(0, 5, 0); - $matrix->set(0, 6, 1); - $matrix->set(0, 7, 0); - $matrix->set(0, 8, 0); - $matrix->set(0, 9, 0); - $matrix->set(0, 10, 0); - $this->assertSame(40, MaskUtil::applyMaskPenaltyRule3($matrix)); - } - - public function testApplyMaskPenaltyRule4() : void - { - // Dark cell ratio = 0% - $matrix = new ByteMatrix(1, 1); - $matrix->set(0, 0, 0); - $this->assertSame(100, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 5% - $matrix = new ByteMatrix(2, 1); - $matrix->set(0, 0, 0); - $matrix->set(0, 0, 1); - $this->assertSame(0, MaskUtil::applyMaskPenaltyRule4($matrix)); - - // Dark cell ratio = 66.67% - $matrix = new ByteMatrix(6, 1); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 1); - $matrix->set(3, 0, 1); - $matrix->set(4, 0, 1); - $matrix->set(5, 0, 0); - $this->assertSame(30, MaskUtil::applyMaskPenaltyRule4($matrix)); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Encoder/MatrixUtilTest.php b/vendor/bacon/bacon-qr-code/test/Encoder/MatrixUtilTest.php deleted file mode 100644 index 106ceaa..0000000 --- a/vendor/bacon/bacon-qr-code/test/Encoder/MatrixUtilTest.php +++ /dev/null @@ -1,335 +0,0 @@ -getMethods(ReflectionMethod::IS_STATIC) as $method) { - $method->setAccessible(true); - $this->methods[$method->getName()] = $method; - } - } - - public function testToString() : void - { - $matrix = new ByteMatrix(3, 3); - $matrix->set(0, 0, 0); - $matrix->set(1, 0, 1); - $matrix->set(2, 0, 0); - $matrix->set(0, 1, 1); - $matrix->set(1, 1, 0); - $matrix->set(2, 1, 1); - $matrix->set(0, 2, -1); - $matrix->set(1, 2, -1); - $matrix->set(2, 2, -1); - - $expected = " 0 1 0\n 1 0 1\n \n"; - $this->assertSame($expected, (string) $matrix); - } - - public function testClearMatrix() : void - { - $matrix = new ByteMatrix(2, 2); - MatrixUtil::clearMatrix($matrix); - - $this->assertSame(-1, $matrix->get(0, 0)); - $this->assertSame(-1, $matrix->get(1, 0)); - $this->assertSame(-1, $matrix->get(0, 1)); - $this->assertSame(-1, $matrix->get(1, 1)); - } - - public function testEmbedBasicPatterns1() : void - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 0 0 0 0 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testEmbedBasicPatterns2() : void - { - $matrix = new ByteMatrix(25, 25); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(2), - $matrix - ); - $expected = " 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 \n" - . " 0 \n" - . " 1 1 1 1 1 1 \n" - . " 0 0 0 0 0 0 0 0 1 1 0 0 0 1 \n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 \n" - . " 1 0 0 0 0 0 1 0 1 0 0 0 1 \n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 1 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 1 1 1 0 1 0 \n" - . " 1 0 0 0 0 0 1 0 \n" - . " 1 1 1 1 1 1 1 0 \n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testEmbedTypeInfo() : void - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedTypeInfo']->invoke( - null, - ErrorCorrectionLevel::M(), - 5, - $matrix - ); - $expected = " 0 \n" - . " 1 \n" - . " 1 \n" - . " 1 \n" - . " 0 \n" - . " 0 \n" - . " \n" - . " 1 \n" - . " 1 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0\n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 0 \n" - . " 1 \n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testEmbedVersionInfo() : void - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['maybeEmbedVersionInfo']->invoke( - null, - Version::getVersionForNumber(7), - $matrix - ); - $expected = " 0 0 1 \n" - . " 0 1 0 \n" - . " 0 1 0 \n" - . " 0 1 1 \n" - . " 1 1 1 \n" - . " 0 0 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " 0 0 0 0 1 0 \n" - . " 0 1 1 1 1 0 \n" - . " 1 0 0 1 1 0 \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n" - . " \n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testEmbedDataBits() : void - { - $matrix = new ByteMatrix(21, 21); - MatrixUtil::clearMatrix($matrix); - $this->methods['embedBasicPatterns']->invoke( - null, - Version::getVersionForNumber(1), - $matrix - ); - - $bits = new BitArray(); - $this->methods['embedDataBits']->invoke( - null, - $bits, - -1, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testBuildMatrix() : void - { - $bytes = [ - 32, 65, 205, 69, 41, 220, 46, 128, 236, 42, 159, 74, 221, 244, 169, - 239, 150, 138, 70, 237, 85, 224, 96, 74, 219 , 61 - ]; - $bits = new BitArray(); - - foreach ($bytes as $byte) { - $bits->appendBits($byte, 8); - } - - $matrix = new ByteMatrix(21, 21); - MatrixUtil::buildMatrix( - $bits, - ErrorCorrectionLevel::H(), - Version::getVersionForNumber(1), - 3, - $matrix - ); - - $expected = " 1 1 1 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1 1 1 1\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1\n" - . " 1 0 1 1 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 0 1 0 1 0 1 1 1 0 1\n" - . " 1 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 0 0 1\n" - . " 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0\n" - . " 0 0 1 1 0 0 1 1 1 0 0 1 1 1 1 0 1 0 0 0 0\n" - . " 1 0 1 0 1 0 0 0 0 0 1 1 1 0 0 1 0 1 1 1 0\n" - . " 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 1 1 1 0 1 0\n" - . " 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 1 0 1 0\n" - . " 0 0 1 0 0 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1\n" - . " 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1\n" - . " 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 1 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0\n" - . " 1 0 1 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1\n" - . " 1 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 1 1 1 0\n" - . " 1 0 1 1 1 0 1 0 1 1 1 1 0 0 0 0 1 1 1 0 0\n" - . " 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0\n" - . " 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 0 1 0\n"; - - $this->assertSame($expected, (string) $matrix); - } - - public function testFindMsbSet() : void - { - $this->assertSame(0, $this->methods['findMsbSet']->invoke(null, 0)); - $this->assertSame(1, $this->methods['findMsbSet']->invoke(null, 1)); - $this->assertSame(8, $this->methods['findMsbSet']->invoke(null, 0x80)); - $this->assertSame(32, $this->methods['findMsbSet']->invoke(null, 0x80000000)); - } - - public function testCalculateBchCode() : void - { - // Encoding of type information. - // From Appendix C in JISX0510:2004 (p 65) - $this->assertSame(0xdc, $this->methods['calculateBchCode']->invoke(null, 5, 0x537)); - // From http://www.swetake.com/qr/qr6.html - $this->assertSame(0x1c2, $this->methods['calculateBchCode']->invoke(null, 0x13, 0x537)); - // From http://www.swetake.com/qr/qr11.html - $this->assertSame(0x214, $this->methods['calculateBchCode']->invoke(null, 0x1b, 0x537)); - - // Encoding of version information. - // From Appendix D in JISX0510:2004 (p 68) - $this->assertSame(0xc94, $this->methods['calculateBchCode']->invoke(null, 7, 0x1f25)); - $this->assertSame(0x5bc, $this->methods['calculateBchCode']->invoke(null, 8, 0x1f25)); - $this->assertSame(0xa99, $this->methods['calculateBchCode']->invoke(null, 9, 0x1f25)); - $this->assertSame(0x4d3, $this->methods['calculateBchCode']->invoke(null, 10, 0x1f25)); - $this->assertSame(0x9a6, $this->methods['calculateBchCode']->invoke(null, 20, 0x1f25)); - $this->assertSame(0xd75, $this->methods['calculateBchCode']->invoke(null, 30, 0x1f25)); - $this->assertSame(0xc69, $this->methods['calculateBchCode']->invoke(null, 40, 0x1f25)); - } - - public function testMakeVersionInfoBits() : void - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeVersionInfoBits']->invoke(null, Version::getVersionForNumber(7), $bits); - $this->assertSame(' ...XXXXX ..X..X.X ..', (string) $bits); - } - - public function testMakeTypeInfoBits() : void - { - // From Appendix D in JISX0510:2004 (p 68) - $bits = new BitArray(); - $this->methods['makeTypeInfoBits']->invoke(null, ErrorCorrectionLevel::M(), 5, $bits); - $this->assertSame(' X......X X..XXX.', (string) $bits); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Integration/ImagickRenderingTest.php b/vendor/bacon/bacon-qr-code/test/Integration/ImagickRenderingTest.php deleted file mode 100644 index 3df8687..0000000 --- a/vendor/bacon/bacon-qr-code/test/Integration/ImagickRenderingTest.php +++ /dev/null @@ -1,72 +0,0 @@ -writeFile('Hello World!', $tempName); - - $this->assertMatchesFileSnapshot($tempName); - unlink($tempName); - } - - /** - * @requires extension imagick - */ - public function testIssue79() : void - { - $eye = SquareEye::instance(); - $squareModule = SquareModule::instance(); - - $eyeFill = new EyeFill(new Rgb(100, 100, 55), new Rgb(100, 100, 255)); - $gradient = new Gradient(new Rgb(100, 100, 55), new Rgb(100, 100, 255), GradientType::HORIZONTAL()); - - $renderer = new ImageRenderer( - new RendererStyle( - 400, - 2, - $squareModule, - $eye, - Fill::withForegroundGradient(new Rgb(255, 255, 255), $gradient, $eyeFill, $eyeFill, $eyeFill) - ), - new ImagickImageBackEnd() - ); - $writer = new Writer($renderer); - $tempName = tempnam(sys_get_temp_dir(), 'test') . '.png'; - $writer->writeFile('https://apiroad.net/very-long-url', $tempName); - - $this->assertMatchesFileSnapshot($tempName); - unlink($tempName); - } -} diff --git a/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testGenericQrCode__1.png b/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testGenericQrCode__1.png deleted file mode 100644 index 9a429ed..0000000 Binary files a/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testGenericQrCode__1.png and /dev/null differ diff --git a/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testIssue79__1.png b/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testIssue79__1.png deleted file mode 100644 index 47e3b1a..0000000 Binary files a/vendor/bacon/bacon-qr-code/test/Integration/__snapshots__/files/ImagickRenderingTest__testIssue79__1.png and /dev/null differ diff --git a/vendor/bin/var-dump-server b/vendor/bin/var-dump-server deleted file mode 100644 index c52c772..0000000 --- a/vendor/bin/var-dump-server +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env php -realpath = realpath($opened_path) ?: $opened_path; - $opened_path = $this->realpath; - $this->handle = fopen($this->realpath, $mode); - $this->position = 0; - - return (bool) $this->handle; - } - - public function stream_read($count) - { - $data = fread($this->handle, $count); - - if ($this->position === 0) { - $data = preg_replace('{^#!.*\r?\n}', '', $data); - } - - $this->position += strlen($data); - - return $data; - } - - public function stream_cast($castAs) - { - return $this->handle; - } - - public function stream_close() - { - fclose($this->handle); - } - - public function stream_lock($operation) - { - return $operation ? flock($this->handle, $operation) : true; - } - - public function stream_seek($offset, $whence) - { - if (0 === fseek($this->handle, $offset, $whence)) { - $this->position = ftell($this->handle); - return true; - } - - return false; - } - - public function stream_tell() - { - return $this->position; - } - - public function stream_eof() - { - return feof($this->handle); - } - - public function stream_stat() - { - return array(); - } - - public function stream_set_option($option, $arg1, $arg2) - { - return true; - } - - public function url_stat($path, $flags) - { - $path = substr($path, 17); - if (file_exists($path)) { - return stat($path); - } - - return false; - } - } - } - - if ( - (function_exists('stream_get_wrappers') && in_array('phpvfscomposer', stream_get_wrappers(), true)) - || (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) - ) { - include("phpvfscomposer://" . __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'); - exit(0); - } -} - -include __DIR__ . '/..'.'/symfony/var-dumper/Resources/bin/var-dump-server'; diff --git a/vendor/bin/var-dump-server.bat b/vendor/bin/var-dump-server.bat deleted file mode 100644 index 94333da..0000000 --- a/vendor/bin/var-dump-server.bat +++ /dev/null @@ -1,5 +0,0 @@ -@ECHO OFF -setlocal DISABLEDELAYEDEXPANSION -SET BIN_TARGET=%~dp0/var-dump-server -SET COMPOSER_RUNTIME_BIN_DIR=%~dp0 -php "%BIN_TARGET%" %* diff --git a/vendor/cache/adapter-common/AbstractCachePool.php b/vendor/cache/adapter-common/AbstractCachePool.php deleted file mode 100644 index de7d2bc..0000000 --- a/vendor/cache/adapter-common/AbstractCachePool.php +++ /dev/null @@ -1,559 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -use Cache\Adapter\Common\Exception\CacheException; -use Cache\Adapter\Common\Exception\CachePoolException; -use Cache\Adapter\Common\Exception\InvalidArgumentException; -use Psr\Cache\CacheItemInterface; -use Psr\Log\LoggerAwareInterface; -use Psr\Log\LoggerInterface; -use Psr\SimpleCache\CacheInterface; - -/** - * @author Aaron Scherer - * @author Tobias Nyholm - */ -abstract class AbstractCachePool implements PhpCachePool, LoggerAwareInterface, CacheInterface -{ - const SEPARATOR_TAG = '!'; - - /** - * @type LoggerInterface - */ - private $logger; - - /** - * @type PhpCacheItem[] deferred - */ - protected $deferred = []; - - /** - * @param PhpCacheItem $item - * @param int|null $ttl seconds from now - * - * @return bool true if saved - */ - abstract protected function storeItemInCache(PhpCacheItem $item, $ttl); - - /** - * Fetch an object from the cache implementation. - * - * If it is a cache miss, it MUST return [false, null, [], null] - * - * @param string $key - * - * @return array with [isHit, value, tags[], expirationTimestamp] - */ - abstract protected function fetchObjectFromCache($key); - - /** - * Clear all objects from cache. - * - * @return bool false if error - */ - abstract protected function clearAllObjectsFromCache(); - - /** - * Remove one object from cache. - * - * @param string $key - * - * @return bool - */ - abstract protected function clearOneObjectFromCache($key); - - /** - * Get an array with all the values in the list named $name. - * - * @param string $name - * - * @return array - */ - abstract protected function getList($name); - - /** - * Remove the list. - * - * @param string $name - * - * @return bool - */ - abstract protected function removeList($name); - - /** - * Add a item key on a list named $name. - * - * @param string $name - * @param string $key - */ - abstract protected function appendListItem($name, $key); - - /** - * Remove an item from the list. - * - * @param string $name - * @param string $key - */ - abstract protected function removeListItem($name, $key); - - /** - * Make sure to commit before we destruct. - */ - public function __destruct() - { - $this->commit(); - } - - /** - * {@inheritdoc} - */ - public function getItem($key) - { - $this->validateKey($key); - if (isset($this->deferred[$key])) { - /** @type CacheItem $item */ - $item = clone $this->deferred[$key]; - $item->moveTagsToPrevious(); - - return $item; - } - - $func = function () use ($key) { - try { - return $this->fetchObjectFromCache($key); - } catch (\Exception $e) { - $this->handleException($e, __FUNCTION__); - } - }; - - return new CacheItem($key, $func); - } - - /** - * {@inheritdoc} - */ - public function getItems(array $keys = []) - { - $items = []; - foreach ($keys as $key) { - $items[$key] = $this->getItem($key); - } - - return $items; - } - - /** - * {@inheritdoc} - */ - public function hasItem($key) - { - try { - return $this->getItem($key)->isHit(); - } catch (\Exception $e) { - $this->handleException($e, __FUNCTION__); - } - } - - /** - * {@inheritdoc} - */ - public function clear() - { - // Clear the deferred items - $this->deferred = []; - - try { - return $this->clearAllObjectsFromCache(); - } catch (\Exception $e) { - $this->handleException($e, __FUNCTION__); - } - } - - /** - * {@inheritdoc} - */ - public function deleteItem($key) - { - try { - return $this->deleteItems([$key]); - } catch (\Exception $e) { - $this->handleException($e, __FUNCTION__); - } - } - - /** - * {@inheritdoc} - */ - public function deleteItems(array $keys) - { - $deleted = true; - foreach ($keys as $key) { - $this->validateKey($key); - - // Delete form deferred - unset($this->deferred[$key]); - - // We have to commit here to be able to remove deferred hierarchy items - $this->commit(); - $this->preRemoveItem($key); - - if (!$this->clearOneObjectFromCache($key)) { - $deleted = false; - } - } - - return $deleted; - } - - /** - * {@inheritdoc} - */ - public function save(CacheItemInterface $item) - { - if (!$item instanceof PhpCacheItem) { - $e = new InvalidArgumentException('Cache items are not transferable between pools. Item MUST implement PhpCacheItem.'); - $this->handleException($e, __FUNCTION__); - } - - $this->removeTagEntries($item); - $this->saveTags($item); - $timeToLive = null; - if (null !== $timestamp = $item->getExpirationTimestamp()) { - $timeToLive = $timestamp - time(); - - if ($timeToLive < 0) { - return $this->deleteItem($item->getKey()); - } - } - - try { - return $this->storeItemInCache($item, $timeToLive); - } catch (\Exception $e) { - $this->handleException($e, __FUNCTION__); - } - } - - /** - * {@inheritdoc} - */ - public function saveDeferred(CacheItemInterface $item) - { - $this->deferred[$item->getKey()] = $item; - - return true; - } - - /** - * {@inheritdoc} - */ - public function commit() - { - $saved = true; - foreach ($this->deferred as $item) { - if (!$this->save($item)) { - $saved = false; - } - } - $this->deferred = []; - - return $saved; - } - - /** - * @param string $key - * - * @throws InvalidArgumentException - */ - protected function validateKey($key) - { - if (!is_string($key)) { - $e = new InvalidArgumentException(sprintf( - 'Cache key must be string, "%s" given', - gettype($key) - )); - $this->handleException($e, __FUNCTION__); - } - if (!isset($key[0])) { - $e = new InvalidArgumentException('Cache key cannot be an empty string'); - $this->handleException($e, __FUNCTION__); - } - if (preg_match('|[\{\}\(\)/\\\@\:]|', $key)) { - $e = new InvalidArgumentException(sprintf( - 'Invalid key: "%s". The key contains one or more characters reserved for future extension: {}()/\@:', - $key - )); - $this->handleException($e, __FUNCTION__); - } - } - - /** - * @param LoggerInterface $logger - */ - public function setLogger(LoggerInterface $logger): void - { - $this->logger = $logger; - } - - /** - * Logs with an arbitrary level if the logger exists. - * - * @param mixed $level - * @param string $message - * @param array $context - */ - protected function log($level, $message, array $context = []) - { - if ($this->logger !== null) { - $this->logger->log($level, $message, $context); - } - } - - /** - * Log exception and rethrow it. - * - * @param \Exception $e - * @param string $function - * - * @throws CachePoolException - */ - private function handleException(\Exception $e, $function) - { - $level = 'alert'; - if ($e instanceof InvalidArgumentException) { - $level = 'warning'; - } - - $this->log($level, $e->getMessage(), ['exception' => $e]); - if (!$e instanceof CacheException) { - $e = new CachePoolException(sprintf('Exception thrown when executing "%s". ', $function), 0, $e); - } - - throw $e; - } - - /** - * @param array $tags - * - * @return bool - */ - public function invalidateTags(array $tags) - { - $itemIds = []; - foreach ($tags as $tag) { - $itemIds = array_merge($itemIds, $this->getList($this->getTagKey($tag))); - } - - // Remove all items with the tag - $success = $this->deleteItems($itemIds); - - if ($success) { - // Remove the tag list - foreach ($tags as $tag) { - $this->removeList($this->getTagKey($tag)); - $l = $this->getList($this->getTagKey($tag)); - } - } - - return $success; - } - - public function invalidateTag($tag) - { - return $this->invalidateTags([$tag]); - } - - /** - * @param PhpCacheItem $item - */ - protected function saveTags(PhpCacheItem $item) - { - $tags = $item->getTags(); - foreach ($tags as $tag) { - $this->appendListItem($this->getTagKey($tag), $item->getKey()); - } - } - - /** - * Removes the key form all tag lists. When an item with tags is removed - * we MUST remove the tags. If we fail to remove the tags a new item with - * the same key will automatically get the previous tags. - * - * @param string $key - * - * @return $this - */ - protected function preRemoveItem($key) - { - $item = $this->getItem($key); - $this->removeTagEntries($item); - - return $this; - } - - /** - * @param PhpCacheItem $item - */ - private function removeTagEntries(PhpCacheItem $item) - { - $tags = $item->getPreviousTags(); - foreach ($tags as $tag) { - $this->removeListItem($this->getTagKey($tag), $item->getKey()); - } - } - - /** - * @param string $tag - * - * @return string - */ - protected function getTagKey($tag) - { - return 'tag'.self::SEPARATOR_TAG.$tag; - } - - /** - * {@inheritdoc} - */ - public function get($key, $default = null) - { - $item = $this->getItem($key); - if (!$item->isHit()) { - return $default; - } - - return $item->get(); - } - - /** - * {@inheritdoc} - */ - public function set($key, $value, $ttl = null) - { - $item = $this->getItem($key); - $item->set($value); - $item->expiresAfter($ttl); - - return $this->save($item); - } - - /** - * {@inheritdoc} - */ - public function delete($key) - { - return $this->deleteItem($key); - } - - /** - * {@inheritdoc} - */ - public function getMultiple($keys, $default = null) - { - if (!is_array($keys)) { - if (!$keys instanceof \Traversable) { - throw new InvalidArgumentException('$keys is neither an array nor Traversable'); - } - - // Since we need to throw an exception if *any* key is invalid, it doesn't - // make sense to wrap iterators or something like that. - $keys = iterator_to_array($keys, false); - } - - $items = $this->getItems($keys); - - return $this->generateValues($default, $items); - } - - /** - * @param $default - * @param $items - * - * @return \Generator - */ - private function generateValues($default, $items) - { - foreach ($items as $key => $item) { - /** @type $item CacheItemInterface */ - if (!$item->isHit()) { - yield $key => $default; - } else { - yield $key => $item->get(); - } - } - } - - /** - * {@inheritdoc} - */ - public function setMultiple($values, $ttl = null) - { - if (!is_array($values)) { - if (!$values instanceof \Traversable) { - throw new InvalidArgumentException('$values is neither an array nor Traversable'); - } - } - - $keys = []; - $arrayValues = []; - foreach ($values as $key => $value) { - if (is_int($key)) { - $key = (string) $key; - } - $this->validateKey($key); - $keys[] = $key; - $arrayValues[$key] = $value; - } - - $items = $this->getItems($keys); - $itemSuccess = true; - foreach ($items as $key => $item) { - $item->set($arrayValues[$key]); - - try { - $item->expiresAfter($ttl); - } catch (InvalidArgumentException $e) { - throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); - } - - $itemSuccess = $itemSuccess && $this->saveDeferred($item); - } - - return $itemSuccess && $this->commit(); - } - - /** - * {@inheritdoc} - */ - public function deleteMultiple($keys) - { - if (!is_array($keys)) { - if (!$keys instanceof \Traversable) { - throw new InvalidArgumentException('$keys is neither an array nor Traversable'); - } - - // Since we need to throw an exception if *any* key is invalid, it doesn't - // make sense to wrap iterators or something like that. - $keys = iterator_to_array($keys, false); - } - - return $this->deleteItems($keys); - } - - /** - * {@inheritdoc} - */ - public function has($key) - { - return $this->hasItem($key); - } -} diff --git a/vendor/cache/adapter-common/CacheItem.php b/vendor/cache/adapter-common/CacheItem.php deleted file mode 100644 index 47e68c3..0000000 --- a/vendor/cache/adapter-common/CacheItem.php +++ /dev/null @@ -1,269 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -use Cache\Adapter\Common\Exception\InvalidArgumentException; -use Cache\TagInterop\TaggableCacheItemInterface; - -/** - * @author Aaron Scherer - * @author Tobias Nyholm - */ -class CacheItem implements PhpCacheItem -{ - /** - * @type array - */ - private $prevTags = []; - - /** - * @type array - */ - private $tags = []; - - /** - * @type \Closure - */ - private $callable; - - /** - * @type string - */ - private $key; - - /** - * @type mixed - */ - private $value; - - /** - * The expiration timestamp is the source of truth. This is the UTC timestamp - * when the cache item expire. A value of zero means it never expires. A nullvalue - * means that no expiration is set. - * - * @type int|null - */ - private $expirationTimestamp = null; - - /** - * @type bool - */ - private $hasValue = false; - - /** - * @param string $key - * @param \Closure|bool $callable or boolean hasValue - */ - public function __construct($key, $callable = null, $value = null) - { - $this->key = $key; - - if ($callable === true) { - $this->hasValue = true; - $this->value = $value; - } elseif ($callable !== false) { - // This must be a callable or null - $this->callable = $callable; - } - } - - /** - * {@inheritdoc} - */ - public function getKey() - { - return $this->key; - } - - /** - * {@inheritdoc} - */ - public function set($value) - { - $this->value = $value; - $this->hasValue = true; - $this->callable = null; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function get() - { - if (!$this->isHit()) { - return; - } - - return $this->value; - } - - /** - * {@inheritdoc} - */ - public function isHit() - { - $this->initialize(); - - if (!$this->hasValue) { - return false; - } - - if ($this->expirationTimestamp !== null) { - return $this->expirationTimestamp > time(); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function getExpirationTimestamp() - { - return $this->expirationTimestamp; - } - - /** - * {@inheritdoc} - */ - public function expiresAt($expiration) - { - if ($expiration instanceof \DateTimeInterface) { - $this->expirationTimestamp = $expiration->getTimestamp(); - } elseif (is_int($expiration) || null === $expiration) { - $this->expirationTimestamp = $expiration; - } else { - throw new InvalidArgumentException('Cache item ttl/expiresAt must be of type integer or \DateTimeInterface.'); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function expiresAfter($time) - { - if ($time === null) { - $this->expirationTimestamp = null; - } elseif ($time instanceof \DateInterval) { - $date = new \DateTime(); - $date->add($time); - $this->expirationTimestamp = $date->getTimestamp(); - } elseif (is_int($time)) { - $this->expirationTimestamp = time() + $time; - } else { - throw new InvalidArgumentException('Cache item ttl/expiresAfter must be of type integer or \DateInterval.'); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getPreviousTags() - { - $this->initialize(); - - return $this->prevTags; - } - - /** - * {@inheritdoc} - */ - public function getTags() - { - return $this->tags; - } - - /** - * {@inheritdoc} - */ - public function setTags(array $tags) - { - $this->tags = []; - $this->tag($tags); - - return $this; - } - - /** - * Adds a tag to a cache item. - * - * @param string|string[] $tags A tag or array of tags - * - * @throws InvalidArgumentException When $tag is not valid. - * - * @return TaggableCacheItemInterface - */ - private function tag($tags) - { - $this->initialize(); - - if (!is_array($tags)) { - $tags = [$tags]; - } - foreach ($tags as $tag) { - if (!is_string($tag)) { - throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given', is_object($tag) ? get_class($tag) : gettype($tag))); - } - if (isset($this->tags[$tag])) { - continue; - } - if (!isset($tag[0])) { - throw new InvalidArgumentException('Cache tag length must be greater than zero'); - } - if (isset($tag[strcspn($tag, '{}()/\@:')])) { - throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters {}()/\@:', $tag)); - } - $this->tags[$tag] = $tag; - } - - return $this; - } - - /** - * If callable is not null, execute it an populate this object with values. - */ - private function initialize() - { - if ($this->callable !== null) { - // $func will be $adapter->fetchObjectFromCache(); - $func = $this->callable; - $result = $func(); - $this->hasValue = $result[0]; - $this->value = $result[1]; - $this->prevTags = isset($result[2]) ? $result[2] : []; - $this->expirationTimestamp = null; - - if (isset($result[3]) && is_int($result[3])) { - $this->expirationTimestamp = $result[3]; - } - - $this->callable = null; - } - } - - /** - * @internal This function should never be used and considered private. - * - * Move tags from $tags to $prevTags - */ - public function moveTagsToPrevious() - { - $this->prevTags = $this->tags; - $this->tags = []; - } -} diff --git a/vendor/cache/adapter-common/Changelog.md b/vendor/cache/adapter-common/Changelog.md deleted file mode 100644 index 5a82188..0000000 --- a/vendor/cache/adapter-common/Changelog.md +++ /dev/null @@ -1,73 +0,0 @@ -# Change Log - -The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. - -## 1.3.0 - -* Support for PHP 8.1 -* Drop support for PHP < 7.4 -* Allow psr/cache: ^1.0 || ^2.0 - -## 1.2.0 - -### Added - -* Support for PHP 8 - -## 1.1.0 - -### Added - -- Support for storing binary data - -### Fixed - -- Issue with one character variables - -### Changed - -- Tests are now extending `PHPUnit\Framework\TestCase` - -## 1.0.0 - -* No changes since 0.4.0. - -## 0.4.0 - -### Added - -* `AbstractCachePool` has 4 new abstract methods: `getList`, `removeList`, `appendListItem` and `removeListItem`. -* `AbstractCachePool::invalidateTags` and `AbstractCachePool::invalidateTags` -* Added interfaces for our items and pools `PhpCachePool` and `PhpCacheItem` -* Trait to help adapters to support tags. `TagSupportWithArray`. - -### Changed - -* First parameter to `AbstractCachePool::storeItemInCache` must be a `PhpCacheItem`. -* Return value from `AbstractCachePool::fetchObjectFromCache` must be a an array with 4 values. Added expiration timestamp. -* `HasExpirationDateInterface` is replaced by `HasExpirationTimestampInterface` -* We do not work with `\DateTime` internally anymore. We work with timestamps. - -## 0.3.3 - -### Fixed - -* Bugfix when you fetch data from the cache storage that was saved as "non-tagging item" but fetch as a tagging item. - -## 0.3.2 - -### Added - -* Cache pools do implement `LoggerAwareInterface` - -## 0.3.0 - -### Changed - -* The `AbstractCachePool` does not longer implement `TaggablePoolInterface`. However, the `CacheItem` does still implement `TaggableItemInterface`. -* `CacheItem::getKeyFromTaggedKey` has been removed -* The `CacheItem`'s second parameter is a callable that must return an array with 3 elements; [`hasValue`, `value`, `tags`]. - -## 0.2.0 - -* No changelog before this version diff --git a/vendor/cache/adapter-common/Exception/CacheException.php b/vendor/cache/adapter-common/Exception/CacheException.php deleted file mode 100644 index 54fbb11..0000000 --- a/vendor/cache/adapter-common/Exception/CacheException.php +++ /dev/null @@ -1,23 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common\Exception; - -use Psr\Cache\CacheException as CacheExceptionInterface; - -/** - * A base exception. All exceptions in this organization will extend this exception. - * - * @author Tobias Nyholm - */ -abstract class CacheException extends \RuntimeException implements CacheExceptionInterface -{ -} diff --git a/vendor/cache/adapter-common/Exception/CachePoolException.php b/vendor/cache/adapter-common/Exception/CachePoolException.php deleted file mode 100644 index c0b7e59..0000000 --- a/vendor/cache/adapter-common/Exception/CachePoolException.php +++ /dev/null @@ -1,21 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common\Exception; - -/** - * If an exception is caused by a pool or by the cache storage. - * - * @author Tobias Nyholm - */ -class CachePoolException extends CacheException -{ -} diff --git a/vendor/cache/adapter-common/Exception/InvalidArgumentException.php b/vendor/cache/adapter-common/Exception/InvalidArgumentException.php deleted file mode 100644 index e3cc8f4..0000000 --- a/vendor/cache/adapter-common/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,19 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common\Exception; - -use Psr\Cache\InvalidArgumentException as CacheInvalidArgumentException; -use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInvalidArgumentException; - -class InvalidArgumentException extends CacheException implements CacheInvalidArgumentException, SimpleCacheInvalidArgumentException -{ -} diff --git a/vendor/cache/adapter-common/HasExpirationTimestampInterface.php b/vendor/cache/adapter-common/HasExpirationTimestampInterface.php deleted file mode 100644 index 22f0adf..0000000 --- a/vendor/cache/adapter-common/HasExpirationTimestampInterface.php +++ /dev/null @@ -1,26 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -/** - * @author Aaron Scherer - * @author Tobias Nyholm - */ -interface HasExpirationTimestampInterface -{ - /** - * The timestamp when the object expires. - * - * @return int|null - */ - public function getExpirationTimestamp(); -} diff --git a/vendor/cache/adapter-common/JsonBinaryArmoring.php b/vendor/cache/adapter-common/JsonBinaryArmoring.php deleted file mode 100644 index 7e3d91d..0000000 --- a/vendor/cache/adapter-common/JsonBinaryArmoring.php +++ /dev/null @@ -1,68 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -/** - * This trait provides common routines for safely encoding binary and non-UTF8 data in - * JSON. This is needed for components that use JSON natively (currently, the MongoDB - * adapter and EncryptedCachePool). - * - * @author Stephen Clouse - */ -trait JsonBinaryArmoring -{ - private static $ESCAPE_JSON_CHARACTERS = [ - "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", - "\x08", "\x09", "\x0A", "\x0B", "\x0C", "\x0D", "\x0E", "\x0F", - "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", - "\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", "\x1E", "\x1F", - ]; - - private static $ENCODED_JSON_CHARACTERS = [ - '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', - '\u0008', '\u0009', '\u000A', '\u000B', '\u000C', '\u000D', '\u000E', '\u000F', - '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', - '\u0018', '\u0019', '\u001A', '\u001B', '\u001C', '\u001D', '\u001E', '\u001F', - ]; - - /** - * Armor a value going into a JSON document. - * - * @param string $value - * - * @return string - */ - protected static function jsonArmor($value) - { - return str_replace( - static::$ESCAPE_JSON_CHARACTERS, - static::$ENCODED_JSON_CHARACTERS, - utf8_encode($value) - ); - } - - /** - * De-armor a value from a JSON document. - * - * @param string $value - * - * @return string - */ - protected static function jsonDeArmor($value) - { - return utf8_decode(str_replace( - static::$ENCODED_JSON_CHARACTERS, - static::$ESCAPE_JSON_CHARACTERS, - $value - )); - } -} diff --git a/vendor/cache/adapter-common/LICENSE b/vendor/cache/adapter-common/LICENSE deleted file mode 100644 index 82f8fee..0000000 --- a/vendor/cache/adapter-common/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Aaron Scherer, Tobias Nyholm - -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. - diff --git a/vendor/cache/adapter-common/PhpCacheItem.php b/vendor/cache/adapter-common/PhpCacheItem.php deleted file mode 100644 index 8d6ed5e..0000000 --- a/vendor/cache/adapter-common/PhpCacheItem.php +++ /dev/null @@ -1,32 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -use Cache\TagInterop\TaggableCacheItemInterface; - -/** - * @author Tobias Nyholm - */ -interface PhpCacheItem extends HasExpirationTimestampInterface, TaggableCacheItemInterface -{ - /** - * Get the current tags. These are not the same tags as getPrevious tags. This - * is the tags that has been added to the item after the item was fetched from - * the cache storage. - * - * WARNING: This is generally not the function you want to use. Please see - * `getPreviousTags`. - * - * @return array - */ - public function getTags(); -} diff --git a/vendor/cache/adapter-common/PhpCachePool.php b/vendor/cache/adapter-common/PhpCachePool.php deleted file mode 100644 index 5ccfb67..0000000 --- a/vendor/cache/adapter-common/PhpCachePool.php +++ /dev/null @@ -1,34 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -use Cache\TagInterop\TaggableCacheItemPoolInterface; - -/** - * @author Tobias Nyholm - */ -interface PhpCachePool extends TaggableCacheItemPoolInterface -{ - /** - * {@inheritdoc} - * - * @return PhpCacheItem - */ - public function getItem($key); - - /** - * {@inheritdoc} - * - * @return array|\Traversable|PhpCacheItem[] - */ - public function getItems(array $keys = []); -} diff --git a/vendor/cache/adapter-common/README.md b/vendor/cache/adapter-common/README.md deleted file mode 100644 index 3ce3480..0000000 --- a/vendor/cache/adapter-common/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Common PSR-6 Cache pool -[![Gitter](https://badges.gitter.im/php-cache/cache.svg)](https://gitter.im/php-cache/cache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -[![Latest Stable Version](https://poser.pugx.org/cache/adapter-common/v/stable)](https://packagist.org/packages/cache/adapter-common) -[![codecov.io](https://codecov.io/github/php-cache/adapter-common/coverage.svg?branch=master)](https://codecov.io/github/php-cache/adapter-common?branch=master) -[![Total Downloads](https://poser.pugx.org/cache/adapter-common/downloads)](https://packagist.org/packages/cache/adapter-common) -[![Monthly Downloads](https://poser.pugx.org/cache/adapter-common/d/monthly.png)](https://packagist.org/packages/cache/adapter-common) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) - -This repository contains shared classes and interfaces used by the PHP Cache organisation. To read about -features like tagging and hierarchy support please read the shared documentation at [www.php-cache.com](http://www.php-cache.com). - -### Contribute - -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/php-cache/cache) or -report any issues you find on the [issue tracker](http://issues.php-cache.com). diff --git a/vendor/cache/adapter-common/TagSupportWithArray.php b/vendor/cache/adapter-common/TagSupportWithArray.php deleted file mode 100644 index 81859d2..0000000 --- a/vendor/cache/adapter-common/TagSupportWithArray.php +++ /dev/null @@ -1,88 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Common; - -/** - * This trait could be used by adapters that do not have a native support for lists. - * - * @author Tobias Nyholm - */ -trait TagSupportWithArray -{ - /** - * Get a value from the storage. - * - * @param string $name - * - * @return mixed - */ - abstract public function getDirectValue($name); - - /** - * Set a value to the storage. - * - * @param string $name - * @param mixed $value - */ - abstract public function setDirectValue($name, $value); - - /** - * {@inheritdoc} - */ - protected function appendListItem($name, $value) - { - $data = $this->getDirectValue($name); - if (!is_array($data)) { - $data = []; - } - $data[] = $value; - $this->setDirectValue($name, $data); - } - - /** - * {@inheritdoc} - */ - protected function getList($name) - { - $data = $this->getDirectValue($name); - if (!is_array($data)) { - $data = []; - } - - return $data; - } - - /** - * {@inheritdoc} - */ - protected function removeList($name) - { - $this->setDirectValue($name, []); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function removeListItem($name, $key) - { - $data = $this->getList($name); - foreach ($data as $i => $value) { - if ($key === $value) { - unset($data[$i]); - } - } - - return $this->setDirectValue($name, $data); - } -} diff --git a/vendor/cache/adapter-common/composer.json b/vendor/cache/adapter-common/composer.json deleted file mode 100644 index c773462..0000000 --- a/vendor/cache/adapter-common/composer.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "cache/adapter-common", - "description": "Common classes for PSR-6 adapters", - "license": "MIT", - "type": "library", - "keywords": [ - "cache", - "psr-6", - "tag" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "homepage": "http://www.php-cache.com/en/latest/", - "require": { - "php": ">=7.4", - "cache/tag-interop": "^1.0", - "psr/cache": "^1.0 || ^2.0", - "psr/log": "^1.0 || ^2.0 || ^3.0", - "psr/simple-cache": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Cache\\Adapter\\Common\\": "" - } - }, - "autoload-dev": { - "psr-4": { - "Cache\\Adapter\\Common\\Tests\\": "Tests/" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/cache/filesystem-adapter/Changelog.md b/vendor/cache/filesystem-adapter/Changelog.md deleted file mode 100644 index bd1f902..0000000 --- a/vendor/cache/filesystem-adapter/Changelog.md +++ /dev/null @@ -1,64 +0,0 @@ -# Change Log - -The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. - -## UNRELEASED - -## 1.2.0 - -* Support for PHP 8.1 -* Drop support for PHP < 7.4 -* Allow psr/cache: ^1.0 || ^2.0 - -## 1.1.0 - -### Added - -* Support for PHP 8 - -### Changed - -* Use `League\Flysystem\FilesystemInterface` instead of concrete `League\Flysystem\Filesystem` class - -## 1.0.0 - -* No changes since 0.4.0 - -## 0.4.0 - -### Added - -* Support for the new `TaggableCacheItemPoolInterface`. -* Support for PSR-16 SimpleCache - -### Changed - -* The behavior of `CacheItem::getTags()` has changed. It will not return the tags stored in the cache storage. - -### Removed - -* `CacheItem::getExpirationDate()`. Use `CacheItem::getExpirationTimestamp()` -* `CacheItem::getTags()`. Use `CacheItem::getPreviousTags()` -* `CacheItem::addTag()`. Use `CacheItem::setTags()` - -## 0.3.3 - -### Fixed - -* Race condition in `fetchObjectFromCache`. - -## 0.3.2 - -### Changed - -* Using `Filesystem::update` instead of `Filesystem::delete` and `Filesystem::write`. - -## 0.3.1 - -### Added - -* Add ability to change cache path in FilesystemCachePool - -## 0.3.0 - -* No changelog before this version diff --git a/vendor/cache/filesystem-adapter/FilesystemCachePool.php b/vendor/cache/filesystem-adapter/FilesystemCachePool.php deleted file mode 100644 index 065519d..0000000 --- a/vendor/cache/filesystem-adapter/FilesystemCachePool.php +++ /dev/null @@ -1,213 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\Adapter\Filesystem; - -use Cache\Adapter\Common\AbstractCachePool; -use Cache\Adapter\Common\Exception\InvalidArgumentException; -use Cache\Adapter\Common\PhpCacheItem; -use League\Flysystem\FileExistsException; -use League\Flysystem\FileNotFoundException; -use League\Flysystem\FilesystemInterface; - -/** - * @author Tobias Nyholm - */ -class FilesystemCachePool extends AbstractCachePool -{ - /** - * @type FilesystemInterface - */ - private $filesystem; - - /** - * The folder should not begin nor end with a slash. Example: path/to/cache. - * - * @type string - */ - private $folder; - - /** - * @param FilesystemInterface $filesystem - * @param string $folder - */ - public function __construct(FilesystemInterface $filesystem, $folder = 'cache') - { - $this->folder = $folder; - - $this->filesystem = $filesystem; - $this->filesystem->createDir($this->folder); - } - - /** - * @param string $folder - */ - public function setFolder($folder) - { - $this->folder = $folder; - } - - /** - * {@inheritdoc} - */ - protected function fetchObjectFromCache($key) - { - $empty = [false, null, [], null]; - $file = $this->getFilePath($key); - - try { - $data = @unserialize($this->filesystem->read($file)); - if ($data === false) { - return $empty; - } - } catch (FileNotFoundException $e) { - return $empty; - } - - // Determine expirationTimestamp from data, remove items if expired - $expirationTimestamp = $data[2] ?: null; - if ($expirationTimestamp !== null && time() > $expirationTimestamp) { - foreach ($data[1] as $tag) { - $this->removeListItem($this->getTagKey($tag), $key); - } - $this->forceClear($key); - - return $empty; - } - - return [true, $data[0], $data[1], $expirationTimestamp]; - } - - /** - * {@inheritdoc} - */ - protected function clearAllObjectsFromCache() - { - $this->filesystem->deleteDir($this->folder); - $this->filesystem->createDir($this->folder); - - return true; - } - - /** - * {@inheritdoc} - */ - protected function clearOneObjectFromCache($key) - { - return $this->forceClear($key); - } - - /** - * {@inheritdoc} - */ - protected function storeItemInCache(PhpCacheItem $item, $ttl) - { - $data = serialize( - [ - $item->get(), - $item->getTags(), - $item->getExpirationTimestamp(), - ] - ); - - $file = $this->getFilePath($item->getKey()); - if ($this->filesystem->has($file)) { - // Update file if it exists - return $this->filesystem->update($file, $data); - } - - try { - return $this->filesystem->write($file, $data); - } catch (FileExistsException $e) { - // To handle issues when/if race conditions occurs, we try to update here. - return $this->filesystem->update($file, $data); - } - } - - /** - * @param string $key - * - * @throws InvalidArgumentException - * - * @return string - */ - private function getFilePath($key) - { - if (!preg_match('|^[a-zA-Z0-9_\.! ]+$|', $key)) { - throw new InvalidArgumentException(sprintf('Invalid key "%s". Valid filenames must match [a-zA-Z0-9_\.! ].', $key)); - } - - return sprintf('%s/%s', $this->folder, $key); - } - - /** - * {@inheritdoc} - */ - protected function getList($name) - { - $file = $this->getFilePath($name); - - if (!$this->filesystem->has($file)) { - $this->filesystem->write($file, serialize([])); - } - - return unserialize($this->filesystem->read($file)); - } - - /** - * {@inheritdoc} - */ - protected function removeList($name) - { - $file = $this->getFilePath($name); - $this->filesystem->delete($file); - } - - /** - * {@inheritdoc} - */ - protected function appendListItem($name, $key) - { - $list = $this->getList($name); - $list[] = $key; - - return $this->filesystem->update($this->getFilePath($name), serialize($list)); - } - - /** - * {@inheritdoc} - */ - protected function removeListItem($name, $key) - { - $list = $this->getList($name); - foreach ($list as $i => $item) { - if ($item === $key) { - unset($list[$i]); - } - } - - return $this->filesystem->update($this->getFilePath($name), serialize($list)); - } - - /** - * @param $key - * - * @return bool - */ - private function forceClear($key) - { - try { - return $this->filesystem->delete($this->getFilePath($key)); - } catch (FileNotFoundException $e) { - return true; - } - } -} diff --git a/vendor/cache/filesystem-adapter/LICENSE b/vendor/cache/filesystem-adapter/LICENSE deleted file mode 100644 index 82f8fee..0000000 --- a/vendor/cache/filesystem-adapter/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Aaron Scherer, Tobias Nyholm - -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. - diff --git a/vendor/cache/filesystem-adapter/README.md b/vendor/cache/filesystem-adapter/README.md deleted file mode 100644 index 90b4e45..0000000 --- a/vendor/cache/filesystem-adapter/README.md +++ /dev/null @@ -1,45 +0,0 @@ -# Filesystem PSR-6 Cache pool -[![Gitter](https://badges.gitter.im/php-cache/cache.svg)](https://gitter.im/php-cache/cache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -[![Latest Stable Version](https://poser.pugx.org/cache/filesystem-adapter/v/stable)](https://packagist.org/packages/cache/filesystem-adapter) -[![codecov.io](https://codecov.io/github/php-cache/filesystem-adapter/coverage.svg?branch=master)](https://codecov.io/github/php-cache/filesystem-adapter?branch=master) -[![Total Downloads](https://poser.pugx.org/cache/filesystem-adapter/downloads)](https://packagist.org/packages/cache/filesystem-adapter) -[![Monthly Downloads](https://poser.pugx.org/cache/filesystem-adapter/d/monthly.png)](https://packagist.org/packages/cache/filesystem-adapter) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) - -This is a PSR-6 cache implementation using Filesystem. It is a part of the PHP Cache organisation. To read about -features like tagging and hierarchy support please read the shared documentation at [www.php-cache.com](http://www.php-cache.com). - -This implementation is using the excellent [Flysystem](http://flysystem.thephpleague.com/). - -### Install - -```bash -composer require cache/filesystem-adapter -``` - -### Use - -To create an instance of `FilesystemCachePool` you need to configure a `Filesystem` and its adapter. - -```php -use League\Flysystem\Adapter\Local; -use League\Flysystem\Filesystem; -use Cache\Adapter\Filesystem\FilesystemCachePool; - -$filesystemAdapter = new Local(__DIR__.'/'); -$filesystem = new Filesystem($filesystemAdapter); - -$pool = new FilesystemCachePool($filesystem); -``` - -You can change the folder the cache pool will write to through the `setFolder` setter: - -```php -$pool = new FilesystemCachePool($filesystem); -$pool->setFolder('path/to/cache'); -``` - -### Contribute - -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/php-cache/cache) or -report any issues you find on the [issue tracker](http://issues.php-cache.com). diff --git a/vendor/cache/filesystem-adapter/composer.json b/vendor/cache/filesystem-adapter/composer.json deleted file mode 100644 index d2f794d..0000000 --- a/vendor/cache/filesystem-adapter/composer.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "cache/filesystem-adapter", - "description": "A PSR-6 cache implementation using filesystem. This implementation supports tags", - "license": "MIT", - "type": "library", - "keywords": [ - "cache", - "psr-6", - "filesystem", - "tag" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "homepage": "http://www.php-cache.com/en/latest/", - "require": { - "php": ">=7.4", - "cache/adapter-common": "^1.0", - "league/flysystem": "^1.0", - "psr/cache": "^1.0 || ^2.0", - "psr/simple-cache": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "provide": { - "psr/cache-implementation": "^1.0", - "psr/simple-cache-implementation": "^1.0" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Cache\\Adapter\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/cache/tag-interop/.github/PULL_REQUEST_TEMPLATE.md b/vendor/cache/tag-interop/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 4a339b4..0000000 --- a/vendor/cache/tag-interop/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,5 +0,0 @@ -This is a READ ONLY repository. - -Please make your pull request to https://github.com/php-cache/cache - -Thank you for contributing. diff --git a/vendor/cache/tag-interop/.gitignore b/vendor/cache/tag-interop/.gitignore deleted file mode 100644 index 987e2a2..0000000 --- a/vendor/cache/tag-interop/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -composer.lock -vendor diff --git a/vendor/cache/tag-interop/.travis.yml b/vendor/cache/tag-interop/.travis.yml deleted file mode 100644 index 45a1672..0000000 --- a/vendor/cache/tag-interop/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: php -sudo: false - -matrix: - include: - - php: 7.1 - -cache: - directories: - - "$HOME/.composer/cache" - -install: - - composer update --prefer-dist --prefer-stable - -script: - - ./vendor/bin/phpunit --coverage-clover=coverage.xml - -after_success: - - pip install --user codecov && codecov - -notifications: - email: false diff --git a/vendor/cache/tag-interop/Changelog.md b/vendor/cache/tag-interop/Changelog.md deleted file mode 100644 index 974da3e..0000000 --- a/vendor/cache/tag-interop/Changelog.md +++ /dev/null @@ -1,18 +0,0 @@ -# Change Log - -The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. - -## 1.1.0 - -* Support PHP 8.1 -* Support for psr/cache v2 - -## 1.0.1 - -* Support PHP 8 - -## 1.0.0 - -* First release - - diff --git a/vendor/cache/tag-interop/LICENSE b/vendor/cache/tag-interop/LICENSE deleted file mode 100644 index 82f8fee..0000000 --- a/vendor/cache/tag-interop/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Aaron Scherer, Tobias Nyholm - -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. - diff --git a/vendor/cache/tag-interop/README.md b/vendor/cache/tag-interop/README.md deleted file mode 100644 index 28511c9..0000000 --- a/vendor/cache/tag-interop/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Tag support for PSR-6 Cache -[![Gitter](https://badges.gitter.im/php-cache/cache.svg)](https://gitter.im/php-cache/cache?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) -[![Latest Stable Version](https://poser.pugx.org/cache/tag-interop/v/stable)](https://packagist.org/packages/cache/tag-interop) -[![Total Downloads](https://poser.pugx.org/cache/tag-interop/downloads)](https://packagist.org/packages/cache/tag-interop) -[![Monthly Downloads](https://poser.pugx.org/cache/tag-interop/d/monthly.png)](https://packagist.org/packages/cache/tag-interop) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) - -This repository holds two interfaces for tagging. These interfaces will make their -way into PHP Fig. Representatives from Symfony, PHP-cache and Drupal has worked -together to agree on these interfaces. - -### Install - -```bash -composer require cache/tag-interop -``` - -### Use - -Read the [documentation on usage](http://www.php-cache.com/). - -### Contribute - -Contributions are very welcome! Send a pull request to the [main repository](https://github.com/php-cache/cache) or -report any issues you find on the [issue tracker](http://issues.php-cache.com). diff --git a/vendor/cache/tag-interop/TaggableCacheItemInterface.php b/vendor/cache/tag-interop/TaggableCacheItemInterface.php deleted file mode 100644 index 5823b0b..0000000 --- a/vendor/cache/tag-interop/TaggableCacheItemInterface.php +++ /dev/null @@ -1,43 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\TagInterop; - -use Psr\Cache\CacheItemInterface; -use Psr\Cache\InvalidArgumentException; - -/** - * An item that supports tags. This interface is a soon-to-be-PSR. - * - * @author Tobias Nyholm - * @author Nicolas Grekas - */ -interface TaggableCacheItemInterface extends CacheItemInterface -{ - /** - * Get all existing tags. These are the tags the item has when the item is - * returned from the pool. - * - * @return array - */ - public function getPreviousTags(); - - /** - * Overwrite all tags with a new set of tags. - * - * @param string[] $tags An array of tags - * - * @throws InvalidArgumentException When a tag is not valid. - * - * @return TaggableCacheItemInterface - */ - public function setTags(array $tags); -} diff --git a/vendor/cache/tag-interop/TaggableCacheItemPoolInterface.php b/vendor/cache/tag-interop/TaggableCacheItemPoolInterface.php deleted file mode 100644 index 055bf4b..0000000 --- a/vendor/cache/tag-interop/TaggableCacheItemPoolInterface.php +++ /dev/null @@ -1,60 +0,0 @@ -, Tobias Nyholm - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Cache\TagInterop; - -use Psr\Cache\CacheItemPoolInterface; -use Psr\Cache\InvalidArgumentException; - -/** - * Interface for invalidating cached items using tags. This interface is a soon-to-be-PSR. - * - * @author Tobias Nyholm - * @author Nicolas Grekas - */ -interface TaggableCacheItemPoolInterface extends CacheItemPoolInterface -{ - /** - * Invalidates cached items using a tag. - * - * @param string $tag The tag to invalidate - * - * @throws InvalidArgumentException When $tags is not valid - * - * @return bool True on success - */ - public function invalidateTag($tag); - - /** - * Invalidates cached items using tags. - * - * @param string[] $tags An array of tags to invalidate - * - * @throws InvalidArgumentException When $tags is not valid - * - * @return bool True on success - */ - public function invalidateTags(array $tags); - - /** - * {@inheritdoc} - * - * @return TaggableCacheItemInterface - */ - public function getItem($key); - - /** - * {@inheritdoc} - * - * @return array|\Traversable|TaggableCacheItemInterface[] - */ - public function getItems(array $keys = []); -} diff --git a/vendor/cache/tag-interop/composer.json b/vendor/cache/tag-interop/composer.json deleted file mode 100644 index 03dacbe..0000000 --- a/vendor/cache/tag-interop/composer.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "cache/tag-interop", - "description": "Framework interoperable interfaces for tags", - "license": "MIT", - "type": "library", - "keywords": [ - "cache", - "psr6", - "tag", - "psr" - ], - "authors": [ - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - }, - { - "name": "Nicolas Grekas ", - "email": "p@tchwork.com", - "homepage": "https://github.com/nicolas-grekas" - } - ], - "homepage": "https://www.php-cache.com/en/latest/", - "require": { - "php": "^5.5 || ^7.0 || ^8.0", - "psr/cache": "^1.0 || ^2.0" - }, - "autoload": { - "psr-4": { - "Cache\\TagInterop\\": "" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 350f034..0fb0a2c 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,23 +6,5 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( - 'Attribute' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Callback' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackBody' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackParam' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackParameterToReference' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackReturnReference' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackReturnValue' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', - 'DOMDocumentWrapper' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'DOMEvent' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'ICallbackNamed' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', - 'phpQuery' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryEvents' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryObject' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryPlugins' => $vendorDir . '/jaeger/phpquery-single/phpQuery.php', ); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 2a84e1c..0aba306 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -9,19 +9,9 @@ return array( '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', '35fab96057f1bf5e7aba31a8a6d5fdde' => $vendorDir . '/topthink/think-orm/stubs/load_stubs.php', '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', - 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', - 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', + '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', - '25072dd6e2470089de65ae7bf11d3109' => $vendorDir . '/symfony/polyfill-php72/bootstrap.php', - '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php', - 'fe62ba7e10580d903cc46d808b5961a4' => $vendorDir . '/tightenco/collect/src/Collect/Support/helpers.php', - 'caf31cc6ec7cf2241cb6f12c226c3846' => $vendorDir . '/tightenco/collect/src/Collect/Support/alias.php', - '6b998e7ad3182c0d21d23780badfa07b' => $vendorDir . '/yansongda/supports/src/Functions.php', - 'b33e3d135e5d9e47d845c576147bda89' => $vendorDir . '/php-di/php-di/src/functions.php', '223fa6f9b46fbe5d6b44c5ff847bfceb' => $vendorDir . '/taoser/think-addons/src/helper.php', '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', - '8c783b3a3de2f6d9177022b5ccdcc841' => $vendorDir . '/yansongda/pay/src/Functions.php', 'd421242fd42b2ea6cd13f802bcf18a6e' => $baseDir . '/extend/taoler/com/form.php', ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 5e85e55..2bf9717 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -7,54 +7,21 @@ $baseDir = dirname($vendorDir); return array( 'yzh52521\\EasyHttp\\' => array($vendorDir . '/yzh52521/easyhttp/src'), - 'wamkj\\thinkphp\\' => array($vendorDir . '/wamkj/thinkphp6.0-databackup/src'), 'think\\view\\driver\\' => array($vendorDir . '/topthink/think-view/src'), - 'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'), - 'think\\migration\\' => array($vendorDir . '/topthink/think-migration/src'), - 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'), - 'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'), + 'think\\' => array($vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/framework/src/think'), 'taoser\\think\\' => array($vendorDir . '/taoser/think-auth/src'), 'taoser\\' => array($vendorDir . '/taoser/think-addons/src', $vendorDir . '/taoser/think-setarr/src'), - 'phpspirit\\databackup\\' => array($vendorDir . '/lotofbadcode/phpspirit_databackup/src'), - 'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'), 'app\\' => array($baseDir . '/app'), - 'Yansongda\\Supports\\' => array($vendorDir . '/yansongda/supports/src'), - 'Yansongda\\Pay\\' => array($vendorDir . '/yansongda/pay/src'), - 'Workerman\\' => array($vendorDir . '/workerman/workerman'), - 'Tightenco\\Collect\\' => array($vendorDir . '/tightenco/collect/src/Collect'), - 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), - 'Symfony\\Polyfill\\Php72\\' => array($vendorDir . '/symfony/polyfill-php72'), - 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'), - 'Symfony\\Component\\VarDumper\\' => array($vendorDir . '/symfony/var-dumper'), - 'QL\\' => array($vendorDir . '/jaeger/querylist/src'), 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), - 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), - 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/src'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'), 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), - 'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'), 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), - 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), - 'PhpDocReader\\' => array($vendorDir . '/php-di/phpdoc-reader/src/PhpDocReader'), - 'Phinx\\' => array($vendorDir . '/topthink/think-migration/phinx/src/Phinx'), - 'PHPSocketIO\\' => array($vendorDir . '/workerman/phpsocket.io/src'), 'PHPMailer\\PHPMailer\\' => array($vendorDir . '/phpmailer/phpmailer/src'), - 'League\\MimeTypeDetection\\' => array($vendorDir . '/league/mime-type-detection/src'), - 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), - 'Laravel\\SerializableClosure\\' => array($vendorDir . '/laravel/serializable-closure/src'), - 'Jaeger\\' => array($vendorDir . '/jaeger/g-http/src'), - 'Invoker\\' => array($vendorDir . '/php-di/invoker/src'), 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), - 'Endroid\\QrCode\\' => array($vendorDir . '/endroid/qr-code/src'), - 'DI\\' => array($vendorDir . '/php-di/php-di/src'), - 'DASPRiD\\Enum\\' => array($vendorDir . '/dasprid/enum/src'), - 'Channel\\' => array($vendorDir . '/workerman/channel/src'), - 'Cache\\TagInterop\\' => array($vendorDir . '/cache/tag-interop'), - 'Cache\\Adapter\\Filesystem\\' => array($vendorDir . '/cache/filesystem-adapter'), - 'Cache\\Adapter\\Common\\' => array($vendorDir . '/cache/adapter-common'), - 'BaconQrCode\\' => array($vendorDir . '/bacon/bacon-qr-code/src'), ); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index bec7df4..35bee46 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit1b32198725235c8d6500c87262ef30c2 +class ComposerAutoloaderInitbd5d3d6d2646baf3ad0aa6db972a53b0 { private static $loader; @@ -24,16 +24,16 @@ class ComposerAutoloaderInit1b32198725235c8d6500c87262ef30c2 require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit1b32198725235c8d6500c87262ef30c2', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitbd5d3d6d2646baf3ad0aa6db972a53b0', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit1b32198725235c8d6500c87262ef30c2', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitbd5d3d6d2646baf3ad0aa6db972a53b0', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit1b32198725235c8d6500c87262ef30c2::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::getInitializer($loader)); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit1b32198725235c8d6500c87262ef30c2::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3c638c2..232bde8 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,26 +4,16 @@ namespace Composer\Autoload; -class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 +class ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0 { public static $files = array ( '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', '35fab96057f1bf5e7aba31a8a6d5fdde' => __DIR__ . '/..' . '/topthink/think-orm/stubs/load_stubs.php', '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', - 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', - 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', + '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', - '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', - '25072dd6e2470089de65ae7bf11d3109' => __DIR__ . '/..' . '/symfony/polyfill-php72/bootstrap.php', - '667aeda72477189d0494fecd327c3641' => __DIR__ . '/..' . '/symfony/var-dumper/Resources/functions/dump.php', - 'fe62ba7e10580d903cc46d808b5961a4' => __DIR__ . '/..' . '/tightenco/collect/src/Collect/Support/helpers.php', - 'caf31cc6ec7cf2241cb6f12c226c3846' => __DIR__ . '/..' . '/tightenco/collect/src/Collect/Support/alias.php', - '6b998e7ad3182c0d21d23780badfa07b' => __DIR__ . '/..' . '/yansongda/supports/src/Functions.php', - 'b33e3d135e5d9e47d845c576147bda89' => __DIR__ . '/..' . '/php-di/php-di/src/functions.php', '223fa6f9b46fbe5d6b44c5ff847bfceb' => __DIR__ . '/..' . '/taoser/think-addons/src/helper.php', '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', - '8c783b3a3de2f6d9177022b5ccdcc841' => __DIR__ . '/..' . '/yansongda/pay/src/Functions.php', 'd421242fd42b2ea6cd13f802bcf18a6e' => __DIR__ . '/../..' . '/extend/taoler/com/form.php', ); @@ -32,58 +22,22 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 'yzh52521\\EasyHttp\\' => 18, ), - 'w' => - array ( - 'wamkj\\thinkphp\\' => 15, - ), 't' => array ( 'think\\view\\driver\\' => 18, - 'think\\trace\\' => 12, - 'think\\migration\\' => 16, - 'think\\composer\\' => 15, 'think\\captcha\\' => 14, 'think\\app\\' => 10, 'think\\' => 6, 'taoser\\think\\' => 13, 'taoser\\' => 7, ), - 'p' => - array ( - 'phpspirit\\databackup\\' => 21, - ), - 'l' => - array ( - 'liliuwei\\social\\' => 16, - ), 'a' => array ( 'app\\' => 4, ), - 'Y' => - array ( - 'Yansongda\\Supports\\' => 19, - 'Yansongda\\Pay\\' => 14, - ), - 'W' => - array ( - 'Workerman\\' => 10, - ), - 'T' => - array ( - 'Tightenco\\Collect\\' => 18, - ), 'S' => array ( - 'Symfony\\Polyfill\\Php80\\' => 23, - 'Symfony\\Polyfill\\Php72\\' => 23, - 'Symfony\\Polyfill\\Mbstring\\' => 26, 'Symfony\\Component\\VarExporter\\' => 30, - 'Symfony\\Component\\VarDumper\\' => 28, - ), - 'Q' => - array ( - 'QL\\' => 3, ), 'P' => array ( @@ -91,54 +45,15 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 'Psr\\Log\\' => 8, 'Psr\\Http\\Message\\' => 17, 'Psr\\Http\\Client\\' => 16, - 'Psr\\EventDispatcher\\' => 20, 'Psr\\Container\\' => 14, - 'Psr\\Cache\\' => 10, - 'PhpDocReader\\' => 13, - 'Phinx\\' => 6, - 'PHPSocketIO\\' => 12, 'PHPMailer\\PHPMailer\\' => 20, ), - 'L' => - array ( - 'League\\MimeTypeDetection\\' => 25, - 'League\\Flysystem\\' => 17, - 'Laravel\\SerializableClosure\\' => 28, - ), - 'J' => - array ( - 'Jaeger\\' => 7, - ), - 'I' => - array ( - 'Invoker\\' => 8, - ), 'G' => array ( 'GuzzleHttp\\Psr7\\' => 16, 'GuzzleHttp\\Promise\\' => 19, 'GuzzleHttp\\' => 11, ), - 'E' => - array ( - 'Endroid\\QrCode\\' => 15, - ), - 'D' => - array ( - 'DI\\' => 3, - 'DASPRiD\\Enum\\' => 13, - ), - 'C' => - array ( - 'Channel\\' => 8, - 'Cache\\TagInterop\\' => 17, - 'Cache\\Adapter\\Filesystem\\' => 25, - 'Cache\\Adapter\\Common\\' => 21, - ), - 'B' => - array ( - 'BaconQrCode\\' => 12, - ), ); public static $prefixDirsPsr4 = array ( @@ -146,26 +61,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 0 => __DIR__ . '/..' . '/yzh52521/easyhttp/src', ), - 'wamkj\\thinkphp\\' => - array ( - 0 => __DIR__ . '/..' . '/wamkj/thinkphp6.0-databackup/src', - ), 'think\\view\\driver\\' => array ( 0 => __DIR__ . '/..' . '/topthink/think-view/src', ), - 'think\\trace\\' => - array ( - 0 => __DIR__ . '/..' . '/topthink/think-trace/src', - ), - 'think\\migration\\' => - array ( - 0 => __DIR__ . '/..' . '/topthink/think-migration/src', - ), - 'think\\composer\\' => - array ( - 0 => __DIR__ . '/..' . '/topthink/think-installer/src', - ), 'think\\captcha\\' => array ( 0 => __DIR__ . '/..' . '/topthink/think-captcha/src', @@ -176,10 +75,10 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 ), 'think\\' => array ( - 0 => __DIR__ . '/..' . '/topthink/framework/src/think', + 0 => __DIR__ . '/..' . '/topthink/think-template/src', 1 => __DIR__ . '/..' . '/topthink/think-helper/src', 2 => __DIR__ . '/..' . '/topthink/think-orm/src', - 3 => __DIR__ . '/..' . '/topthink/think-template/src', + 3 => __DIR__ . '/..' . '/topthink/framework/src/think', ), 'taoser\\think\\' => array ( @@ -190,122 +89,39 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 0 => __DIR__ . '/..' . '/taoser/think-addons/src', 1 => __DIR__ . '/..' . '/taoser/think-setarr/src', ), - 'phpspirit\\databackup\\' => - array ( - 0 => __DIR__ . '/..' . '/lotofbadcode/phpspirit_databackup/src', - ), - 'liliuwei\\social\\' => - array ( - 0 => __DIR__ . '/..' . '/liliuwei/thinkphp-social/src', - ), 'app\\' => array ( 0 => __DIR__ . '/../..' . '/app', ), - 'Yansongda\\Supports\\' => - array ( - 0 => __DIR__ . '/..' . '/yansongda/supports/src', - ), - 'Yansongda\\Pay\\' => - array ( - 0 => __DIR__ . '/..' . '/yansongda/pay/src', - ), - 'Workerman\\' => - array ( - 0 => __DIR__ . '/..' . '/workerman/workerman', - ), - 'Tightenco\\Collect\\' => - array ( - 0 => __DIR__ . '/..' . '/tightenco/collect/src/Collect', - ), - 'Symfony\\Polyfill\\Php80\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', - ), - 'Symfony\\Polyfill\\Php72\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-php72', - ), - 'Symfony\\Polyfill\\Mbstring\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', - ), 'Symfony\\Component\\VarExporter\\' => array ( 0 => __DIR__ . '/..' . '/symfony/var-exporter', ), - 'Symfony\\Component\\VarDumper\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/var-dumper', - ), - 'QL\\' => - array ( - 0 => __DIR__ . '/..' . '/jaeger/querylist/src', - ), 'Psr\\SimpleCache\\' => array ( 0 => __DIR__ . '/..' . '/psr/simple-cache/src', ), 'Psr\\Log\\' => array ( - 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', + 0 => __DIR__ . '/..' . '/psr/log/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', ), - 'Psr\\EventDispatcher\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/event-dispatcher/src', - ), 'Psr\\Container\\' => array ( 0 => __DIR__ . '/..' . '/psr/container/src', ), - 'Psr\\Cache\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/cache/src', - ), - 'PhpDocReader\\' => - array ( - 0 => __DIR__ . '/..' . '/php-di/phpdoc-reader/src/PhpDocReader', - ), - 'Phinx\\' => - array ( - 0 => __DIR__ . '/..' . '/topthink/think-migration/phinx/src/Phinx', - ), - 'PHPSocketIO\\' => - array ( - 0 => __DIR__ . '/..' . '/workerman/phpsocket.io/src', - ), 'PHPMailer\\PHPMailer\\' => array ( 0 => __DIR__ . '/..' . '/phpmailer/phpmailer/src', ), - 'League\\MimeTypeDetection\\' => - array ( - 0 => __DIR__ . '/..' . '/league/mime-type-detection/src', - ), - 'League\\Flysystem\\' => - array ( - 0 => __DIR__ . '/..' . '/league/flysystem/src', - ), - 'Laravel\\SerializableClosure\\' => - array ( - 0 => __DIR__ . '/..' . '/laravel/serializable-closure/src', - ), - 'Jaeger\\' => - array ( - 0 => __DIR__ . '/..' . '/jaeger/g-http/src', - ), - 'Invoker\\' => - array ( - 0 => __DIR__ . '/..' . '/php-di/invoker/src', - ), 'GuzzleHttp\\Psr7\\' => array ( 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', @@ -318,38 +134,6 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 array ( 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', ), - 'Endroid\\QrCode\\' => - array ( - 0 => __DIR__ . '/..' . '/endroid/qr-code/src', - ), - 'DI\\' => - array ( - 0 => __DIR__ . '/..' . '/php-di/php-di/src', - ), - 'DASPRiD\\Enum\\' => - array ( - 0 => __DIR__ . '/..' . '/dasprid/enum/src', - ), - 'Channel\\' => - array ( - 0 => __DIR__ . '/..' . '/workerman/channel/src', - ), - 'Cache\\TagInterop\\' => - array ( - 0 => __DIR__ . '/..' . '/cache/tag-interop', - ), - 'Cache\\Adapter\\Filesystem\\' => - array ( - 0 => __DIR__ . '/..' . '/cache/filesystem-adapter', - ), - 'Cache\\Adapter\\Common\\' => - array ( - 0 => __DIR__ . '/..' . '/cache/adapter-common', - ), - 'BaconQrCode\\' => - array ( - 0 => __DIR__ . '/..' . '/bacon/bacon-qr-code/src', - ), ); public static $fallbackDirsPsr0 = array ( @@ -357,34 +141,16 @@ class ComposerStaticInit1b32198725235c8d6500c87262ef30c2 ); public static $classMap = array ( - 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', - 'Callback' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackBody' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackParam' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackParameterToReference' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackReturnReference' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'CallbackReturnValue' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', - 'DOMDocumentWrapper' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'DOMEvent' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'ICallbackNamed' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', - 'Stringable' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Stringable.php', - 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', - 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', - 'phpQuery' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryEvents' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryObject' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', - 'phpQueryPlugins' => __DIR__ . '/..' . '/jaeger/phpquery-single/phpQuery.php', ); public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit1b32198725235c8d6500c87262ef30c2::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit1b32198725235c8d6500c87262ef30c2::$prefixDirsPsr4; - $loader->fallbackDirsPsr0 = ComposerStaticInit1b32198725235c8d6500c87262ef30c2::$fallbackDirsPsr0; - $loader->classMap = ComposerStaticInit1b32198725235c8d6500c87262ef30c2::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::$prefixDirsPsr4; + $loader->fallbackDirsPsr0 = ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::$fallbackDirsPsr0; + $loader->classMap = ComposerStaticInitbd5d3d6d2646baf3ad0aa6db972a53b0::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 9c34d1c..e687037 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,448 +1,50 @@ { "packages": [ - { - "name": "bacon/bacon-qr-code", - "version": "2.0.8", - "version_normalized": "2.0.8.0", - "source": { - "type": "git", - "url": "https://github.com/Bacon/BaconQrCode.git", - "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Bacon/BaconQrCode/zipball/8674e51bb65af933a5ffaf1c308a660387c35c22", - "reference": "8674e51bb65af933a5ffaf1c308a660387c35c22", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "dasprid/enum": "^1.0.3", - "ext-iconv": "*", - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "phly/keep-a-changelog": "^2.1", - "phpunit/phpunit": "^7 | ^8 | ^9", - "spatie/phpunit-snapshot-assertions": "^4.2.9", - "squizlabs/php_codesniffer": "^3.4" - }, - "suggest": { - "ext-imagick": "to generate QR code images" - }, - "time": "2022-12-07T17:46:57+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "BaconQrCode\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "BaconQrCode is a QR code generator for PHP.", - "homepage": "https://github.com/Bacon/BaconQrCode", - "support": { - "issues": "https://github.com/Bacon/BaconQrCode/issues", - "source": "https://github.com/Bacon/BaconQrCode/tree/2.0.8" - }, - "install-path": "../bacon/bacon-qr-code" - }, - { - "name": "cache/adapter-common", - "version": "1.3.0", - "version_normalized": "1.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/adapter-common.git", - "reference": "8788309be72aa7be69b88cdc0687549c74a7d479" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/adapter-common/zipball/8788309be72aa7be69b88cdc0687549c74a7d479", - "reference": "8788309be72aa7be69b88cdc0687549c74a7d479", - "shasum": "" - }, - "require": { - "cache/tag-interop": "^1.0", - "php": ">=7.4", - "psr/cache": "^1.0 || ^2.0", - "psr/log": "^1.0 || ^2.0 || ^3.0", - "psr/simple-cache": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "time": "2022-01-15T15:47:19+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Cache\\Adapter\\Common\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "description": "Common classes for PSR-6 adapters", - "homepage": "http://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "psr-6", - "tag" - ], - "support": { - "source": "https://github.com/php-cache/adapter-common/tree/1.3.0" - }, - "install-path": "../cache/adapter-common" - }, - { - "name": "cache/filesystem-adapter", - "version": "1.2.0", - "version_normalized": "1.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/filesystem-adapter.git", - "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/filesystem-adapter/zipball/f1faaae40aaa696ef899cef6f6888aedb90b419b", - "reference": "f1faaae40aaa696ef899cef6f6888aedb90b419b", - "shasum": "" - }, - "require": { - "cache/adapter-common": "^1.0", - "league/flysystem": "^1.0", - "php": ">=7.4", - "psr/cache": "^1.0 || ^2.0", - "psr/simple-cache": "^1.0" - }, - "provide": { - "psr/cache-implementation": "^1.0", - "psr/simple-cache-implementation": "^1.0" - }, - "require-dev": { - "cache/integration-tests": "^0.17", - "phpunit/phpunit": "^7.5.20 || ^9.5.10" - }, - "time": "2022-01-15T15:47:19+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Cache\\Adapter\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Aaron Scherer", - "email": "aequasi@gmail.com", - "homepage": "https://github.com/aequasi" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - } - ], - "description": "A PSR-6 cache implementation using filesystem. This implementation supports tags", - "homepage": "http://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "filesystem", - "psr-6", - "tag" - ], - "support": { - "source": "https://github.com/php-cache/filesystem-adapter/tree/1.2.0" - }, - "install-path": "../cache/filesystem-adapter" - }, - { - "name": "cache/tag-interop", - "version": "1.1.0", - "version_normalized": "1.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-cache/tag-interop.git", - "reference": "b062b1d735357da50edf8387f7a8696f3027d328" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-cache/tag-interop/zipball/b062b1d735357da50edf8387f7a8696f3027d328", - "reference": "b062b1d735357da50edf8387f7a8696f3027d328", - "shasum": "" - }, - "require": { - "php": "^5.5 || ^7.0 || ^8.0", - "psr/cache": "^1.0 || ^2.0" - }, - "time": "2021-12-31T10:03:23+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Cache\\TagInterop\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/nyholm" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com", - "homepage": "https://github.com/nicolas-grekas" - } - ], - "description": "Framework interoperable interfaces for tags", - "homepage": "https://www.php-cache.com/en/latest/", - "keywords": [ - "cache", - "psr", - "psr6", - "tag" - ], - "support": { - "issues": "https://github.com/php-cache/tag-interop/issues", - "source": "https://github.com/php-cache/tag-interop/tree/1.1.0" - }, - "install-path": "../cache/tag-interop" - }, - { - "name": "dasprid/enum", - "version": "1.0.4", - "version_normalized": "1.0.4.0", - "source": { - "type": "git", - "url": "https://github.com/DASPRiD/Enum.git", - "reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/DASPRiD/Enum/zipball/8e6b6ea76eabbf19ea2bf5b67b98e1860474012f", - "reference": "8e6b6ea76eabbf19ea2bf5b67b98e1860474012f", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1 <9.0" - }, - "require-dev": { - "phpunit/phpunit": "^7 | ^8 | ^9", - "squizlabs/php_codesniffer": "*" - }, - "time": "2023-03-01T18:44:03+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "DASPRiD\\Enum\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "description": "PHP 7.1 enum implementation", - "keywords": [ - "enum", - "map" - ], - "support": { - "issues": "https://github.com/DASPRiD/Enum/issues", - "source": "https://github.com/DASPRiD/Enum/tree/1.0.4" - }, - "install-path": "../dasprid/enum" - }, - { - "name": "endroid/qr-code", - "version": "4.6.1", - "version_normalized": "4.6.1.0", - "source": { - "type": "git", - "url": "https://github.com/endroid/qr-code.git", - "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/endroid/qr-code/zipball/a75c913b0e4d6ad275e49a2c1de1cacffc6c2184", - "reference": "a75c913b0e4d6ad275e49a2c1de1cacffc6c2184", - "shasum": "" - }, - "require": { - "bacon/bacon-qr-code": "^2.0.5", - "php": "^7.4||^8.0" - }, - "require-dev": { - "endroid/quality": "dev-master", - "ext-gd": "*", - "khanamiryan/qrcode-detector-decoder": "^1.0.4", - "setasign/fpdf": "^1.8.2" - }, - "suggest": { - "ext-gd": "Enables you to write PNG images", - "khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator", - "roave/security-advisories": "Makes sure package versions with known security issues are not installed", - "setasign/fpdf": "Enables you to use the PDF writer" - }, - "time": "2022-10-26T08:48:17+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Endroid\\QrCode\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jeroen van den Enden", - "email": "info@endroid.nl" - } - ], - "description": "Endroid QR Code", - "homepage": "https://github.com/endroid/qr-code", - "keywords": [ - "code", - "endroid", - "php", - "qr", - "qrcode" - ], - "support": { - "issues": "https://github.com/endroid/qr-code/issues", - "source": "https://github.com/endroid/qr-code/tree/4.6.1" - }, - "funding": [ - { - "url": "https://github.com/endroid", - "type": "github" - } - ], - "install-path": "../endroid/qr-code" - }, { "name": "guzzlehttp/guzzle", - "version": "7.0.0", - "version_normalized": "7.0.0.0", + "version": "7.7.0", + "version_normalized": "7.7.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "414c24961042f6616fb43e23fa69a785f9fc053e" + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/414c24961042f6616fb43e23fa69a785f9fc053e", - "reference": "414c24961042f6616fb43e23fa69a785f9fc053e", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/fb7566caccf22d74d1ab270de3551f72a58399f5", + "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "php": "^7.2.5", - "psr/http-client": "^1.0" + "guzzlehttp/promises": "^1.5.3 || ^2.0", + "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" }, "require-dev": { - "ergebnis/composer-normalize": "^2.0", + "bamarni/composer-bin-plugin": "^1.8.1", "ext-curl": "*", - "php-http/client-integration-tests": "dev-phpunit8", - "phpunit/phpunit": "^8.5.5", - "psr/log": "^1.1" + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", "ext-intl": "Required for Internationalized Domain Name (IDN) support", "psr/log": "Required for using the Log middleware" }, - "time": "2020-06-27T08:47:54+00:00", + "time": "2023-05-21T14:04:53+00:00", "type": "library", "extra": { - "branch-alias": { - "dev-master": "7.0-dev" + "bamarni-bin": { + "bin-links": true, + "forward-command": false } }, "installation-source": "dist", @@ -459,19 +61,43 @@ "MIT" ], "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", "keywords": [ "client", "curl", @@ -485,44 +111,56 @@ ], "support": { "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/master" + "source": "https://github.com/guzzle/guzzle/tree/7.7.0" }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], "install-path": "../guzzlehttp/guzzle" }, { "name": "guzzlehttp/promises", - "version": "1.5.3", - "version_normalized": "1.5.3.0", + "version": "2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/guzzle/promises/zipball/3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "reference": "3a494dc7dc1d7d12e511890177ae2d0e6c107da6", + "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, - "time": "2023-05-21T12:31:43+00:00", + "time": "2023-05-21T13:50:22+00:00", "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "installation-source": "dist", "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -559,7 +197,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.3" + "source": "https://github.com/guzzle/promises/tree/2.0.0" }, "funding": [ { @@ -579,47 +217,47 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.9.1", - "version_normalized": "1.9.1.0", + "version": "2.5.0", + "version_normalized": "2.5.0.0", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b" + "reference": "b635f279edd83fc275f822a1188157ffea568ff6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/e4490cabc77465aaee90b20cfc9a770f8c04be6b", - "reference": "e4490cabc77465aaee90b20cfc9a770f8c04be6b", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/guzzle/psr7/zipball/b635f279edd83fc275f822a1188157ffea568ff6", + "reference": "b635f279edd83fc275f822a1188157ffea568ff6", + "shasum": "" }, "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, "require-dev": { - "ext-zlib": "*", - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10" + "bamarni/composer-bin-plugin": "^1.8.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, - "time": "2023-04-17T16:00:37+00:00", + "time": "2023-04-17T16:11:26+00:00", "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "installation-source": "dist", "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Psr7\\": "src/" } @@ -658,6 +296,11 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "description": "PSR-7 message implementation that also provides common utility methods", @@ -673,7 +316,7 @@ ], "support": { "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/1.9.1" + "source": "https://github.com/guzzle/psr7/tree/2.5.0" }, "funding": [ { @@ -691,707 +334,6 @@ ], "install-path": "../guzzlehttp/psr7" }, - { - "name": "jaeger/g-http", - "version": "V1.7.2", - "version_normalized": "1.7.2.0", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/GHttp.git", - "reference": "82585ddd5e2c6651e37ab1d8166efcdbb6b293d4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/GHttp/zipball/82585ddd5e2c6651e37ab1d8166efcdbb6b293d4", - "reference": "82585ddd5e2c6651e37ab1d8166efcdbb6b293d4", - "shasum": "" - }, - "require": { - "cache/filesystem-adapter": "^1", - "guzzlehttp/guzzle": "^6.0 | ^7.0" - }, - "time": "2021-08-08T04:59:44+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Jaeger\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "description": "Simple Http client base on GuzzleHttp", - "support": { - "issues": "https://github.com/jae-jae/GHttp/issues", - "source": "https://github.com/jae-jae/GHttp/tree/V1.7.2" - }, - "install-path": "../jaeger/g-http" - }, - { - "name": "jaeger/phpquery-single", - "version": "1.1.1", - "version_normalized": "1.1.1.0", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/phpQuery-single.git", - "reference": "39a650ade692a6b480c22220dce0c198d6a946fb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/phpQuery-single/zipball/39a650ade692a6b480c22220dce0c198d6a946fb", - "reference": "39a650ade692a6b480c22220dce0c198d6a946fb", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2022-03-26T15:01:16+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "phpQuery.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobiasz Cudnik", - "email": "tobiasz.cudnik@gmail.com", - "homepage": "https://github.com/TobiaszCudnik", - "role": "Developer" - }, - { - "name": "Jaeger", - "role": "Packager" - } - ], - "description": "phpQuery单文件版本,是Querylist的依赖(http://querylist.cc/),phpQuery项目主页:http://code.google.com/p/phpquery/", - "homepage": "http://code.google.com/p/phpquery/", - "support": { - "issues": "https://github.com/jae-jae/phpQuery-single/issues", - "source": "https://github.com/jae-jae/phpQuery-single/tree/1.1.1" - }, - "install-path": "../jaeger/phpquery-single" - }, - { - "name": "jaeger/querylist", - "version": "V4.2.8", - "version_normalized": "4.2.8.0", - "source": { - "type": "git", - "url": "https://github.com/jae-jae/QueryList.git", - "reference": "39dc0ca9c668bec7a793e20472ccd7d26ef89ea4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jae-jae/QueryList/zipball/39dc0ca9c668bec7a793e20472ccd7d26ef89ea4", - "reference": "39dc0ca9c668bec7a793e20472ccd7d26ef89ea4", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "jaeger/g-http": "^1.1", - "jaeger/phpquery-single": "^1", - "php": ">=7.1", - "tightenco/collect": ">5.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.5", - "symfony/var-dumper": "^3.3" - }, - "time": "2021-07-05T06:07:58+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "QL\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "description": "Simple, elegant, extensible PHP Web Scraper (crawler/spider),Use the css3 dom selector,Based on phpQuery! 简洁、优雅、可扩展的PHP采集工具(爬虫),基于phpQuery。", - "homepage": "http://querylist.cc", - "keywords": [ - "QueryList", - "phpQuery", - "spider" - ], - "support": { - "issues": "https://github.com/jae-jae/QueryList/issues", - "source": "https://github.com/jae-jae/QueryList/tree/V4.2.8" - }, - "funding": [ - { - "url": "https://opencollective.com/querylist", - "type": "open_collective" - } - ], - "install-path": "../jaeger/querylist" - }, - { - "name": "laravel/serializable-closure", - "version": "v1.3.0", - "version_normalized": "1.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/laravel/serializable-closure.git", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel/serializable-closure/zipball/f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "reference": "f23fe9d4e95255dacee1bf3525e0810d1a1b0f37", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "nesbot/carbon": "^2.61", - "pestphp/pest": "^1.21.3", - "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" - }, - "time": "2023-01-30T18:31:20+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Laravel\\SerializableClosure\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Nuno Maduro", - "email": "nuno@laravel.com" - } - ], - "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", - "keywords": [ - "closure", - "laravel", - "serializable" - ], - "support": { - "issues": "https://github.com/laravel/serializable-closure/issues", - "source": "https://github.com/laravel/serializable-closure" - }, - "install-path": "../laravel/serializable-closure" - }, - { - "name": "league/flysystem", - "version": "1.1.10", - "version_normalized": "1.1.10.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/flysystem.git", - "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1", - "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "ext-fileinfo": "*", - "league/mime-type-detection": "^1.3", - "php": "^7.2.5 || ^8.0" - }, - "conflict": { - "league/flysystem-sftp": "<1.0.6" - }, - "require-dev": { - "phpspec/prophecy": "^1.11.1", - "phpunit/phpunit": "^8.5.8" - }, - "suggest": { - "ext-ftp": "Allows you to use FTP server storage", - "ext-openssl": "Allows you to use FTPS server storage", - "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", - "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", - "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", - "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", - "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", - "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", - "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", - "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter", - "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", - "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications" - }, - "time": "2022-10-04T09:16:37+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "League\\Flysystem\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "description": "Filesystem abstraction: Many filesystems, one API.", - "keywords": [ - "Cloud Files", - "WebDAV", - "abstraction", - "aws", - "cloud", - "copy.com", - "dropbox", - "file systems", - "files", - "filesystem", - "filesystems", - "ftp", - "rackspace", - "remote", - "s3", - "sftp", - "storage" - ], - "support": { - "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/1.1.10" - }, - "funding": [ - { - "url": "https://offset.earth/frankdejonge", - "type": "other" - } - ], - "install-path": "../league/flysystem" - }, - { - "name": "league/mime-type-detection", - "version": "1.11.0", - "version_normalized": "1.11.0.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ff6248ea87a9f116e78edd6002e39e5128a0d4dd", - "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd", - "shasum": "" - }, - "require": { - "ext-fileinfo": "*", - "php": "^7.2 || ^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.2", - "phpstan/phpstan": "^0.12.68", - "phpunit/phpunit": "^8.5.8 || ^9.3" - }, - "time": "2022-04-17T13:12:02+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "League\\MimeTypeDetection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frankdejonge.nl" - } - ], - "description": "Mime-type detection for Flysystem", - "support": { - "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.11.0" - }, - "funding": [ - { - "url": "https://github.com/frankdejonge", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/league/flysystem", - "type": "tidelift" - } - ], - "install-path": "../league/mime-type-detection" - }, - { - "name": "liliuwei/thinkphp-social", - "version": "v1.3", - "version_normalized": "1.3.0.0", - "source": { - "type": "git", - "url": "https://github.com/liliuwei/thinkphp-social.git", - "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/liliuwei/thinkphp-social/zipball/2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", - "reference": "2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=5.6.0", - "topthink/framework": "^5.1 || ^6.0", - "topthink/think-installer": "^2.0" - }, - "time": "2021-01-13T05:11:12+00:00", - "type": "think-extend", - "extra": { - "think-config": { - "social": "src/config/config.php" - }, - "think": { - "config": { - "social": "src/config/config.php" - } - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "liliuwei\\social\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "liliuwei", - "email": "974829947@qq.com" - } - ], - "description": "适用于thinkphp5.1和6.0的社会化登录扩展", - "keywords": [ - "Facebook登录", - "Gitee登录", - "Github登录", - "Google登录", - "Oschina登录", - "QQ登录", - "oauth", - "think-social", - "thinkphp", - "thinkphp-social", - "thinkphp5.1", - "thinkphp6.0", - "小米登录", - "微信登录", - "抖音登录", - "新浪登录", - "淘宝登录", - "百度登录", - "第三方授权登录", - "谷歌登录", - "钉钉登录" - ], - "support": { - "issues": "https://github.com/liliuwei/thinkphp-social/issues", - "source": "https://github.com/liliuwei/thinkphp-social/tree/v1.3" - }, - "install-path": "../liliuwei/thinkphp-social" - }, - { - "name": "lotofbadcode/phpspirit_databackup", - "version": "v1.2", - "version_normalized": "1.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/lotofbadcode/phpspirit_databackup.git", - "reference": "77c2421f8461392c044cf8c29918f495c22a5612" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/lotofbadcode/phpspirit_databackup/zipball/77c2421f8461392c044cf8c29918f495c22a5612", - "reference": "77c2421f8461392c044cf8c29918f495c22a5612", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.0" - }, - "time": "2023-05-12T12:02:05+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "phpspirit\\databackup\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "代码庸医", - "email": "3359964266@qq.com" - } - ], - "description": "一个PHP数据库备份恢复的插件", - "keywords": [ - "library", - "php" - ], - "support": { - "issues": "https://github.com/lotofbadcode/phpspirit_databackup/issues", - "source": "https://github.com/lotofbadcode/phpspirit_databackup/tree/v1.2" - }, - "install-path": "../lotofbadcode/phpspirit_databackup" - }, - { - "name": "php-di/invoker", - "version": "2.3.3", - "version_normalized": "2.3.3.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/Invoker.git", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/Invoker/zipball/cd6d9f267d1a3474bdddf1be1da079f01b942786", - "reference": "cd6d9f267d1a3474bdddf1be1da079f01b942786", - "shasum": "" - }, - "require": { - "php": ">=7.3", - "psr/container": "^1.0|^2.0" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^9.0" - }, - "time": "2021-12-13T09:22:56+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Invoker\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Generic and extensible callable invoker", - "homepage": "https://github.com/PHP-DI/Invoker", - "keywords": [ - "callable", - "dependency", - "dependency-injection", - "injection", - "invoke", - "invoker" - ], - "support": { - "issues": "https://github.com/PHP-DI/Invoker/issues", - "source": "https://github.com/PHP-DI/Invoker/tree/2.3.3" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - } - ], - "install-path": "../php-di/invoker" - }, - { - "name": "php-di/php-di", - "version": "6.4.0", - "version_normalized": "6.4.0.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PHP-DI.git", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PHP-DI/zipball/ae0f1b3b03d8b29dff81747063cbfd6276246cc4", - "reference": "ae0f1b3b03d8b29dff81747063cbfd6276246cc4", - "shasum": "" - }, - "require": { - "laravel/serializable-closure": "^1.0", - "php": ">=7.4.0", - "php-di/invoker": "^2.0", - "php-di/phpdoc-reader": "^2.0.1", - "psr/container": "^1.0" - }, - "provide": { - "psr/container-implementation": "^1.0" - }, - "require-dev": { - "doctrine/annotations": "~1.10", - "friendsofphp/php-cs-fixer": "^2.4", - "mnapoli/phpunit-easymock": "^1.2", - "ocramius/proxy-manager": "^2.11.2", - "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^9.5" - }, - "suggest": { - "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", - "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" - }, - "time": "2022-04-09T16:46:38+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "src/functions.php" - ], - "psr-4": { - "DI\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "The dependency injection container for humans", - "homepage": "https://php-di.org/", - "keywords": [ - "PSR-11", - "container", - "container-interop", - "dependency injection", - "di", - "ioc", - "psr11" - ], - "support": { - "issues": "https://github.com/PHP-DI/PHP-DI/issues", - "source": "https://github.com/PHP-DI/PHP-DI/tree/6.4.0" - }, - "funding": [ - { - "url": "https://github.com/mnapoli", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/php-di/php-di", - "type": "tidelift" - } - ], - "install-path": "../php-di/php-di" - }, - { - "name": "php-di/phpdoc-reader", - "version": "2.2.1", - "version_normalized": "2.2.1.0", - "source": { - "type": "git", - "url": "https://github.com/PHP-DI/PhpDocReader.git", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-DI/PhpDocReader/zipball/66daff34cbd2627740ffec9469ffbac9f8c8185c", - "reference": "66daff34cbd2627740ffec9469ffbac9f8c8185c", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "require-dev": { - "mnapoli/hard-mode": "~0.3.0", - "phpunit/phpunit": "^8.5|^9.0" - }, - "time": "2020-10-12T12:39:22+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "PhpDocReader\\": "src/PhpDocReader" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", - "keywords": [ - "phpdoc", - "reflection" - ], - "support": { - "issues": "https://github.com/PHP-DI/PhpDocReader/issues", - "source": "https://github.com/PHP-DI/PhpDocReader/tree/2.2.1" - }, - "install-path": "../php-di/phpdoc-reader" - }, { "name": "phpmailer/phpmailer", "version": "v6.8.0", @@ -1475,87 +417,31 @@ ], "install-path": "../phpmailer/phpmailer" }, - { - "name": "psr/cache", - "version": "1.0.1", - "version_normalized": "1.0.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", - "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2016-08-06T20:24:11+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "install-path": "../psr/cache" - }, { "name": "psr/container", - "version": "1.1.2", - "version_normalized": "1.1.2.0", + "version": "2.0.2", + "version_normalized": "2.0.2.0", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea" + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea", - "reference": "513e0666f7216c7459170d56df27dfcefe1689ea", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" }, "require": { "php": ">=7.4.0" }, - "time": "2021-11-05T16:50:12+00:00", + "time": "2021-11-05T16:47:00+00:00", "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, "installation-source": "dist", "autoload": { "psr-4": { @@ -1583,63 +469,10 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.2" + "source": "https://github.com/php-fig/container/tree/2.0.2" }, "install-path": "../psr/container" }, - { - "name": "psr/event-dispatcher", - "version": "1.0.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/event-dispatcher.git", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", - "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "time": "2019-01-08T18:20:26+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Standard interfaces for event handling.", - "keywords": [ - "events", - "psr", - "psr-14" - ], - "support": { - "issues": "https://github.com/php-fig/event-dispatcher/issues", - "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" - }, - "install-path": "../psr/event-dispatcher" - }, { "name": "psr/http-client", "version": "1.0.2", @@ -1695,6 +528,64 @@ }, "install-path": "../psr/http-client" }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-04-10T20:10:41+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": "https://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/1.0.2" + }, + "install-path": "../psr/http-factory" + }, { "name": "psr/http-message", "version": "1.1", @@ -1708,13 +599,7 @@ "type": "zip", "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": "^7.2 || ^8.0" @@ -1759,39 +644,33 @@ }, { "name": "psr/log", - "version": "1.1.4", - "version_normalized": "1.1.4.0", + "version": "3.0.0", + "version_normalized": "3.0.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, - "time": "2021-05-03T11:20:27+00:00", + "time": "2021-07-14T16:46:02+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } }, "installation-source": "dist", "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -1812,39 +691,33 @@ "psr-3" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/php-fig/log/tree/3.0.0" }, "install-path": "../psr/log" }, { "name": "psr/simple-cache", - "version": "1.0.1", - "version_normalized": "1.0.1.0", + "version": "3.0.0", + "version_normalized": "3.0.0.0", "source": { "type": "git", "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, - "time": "2017-10-23T01:57:42+00:00", + "time": "2021-10-29T13:26:27+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } }, "installation-source": "dist", @@ -1860,7 +733,7 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "description": "Common interfaces for simple caching", @@ -1871,6 +744,9 @@ "psr-16", "simple-cache" ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, "install-path": "../psr/simple-cache" }, { @@ -1921,331 +797,38 @@ "install-path": "../ralouphie/getallheaders" }, { - "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", - "version_normalized": "1.27.0.0", + "name": "symfony/deprecation-contracts", + "version": "v3.3.0", + "version_normalized": "3.3.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "time": "2022-11-03T14:55:06+00:00", + "time": "2023-05-23T14:45:45+00:00", "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "3.4-dev" }, "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "installation-source": "dist", "autoload": { "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "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.27.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-mbstring" - }, - { - "name": "symfony/polyfill-php72", - "version": "v1.27.0", - "version_normalized": "1.27.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1" - }, - "time": "2022-11-03T14:55:06+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - } - }, - "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 backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.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-php72" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.27.0", - "version_normalized": "1.27.0.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1" - }, - "time": "2022-11-03T14:55:06+00:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.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-php80" - }, - { - "name": "symfony/var-dumper", - "version": "v4.4.47", - "version_normalized": "4.4.47.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/var-dumper.git", - "reference": "1069c7a3fca74578022fab6f81643248d02f8e63" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1069c7a3fca74578022fab6f81643248d02f8e63", - "reference": "1069c7a3fca74578022fab6f81643248d02f8e63", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php72": "~1.5", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/console": "<3.4" - }, - "require-dev": { - "ext-iconv": "*", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/process": "^4.4|^5.0", - "twig/twig": "^1.43|^2.13|^3.0.4" - }, - "suggest": { - "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", - "ext-intl": "To show region name in time zone dump", - "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" - }, - "time": "2022-10-03T15:15:11+00:00", - "bin": [ - "Resources/bin/var-dump-server" - ], - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "Resources/functions/dump.php" - ], - "psr-4": { - "Symfony\\Component\\VarDumper\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "function.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -2262,14 +845,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Provides mechanisms for walking through any arbitrary PHP variable", + "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", - "keywords": [ - "debug", - "dump" - ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v4.4.47" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0" }, "funding": [ { @@ -2285,37 +864,30 @@ "type": "tidelift" } ], - "install-path": "../symfony/var-dumper" + "install-path": "../symfony/deprecation-contracts" }, { "name": "symfony/var-exporter", - "version": "v5.4.21", - "version_normalized": "5.4.21.0", + "version": "v6.3.2", + "version_normalized": "6.3.2.0", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4" + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/be74908a6942fdd331554b3cec27ff41b45ccad4", - "reference": "be74908a6942fdd331554b3cec27ff41b45ccad4", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/3400949782c0cb5b3e73aa64cfd71dde000beccc", + "reference": "3400949782c0cb5b3e73aa64cfd71dde000beccc", + "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" }, "require-dev": { - "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + "symfony/var-dumper": "^5.4|^6.0" }, - "time": "2023-02-21T19:46:44+00:00", + "time": "2023-07-26T17:39:03+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2348,10 +920,12 @@ "export", "hydrate", "instantiate", + "lazy-loading", + "proxy", "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v5.4.21" + "source": "https://github.com/symfony/var-exporter/tree/v6.3.2" }, "funding": [ { @@ -2371,27 +945,27 @@ }, { "name": "taoser/think-addons", - "version": "v1.0.9", - "version_normalized": "1.0.9.0", + "version": "v2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/taoser/think-addons.git", - "reference": "00112adf200b897deecbd1bbabc33ad22377b008" + "reference": "ef97225aca7f0ec1da275c4ae025686899a91ad2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-addons/zipball/00112adf200b897deecbd1bbabc33ad22377b008", - "reference": "00112adf200b897deecbd1bbabc33ad22377b008", + "url": "https://api.github.com/repos/taoser/think-addons/zipball/ef97225aca7f0ec1da275c4ae025686899a91ad2", + "reference": "ef97225aca7f0ec1da275c4ae025686899a91ad2", "shasum": "" }, "require": { - "php": ">=7.1.0", - "symfony/var-exporter": "^5.4", - "topthink/framework": "^6.0", + "php": ">=8.0.0", + "symfony/var-exporter": "^6.0", + "topthink/framework": "^8.0", "topthink/think-helper": "^3.0.0", - "topthink/think-view": "^1.0" + "topthink/think-view": "^2.0" }, - "time": "2023-06-10T05:08:45+00:00", + "time": "2023-08-02T06:40:11+00:00", "type": "library", "extra": { "think": { @@ -2422,39 +996,33 @@ "email": "changlin_zhao@qq.com" } ], - "description": "The ThinkPHP6 Addons Package", + "description": "The ThinkPHP8 Addons Package", "support": { "issues": "https://github.com/taoser/think-addons/issues", - "source": "https://github.com/taoser/think-addons/tree/v1.0.9" + "source": "https://github.com/taoser/think-addons/tree/v2.0.0" }, "install-path": "../taoser/think-addons" }, { "name": "taoser/think-auth", - "version": "v1.0.1", - "version_normalized": "1.0.1.0", + "version": "v2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/taoser/think-auth.git", - "reference": "d3aa853b7d2a34624bcc566150105f2815e68ad0" + "reference": "db57156530dd8e2c020afc6e64abc1ad64e9e06c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-auth/zipball/d3aa853b7d2a34624bcc566150105f2815e68ad0", - "reference": "d3aa853b7d2a34624bcc566150105f2815e68ad0", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/taoser/think-auth/zipball/db57156530dd8e2c020afc6e64abc1ad64e9e06c", + "reference": "db57156530dd8e2c020afc6e64abc1ad64e9e06c", + "shasum": "" }, "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" + "php": ">=8.0.0", + "topthink/framework": "^8.0" }, - "time": "2023-02-26T03:08:39+00:00", + "time": "2023-08-02T06:28:49+00:00", "type": "think-extend", "extra": { "think": { @@ -2483,33 +1051,33 @@ "homepage": "https://github.com/taoser/think-auth", "keywords": [ "think-auth", - "thinkphp6" + "thinkphp8" ], "support": { "issues": "https://github.com/taoser/think-auth/issues", - "source": "https://github.com/taoser/think-auth/tree/v1.0.1" + "source": "https://github.com/taoser/think-auth/tree/v2.0.0" }, "install-path": "../taoser/think-auth" }, { "name": "taoser/think-setarr", - "version": "v0.0.3", - "version_normalized": "0.0.3.0", + "version": "v0.0.5", + "version_normalized": "0.0.5.0", "source": { "type": "git", "url": "https://github.com/taoser/think-setarr.git", - "reference": "6651c31ef42417a6294ef08e6fb970917b7e7f86" + "reference": "e436e2d855c2014dae19cbdecfd3d6c57c04aca8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/taoser/think-setarr/zipball/6651c31ef42417a6294ef08e6fb970917b7e7f86", - "reference": "6651c31ef42417a6294ef08e6fb970917b7e7f86", + "url": "https://api.github.com/repos/taoser/think-setarr/zipball/e436e2d855c2014dae19cbdecfd3d6c57c04aca8", + "reference": "e436e2d855c2014dae19cbdecfd3d6c57c04aca8", "shasum": "" }, "require": { "php": ">=7.2.0" }, - "time": "2022-04-16T23:08:43+00:00", + "time": "2022-05-09T04:22:56+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2530,112 +1098,43 @@ "description": "php confing", "support": { "issues": "https://github.com/taoser/think-setarr/issues", - "source": "https://github.com/taoser/think-setarr/tree/v0.0.3" + "source": "https://github.com/taoser/think-setarr/tree/v0.0.5" }, "install-path": "../taoser/think-setarr" }, - { - "name": "tightenco/collect", - "version": "v8.83.27", - "version_normalized": "8.83.27.0", - "source": { - "type": "git", - "url": "https://github.com/tighten/collect.git", - "reference": "07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tighten/collect/zipball/07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6", - "reference": "07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": "^7.3|^8.0", - "symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "nesbot/carbon": "^2.23.0", - "phpunit/phpunit": "^8.3" - }, - "time": "2023-01-13T18:05:42+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "src/Collect/Support/helpers.php", - "src/Collect/Support/alias.php" - ], - "psr-4": { - "Tightenco\\Collect\\": "src/Collect" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - } - ], - "description": "Collect - Illuminate Collections as a separate package.", - "keywords": [ - "collection", - "laravel" - ], - "support": { - "issues": "https://github.com/tighten/collect/issues", - "source": "https://github.com/tighten/collect/tree/v8.83.27" - }, - "install-path": "../tightenco/collect" - }, { "name": "topthink/framework", - "version": "v6.1.3", - "version_normalized": "6.1.3.0", + "version": "v8.0.1", + "version_normalized": "8.0.1.0", "source": { "type": "git", "url": "https://github.com/top-think/framework.git", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041" + "reference": "23101f0ad7581de32442553e045cffd7686a337b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/framework/zipball/7c324e7011246f0064b055b62ab9c3921cf0a041", - "reference": "7c324e7011246f0064b055b62ab9c3921cf0a041", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/top-think/framework/zipball/23101f0ad7581de32442553e045cffd7686a337b", + "reference": "23101f0ad7581de32442553e045cffd7686a337b", + "shasum": "" }, "require": { "ext-json": "*", "ext-mbstring": "*", - "php": ">=7.2.5", - "psr/container": "~1.0", + "php": ">=8.0.0", + "psr/container": "^2.0", "psr/http-message": "^1.0", - "psr/log": "~1.0", - "psr/simple-cache": "^1.0", - "topthink/think-helper": "^3.1.1", - "topthink/think-orm": "^2.0|^3.0" + "psr/log": "^3.0", + "psr/simple-cache": "^3.0", + "topthink/think-helper": "^3.1", + "topthink/think-orm": "^3.0" }, "require-dev": { "guzzlehttp/psr7": "^2.1.0", "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.2", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.5" }, - "time": "2023-05-22T03:02:08+00:00", + "time": "2023-07-09T09:12:43+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2667,7 +1166,7 @@ ], "support": { "issues": "https://github.com/top-think/framework/issues", - "source": "https://github.com/top-think/framework/tree/v6.1.3" + "source": "https://github.com/top-think/framework/tree/v8.0.1" }, "install-path": "../topthink/framework" }, @@ -2684,13 +1183,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-captcha/zipball/b1ef360670578214edeebcf824aaf6ab7ee0528b", "reference": "b1ef360670578214edeebcf824aaf6ab7ee0528b", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "topthink/framework": "^6.0|^8.0" @@ -2746,13 +1239,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-helper/zipball/769acbe50a4274327162f9c68ec2e89a38eb2aff", "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=7.1.0" @@ -2764,12 +1251,12 @@ "type": "library", "installation-source": "dist", "autoload": { - "psr-4": { - "think\\": "src" - }, "files": [ "src/helper.php" - ] + ], + "psr-4": { + "think\\": "src" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2788,117 +1275,6 @@ }, "install-path": "../topthink/think-helper" }, - { - "name": "topthink/think-installer", - "version": "v2.0.5", - "version_normalized": "2.0.5.0", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-installer.git", - "reference": "38ba647706e35d6704b5d370c06f8a160b635f88" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-installer/zipball/38ba647706e35d6704b5d370c06f8a160b635f88", - "reference": "38ba647706e35d6704b5d370c06f8a160b635f88", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "composer-plugin-api": "^1.0||^2.0" - }, - "require-dev": { - "composer/composer": "^1.0||^2.0" - }, - "time": "2021-01-14T12:12:14+00:00", - "type": "composer-plugin", - "extra": { - "class": "think\\composer\\Plugin" - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "think\\composer\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "support": { - "issues": "https://github.com/top-think/think-installer/issues", - "source": "https://github.com/top-think/think-installer/tree/v2.0.5" - }, - "install-path": "../topthink/think-installer" - }, - { - "name": "topthink/think-migration", - "version": "v3.0.5", - "version_normalized": "3.0.5.0", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-migration.git", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-migration/zipball/7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "reference": "7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca", - "shasum": "" - }, - "require": { - "topthink/framework": "^6.0", - "topthink/think-helper": "^3.0.3" - }, - "require-dev": { - "fzaninotto/faker": "^1.8" - }, - "suggest": { - "fzaninotto/faker": "Required to use the factory builder (^1.8)." - }, - "time": "2023-02-26T13:16:22+00:00", - "type": "library", - "extra": { - "think": { - "services": [ - "think\\migration\\Service" - ] - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Phinx\\": "phinx/src/Phinx", - "think\\migration\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "support": { - "issues": "https://github.com/top-think/think-migration/issues", - "source": "https://github.com/top-think/think-migration/tree/v3.0.5" - }, - "install-path": "../topthink/think-migration" - }, { "name": "topthink/think-multi-app", "version": "v1.0.17", @@ -2912,13 +1288,7 @@ "type": "zip", "url": "https://api.github.com/repos/top-think/think-multi-app/zipball/4055a6187296ac16c0bc7bbab4ed5d92f82f791c", "reference": "4055a6187296ac16c0bc7bbab4ed5d92f82f791c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "php": ">=7.1.0", @@ -2958,37 +1328,31 @@ }, { "name": "topthink/think-orm", - "version": "v2.0.61", - "version_normalized": "2.0.61.0", + "version": "v3.0.11", + "version_normalized": "3.0.11.0", "source": { "type": "git", "url": "https://github.com/top-think/think-orm.git", - "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6" + "reference": "38a6da3ae03bcae4ea2f484a4cf05687a88a5488" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-orm/zipball/10528ebf4a5106b19c3bac9c6deae7a67ff49de6", - "reference": "10528ebf4a5106b19c3bac9c6deae7a67ff49de6", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/top-think/think-orm/zipball/38a6da3ae03bcae4ea2f484a4cf05687a88a5488", + "reference": "38a6da3ae03bcae4ea2f484a4cf05687a88a5488", + "shasum": "" }, "require": { "ext-json": "*", "ext-pdo": "*", - "php": ">=7.1.0", - "psr/log": "^1.0|^2.0", - "psr/simple-cache": "^1.0|^2.0", + "php": ">=8.0.0", + "psr/log": ">=1.0", + "psr/simple-cache": ">=1.0", "topthink/think-helper": "^3.1" }, "require-dev": { - "phpunit/phpunit": "^7|^8|^9.5" + "phpunit/phpunit": "^8|^9.5|^10" }, - "time": "2023-04-20T14:27:51+00:00", + "time": "2023-07-18T11:04:31+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -3009,43 +1373,37 @@ "email": "liu21st@gmail.com" } ], - "description": "think orm", + "description": "the PHP Database&ORM Framework", "keywords": [ "database", "orm" ], "support": { "issues": "https://github.com/top-think/think-orm/issues", - "source": "https://github.com/top-think/think-orm/tree/v2.0.61" + "source": "https://github.com/top-think/think-orm/tree/v3.0.11" }, "install-path": "../topthink/think-orm" }, { "name": "topthink/think-template", - "version": "v2.0.9", - "version_normalized": "2.0.9.0", + "version": "v3.0.0", + "version_normalized": "3.0.0.0", "source": { "type": "git", "url": "https://github.com/top-think/think-template.git", - "reference": "6d25642ae0e306166742fd7073dc7a159e18073c" + "reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-template/zipball/6d25642ae0e306166742fd7073dc7a159e18073c", - "reference": "6d25642ae0e306166742fd7073dc7a159e18073c", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/top-think/think-template/zipball/4352d2cf627abfb8b49f830686c25c02f59c23f2", + "reference": "4352d2cf627abfb8b49f830686c25c02f59c23f2", + "shasum": "" }, "require": { - "php": ">=7.1.0", - "psr/simple-cache": "^1.0" + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" }, - "time": "2023-02-14T10:50:39+00:00", + "time": "2023-02-25T12:11:14+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -3066,96 +1424,30 @@ "description": "the php template engine", "support": { "issues": "https://github.com/top-think/think-template/issues", - "source": "https://github.com/top-think/think-template/tree/v2.0.9" + "source": "https://github.com/top-think/think-template/tree/v3.0.0" }, "install-path": "../topthink/think-template" }, - { - "name": "topthink/think-trace", - "version": "v1.6", - "version_normalized": "1.6.0.0", - "source": { - "type": "git", - "url": "https://github.com/top-think/think-trace.git", - "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/top-think/think-trace/zipball/136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", - "reference": "136cd5d97e8bdb780e4b5c1637c588ed7ca3e142", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0|^8.0" - }, - "time": "2023-02-07T08:36:32+00:00", - "type": "library", - "extra": { - "think": { - "services": [ - "think\\trace\\Service" - ], - "config": { - "trace": "src/config.php" - } - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "think\\trace\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - } - ], - "description": "thinkphp debug trace", - "support": { - "issues": "https://github.com/top-think/think-trace/issues", - "source": "https://github.com/top-think/think-trace/tree/v1.6" - }, - "install-path": "../topthink/think-trace" - }, { "name": "topthink/think-view", - "version": "v1.0.14", - "version_normalized": "1.0.14.0", + "version": "v2.0.0", + "version_normalized": "2.0.0.0", "source": { "type": "git", "url": "https://github.com/top-think/think-view.git", - "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d" + "reference": "d2a076011c96d2edd8016703a827fb54b2683c62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/top-think/think-view/zipball/edce0ae2c9551ab65f9e94a222604b0dead3576d", - "reference": "edce0ae2c9551ab65f9e94a222604b0dead3576d", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "url": "https://api.github.com/repos/top-think/think-view/zipball/d2a076011c96d2edd8016703a827fb54b2683c62", + "reference": "d2a076011c96d2edd8016703a827fb54b2683c62", + "shasum": "" }, "require": { - "php": ">=7.1.0", - "topthink/think-template": "^2.0" + "php": ">=8.0.0", + "topthink/think-template": "^3.0" }, - "time": "2019-11-06T11:40:13+00:00", + "time": "2023-02-25T12:18:09+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -3174,372 +1466,12 @@ } ], "description": "thinkphp template driver", + "support": { + "issues": "https://github.com/top-think/think-view/issues", + "source": "https://github.com/top-think/think-view/tree/v2.0.0" + }, "install-path": "../topthink/think-view" }, - { - "name": "wamkj/thinkphp6.0-databackup", - "version": "v1.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/wamkj/thinkphp6.0-databackup.git", - "reference": "28a0e406d827132942723a3c9f69bb20c98e652f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wamkj/thinkphp6.0-databackup/zipball/28a0e406d827132942723a3c9f69bb20c98e652f", - "reference": "28a0e406d827132942723a3c9f69bb20c98e652f", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" - }, - "time": "2020-02-15T13:04:16+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "wamkj\\thinkphp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "wamkj", - "email": "1149183529@qq.com" - } - ], - "description": "thinkphp6.0的数据库自动备份扩展", - "keywords": [ - "think-databackup", - "thinkphp" - ], - "support": { - "issues": "https://github.com/wamkj/thinkphp6.0-databackup/issues", - "source": "https://github.com/wamkj/thinkphp6.0-databackup/tree/v1.0" - }, - "install-path": "../wamkj/thinkphp6.0-databackup" - }, - { - "name": "workerman/channel", - "version": "v1.2.0", - "version_normalized": "1.2.0.0", - "source": { - "type": "git", - "url": "https://github.com/walkor/channel.git", - "reference": "fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/channel/zipball/fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e", - "reference": "fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "workerman/workerman": ">=4.0.12" - }, - "time": "2023-04-04T02:47:35+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Channel\\": "./src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "homepage": "http://www.workerman.net", - "support": { - "issues": "https://github.com/walkor/channel/issues", - "source": "https://github.com/walkor/channel/tree/v1.2.0" - }, - "install-path": "../workerman/channel" - }, - { - "name": "workerman/phpsocket.io", - "version": "v1.1.18", - "version_normalized": "1.1.18.0", - "source": { - "type": "git", - "url": "https://github.com/walkor/phpsocket.io.git", - "reference": "b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/phpsocket.io/zipball/b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b", - "reference": "b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b", - "shasum": "" - }, - "require": { - "workerman/channel": ">=1.0.0", - "workerman/workerman": "^4.0.0" - }, - "time": "2023-06-16T01:41:34+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "PHPSocketIO\\": "./src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "homepage": "http://www.workerman.net", - "keywords": [ - "Socket.io" - ], - "support": { - "issues": "https://github.com/walkor/phpsocket.io/issues", - "source": "https://github.com/walkor/phpsocket.io/tree/v1.1.18" - }, - "funding": [ - { - "url": "https://opencollective.com/walkor", - "type": "open_collective" - }, - { - "url": "https://www.patreon.com/walkor", - "type": "patreon" - } - ], - "install-path": "../workerman/phpsocket.io" - }, - { - "name": "workerman/workerman", - "version": "v4.1.10", - "version_normalized": "4.1.10.0", - "source": { - "type": "git", - "url": "https://github.com/walkor/workerman.git", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/walkor/workerman/zipball/e967b79f95b9251a72acb971be05623ec1a51e83", - "reference": "e967b79f95b9251a72acb971be05623ec1a51e83", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] - }, - "require": { - "php": ">=7.0" - }, - "suggest": { - "ext-event": "For better performance. " - }, - "time": "2023-05-01T02:12:20+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Workerman\\": "./" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "walkor", - "email": "walkor@workerman.net", - "homepage": "http://www.workerman.net", - "role": "Developer" - } - ], - "description": "An asynchronous event driven PHP framework for easily building fast, scalable network applications.", - "homepage": "http://www.workerman.net", - "keywords": [ - "asynchronous", - "event-loop" - ], - "support": { - "email": "walkor@workerman.net", - "forum": "http://wenda.workerman.net/", - "issues": "https://github.com/walkor/workerman/issues", - "source": "https://github.com/walkor/workerman", - "wiki": "http://doc.workerman.net/" - }, - "funding": [ - { - "url": "https://opencollective.com/workerman", - "type": "open_collective" - }, - { - "url": "https://www.patreon.com/walkor", - "type": "patreon" - } - ], - "install-path": "../workerman/workerman" - }, - { - "name": "yansongda/pay", - "version": "v3.1.12", - "version_normalized": "3.1.12.0", - "source": { - "type": "git", - "url": "https://github.com/yansongda/pay.git", - "reference": "7ff004f05f9d6e288ff9b4deef585d30395f37f2" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/yansongda/pay/zipball/7ff004f05f9d6e288ff9b4deef585d30395f37f2", - "reference": "7ff004f05f9d6e288ff9b4deef585d30395f37f2", - "shasum": "" - }, - "require": { - "ext-bcmath": "*", - "ext-json": "*", - "ext-libxml": "*", - "ext-openssl": "*", - "ext-simplexml": "*", - "php": ">=7.4", - "psr/container": "^1.1 | ^2.0", - "psr/event-dispatcher": "^1.0", - "psr/http-client": "^1.0", - "psr/http-message": "^1.0", - "psr/log": "^1.1 | ^2.0 | ^3.0", - "yansongda/supports": "~3.2.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "guzzlehttp/guzzle": "^7.0", - "mockery/mockery": "^1.4", - "monolog/monolog": "^2.2", - "phpstan/phpstan": "^1.0.0", - "phpunit/phpunit": "^9.0", - "symfony/event-dispatcher": "^5.2.0", - "symfony/http-foundation": "^5.2.0", - "symfony/psr-http-message-bridge": "^2.1", - "symfony/var-dumper": "^5.1" - }, - "suggest": { - "hyperf/utils": "Hyperf 框架下使用 SDK,请安装", - "illuminate/container": "Laravel 框架下使用 SDK,请安装", - "php-di/php-di": "其它/无框架下使用 SDK,请安装" - }, - "time": "2022-09-03T05:39:21+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "src/Functions.php" - ], - "psr-4": { - "Yansongda\\Pay\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "yansongda", - "email": "me@yansongda.cn" - } - ], - "description": "可能是我用过的最优雅的 Alipay 和 WeChat 的支付 SDK 扩展包了", - "keywords": [ - "alipay", - "pay", - "wechat" - ], - "support": { - "homepage": "https://pay.yansongda.cn", - "issues": "https://github.com/yansongda/pay/issues", - "source": "https://github.com/yansongda/pay" - }, - "install-path": "../yansongda/pay" - }, - { - "name": "yansongda/supports", - "version": "v3.2.5", - "version_normalized": "3.2.5.0", - "source": { - "type": "git", - "url": "https://github.com/yansongda/supports.git", - "reference": "c3f736efe169696cef94730976e604a61c345b5c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/yansongda/supports/zipball/c3f736efe169696cef94730976e604a61c345b5c", - "reference": "c3f736efe169696cef94730976e604a61c345b5c", - "shasum": "" - }, - "require": { - "php": ">=7.4" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.0", - "mockery/mockery": "^1.4", - "monolog/monolog": "^2.0", - "phpstan/phpstan": "^1.1.0", - "phpunit/phpunit": "^9.0", - "symfony/console": "^5.1" - }, - "suggest": { - "monolog/monolog": "Use logger", - "symfony/console": "Use stdout logger" - }, - "time": "2022-03-28T10:25:04+00:00", - "type": "library", - "installation-source": "dist", - "autoload": { - "files": [ - "src/Functions.php" - ], - "psr-4": { - "Yansongda\\Supports\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "yansongda", - "email": "me@yansongda.cn" - } - ], - "description": "common components", - "keywords": [ - "array", - "collection", - "config", - "support" - ], - "support": { - "issues": "https://github.com/yansongda/supports/issues", - "source": "https://github.com/yansongda/supports" - }, - "install-path": "../yansongda/supports" - }, { "name": "yzh52521/easyhttp", "version": "v1.0.7", @@ -3553,13 +1485,7 @@ "type": "zip", "url": "https://api.github.com/repos/yzh52521/easyhttp/zipball/52cb9aba60a725bef77acd9c4c48ecc78931af9e", "reference": "52cb9aba60a725bef77acd9c4c48ecc78931af9e", - "shasum": "", - "mirrors": [ - { - "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", - "preferred": true - } - ] + "shasum": "" }, "require": { "guzzlehttp/guzzle": "^6.0|^7.0", @@ -3603,7 +1529,5 @@ } ], "dev": true, - "dev-package-names": [ - "topthink/think-trace" - ] + "dev-package-names": [] } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 3c23038..23e0f3d 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,195 +1,42 @@ array( 'name' => 'taoser/taoler', - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6', + 'pretty_version' => '3.0.x-dev', + 'version' => '3.0.9999999.9999999-dev', + 'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => true, ), 'versions' => array( - 'bacon/bacon-qr-code' => array( - 'pretty_version' => '2.0.8', - 'version' => '2.0.8.0', - 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', - 'type' => 'library', - 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'cache/adapter-common' => array( - 'pretty_version' => '1.3.0', - 'version' => '1.3.0.0', - 'reference' => '8788309be72aa7be69b88cdc0687549c74a7d479', - 'type' => 'library', - 'install_path' => __DIR__ . '/../cache/adapter-common', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'cache/filesystem-adapter' => array( - 'pretty_version' => '1.2.0', - 'version' => '1.2.0.0', - 'reference' => 'f1faaae40aaa696ef899cef6f6888aedb90b419b', - 'type' => 'library', - 'install_path' => __DIR__ . '/../cache/filesystem-adapter', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'cache/tag-interop' => array( - 'pretty_version' => '1.1.0', - 'version' => '1.1.0.0', - 'reference' => 'b062b1d735357da50edf8387f7a8696f3027d328', - 'type' => 'library', - 'install_path' => __DIR__ . '/../cache/tag-interop', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'dasprid/enum' => array( - 'pretty_version' => '1.0.4', - 'version' => '1.0.4.0', - 'reference' => '8e6b6ea76eabbf19ea2bf5b67b98e1860474012f', - 'type' => 'library', - 'install_path' => __DIR__ . '/../dasprid/enum', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'endroid/qr-code' => array( - 'pretty_version' => '4.6.1', - 'version' => '4.6.1.0', - 'reference' => 'a75c913b0e4d6ad275e49a2c1de1cacffc6c2184', - 'type' => 'library', - 'install_path' => __DIR__ . '/../endroid/qr-code', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'guzzlehttp/guzzle' => array( - 'pretty_version' => '7.0.0', - 'version' => '7.0.0.0', - 'reference' => '414c24961042f6616fb43e23fa69a785f9fc053e', + 'pretty_version' => '7.7.0', + 'version' => '7.7.0.0', + 'reference' => 'fb7566caccf22d74d1ab270de3551f72a58399f5', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => false, ), 'guzzlehttp/promises' => array( - 'pretty_version' => '1.5.3', - 'version' => '1.5.3.0', - 'reference' => '67ab6e18aaa14d753cc148911d273f6e6cb6721e', + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'reference' => '3a494dc7dc1d7d12e511890177ae2d0e6c107da6', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => false, ), 'guzzlehttp/psr7' => array( - 'pretty_version' => '1.9.1', - 'version' => '1.9.1.0', - 'reference' => 'e4490cabc77465aaee90b20cfc9a770f8c04be6b', + 'pretty_version' => '2.5.0', + 'version' => '2.5.0.0', + 'reference' => 'b635f279edd83fc275f822a1188157ffea568ff6', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => false, ), - 'jaeger/g-http' => array( - 'pretty_version' => 'V1.7.2', - 'version' => '1.7.2.0', - 'reference' => '82585ddd5e2c6651e37ab1d8166efcdbb6b293d4', - 'type' => 'library', - 'install_path' => __DIR__ . '/../jaeger/g-http', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'jaeger/phpquery-single' => array( - 'pretty_version' => '1.1.1', - 'version' => '1.1.1.0', - 'reference' => '39a650ade692a6b480c22220dce0c198d6a946fb', - 'type' => 'library', - 'install_path' => __DIR__ . '/../jaeger/phpquery-single', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'jaeger/querylist' => array( - 'pretty_version' => 'V4.2.8', - 'version' => '4.2.8.0', - 'reference' => '39dc0ca9c668bec7a793e20472ccd7d26ef89ea4', - 'type' => 'library', - 'install_path' => __DIR__ . '/../jaeger/querylist', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'laravel/serializable-closure' => array( - 'pretty_version' => 'v1.3.0', - 'version' => '1.3.0.0', - 'reference' => 'f23fe9d4e95255dacee1bf3525e0810d1a1b0f37', - 'type' => 'library', - 'install_path' => __DIR__ . '/../laravel/serializable-closure', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'league/flysystem' => array( - 'pretty_version' => '1.1.10', - 'version' => '1.1.10.0', - 'reference' => '3239285c825c152bcc315fe0e87d6b55f5972ed1', - 'type' => 'library', - 'install_path' => __DIR__ . '/../league/flysystem', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'league/mime-type-detection' => array( - 'pretty_version' => '1.11.0', - 'version' => '1.11.0.0', - 'reference' => 'ff6248ea87a9f116e78edd6002e39e5128a0d4dd', - 'type' => 'library', - 'install_path' => __DIR__ . '/../league/mime-type-detection', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'liliuwei/thinkphp-social' => array( - 'pretty_version' => 'v1.3', - 'version' => '1.3.0.0', - 'reference' => '2067fc2c2cc3b3d109602bc19c3e5a99c5f4c970', - 'type' => 'think-extend', - 'install_path' => __DIR__ . '/../liliuwei/thinkphp-social', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'lotofbadcode/phpspirit_databackup' => array( - 'pretty_version' => 'v1.2', - 'version' => '1.2.0.0', - 'reference' => '77c2421f8461392c044cf8c29918f495c22a5612', - 'type' => 'library', - 'install_path' => __DIR__ . '/../lotofbadcode/phpspirit_databackup', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'php-di/invoker' => array( - 'pretty_version' => '2.3.3', - 'version' => '2.3.3.0', - 'reference' => 'cd6d9f267d1a3474bdddf1be1da079f01b942786', - 'type' => 'library', - 'install_path' => __DIR__ . '/../php-di/invoker', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'php-di/php-di' => array( - 'pretty_version' => '6.4.0', - 'version' => '6.4.0.0', - 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', - 'type' => 'library', - 'install_path' => __DIR__ . '/../php-di/php-di', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'php-di/phpdoc-reader' => array( - 'pretty_version' => '2.2.1', - 'version' => '2.2.1.0', - 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', - 'type' => 'library', - 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'phpmailer/phpmailer' => array( 'pretty_version' => 'v6.8.0', 'version' => '6.8.0.0', @@ -199,45 +46,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'psr/cache' => array( - 'pretty_version' => '1.0.1', - 'version' => '1.0.1.0', - 'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8', - 'type' => 'library', - 'install_path' => __DIR__ . '/../psr/cache', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'psr/cache-implementation' => array( - 'dev_requirement' => false, - 'provided' => array( - 0 => '^1.0', - ), - ), 'psr/container' => array( - 'pretty_version' => '1.1.2', - 'version' => '1.1.2.0', - 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => false, ), - 'psr/container-implementation' => array( - 'dev_requirement' => false, - 'provided' => array( - 0 => '^1.0', - ), - ), - 'psr/event-dispatcher' => array( - 'pretty_version' => '1.0.0', - 'version' => '1.0.0.0', - 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0', - 'type' => 'library', - 'install_path' => __DIR__ . '/../psr/event-dispatcher', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'psr/http-client' => array( 'pretty_version' => '1.0.2', 'version' => '1.0.2.0', @@ -253,6 +70,21 @@ 0 => '1.0', ), ), + 'psr/http-factory' => array( + 'pretty_version' => '1.0.2', + 'version' => '1.0.2.0', + 'reference' => 'e616d01114759c4c489f93b099585439f795fe35', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), 'psr/http-message' => array( 'pretty_version' => '1.1', 'version' => '1.1.0.0', @@ -269,29 +101,23 @@ ), ), 'psr/log' => array( - 'pretty_version' => '1.1.4', - 'version' => '1.1.4.0', - 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => false, ), 'psr/simple-cache' => array( - 'pretty_version' => '1.0.1', - 'version' => '1.0.1.0', - 'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b', + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/simple-cache', 'aliases' => array(), 'dev_requirement' => false, ), - 'psr/simple-cache-implementation' => array( - 'dev_requirement' => false, - 'provided' => array( - 0 => '^1.0', - ), - ), 'ralouphie/getallheaders' => array( 'pretty_version' => '3.0.3', 'version' => '3.0.3.0', @@ -301,100 +127,64 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'symfony/polyfill-mbstring' => array( - 'pretty_version' => 'v1.27.0', - 'version' => '1.27.0.0', - 'reference' => '8ad114f6b39e2c98a8b0e3bd907732c207c2b534', + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v3.3.0', + 'version' => '3.3.0.0', + 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-php72' => array( - 'pretty_version' => 'v1.27.0', - 'version' => '1.27.0.0', - 'reference' => '869329b1e9894268a8a61dabb69153029b7a8c97', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-php72', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/polyfill-php80' => array( - 'pretty_version' => 'v1.27.0', - 'version' => '1.27.0.0', - 'reference' => '7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/polyfill-php80', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'symfony/var-dumper' => array( - 'pretty_version' => 'v4.4.47', - 'version' => '4.4.47.0', - 'reference' => '1069c7a3fca74578022fab6f81643248d02f8e63', - 'type' => 'library', - 'install_path' => __DIR__ . '/../symfony/var-dumper', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => false, ), 'symfony/var-exporter' => array( - 'pretty_version' => 'v5.4.21', - 'version' => '5.4.21.0', - 'reference' => 'be74908a6942fdd331554b3cec27ff41b45ccad4', + 'pretty_version' => 'v6.3.2', + 'version' => '6.3.2.0', + 'reference' => '3400949782c0cb5b3e73aa64cfd71dde000beccc', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/var-exporter', 'aliases' => array(), 'dev_requirement' => false, ), 'taoser/taoler' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '4be45082e6e9bbe7fa38b4fca5566a08fe1a24a6', + 'pretty_version' => '3.0.x-dev', + 'version' => '3.0.9999999.9999999-dev', + 'reference' => '0c2f0154a81dd0a6268da627982d1bf41c0ef231', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'taoser/think-addons' => array( - 'pretty_version' => 'v1.0.9', - 'version' => '1.0.9.0', - 'reference' => '00112adf200b897deecbd1bbabc33ad22377b008', + 'pretty_version' => 'v2.0.0', + 'version' => '2.0.0.0', + 'reference' => 'ef97225aca7f0ec1da275c4ae025686899a91ad2', 'type' => 'library', 'install_path' => __DIR__ . '/../taoser/think-addons', 'aliases' => array(), 'dev_requirement' => false, ), 'taoser/think-auth' => array( - 'pretty_version' => 'v1.0.1', - 'version' => '1.0.1.0', - 'reference' => 'd3aa853b7d2a34624bcc566150105f2815e68ad0', + 'pretty_version' => 'v2.0.0', + 'version' => '2.0.0.0', + 'reference' => 'db57156530dd8e2c020afc6e64abc1ad64e9e06c', 'type' => 'think-extend', 'install_path' => __DIR__ . '/../taoser/think-auth', 'aliases' => array(), 'dev_requirement' => false, ), 'taoser/think-setarr' => array( - 'pretty_version' => 'v0.0.3', - 'version' => '0.0.3.0', - 'reference' => '6651c31ef42417a6294ef08e6fb970917b7e7f86', + 'pretty_version' => 'v0.0.5', + 'version' => '0.0.5.0', + 'reference' => 'e436e2d855c2014dae19cbdecfd3d6c57c04aca8', 'type' => 'library', 'install_path' => __DIR__ . '/../taoser/think-setarr', 'aliases' => array(), 'dev_requirement' => false, ), - 'tightenco/collect' => array( - 'pretty_version' => 'v8.83.27', - 'version' => '8.83.27.0', - 'reference' => '07eed6cf7441c7a69c379fdcb118eec1a1fdd0e6', - 'type' => 'library', - 'install_path' => __DIR__ . '/../tightenco/collect', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'topthink/framework' => array( - 'pretty_version' => 'v6.1.3', - 'version' => '6.1.3.0', - 'reference' => '7c324e7011246f0064b055b62ab9c3921cf0a041', + 'pretty_version' => 'v8.0.1', + 'version' => '8.0.1.0', + 'reference' => '23101f0ad7581de32442553e045cffd7686a337b', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/framework', 'aliases' => array(), @@ -418,24 +208,6 @@ 'aliases' => array(), 'dev_requirement' => false, ), - 'topthink/think-installer' => array( - 'pretty_version' => 'v2.0.5', - 'version' => '2.0.5.0', - 'reference' => '38ba647706e35d6704b5d370c06f8a160b635f88', - 'type' => 'composer-plugin', - 'install_path' => __DIR__ . '/../topthink/think-installer', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'topthink/think-migration' => array( - 'pretty_version' => 'v3.0.5', - 'version' => '3.0.5.0', - 'reference' => '7a5ec3952ea97bf1a5d8872e1bd10f2abf6294ca', - 'type' => 'library', - 'install_path' => __DIR__ . '/../topthink/think-migration', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'topthink/think-multi-app' => array( 'pretty_version' => 'v1.0.17', 'version' => '1.0.17.0', @@ -446,95 +218,32 @@ 'dev_requirement' => false, ), 'topthink/think-orm' => array( - 'pretty_version' => 'v2.0.61', - 'version' => '2.0.61.0', - 'reference' => '10528ebf4a5106b19c3bac9c6deae7a67ff49de6', + 'pretty_version' => 'v3.0.11', + 'version' => '3.0.11.0', + 'reference' => '38a6da3ae03bcae4ea2f484a4cf05687a88a5488', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-orm', 'aliases' => array(), 'dev_requirement' => false, ), 'topthink/think-template' => array( - 'pretty_version' => 'v2.0.9', - 'version' => '2.0.9.0', - 'reference' => '6d25642ae0e306166742fd7073dc7a159e18073c', + 'pretty_version' => 'v3.0.0', + 'version' => '3.0.0.0', + 'reference' => '4352d2cf627abfb8b49f830686c25c02f59c23f2', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-template', 'aliases' => array(), 'dev_requirement' => false, ), - 'topthink/think-trace' => array( - 'pretty_version' => 'v1.6', - 'version' => '1.6.0.0', - 'reference' => '136cd5d97e8bdb780e4b5c1637c588ed7ca3e142', - 'type' => 'library', - 'install_path' => __DIR__ . '/../topthink/think-trace', - 'aliases' => array(), - 'dev_requirement' => true, - ), 'topthink/think-view' => array( - 'pretty_version' => 'v1.0.14', - 'version' => '1.0.14.0', - 'reference' => 'edce0ae2c9551ab65f9e94a222604b0dead3576d', + 'pretty_version' => 'v2.0.0', + 'version' => '2.0.0.0', + 'reference' => 'd2a076011c96d2edd8016703a827fb54b2683c62', 'type' => 'library', 'install_path' => __DIR__ . '/../topthink/think-view', 'aliases' => array(), 'dev_requirement' => false, ), - 'wamkj/thinkphp6.0-databackup' => array( - 'pretty_version' => 'v1.0', - 'version' => '1.0.0.0', - 'reference' => '28a0e406d827132942723a3c9f69bb20c98e652f', - 'type' => 'library', - 'install_path' => __DIR__ . '/../wamkj/thinkphp6.0-databackup', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'workerman/channel' => array( - 'pretty_version' => 'v1.2.0', - 'version' => '1.2.0.0', - 'reference' => 'fbfb81c7ebc5858c4053f226cbb5d15fe670ff6e', - 'type' => 'library', - 'install_path' => __DIR__ . '/../workerman/channel', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'workerman/phpsocket.io' => array( - 'pretty_version' => 'v1.1.18', - 'version' => '1.1.18.0', - 'reference' => 'b89b3f2ed44f6f79fd9895e2d198b52b3fb4783b', - 'type' => 'library', - 'install_path' => __DIR__ . '/../workerman/phpsocket.io', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'workerman/workerman' => array( - 'pretty_version' => 'v4.1.10', - 'version' => '4.1.10.0', - 'reference' => 'e967b79f95b9251a72acb971be05623ec1a51e83', - 'type' => 'library', - 'install_path' => __DIR__ . '/../workerman/workerman', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'yansongda/pay' => array( - 'pretty_version' => 'v3.1.12', - 'version' => '3.1.12.0', - 'reference' => '7ff004f05f9d6e288ff9b4deef585d30395f37f2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../yansongda/pay', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'yansongda/supports' => array( - 'pretty_version' => 'v3.2.5', - 'version' => '3.2.5.0', - 'reference' => 'c3f736efe169696cef94730976e604a61c345b5c', - 'type' => 'library', - 'install_path' => __DIR__ . '/../yansongda/supports', - 'aliases' => array(), - 'dev_requirement' => false, - ), 'yzh52521/easyhttp' => array( 'pretty_version' => 'v1.0.7', 'version' => '1.0.7.0', diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index 580fa96..4c3a5d6 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 70400)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; } if ($issues) { diff --git a/vendor/dasprid/enum/.github/workflows/tests.yml b/vendor/dasprid/enum/.github/workflows/tests.yml deleted file mode 100644 index 94b2562..0000000 --- a/vendor/dasprid/enum/.github/workflows/tests.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Tests - -on: [push, pull_request] - -jobs: - php-tests: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1] - dependency-version: [prefer-stable] - os: [ubuntu-latest, windows-latest] - - name: ${{ matrix.os }} - PHP${{ matrix.php }} - ${{ matrix.dependency-version }} - - steps: - - name: Set git to use LF - run: | - git config --global core.autocrlf false - git config --global core.eol lf - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: ~/.composer/cache/files - key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Install dependencies - run: | - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction - - - name: Execute tests - run: vendor/bin/phpunit - - - name: Code Sniffer - run: vendor/bin/phpcs - diff --git a/vendor/dasprid/enum/LICENSE b/vendor/dasprid/enum/LICENSE deleted file mode 100644 index d45a356..0000000 --- a/vendor/dasprid/enum/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2017, Ben Scholzen 'DASPRiD' -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. 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. - -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. diff --git a/vendor/dasprid/enum/README.md b/vendor/dasprid/enum/README.md deleted file mode 100644 index da37045..0000000 --- a/vendor/dasprid/enum/README.md +++ /dev/null @@ -1,164 +0,0 @@ -# PHP 7.1 enums - -[![Build Status](https://github.com/DASPRiD/Enum/actions/workflows/tests.yml/badge.svg)](https://github.com/DASPRiD/Enum/actions?query=workflow%3Atests) -[![Coverage Status](https://coveralls.io/repos/github/DASPRiD/Enum/badge.svg?branch=master)](https://coveralls.io/github/DASPRiD/Enum?branch=master) -[![Latest Stable Version](https://poser.pugx.org/dasprid/enum/v/stable)](https://packagist.org/packages/dasprid/enum) -[![Total Downloads](https://poser.pugx.org/dasprid/enum/downloads)](https://packagist.org/packages/dasprid/enum) -[![License](https://poser.pugx.org/dasprid/enum/license)](https://packagist.org/packages/dasprid/enum) - -It is a well known fact that PHP is missing a basic enum type, ignoring the rather incomplete `SplEnum` implementation -which is only available as a PECL extension. There are also quite a few other userland enum implementations around, -but all of them have one or another compromise. This library tries to close that gap as far as PHP allows it to. - -## Usage - -### Basics - -At its core, there is the `DASPRiD\Enum\AbstractEnum` class, which by default will work with constants like any other -enum implementation you might know. The first clear difference is that you should define all the constants as protected -(so nobody outside your class can read them but the `AbstractEnum` can still do so). The other even mightier difference -is that, for simple enums, the value of the constant doesn't matter at all. Let's have a look at a simple example: - -```php -use DASPRiD\Enum\AbstractEnum; - -/** - * @method static self MONDAY() - * @method static self TUESDAY() - * @method static self WEDNESDAY() - * @method static self THURSDAY() - * @method static self FRIDAY() - * @method static self SATURDAY() - * @method static self SUNDAY() - */ -final class WeekDay extends AbstractEnum -{ - protected const MONDAY = null; - protected const TUESDAY = null; - protected const WEDNESDAY = null; - protected const THURSDAY = null; - protected const FRIDAY = null; - protected const SATURDAY = null; - protected const SUNDAY = null; -} -``` - -If you need to provide constants for either internal use or public use, you can mark them as either private or public, -in which case they will be ignored by the enum, which only considers protected constants as valid values. As you can -see, we specifically defined the generated magic methods in a class level doc block, so anyone using this class will -automatically have proper auto-completion in their IDE. Now since you have defined the enum, you can simply use it like -that: - -```php -function tellItLikeItIs(WeekDay $weekDay) -{ - switch ($weekDay) { - case WeekDay::MONDAY(): - echo 'Mondays are bad.'; - break; - - case WeekDay::FRIDAY(): - echo 'Fridays are better.'; - break; - - case WeekDay::SATURDAY(): - case WeekDay::SUNDAY(): - echo 'Weekends are best.'; - break; - - default: - echo 'Midweek days are so-so.'; - } -} - -tellItLikeItIs(WeekDay::MONDAY()); -tellItLikeItIs(WeekDay::WEDNESDAY()); -tellItLikeItIs(WeekDay::FRIDAY()); -tellItLikeItIs(WeekDay::SATURDAY()); -tellItLikeItIs(WeekDay::SUNDAY()); -``` - -### More complex example - -Of course, all enums are singletons, which are not cloneable or serializable. Thus you can be sure that there is always -just one instance of the same type. Of course, the values of constants are not completely useless, let's have a look at -a more complex example: - -```php -use DASPRiD\Enum\AbstractEnum; - -/** - * @method static self MERCURY() - * @method static self VENUS() - * @method static self EARTH() - * @method static self MARS() - * @method static self JUPITER() - * @method static self SATURN() - * @method static self URANUS() - * @method static self NEPTUNE() - */ -final class Planet extends AbstractEnum -{ - protected const MERCURY = [3.303e+23, 2.4397e6]; - protected const VENUS = [4.869e+24, 6.0518e6]; - protected const EARTH = [5.976e+24, 6.37814e6]; - protected const MARS = [6.421e+23, 3.3972e6]; - protected const JUPITER = [1.9e+27, 7.1492e7]; - protected const SATURN = [5.688e+26, 6.0268e7]; - protected const URANUS = [8.686e+25, 2.5559e7]; - protected const NEPTUNE = [1.024e+26, 2.4746e7]; - - /** - * Universal gravitational constant. - * - * @var float - */ - private const G = 6.67300E-11; - - /** - * Mass in kilograms. - * - * @var float - */ - private $mass; - - /** - * Radius in meters. - * - * @var float - */ - private $radius; - - protected function __construct(float $mass, float $radius) - { - $this->mass = $mass; - $this->radius = $radius; - } - - public function mass() : float - { - return $this->mass; - } - - public function radius() : float - { - return $this->radius; - } - - public function surfaceGravity() : float - { - return self::G * $this->mass / ($this->radius * $this->radius); - } - - public function surfaceWeight(float $otherMass) : float - { - return $otherMass * $this->surfaceGravity(); - } -} - -$myMass = 80; - -foreach (Planet::values() as $planet) { - printf("Your weight on %s is %f\n", $planet, $planet->surfaceWeight($myMass)); -} -``` diff --git a/vendor/dasprid/enum/composer.json b/vendor/dasprid/enum/composer.json deleted file mode 100644 index 133e279..0000000 --- a/vendor/dasprid/enum/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "dasprid/enum", - "description": "PHP 7.1 enum implementation", - "license": "BSD-2-Clause", - "authors": [ - { - "name": "Ben Scholzen 'DASPRiD'", - "email": "mail@dasprids.de", - "homepage": "https://dasprids.de/", - "role": "Developer" - } - ], - "keywords": [ - "enum", - "map" - ], - "require": { - "php": ">=7.1 <9.0" - }, - "require-dev": { - "phpunit/phpunit": "^7 | ^8 | ^9", - "squizlabs/php_codesniffer": "*" - }, - "autoload": { - "psr-4": { - "DASPRiD\\Enum\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "DASPRiD\\EnumTest\\": "test/" - } - } -} diff --git a/vendor/dasprid/enum/phpunit.xml.dist b/vendor/dasprid/enum/phpunit.xml.dist deleted file mode 100644 index 307a430..0000000 --- a/vendor/dasprid/enum/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - - ./test - - - - - - src - - - diff --git a/vendor/dasprid/enum/src/AbstractEnum.php b/vendor/dasprid/enum/src/AbstractEnum.php deleted file mode 100644 index 79fe81c..0000000 --- a/vendor/dasprid/enum/src/AbstractEnum.php +++ /dev/null @@ -1,241 +0,0 @@ -> - */ - private static $values = []; - - /** - * @var array - */ - private static $allValuesLoaded = []; - - /** - * @var array - */ - private static $constants = []; - - /** - * The constructor is private by default to avoid arbitrary enum creation. - * - * When creating your own constructor for a parameterized enum, make sure to declare it as protected, so that - * the static methods are able to construct it. Avoid making it public, as that would allow creation of - * non-singleton enum instances. - */ - private function __construct() - { - } - - /** - * Magic getter which forwards all calls to {@see self::valueOf()}. - * - * @return static - */ - final public static function __callStatic(string $name, array $arguments) : self - { - return static::valueOf($name); - } - - /** - * Returns an enum with the specified name. - * - * The name must match exactly an identifier used to declare an enum in this type (extraneous whitespace characters - * are not permitted). - * - * @return static - * @throws IllegalArgumentException if the enum has no constant with the specified name - */ - final public static function valueOf(string $name) : self - { - if (isset(self::$values[static::class][$name])) { - return self::$values[static::class][$name]; - } - - $constants = self::constants(); - - if (array_key_exists($name, $constants)) { - return self::createValue($name, $constants[$name][0], $constants[$name][1]); - } - - throw new IllegalArgumentException(sprintf('No enum constant %s::%s', static::class, $name)); - } - - /** - * @return static - */ - private static function createValue(string $name, int $ordinal, array $arguments) : self - { - $instance = new static(...$arguments); - $instance->name = $name; - $instance->ordinal = $ordinal; - self::$values[static::class][$name] = $instance; - return $instance; - } - - /** - * Obtains all possible types defined by this enum. - * - * @return static[] - */ - final public static function values() : array - { - if (isset(self::$allValuesLoaded[static::class])) { - return self::$values[static::class]; - } - - if (! isset(self::$values[static::class])) { - self::$values[static::class] = []; - } - - foreach (self::constants() as $name => $constant) { - if (array_key_exists($name, self::$values[static::class])) { - continue; - } - - static::createValue($name, $constant[0], $constant[1]); - } - - uasort(self::$values[static::class], function (self $a, self $b) { - return $a->ordinal() <=> $b->ordinal(); - }); - - self::$allValuesLoaded[static::class] = true; - return self::$values[static::class]; - } - - private static function constants() : array - { - if (isset(self::$constants[static::class])) { - return self::$constants[static::class]; - } - - self::$constants[static::class] = []; - $reflectionClass = new ReflectionClass(static::class); - $ordinal = -1; - - foreach ($reflectionClass->getReflectionConstants() as $reflectionConstant) { - if (! $reflectionConstant->isProtected()) { - continue; - } - - $value = $reflectionConstant->getValue(); - - self::$constants[static::class][$reflectionConstant->name] = [ - ++$ordinal, - is_array($value) ? $value : [] - ]; - } - - return self::$constants[static::class]; - } - - /** - * Returns the name of this enum constant, exactly as declared in its enum declaration. - * - * Most programmers should use the {@see self::__toString()} method in preference to this one, as the toString - * method may return a more user-friendly name. This method is designed primarily for use in specialized situations - * where correctness depends on getting the exact name, which will not vary from release to release. - */ - final public function name() : string - { - return $this->name; - } - - /** - * Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial - * constant is assigned an ordinal of zero). - * - * Most programmers will have no use for this method. It is designed for use by sophisticated enum-based data - * structures. - */ - final public function ordinal() : int - { - return $this->ordinal; - } - - /** - * Compares this enum with the specified object for order. - * - * Returns negative integer, zero or positive integer as this object is less than, equal to or greater than the - * specified object. - * - * Enums are only comparable to other enums of the same type. The natural order implemented by this method is the - * order in which the constants are declared. - * - * @throws MismatchException if the passed enum is not of the same type - */ - final public function compareTo(self $other) : int - { - if (! $other instanceof static) { - throw new MismatchException(sprintf( - 'The passed enum %s is not of the same type as %s', - get_class($other), - static::class - )); - } - - return $this->ordinal - $other->ordinal; - } - - /** - * Forbid cloning enums. - * - * @throws CloneNotSupportedException - */ - final public function __clone() - { - throw new CloneNotSupportedException(); - } - - /** - * Forbid serializing enums. - * - * @throws SerializeNotSupportedException - */ - final public function __sleep() : array - { - throw new SerializeNotSupportedException(); - } - - /** - * Forbid unserializing enums. - * - * @throws UnserializeNotSupportedException - */ - final public function __wakeup() : void - { - throw new UnserializeNotSupportedException(); - } - - /** - * Turns the enum into a string representation. - * - * You may override this method to give a more user-friendly version. - */ - public function __toString() : string - { - return $this->name; - } -} diff --git a/vendor/dasprid/enum/src/EnumMap.php b/vendor/dasprid/enum/src/EnumMap.php deleted file mode 100644 index 95b8856..0000000 --- a/vendor/dasprid/enum/src/EnumMap.php +++ /dev/null @@ -1,385 +0,0 @@ - - */ - private $keyUniverse; - - /** - * Array representation of this map. The ith element is the value to which universe[i] is currently mapped, or null - * if it isn't mapped to anything, or NullValue if it's mapped to null. - * - * @var array - */ - private $values; - - /** - * @var int - */ - private $size = 0; - - /** - * Creates a new enum map. - * - * @param string $keyType the type of the keys, must extend AbstractEnum - * @param string $valueType the type of the values - * @param bool $allowNullValues whether to allow null values - * @throws IllegalArgumentException when key type does not extend AbstractEnum - */ - public function __construct(string $keyType, string $valueType, bool $allowNullValues) - { - if (! is_subclass_of($keyType, AbstractEnum::class)) { - throw new IllegalArgumentException(sprintf( - 'Class %s does not extend %s', - $keyType, - AbstractEnum::class - )); - } - - $this->keyType = $keyType; - $this->valueType = $valueType; - $this->allowNullValues = $allowNullValues; - $this->keyUniverse = $keyType::values(); - $this->values = array_fill(0, count($this->keyUniverse), null); - } - - public function __serialize(): array - { - $values = []; - - foreach ($this->values as $ordinal => $value) { - if (null === $value) { - continue; - } - - $values[$ordinal] = $this->unmaskNull($value); - } - - return [ - 'keyType' => $this->keyType, - 'valueType' => $this->valueType, - 'allowNullValues' => $this->allowNullValues, - 'values' => $values, - ]; - } - - public function __unserialize(array $data): void - { - $this->unserialize(serialize($data)); - } - - /** - * Checks whether the map types match the supplied ones. - * - * You should call this method when an EnumMap is passed to you and you want to ensure that it's made up of the - * correct types. - * - * @throws ExpectationException when supplied key type mismatches local key type - * @throws ExpectationException when supplied value type mismatches local value type - * @throws ExpectationException when the supplied map allows null values, abut should not - */ - public function expect(string $keyType, string $valueType, bool $allowNullValues) : void - { - if ($keyType !== $this->keyType) { - throw new ExpectationException(sprintf( - 'Callee expected an EnumMap with key type %s, but got %s', - $keyType, - $this->keyType - )); - } - - if ($valueType !== $this->valueType) { - throw new ExpectationException(sprintf( - 'Callee expected an EnumMap with value type %s, but got %s', - $keyType, - $this->keyType - )); - } - - if ($allowNullValues !== $this->allowNullValues) { - throw new ExpectationException(sprintf( - 'Callee expected an EnumMap with nullable flag %s, but got %s', - ($allowNullValues ? 'true' : 'false'), - ($this->allowNullValues ? 'true' : 'false') - )); - } - } - - /** - * Returns the number of key-value mappings in this map. - */ - public function size() : int - { - return $this->size; - } - - /** - * Returns true if this map maps one or more keys to the specified value. - */ - public function containsValue($value) : bool - { - return in_array($this->maskNull($value), $this->values, true); - } - - /** - * Returns true if this map contains a mapping for the specified key. - */ - public function containsKey(AbstractEnum $key) : bool - { - $this->checkKeyType($key); - return null !== $this->values[$key->ordinal()]; - } - - /** - * Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. - * - * More formally, if this map contains a mapping from a key to a value, then this method returns the value; - * otherwise it returns null (there can be at most one such mapping). - * - * A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also - * possible that hte map explicitly maps the key to null. The {@see self::containsKey()} operation may be used to - * distinguish these two cases. - * - * @return mixed - */ - public function get(AbstractEnum $key) - { - $this->checkKeyType($key); - return $this->unmaskNull($this->values[$key->ordinal()]); - } - - /** - * Associates the specified value with the specified key in this map. - * - * If the map previously contained a mapping for this key, the old value is replaced. - * - * @return mixed the previous value associated with the specified key, or null if there was no mapping for the key. - * (a null return can also indicate that the map previously associated null with the specified key.) - * @throws IllegalArgumentException when the passed values does not match the internal value type - */ - public function put(AbstractEnum $key, $value) - { - $this->checkKeyType($key); - - if (! $this->isValidValue($value)) { - throw new IllegalArgumentException(sprintf('Value is not of type %s', $this->valueType)); - } - - $index = $key->ordinal(); - $oldValue = $this->values[$index]; - $this->values[$index] = $this->maskNull($value); - - if (null === $oldValue) { - ++$this->size; - } - - return $this->unmaskNull($oldValue); - } - - /** - * Removes the mapping for this key frm this map if present. - * - * @return mixed the previous value associated with the specified key, or null if there was no mapping for the key. - * (a null return can also indicate that the map previously associated null with the specified key.) - */ - public function remove(AbstractEnum $key) - { - $this->checkKeyType($key); - - $index = $key->ordinal(); - $oldValue = $this->values[$index]; - $this->values[$index] = null; - - if (null !== $oldValue) { - --$this->size; - } - - return $this->unmaskNull($oldValue); - } - - /** - * Removes all mappings from this map. - */ - public function clear() : void - { - $this->values = array_fill(0, count($this->keyUniverse), null); - $this->size = 0; - } - - /** - * Compares the specified map with this map for quality. - * - * Returns true if the two maps represent the same mappings. - */ - public function equals(self $other) : bool - { - if ($this === $other) { - return true; - } - - if ($this->size !== $other->size) { - return false; - } - - return $this->values === $other->values; - } - - /** - * Returns the values contained in this map. - * - * The array will contain the values in the order their corresponding keys appear in the map, which is their natural - * order (the order in which the num constants are declared). - */ - public function values() : array - { - return array_values(array_map(function ($value) { - return $this->unmaskNull($value); - }, array_filter($this->values, function ($value) : bool { - return null !== $value; - }))); - } - - public function serialize() : string - { - return serialize($this->__serialize()); - } - - public function unserialize($serialized) : void - { - $data = unserialize($serialized); - $this->__construct($data['keyType'], $data['valueType'], $data['allowNullValues']); - - foreach ($this->keyUniverse as $key) { - if (array_key_exists($key->ordinal(), $data['values'])) { - $this->put($key, $data['values'][$key->ordinal()]); - } - } - } - - public function getIterator() : Traversable - { - foreach ($this->keyUniverse as $key) { - if (null === $this->values[$key->ordinal()]) { - continue; - } - - yield $key => $this->unmaskNull($this->values[$key->ordinal()]); - } - } - - private function maskNull($value) - { - if (null === $value) { - return NullValue::instance(); - } - - return $value; - } - - private function unmaskNull($value) - { - if ($value instanceof NullValue) { - return null; - } - - return $value; - } - - /** - * @throws IllegalArgumentException when the passed key does not match the internal key type - */ - private function checkKeyType(AbstractEnum $key) : void - { - if (get_class($key) !== $this->keyType) { - throw new IllegalArgumentException(sprintf( - 'Object of type %s is not the same type as %s', - get_class($key), - $this->keyType - )); - } - } - - private function isValidValue($value) : bool - { - if (null === $value) { - if ($this->allowNullValues) { - return true; - } - - return false; - } - - switch ($this->valueType) { - case 'mixed': - return true; - - case 'bool': - case 'boolean': - return is_bool($value); - - case 'int': - case 'integer': - return is_int($value); - - case 'float': - case 'double': - return is_float($value); - - case 'string': - return is_string($value); - - case 'object': - return is_object($value); - - case 'array': - return is_array($value); - } - - return $value instanceof $this->valueType; - } -} diff --git a/vendor/dasprid/enum/src/Exception/CloneNotSupportedException.php b/vendor/dasprid/enum/src/Exception/CloneNotSupportedException.php deleted file mode 100644 index 4b37dbe..0000000 --- a/vendor/dasprid/enum/src/Exception/CloneNotSupportedException.php +++ /dev/null @@ -1,10 +0,0 @@ -getProperty('constants'); - $constantsProperty->setAccessible(true); - $constantsProperty->setValue([]); - - $valuesProperty = $reflectionClass->getProperty('values'); - $valuesProperty->setAccessible(true); - $valuesProperty->setValue([]); - - $allValuesLoadedProperty = $reflectionClass->getProperty('allValuesLoaded'); - $allValuesLoadedProperty->setAccessible(true); - $allValuesLoadedProperty->setValue([]); - } - - public function testToString() : void - { - $weekday = WeekDay::FRIDAY(); - self::assertSame('FRIDAY', (string) $weekday); - } - - public function testName() : void - { - $this->assertSame('WEDNESDAY', WeekDay::WEDNESDAY()->name()); - } - - public function testOrdinal() : void - { - $this->assertSame(2, WeekDay::WEDNESDAY()->ordinal()); - } - - public function testSameInstanceIsReturned() : void - { - self::assertSame(WeekDay::FRIDAY(), WeekDay::FRIDAY()); - } - - public static function testValueOf() : void - { - self::assertSame(WeekDay::FRIDAY(), WeekDay::valueOf('FRIDAY')); - } - - public function testValueOfInvalidConstant() : void - { - $this->expectException(IllegalArgumentException::class); - WeekDay::valueOf('CATURDAY'); - } - - public function testExceptionOnCloneAttempt() : void - { - $this->expectException(CloneNotSupportedException::class); - clone WeekDay::FRIDAY(); - } - - public function testExceptionOnSerializeAttempt() : void - { - $this->expectException(SerializeNotSupportedException::class); - serialize(WeekDay::FRIDAY()); - } - - public function testExceptionOnUnserializeAttempt() : void - { - $this->expectException(UnserializeNotSupportedException::class); - unserialize('O:24:"DASPRiD\\EnumTest\\WeekDay":0:{}'); - } - - public function testReturnValueOfValuesIsSortedByOrdinal() : void - { - // Initialize some week days out of order - WeekDay::SATURDAY(); - WeekDay::TUESDAY(); - - $ordinals = array_values(array_map(function (WeekDay $weekDay) : int { - return $weekDay->ordinal(); - }, WeekDay::values())); - - self::assertSame([0, 1, 2, 3, 4, 5, 6], $ordinals); - - $cachedOrdinals = array_values(array_map(function (WeekDay $weekDay) : int { - return $weekDay->ordinal(); - }, WeekDay::values())); - $this->assertSame($ordinals, $cachedOrdinals); - } - - public function testCompareTo() : void - { - $this->assertSame(-4, WeekDay::WEDNESDAY()->compareTo(WeekDay::SUNDAY())); - $this->assertSame(4, WeekDay::SUNDAY()->compareTo(WeekDay::WEDNESDAY())); - $this->assertSame(0, WeekDay::WEDNESDAY()->compareTo(WeekDay::WEDNESDAY())); - } - - public function testCompareToWrongEnum() : void - { - $this->expectException(MismatchException::class); - WeekDay::MONDAY()->compareTo(Planet::EARTH()); - } - - public function testParameterizedEnum() : void - { - $planet = Planet::EARTH(); - $this->assertSame(5.976e+24, $planet->mass()); - $this->assertSame(6.37814e6, $planet->radius()); - } -} diff --git a/vendor/dasprid/enum/test/EnumMapTest.php b/vendor/dasprid/enum/test/EnumMapTest.php deleted file mode 100644 index d51a86c..0000000 --- a/vendor/dasprid/enum/test/EnumMapTest.php +++ /dev/null @@ -1,243 +0,0 @@ -expectException(IllegalArgumentException::class); - new EnumMap(stdClass::class, 'string', false); - } - - public function testUnexpectedKeyType() : void - { - $this->expectException(ExpectationException::class); - $map = new EnumMap(WeekDay::class, 'string', false); - $map->expect(Planet::class, 'string', false); - } - - public function testUnexpectedValueType() : void - { - $this->expectException(ExpectationException::class); - $map = new EnumMap(WeekDay::class, 'string', false); - $map->expect(WeekDay::class, 'int', false); - } - - public function testUnexpectedNullableValueType() : void - { - $this->expectException(ExpectationException::class); - $map = new EnumMap(WeekDay::class, 'string', true); - $map->expect(WeekDay::class, 'string', false); - } - - public function testExpectedTypes() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $map->expect(WeekDay::class, 'string', true); - $this->addToAssertionCount(1); - } - - public function testSize() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $this->assertSame(0, $map->size()); - $map->put(WeekDay::MONDAY(), 'foo'); - $this->assertSame(1, $map->size()); - } - - public function testContainsValue() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $this->assertFalse($map->containsValue('foo')); - $map->put(WeekDay::TUESDAY(), 'foo'); - $this->assertTrue($map->containsValue('foo')); - $this->assertFalse($map->containsValue(null)); - $map->put(WeekDay::WEDNESDAY(), null); - $this->assertTrue($map->containsValue(null)); - } - - public function testContainsKey() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $this->assertFalse($map->containsKey(WeekDay::TUESDAY())); - $map->put(WeekDay::TUESDAY(), 'foo'); - $this->assertTrue($map->containsKey(WeekDay::TUESDAY())); - $map->put(WeekDay::WEDNESDAY(), null); - $this->assertTrue($map->containsKey(WeekDay::WEDNESDAY())); - } - - public function testPutAndGet() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $map->put(WeekDay::TUESDAY(), 'foo'); - $map->put(WeekDay::FRIDAY(), null); - $this->assertSame('foo', $map->get(WeekDay::TUESDAY())); - $this->assertSame(null, $map->get(WeekDay::WEDNESDAY())); - $this->assertSame(null, $map->get(WeekDay::FRIDAY())); - } - - public function testPutInvalidKey() : void - { - $this->expectException(IllegalArgumentException::class); - $map = new EnumMap(WeekDay::class, 'string', true); - $map->put(Planet::MARS(), 'foo'); - } - - public function invalidValues() : array - { - return [ - ['bool', null, false], - ['bool', 0], - ['boolean', 0], - ['int', 2.4], - ['integer', 5.3], - ['float', 3], - ['double', 7], - ['string', 1], - ['object', 1], - ['array', 1], - [stdClass::class, 1], - ]; - } - - /** - * @dataProvider invalidValues - * @param mixed $value - */ - public function testPutInvalidValue(string $valueType, $value, bool $allowNull = true) : void - { - $this->expectException(IllegalArgumentException::class); - $map = new EnumMap(WeekDay::class, $valueType, $allowNull); - $map->put(WeekDay::TUESDAY(), $value); - } - - public function validValues() : array - { - return [ - ['bool', null], - ['mixed', 'foo'], - ['mixed', 1], - ['mixed', new stdClass()], - ['bool', true], - ['boolean', false], - ['int', 1], - ['integer', 4], - ['float', 2.5], - ['double', 6.4], - ['string', 'foo'], - ['object', new stdClass()], - ['array', ['foo']], - [stdClass::class, new stdClass()], - ]; - } - - /** - * @dataProvider validValues - * @param mixed $value - */ - public function testPutValidValue(string $valueType, $value, bool $allowNull = true) : void - { - $map = new EnumMap(WeekDay::class, $valueType, $allowNull); - $map->put(WeekDay::TUESDAY(), $value); - $this->addToAssertionCount(1); - } - - public function testRemove() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $map->put(WeekDay::TUESDAY(), 'foo'); - $map->remove(WeekDay::TUESDAY()); - $map->remove(WeekDay::WEDNESDAY()); - $this->assertSame(null, $map->get(WeekDay::TUESDAY())); - $this->assertSame(0, $map->size()); - } - - public function testClear() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $map->put(WeekDay::TUESDAY(), 'foo'); - $map->clear(); - $this->assertSame(null, $map->get(WeekDay::TUESDAY())); - $this->assertSame(0, $map->size()); - } - - public function testEqualsWithSameInstance() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $this->assertTrue($map->equals($map)); - } - - public function testEqualsWithDifferentSize() : void - { - $mapA = new EnumMap(WeekDay::class, 'string', true); - $mapB = new EnumMap(WeekDay::class, 'string', true); - $mapB->put(WeekDay::MONDAY(), 'foo'); - - $this->assertFalse($mapA->equals($mapB)); - } - - public function testEqualsWithDifferentValues() : void - { - $mapA = new EnumMap(WeekDay::class, 'string', true); - $mapA->put(WeekDay::MONDAY(), 'foo'); - $mapB = new EnumMap(WeekDay::class, 'string', true); - $mapB->put(WeekDay::MONDAY(), 'bar'); - - $this->assertFalse($mapA->equals($mapB)); - } - - public function testEqualsWithDifferentConstants() : void - { - $mapA = new EnumMap(WeekDay::class, 'string', true); - $mapA->put(WeekDay::MONDAY(), 'foo'); - $mapB = new EnumMap(WeekDay::class, 'string', true); - $mapB->put(WeekDay::TUESDAY(), 'foo'); - - $this->assertFalse($mapA->equals($mapB)); - } - - public function testValues() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $this->assertSame([], $map->values()); - - $map->put(WeekDay::FRIDAY(), 'foo'); - $map->put(WeekDay::TUESDAY(), 'bar'); - $map->put(WeekDay::SUNDAY(), null); - - $this->assertSame(['bar', 'foo', null], $map->values()); - } - - public function testSerializeAndUnserialize() : void - { - $mapA = new EnumMap(WeekDay::class, 'string', true); - $mapA->put(WeekDay::MONDAY(), 'foo'); - $mapB = unserialize(serialize($mapA)); - - $this->assertTrue($mapA->equals($mapB)); - } - - public function testIterator() : void - { - $map = new EnumMap(WeekDay::class, 'string', true); - $map->put(WeekDay::FRIDAY(), 'foo'); - $map->put(WeekDay::TUESDAY(), 'bar'); - $map->put(WeekDay::SUNDAY(), null); - - $result = []; - - foreach ($map as $key => $value) { - $result[$key->ordinal()] = $value; - } - - $this->assertSame([1 => 'bar', 4 => 'foo', 6 => null], $result); - } -} diff --git a/vendor/dasprid/enum/test/NullValueTest.php b/vendor/dasprid/enum/test/NullValueTest.php deleted file mode 100644 index 9f70640..0000000 --- a/vendor/dasprid/enum/test/NullValueTest.php +++ /dev/null @@ -1,31 +0,0 @@ -expectException(CloneNotSupportedException::class); - clone NullValue::instance(); - } - - public function testExceptionOnSerializeAttempt() : void - { - $this->expectException(SerializeNotSupportedException::class); - serialize(NullValue::instance()); - } - - public function testExceptionOnUnserializeAttempt() : void - { - $this->expectException(UnserializeNotSupportedException::class); - unserialize('O:22:"DASPRiD\\Enum\\NullValue":0:{}'); - } -} diff --git a/vendor/dasprid/enum/test/Planet.php b/vendor/dasprid/enum/test/Planet.php deleted file mode 100644 index 3c44c1d..0000000 --- a/vendor/dasprid/enum/test/Planet.php +++ /dev/null @@ -1,73 +0,0 @@ -mass = $mass; - $this->radius = $radius; - } - - public function mass() : float - { - return $this->mass; - } - - public function radius() : float - { - return $this->radius; - } - - public function surfaceGravity() : float - { - return self::G * $this->mass / ($this->radius * $this->radius); - } - - public function surfaceWeight(float $otherMass) : float - { - return $otherMass * $this->surfaceGravity(); - } -} diff --git a/vendor/dasprid/enum/test/WeekDay.php b/vendor/dasprid/enum/test/WeekDay.php deleted file mode 100644 index 70b8db5..0000000 --- a/vendor/dasprid/enum/test/WeekDay.php +++ /dev/null @@ -1,26 +0,0 @@ -writer(new PngWriter()) - ->writerOptions([]) - ->data('Custom QR code contents') - ->encoding(new Encoding('UTF-8')) - ->errorCorrectionLevel(new ErrorCorrectionLevelHigh()) - ->size(300) - ->margin(10) - ->roundBlockSizeMode(new RoundBlockSizeModeMargin()) - ->logoPath(__DIR__.'/assets/symfony.png') - ->labelText('This is the label') - ->labelFont(new NotoSans(20)) - ->labelAlignment(new LabelAlignmentCenter()) - ->validateResult(false) - ->build(); -``` - -## Usage: without using the builder - -```php -use Endroid\QrCode\Color\Color; -use Endroid\QrCode\Encoding\Encoding; -use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow; -use Endroid\QrCode\QrCode; -use Endroid\QrCode\Label\Label; -use Endroid\QrCode\Logo\Logo; -use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin; -use Endroid\QrCode\Writer\PngWriter; -use Endroid\QrCode\Writer\ValidationException; - -$writer = new PngWriter(); - -// Create QR code -$qrCode = QrCode::create('Life is too short to be generating QR codes') - ->setEncoding(new Encoding('UTF-8')) - ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow()) - ->setSize(300) - ->setMargin(10) - ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin()) - ->setForegroundColor(new Color(0, 0, 0)) - ->setBackgroundColor(new Color(255, 255, 255)); - -// Create generic logo -$logo = Logo::create(__DIR__.'/assets/symfony.png') - ->setResizeToWidth(50); - -// Create generic label -$label = Label::create('Label') - ->setTextColor(new Color(255, 0, 0)); - -$result = $writer->write($qrCode, $logo, $label); - -// Validate the result -$writer->validateResult($result, 'Life is too short to be generating QR codes'); -``` - -## Usage: working with results - -```php - -// Directly output the QR code -header('Content-Type: '.$result->getMimeType()); -echo $result->getString(); - -// Save it to a file -$result->saveToFile(__DIR__.'/qrcode.png'); - -// Generate a data URI to include image data inline (i.e. inside an tag) -$dataUri = $result->getDataUri(); -``` - -![QR Code](https://endroid.nl/qr-code/default/Life%20is%20too%20short%20to%20be%20generating%20QR%20codes) - -### Writer options - -```php -use Endroid\QrCode\Writer\SvgWriter; - -$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]); -``` - -### Encoding - -If you use a barcode scanner you can have some troubles while reading the -generated QR codes. Depending on the encoding you chose you will have an extra -amount of data corresponding to the ECI block. Some barcode scanner are not -programmed to interpret this block of information. To ensure a maximum -compatibility you can use the `ISO-8859-1` encoding that is the default -encoding used by barcode scanners (if your character set supports it, -i.e. no Chinese characters are present). - -### Round block size mode - -By default block sizes are rounded to guarantee sharp images and improve -readability. However some other rounding variants are available. - -* `margin (default)`: the size of the QR code is shrunk if necessary but the size - of the final image remains unchanged due to additional margin being added. -* `enlarge`: the size of the QR code and the final image are enlarged when - rounding differences occur. -* `shrink`: the size of the QR code and the final image are - shrunk when rounding differences occur. -* `none`: No rounding. This mode can be used when blocks don't need to be rounded - to pixels (for instance SVG). - -## Readability - -The readability of a QR code is primarily determined by the size, the input -length, the error correction level and any possible logo over the image so you -can tweak these parameters if you are looking for optimal results. You can also -check $qrCode->getRoundBlockSize() value to see if block dimensions are rounded -so that the image is more sharp and readable. Please note that rounding block -size can result in additional padding to compensate for the rounding difference. -And finally the encoding (default UTF-8 to support large character sets) can be -set to `ISO-8859-1` if possible to improve readability. - -## Validating the generated QR code - -If you need to be extra sure the QR code you generated is readable and contains -the exact data you requested you can enable the validation reader, which is -disabled by default. You can do this either via the builder or directly on any -writer that supports validation. See the examples above. - -Please note that validation affects performance so only use it in case of problems. - -## Symfony integration - -The [endroid/qr-code-bundle](https://github.com/endroid/qr-code-bundle) -integrates the QR code library in Symfony for an even better experience. - -* Configure your defaults (like image size, default writer etc.) -* Support for multiple configurations and injection via aliases -* Generate QR codes for defined configurations via URL like /qr-code//Hello -* Generate QR codes or URLs directly from Twig using dedicated functions - -Read the [bundle documentation](https://github.com/endroid/qr-code-bundle) -for more information. - -## Versioning - -Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility -breaking changes will be kept to a minimum but be aware that these can occur. -Lock your dependencies for production and test your code when upgrading. - -## License - -This bundle is under the MIT license. For the full copyright and license -information please view the LICENSE file that was distributed with this source code. diff --git a/vendor/endroid/qr-code/assets/blackfire.png b/vendor/endroid/qr-code/assets/blackfire.png deleted file mode 100644 index bc378fd..0000000 Binary files a/vendor/endroid/qr-code/assets/blackfire.png and /dev/null differ diff --git a/vendor/endroid/qr-code/assets/noto_sans.otf b/vendor/endroid/qr-code/assets/noto_sans.otf deleted file mode 100644 index 296fbeb..0000000 Binary files a/vendor/endroid/qr-code/assets/noto_sans.otf and /dev/null differ diff --git a/vendor/endroid/qr-code/assets/open_sans.ttf b/vendor/endroid/qr-code/assets/open_sans.ttf deleted file mode 100644 index db43334..0000000 Binary files a/vendor/endroid/qr-code/assets/open_sans.ttf and /dev/null differ diff --git a/vendor/endroid/qr-code/composer.json b/vendor/endroid/qr-code/composer.json deleted file mode 100644 index 9fd62c0..0000000 --- a/vendor/endroid/qr-code/composer.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "endroid/qr-code", - "description": "Endroid QR Code", - "keywords": ["endroid", "qrcode", "qr", "code", "php"], - "homepage": "https://github.com/endroid/qr-code", - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "Jeroen van den Enden", - "email": "info@endroid.nl" - } - ], - "require": { - "php": "^7.4||^8.0", - "bacon/bacon-qr-code": "^2.0.5" - }, - "require-dev": { - "ext-gd": "*", - "endroid/quality": "dev-master", - "khanamiryan/qrcode-detector-decoder": "^1.0.4", - "setasign/fpdf": "^1.8.2" - }, - "suggest": { - "ext-gd": "Enables you to write PNG images", - "khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator", - "roave/security-advisories": "Makes sure package versions with known security issues are not installed", - "setasign/fpdf": "Enables you to use the PDF writer" - }, - "autoload": { - "psr-4": { - "Endroid\\QrCode\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Endroid\\QrCode\\Tests\\": "tests/" - } - }, - "config": { - "sort-packages": true, - "preferred-install": { - "endroid/*": "source" - } - }, - "extra": { - "branch-alias": { - "dev-master": "4.x-dev" - } - } -} diff --git a/vendor/endroid/qr-code/src/Bacon/ErrorCorrectionLevelConverter.php b/vendor/endroid/qr-code/src/Bacon/ErrorCorrectionLevelConverter.php deleted file mode 100644 index 90f23e0..0000000 --- a/vendor/endroid/qr-code/src/Bacon/ErrorCorrectionLevelConverter.php +++ /dev/null @@ -1,30 +0,0 @@ -getErrorCorrectionLevel()); - $baconMatrix = Encoder::encode($qrCode->getData(), $baconErrorCorrectionLevel, strval($qrCode->getEncoding()))->getMatrix(); - - $blockValues = []; - $columnCount = $baconMatrix->getWidth(); - $rowCount = $baconMatrix->getHeight(); - for ($rowIndex = 0; $rowIndex < $rowCount; ++$rowIndex) { - $blockValues[$rowIndex] = []; - for ($columnIndex = 0; $columnIndex < $columnCount; ++$columnIndex) { - $blockValues[$rowIndex][$columnIndex] = $baconMatrix->get($columnIndex, $rowIndex); - } - } - - return new Matrix($blockValues, $qrCode->getSize(), $qrCode->getMargin(), $qrCode->getRoundBlockSizeMode()); - } -} diff --git a/vendor/endroid/qr-code/src/Builder/Builder.php b/vendor/endroid/qr-code/src/Builder/Builder.php deleted file mode 100644 index 63fd28b..0000000 --- a/vendor/endroid/qr-code/src/Builder/Builder.php +++ /dev/null @@ -1,279 +0,0 @@ -{ - * data: string, - * writer: WriterInterface, - * writerOptions: array, - * qrCodeClass: class-string, - * logoClass: class-string, - * labelClass: class-string, - * validateResult: bool, - * size?: int, - * encoding?: EncodingInterface, - * errorCorrectionLevel?: ErrorCorrectionLevelInterface, - * roundBlockSizeMode?: RoundBlockSizeModeInterface, - * margin?: int, - * backgroundColor?: ColorInterface, - * foregroundColor?: ColorInterface, - * labelText?: string, - * labelFont?: FontInterface, - * labelAlignment?: LabelAlignmentInterface, - * labelMargin?: MarginInterface, - * labelTextColor?: ColorInterface, - * logoPath?: string, - * logoResizeToWidth?: int, - * logoResizeToHeight?: int, - * logoPunchoutBackground?: bool - * } - */ - private array $options; - - public function __construct() - { - $this->options = [ - 'data' => '', - 'writer' => new PngWriter(), - 'writerOptions' => [], - 'qrCodeClass' => QrCode::class, - 'logoClass' => Logo::class, - 'labelClass' => Label::class, - 'validateResult' => false, - ]; - } - - public static function create(): BuilderInterface - { - return new self(); - } - - public function writer(WriterInterface $writer): BuilderInterface - { - $this->options['writer'] = $writer; - - return $this; - } - - /** @param array $writerOptions */ - public function writerOptions(array $writerOptions): BuilderInterface - { - $this->options['writerOptions'] = $writerOptions; - - return $this; - } - - public function data(string $data): BuilderInterface - { - $this->options['data'] = $data; - - return $this; - } - - public function encoding(EncodingInterface $encoding): BuilderInterface - { - $this->options['encoding'] = $encoding; - - return $this; - } - - public function errorCorrectionLevel(ErrorCorrectionLevelInterface $errorCorrectionLevel): BuilderInterface - { - $this->options['errorCorrectionLevel'] = $errorCorrectionLevel; - - return $this; - } - - public function size(int $size): BuilderInterface - { - $this->options['size'] = $size; - - return $this; - } - - public function margin(int $margin): BuilderInterface - { - $this->options['margin'] = $margin; - - return $this; - } - - public function roundBlockSizeMode(RoundBlockSizeModeInterface $roundBlockSizeMode): BuilderInterface - { - $this->options['roundBlockSizeMode'] = $roundBlockSizeMode; - - return $this; - } - - public function foregroundColor(ColorInterface $foregroundColor): BuilderInterface - { - $this->options['foregroundColor'] = $foregroundColor; - - return $this; - } - - public function backgroundColor(ColorInterface $backgroundColor): BuilderInterface - { - $this->options['backgroundColor'] = $backgroundColor; - - return $this; - } - - public function logoPath(string $logoPath): BuilderInterface - { - $this->options['logoPath'] = $logoPath; - - return $this; - } - - public function logoResizeToWidth(int $logoResizeToWidth): BuilderInterface - { - $this->options['logoResizeToWidth'] = $logoResizeToWidth; - - return $this; - } - - public function logoResizeToHeight(int $logoResizeToHeight): BuilderInterface - { - $this->options['logoResizeToHeight'] = $logoResizeToHeight; - - return $this; - } - - public function logoPunchoutBackground(bool $logoPunchoutBackground): BuilderInterface - { - $this->options['logoPunchoutBackground'] = $logoPunchoutBackground; - - return $this; - } - - public function labelText(string $labelText): BuilderInterface - { - $this->options['labelText'] = $labelText; - - return $this; - } - - public function labelFont(FontInterface $labelFont): BuilderInterface - { - $this->options['labelFont'] = $labelFont; - - return $this; - } - - public function labelAlignment(LabelAlignmentInterface $labelAlignment): BuilderInterface - { - $this->options['labelAlignment'] = $labelAlignment; - - return $this; - } - - public function labelMargin(MarginInterface $labelMargin): BuilderInterface - { - $this->options['labelMargin'] = $labelMargin; - - return $this; - } - - public function labelTextColor(ColorInterface $labelTextColor): BuilderInterface - { - $this->options['labelTextColor'] = $labelTextColor; - - return $this; - } - - public function validateResult(bool $validateResult): BuilderInterface - { - $this->options['validateResult'] = $validateResult; - - return $this; - } - - public function build(): ResultInterface - { - $writer = $this->options['writer']; - - if ($this->options['validateResult'] && !$writer instanceof ValidatingWriterInterface) { - throw ValidationException::createForUnsupportedWriter(strval(get_class($writer))); - } - - /** @var QrCode $qrCode */ - $qrCode = $this->buildObject($this->options['qrCodeClass']); - - /** @var LogoInterface|null $logo */ - $logo = $this->buildObject($this->options['logoClass'], 'logo'); - - /** @var LabelInterface|null $label */ - $label = $this->buildObject($this->options['labelClass'], 'label'); - - $result = $writer->write($qrCode, $logo, $label, $this->options['writerOptions']); - - if ($this->options['validateResult'] && $writer instanceof ValidatingWriterInterface) { - $writer->validateResult($result, $qrCode->getData()); - } - - return $result; - } - - /** - * @param class-string $class - * - * @return mixed - */ - private function buildObject(string $class, string $optionsPrefix = null) - { - /** @var \ReflectionClass $reflectionClass */ - $reflectionClass = new \ReflectionClass($class); - - $arguments = []; - $hasBuilderOptions = false; - $missingRequiredArguments = []; - /** @var \ReflectionMethod $constructor */ - $constructor = $reflectionClass->getConstructor(); - $constructorParameters = $constructor->getParameters(); - foreach ($constructorParameters as $parameter) { - $optionName = null === $optionsPrefix ? $parameter->getName() : $optionsPrefix.ucfirst($parameter->getName()); - if (isset($this->options[$optionName])) { - $hasBuilderOptions = true; - $arguments[] = $this->options[$optionName]; - } elseif ($parameter->isDefaultValueAvailable()) { - $arguments[] = $parameter->getDefaultValue(); - } else { - $missingRequiredArguments[] = $optionName; - } - } - - if (!$hasBuilderOptions) { - return null; - } - - if (count($missingRequiredArguments) > 0) { - throw new \Exception(sprintf('Missing required arguments: %s', implode(', ', $missingRequiredArguments))); - } - - return $reflectionClass->newInstanceArgs($arguments); - } -} diff --git a/vendor/endroid/qr-code/src/Builder/BuilderInterface.php b/vendor/endroid/qr-code/src/Builder/BuilderInterface.php deleted file mode 100644 index 5e69bc2..0000000 --- a/vendor/endroid/qr-code/src/Builder/BuilderInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - $writerOptions */ - public function writerOptions(array $writerOptions): BuilderInterface; - - public function data(string $data): BuilderInterface; - - public function encoding(EncodingInterface $encoding): BuilderInterface; - - public function errorCorrectionLevel(ErrorCorrectionLevelInterface $errorCorrectionLevel): BuilderInterface; - - public function size(int $size): BuilderInterface; - - public function margin(int $margin): BuilderInterface; - - public function roundBlockSizeMode(RoundBlockSizeModeInterface $roundBlockSizeMode): BuilderInterface; - - public function foregroundColor(ColorInterface $foregroundColor): BuilderInterface; - - public function backgroundColor(ColorInterface $backgroundColor): BuilderInterface; - - public function logoPath(string $logoPath): BuilderInterface; - - public function logoResizeToWidth(int $logoResizeToWidth): BuilderInterface; - - public function logoResizeToHeight(int $logoResizeToHeight): BuilderInterface; - - public function logoPunchoutBackground(bool $logoPunchoutBackground): BuilderInterface; - - public function labelText(string $labelText): BuilderInterface; - - public function labelFont(FontInterface $labelFont): BuilderInterface; - - public function labelAlignment(LabelAlignmentInterface $labelAlignment): BuilderInterface; - - public function labelMargin(MarginInterface $labelMargin): BuilderInterface; - - public function labelTextColor(ColorInterface $labelTextColor): BuilderInterface; - - public function validateResult(bool $validateResult): BuilderInterface; - - public function build(): ResultInterface; -} diff --git a/vendor/endroid/qr-code/src/Builder/BuilderRegistry.php b/vendor/endroid/qr-code/src/Builder/BuilderRegistry.php deleted file mode 100644 index cf1449c..0000000 --- a/vendor/endroid/qr-code/src/Builder/BuilderRegistry.php +++ /dev/null @@ -1,25 +0,0 @@ - */ - private array $builders = []; - - public function getBuilder(string $name): BuilderInterface - { - if (!isset($this->builders[$name])) { - throw new \Exception(sprintf('Builder with name "%s" not available from registry', $name)); - } - - return $this->builders[$name]; - } - - public function addBuilder(string $name, BuilderInterface $builder): void - { - $this->builders[$name] = $builder; - } -} diff --git a/vendor/endroid/qr-code/src/Builder/BuilderRegistryInterface.php b/vendor/endroid/qr-code/src/Builder/BuilderRegistryInterface.php deleted file mode 100644 index 048d649..0000000 --- a/vendor/endroid/qr-code/src/Builder/BuilderRegistryInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -red = $red; - $this->green = $green; - $this->blue = $blue; - $this->alpha = $alpha; - } - - public function getRed(): int - { - return $this->red; - } - - public function getGreen(): int - { - return $this->green; - } - - public function getBlue(): int - { - return $this->blue; - } - - public function getAlpha(): int - { - return $this->alpha; - } - - public function getOpacity(): float - { - return 1 - $this->alpha / 127; - } - - public function getHex(): string - { - return sprintf('#%02x%02x%02x', $this->red, $this->green, $this->blue); - } - - public function toArray(): array - { - return [ - 'red' => $this->red, - 'green' => $this->green, - 'blue' => $this->blue, - 'alpha' => $this->alpha, - ]; - } -} diff --git a/vendor/endroid/qr-code/src/Color/ColorInterface.php b/vendor/endroid/qr-code/src/Color/ColorInterface.php deleted file mode 100644 index 398be26..0000000 --- a/vendor/endroid/qr-code/src/Color/ColorInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - */ - public function toArray(): array; -} diff --git a/vendor/endroid/qr-code/src/Encoding/Encoding.php b/vendor/endroid/qr-code/src/Encoding/Encoding.php deleted file mode 100644 index 2126d1e..0000000 --- a/vendor/endroid/qr-code/src/Encoding/Encoding.php +++ /dev/null @@ -1,24 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } -} diff --git a/vendor/endroid/qr-code/src/Encoding/EncodingInterface.php b/vendor/endroid/qr-code/src/Encoding/EncodingInterface.php deleted file mode 100644 index f57001b..0000000 --- a/vendor/endroid/qr-code/src/Encoding/EncodingInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -width = $width; - $this->height = $height; - } - - public static function createForLabel(LabelInterface $label): self - { - if (false !== strpos($label->getText(), "\n")) { - throw new \Exception('Label does not support line breaks'); - } - - if (!function_exists('imagettfbbox')) { - throw new \Exception('Function "imagettfbbox" does not exist: check your FreeType installation'); - } - - $labelBox = imagettfbbox($label->getFont()->getSize(), 0, $label->getFont()->getPath(), $label->getText()); - - if (!is_array($labelBox)) { - throw new \Exception('Unable to generate label image box: check your FreeType installation'); - } - - return new self( - intval($labelBox[2] - $labelBox[0]), - intval($labelBox[0] - $labelBox[7]) - ); - } - - public function getWidth(): int - { - return $this->width; - } - - public function getHeight(): int - { - return $this->height; - } -} diff --git a/vendor/endroid/qr-code/src/ImageData/LogoImageData.php b/vendor/endroid/qr-code/src/ImageData/LogoImageData.php deleted file mode 100644 index 75b4078..0000000 --- a/vendor/endroid/qr-code/src/ImageData/LogoImageData.php +++ /dev/null @@ -1,164 +0,0 @@ -data = $data; - $this->image = $image; - $this->mimeType = $mimeType; - $this->width = $width; - $this->height = $height; - $this->punchoutBackground = $punchoutBackground; - } - - public static function createForLogo(LogoInterface $logo): self - { - $data = @file_get_contents($logo->getPath()); - - if (!is_string($data)) { - throw new \Exception(sprintf('Invalid data at path "%s"', $logo->getPath())); - } - - if (false !== filter_var($logo->getPath(), FILTER_VALIDATE_URL)) { - $mimeType = self::detectMimeTypeFromUrl($logo->getPath()); - } else { - $mimeType = self::detectMimeTypeFromPath($logo->getPath()); - } - - $width = $logo->getResizeToWidth(); - $height = $logo->getResizeToHeight(); - - if ('image/svg+xml' === $mimeType) { - if (null === $width || null === $height) { - throw new \Exception('SVG Logos require an explicitly set resize width and height'); - } - - return new self($data, null, $mimeType, $width, $height, $logo->getPunchoutBackground()); - } - - $image = @imagecreatefromstring($data); - - if (!$image) { - throw new \Exception(sprintf('Unable to parse image data at path "%s"', $logo->getPath())); - } - - // No target width and height specified: use from original image - if (null !== $width && null !== $height) { - return new self($data, $image, $mimeType, $width, $height, $logo->getPunchoutBackground()); - } - - // Only target width specified: calculate height - if (null !== $width && null === $height) { - return new self($data, $image, $mimeType, $width, intval(imagesy($image) * $width / imagesx($image)), $logo->getPunchoutBackground()); - } - - // Only target height specified: calculate width - if (null === $width && null !== $height) { - return new self($data, $image, $mimeType, intval(imagesx($image) * $height / imagesy($image)), $height, $logo->getPunchoutBackground()); - } - - return new self($data, $image, $mimeType, imagesx($image), imagesy($image), $logo->getPunchoutBackground()); - } - - public function getData(): string - { - return $this->data; - } - - /** @return mixed */ - public function getImage() - { - if (null === $this->image) { - throw new \Exception('SVG Images have no image resource'); - } - - return $this->image; - } - - public function getMimeType(): string - { - return $this->mimeType; - } - - public function getWidth(): int - { - return $this->width; - } - - public function getHeight(): int - { - return $this->height; - } - - public function getPunchoutBackground(): bool - { - return $this->punchoutBackground; - } - - public function createDataUri(): string - { - return 'data:'.$this->mimeType.';base64,'.base64_encode($this->data); - } - - private static function detectMimeTypeFromUrl(string $url): string - { - /** @var mixed $format */ - $format = PHP_VERSION_ID >= 80000 ? true : 1; - - $headers = get_headers($url, $format); - - if (!is_array($headers) || !isset($headers['Content-Type'])) { - throw new \Exception(sprintf('Content type could not be determined for logo URL "%s"', $url)); - } - - return is_array($headers['Content-Type']) ? $headers['Content-Type'][1] : $headers['Content-Type']; - } - - private static function detectMimeTypeFromPath(string $path): string - { - if (!function_exists('mime_content_type')) { - throw new \Exception('You need the ext-fileinfo extension to determine logo mime type'); - } - - $mimeType = @mime_content_type($path); - - if (!is_string($mimeType)) { - throw new \Exception('Could not determine mime type'); - } - - if (!preg_match('#^image/#', $mimeType)) { - throw new \Exception('Logo path is not an image'); - } - - // Passing mime type image/svg results in invisible images - if ('image/svg' === $mimeType) { - return 'image/svg+xml'; - } - - return $mimeType; - } -} diff --git a/vendor/endroid/qr-code/src/Label/Alignment/LabelAlignmentCenter.php b/vendor/endroid/qr-code/src/Label/Alignment/LabelAlignmentCenter.php deleted file mode 100644 index c13e287..0000000 --- a/vendor/endroid/qr-code/src/Label/Alignment/LabelAlignmentCenter.php +++ /dev/null @@ -1,9 +0,0 @@ -validatePath($path); - - $this->path = $path; - $this->size = $size; - } - - private function validatePath(string $path): void - { - if (!file_exists($path)) { - throw new \Exception(sprintf('Invalid font path "%s"', $path)); - } - } - - public function getPath(): string - { - return $this->path; - } - - public function getSize(): int - { - return $this->size; - } -} diff --git a/vendor/endroid/qr-code/src/Label/Font/FontInterface.php b/vendor/endroid/qr-code/src/Label/Font/FontInterface.php deleted file mode 100644 index 1c0de9a..0000000 --- a/vendor/endroid/qr-code/src/Label/Font/FontInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -size = $size; - } - - public function getPath(): string - { - return __DIR__.'/../../../assets/noto_sans.otf'; - } - - public function getSize(): int - { - return $this->size; - } -} diff --git a/vendor/endroid/qr-code/src/Label/Font/OpenSans.php b/vendor/endroid/qr-code/src/Label/Font/OpenSans.php deleted file mode 100644 index 4daab73..0000000 --- a/vendor/endroid/qr-code/src/Label/Font/OpenSans.php +++ /dev/null @@ -1,25 +0,0 @@ -size = $size; - } - - public function getPath(): string - { - return __DIR__.'/../../../assets/open_sans.ttf'; - } - - public function getSize(): int - { - return $this->size; - } -} diff --git a/vendor/endroid/qr-code/src/Label/Label.php b/vendor/endroid/qr-code/src/Label/Label.php deleted file mode 100644 index 4c51c75..0000000 --- a/vendor/endroid/qr-code/src/Label/Label.php +++ /dev/null @@ -1,102 +0,0 @@ -text = $text; - $this->font = $font ?? new Font(__DIR__.'/../../assets/noto_sans.otf', 16); - $this->alignment = $alignment ?? new LabelAlignmentCenter(); - $this->margin = $margin ?? new Margin(0, 10, 10, 10); - $this->textColor = $textColor ?? new Color(0, 0, 0); - } - - public static function create(string $text): self - { - return new self($text); - } - - public function getText(): string - { - return $this->text; - } - - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - - public function getFont(): FontInterface - { - return $this->font; - } - - public function setFont(FontInterface $font): self - { - $this->font = $font; - - return $this; - } - - public function getAlignment(): LabelAlignmentInterface - { - return $this->alignment; - } - - public function setAlignment(LabelAlignmentInterface $alignment): self - { - $this->alignment = $alignment; - - return $this; - } - - public function getMargin(): MarginInterface - { - return $this->margin; - } - - public function setMargin(MarginInterface $margin): self - { - $this->margin = $margin; - - return $this; - } - - public function getTextColor(): ColorInterface - { - return $this->textColor; - } - - public function setTextColor(ColorInterface $textColor): self - { - $this->textColor = $textColor; - - return $this; - } -} diff --git a/vendor/endroid/qr-code/src/Label/LabelInterface.php b/vendor/endroid/qr-code/src/Label/LabelInterface.php deleted file mode 100644 index a7d2ed6..0000000 --- a/vendor/endroid/qr-code/src/Label/LabelInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -top = $top; - $this->right = $right; - $this->bottom = $bottom; - $this->left = $left; - } - - public function getTop(): int - { - return $this->top; - } - - public function getRight(): int - { - return $this->right; - } - - public function getBottom(): int - { - return $this->bottom; - } - - public function getLeft(): int - { - return $this->left; - } - - /** @return array */ - public function toArray(): array - { - return [ - 'top' => $this->top, - 'right' => $this->right, - 'bottom' => $this->bottom, - 'left' => $this->left, - ]; - } -} diff --git a/vendor/endroid/qr-code/src/Label/Margin/MarginInterface.php b/vendor/endroid/qr-code/src/Label/Margin/MarginInterface.php deleted file mode 100644 index bc428bd..0000000 --- a/vendor/endroid/qr-code/src/Label/Margin/MarginInterface.php +++ /dev/null @@ -1,19 +0,0 @@ - */ - public function toArray(): array; -} diff --git a/vendor/endroid/qr-code/src/Logo/Logo.php b/vendor/endroid/qr-code/src/Logo/Logo.php deleted file mode 100644 index b50d743..0000000 --- a/vendor/endroid/qr-code/src/Logo/Logo.php +++ /dev/null @@ -1,74 +0,0 @@ -path = $path; - $this->resizeToWidth = $resizeToWidth; - $this->resizeToHeight = $resizeToHeight; - $this->punchoutBackground = $punchoutBackground; - } - - public static function create(string $path): self - { - return new self($path); - } - - public function getPath(): string - { - return $this->path; - } - - public function setPath(string $path): self - { - $this->path = $path; - - return $this; - } - - public function getResizeToWidth(): ?int - { - return $this->resizeToWidth; - } - - public function setResizeToWidth(?int $resizeToWidth): self - { - $this->resizeToWidth = $resizeToWidth; - - return $this; - } - - public function getResizeToHeight(): ?int - { - return $this->resizeToHeight; - } - - public function setResizeToHeight(?int $resizeToHeight): self - { - $this->resizeToHeight = $resizeToHeight; - - return $this; - } - - public function getPunchoutBackground(): bool - { - return $this->punchoutBackground; - } - - public function setPunchoutBackground(bool $punchoutBackground): self - { - $this->punchoutBackground = $punchoutBackground; - - return $this; - } -} diff --git a/vendor/endroid/qr-code/src/Logo/LogoInterface.php b/vendor/endroid/qr-code/src/Logo/LogoInterface.php deleted file mode 100644 index 13d940c..0000000 --- a/vendor/endroid/qr-code/src/Logo/LogoInterface.php +++ /dev/null @@ -1,16 +0,0 @@ -> */ - private array $blockValues = []; - - private float $blockSize; - private int $innerSize; - private int $outerSize; - private int $marginLeft; - private int $marginRight; - - /** @param array> $blockValues */ - public function __construct(array $blockValues, int $size, int $margin, RoundBlockSizeModeInterface $roundBlockSizeMode) - { - $this->blockValues = $blockValues; - - $this->blockSize = $size / $this->getBlockCount(); - $this->innerSize = $size; - $this->outerSize = $size + 2 * $margin; - - if ($roundBlockSizeMode instanceof RoundBlockSizeModeEnlarge) { - $this->blockSize = intval(ceil($this->blockSize)); - $this->innerSize = intval($this->blockSize * $this->getBlockCount()); - $this->outerSize = $this->innerSize + 2 * $margin; - } elseif ($roundBlockSizeMode instanceof RoundBlockSizeModeShrink) { - $this->blockSize = intval(floor($this->blockSize)); - $this->innerSize = intval($this->blockSize * $this->getBlockCount()); - $this->outerSize = $this->innerSize + 2 * $margin; - } elseif ($roundBlockSizeMode instanceof RoundBlockSizeModeMargin) { - $this->blockSize = intval(floor($this->blockSize)); - $this->innerSize = intval($this->blockSize * $this->getBlockCount()); - } - - if ($this->blockSize < 1) { - throw new \Exception('Too much data: increase image dimensions or lower error correction level'); - } - - $this->marginLeft = intval(($this->outerSize - $this->innerSize) / 2); - $this->marginRight = $this->outerSize - $this->innerSize - $this->marginLeft; - } - - public function getBlockValue(int $rowIndex, int $columnIndex): int - { - return $this->blockValues[$rowIndex][$columnIndex]; - } - - public function getBlockCount(): int - { - return count($this->blockValues[0]); - } - - public function getBlockSize(): float - { - return $this->blockSize; - } - - public function getInnerSize(): int - { - return $this->innerSize; - } - - public function getOuterSize(): int - { - return $this->outerSize; - } - - public function getMarginLeft(): int - { - return $this->marginLeft; - } - - public function getMarginRight(): int - { - return $this->marginRight; - } -} diff --git a/vendor/endroid/qr-code/src/Matrix/MatrixFactoryInterface.php b/vendor/endroid/qr-code/src/Matrix/MatrixFactoryInterface.php deleted file mode 100644 index be501f1..0000000 --- a/vendor/endroid/qr-code/src/Matrix/MatrixFactoryInterface.php +++ /dev/null @@ -1,12 +0,0 @@ -data = $data; - $this->encoding = $encoding ?? new Encoding('UTF-8'); - $this->errorCorrectionLevel = $errorCorrectionLevel ?? new ErrorCorrectionLevelLow(); - $this->size = $size; - $this->margin = $margin; - $this->roundBlockSizeMode = $roundBlockSizeMode ?? new RoundBlockSizeModeMargin(); - $this->foregroundColor = $foregroundColor ?? new Color(0, 0, 0); - $this->backgroundColor = $backgroundColor ?? new Color(255, 255, 255); - } - - public static function create(string $data): self - { - return new self($data); - } - - public function getData(): string - { - return $this->data; - } - - public function setData(string $data): self - { - $this->data = $data; - - return $this; - } - - public function getEncoding(): EncodingInterface - { - return $this->encoding; - } - - public function setEncoding(Encoding $encoding): self - { - $this->encoding = $encoding; - - return $this; - } - - public function getErrorCorrectionLevel(): ErrorCorrectionLevelInterface - { - return $this->errorCorrectionLevel; - } - - public function setErrorCorrectionLevel(ErrorCorrectionLevelInterface $errorCorrectionLevel): self - { - $this->errorCorrectionLevel = $errorCorrectionLevel; - - return $this; - } - - public function getSize(): int - { - return $this->size; - } - - public function setSize(int $size): self - { - $this->size = $size; - - return $this; - } - - public function getMargin(): int - { - return $this->margin; - } - - public function setMargin(int $margin): self - { - $this->margin = $margin; - - return $this; - } - - public function getRoundBlockSizeMode(): RoundBlockSizeModeInterface - { - return $this->roundBlockSizeMode; - } - - public function setRoundBlockSizeMode(RoundBlockSizeModeInterface $roundBlockSizeMode): self - { - $this->roundBlockSizeMode = $roundBlockSizeMode; - - return $this; - } - - public function getForegroundColor(): ColorInterface - { - return $this->foregroundColor; - } - - public function setForegroundColor(ColorInterface $foregroundColor): self - { - $this->foregroundColor = $foregroundColor; - - return $this; - } - - public function getBackgroundColor(): ColorInterface - { - return $this->backgroundColor; - } - - public function setBackgroundColor(ColorInterface $backgroundColor): self - { - $this->backgroundColor = $backgroundColor; - - return $this; - } -} diff --git a/vendor/endroid/qr-code/src/QrCodeInterface.php b/vendor/endroid/qr-code/src/QrCodeInterface.php deleted file mode 100644 index 2c96984..0000000 --- a/vendor/endroid/qr-code/src/QrCodeInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -create($qrCode); - - return new BinaryResult($matrix); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/ConsoleWriter.php b/vendor/endroid/qr-code/src/Writer/ConsoleWriter.php deleted file mode 100644 index 92b8126..0000000 --- a/vendor/endroid/qr-code/src/Writer/ConsoleWriter.php +++ /dev/null @@ -1,29 +0,0 @@ -create($qrCode); - - return new ConsoleResult($matrix, $qrCode->getForegroundColor(), $qrCode->getBackgroundColor()); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/DebugWriter.php b/vendor/endroid/qr-code/src/Writer/DebugWriter.php deleted file mode 100644 index d514b0e..0000000 --- a/vendor/endroid/qr-code/src/Writer/DebugWriter.php +++ /dev/null @@ -1,32 +0,0 @@ -create($qrCode); - - return new DebugResult($matrix, $qrCode, $logo, $label, $options); - } - - public function validateResult(ResultInterface $result, string $expectedData): void - { - if (!$result instanceof DebugResult) { - throw new \Exception('Unable to write logo: instance of DebugResult expected'); - } - - $result->setValidateResult(true); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/EpsWriter.php b/vendor/endroid/qr-code/src/Writer/EpsWriter.php deleted file mode 100644 index eb0a0cd..0000000 --- a/vendor/endroid/qr-code/src/Writer/EpsWriter.php +++ /dev/null @@ -1,44 +0,0 @@ -create($qrCode); - - $lines = [ - '%!PS-Adobe-3.0 EPSF-3.0', - '%%BoundingBox: 0 0 '.$matrix->getOuterSize().' '.$matrix->getOuterSize(), - '/F { rectfill } def', - number_format($qrCode->getBackgroundColor()->getRed() / 100, 2, '.', ',').' '.number_format($qrCode->getBackgroundColor()->getGreen() / 100, 2, '.', ',').' '.number_format($qrCode->getBackgroundColor()->getBlue() / 100, 2, '.', ',').' setrgbcolor', - '0 0 '.$matrix->getOuterSize().' '.$matrix->getOuterSize().' F', - number_format($qrCode->getForegroundColor()->getRed() / 100, 2, '.', ',').' '.number_format($qrCode->getForegroundColor()->getGreen() / 100, 2, '.', ',').' '.number_format($qrCode->getForegroundColor()->getBlue() / 100, 2, '.', ',').' setrgbcolor', - ]; - - for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { - for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) { - if (1 === $matrix->getBlockValue($matrix->getBlockCount() - 1 - $rowIndex, $columnIndex)) { - $x = $matrix->getMarginLeft() + $matrix->getBlockSize() * $columnIndex; - $y = $matrix->getMarginLeft() + $matrix->getBlockSize() * $rowIndex; - $lines[] = number_format($x, self::DECIMAL_PRECISION, '.', '').' '.number_format($y, self::DECIMAL_PRECISION, '.', '').' '.number_format($matrix->getBlockSize(), self::DECIMAL_PRECISION, '.', '').' '.number_format($matrix->getBlockSize(), self::DECIMAL_PRECISION, '.', '').' F'; - } - } - } - - return new EpsResult($matrix, $lines); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/PdfWriter.php b/vendor/endroid/qr-code/src/Writer/PdfWriter.php deleted file mode 100644 index a087ba7..0000000 --- a/vendor/endroid/qr-code/src/Writer/PdfWriter.php +++ /dev/null @@ -1,133 +0,0 @@ -create($qrCode); - - $unit = 'mm'; - if (isset($options[self::WRITER_OPTION_UNIT])) { - $unit = $options[self::WRITER_OPTION_UNIT]; - } - - $allowedUnits = ['mm', 'pt', 'cm', 'in']; - if (!in_array($unit, $allowedUnits)) { - throw new \Exception(sprintf('PDF Measure unit should be one of [%s]', implode(', ', $allowedUnits))); - } - - $labelSpace = 0; - if ($label instanceof LabelInterface) { - $labelSpace = 30; - } - - if (!class_exists(\FPDF::class)) { - throw new \Exception('Unable to find FPDF: check your installation'); - } - - $foregroundColor = $qrCode->getForegroundColor(); - if ($foregroundColor->getAlpha() > 0) { - throw new \Exception('PDF Writer does not support alpha channels'); - } - $backgroundColor = $qrCode->getBackgroundColor(); - if ($backgroundColor->getAlpha() > 0) { - throw new \Exception('PDF Writer does not support alpha channels'); - } - - if (isset($options[self::WRITER_OPTION_PDF])) { - $fpdf = $options[self::WRITER_OPTION_PDF]; - if (!$fpdf instanceof \FPDF) { - throw new \Exception('pdf option must be an instance of FPDF'); - } - } else { - // @todo Check how to add label height later - $fpdf = new \FPDF('P', $unit, [$matrix->getOuterSize(), $matrix->getOuterSize() + $labelSpace]); - $fpdf->AddPage(); - } - - $x = 0; - if (isset($options[self::WRITER_OPTION_X])) { - $x = $options[self::WRITER_OPTION_X]; - } - $y = 0; - if (isset($options[self::WRITER_OPTION_Y])) { - $y = $options[self::WRITER_OPTION_Y]; - } - - $fpdf->SetFillColor($backgroundColor->getRed(), $backgroundColor->getGreen(), $backgroundColor->getBlue()); - $fpdf->Rect($x, $y, $matrix->getOuterSize(), $matrix->getOuterSize(), 'F'); - $fpdf->SetFillColor($foregroundColor->getRed(), $foregroundColor->getGreen(), $foregroundColor->getBlue()); - - for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { - for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) { - if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) { - $fpdf->Rect( - $x + $matrix->getMarginLeft() + ($columnIndex * $matrix->getBlockSize()), - $y + $matrix->getMarginLeft() + ($rowIndex * $matrix->getBlockSize()), - $matrix->getBlockSize(), - $matrix->getBlockSize(), - 'F' - ); - } - } - } - - if ($logo instanceof LogoInterface) { - $this->addLogo($logo, $fpdf, $x, $y, $matrix->getOuterSize()); - } - - if ($label instanceof LabelInterface) { - $fpdf->SetXY($x, $y + $matrix->getOuterSize() + $labelSpace - 25); - $fpdf->SetFont('Helvetica', '', $label->getFont()->getSize()); - $fpdf->Cell($matrix->getOuterSize(), 0, $label->getText(), 0, 0, 'C'); - } - - return new PdfResult($matrix, $fpdf); - } - - private function addLogo(LogoInterface $logo, \FPDF $fpdf, float $x, float $y, float $size): void - { - $logoPath = $logo->getPath(); - $logoHeight = $logo->getResizeToHeight(); - $logoWidth = $logo->getResizeToWidth(); - - if (null === $logoHeight || null === $logoWidth) { - $imageSize = \getimagesize($logoPath); - if (!$imageSize) { - throw new \Exception(sprintf('Unable to read image size for logo "%s"', $logoPath)); - } - [$logoSourceWidth, $logoSourceHeight] = $imageSize; - - if (null === $logoWidth) { - $logoWidth = (int) $logoSourceWidth; - } - - if (null === $logoHeight) { - $aspectRatio = $logoWidth / $logoSourceWidth; - $logoHeight = (int) ($logoSourceHeight * $aspectRatio); - } - } - - $logoX = $x + $size / 2 - $logoWidth / 2; - $logoY = $y + $size / 2 - $logoHeight / 2; - - $fpdf->Image($logoPath, $logoX, $logoY, $logoWidth, $logoHeight); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/PngWriter.php b/vendor/endroid/qr-code/src/Writer/PngWriter.php deleted file mode 100644 index 717ab9a..0000000 --- a/vendor/endroid/qr-code/src/Writer/PngWriter.php +++ /dev/null @@ -1,217 +0,0 @@ -create($qrCode); - - $baseBlockSize = $qrCode->getRoundBlockSizeMode() instanceof RoundBlockSizeModeNone ? 10 : intval($matrix->getBlockSize()); - $baseImage = imagecreatetruecolor($matrix->getBlockCount() * $baseBlockSize, $matrix->getBlockCount() * $baseBlockSize); - - if (!$baseImage) { - throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly'); - } - - /** @var int $foregroundColor */ - $foregroundColor = imagecolorallocatealpha( - $baseImage, - $qrCode->getForegroundColor()->getRed(), - $qrCode->getForegroundColor()->getGreen(), - $qrCode->getForegroundColor()->getBlue(), - $qrCode->getForegroundColor()->getAlpha() - ); - - /** @var int $transparentColor */ - $transparentColor = imagecolorallocatealpha($baseImage, 255, 255, 255, 127); - - imagefill($baseImage, 0, 0, $transparentColor); - - for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { - for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) { - if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) { - imagefilledrectangle( - $baseImage, - $columnIndex * $baseBlockSize, - $rowIndex * $baseBlockSize, - ($columnIndex + 1) * $baseBlockSize - 1, - ($rowIndex + 1) * $baseBlockSize - 1, - $foregroundColor - ); - } - } - } - - $targetWidth = $matrix->getOuterSize(); - $targetHeight = $matrix->getOuterSize(); - - if ($label instanceof LabelInterface) { - $labelImageData = LabelImageData::createForLabel($label); - $targetHeight += $labelImageData->getHeight() + $label->getMargin()->getTop() + $label->getMargin()->getBottom(); - } - - $targetImage = imagecreatetruecolor($targetWidth, $targetHeight); - - if (!$targetImage) { - throw new \Exception('Unable to generate image: please check if the GD extension is enabled and configured correctly'); - } - - /** @var int $backgroundColor */ - $backgroundColor = imagecolorallocatealpha( - $targetImage, - $qrCode->getBackgroundColor()->getRed(), - $qrCode->getBackgroundColor()->getGreen(), - $qrCode->getBackgroundColor()->getBlue(), - $qrCode->getBackgroundColor()->getAlpha() - ); - - imagefill($targetImage, 0, 0, $backgroundColor); - - imagecopyresampled( - $targetImage, - $baseImage, - $matrix->getMarginLeft(), - $matrix->getMarginLeft(), - 0, - 0, - $matrix->getInnerSize(), - $matrix->getInnerSize(), - imagesx($baseImage), - imagesy($baseImage) - ); - - if (PHP_VERSION_ID < 80000) { - imagedestroy($baseImage); - } - - if ($qrCode->getBackgroundColor()->getAlpha() > 0) { - imagesavealpha($targetImage, true); - } - - $result = new PngResult($matrix, $targetImage); - - if ($logo instanceof LogoInterface) { - $result = $this->addLogo($logo, $result); - } - - if ($label instanceof LabelInterface) { - $result = $this->addLabel($label, $result); - } - - return $result; - } - - private function addLogo(LogoInterface $logo, PngResult $result): PngResult - { - $logoImageData = LogoImageData::createForLogo($logo); - - if ('image/svg+xml' === $logoImageData->getMimeType()) { - throw new \Exception('PNG Writer does not support SVG logo'); - } - - $targetImage = $result->getImage(); - $matrix = $result->getMatrix(); - - if ($logoImageData->getPunchoutBackground()) { - /** @var int $transparent */ - $transparent = imagecolorallocatealpha($targetImage, 255, 255, 255, 127); - imagealphablending($targetImage, false); - $xOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2); - $yOffsetStart = intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2); - for ($xOffset = $xOffsetStart; $xOffset < $xOffsetStart + $logoImageData->getWidth(); ++$xOffset) { - for ($yOffset = $yOffsetStart; $yOffset < $yOffsetStart + $logoImageData->getHeight(); ++$yOffset) { - imagesetpixel($targetImage, $xOffset, $yOffset, $transparent); - } - } - } - - imagecopyresampled( - $targetImage, - $logoImageData->getImage(), - intval($matrix->getOuterSize() / 2 - $logoImageData->getWidth() / 2), - intval($matrix->getOuterSize() / 2 - $logoImageData->getHeight() / 2), - 0, - 0, - $logoImageData->getWidth(), - $logoImageData->getHeight(), - imagesx($logoImageData->getImage()), - imagesy($logoImageData->getImage()) - ); - - if (PHP_VERSION_ID < 80000) { - imagedestroy($logoImageData->getImage()); - } - - return new PngResult($matrix, $targetImage); - } - - private function addLabel(LabelInterface $label, PngResult $result): PngResult - { - $targetImage = $result->getImage(); - - $labelImageData = LabelImageData::createForLabel($label); - - /** @var int $textColor */ - $textColor = imagecolorallocatealpha( - $targetImage, - $label->getTextColor()->getRed(), - $label->getTextColor()->getGreen(), - $label->getTextColor()->getBlue(), - $label->getTextColor()->getAlpha() - ); - - $x = intval(imagesx($targetImage) / 2 - $labelImageData->getWidth() / 2); - $y = imagesy($targetImage) - $label->getMargin()->getBottom(); - - if ($label->getAlignment() instanceof LabelAlignmentLeft) { - $x = $label->getMargin()->getLeft(); - } elseif ($label->getAlignment() instanceof LabelAlignmentRight) { - $x = imagesx($targetImage) - $labelImageData->getWidth() - $label->getMargin()->getRight(); - } - - imagettftext($targetImage, $label->getFont()->getSize(), 0, $x, $y, $textColor, $label->getFont()->getPath(), $label->getText()); - - return new PngResult($result->getMatrix(), $targetImage); - } - - public function validateResult(ResultInterface $result, string $expectedData): void - { - $string = $result->getString(); - - if (!class_exists(QrReader::class)) { - throw ValidationException::createForMissingPackage('khanamiryan/qrcode-detector-decoder'); - } - - if (PHP_VERSION_ID >= 80000) { - throw ValidationException::createForIncompatiblePhpVersion(); - } - - $reader = new QrReader($string, QrReader::SOURCE_TYPE_BLOB); - if ($reader->text() !== $expectedData) { - throw ValidationException::createForInvalidData($expectedData, strval($reader->text())); - } - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/AbstractResult.php b/vendor/endroid/qr-code/src/Writer/Result/AbstractResult.php deleted file mode 100644 index acc1e5c..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/AbstractResult.php +++ /dev/null @@ -1,33 +0,0 @@ -matrix = $matrix; - } - - public function getMatrix(): MatrixInterface - { - return $this->matrix; - } - - public function getDataUri(): string - { - return 'data:'.$this->getMimeType().';base64,'.base64_encode($this->getString()); - } - - public function saveToFile(string $path): void - { - $string = $this->getString(); - file_put_contents($path, $string); - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/BinaryResult.php b/vendor/endroid/qr-code/src/Writer/Result/BinaryResult.php deleted file mode 100644 index 386fb6a..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/BinaryResult.php +++ /dev/null @@ -1,35 +0,0 @@ -getMatrix(); - - $binaryString = ''; - for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { - for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) { - $binaryString .= $matrix->getBlockValue($rowIndex, $columnIndex); - } - $binaryString .= "\n"; - } - - return $binaryString; - } - - public function getMimeType(): string - { - return 'text/plain'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/ConsoleResult.php b/vendor/endroid/qr-code/src/Writer/Result/ConsoleResult.php deleted file mode 100644 index 1da8984..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/ConsoleResult.php +++ /dev/null @@ -1,69 +0,0 @@ - ' ', - 1 => "\xe2\x96\x80", - 2 => "\xe2\x96\x84", - 3 => "\xe2\x96\x88", - ]; - - private string $colorEscapeCode; - - public function __construct( - MatrixInterface $matrix, - ColorInterface $foreground, - ColorInterface $background - ) { - parent::__construct($matrix); - - $this->colorEscapeCode = sprintf( - "\e[38;2;%d;%d;%dm\e[48;2;%d;%d;%dm", - $foreground->getRed(), - $foreground->getGreen(), - $foreground->getBlue(), - $background->getRed(), - $background->getGreen(), - $background->getBlue() - ); - } - - public function getMimeType(): string - { - return 'text/plain'; - } - - public function getString(): string - { - $matrix = $this->getMatrix(); - - $side = $matrix->getBlockCount(); - $marginLeft = $this->colorEscapeCode.self::TWO_BLOCKS[0].self::TWO_BLOCKS[0]; - $marginRight = self::TWO_BLOCKS[0].self::TWO_BLOCKS[0]."\e[0m".PHP_EOL; - $marginVertical = $marginLeft.str_repeat(self::TWO_BLOCKS[0], $side).$marginRight; - - $qrCodeString = $marginVertical; - for ($rowIndex = 0; $rowIndex < $side; $rowIndex += 2) { - $qrCodeString .= $marginLeft; - for ($columnIndex = 0; $columnIndex < $side; ++$columnIndex) { - $combined = $matrix->getBlockValue($rowIndex, $columnIndex); - if ($rowIndex + 1 < $side) { - $combined |= $matrix->getBlockValue($rowIndex + 1, $columnIndex) << 1; - } - $qrCodeString .= self::TWO_BLOCKS[$combined]; - } - $qrCodeString .= $marginRight; - } - $qrCodeString .= $marginVertical; - - return $qrCodeString; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/DebugResult.php b/vendor/endroid/qr-code/src/Writer/Result/DebugResult.php deleted file mode 100644 index 4c4fad2..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/DebugResult.php +++ /dev/null @@ -1,85 +0,0 @@ - */ - private array $options; - - private bool $validateResult = false; - - /** @param array $options */ - public function __construct( - MatrixInterface $matrix, - QrCodeInterface $qrCode, - LogoInterface $logo = null, - LabelInterface $label = null, - array $options = [] - ) { - parent::__construct($matrix); - - $this->qrCode = $qrCode; - $this->logo = $logo; - $this->label = $label; - $this->options = $options; - } - - public function setValidateResult(bool $validateResult): void - { - $this->validateResult = $validateResult; - } - - public function getString(): string - { - $debugLines = []; - - $debugLines[] = 'Data: '.$this->qrCode->getData(); - $debugLines[] = 'Encoding: '.$this->qrCode->getEncoding(); - $debugLines[] = 'Error Correction Level: '.get_class($this->qrCode->getErrorCorrectionLevel()); - $debugLines[] = 'Size: '.$this->qrCode->getSize(); - $debugLines[] = 'Margin: '.$this->qrCode->getMargin(); - $debugLines[] = 'Round block size mode: '.get_class($this->qrCode->getRoundBlockSizeMode()); - $debugLines[] = 'Foreground color: ['.implode(', ', $this->qrCode->getForegroundColor()->toArray()).']'; - $debugLines[] = 'Background color: ['.implode(', ', $this->qrCode->getBackgroundColor()->toArray()).']'; - - foreach ($this->options as $key => $value) { - $debugLines[] = 'Writer option: '.$key.': '.$value; - } - - if (isset($this->logo)) { - $debugLines[] = 'Logo path: '.$this->logo->getPath(); - $debugLines[] = 'Logo resize to width: '.$this->logo->getResizeToWidth(); - $debugLines[] = 'Logo resize to height: '.$this->logo->getResizeToHeight(); - } - - if (isset($this->label)) { - $debugLines[] = 'Label text: '.$this->label->getText(); - $debugLines[] = 'Label font path: '.$this->label->getFont()->getPath(); - $debugLines[] = 'Label font size: '.$this->label->getFont()->getSize(); - $debugLines[] = 'Label alignment: '.get_class($this->label->getAlignment()); - $debugLines[] = 'Label margin: ['.implode(', ', $this->label->getMargin()->toArray()).']'; - $debugLines[] = 'Label text color: ['.implode(', ', $this->label->getTextColor()->toArray()).']'; - } - - $debugLines[] = 'Validate result: '.($this->validateResult ? 'true' : 'false'); - - return implode("\n", $debugLines); - } - - public function getMimeType(): string - { - return 'text/plain'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/EpsResult.php b/vendor/endroid/qr-code/src/Writer/Result/EpsResult.php deleted file mode 100644 index cda126a..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/EpsResult.php +++ /dev/null @@ -1,31 +0,0 @@ - */ - private array $lines; - - /** @param array $lines */ - public function __construct(MatrixInterface $matrix, array $lines) - { - parent::__construct($matrix); - - $this->lines = $lines; - } - - public function getString(): string - { - return implode("\n", $this->lines); - } - - public function getMimeType(): string - { - return 'image/eps'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/PdfResult.php b/vendor/endroid/qr-code/src/Writer/Result/PdfResult.php deleted file mode 100644 index 28445fc..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/PdfResult.php +++ /dev/null @@ -1,34 +0,0 @@ -fpdf = $fpdf; - } - - public function getPdf(): \FPDF - { - return $this->fpdf; - } - - public function getString(): string - { - return $this->fpdf->Output('S'); - } - - public function getMimeType(): string - { - return 'application/pdf'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/PngResult.php b/vendor/endroid/qr-code/src/Writer/Result/PngResult.php deleted file mode 100644 index bbf795d..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/PngResult.php +++ /dev/null @@ -1,40 +0,0 @@ -image = $image; - } - - /** @return mixed */ - public function getImage() - { - return $this->image; - } - - public function getString(): string - { - ob_start(); - imagepng($this->image); - - return strval(ob_get_clean()); - } - - public function getMimeType(): string - { - return 'image/png'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/Result/ResultInterface.php b/vendor/endroid/qr-code/src/Writer/Result/ResultInterface.php deleted file mode 100644 index 2cd387e..0000000 --- a/vendor/endroid/qr-code/src/Writer/Result/ResultInterface.php +++ /dev/null @@ -1,20 +0,0 @@ -xml = $xml; - $this->excludeXmlDeclaration = $excludeXmlDeclaration; - } - - public function getXml(): \SimpleXMLElement - { - return $this->xml; - } - - public function getString(): string - { - $string = $this->xml->asXML(); - - if (!is_string($string)) { - throw new \Exception('Could not save SVG XML to string'); - } - - if ($this->excludeXmlDeclaration) { - $string = str_replace("\n", '', $string); - } - - return $string; - } - - public function getMimeType(): string - { - return 'image/svg+xml'; - } -} diff --git a/vendor/endroid/qr-code/src/Writer/SvgWriter.php b/vendor/endroid/qr-code/src/Writer/SvgWriter.php deleted file mode 100644 index f0857c4..0000000 --- a/vendor/endroid/qr-code/src/Writer/SvgWriter.php +++ /dev/null @@ -1,114 +0,0 @@ -create($qrCode); - - $xml = new \SimpleXMLElement(''); - $xml->addAttribute('version', '1.1'); - if (!$options[self::WRITER_OPTION_EXCLUDE_SVG_WIDTH_AND_HEIGHT]) { - $xml->addAttribute('width', $matrix->getOuterSize().'px'); - $xml->addAttribute('height', $matrix->getOuterSize().'px'); - } - $xml->addAttribute('viewBox', '0 0 '.$matrix->getOuterSize().' '.$matrix->getOuterSize()); - $xml->addChild('defs'); - - $blockDefinition = $xml->defs->addChild('rect'); - $blockDefinition->addAttribute('id', strval($options[self::WRITER_OPTION_BLOCK_ID])); - $blockDefinition->addAttribute('width', number_format($matrix->getBlockSize(), self::DECIMAL_PRECISION, '.', '')); - $blockDefinition->addAttribute('height', number_format($matrix->getBlockSize(), self::DECIMAL_PRECISION, '.', '')); - $blockDefinition->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getForegroundColor()->getRed(), $qrCode->getForegroundColor()->getGreen(), $qrCode->getForegroundColor()->getBlue())); - $blockDefinition->addAttribute('fill-opacity', strval($qrCode->getForegroundColor()->getOpacity())); - - $background = $xml->addChild('rect'); - $background->addAttribute('x', '0'); - $background->addAttribute('y', '0'); - $background->addAttribute('width', strval($matrix->getOuterSize())); - $background->addAttribute('height', strval($matrix->getOuterSize())); - $background->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getBackgroundColor()->getRed(), $qrCode->getBackgroundColor()->getGreen(), $qrCode->getBackgroundColor()->getBlue())); - $background->addAttribute('fill-opacity', strval($qrCode->getBackgroundColor()->getOpacity())); - - for ($rowIndex = 0; $rowIndex < $matrix->getBlockCount(); ++$rowIndex) { - for ($columnIndex = 0; $columnIndex < $matrix->getBlockCount(); ++$columnIndex) { - if (1 === $matrix->getBlockValue($rowIndex, $columnIndex)) { - $block = $xml->addChild('use'); - $block->addAttribute('x', number_format($matrix->getMarginLeft() + $matrix->getBlockSize() * $columnIndex, self::DECIMAL_PRECISION, '.', '')); - $block->addAttribute('y', number_format($matrix->getMarginLeft() + $matrix->getBlockSize() * $rowIndex, self::DECIMAL_PRECISION, '.', '')); - $block->addAttribute('xlink:href', '#'.$options[self::WRITER_OPTION_BLOCK_ID], 'http://www.w3.org/1999/xlink'); - } - } - } - - $result = new SvgResult($matrix, $xml, boolval($options[self::WRITER_OPTION_EXCLUDE_XML_DECLARATION])); - - if ($logo instanceof LogoInterface) { - $this->addLogo($logo, $result, $options); - } - - return $result; - } - - /** @param array $options */ - private function addLogo(LogoInterface $logo, SvgResult $result, array $options): void - { - $logoImageData = LogoImageData::createForLogo($logo); - - if (!isset($options[self::WRITER_OPTION_FORCE_XLINK_HREF])) { - $options[self::WRITER_OPTION_FORCE_XLINK_HREF] = false; - } - - $xml = $result->getXml(); - - /** @var \SimpleXMLElement $xmlAttributes */ - $xmlAttributes = $xml->attributes(); - - $x = intval($xmlAttributes->width) / 2 - $logoImageData->getWidth() / 2; - $y = intval($xmlAttributes->height) / 2 - $logoImageData->getHeight() / 2; - - $imageDefinition = $xml->addChild('image'); - $imageDefinition->addAttribute('x', strval($x)); - $imageDefinition->addAttribute('y', strval($y)); - $imageDefinition->addAttribute('width', strval($logoImageData->getWidth())); - $imageDefinition->addAttribute('height', strval($logoImageData->getHeight())); - $imageDefinition->addAttribute('preserveAspectRatio', 'none'); - - if ($options[self::WRITER_OPTION_FORCE_XLINK_HREF]) { - $imageDefinition->addAttribute('xlink:href', $logoImageData->createDataUri(), 'http://www.w3.org/1999/xlink'); - } else { - $imageDefinition->addAttribute('href', $logoImageData->createDataUri()); - } - } -} diff --git a/vendor/endroid/qr-code/src/Writer/ValidatingWriterInterface.php b/vendor/endroid/qr-code/src/Writer/ValidatingWriterInterface.php deleted file mode 100644 index 4f40048..0000000 --- a/vendor/endroid/qr-code/src/Writer/ValidatingWriterInterface.php +++ /dev/null @@ -1,12 +0,0 @@ - $options */ - public function write(QrCodeInterface $qrCode, LogoInterface $logo = null, LabelInterface $label = null, array $options = []): ResultInterface; -} diff --git a/vendor/firebase/php-jwt/LICENSE b/vendor/firebase/php-jwt/LICENSE deleted file mode 100644 index 11c0146..0000000 --- a/vendor/firebase/php-jwt/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2011, Neuman Vong - -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 the copyright holder nor the names of other - 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. diff --git a/vendor/firebase/php-jwt/README.md b/vendor/firebase/php-jwt/README.md deleted file mode 100644 index 1d392cd..0000000 --- a/vendor/firebase/php-jwt/README.md +++ /dev/null @@ -1,289 +0,0 @@ -[![Build Status](https://travis-ci.org/firebase/php-jwt.png?branch=master)](https://travis-ci.org/firebase/php-jwt) -[![Latest Stable Version](https://poser.pugx.org/firebase/php-jwt/v/stable)](https://packagist.org/packages/firebase/php-jwt) -[![Total Downloads](https://poser.pugx.org/firebase/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt) -[![License](https://poser.pugx.org/firebase/php-jwt/license)](https://packagist.org/packages/firebase/php-jwt) - -PHP-JWT -======= -A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to [RFC 7519](https://tools.ietf.org/html/rfc7519). - -Installation ------------- - -Use composer to manage your dependencies and download PHP-JWT: - -```bash -composer require firebase/php-jwt -``` - -Optionally, install the `paragonie/sodium_compat` package from composer if your -php is < 7.2 or does not have libsodium installed: - -```bash -composer require paragonie/sodium_compat -``` - -Example -------- -```php -use Firebase\JWT\JWT; -use Firebase\JWT\Key; - -$key = "example_key"; -$payload = array( - "iss" => "http://example.org", - "aud" => "http://example.com", - "iat" => 1356999524, - "nbf" => 1357000000 -); - -/** - * IMPORTANT: - * You must specify supported algorithms for your application. See - * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40 - * for a list of spec-compliant algorithms. - */ -$jwt = JWT::encode($payload, $key, 'HS256'); -$decoded = JWT::decode($jwt, new Key($key, 'HS256')); - -print_r($decoded); - -/* - NOTE: This will now be an object instead of an associative array. To get - an associative array, you will need to cast it as such: -*/ - -$decoded_array = (array) $decoded; - -/** - * You can add a leeway to account for when there is a clock skew times between - * the signing and verifying servers. It is recommended that this leeway should - * not be bigger than a few minutes. - * - * Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef - */ -JWT::$leeway = 60; // $leeway in seconds -$decoded = JWT::decode($jwt, new Key($key, 'HS256')); -``` -Example with RS256 (openssl) ----------------------------- -```php -use Firebase\JWT\JWT; -use Firebase\JWT\Key; - -$privateKey = << "example.org", - "aud" => "example.com", - "iat" => 1356999524, - "nbf" => 1357000000 -); - -$jwt = JWT::encode($payload, $privateKey, 'RS256'); -echo "Encode:\n" . print_r($jwt, true) . "\n"; - -$decoded = JWT::decode($jwt, new Key($publicKey, 'RS256')); - -/* - NOTE: This will now be an object instead of an associative array. To get - an associative array, you will need to cast it as such: -*/ - -$decoded_array = (array) $decoded; -echo "Decode:\n" . print_r($decoded_array, true) . "\n"; -``` - -Example with a passphrase -------------------------- - -```php -use Firebase\JWT\JWT; -use Firebase\JWT\Key; - -// Your passphrase -$passphrase = '[YOUR_PASSPHRASE]'; - -// Your private key file with passphrase -// Can be generated with "ssh-keygen -t rsa -m pem" -$privateKeyFile = '/path/to/key-with-passphrase.pem'; - -// Create a private key of type "resource" -$privateKey = openssl_pkey_get_private( - file_get_contents($privateKeyFile), - $passphrase -); - -$payload = array( - "iss" => "example.org", - "aud" => "example.com", - "iat" => 1356999524, - "nbf" => 1357000000 -); - -$jwt = JWT::encode($payload, $privateKey, 'RS256'); -echo "Encode:\n" . print_r($jwt, true) . "\n"; - -// Get public key from the private key, or pull from from a file. -$publicKey = openssl_pkey_get_details($privateKey)['key']; - -$decoded = JWT::decode($jwt, new Key($publicKey, 'RS256')); -echo "Decode:\n" . print_r((array) $decoded, true) . "\n"; -``` - -Example with EdDSA (libsodium and Ed25519 signature) ----------------------------- -```php -use Firebase\JWT\JWT; -use Firebase\JWT\Key; - -// Public and private keys are expected to be Base64 encoded. The last -// non-empty line is used so that keys can be generated with -// sodium_crypto_sign_keypair(). The secret keys generated by other tools may -// need to be adjusted to match the input expected by libsodium. - -$keyPair = sodium_crypto_sign_keypair(); - -$privateKey = base64_encode(sodium_crypto_sign_secretkey($keyPair)); - -$publicKey = base64_encode(sodium_crypto_sign_publickey($keyPair)); - -$payload = array( - "iss" => "example.org", - "aud" => "example.com", - "iat" => 1356999524, - "nbf" => 1357000000 -); - -$jwt = JWT::encode($payload, $privateKey, 'EdDSA'); -echo "Encode:\n" . print_r($jwt, true) . "\n"; - -$decoded = JWT::decode($jwt, new Key($publicKey, 'EdDSA')); -echo "Decode:\n" . print_r((array) $decoded, true) . "\n"; -```` - -Using JWKs ----------- - -```php -use Firebase\JWT\JWK; -use Firebase\JWT\JWT; - -// Set of keys. The "keys" key is required. For example, the JSON response to -// this endpoint: https://www.gstatic.com/iap/verify/public_key-jwk -$jwks = ['keys' => []]; - -// JWK::parseKeySet($jwks) returns an associative array of **kid** to private -// key. Pass this as the second parameter to JWT::decode. -// NOTE: The deprecated $supportedAlgorithm must be supplied when parsing from JWK. -JWT::decode($payload, JWK::parseKeySet($jwks), $supportedAlgorithm); -``` - -Changelog ---------- - -#### 5.0.0 / 2017-06-26 -- Support RS384 and RS512. - See [#117](https://github.com/firebase/php-jwt/pull/117). Thanks [@joostfaassen](https://github.com/joostfaassen)! -- Add an example for RS256 openssl. - See [#125](https://github.com/firebase/php-jwt/pull/125). Thanks [@akeeman](https://github.com/akeeman)! -- Detect invalid Base64 encoding in signature. - See [#162](https://github.com/firebase/php-jwt/pull/162). Thanks [@psignoret](https://github.com/psignoret)! -- Update `JWT::verify` to handle OpenSSL errors. - See [#159](https://github.com/firebase/php-jwt/pull/159). Thanks [@bshaffer](https://github.com/bshaffer)! -- Add `array` type hinting to `decode` method - See [#101](https://github.com/firebase/php-jwt/pull/101). Thanks [@hywak](https://github.com/hywak)! -- Add all JSON error types. - See [#110](https://github.com/firebase/php-jwt/pull/110). Thanks [@gbalduzzi](https://github.com/gbalduzzi)! -- Bugfix 'kid' not in given key list. - See [#129](https://github.com/firebase/php-jwt/pull/129). Thanks [@stampycode](https://github.com/stampycode)! -- Miscellaneous cleanup, documentation and test fixes. - See [#107](https://github.com/firebase/php-jwt/pull/107), [#115](https://github.com/firebase/php-jwt/pull/115), - [#160](https://github.com/firebase/php-jwt/pull/160), [#161](https://github.com/firebase/php-jwt/pull/161), and - [#165](https://github.com/firebase/php-jwt/pull/165). Thanks [@akeeman](https://github.com/akeeman), - [@chinedufn](https://github.com/chinedufn), and [@bshaffer](https://github.com/bshaffer)! - -#### 4.0.0 / 2016-07-17 -- Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)! -- Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)! -- Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)! -- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)! - -#### 3.0.0 / 2015-07-22 -- Minimum PHP version updated from `5.2.0` to `5.3.0`. -- Add `\Firebase\JWT` namespace. See -[#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to -[@Dashron](https://github.com/Dashron)! -- Require a non-empty key to decode and verify a JWT. See -[#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to -[@sjones608](https://github.com/sjones608)! -- Cleaner documentation blocks in the code. See -[#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to -[@johanderuijter](https://github.com/johanderuijter)! - -#### 2.2.0 / 2015-06-22 -- Add support for adding custom, optional JWT headers to `JWT::encode()`. See -[#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to -[@mcocaro](https://github.com/mcocaro)! - -#### 2.1.0 / 2015-05-20 -- Add support for adding a leeway to `JWT:decode()` that accounts for clock skew -between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)! -- Add support for passing an object implementing the `ArrayAccess` interface for -`$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)! - -#### 2.0.0 / 2015-04-01 -- **Note**: It is strongly recommended that you update to > v2.0.0 to address - known security vulnerabilities in prior versions when both symmetric and - asymmetric keys are used together. -- Update signature for `JWT::decode(...)` to require an array of supported - algorithms to use when verifying token signatures. - - -Tests ------ -Run the tests using phpunit: - -```bash -$ pear install PHPUnit -$ phpunit --configuration phpunit.xml.dist -PHPUnit 3.7.10 by Sebastian Bergmann. -..... -Time: 0 seconds, Memory: 2.50Mb -OK (5 tests, 5 assertions) -``` - -New Lines in private keys ------ - -If your private key contains `\n` characters, be sure to wrap it in double quotes `""` -and not single quotes `''` in order to properly interpret the escaped characters. - -License -------- -[3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause). diff --git a/vendor/firebase/php-jwt/composer.json b/vendor/firebase/php-jwt/composer.json deleted file mode 100644 index 6146e2d..0000000 --- a/vendor/firebase/php-jwt/composer.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "firebase/php-jwt", - "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", - "homepage": "https://github.com/firebase/php-jwt", - "keywords": [ - "php", - "jwt" - ], - "authors": [ - { - "name": "Neuman Vong", - "email": "neuman+pear@twilio.com", - "role": "Developer" - }, - { - "name": "Anant Narayanan", - "email": "anant@php.net", - "role": "Developer" - } - ], - "license": "BSD-3-Clause", - "require": { - "php": ">=5.3.0" - }, - "suggest": { - "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" - }, - "autoload": { - "psr-4": { - "Firebase\\JWT\\": "src" - } - }, - "require-dev": { - "phpunit/phpunit": ">=4.8 <=9" - } -} diff --git a/vendor/firebase/php-jwt/src/BeforeValidException.php b/vendor/firebase/php-jwt/src/BeforeValidException.php deleted file mode 100644 index c147852..0000000 --- a/vendor/firebase/php-jwt/src/BeforeValidException.php +++ /dev/null @@ -1,7 +0,0 @@ - - * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD - * @link https://github.com/firebase/php-jwt - */ -class JWK -{ - /** - * Parse a set of JWK keys - * - * @param array $jwks The JSON Web Key Set as an associative array - * - * @return array An associative array that represents the set of keys - * - * @throws InvalidArgumentException Provided JWK Set is empty - * @throws UnexpectedValueException Provided JWK Set was invalid - * @throws DomainException OpenSSL failure - * - * @uses parseKey - */ - public static function parseKeySet(array $jwks) - { - $keys = array(); - - if (!isset($jwks['keys'])) { - throw new UnexpectedValueException('"keys" member must exist in the JWK Set'); - } - if (empty($jwks['keys'])) { - throw new InvalidArgumentException('JWK Set did not contain any keys'); - } - - foreach ($jwks['keys'] as $k => $v) { - $kid = isset($v['kid']) ? $v['kid'] : $k; - if ($key = self::parseKey($v)) { - $keys[$kid] = $key; - } - } - - if (0 === \count($keys)) { - throw new UnexpectedValueException('No supported algorithms found in JWK Set'); - } - - return $keys; - } - - /** - * Parse a JWK key - * - * @param array $jwk An individual JWK - * - * @return resource|array An associative array that represents the key - * - * @throws InvalidArgumentException Provided JWK is empty - * @throws UnexpectedValueException Provided JWK was invalid - * @throws DomainException OpenSSL failure - * - * @uses createPemFromModulusAndExponent - */ - public static function parseKey(array $jwk) - { - if (empty($jwk)) { - throw new InvalidArgumentException('JWK must not be empty'); - } - if (!isset($jwk['kty'])) { - throw new UnexpectedValueException('JWK must contain a "kty" parameter'); - } - - switch ($jwk['kty']) { - case 'RSA': - if (!empty($jwk['d'])) { - throw new UnexpectedValueException('RSA private keys are not supported'); - } - if (!isset($jwk['n']) || !isset($jwk['e'])) { - throw new UnexpectedValueException('RSA keys must contain values for both "n" and "e"'); - } - - $pem = self::createPemFromModulusAndExponent($jwk['n'], $jwk['e']); - $publicKey = \openssl_pkey_get_public($pem); - if (false === $publicKey) { - throw new DomainException( - 'OpenSSL error: ' . \openssl_error_string() - ); - } - return $publicKey; - default: - // Currently only RSA is supported - break; - } - } - - /** - * Create a public key represented in PEM format from RSA modulus and exponent information - * - * @param string $n The RSA modulus encoded in Base64 - * @param string $e The RSA exponent encoded in Base64 - * - * @return string The RSA public key represented in PEM format - * - * @uses encodeLength - */ - private static function createPemFromModulusAndExponent($n, $e) - { - $modulus = JWT::urlsafeB64Decode($n); - $publicExponent = JWT::urlsafeB64Decode($e); - - $components = array( - 'modulus' => \pack('Ca*a*', 2, self::encodeLength(\strlen($modulus)), $modulus), - 'publicExponent' => \pack('Ca*a*', 2, self::encodeLength(\strlen($publicExponent)), $publicExponent) - ); - - $rsaPublicKey = \pack( - 'Ca*a*a*', - 48, - self::encodeLength(\strlen($components['modulus']) + \strlen($components['publicExponent'])), - $components['modulus'], - $components['publicExponent'] - ); - - // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. - $rsaOID = \pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA - $rsaPublicKey = \chr(0) . $rsaPublicKey; - $rsaPublicKey = \chr(3) . self::encodeLength(\strlen($rsaPublicKey)) . $rsaPublicKey; - - $rsaPublicKey = \pack( - 'Ca*a*', - 48, - self::encodeLength(\strlen($rsaOID . $rsaPublicKey)), - $rsaOID . $rsaPublicKey - ); - - $rsaPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . - \chunk_split(\base64_encode($rsaPublicKey), 64) . - '-----END PUBLIC KEY-----'; - - return $rsaPublicKey; - } - - /** - * DER-encode the length - * - * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See - * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. - * - * @param int $length - * @return string - */ - private static function encodeLength($length) - { - if ($length <= 0x7F) { - return \chr($length); - } - - $temp = \ltrim(\pack('N', $length), \chr(0)); - - return \pack('Ca*', 0x80 | \strlen($temp), $temp); - } -} diff --git a/vendor/firebase/php-jwt/src/JWT.php b/vendor/firebase/php-jwt/src/JWT.php deleted file mode 100644 index ec1641b..0000000 --- a/vendor/firebase/php-jwt/src/JWT.php +++ /dev/null @@ -1,611 +0,0 @@ - - * @author Anant Narayanan - * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD - * @link https://github.com/firebase/php-jwt - */ -class JWT -{ - const ASN1_INTEGER = 0x02; - const ASN1_SEQUENCE = 0x10; - const ASN1_BIT_STRING = 0x03; - - /** - * When checking nbf, iat or expiration times, - * we want to provide some extra leeway time to - * account for clock skew. - */ - public static $leeway = 0; - - /** - * Allow the current timestamp to be specified. - * Useful for fixing a value within unit testing. - * - * Will default to PHP time() value if null. - */ - public static $timestamp = null; - - public static $supported_algs = array( - 'ES384' => array('openssl', 'SHA384'), - 'ES256' => array('openssl', 'SHA256'), - 'HS256' => array('hash_hmac', 'SHA256'), - 'HS384' => array('hash_hmac', 'SHA384'), - 'HS512' => array('hash_hmac', 'SHA512'), - 'RS256' => array('openssl', 'SHA256'), - 'RS384' => array('openssl', 'SHA384'), - 'RS512' => array('openssl', 'SHA512'), - 'EdDSA' => array('sodium_crypto', 'EdDSA'), - ); - - /** - * Decodes a JWT string into a PHP object. - * - * @param string $jwt The JWT - * @param Key|array|mixed $keyOrKeyArray The Key or array of Key objects. - * If the algorithm used is asymmetric, this is the public key - * Each Key object contains an algorithm and matching key. - * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384', - * 'HS512', 'RS256', 'RS384', and 'RS512' - * @param array $allowed_algs [DEPRECATED] List of supported verification algorithms. Only - * should be used for backwards compatibility. - * - * @return object The JWT's payload as a PHP object - * - * @throws InvalidArgumentException Provided JWT was empty - * @throws UnexpectedValueException Provided JWT was invalid - * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed - * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf' - * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat' - * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim - * - * @uses jsonDecode - * @uses urlsafeB64Decode - */ - public static function decode($jwt, $keyOrKeyArray, array $allowed_algs = array()) - { - $timestamp = \is_null(static::$timestamp) ? \time() : static::$timestamp; - - if (empty($keyOrKeyArray)) { - throw new InvalidArgumentException('Key may not be empty'); - } - $tks = \explode('.', $jwt); - if (\count($tks) != 3) { - throw new UnexpectedValueException('Wrong number of segments'); - } - list($headb64, $bodyb64, $cryptob64) = $tks; - if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) { - throw new UnexpectedValueException('Invalid header encoding'); - } - if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) { - throw new UnexpectedValueException('Invalid claims encoding'); - } - if (false === ($sig = static::urlsafeB64Decode($cryptob64))) { - throw new UnexpectedValueException('Invalid signature encoding'); - } - if (empty($header->alg)) { - throw new UnexpectedValueException('Empty algorithm'); - } - if (empty(static::$supported_algs[$header->alg])) { - throw new UnexpectedValueException('Algorithm not supported'); - } - - list($keyMaterial, $algorithm) = self::getKeyMaterialAndAlgorithm( - $keyOrKeyArray, - empty($header->kid) ? null : $header->kid - ); - - if (empty($algorithm)) { - // Use deprecated "allowed_algs" to determine if the algorithm is supported. - // This opens up the possibility of an attack in some implementations. - // @see https://github.com/firebase/php-jwt/issues/351 - if (!\in_array($header->alg, $allowed_algs)) { - throw new UnexpectedValueException('Algorithm not allowed'); - } - } else { - // Check the algorithm - if (!self::constantTimeEquals($algorithm, $header->alg)) { - // See issue #351 - throw new UnexpectedValueException('Incorrect key for this algorithm'); - } - } - if ($header->alg === 'ES256' || $header->alg === 'ES384') { - // OpenSSL expects an ASN.1 DER sequence for ES256/ES384 signatures - $sig = self::signatureToDER($sig); - } - - if (!static::verify("$headb64.$bodyb64", $sig, $keyMaterial, $header->alg)) { - throw new SignatureInvalidException('Signature verification failed'); - } - - // Check the nbf if it is defined. This is the time that the - // token can actually be used. If it's not yet that time, abort. - if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { - throw new BeforeValidException( - 'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->nbf) - ); - } - - // Check that this token has been created before 'now'. This prevents - // using tokens that have been created for later use (and haven't - // correctly used the nbf claim). - if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) { - throw new BeforeValidException( - 'Cannot handle token prior to ' . \date(DateTime::ISO8601, $payload->iat) - ); - } - - // Check if this token has expired. - if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) { - throw new ExpiredException('Expired token'); - } - - return $payload; - } - - /** - * Converts and signs a PHP object or array into a JWT string. - * - * @param object|array $payload PHP object or array - * @param string|resource $key The secret key. - * If the algorithm used is asymmetric, this is the private key - * @param string $alg The signing algorithm. - * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384', - * 'HS512', 'RS256', 'RS384', and 'RS512' - * @param mixed $keyId - * @param array $head An array with header elements to attach - * - * @return string A signed JWT - * - * @uses jsonEncode - * @uses urlsafeB64Encode - */ - public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) - { - $header = array('typ' => 'JWT', 'alg' => $alg); - if ($keyId !== null) { - $header['kid'] = $keyId; - } - if (isset($head) && \is_array($head)) { - $header = \array_merge($head, $header); - } - $segments = array(); - $segments[] = static::urlsafeB64Encode(static::jsonEncode($header)); - $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload)); - $signing_input = \implode('.', $segments); - - $signature = static::sign($signing_input, $key, $alg); - $segments[] = static::urlsafeB64Encode($signature); - - return \implode('.', $segments); - } - - /** - * Sign a string with a given key and algorithm. - * - * @param string $msg The message to sign - * @param string|resource $key The secret key - * @param string $alg The signing algorithm. - * Supported algorithms are 'ES384','ES256', 'HS256', 'HS384', - * 'HS512', 'RS256', 'RS384', and 'RS512' - * - * @return string An encrypted message - * - * @throws DomainException Unsupported algorithm or bad key was specified - */ - public static function sign($msg, $key, $alg = 'HS256') - { - if (empty(static::$supported_algs[$alg])) { - throw new DomainException('Algorithm not supported'); - } - list($function, $algorithm) = static::$supported_algs[$alg]; - switch ($function) { - case 'hash_hmac': - return \hash_hmac($algorithm, $msg, $key, true); - case 'openssl': - $signature = ''; - $success = \openssl_sign($msg, $signature, $key, $algorithm); - if (!$success) { - throw new DomainException("OpenSSL unable to sign data"); - } - if ($alg === 'ES256') { - $signature = self::signatureFromDER($signature, 256); - } elseif ($alg === 'ES384') { - $signature = self::signatureFromDER($signature, 384); - } - return $signature; - case 'sodium_crypto': - if (!function_exists('sodium_crypto_sign_detached')) { - throw new DomainException('libsodium is not available'); - } - try { - // The last non-empty line is used as the key. - $lines = array_filter(explode("\n", $key)); - $key = base64_decode(end($lines)); - return sodium_crypto_sign_detached($msg, $key); - } catch (Exception $e) { - throw new DomainException($e->getMessage(), 0, $e); - } - } - } - - /** - * Verify a signature with the message, key and method. Not all methods - * are symmetric, so we must have a separate verify and sign method. - * - * @param string $msg The original message (header and body) - * @param string $signature The original signature - * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key - * @param string $alg The algorithm - * - * @return bool - * - * @throws DomainException Invalid Algorithm, bad key, or OpenSSL failure - */ - private static function verify($msg, $signature, $key, $alg) - { - if (empty(static::$supported_algs[$alg])) { - throw new DomainException('Algorithm not supported'); - } - - list($function, $algorithm) = static::$supported_algs[$alg]; - switch ($function) { - case 'openssl': - $success = \openssl_verify($msg, $signature, $key, $algorithm); - if ($success === 1) { - return true; - } elseif ($success === 0) { - return false; - } - // returns 1 on success, 0 on failure, -1 on error. - throw new DomainException( - 'OpenSSL error: ' . \openssl_error_string() - ); - case 'sodium_crypto': - if (!function_exists('sodium_crypto_sign_verify_detached')) { - throw new DomainException('libsodium is not available'); - } - try { - // The last non-empty line is used as the key. - $lines = array_filter(explode("\n", $key)); - $key = base64_decode(end($lines)); - return sodium_crypto_sign_verify_detached($signature, $msg, $key); - } catch (Exception $e) { - throw new DomainException($e->getMessage(), 0, $e); - } - case 'hash_hmac': - default: - $hash = \hash_hmac($algorithm, $msg, $key, true); - return self::constantTimeEquals($signature, $hash); - } - } - - /** - * Decode a JSON string into a PHP object. - * - * @param string $input JSON string - * - * @return object Object representation of JSON string - * - * @throws DomainException Provided string was invalid JSON - */ - public static function jsonDecode($input) - { - if (\version_compare(PHP_VERSION, '5.4.0', '>=') && !(\defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { - /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you - * to specify that large ints (like Steam Transaction IDs) should be treated as - * strings, rather than the PHP default behaviour of converting them to floats. - */ - $obj = \json_decode($input, false, 512, JSON_BIGINT_AS_STRING); - } else { - /** Not all servers will support that, however, so for older versions we must - * manually detect large ints in the JSON string and quote them (thus converting - *them to strings) before decoding, hence the preg_replace() call. - */ - $max_int_length = \strlen((string) PHP_INT_MAX) - 1; - $json_without_bigints = \preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input); - $obj = \json_decode($json_without_bigints); - } - - if ($errno = \json_last_error()) { - static::handleJsonError($errno); - } elseif ($obj === null && $input !== 'null') { - throw new DomainException('Null result with non-null input'); - } - return $obj; - } - - /** - * Encode a PHP object into a JSON string. - * - * @param object|array $input A PHP object or array - * - * @return string JSON representation of the PHP object or array - * - * @throws DomainException Provided object could not be encoded to valid JSON - */ - public static function jsonEncode($input) - { - $json = \json_encode($input); - if ($errno = \json_last_error()) { - static::handleJsonError($errno); - } elseif ($json === 'null' && $input !== null) { - throw new DomainException('Null result with non-null input'); - } - return $json; - } - - /** - * Decode a string with URL-safe Base64. - * - * @param string $input A Base64 encoded string - * - * @return string A decoded string - */ - public static function urlsafeB64Decode($input) - { - $remainder = \strlen($input) % 4; - if ($remainder) { - $padlen = 4 - $remainder; - $input .= \str_repeat('=', $padlen); - } - return \base64_decode(\strtr($input, '-_', '+/')); - } - - /** - * Encode a string with URL-safe Base64. - * - * @param string $input The string you want encoded - * - * @return string The base64 encode of what you passed in - */ - public static function urlsafeB64Encode($input) - { - return \str_replace('=', '', \strtr(\base64_encode($input), '+/', '-_')); - } - - - /** - * Determine if an algorithm has been provided for each Key - * - * @param Key|array|mixed $keyOrKeyArray - * @param string|null $kid - * - * @throws UnexpectedValueException - * - * @return array containing the keyMaterial and algorithm - */ - private static function getKeyMaterialAndAlgorithm($keyOrKeyArray, $kid = null) - { - if ( - is_string($keyOrKeyArray) - || is_resource($keyOrKeyArray) - || $keyOrKeyArray instanceof OpenSSLAsymmetricKey - ) { - return array($keyOrKeyArray, null); - } - - if ($keyOrKeyArray instanceof Key) { - return array($keyOrKeyArray->getKeyMaterial(), $keyOrKeyArray->getAlgorithm()); - } - - if (is_array($keyOrKeyArray) || $keyOrKeyArray instanceof ArrayAccess) { - if (!isset($kid)) { - throw new UnexpectedValueException('"kid" empty, unable to lookup correct key'); - } - if (!isset($keyOrKeyArray[$kid])) { - throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key'); - } - - $key = $keyOrKeyArray[$kid]; - - if ($key instanceof Key) { - return array($key->getKeyMaterial(), $key->getAlgorithm()); - } - - return array($key, null); - } - - throw new UnexpectedValueException( - '$keyOrKeyArray must be a string|resource key, an array of string|resource keys, ' - . 'an instance of Firebase\JWT\Key key or an array of Firebase\JWT\Key keys' - ); - } - - /** - * @param string $left - * @param string $right - * @return bool - */ - public static function constantTimeEquals($left, $right) - { - if (\function_exists('hash_equals')) { - return \hash_equals($left, $right); - } - $len = \min(static::safeStrlen($left), static::safeStrlen($right)); - - $status = 0; - for ($i = 0; $i < $len; $i++) { - $status |= (\ord($left[$i]) ^ \ord($right[$i])); - } - $status |= (static::safeStrlen($left) ^ static::safeStrlen($right)); - - return ($status === 0); - } - - /** - * Helper method to create a JSON error. - * - * @param int $errno An error number from json_last_error() - * - * @return void - */ - private static function handleJsonError($errno) - { - $messages = array( - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3 - ); - throw new DomainException( - isset($messages[$errno]) - ? $messages[$errno] - : 'Unknown JSON error: ' . $errno - ); - } - - /** - * Get the number of bytes in cryptographic strings. - * - * @param string $str - * - * @return int - */ - private static function safeStrlen($str) - { - if (\function_exists('mb_strlen')) { - return \mb_strlen($str, '8bit'); - } - return \strlen($str); - } - - /** - * Convert an ECDSA signature to an ASN.1 DER sequence - * - * @param string $sig The ECDSA signature to convert - * @return string The encoded DER object - */ - private static function signatureToDER($sig) - { - // Separate the signature into r-value and s-value - list($r, $s) = \str_split($sig, (int) (\strlen($sig) / 2)); - - // Trim leading zeros - $r = \ltrim($r, "\x00"); - $s = \ltrim($s, "\x00"); - - // Convert r-value and s-value from unsigned big-endian integers to - // signed two's complement - if (\ord($r[0]) > 0x7f) { - $r = "\x00" . $r; - } - if (\ord($s[0]) > 0x7f) { - $s = "\x00" . $s; - } - - return self::encodeDER( - self::ASN1_SEQUENCE, - self::encodeDER(self::ASN1_INTEGER, $r) . - self::encodeDER(self::ASN1_INTEGER, $s) - ); - } - - /** - * Encodes a value into a DER object. - * - * @param int $type DER tag - * @param string $value the value to encode - * @return string the encoded object - */ - private static function encodeDER($type, $value) - { - $tag_header = 0; - if ($type === self::ASN1_SEQUENCE) { - $tag_header |= 0x20; - } - - // Type - $der = \chr($tag_header | $type); - - // Length - $der .= \chr(\strlen($value)); - - return $der . $value; - } - - /** - * Encodes signature from a DER object. - * - * @param string $der binary signature in DER format - * @param int $keySize the number of bits in the key - * @return string the signature - */ - private static function signatureFromDER($der, $keySize) - { - // OpenSSL returns the ECDSA signatures as a binary ASN.1 DER SEQUENCE - list($offset, $_) = self::readDER($der); - list($offset, $r) = self::readDER($der, $offset); - list($offset, $s) = self::readDER($der, $offset); - - // Convert r-value and s-value from signed two's compliment to unsigned - // big-endian integers - $r = \ltrim($r, "\x00"); - $s = \ltrim($s, "\x00"); - - // Pad out r and s so that they are $keySize bits long - $r = \str_pad($r, $keySize / 8, "\x00", STR_PAD_LEFT); - $s = \str_pad($s, $keySize / 8, "\x00", STR_PAD_LEFT); - - return $r . $s; - } - - /** - * Reads binary DER-encoded data and decodes into a single object - * - * @param string $der the binary data in DER format - * @param int $offset the offset of the data stream containing the object - * to decode - * @return array [$offset, $data] the new offset and the decoded object - */ - private static function readDER($der, $offset = 0) - { - $pos = $offset; - $size = \strlen($der); - $constructed = (\ord($der[$pos]) >> 5) & 0x01; - $type = \ord($der[$pos++]) & 0x1f; - - // Length - $len = \ord($der[$pos++]); - if ($len & 0x80) { - $n = $len & 0x1f; - $len = 0; - while ($n-- && $pos < $size) { - $len = ($len << 8) | \ord($der[$pos++]); - } - } - - // Value - if ($type == self::ASN1_BIT_STRING) { - $pos++; // Skip the first contents octet (padding indicator) - $data = \substr($der, $pos, $len - 1); - $pos += $len - 1; - } elseif (!$constructed) { - $data = \substr($der, $pos, $len); - $pos += $len; - } else { - $data = null; - } - - return array($pos, $data); - } -} diff --git a/vendor/firebase/php-jwt/src/Key.php b/vendor/firebase/php-jwt/src/Key.php deleted file mode 100644 index f1ede6f..0000000 --- a/vendor/firebase/php-jwt/src/Key.php +++ /dev/null @@ -1,59 +0,0 @@ -keyMaterial = $keyMaterial; - $this->algorithm = $algorithm; - } - - /** - * Return the algorithm valid for this key - * - * @return string - */ - public function getAlgorithm() - { - return $this->algorithm; - } - - /** - * @return string|resource|OpenSSLAsymmetricKey - */ - public function getKeyMaterial() - { - return $this->keyMaterial; - } -} diff --git a/vendor/firebase/php-jwt/src/SignatureInvalidException.php b/vendor/firebase/php-jwt/src/SignatureInvalidException.php deleted file mode 100644 index d35dee9..0000000 --- a/vendor/firebase/php-jwt/src/SignatureInvalidException.php +++ /dev/null @@ -1,7 +0,0 @@ -= 5.5 @@ -352,6 +561,7 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c * `GuzzleHttp\QueryParser` has been replaced with the `GuzzleHttp\Psr7\parse_query`. + ## 5.2.0 - 2015-01-27 * Added `AppliesHeadersInterface` to make applying headers to a request based @@ -362,6 +572,7 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c RingBridge. * Added a guard in the Pool class to not use recursion for request retries. + ## 5.1.0 - 2014-12-19 * Pool class no longer uses recursion when a request is intercepted. @@ -382,6 +593,7 @@ Please see [the upgrade document](UPGRADING.md) that describes all BC breaking c * Exceptions thrown in the `end` event are now correctly wrapped with Guzzle specific exceptions if necessary. + ## 5.0.3 - 2014-11-03 This change updates query strings so that they are treated as un-encoded values @@ -396,6 +608,7 @@ string that should not be parsed or encoded (unless a call to getQuery() is subsequently made, forcing the query-string to be converted into a Query object). + ## 5.0.2 - 2014-10-30 * Added a trailing `\r\n` to multipart/form-data payloads. See @@ -417,6 +630,7 @@ object). string on a URL: Now allowing many more characters to be present in the query string without being percent encoded. See https://tools.ietf.org/html/rfc3986#appendix-A + ## 5.0.1 - 2014-10-16 Bugfix release. @@ -428,6 +642,7 @@ Bugfix release. * Fixed an issue where transfer statistics were not being populated in the RingBridge. https://github.com/guzzle/guzzle/issues/866 + ## 5.0.0 - 2014-10-12 Adding support for non-blocking responses and some minor API cleanup. @@ -509,6 +724,7 @@ interfaces. argument. They now accept an associative array of options, including the "size" key and "metadata" key which can be used to provide custom metadata. + ## 4.2.2 - 2014-09-08 * Fixed a memory leak in the CurlAdapter when reusing cURL handles. diff --git a/vendor/guzzlehttp/guzzle/LICENSE b/vendor/guzzlehttp/guzzle/LICENSE index d51aa69..fd2375d 100644 --- a/vendor/guzzlehttp/guzzle/LICENSE +++ b/vendor/guzzlehttp/guzzle/LICENSE @@ -1,4 +1,12 @@ -Copyright (c) 2011 Michael Dowling, https://github.com/mtdowling +The MIT License (MIT) + +Copyright (c) 2011 Michael Dowling +Copyright (c) 2012 Jeremy Lindblom +Copyright (c) 2014 Graham Campbell +Copyright (c) 2015 Márk Sági-Kazár +Copyright (c) 2015 Tobias Schultze +Copyright (c) 2016 Tobias Nyholm +Copyright (c) 2016 George Mponos Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md index 7237170..0786462 100644 --- a/vendor/guzzlehttp/guzzle/README.md +++ b/vendor/guzzlehttp/guzzle/README.md @@ -42,9 +42,9 @@ $promise->wait(); We use GitHub issues only to discuss bugs and new features. For support please refer to: -- [Documentation](http://guzzlephp.org/) -- [Stack Overflow](http://stackoverflow.com/questions/tagged/guzzle) -- [#guzzle](https://app.slack.com/client/T0D2S9JCT/CE6UAAKL4) channel on [PHP-HTTP Slack](http://slack.httplug.io/) +- [Documentation](https://docs.guzzlephp.org) +- [Stack Overflow](https://stackoverflow.com/questions/tagged/guzzle) +- [#guzzle](https://app.slack.com/client/T0D2S9JCT/CE6UAAKL4) channel on [PHP-HTTP Slack](https://slack.httplug.io/) - [Gitter](https://gitter.im/guzzle/guzzle) @@ -60,20 +60,35 @@ composer require guzzlehttp/guzzle ## Version Guidance -| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version | -|---------|------------|---------------------|--------------|---------------------|---------------------|-------|-------------| -| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >= 5.3.3 | -| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >= 5.4 | -| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >= 5.4 | -| 6.x | Bugfixes | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >= 5.5 | -| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >= 7.2 | +| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version | +|---------|---------------------|---------------------|--------------|---------------------|---------------------|-------|--------------| +| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >=5.3.3,<7.0 | +| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >=5.4,<7.0 | +| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >=5.4,<7.4 | +| 6.x | Security fixes only | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >=5.5,<8.0 | +| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >=7.2.5,<8.3 | [guzzle-3-repo]: https://github.com/guzzle/guzzle3 [guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x [guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 [guzzle-6-repo]: https://github.com/guzzle/guzzle/tree/6.5 [guzzle-7-repo]: https://github.com/guzzle/guzzle -[guzzle-3-docs]: http://guzzle3.readthedocs.org -[guzzle-5-docs]: http://docs.guzzlephp.org/en/5.3/ -[guzzle-6-docs]: http://docs.guzzlephp.org/en/6.5/ -[guzzle-7-docs]: http://docs.guzzlephp.org/en/latest/ +[guzzle-3-docs]: https://guzzle3.readthedocs.io/ +[guzzle-5-docs]: https://docs.guzzlephp.org/en/5.3/ +[guzzle-6-docs]: https://docs.guzzlephp.org/en/6.5/ +[guzzle-7-docs]: https://docs.guzzlephp.org/en/latest/ + + +## Security + +If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information. + +## License + +Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information. + +## For Enterprise + +Available as part of the Tidelift Subscription + +The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json index 5cf87fd..3207f8c 100644 --- a/vendor/guzzlehttp/guzzle/composer.json +++ b/vendor/guzzlehttp/guzzle/composer.json @@ -1,6 +1,5 @@ { "name": "guzzlehttp/guzzle", - "type": "library", "description": "Guzzle is a PHP HTTP client library", "keywords": [ "framework", @@ -13,36 +12,62 @@ "PSR-7", "PSR-18" ], - "homepage": "http://guzzlephp.org/", "license": "MIT", "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, { "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, { "name": "Márk Sági-Kazár", "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" } ], "require": { - "php": "^7.2.5", + "php": "^7.2.5 || ^8.0", "ext-json": "*", - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.6.1", - "psr/http-client": "^1.0" + "guzzlehttp/promises": "^1.5.3 || ^2.0", + "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" }, "provide": { "psr/http-client-implementation": "1.0" }, "require-dev": { "ext-curl": "*", - "ergebnis/composer-normalize": "^2.0", - "php-http/client-integration-tests": "dev-phpunit8", - "phpunit/phpunit": "^8.5.5", - "psr/log": "^1.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23", + "psr/log": "^1.1 || ^2.0 || ^3.0" }, "suggest": { "ext-curl": "Required for CURL handler support", @@ -50,11 +75,16 @@ "psr/log": "Required for using the Log middleware" }, "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, + "preferred-install": "dist", "sort-packages": true }, "extra": { - "branch-alias": { - "dev-master": "7.0-dev" + "bamarni-bin": { + "bin-links": true, + "forward-command": false } }, "autoload": { diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizer.php b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php new file mode 100644 index 0000000..6eca94e --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizer.php @@ -0,0 +1,28 @@ +truncateAt = $truncateAt; + } + + /** + * Returns a summarized message body. + */ + public function summarize(MessageInterface $message): ?string + { + return $this->truncateAt === null + ? \GuzzleHttp\Psr7\Message::bodySummary($message) + : \GuzzleHttp\Psr7\Message::bodySummary($message, $this->truncateAt); + } +} diff --git a/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php new file mode 100644 index 0000000..3e02e03 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/BodySummarizerInterface.php @@ -0,0 +1,13 @@ +configureDefaults($config); @@ -71,6 +75,8 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface * @param array $args * * @return PromiseInterface|ResponseInterface + * + * @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0. */ public function __call($method, $args) { @@ -114,13 +120,14 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface public function send(RequestInterface $request, array $options = []): ResponseInterface { $options[RequestOptions::SYNCHRONOUS] = true; + return $this->sendAsync($request, $options)->wait(); } /** * The HttpClient PSR (PSR-18) specify this method. * - * @inheritDoc + * {@inheritDoc} */ public function sendRequest(RequestInterface $request): ResponseInterface { @@ -151,7 +158,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $body = $options['body'] ?? null; $version = $options['version'] ?? '1.1'; // Merge the URI into the base URI. - $uri = $this->buildUri(Psr7\uri_for($uri), $options); + $uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options); if (\is_array($body)) { throw $this->invalidBody(); } @@ -178,6 +185,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface public function request(string $method, $uri = '', array $options = []): ResponseInterface { $options[RequestOptions::SYNCHRONOUS] = true; + return $this->requestAsync($method, $uri, $options)->wait(); } @@ -191,18 +199,20 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface * @param string|null $option The config option to retrieve. * * @return mixed + * + * @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0. */ public function getConfig(?string $option = null) { return $option === null ? $this->config - : (isset($this->config[$option]) ? $this->config[$option] : null); + : ($this->config[$option] ?? null); } private function buildUri(UriInterface $uri, array $config): UriInterface { if (isset($config['base_uri'])) { - $uri = Psr7\UriResolver::resolve(Psr7\uri_for($config['base_uri']), $uri); + $uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri); } if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) { @@ -220,11 +230,11 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface { $defaults = [ 'allow_redirects' => RedirectMiddleware::$defaultSettings, - 'http_errors' => true, - 'decode_content' => true, - 'verify' => true, - 'cookies' => false, - 'idn_conversion' => false, + 'http_errors' => true, + 'decode_content' => true, + 'verify' => true, + 'cookies' => false, + 'idn_conversion' => false, ]; // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. @@ -320,9 +330,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $handler = $options['handler']; try { - return Promise\promise_for($handler($request, $options)); + return P\Create::promiseFor($handler($request, $options)); } catch (\Exception $e) { - return Promise\rejection_for($e); + return P\Create::rejectionFor($e); } } @@ -336,6 +346,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface ]; if (isset($options['headers'])) { + if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) { + throw new InvalidArgumentException('The headers array must have header name as keys.'); + } $modify['set_headers'] = $options['headers']; unset($options['headers']); } @@ -343,15 +356,15 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface if (isset($options['form_params'])) { if (isset($options['multipart'])) { throw new InvalidArgumentException('You cannot use ' - . 'form_params and multipart at the same time. Use the ' - . 'form_params option if you want to send application/' - . 'x-www-form-urlencoded requests, and the multipart ' - . 'option to send multipart/form-data requests.'); + .'form_params and multipart at the same time. Use the ' + .'form_params option if you want to send application/' + .'x-www-form-urlencoded requests, and the multipart ' + .'option to send multipart/form-data requests.'); } $options['body'] = \http_build_query($options['form_params'], '', '&'); unset($options['form_params']); // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; } @@ -364,7 +377,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $options['body'] = Utils::jsonEncode($options['json']); unset($options['json']); // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'application/json'; } @@ -372,7 +385,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface && $options['decode_content'] !== true ) { // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Accept-Encoding'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']); $modify['set_headers']['Accept-Encoding'] = $options['decode_content']; } @@ -380,7 +393,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface if (\is_array($options['body'])) { throw $this->invalidBody(); } - $modify['body'] = Psr7\stream_for($options['body']); + $modify['body'] = Psr7\Utils::streamFor($options['body']); unset($options['body']); } @@ -390,9 +403,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface switch ($type) { case 'basic': // Ensure that we don't have the header in different case and set the new value. - $modify['set_headers'] = Psr7\_caseless_remove(['Authorization'], $modify['set_headers']); + $modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']); $modify['set_headers']['Authorization'] = 'Basic ' - . \base64_encode("$value[0]:$value[1]"); + .\base64_encode("$value[0]:$value[1]"); break; case 'digest': // @todo: Do not rely on curl @@ -426,13 +439,17 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface } } - $request = Psr7\modify_request($request, $modify); + if (isset($options['version'])) { + $modify['version'] = $options['version']; + } + + $request = Psr7\Utils::modifyRequest($request, $modify); if ($request->getBody() instanceof Psr7\MultipartStream) { // Use a multipart/form-data POST if a Content-Type is not set. // Ensure that we don't have the header in different case and set the new value. - $options['_conditional'] = Psr7\_caseless_remove(['Content-Type'], $options['_conditional']); + $options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']); $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' - . $request->getBody()->getBoundary(); + .$request->getBody()->getBoundary(); } // Merge in conditional headers if they are not present. @@ -444,7 +461,7 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface $modify['set_headers'][$k] = $v; } } - $request = Psr7\modify_request($request, $modify); + $request = Psr7\Utils::modifyRequest($request, $modify); // Don't pass this internal value along to middleware/handlers. unset($options['_conditional']); } @@ -458,9 +475,9 @@ class Client implements ClientInterface, \Psr\Http\Client\ClientInterface private function invalidBody(): InvalidArgumentException { return new InvalidArgumentException('Passing in the "body" request ' - . 'option as an array to send a request is not supported. ' - . 'Please use the "form_params" request option to send a ' - . 'application/x-www-form-urlencoded request, or the "multipart" ' - . 'request option to send a multipart/form-data request.'); + .'option as an array to send a request is not supported. ' + .'Please use the "form_params" request option to send a ' + .'application/x-www-form-urlencoded request, or the "multipart" ' + .'request option to send a multipart/form-data request.'); } } diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php index bc0fe73..6aaee61 100644 --- a/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ b/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -16,7 +16,7 @@ interface ClientInterface /** * The Guzzle major version. */ - const MAJOR_VERSION = 7; + public const MAJOR_VERSION = 7; /** * Send an HTTP request. @@ -77,6 +77,8 @@ interface ClientInterface * @param string|null $option The config option to retrieve. * * @return mixed + * + * @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0. */ public function getConfig(?string $option = null); } diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php index d6757c6..b4ced5a 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php @@ -50,10 +50,10 @@ class CookieJar implements CookieJarInterface $cookieJar = new self(); foreach ($cookies as $name => $value) { $cookieJar->setCookie(new SetCookie([ - 'Domain' => $domain, - 'Name' => $name, - 'Value' => $value, - 'Discard' => true + 'Domain' => $domain, + 'Name' => $name, + 'Value' => $value, + 'Discard' => true, ])); } @@ -97,7 +97,7 @@ class CookieJar implements CookieJarInterface } /** - * @inheritDoc + * {@inheritDoc} */ public function toArray(): array { @@ -107,12 +107,13 @@ class CookieJar implements CookieJarInterface } /** - * @inheritDoc + * {@inheritDoc} */ public function clear(?string $domain = null, ?string $path = null, ?string $name = null): void { if (!$domain) { $this->cookies = []; + return; } elseif (!$path) { $this->cookies = \array_filter( @@ -142,7 +143,7 @@ class CookieJar implements CookieJarInterface } /** - * @inheritDoc + * {@inheritDoc} */ public function clearSessionCookies(): void { @@ -155,7 +156,7 @@ class CookieJar implements CookieJarInterface } /** - * @inheritDoc + * {@inheritDoc} */ public function setCookie(SetCookie $cookie): bool { @@ -170,15 +171,15 @@ class CookieJar implements CookieJarInterface $result = $cookie->validate(); if ($result !== true) { if ($this->strictMode) { - throw new \RuntimeException('Invalid cookie: ' . $result); + throw new \RuntimeException('Invalid cookie: '.$result); } $this->removeCookieIfEmpty($cookie); + return false; } // Resolve conflicts with previously set cookies foreach ($this->cookies as $i => $c) { - // Two cookies are identical, when their path, and domain are // identical. if ($c->getPath() != $cookie->getPath() || @@ -241,6 +242,11 @@ class CookieJar implements CookieJarInterface if (0 !== \strpos($sc->getPath(), '/')) { $sc->setPath($this->getCookiePathFromRequest($request)); } + if (!$sc->matchesDomain($request->getUri()->getHost())) { + continue; + } + // Note: At this point `$sc->getDomain()` being a public suffix should + // be rejected, but we don't want to pull in the full PSL dependency. $this->setCookie($sc); } } @@ -249,7 +255,7 @@ class CookieJar implements CookieJarInterface /** * Computes cookie path following RFC 6265 section 5.1.4 * - * @link https://tools.ietf.org/html/rfc6265#section-5.1.4 + * @see https://tools.ietf.org/html/rfc6265#section-5.1.4 */ private function getCookiePathFromRequest(RequestInterface $request): string { @@ -285,8 +291,8 @@ class CookieJar implements CookieJarInterface !$cookie->isExpired() && (!$cookie->getSecure() || $scheme === 'https') ) { - $values[] = $cookie->getName() . '=' - . $cookie->getValue(); + $values[] = $cookie->getName().'=' + .$cookie->getValue(); } } diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php index fa6d660..50bc363 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php @@ -13,7 +13,7 @@ use Psr\Http\Message\ResponseInterface; * necessary. Subclasses are also responsible for storing and retrieving * cookies from a file, database, etc. * - * @link https://docs.python.org/2/library/cookielib.html Inspiration + * @see https://docs.python.org/2/library/cookielib.html Inspiration * @extends \IteratorAggregate */ interface CookieJarInterface extends \Countable, \IteratorAggregate @@ -36,10 +36,7 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate * @param RequestInterface $request Request that was sent * @param ResponseInterface $response Response that was received */ - public function extractCookies( - RequestInterface $request, - ResponseInterface $response - ): void; + public function extractCookies(RequestInterface $request, ResponseInterface $response): void; /** * Sets a cookie in the cookie jar. diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php index 5d51ca9..cb3e67c 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php @@ -71,7 +71,7 @@ class SessionCookieJar extends CookieJar $this->setCookie(new SetCookie($cookie)); } } elseif (\strlen($data)) { - throw new \RuntimeException("Invalid cookie data"); + throw new \RuntimeException('Invalid cookie data'); } } } diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php index cf278cb..d74915b 100644 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php @@ -11,15 +11,15 @@ class SetCookie * @var array */ private static $defaults = [ - 'Name' => null, - 'Value' => null, - 'Domain' => null, - 'Path' => '/', - 'Max-Age' => null, - 'Expires' => null, - 'Secure' => false, - 'Discard' => false, - 'HttpOnly' => false + 'Name' => null, + 'Value' => null, + 'Domain' => null, + 'Path' => '/', + 'Max-Age' => null, + 'Expires' => null, + 'Secure' => false, + 'Discard' => false, + 'HttpOnly' => false, ]; /** @@ -28,7 +28,7 @@ class SetCookie private $data; /** - * Create a new SetCookie object from a string + * Create a new SetCookie object from a string. * * @param string $cookie Set-Cookie header string */ @@ -39,7 +39,7 @@ class SetCookie // Explode the cookie string using a series of semicolons $pieces = \array_filter(\array_map('trim', \explode(';', $cookie))); // The name of the cookie (first kvp) must exist and include an equal sign. - if (empty($pieces[0]) || !\strpos($pieces[0], '=')) { + if (!isset($pieces[0]) || \strpos($pieces[0], '=') === false) { return new self($data); } @@ -52,13 +52,19 @@ class SetCookie : true; // Only check for non-cookies when cookies have been found - if (empty($data['Name'])) { + if (!isset($data['Name'])) { $data['Name'] = $key; $data['Value'] = $value; } else { foreach (\array_keys(self::$defaults) as $search) { if (!\strcasecmp($search, $key)) { - $data[$search] = $value; + if ($search === 'Max-Age') { + if (is_numeric($value)) { + $data[$search] = (int) $value; + } + } else { + $data[$search] = $value; + } continue 2; } } @@ -74,13 +80,49 @@ class SetCookie */ public function __construct(array $data = []) { - /** @var array|null $replaced will be null in case of replace error */ - $replaced = \array_replace(self::$defaults, $data); - if ($replaced === null) { - throw new \InvalidArgumentException('Unable to replace the default values for the Cookie.'); + $this->data = self::$defaults; + + if (isset($data['Name'])) { + $this->setName($data['Name']); + } + + if (isset($data['Value'])) { + $this->setValue($data['Value']); + } + + if (isset($data['Domain'])) { + $this->setDomain($data['Domain']); + } + + if (isset($data['Path'])) { + $this->setPath($data['Path']); + } + + if (isset($data['Max-Age'])) { + $this->setMaxAge($data['Max-Age']); + } + + if (isset($data['Expires'])) { + $this->setExpires($data['Expires']); + } + + if (isset($data['Secure'])) { + $this->setSecure($data['Secure']); + } + + if (isset($data['Discard'])) { + $this->setDiscard($data['Discard']); + } + + if (isset($data['HttpOnly'])) { + $this->setHttpOnly($data['HttpOnly']); + } + + // Set the remaining values that don't have extra validation logic + foreach (array_diff(array_keys($data), array_keys(self::$defaults)) as $key) { + $this->data[$key] = $data[$key]; } - $this->data = $replaced; // Extract the Expires value and turn it into a UNIX timestamp if needed if (!$this->getExpires() && $this->getMaxAge()) { // Calculate the Expires date @@ -92,13 +134,13 @@ class SetCookie public function __toString() { - $str = $this->data['Name'] . '=' . $this->data['Value'] . '; '; + $str = $this->data['Name'].'='.($this->data['Value'] ?? '').'; '; foreach ($this->data as $k => $v) { if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) { if ($k === 'Expires') { - $str .= 'Expires=' . \gmdate('D, d M Y H:i:s \G\M\T', $v) . '; '; + $str .= 'Expires='.\gmdate('D, d M Y H:i:s \G\M\T', $v).'; '; } else { - $str .= ($v === true ? $k : "{$k}={$v}") . '; '; + $str .= ($v === true ? $k : "{$k}={$v}").'; '; } } } @@ -112,7 +154,7 @@ class SetCookie } /** - * Get the cookie name + * Get the cookie name. * * @return string */ @@ -122,17 +164,21 @@ class SetCookie } /** - * Set the cookie name + * Set the cookie name. * * @param string $name Cookie name */ public function setName($name): void { - $this->data['Name'] = $name; + if (!is_string($name)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Name'] = (string) $name; } /** - * Get the cookie value + * Get the cookie value. * * @return string|null */ @@ -142,17 +188,21 @@ class SetCookie } /** - * Set the cookie value + * Set the cookie value. * * @param string $value Cookie value */ public function setValue($value): void { - $this->data['Value'] = $value; + if (!is_string($value)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Value'] = (string) $value; } /** - * Get the domain + * Get the domain. * * @return string|null */ @@ -162,17 +212,21 @@ class SetCookie } /** - * Set the domain of the cookie + * Set the domain of the cookie. * - * @param string $domain + * @param string|null $domain */ public function setDomain($domain): void { - $this->data['Domain'] = $domain; + if (!is_string($domain) && null !== $domain) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Domain'] = null === $domain ? null : (string) $domain; } /** - * Get the path + * Get the path. * * @return string */ @@ -182,37 +236,45 @@ class SetCookie } /** - * Set the path of the cookie + * Set the path of the cookie. * * @param string $path Path of the cookie */ public function setPath($path): void { - $this->data['Path'] = $path; + if (!is_string($path)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Path'] = (string) $path; } /** - * Maximum lifetime of the cookie in seconds + * Maximum lifetime of the cookie in seconds. * * @return int|null */ public function getMaxAge() { - return $this->data['Max-Age']; + return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age']; } /** - * Set the max-age of the cookie + * Set the max-age of the cookie. * - * @param int $maxAge Max age of the cookie in seconds + * @param int|null $maxAge Max age of the cookie in seconds */ public function setMaxAge($maxAge): void { - $this->data['Max-Age'] = $maxAge; + if (!is_int($maxAge) && null !== $maxAge) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Max-Age'] = $maxAge === null ? null : (int) $maxAge; } /** - * The UNIX timestamp when the cookie Expires + * The UNIX timestamp when the cookie Expires. * * @return string|int|null */ @@ -222,21 +284,23 @@ class SetCookie } /** - * Set the unix timestamp for which the cookie will expire + * Set the unix timestamp for which the cookie will expire. * - * @param int|string $timestamp Unix timestamp or any English textual datetime description. + * @param int|string|null $timestamp Unix timestamp or any English textual datetime description. */ public function setExpires($timestamp): void { - $this->data['Expires'] = \is_numeric($timestamp) - ? (int) $timestamp - : \strtotime($timestamp); + if (!is_int($timestamp) && !is_string($timestamp) && null !== $timestamp) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int, string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Expires'] = null === $timestamp ? null : (\is_numeric($timestamp) ? (int) $timestamp : \strtotime((string) $timestamp)); } /** - * Get whether or not this is a secure cookie + * Get whether or not this is a secure cookie. * - * @return bool|null + * @return bool */ public function getSecure() { @@ -244,17 +308,21 @@ class SetCookie } /** - * Set whether or not the cookie is secure + * Set whether or not the cookie is secure. * * @param bool $secure Set to true or false if secure */ public function setSecure($secure): void { - $this->data['Secure'] = $secure; + if (!is_bool($secure)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Secure'] = (bool) $secure; } /** - * Get whether or not this is a session cookie + * Get whether or not this is a session cookie. * * @return bool|null */ @@ -264,17 +332,21 @@ class SetCookie } /** - * Set whether or not this is a session cookie + * Set whether or not this is a session cookie. * * @param bool $discard Set to true or false if this is a session cookie */ public function setDiscard($discard): void { - $this->data['Discard'] = $discard; + if (!is_bool($discard)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['Discard'] = (bool) $discard; } /** - * Get whether or not this is an HTTP only cookie + * Get whether or not this is an HTTP only cookie. * * @return bool */ @@ -284,13 +356,17 @@ class SetCookie } /** - * Set whether or not this is an HTTP only cookie + * Set whether or not this is an HTTP only cookie. * * @param bool $httpOnly Set to true or false if this is HTTP only */ public function setHttpOnly($httpOnly): void { - $this->data['HttpOnly'] = $httpOnly; + if (!is_bool($httpOnly)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + + $this->data['HttpOnly'] = (bool) $httpOnly; } /** @@ -332,7 +408,7 @@ class SetCookie } /** - * Check if the cookie matches a domain value + * Check if the cookie matches a domain value. * * @param string $domain Domain to check against */ @@ -345,10 +421,12 @@ class SetCookie // Remove the leading '.' as per spec in RFC 6265. // https://tools.ietf.org/html/rfc6265#section-5.2.3 - $cookieDomain = \ltrim($cookieDomain, '.'); + $cookieDomain = \ltrim(\strtolower($cookieDomain), '.'); + + $domain = \strtolower($domain); // Domain not set or exact match. - if (!$cookieDomain || !\strcasecmp($domain, $cookieDomain)) { + if ('' === $cookieDomain || $domain === $cookieDomain) { return true; } @@ -358,11 +436,11 @@ class SetCookie return false; } - return (bool) \preg_match('/\.' . \preg_quote($cookieDomain, '/') . '$/', $domain); + return (bool) \preg_match('/\.'.\preg_quote($cookieDomain, '/').'$/', $domain); } /** - * Check if the cookie is expired + * Check if the cookie is expired. */ public function isExpired(): bool { @@ -370,15 +448,14 @@ class SetCookie } /** - * Check if the cookie is valid according to RFC 6265 + * Check if the cookie is valid according to RFC 6265. * * @return bool|string Returns true if valid or an error message if invalid */ public function validate() { - // Names must not be empty, but can be 0 $name = $this->getName(); - if (empty($name) && !\is_numeric($name)) { + if ($name === '') { return 'The cookie name must not be empty'; } @@ -388,21 +465,21 @@ class SetCookie $name )) { return 'Cookie name must not contain invalid characters: ASCII ' - . 'Control characters (0-31;127), space, tab and the ' - . 'following characters: ()<>@,;:\"/?={}'; + .'Control characters (0-31;127), space, tab and the ' + .'following characters: ()<>@,;:\"/?={}'; } - // Value must not be empty, but can be 0 + // Value must not be null. 0 and empty string are valid. Empty strings + // are technically against RFC 6265, but known to happen in the wild. $value = $this->getValue(); - if (empty($value) && !\is_numeric($value)) { + if ($value === null) { return 'The cookie value must not be empty'; } - // Domains must not be empty, but can be 0 - // A "0" is not a valid internet domain, but may be used as server name - // in a private network. + // Domains must not be empty, but can be 0. "0" is not a valid internet + // domain, but may be used as server name in a private network. $domain = $this->getDomain(); - if (empty($domain) && !\is_numeric($domain)) { + if ($domain === null || $domain === '') { return 'The cookie domain must not be empty'; } diff --git a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php index 315fa37..c2d0a9c 100644 --- a/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php +++ b/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php @@ -2,6 +2,8 @@ namespace GuzzleHttp\Exception; +use GuzzleHttp\BodySummarizer; +use GuzzleHttp\BodySummarizerInterface; use Psr\Http\Client\RequestExceptionInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -47,24 +49,24 @@ class RequestException extends TransferException implements RequestExceptionInte */ public static function wrapException(RequestInterface $request, \Throwable $e): RequestException { - return $e instanceof RequestException - ? $e - : new RequestException($e->getMessage(), $request, null, $e); + return $e instanceof RequestException ? $e : new RequestException($e->getMessage(), $request, null, $e); } /** * Factory method to create a new exception with a normalized error message * - * @param RequestInterface $request Request - * @param ResponseInterface $response Response received - * @param \Throwable $previous Previous exception - * @param array $ctx Optional handler context. + * @param RequestInterface $request Request sent + * @param ResponseInterface $response Response received + * @param \Throwable|null $previous Previous exception + * @param array $handlerContext Optional handler context + * @param BodySummarizerInterface|null $bodySummarizer Optional body summarizer */ public static function create( RequestInterface $request, ResponseInterface $response = null, \Throwable $previous = null, - array $ctx = [] + array $handlerContext = [], + BodySummarizerInterface $bodySummarizer = null ): self { if (!$response) { return new self( @@ -72,7 +74,7 @@ class RequestException extends TransferException implements RequestExceptionInte $request, null, $previous, - $ctx + $handlerContext ); } @@ -97,18 +99,18 @@ class RequestException extends TransferException implements RequestExceptionInte '%s: `%s %s` resulted in a `%s %s` response', $label, $request->getMethod(), - $uri, + $uri->__toString(), $response->getStatusCode(), $response->getReasonPhrase() ); - $summary = \GuzzleHttp\Psr7\get_message_body_summary($response); + $summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response); if ($summary !== null) { $message .= ":\n{$summary}\n"; } - return new $className($message, $request, $response, $previous, $ctx); + return new $className($message, $request, $response, $previous, $handlerContext); } /** diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php index d236865..3a6a8db 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php @@ -4,9 +4,9 @@ namespace GuzzleHttp\Handler; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\PromiseInterface; -use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\LazyOpenStream; use GuzzleHttp\TransferStats; use GuzzleHttp\Utils; @@ -14,14 +14,20 @@ use Psr\Http\Message\RequestInterface; /** * Creates curl resources from a request + * + * @final */ class CurlFactory implements CurlFactoryInterface { public const CURL_VERSION_STR = 'curl_version'; + + /** + * @deprecated + */ public const LOW_CURL_VERSION_NUMBER = '7.21.2'; /** - * @var resource[] + * @var resource[]|\CurlHandle[] */ private $handles = []; @@ -45,7 +51,7 @@ class CurlFactory implements CurlFactoryInterface unset($options['curl']['body_as_string']); } - $easy = new EasyHandle; + $easy = new EasyHandle(); $easy->request = $request; $easy->options = $options; $conf = $this->getDefaultConf($easy); @@ -60,9 +66,7 @@ class CurlFactory implements CurlFactoryInterface } $conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy); - $easy->handle = $this->handles - ? \array_pop($this->handles) - : \curl_init(); + $easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init(); curl_setopt_array($easy->handle, $conf); return $easy; @@ -96,11 +100,8 @@ class CurlFactory implements CurlFactoryInterface * @param callable(RequestInterface, array): PromiseInterface $handler * @param CurlFactoryInterface $factory Dictates how the handle is released */ - public static function finish( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ): PromiseInterface { + public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { if (isset($easy->options['on_stats'])) { self::invokeStats($easy); } @@ -132,17 +133,14 @@ class CurlFactory implements CurlFactoryInterface $easy->errno, $curlStats ); - \call_user_func($easy->options['on_stats'], $stats); + ($easy->options['on_stats'])($stats); } /** * @param callable(RequestInterface, array): PromiseInterface $handler */ - private static function finishError( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ): PromiseInterface { + private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface + { // Get error information and release the handle to the factory. $ctx = [ 'errno' => $easy->errno, @@ -153,9 +151,7 @@ class CurlFactory implements CurlFactoryInterface $factory->release($easy); // Retry when nothing is present or when curl failed to rewind. - if (empty($easy->options['_err_message']) - && (!$easy->errno || $easy->errno == 65) - ) { + if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) { return self::retryFailedRewind($handler, $easy, $ctx); } @@ -165,17 +161,29 @@ class CurlFactory implements CurlFactoryInterface private static function createRejection(EasyHandle $easy, array $ctx): PromiseInterface { static $connectionErrors = [ - \CURLE_OPERATION_TIMEOUTED => true, + \CURLE_OPERATION_TIMEOUTED => true, \CURLE_COULDNT_RESOLVE_HOST => true, - \CURLE_COULDNT_CONNECT => true, - \CURLE_SSL_CONNECT_ERROR => true, - \CURLE_GOT_NOTHING => true, + \CURLE_COULDNT_CONNECT => true, + \CURLE_SSL_CONNECT_ERROR => true, + \CURLE_GOT_NOTHING => true, ]; + if ($easy->createResponseException) { + return P\Create::rejectionFor( + new RequestException( + 'An error was encountered while creating the response', + $easy->request, + $easy->response, + $easy->createResponseException, + $ctx + ) + ); + } + // If an exception was encountered during the onHeaders event, then // return a rejected promise that wraps that exception. if ($easy->onHeadersException) { - return \GuzzleHttp\Promise\rejection_for( + return P\Create::rejectionFor( new RequestException( 'An error was encountered during the on_headers event', $easy->request, @@ -185,21 +193,16 @@ class CurlFactory implements CurlFactoryInterface ) ); } - if (\version_compare($ctx[self::CURL_VERSION_STR], self::LOW_CURL_VERSION_NUMBER)) { - $message = \sprintf( - 'cURL error %s: %s (%s)', - $ctx['errno'], - $ctx['error'], - 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html' - ); - } else { - $message = \sprintf( - 'cURL error %s: %s (%s) for %s', - $ctx['errno'], - $ctx['error'], - 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html', - $easy->request->getUri() - ); + + $message = \sprintf( + 'cURL error %s: %s (%s)', + $ctx['errno'], + $ctx['error'], + 'see https://curl.haxx.se/libcurl/c/libcurl-errors.html' + ); + $uriString = (string) $easy->request->getUri(); + if ($uriString !== '' && false === \strpos($ctx['error'], $uriString)) { + $message .= \sprintf(' for %s', $uriString); } // Create a connection exception if it was a specific error code. @@ -207,7 +210,7 @@ class CurlFactory implements CurlFactoryInterface ? new ConnectException($message, $easy->request, null, $ctx) : new RequestException($message, $easy->request, $easy->response, null, $ctx); - return \GuzzleHttp\Promise\rejection_for($error); + return P\Create::rejectionFor($error); } /** @@ -216,12 +219,12 @@ class CurlFactory implements CurlFactoryInterface private function getDefaultConf(EasyHandle $easy): array { $conf = [ - '_headers' => $easy->request->getHeaders(), - \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), - \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), + '_headers' => $easy->request->getHeaders(), + \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), + \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => false, - \CURLOPT_HEADER => false, - \CURLOPT_CONNECTTIMEOUT => 150, + \CURLOPT_HEADER => false, + \CURLOPT_CONNECTTIMEOUT => 300, ]; if (\defined('CURLOPT_PROTOCOLS')) { @@ -247,6 +250,7 @@ class CurlFactory implements CurlFactoryInterface if ($size === null || $size > 0) { $this->applyBody($easy->request, $easy->options, $conf); + return; } @@ -275,9 +279,7 @@ class CurlFactory implements CurlFactoryInterface // Send the body as a string if the size is less than 1MB OR if the // [curl][body_as_string] request value is set. - if (($size !== null && $size < 1000000) || - !empty($options['_body_as_string']) - ) { + if (($size !== null && $size < 1000000) || !empty($options['_body_as_string'])) { $conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody(); // Don't duplicate the Content-Length header $this->removeHeader('Content-Length', $conf); @@ -340,6 +342,7 @@ class CurlFactory implements CurlFactoryInterface foreach (\array_keys($options['_headers']) as $key) { if (!\strcasecmp($key, $name)) { unset($options['_headers'][$key]); + return; } } @@ -359,9 +362,7 @@ class CurlFactory implements CurlFactoryInterface if (\is_string($options['verify'])) { // Throw an error if the file/folder/link path is not valid or doesn't exist. if (!\file_exists($options['verify'])) { - throw new \InvalidArgumentException( - "SSL CA bundle not found: {$options['verify']}" - ); + throw new \InvalidArgumentException("SSL CA bundle not found: {$options['verify']}"); } // If it's a directory or a link to a directory use CURLOPT_CAPATH. // If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO. @@ -381,40 +382,38 @@ class CurlFactory implements CurlFactoryInterface } } - if (!empty($options['decode_content'])) { + if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) { $accept = $easy->request->getHeaderLine('Accept-Encoding'); if ($accept) { $conf[\CURLOPT_ENCODING] = $accept; } else { + // The empty string enables all available decoders and implicitly + // sets a matching 'Accept-Encoding' header. $conf[\CURLOPT_ENCODING] = ''; - // Don't let curl send the header over the wire + // But as the user did not specify any acceptable encodings we need + // to overwrite this implicit header with an empty one. $conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; } } - if (isset($options['sink'])) { - $sink = $options['sink']; - if (!\is_string($sink)) { - $sink = \GuzzleHttp\Psr7\stream_for($sink); - } elseif (!\is_dir(\dirname($sink))) { - // Ensure that the directory exists before failing in curl. - throw new \RuntimeException(\sprintf( - 'Directory %s does not exist for sink value of %s', - \dirname($sink), - $sink - )); - } else { - $sink = new LazyOpenStream($sink, 'w+'); - } - $easy->sink = $sink; - $conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int { - return $sink->write($write); - }; - } else { + if (!isset($options['sink'])) { // Use a default temp stream if no sink was set. - $conf[\CURLOPT_FILE] = \fopen('php://temp', 'w+'); - $easy->sink = Psr7\stream_for($conf[\CURLOPT_FILE]); + $options['sink'] = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+'); } + $sink = $options['sink']; + if (!\is_string($sink)) { + $sink = \GuzzleHttp\Psr7\Utils::streamFor($sink); + } elseif (!\is_dir(\dirname($sink))) { + // Ensure that the directory exists before failing in curl. + throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink)); + } else { + $sink = new LazyOpenStream($sink, 'w+'); + } + $easy->sink = $sink; + $conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int { + return $sink->write($write); + }; + $timeoutRequiresNoSignal = false; if (isset($options['timeout'])) { $timeoutRequiresNoSignal |= $options['timeout'] < 1; @@ -446,15 +445,41 @@ class CurlFactory implements CurlFactoryInterface $scheme = $easy->request->getUri()->getScheme(); if (isset($options['proxy'][$scheme])) { $host = $easy->request->getUri()->getHost(); - if (!isset($options['proxy']['no']) || - !Utils::isHostInNoProxy($host, $options['proxy']['no']) - ) { + if (isset($options['proxy']['no']) && Utils::isHostInNoProxy($host, $options['proxy']['no'])) { + unset($conf[\CURLOPT_PROXY]); + } else { $conf[\CURLOPT_PROXY] = $options['proxy'][$scheme]; } } } } + if (isset($options['crypto_method'])) { + if (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) { + if (!defined('CURL_SSLVERSION_TLSv1_0')) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.0 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0; + } elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) { + if (!defined('CURL_SSLVERSION_TLSv1_1')) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.1 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1; + } elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) { + if (!defined('CURL_SSLVERSION_TLSv1_2')) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2; + } elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) { + if (!defined('CURL_SSLVERSION_TLSv1_3')) { + throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL'); + } + $conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3; + } else { + throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided'); + } + } + if (isset($options['cert'])) { $cert = $options['cert']; if (\is_array($cert)) { @@ -462,9 +487,13 @@ class CurlFactory implements CurlFactoryInterface $cert = $cert[0]; } if (!\file_exists($cert)) { - throw new \InvalidArgumentException( - "SSL certificate not found: {$cert}" - ); + throw new \InvalidArgumentException("SSL certificate not found: {$cert}"); + } + // OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files. + // see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html + $ext = pathinfo($cert, \PATHINFO_EXTENSION); + if (preg_match('#^(der|p12)$#i', $ext)) { + $conf[\CURLOPT_SSLCERTTYPE] = strtoupper($ext); } $conf[\CURLOPT_SSLCERT] = $cert; } @@ -481,9 +510,7 @@ class CurlFactory implements CurlFactoryInterface $sslKey = $sslKey ?? $options['ssl_key']; if (!\file_exists($sslKey)) { - throw new \InvalidArgumentException( - "SSL private key not found: {$sslKey}" - ); + throw new \InvalidArgumentException("SSL private key not found: {$sslKey}"); } $conf[\CURLOPT_SSLKEY] = $sslKey; } @@ -491,18 +518,11 @@ class CurlFactory implements CurlFactoryInterface if (isset($options['progress'])) { $progress = $options['progress']; if (!\is_callable($progress)) { - throw new \InvalidArgumentException( - 'progress client option must be callable' - ); + throw new \InvalidArgumentException('progress client option must be callable'); } $conf[\CURLOPT_NOPROGRESS] = false; - $conf[\CURLOPT_PROGRESSFUNCTION] = static function () use ($progress) { - $args = \func_get_args(); - // PHP 5.5 pushed the handle onto the start of the args - if (\is_resource($args[0])) { - \array_shift($args); - } - \call_user_func_array($progress, $args); + $conf[\CURLOPT_PROGRESSFUNCTION] = static function ($resource, int $downloadSize, int $downloaded, int $uploadSize, int $uploaded) use ($progress) { + $progress($downloadSize, $downloaded, $uploadSize, $uploaded); }; } @@ -523,11 +543,8 @@ class CurlFactory implements CurlFactoryInterface * * @param callable(RequestInterface, array): PromiseInterface $handler */ - private static function retryFailedRewind( - callable $handler, - EasyHandle $easy, - array $ctx - ): PromiseInterface { + private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx): PromiseInterface + { try { // Only rewind if the body has been read from. $body = $easy->request->getBody(); @@ -536,9 +553,10 @@ class CurlFactory implements CurlFactoryInterface } } catch (\RuntimeException $e) { $ctx['error'] = 'The connection unexpectedly failed without ' - . 'providing an error. The request would have been retried, ' - . 'but attempting to rewind the request body failed. ' - . 'Exception: ' . $e; + .'providing an error. The request would have been retried, ' + .'but attempting to rewind the request body failed. ' + .'Exception: '.$e; + return self::createRejection($easy, $ctx); } @@ -547,14 +565,15 @@ class CurlFactory implements CurlFactoryInterface $easy->options['_curl_retries'] = 1; } elseif ($easy->options['_curl_retries'] == 2) { $ctx['error'] = 'The cURL request was retried 3 times ' - . 'and did not succeed. The most likely reason for the failure ' - . 'is that cURL was unable to rewind the body of the request ' - . 'and subsequent retries resulted in the same error. Turn on ' - . 'the debug option to see what went wrong. See ' - . 'https://bugs.php.net/bug.php?id=47204 for more information.'; + .'and did not succeed. The most likely reason for the failure ' + .'is that cURL was unable to rewind the body of the request ' + .'and subsequent retries resulted in the same error. Turn on ' + .'the debug option to see what went wrong. See ' + .'https://bugs.php.net/bug.php?id=47204 for more information.'; + return self::createRejection($easy, $ctx); } else { - $easy->options['_curl_retries']++; + ++$easy->options['_curl_retries']; } return $handler($easy->request, $easy->options); @@ -580,7 +599,13 @@ class CurlFactory implements CurlFactoryInterface $value = \trim($h); if ($value === '') { $startingResponse = true; - $easy->createResponse(); + try { + $easy->createResponse(); + } catch (\Exception $e) { + $easy->createResponseException = $e; + + return -1; + } if ($onHeaders !== null) { try { $onHeaders($easy->response); @@ -588,6 +613,7 @@ class CurlFactory implements CurlFactoryInterface // Associate the exception with the handle and trigger // a curl header write error by returning 0. $easy->onHeadersException = $e; + return -1; } } @@ -597,6 +623,7 @@ class CurlFactory implements CurlFactoryInterface } else { $easy->headers[] = $value; } + return \strlen($h); }; } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php index 55bba70..9ad10a9 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php @@ -11,6 +11,8 @@ use Psr\Http\Message\RequestInterface; * When using the CurlHandler, custom curl options can be specified as an * associative array of curl option constants mapping to values in the * **curl** key of the "client" key of the request. + * + * @final */ class CurlHandler { @@ -22,9 +24,9 @@ class CurlHandler /** * Accepts an associative array of options: * - * - factory: Optional curl factory used to create cURL handles. + * - handle_factory: Optional curl factory used to create cURL handles. * - * @param array $options Array of options to use with the handler + * @param array{handle_factory?: ?CurlFactoryInterface} $options Array of options to use with the handler */ public function __construct(array $options = []) { diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php index a996d70..f0acde1 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php @@ -15,8 +15,11 @@ use Psr\Http\Message\RequestInterface; * associative array of curl option constants mapping to values in the * **curl** key of the provided request options. * - * @property resource $_mh Internal use only. Lazy loaded multi-handle. + * @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle. + * + * @final */ +#[\AllowDynamicProperties] class CurlMultiHandler { /** @@ -30,9 +33,9 @@ class CurlMultiHandler private $selectTimeout; /** - * @var resource|null the currently executing resource in `curl_multi_exec`. + * @var int Will be higher than 0 when `curl_multi_exec` is still running. */ - private $active; + private $active = 0; /** * @var array Request entry handles, indexed by handle id in `addRequest`. @@ -69,6 +72,7 @@ class CurlMultiHandler if (isset($options['select_timeout'])) { $this->selectTimeout = $options['select_timeout']; } elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) { + @trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.', \E_USER_DEPRECATED); $this->selectTimeout = (int) $selectTimeout; } else { $this->selectTimeout = 1; @@ -80,7 +84,7 @@ class CurlMultiHandler /** * @param string $name * - * @return resource + * @return resource|\CurlMultiHandle * * @throws \BadMethodCallException when another field as `_mh` will be gotten * @throws \RuntimeException when curl can not initialize a multi handle @@ -152,17 +156,16 @@ class CurlMultiHandler } // Step through the task queue which may add additional requests. - P\queue()->run(); + P\Utils::queue()->run(); - if ($this->active && - \curl_multi_select($this->_mh, $this->selectTimeout) === -1 - ) { + if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) { // Perform a usleep if a select returns -1. // See: https://bugs.php.net/bug.php?id=61141 \usleep(250); } - while (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM); + while (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM) { + } $this->processMessages(); } @@ -172,7 +175,7 @@ class CurlMultiHandler */ public function execute(): void { - $queue = P\queue(); + $queue = P\Utils::queue(); while ($this->handles || !$queue->isEmpty()) { // If there are no transfers, then sleep for the next delay @@ -204,6 +207,10 @@ class CurlMultiHandler */ private function cancel($id): bool { + if (!is_int($id)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + // Cannot cancel if it has been processed. if (!isset($this->handles[$id])) { return false; @@ -220,6 +227,10 @@ class CurlMultiHandler private function processMessages(): void { while ($done = \curl_multi_info_read($this->_mh)) { + if ($done['msg'] !== \CURLMSG_DONE) { + // if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216 + continue; + } $id = (int) $done['handle']; \curl_multi_remove_handle($this->_mh, $done['handle']); @@ -232,11 +243,7 @@ class CurlMultiHandler unset($this->handles[$id], $this->delays[$id]); $entry['easy']->errno = $done['result']; $entry['deferred']->resolve( - CurlFactory::finish( - $this, - $entry['easy'], - $this->factory - ) + CurlFactory::finish($this, $entry['easy'], $this->factory) ); } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php index 183476e..1bc39f4 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php @@ -16,7 +16,7 @@ use Psr\Http\Message\StreamInterface; final class EasyHandle { /** - * @var resource cURL resource + * @var resource|\CurlHandle cURL resource */ public $handle; @@ -55,31 +55,28 @@ final class EasyHandle */ public $onHeadersException; + /** + * @var \Exception|null Exception during createResponse (if any) + */ + public $createResponseException; + /** * Attach a response to the easy handle based on the received headers. * - * @throws \RuntimeException if no headers have been received. + * @throws \RuntimeException if no headers have been received or the first + * header line is invalid. */ public function createResponse(): void { - if (empty($this->headers)) { - throw new \RuntimeException('No headers have been received'); - } + [$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($this->headers); - // HTTP-version SP status-code SP reason-phrase - $startLine = \explode(' ', \array_shift($this->headers), 3); - $headers = Utils::headersFromLines($this->headers); $normalizedKeys = Utils::normalizeHeaderKeys($headers); - if (!empty($this->options['decode_content']) - && isset($normalizedKeys['content-encoding']) - ) { - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; + if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding'])) { + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; unset($headers[$normalizedKeys['content-encoding']]); if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; $bodyLength = (int) $this->sink->getSize(); if ($bodyLength) { @@ -90,15 +87,13 @@ final class EasyHandle } } - $statusCode = (int) $startLine[1]; - // Attach a response to the easy handle with the parsed headers. $this->response = new Response( - $statusCode, + $status, $headers, $this->sink, - \substr($startLine[0], 5), - isset($startLine[2]) ? (string) $startLine[2] : null + $ver, + $reason ); } @@ -111,9 +106,7 @@ final class EasyHandle */ public function __get($name) { - $msg = $name === 'handle' - ? 'The EasyHandle has been released' - : 'Invalid property: ' . $name; + $msg = $name === 'handle' ? 'The EasyHandle has been released' : 'Invalid property: '.$name; throw new \BadMethodCallException($msg); } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php new file mode 100644 index 0000000..5554b8f --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/Handler/HeaderProcessor.php @@ -0,0 +1,42 @@ +onFulfilled = $onFulfilled; $this->onRejected = $onRejected; if ($queue) { - \call_user_func_array([$this, 'append'], $queue); + // array_values included for BC + $this->append(...array_values($queue)); } } @@ -86,7 +84,7 @@ class MockHandler implements \Countable } if (isset($options['delay']) && \is_numeric($options['delay'])) { - \usleep($options['delay'] * 1000); + \usleep((int) $options['delay'] * 1000); } $this->lastRequest = $request; @@ -106,18 +104,18 @@ class MockHandler implements \Countable } if (\is_callable($response)) { - $response = \call_user_func($response, $request, $options); + $response = $response($request, $options); } $response = $response instanceof \Throwable - ? \GuzzleHttp\Promise\rejection_for($response) - : \GuzzleHttp\Promise\promise_for($response); + ? P\Create::rejectionFor($response) + : P\Create::promiseFor($response); return $response->then( function (?ResponseInterface $value) use ($request, $options) { $this->invokeStats($request, $options, $value); if ($this->onFulfilled) { - \call_user_func($this->onFulfilled, $value); + ($this->onFulfilled)($value); } if ($value !== null && isset($options['sink'])) { @@ -138,9 +136,10 @@ class MockHandler implements \Countable function ($reason) use ($request, $options) { $this->invokeStats($request, $options, null, $reason); if ($this->onRejected) { - \call_user_func($this->onRejected, $reason); + ($this->onRejected)($reason); } - return \GuzzleHttp\Promise\rejection_for($reason); + + return P\Create::rejectionFor($reason); } ); } @@ -161,7 +160,7 @@ class MockHandler implements \Countable ) { $this->queue[] = $value; } else { - throw new \TypeError('Expected a Response, Promise, Throwable or callable. Found ' . Utils::describeType($value)); + throw new \TypeError('Expected a Response, Promise, Throwable or callable. Found '.Utils::describeType($value)); } } } @@ -207,7 +206,7 @@ class MockHandler implements \Countable if (isset($options['on_stats'])) { $transferTime = $options['transfer_time'] ?? 0; $stats = new TransferStats($request, $response, $transferTime, $reason); - \call_user_func($options['on_stats'], $stats); + ($options['on_stats'])($stats); } } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php index c027b7f..f045b52 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php @@ -8,6 +8,8 @@ use Psr\Http\Message\RequestInterface; /** * Provides basic proxies for handlers. + * + * @final */ class Proxy { @@ -20,14 +22,10 @@ class Proxy * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. */ - public static function wrapSync( - callable $default, - callable $sync - ): callable { + public static function wrapSync(callable $default, callable $sync): callable + { return static function (RequestInterface $request, array $options) use ($default, $sync): PromiseInterface { - return empty($options[RequestOptions::SYNCHRONOUS]) - ? $default($request, $options) - : $sync($request, $options); + return empty($options[RequestOptions::SYNCHRONOUS]) ? $default($request, $options) : $sync($request, $options); }; } @@ -44,14 +42,10 @@ class Proxy * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler. */ - public static function wrapStreaming( - callable $default, - callable $streaming - ): callable { + public static function wrapStreaming(callable $default, callable $streaming): callable + { return static function (RequestInterface $request, array $options) use ($default, $streaming): PromiseInterface { - return empty($options['stream']) - ? $default($request, $options) - : $streaming($request, $options); + return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options); }; } } diff --git a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index 9d45b62..61632f5 100644 --- a/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -4,6 +4,7 @@ namespace GuzzleHttp\Handler; use GuzzleHttp\Exception\ConnectException; use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\FulfilledPromise; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7; @@ -16,6 +17,8 @@ use Psr\Http\Message\UriInterface; /** * HTTP handler that uses PHP's HTTP stream wrapper. + * + * @final */ class StreamHandler { @@ -64,7 +67,7 @@ class StreamHandler if (false !== \strpos($message, 'getaddrinfo') // DNS lookup failed || false !== \strpos($message, 'Connection refused') || false !== \strpos($message, "couldn't connect to host") // error on HHVM - || false !== \strpos($message, "connection attempt failed") + || false !== \strpos($message, 'connection attempt failed') ) { $e = new ConnectException($e->getMessage(), $request, $e); } else { @@ -72,7 +75,7 @@ class StreamHandler } $this->invokeStats($options, $request, $startTime, null, $e); - return \GuzzleHttp\Promise\rejection_for($e); + return P\Create::rejectionFor($e); } } @@ -84,61 +87,57 @@ class StreamHandler \Throwable $error = null ): void { if (isset($options['on_stats'])) { - $stats = new TransferStats( - $request, - $response, - Utils::currentTime() - $startTime, - $error, - [] - ); - \call_user_func($options['on_stats'], $stats); + $stats = new TransferStats($request, $response, Utils::currentTime() - $startTime, $error, []); + ($options['on_stats'])($stats); } } /** * @param resource $stream */ - private function createResponse( - RequestInterface $request, - array $options, - $stream, - ?float $startTime - ): PromiseInterface { + private function createResponse(RequestInterface $request, array $options, $stream, ?float $startTime): PromiseInterface + { $hdrs = $this->lastHeaders; $this->lastHeaders = []; - $parts = \explode(' ', \array_shift($hdrs), 3); - $ver = \explode('/', $parts[0])[1]; - $status = (int) $parts[1]; - $reason = $parts[2] ?? null; - $headers = Utils::headersFromLines($hdrs); + + try { + [$ver, $status, $reason, $headers] = HeaderProcessor::parseHeaders($hdrs); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } + [$stream, $headers] = $this->checkDecode($options, $headers, $stream); - $stream = Psr7\stream_for($stream); + $stream = Psr7\Utils::streamFor($stream); $sink = $stream; if (\strcasecmp('HEAD', $request->getMethod())) { $sink = $this->createSink($stream, $options); } - $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); + try { + $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); + } catch (\Exception $e) { + return P\Create::rejectionFor( + new RequestException('An error was encountered while creating the response', $request, null, $e) + ); + } if (isset($options['on_headers'])) { try { $options['on_headers']($response); } catch (\Exception $e) { - $msg = 'An error was encountered during the on_headers event'; - $ex = new RequestException($msg, $request, $response, $e); - return \GuzzleHttp\Promise\rejection_for($ex); + return P\Create::rejectionFor( + new RequestException('An error was encountered during the on_headers event', $request, $response, $e) + ); } } // Do not drain when the request is a HEAD request because they have // no body. if ($sink !== $stream) { - $this->drain( - $stream, - $sink, - $response->getHeaderLine('Content-Length') - ); + $this->drain($stream, $sink, $response->getHeaderLine('Content-Length')); } $this->invokeStats($options, $request, $startTime, $response, null); @@ -152,12 +151,9 @@ class StreamHandler return $stream; } - $sink = $options['sink'] - ?? \fopen('php://temp', 'r+'); + $sink = $options['sink'] ?? Psr7\Utils::tryFopen('php://temp', 'r+'); - return \is_string($sink) - ? new Psr7\LazyOpenStream($sink, 'w+') - : Psr7\stream_for($sink); + return \is_string($sink) ? new Psr7\LazyOpenStream($sink, 'w+') : Psr7\Utils::streamFor($sink); } /** @@ -171,18 +167,15 @@ class StreamHandler if (isset($normalizedKeys['content-encoding'])) { $encoding = $headers[$normalizedKeys['content-encoding']]; if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') { - $stream = new Psr7\InflateStream( - Psr7\stream_for($stream) - ); - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; + $stream = new Psr7\InflateStream(Psr7\Utils::streamFor($stream)); + $headers['x-encoded-content-encoding'] = $headers[$normalizedKeys['content-encoding']]; + // Remove content-encoding header unset($headers[$normalizedKeys['content-encoding']]); + // Fix content-length header if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - + $headers['x-encoded-content-length'] = $headers[$normalizedKeys['content-length']]; $length = (int) $stream->getSize(); if ($length === 0) { unset($headers[$normalizedKeys['content-length']]); @@ -205,16 +198,13 @@ class StreamHandler * * @throws \RuntimeException when the sink option is invalid. */ - private function drain( - StreamInterface $source, - StreamInterface $sink, - string $contentLength - ): StreamInterface { + private function drain(StreamInterface $source, StreamInterface $sink, string $contentLength): StreamInterface + { // If a content-length header is provided, then stop reading once // that number of bytes has been read. This can prevent infinitely // reading from a stream when dealing with servers that do not honor // Connection: Close headers. - Psr7\copy_to_stream( + Psr7\Utils::copyToStream( $source, $sink, (\strlen($contentLength) > 0 && (int) $contentLength > 0) ? (int) $contentLength : -1 @@ -241,20 +231,24 @@ class StreamHandler \set_error_handler(static function ($_, $msg, $file, $line) use (&$errors): bool { $errors[] = [ 'message' => $msg, - 'file' => $file, - 'line' => $line + 'file' => $file, + 'line' => $line, ]; + return true; }); - $resource = $callback(); - \restore_error_handler(); + try { + $resource = $callback(); + } finally { + \restore_error_handler(); + } if (!$resource) { $message = 'Error creating resource: '; foreach ($errors as $err) { foreach ($err as $key => $value) { - $message .= "[$key] $value" . \PHP_EOL; + $message .= "[$key] $value".\PHP_EOL; } } throw new \RuntimeException(\trim($message)); @@ -273,6 +267,10 @@ class StreamHandler $methods = \array_flip(\get_class_methods(__CLASS__)); } + if (!\in_array($request->getUri()->getScheme(), ['http', 'https'])) { + throw new RequestException(\sprintf("The scheme '%s' is not supported.", $request->getUri()->getScheme()), $request); + } + // HTTP/1.1 streams using the PHP stream wrapper require a // Connection: close header if ($request->getProtocolVersion() == '1.1' @@ -306,10 +304,7 @@ class StreamHandler if (!\is_array($options['stream_context'])) { throw new \InvalidArgumentException('stream_context must be an array'); } - $context = \array_replace_recursive( - $context, - $options['stream_context'] - ); + $context = \array_replace_recursive($context, $options['stream_context']); } // Microsoft NTLM authentication only supported with curl handler @@ -327,16 +322,11 @@ class StreamHandler return $this->createResource( function () use ($uri, &$http_response_header, $contextResource, $context, $options, $request) { - $resource = \fopen((string) $uri, 'r', false, $contextResource); - $this->lastHeaders = $http_response_header; + $resource = @\fopen((string) $uri, 'r', false, $contextResource); + $this->lastHeaders = $http_response_header ?? []; if (false === $resource) { - throw new ConnectException( - sprintf('Connection refused for URI %s', $uri), - $request, - null, - $context - ); + throw new ConnectException(sprintf('Connection refused for URI %s', $uri), $request, null, $context); } if (isset($options['read_timeout'])) { @@ -359,28 +349,18 @@ class StreamHandler if ('v4' === $options['force_ip_resolve']) { $records = \dns_get_record($uri->getHost(), \DNS_A); if (false === $records || !isset($records[0]['ip'])) { - throw new ConnectException( - \sprintf( - "Could not resolve IPv4 address for host '%s'", - $uri->getHost() - ), - $request - ); + throw new ConnectException(\sprintf("Could not resolve IPv4 address for host '%s'", $uri->getHost()), $request); } + return $uri->withHost($records[0]['ip']); } if ('v6' === $options['force_ip_resolve']) { $records = \dns_get_record($uri->getHost(), \DNS_AAAA); if (false === $records || !isset($records[0]['ipv6'])) { - throw new ConnectException( - \sprintf( - "Could not resolve IPv6 address for host '%s'", - $uri->getHost() - ), - $request - ); + throw new ConnectException(\sprintf("Could not resolve IPv6 address for host '%s'", $uri->getHost()), $request); } - return $uri->withHost('[' . $records[0]['ipv6'] . ']'); + + return $uri->withHost('['.$records[0]['ipv6'].']'); } } @@ -398,17 +378,20 @@ class StreamHandler $context = [ 'http' => [ - 'method' => $request->getMethod(), - 'header' => $headers, + 'method' => $request->getMethod(), + 'header' => $headers, 'protocol_version' => $request->getProtocolVersion(), - 'ignore_errors' => true, - 'follow_location' => 0, + 'ignore_errors' => true, + 'follow_location' => 0, + ], + 'ssl' => [ + 'peer_name' => $request->getUri()->getHost(), ], ]; $body = (string) $request->getBody(); - if (!empty($body)) { + if ('' !== $body) { $context['http']['content'] = $body; // Prevent the HTTP handler from adding a Content-Type header. if (!$request->hasHeader('Content-Type')) { @@ -426,21 +409,60 @@ class StreamHandler */ private function add_proxy(RequestInterface $request, array &$options, $value, array &$params): void { + $uri = null; + if (!\is_array($value)) { - $options['http']['proxy'] = $value; + $uri = $value; } else { $scheme = $request->getUri()->getScheme(); if (isset($value[$scheme])) { - if (!isset($value['no']) - || !Utils::isHostInNoProxy( - $request->getUri()->getHost(), - $value['no'] - ) - ) { - $options['http']['proxy'] = $value[$scheme]; + if (!isset($value['no']) || !Utils::isHostInNoProxy($request->getUri()->getHost(), $value['no'])) { + $uri = $value[$scheme]; } } } + + if (!$uri) { + return; + } + + $parsed = $this->parse_proxy($uri); + $options['http']['proxy'] = $parsed['proxy']; + + if ($parsed['auth']) { + if (!isset($options['http']['header'])) { + $options['http']['header'] = []; + } + $options['http']['header'] .= "\r\nProxy-Authorization: {$parsed['auth']}"; + } + } + + /** + * Parses the given proxy URL to make it compatible with the format PHP's stream context expects. + */ + private function parse_proxy(string $url): array + { + $parsed = \parse_url($url); + + if ($parsed !== false && isset($parsed['scheme']) && $parsed['scheme'] === 'http') { + if (isset($parsed['host']) && isset($parsed['port'])) { + $auth = null; + if (isset($parsed['user']) && isset($parsed['pass'])) { + $auth = \base64_encode("{$parsed['user']}:{$parsed['pass']}"); + } + + return [ + 'proxy' => "tcp://{$parsed['host']}:{$parsed['port']}", + 'auth' => $auth ? "Basic {$auth}" : null, + ]; + } + } + + // Return proxy as-is. + return [ + 'proxy' => $url, + 'auth' => null, + ]; } /** @@ -453,6 +475,25 @@ class StreamHandler } } + /** + * @param mixed $value as passed via Request transfer options. + */ + private function add_crypto_method(RequestInterface $request, array &$options, $value, array &$params): void + { + if ( + $value === \STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT + || $value === \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT + || $value === \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + || (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && $value === \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT) + ) { + $options['http']['crypto_method'] = $value; + + return; + } + + throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided'); + } + /** * @param mixed $value as passed via Request transfer options. */ @@ -501,11 +542,13 @@ class StreamHandler */ private function add_progress(RequestInterface $request, array &$options, $value, array &$params): void { - $this->addNotification( + self::addNotification( $params, static function ($code, $a, $b, $c, $transferred, $total) use ($value) { if ($code == \STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); + // The upload progress cannot be determined. Use 0 for cURL compatibility: + // https://curl.se/libcurl/c/CURLOPT_PROGRESSFUNCTION.html + $value($total, $transferred, 0, 0); } } ); @@ -521,55 +564,51 @@ class StreamHandler } static $map = [ - \STREAM_NOTIFY_CONNECT => 'CONNECT', + \STREAM_NOTIFY_CONNECT => 'CONNECT', \STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', - \STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', - \STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', - \STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', - \STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', - \STREAM_NOTIFY_PROGRESS => 'PROGRESS', - \STREAM_NOTIFY_FAILURE => 'FAILURE', - \STREAM_NOTIFY_COMPLETED => 'COMPLETED', - \STREAM_NOTIFY_RESOLVE => 'RESOLVE', + \STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', + \STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', + \STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', + \STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', + \STREAM_NOTIFY_PROGRESS => 'PROGRESS', + \STREAM_NOTIFY_FAILURE => 'FAILURE', + \STREAM_NOTIFY_COMPLETED => 'COMPLETED', + \STREAM_NOTIFY_RESOLVE => 'RESOLVE', ]; - static $args = ['severity', 'message', 'message_code', - 'bytes_transferred', 'bytes_max']; + static $args = ['severity', 'message', 'message_code', 'bytes_transferred', 'bytes_max']; $value = Utils::debugResource($value); - $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment(''); - $this->addNotification( + $ident = $request->getMethod().' '.$request->getUri()->withFragment(''); + self::addNotification( $params, - static function () use ($ident, $value, $map, $args): void { - $passed = \func_get_args(); - $code = \array_shift($passed); + static function (int $code, ...$passed) use ($ident, $value, $map, $args): void { \fprintf($value, '<%s> [%s] ', $ident, $map[$code]); foreach (\array_filter($passed) as $i => $v) { - \fwrite($value, $args[$i] . ': "' . $v . '" '); + \fwrite($value, $args[$i].': "'.$v.'" '); } \fwrite($value, "\n"); } ); } - private function addNotification(array &$params, callable $notify): void + private static function addNotification(array &$params, callable $notify): void { // Wrap the existing function if needed. if (!isset($params['notification'])) { $params['notification'] = $notify; } else { - $params['notification'] = $this->callArray([ + $params['notification'] = self::callArray([ $params['notification'], - $notify + $notify, ]); } } - private function callArray(array $functions): callable + private static function callArray(array $functions): callable { - return static function () use ($functions) { - $args = \func_get_args(); + return static function (...$args) use ($functions) { foreach ($functions as $fn) { - \call_user_func_array($fn, $args); + $fn(...$args); } }; } diff --git a/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/vendor/guzzlehttp/guzzle/src/HandlerStack.php index 13a3fa0..1ce9c4b 100644 --- a/vendor/guzzlehttp/guzzle/src/HandlerStack.php +++ b/vendor/guzzlehttp/guzzle/src/HandlerStack.php @@ -9,11 +9,13 @@ use Psr\Http\Message\ResponseInterface; /** * Creates a composed Guzzle handler function by stacking middlewares on top of * an HTTP handler function. + * + * @final */ class HandlerStack { /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $handler; @@ -23,7 +25,7 @@ class HandlerStack private $stack = []; /** - * @var null|callable(RequestInterface, array): PromiseInterface + * @var (callable(RequestInterface, array): PromiseInterface)|null */ private $cached; @@ -38,9 +40,9 @@ class HandlerStack * The returned handler stack can be passed to a client in the "handler" * option. * - * @param null|callable(RequestInterface, array): PromiseInterface $handler HTTP handler function to use with the stack. If no - * handler is provided, the best handler for your - * system will be utilized. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler HTTP handler function to use with the stack. If no + * handler is provided, the best handler for your + * system will be utilized. */ public static function create(?callable $handler = null): self { @@ -54,7 +56,7 @@ class HandlerStack } /** - * @param null|callable(RequestInterface, array): PromiseInterface $handler Underlying HTTP handler. + * @param (callable(RequestInterface, array): PromiseInterface)|null $handler Underlying HTTP handler. */ public function __construct(callable $handler = null) { @@ -84,14 +86,14 @@ class HandlerStack $stack = []; if ($this->handler !== null) { - $stack[] = "0) Handler: " . $this->debugCallable($this->handler); + $stack[] = '0) Handler: '.$this->debugCallable($this->handler); } $result = ''; foreach (\array_reverse($this->stack) as $tuple) { - $depth++; + ++$depth; $str = "{$depth}) Name: '{$tuple[1]}', "; - $str .= "Function: " . $this->debugCallable($tuple[0]); + $str .= 'Function: '.$this->debugCallable($tuple[0]); $result = "> {$str}\n{$result}"; $stack[] = $str; } @@ -120,7 +122,7 @@ class HandlerStack */ public function hasHandler(): bool { - return $this->handler !== null ; + return $this->handler !== null; } /** @@ -178,6 +180,10 @@ class HandlerStack */ public function remove($remove): void { + if (!is_string($remove) && !is_callable($remove)) { + trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a callable or string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__); + } + $this->cached = null; $idx = \is_callable($remove) ? 0 : 1; $this->stack = \array_values(\array_filter( @@ -249,7 +255,7 @@ class HandlerStack /** * Provides a debug string for a given callable. * - * @param callable $fn Function to write as a string. + * @param callable|string $fn Function to write as a string. */ private function debugCallable($fn): string { @@ -260,10 +266,10 @@ class HandlerStack if (\is_array($fn)) { return \is_string($fn[0]) ? "callable({$fn[0]}::{$fn[1]})" - : "callable(['" . \get_class($fn[0]) . "', '{$fn[1]}'])"; + : "callable(['".\get_class($fn[0])."', '{$fn[1]}'])"; } /** @var object $fn */ - return 'callable(' . \spl_object_hash($fn) . ')'; + return 'callable('.\spl_object_hash($fn).')'; } } diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php index 36e3a9c..9b77eee 100644 --- a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php @@ -32,17 +32,19 @@ use Psr\Http\Message\ResponseInterface; * - {res_headers}: Response headers * - {req_body}: Request body * - {res_body}: Response body + * + * @final */ -class MessageFormatter +class MessageFormatter implements MessageFormatterInterface { /** * Apache Common Log Format. * - * @link https://httpd.apache.org/docs/2.4/logs.html#common + * @see https://httpd.apache.org/docs/2.4/logs.html#common * * @var string */ - public const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}"; + public const CLF = '{hostname} {req_header_User-Agent} - [{date_common_log}] "{method} {target} HTTP/{version}" {code} {res_header_Content-Length}'; public const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"; public const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'; @@ -66,11 +68,8 @@ class MessageFormatter * @param ResponseInterface|null $response Response that was received * @param \Throwable|null $error Exception that was received */ - public function format( - RequestInterface $request, - ?ResponseInterface $response = null, - ?\Throwable $error = null - ): string { + public function format(RequestInterface $request, ?ResponseInterface $response = null, ?\Throwable $error = null): string + { $cache = []; /** @var string */ @@ -84,16 +83,16 @@ class MessageFormatter $result = ''; switch ($matches[1]) { case 'request': - $result = Psr7\str($request); + $result = Psr7\Message::toString($request); break; case 'response': - $result = $response ? Psr7\str($response) : ''; + $result = $response ? Psr7\Message::toString($response) : ''; break; case 'req_headers': $result = \trim($request->getMethod() - . ' ' . $request->getRequestTarget()) - . ' HTTP/' . $request->getProtocolVersion() . "\r\n" - . $this->headers($request); + .' '.$request->getRequestTarget()) + .' HTTP/'.$request->getProtocolVersion()."\r\n" + .$this->headers($request); break; case 'res_headers': $result = $response ? @@ -102,14 +101,26 @@ class MessageFormatter $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase() - ) . "\r\n" . $this->headers($response) + )."\r\n".$this->headers($response) : 'NULL'; break; case 'req_body': - $result = $request->getBody(); + $result = $request->getBody()->__toString(); break; case 'res_body': - $result = $response ? $response->getBody() : 'NULL'; + if (!$response instanceof ResponseInterface) { + $result = 'NULL'; + break; + } + + $body = $response->getBody(); + + if (!$body->isSeekable()) { + $result = 'RESPONSE_NOT_LOGGEABLE'; + break; + } + + $result = $response->getBody()->__toString(); break; case 'ts': case 'date_iso_8601': @@ -126,7 +137,7 @@ class MessageFormatter break; case 'uri': case 'url': - $result = $request->getUri(); + $result = $request->getUri()->__toString(); break; case 'target': $result = $request->getRequestTarget(); @@ -166,6 +177,7 @@ class MessageFormatter } $cache[$matches[1]] = $result; + return $result; }, $this->template @@ -179,7 +191,7 @@ class MessageFormatter { $result = ''; foreach ($message->getHeaders() as $name => $values) { - $result .= $name . ': ' . \implode(', ', $values) . "\r\n"; + $result .= $name.': '.\implode(', ', $values)."\r\n"; } return \trim($result); diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php new file mode 100644 index 0000000..a39ac24 --- /dev/null +++ b/vendor/guzzlehttp/guzzle/src/MessageFormatterInterface.php @@ -0,0 +1,18 @@ +withCookieHeader($request); + return $handler($request, $options) ->then( static function (ResponseInterface $response) use ($cookieJar, $request): ResponseInterface { $cookieJar->extractCookies($request, $response); + return $response; } ); @@ -46,24 +49,27 @@ final class Middleware /** * Middleware that throws exceptions for 4xx or 5xx responses when the - * "http_error" request option is set to true. + * "http_errors" request option is set to true. + * + * @param BodySummarizerInterface|null $bodySummarizer The body summarizer to use in exception messages. * * @return callable(callable): callable Returns a function that accepts the next handler. */ - public static function httpErrors(): callable + public static function httpErrors(BodySummarizerInterface $bodySummarizer = null): callable { - return static function (callable $handler): callable { - return static function ($request, array $options) use ($handler) { + return static function (callable $handler) use ($bodySummarizer): callable { + return static function ($request, array $options) use ($handler, $bodySummarizer) { if (empty($options['http_errors'])) { return $handler($request, $options); } + return $handler($request, $options)->then( - static function (ResponseInterface $response) use ($request) { + static function (ResponseInterface $response) use ($request, $bodySummarizer) { $code = $response->getStatusCode(); if ($code < 400) { return $response; } - throw RequestException::create($request, $response); + throw RequestException::create($request, $response, null, [], $bodySummarizer); } ); }; @@ -90,21 +96,23 @@ final class Middleware return $handler($request, $options)->then( static function ($value) use ($request, &$container, $options) { $container[] = [ - 'request' => $request, + 'request' => $request, 'response' => $value, - 'error' => null, - 'options' => $options + 'error' => null, + 'options' => $options, ]; + return $value; }, static function ($reason) use ($request, &$container, $options) { $container[] = [ - 'request' => $request, + 'request' => $request, 'response' => null, - 'error' => $reason, - 'options' => $options + 'error' => $reason, + 'options' => $options, ]; - return \GuzzleHttp\Promise\rejection_for($reason); + + return P\Create::rejectionFor($reason); } ); }; @@ -135,6 +143,7 @@ final class Middleware if ($after) { $after($request, $options, $response); } + return $response; }; }; @@ -180,29 +189,34 @@ final class Middleware * * @phpstan-param \Psr\Log\LogLevel::* $logLevel Level at which to log requests. * - * @param LoggerInterface $logger Logs messages. - * @param MessageFormatter $formatter Formatter used to create message strings. - * @param string $logLevel Level at which to log requests. + * @param LoggerInterface $logger Logs messages. + * @param MessageFormatterInterface|MessageFormatter $formatter Formatter used to create message strings. + * @param string $logLevel Level at which to log requests. * * @return callable Returns a function that accepts the next handler. */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, string $logLevel = 'info'): callable + public static function log(LoggerInterface $logger, $formatter, string $logLevel = 'info'): callable { + // To be compatible with Guzzle 7.1.x we need to allow users to pass a MessageFormatter + if (!$formatter instanceof MessageFormatter && !$formatter instanceof MessageFormatterInterface) { + throw new \LogicException(sprintf('Argument 2 to %s::log() must be of type %s', self::class, MessageFormatterInterface::class)); + } + return static function (callable $handler) use ($logger, $formatter, $logLevel): callable { return static function (RequestInterface $request, array $options = []) use ($handler, $logger, $formatter, $logLevel) { return $handler($request, $options)->then( static function ($response) use ($logger, $request, $formatter, $logLevel): ResponseInterface { $message = $formatter->format($request, $response); $logger->log($logLevel, $message); + return $response; }, static function ($reason) use ($logger, $request, $formatter): PromiseInterface { - $response = $reason instanceof RequestException - ? $reason->getResponse() - : null; - $message = $formatter->format($request, $response, \GuzzleHttp\Promise\exception_for($reason)); + $response = $reason instanceof RequestException ? $reason->getResponse() : null; + $message = $formatter->format($request, $response, P\Create::exceptionFor($reason)); $logger->error($message); - return \GuzzleHttp\Promise\rejection_for($reason); + + return P\Create::rejectionFor($reason); } ); }; diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php index 66fe029..6277c61 100644 --- a/vendor/guzzlehttp/guzzle/src/Pool.php +++ b/vendor/guzzlehttp/guzzle/src/Pool.php @@ -2,6 +2,7 @@ namespace GuzzleHttp; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\EachPromise; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Promise\PromisorInterface; @@ -17,6 +18,8 @@ use Psr\Http\Message\RequestInterface; * When a function is yielded by the iterator, the function is provided the * "request_options" array that should be merged on top of any existing * options, and the function MUST then return a wait-able promise. + * + * @final */ class Pool implements PromisorInterface { @@ -35,11 +38,8 @@ class Pool implements PromisorInterface * - fulfilled: (callable) Function to invoke when a request completes. * - rejected: (callable) Function to invoke when a request is rejected. */ - public function __construct( - ClientInterface $client, - $requests, - array $config = [] - ) { + public function __construct(ClientInterface $client, $requests, array $config = []) + { if (!isset($config['concurrency'])) { $config['concurrency'] = 25; } @@ -51,7 +51,7 @@ class Pool implements PromisorInterface $opts = []; } - $iterable = \GuzzleHttp\Promise\iter_for($requests); + $iterable = P\Create::iterFor($requests); $requests = static function () use ($iterable, $client, $opts) { foreach ($iterable as $key => $rfn) { if ($rfn instanceof RequestInterface) { @@ -59,10 +59,7 @@ class Pool implements PromisorInterface } elseif (\is_callable($rfn)) { yield $key => $rfn($opts); } else { - throw new \InvalidArgumentException('Each value yielded by ' - . 'the iterator must be a Psr7\Http\Message\RequestInterface ' - . 'or a callable that returns a promise that fulfills ' - . 'with a Psr7\Message\Http\ResponseInterface object.'); + throw new \InvalidArgumentException('Each value yielded by the iterator must be a Psr7\Http\Message\RequestInterface or a callable that returns a promise that fulfills with a Psr7\Message\Http\ResponseInterface object.'); } } }; @@ -96,11 +93,8 @@ class Pool implements PromisorInterface * * @throws \InvalidArgumentException if the event format is incorrect. */ - public static function batch( - ClientInterface $client, - $requests, - array $options = [] - ): array { + public static function batch(ClientInterface $client, $requests, array $options = []): array + { $res = []; self::cmpCallback($options, 'fulfilled', $res); self::cmpCallback($options, 'rejected', $res); diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php index 28331a0..0a8de81 100644 --- a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php @@ -8,6 +8,8 @@ use Psr\Http\Message\RequestInterface; /** * Prepares requests that contain a body, adding the Content-Length, * Content-Type, and Expect headers. + * + * @final */ class PrepareBodyMiddleware { @@ -38,7 +40,7 @@ class PrepareBodyMiddleware // Add a default content-type if possible. if (!$request->hasHeader('Content-Type')) { if ($uri = $request->getBody()->getMetadata('uri')) { - if ($type = Psr7\mimetype_from_filename($uri)) { + if (is_string($uri) && $type = Psr7\MimeType::fromFilename($uri)) { $modify['set_headers']['Content-Type'] = $type; } } @@ -59,17 +61,14 @@ class PrepareBodyMiddleware // Add the expect header if needed. $this->addExpectHeader($request, $options, $modify); - return $fn(Psr7\modify_request($request, $modify), $options); + return $fn(Psr7\Utils::modifyRequest($request, $modify), $options); } /** * Add expect header */ - private function addExpectHeader( - RequestInterface $request, - array $options, - array &$modify - ): void { + private function addExpectHeader(RequestInterface $request, array $options, array &$modify): void + { // Determine if the Expect header should be used if ($request->hasHeader('Expect')) { return; @@ -85,6 +84,7 @@ class PrepareBodyMiddleware // The expect header is unconditionally enabled if ($expect === true) { $modify['set_headers']['Expect'] = '100-Continue'; + return; } diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php index 09dc7ef..f32808a 100644 --- a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php @@ -14,6 +14,8 @@ use Psr\Http\Message\UriInterface; * * Apply this middleware like other middleware using * {@see \GuzzleHttp\Middleware::redirect()}. + * + * @final */ class RedirectMiddleware { @@ -25,10 +27,10 @@ class RedirectMiddleware * @var array */ public static $defaultSettings = [ - 'max' => 5, - 'protocols' => ['http', 'https'], - 'strict' => false, - 'referer' => false, + 'max' => 5, + 'protocols' => ['http', 'https'], + 'strict' => false, + 'referer' => false, 'track_redirects' => false, ]; @@ -75,23 +77,27 @@ class RedirectMiddleware /** * @return ResponseInterface|PromiseInterface */ - public function checkRedirect( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { + public function checkRedirect(RequestInterface $request, array $options, ResponseInterface $response) + { if (\strpos((string) $response->getStatusCode(), '3') !== 0 || !$response->hasHeader('Location') ) { return $response; } - $this->guardMax($request, $options); + $this->guardMax($request, $response, $options); $nextRequest = $this->modifyRequest($request, $options, $response); + // If authorization is handled by curl, unset it if URI is cross-origin. + if (Psr7\UriComparator::isCrossOrigin($request->getUri(), $nextRequest->getUri()) && defined('\CURLOPT_HTTPAUTH')) { + unset( + $options['curl'][\CURLOPT_HTTPAUTH], + $options['curl'][\CURLOPT_USERPWD] + ); + } + if (isset($options['allow_redirects']['on_redirect'])) { - \call_user_func( - $options['allow_redirects']['on_redirect'], + ($options['allow_redirects']['on_redirect'])( $request, $response, $nextRequest->getUri() @@ -134,11 +140,11 @@ class RedirectMiddleware } /** - * Check for too many redirects + * Check for too many redirects. * * @throws TooManyRedirectsException Too many redirects. */ - private function guardMax(RequestInterface $request, array &$options): void + private function guardMax(RequestInterface $request, ResponseInterface $response, array &$options): void { $current = $options['__redirect_count'] ?? 0; @@ -146,18 +152,12 @@ class RedirectMiddleware $max = $options['allow_redirects']['max']; if ($options['__redirect_count'] > $max) { - throw new TooManyRedirectsException( - "Will not follow more than {$max} redirects", - $request - ); + throw new TooManyRedirectsException("Will not follow more than {$max} redirects", $request, $response); } } - public function modifyRequest( - RequestInterface $request, - array $options, - ResponseInterface $response - ): RequestInterface { + public function modifyRequest(RequestInterface $request, array $options, ResponseInterface $response): RequestInterface + { // Request modifications to apply. $modify = []; $protocols = $options['allow_redirects']['protocols']; @@ -169,18 +169,21 @@ class RedirectMiddleware if ($statusCode == 303 || ($statusCode <= 302 && !$options['allow_redirects']['strict']) ) { - $modify['method'] = 'GET'; + $safeMethods = ['GET', 'HEAD', 'OPTIONS']; + $requestMethod = $request->getMethod(); + + $modify['method'] = in_array($requestMethod, $safeMethods) ? $requestMethod : 'GET'; $modify['body'] = ''; } - $uri = $this->redirectUri($request, $response, $protocols); + $uri = self::redirectUri($request, $response, $protocols); if (isset($options['idn_conversion']) && ($options['idn_conversion'] !== false)) { $idnOptions = ($options['idn_conversion'] === true) ? \IDNA_DEFAULT : $options['idn_conversion']; $uri = Utils::idnUriConvert($uri, $idnOptions); } $modify['uri'] = $uri; - Psr7\rewind_body($request); + Psr7\Message::rewindBody($request); // Add the Referer header if it is told to do so and only // add the header if we are not redirecting from https to http. @@ -193,18 +196,19 @@ class RedirectMiddleware $modify['remove_headers'][] = 'Referer'; } - // Remove Authorization header if host is different. - if ($request->getUri()->getHost() !== $modify['uri']->getHost()) { + // Remove Authorization and Cookie headers if URI is cross-origin. + if (Psr7\UriComparator::isCrossOrigin($request->getUri(), $modify['uri'])) { $modify['remove_headers'][] = 'Authorization'; + $modify['remove_headers'][] = 'Cookie'; } - return Psr7\modify_request($request, $modify); + return Psr7\Utils::modifyRequest($request, $modify); } /** - * Set the appropriate URL on the request based on the location header + * Set the appropriate URL on the request based on the location header. */ - private function redirectUri( + private static function redirectUri( RequestInterface $request, ResponseInterface $response, array $protocols @@ -216,15 +220,7 @@ class RedirectMiddleware // Ensure that the redirect URI is allowed based on the protocols. if (!\in_array($location->getScheme(), $protocols)) { - throw new BadResponseException( - \sprintf( - 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s', - $location, - \implode(', ', $protocols) - ), - $request, - $response - ); + throw new BadResponseException(\sprintf('Redirect URI, %s, does not use one of the allowed redirect protocols: %s', $location, \implode(', ', $protocols)), $request, $response); } return $location; diff --git a/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/vendor/guzzlehttp/guzzle/src/RequestOptions.php index 20b31bc..bf3b02b 100644 --- a/vendor/guzzlehttp/guzzle/src/RequestOptions.php +++ b/vendor/guzzlehttp/guzzle/src/RequestOptions.php @@ -7,7 +7,7 @@ namespace GuzzleHttp; * * More documentation for each option can be found at http://guzzlephp.org/. * - * @link http://docs.guzzlephp.org/en/v6/request-options.html + * @see http://docs.guzzlephp.org/en/v6/request-options.html */ final class RequestOptions { @@ -70,10 +70,22 @@ final class RequestOptions /** * connect_timeout: (float, default=0) Float describing the number of * seconds to wait while trying to connect to a server. Use 0 to wait - * indefinitely (the default behavior). + * 300 seconds (the default behavior). */ public const CONNECT_TIMEOUT = 'connect_timeout'; + /** + * crypto_method: (int) A value describing the minimum TLS protocol + * version to use. + * + * This setting must be set to one of the + * ``STREAM_CRYPTO_METHOD_TLS*_CLIENT`` constants. PHP 7.4 or higher is + * required in order to use TLS 1.3, and cURL 7.34.0 or higher is required + * in order to specify a crypto method, with cURL 7.52.0 or higher being + * required to use TLS 1.3. + */ + public const CRYPTO_METHOD = 'crypto_method'; + /** * debug: (bool|resource) Set to true or set to a PHP stream returned by * fopen() enable debug output with the HTTP handler used to send a diff --git a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php index 187eca6..8f4d93a 100644 --- a/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php +++ b/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php @@ -2,6 +2,7 @@ namespace GuzzleHttp; +use GuzzleHttp\Promise as P; use GuzzleHttp\Promise\PromiseInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; @@ -9,6 +10,8 @@ use Psr\Http\Message\ResponseInterface; /** * Middleware that retries requests based on the boolean result of * invoking the provided "decider" function. + * + * @final */ class RetryMiddleware { @@ -33,18 +36,15 @@ class RetryMiddleware * returns true if the request is to be * retried. * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke. - * @param null|callable(int): int $delay Function that accepts the number of retries + * @param (callable(int): int)|null $delay Function that accepts the number of retries * and returns the number of * milliseconds to delay. */ - public function __construct( - callable $decider, - callable $nextHandler, - callable $delay = null - ) { + public function __construct(callable $decider, callable $nextHandler, callable $delay = null) + { $this->decider = $decider; $this->nextHandler = $nextHandler; - $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; + $this->delay = $delay ?: __CLASS__.'::exponentialDelay'; } /** @@ -54,7 +54,7 @@ class RetryMiddleware */ public static function exponentialDelay(int $retries): int { - return (int) \pow(2, $retries - 1) * 1000; + return (int) 2 ** ($retries - 1) * 1000; } public function __invoke(RequestInterface $request, array $options): PromiseInterface @@ -64,6 +64,7 @@ class RetryMiddleware } $fn = $this->nextHandler; + return $fn($request, $options) ->then( $this->onFulfilled($request, $options), @@ -77,8 +78,7 @@ class RetryMiddleware private function onFulfilled(RequestInterface $request, array $options): callable { return function ($value) use ($request, $options) { - if (!\call_user_func( - $this->decider, + if (!($this->decider)( $options['retries'], $request, $value, @@ -86,6 +86,7 @@ class RetryMiddleware )) { return $value; } + return $this->doRetry($request, $options, $value); }; } @@ -96,22 +97,22 @@ class RetryMiddleware private function onRejected(RequestInterface $req, array $options): callable { return function ($reason) use ($req, $options) { - if (!\call_user_func( - $this->decider, + if (!($this->decider)( $options['retries'], $req, null, $reason )) { - return \GuzzleHttp\Promise\rejection_for($reason); + return P\Create::rejectionFor($reason); } + return $this->doRetry($req, $options); }; } private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null): PromiseInterface { - $options['delay'] = \call_user_func($this->delay, ++$options['retries'], $response); + $options['delay'] = ($this->delay)(++$options['retries'], $response, $request); return $this($request, $options); } diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php index f15e816..93fa334 100644 --- a/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ b/vendor/guzzlehttp/guzzle/src/TransferStats.php @@ -128,8 +128,6 @@ final class TransferStats */ public function getHandlerStat(string $stat) { - return isset($this->handlerStats[$stat]) - ? $this->handlerStats[$stat] - : null; + return $this->handlerStats[$stat] ?? null; } } diff --git a/vendor/guzzlehttp/guzzle/src/Utils.php b/vendor/guzzlehttp/guzzle/src/Utils.php index 5a0f8a8..fcf571d 100644 --- a/vendor/guzzlehttp/guzzle/src/Utils.php +++ b/vendor/guzzlehttp/guzzle/src/Utils.php @@ -23,9 +23,9 @@ final class Utils { switch (\gettype($input)) { case 'object': - return 'object(' . \get_class($input) . ')'; + return 'object('.\get_class($input).')'; case 'array': - return 'array(' . \count($input) . ')'; + return 'array('.\count($input).')'; default: \ob_start(); \var_dump($input); @@ -49,9 +49,7 @@ final class Utils foreach ($lines as $line) { $parts = \explode(':', $line, 2); - $headers[\trim($parts[0])][] = isset($parts[1]) - ? \trim($parts[1]) - : null; + $headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null; } return $headers; @@ -73,12 +71,7 @@ final class Utils return \STDOUT; } - $resource = \fopen('php://output', 'w'); - if (false === $resource) { - throw new \RuntimeException('Can not open php output for writing to debug the resource.'); - } - - return $resource; + return \GuzzleHttp\Psr7\Utils::tryFopen('php://output', 'w'); } /** @@ -86,19 +79,22 @@ final class Utils * * The returned handler is not wrapped by any default middlewares. * - * @throws \RuntimeException if no viable Handler is available. - * * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * + * @throws \RuntimeException if no viable Handler is available. */ public static function chooseHandler(): callable { $handler = null; - if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) { - $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler()); - } elseif (\function_exists('curl_exec')) { - $handler = new CurlHandler(); - } elseif (\function_exists('curl_multi_exec')) { - $handler = new CurlMultiHandler(); + + if (\defined('CURLOPT_CUSTOMREQUEST')) { + if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) { + $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler()); + } elseif (\function_exists('curl_exec')) { + $handler = new CurlHandler(); + } elseif (\function_exists('curl_multi_exec')) { + $handler = new CurlMultiHandler(); + } } if (\ini_get('allow_url_fopen')) { @@ -106,8 +102,7 @@ final class Utils ? Proxy::wrapStreaming($handler, new StreamHandler()) : new StreamHandler(); } elseif (!$handler) { - throw new \RuntimeException('GuzzleHttp requires cURL, the ' - . 'allow_url_fopen ini setting, or a custom HTTP handler.'); + throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.'); } return $handler; @@ -133,6 +128,8 @@ final class Utils * Note: the result of this function is cached for subsequent calls. * * @throws \RuntimeException if no bundle can be found. + * + * @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+. */ public static function defaultCaBundle(): string { @@ -231,27 +228,27 @@ EOT } // Strip port if present. - if (\strpos($host, ':')) { - /** @var string[] $hostParts will never be false because of the checks above */ - $hostParts = \explode($host, ':', 2); - $host = $hostParts[0]; - } + [$host] = \explode(':', $host, 2); foreach ($noProxyArray as $area) { // Always match on wildcards. if ($area === '*') { return true; - } elseif (empty($area)) { + } + + if (empty($area)) { // Don't match on empty values. continue; - } elseif ($area === $host) { + } + + if ($area === $host) { // Exact matches. return true; } // Special match if the area when prefixed with ".". Remove any // existing leading "." and add a new leading ".". - $area = '.' . \ltrim($area, '.'); - if (\substr($host, -(\strlen($area))) === $area) { + $area = '.'.\ltrim($area, '.'); + if (\substr($host, -\strlen($area)) === $area) { return true; } } @@ -272,15 +269,13 @@ EOT * * @throws InvalidArgumentException if the JSON cannot be decoded. * - * @link https://www.php.net/manual/en/function.json-decode.php + * @see https://www.php.net/manual/en/function.json-decode.php */ public static function jsonDecode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) { $data = \json_decode($json, $assoc, $depth, $options); if (\JSON_ERROR_NONE !== \json_last_error()) { - throw new InvalidArgumentException( - 'json_decode error: ' . \json_last_error_msg() - ); + throw new InvalidArgumentException('json_decode error: '.\json_last_error_msg()); } return $data; @@ -295,15 +290,13 @@ EOT * * @throws InvalidArgumentException if the JSON cannot be encoded. * - * @link https://www.php.net/manual/en/function.json-encode.php + * @see https://www.php.net/manual/en/function.json-encode.php */ public static function jsonEncode($value, int $options = 0, int $depth = 512): string { $json = \json_encode($value, $options, $depth); if (\JSON_ERROR_NONE !== \json_last_error()) { - throw new InvalidArgumentException( - 'json_encode error: ' . \json_last_error_msg() - ); + throw new InvalidArgumentException('json_encode error: '.\json_last_error_msg()); } /** @var string */ @@ -335,7 +328,7 @@ EOT if ($asciiHost === false) { $errorBitSet = $info['errors'] ?? 0; - $errorConstants = array_filter(array_keys(get_defined_constants()), static function ($name) { + $errorConstants = array_filter(array_keys(get_defined_constants()), static function (string $name): bool { return substr($name, 0, 11) === 'IDNA_ERROR_'; }); @@ -348,7 +341,7 @@ EOT $errorMessage = 'IDN conversion failed'; if ($errors) { - $errorMessage .= ' (errors: ' . implode(', ', $errors) . ')'; + $errorMessage .= ' (errors: '.implode(', ', $errors).')'; } throw new InvalidArgumentException($errorMessage); diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php index 74e3bd2..5edc66a 100644 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ b/vendor/guzzlehttp/guzzle/src/functions.php @@ -10,6 +10,8 @@ namespace GuzzleHttp; * * @return string Returns a string containing the type of the variable and * if a class is provided, the class name. + * + * @deprecated describe_type will be removed in guzzlehttp/guzzle:8.0. Use Utils::describeType instead. */ function describe_type($input): string { @@ -21,6 +23,8 @@ function describe_type($input): string * * @param iterable $lines Header lines array of strings in the following * format: "Name: Value" + * + * @deprecated headers_from_lines will be removed in guzzlehttp/guzzle:8.0. Use Utils::headersFromLines instead. */ function headers_from_lines(iterable $lines): array { @@ -33,6 +37,8 @@ function headers_from_lines(iterable $lines): array * @param mixed $value Optional value * * @return resource + * + * @deprecated debug_resource will be removed in guzzlehttp/guzzle:8.0. Use Utils::debugResource instead. */ function debug_resource($value = null) { @@ -44,9 +50,11 @@ function debug_resource($value = null) * * The returned handler is not wrapped by any default middlewares. * + * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * * @throws \RuntimeException if no viable Handler is available. * - * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system. + * @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead. */ function choose_handler(): callable { @@ -55,6 +63,8 @@ function choose_handler(): callable /** * Get the default User-Agent string to use with Guzzle. + * + * @deprecated default_user_agent will be removed in guzzlehttp/guzzle:8.0. Use Utils::defaultUserAgent instead. */ function default_user_agent(): string { @@ -73,6 +83,8 @@ function default_user_agent(): string * Note: the result of this function is cached for subsequent calls. * * @throws \RuntimeException if no bundle can be found. + * + * @deprecated default_ca_bundle will be removed in guzzlehttp/guzzle:8.0. This function is not needed in PHP 5.6+. */ function default_ca_bundle(): string { @@ -82,6 +94,8 @@ function default_ca_bundle(): string /** * Creates an associative array of lowercase header names to the actual * header casing. + * + * @deprecated normalize_header_keys will be removed in guzzlehttp/guzzle:8.0. Use Utils::normalizeHeaderKeys instead. */ function normalize_header_keys(array $headers): array { @@ -106,6 +120,8 @@ function normalize_header_keys(array $headers): array * @param string[] $noProxyArray An array of host patterns. * * @throws Exception\InvalidArgumentException + * + * @deprecated is_host_in_noproxy will be removed in guzzlehttp/guzzle:8.0. Use Utils::isHostInNoProxy instead. */ function is_host_in_noproxy(string $host, array $noProxyArray): bool { @@ -125,7 +141,8 @@ function is_host_in_noproxy(string $host, array $noProxyArray): bool * * @throws Exception\InvalidArgumentException if the JSON cannot be decoded. * - * @link https://www.php.net/manual/en/function.json-decode.php + * @see https://www.php.net/manual/en/function.json-decode.php + * @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead. */ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0) { @@ -141,7 +158,8 @@ function json_decode(string $json, bool $assoc = false, int $depth = 512, int $o * * @throws Exception\InvalidArgumentException if the JSON cannot be encoded. * - * @link https://www.php.net/manual/en/function.json-encode.php + * @see https://www.php.net/manual/en/function.json-encode.php + * @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead. */ function json_encode($value, int $options = 0, int $depth = 512): string { diff --git a/vendor/guzzlehttp/guzzle/src/functions_include.php b/vendor/guzzlehttp/guzzle/src/functions_include.php index f17a3c2..394f953 100644 --- a/vendor/guzzlehttp/guzzle/src/functions_include.php +++ b/vendor/guzzlehttp/guzzle/src/functions_include.php @@ -1,6 +1,6 @@ =5.5,<8.3 | +| 2.x | Latest | >=7.2.5,<8.3 | + + ## Quick Start A *promise* represents the eventual result of an asynchronous operation. The @@ -430,8 +445,6 @@ $loop = React\EventLoop\Factory::create(); $loop->addPeriodicTimer(0, [$queue, 'run']); ``` -*TODO*: Perhaps adding a `futureTick()` on each tick would be faster? - ## Implementation Notes @@ -501,8 +514,8 @@ $promise->resolve('foo'); A static API was first introduced in 1.4.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The -function API will be removed in 2.0.0. A migration table has been provided here -for your convenience: +function API was removed in 2.0.0. A migration table has been provided here for +your convenience: | Original Function | Replacement Method | |----------------|----------------| diff --git a/vendor/guzzlehttp/promises/composer.json b/vendor/guzzlehttp/promises/composer.json index 966e3e3..fc1989e 100644 --- a/vendor/guzzlehttp/promises/composer.json +++ b/vendor/guzzlehttp/promises/composer.json @@ -26,27 +26,32 @@ } ], "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.1", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" }, "autoload": { "psr-4": { "GuzzleHttp\\Promise\\": "src/" - }, - "files": ["src/functions_include.php"] + } }, "autoload-dev": { "psr-4": { "GuzzleHttp\\Promise\\Tests\\": "tests/" } }, - "scripts": { - "test": "vendor/bin/simple-phpunit", - "test-ci": "vendor/bin/simple-phpunit --coverage-text" + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } }, "config": { + "allow-plugins": { + "bamarni/composer-bin-plugin": true + }, "preferred-install": "dist", "sort-packages": true } diff --git a/vendor/guzzlehttp/promises/src/AggregateException.php b/vendor/guzzlehttp/promises/src/AggregateException.php index d2b5712..40ffdbc 100644 --- a/vendor/guzzlehttp/promises/src/AggregateException.php +++ b/vendor/guzzlehttp/promises/src/AggregateException.php @@ -1,5 +1,7 @@ generator = $generatorFn(); - $this->result = new Promise(function () { + $this->result = new Promise(function (): void { while (isset($this->currentPromise)) { $this->currentPromise->wait(); } }); try { $this->nextCoroutine($this->generator->current()); - } catch (\Exception $exception) { - $this->result->reject($exception); } catch (Throwable $throwable) { $this->result->reject($throwable); } @@ -78,10 +77,8 @@ final class Coroutine implements PromiseInterface /** * Create a new coroutine. - * - * @return self */ - public static function of(callable $generatorFn) + public static function of(callable $generatorFn): self { return new self($generatorFn); } @@ -89,42 +86,42 @@ final class Coroutine implements PromiseInterface public function then( callable $onFulfilled = null, callable $onRejected = null - ) { + ): PromiseInterface { return $this->result->then($onFulfilled, $onRejected); } - public function otherwise(callable $onRejected) + public function otherwise(callable $onRejected): PromiseInterface { return $this->result->otherwise($onRejected); } - public function wait($unwrap = true) + public function wait(bool $unwrap = true) { return $this->result->wait($unwrap); } - public function getState() + public function getState(): string { return $this->result->getState(); } - public function resolve($value) + public function resolve($value): void { $this->result->resolve($value); } - public function reject($reason) + public function reject($reason): void { $this->result->reject($reason); } - public function cancel() + public function cancel(): void { $this->currentPromise->cancel(); $this->result->cancel(); } - private function nextCoroutine($yielded) + private function nextCoroutine($yielded): void { $this->currentPromise = Create::promiseFor($yielded) ->then([$this, '_handleSuccess'], [$this, '_handleFailure']); @@ -133,7 +130,7 @@ final class Coroutine implements PromiseInterface /** * @internal */ - public function _handleSuccess($value) + public function _handleSuccess($value): void { unset($this->currentPromise); try { @@ -143,8 +140,6 @@ final class Coroutine implements PromiseInterface } else { $this->result->resolve($value); } - } catch (Exception $exception) { - $this->result->reject($exception); } catch (Throwable $throwable) { $this->result->reject($throwable); } @@ -153,15 +148,13 @@ final class Coroutine implements PromiseInterface /** * @internal */ - public function _handleFailure($reason) + public function _handleFailure($reason): void { unset($this->currentPromise); try { $nextYield = $this->generator->throw(Create::exceptionFor($reason)); // The throw was caught, so keep iterating on the coroutine $this->nextCoroutine($nextYield); - } catch (Exception $exception) { - $this->result->reject($exception); } catch (Throwable $throwable) { $this->result->reject($throwable); } diff --git a/vendor/guzzlehttp/promises/src/Create.php b/vendor/guzzlehttp/promises/src/Create.php index 8d038e9..9d3fc4a 100644 --- a/vendor/guzzlehttp/promises/src/Create.php +++ b/vendor/guzzlehttp/promises/src/Create.php @@ -1,5 +1,7 @@ then([$promise, 'resolve'], [$promise, 'reject']); + return $promise; } @@ -34,10 +35,8 @@ final class Create * If the provided reason is a promise, then it is returned as-is. * * @param mixed $reason Promise or reason. - * - * @return PromiseInterface */ - public static function rejectionFor($reason) + public static function rejectionFor($reason): PromiseInterface { if ($reason instanceof PromiseInterface) { return $reason; @@ -50,12 +49,10 @@ final class Create * Create an exception for a rejected promise value. * * @param mixed $reason - * - * @return \Exception|\Throwable */ - public static function exceptionFor($reason) + public static function exceptionFor($reason): \Throwable { - if ($reason instanceof \Exception || $reason instanceof \Throwable) { + if ($reason instanceof \Throwable) { return $reason; } @@ -66,10 +63,8 @@ final class Create * Returns an iterator for the given value. * * @param mixed $value - * - * @return \Iterator */ - public static function iterFor($value) + public static function iterFor($value): \Iterator { if ($value instanceof \Iterator) { return $value; diff --git a/vendor/guzzlehttp/promises/src/Each.php b/vendor/guzzlehttp/promises/src/Each.php index ff8efd7..1a7aa0f 100644 --- a/vendor/guzzlehttp/promises/src/Each.php +++ b/vendor/guzzlehttp/promises/src/Each.php @@ -1,5 +1,7 @@ $onFulfilled, - 'rejected' => $onRejected + 'rejected' => $onRejected, ]))->promise(); } @@ -46,19 +46,17 @@ final class Each * @param int|callable $concurrency * @param callable $onFulfilled * @param callable $onRejected - * - * @return PromiseInterface */ public static function ofLimit( $iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null - ) { + ): PromiseInterface { return (new EachPromise($iterable, [ - 'fulfilled' => $onFulfilled, - 'rejected' => $onRejected, - 'concurrency' => $concurrency + 'fulfilled' => $onFulfilled, + 'rejected' => $onRejected, + 'concurrency' => $concurrency, ]))->promise(); } @@ -70,19 +68,17 @@ final class Each * @param mixed $iterable * @param int|callable $concurrency * @param callable $onFulfilled - * - * @return PromiseInterface */ public static function ofLimitAll( $iterable, $concurrency, callable $onFulfilled = null - ) { + ): PromiseInterface { return self::ofLimit( $iterable, $concurrency, $onFulfilled, - function ($reason, $idx, PromiseInterface $aggregate) { + function ($reason, $idx, PromiseInterface $aggregate): void { $aggregate->reject($reason); } ); diff --git a/vendor/guzzlehttp/promises/src/EachPromise.php b/vendor/guzzlehttp/promises/src/EachPromise.php index 280d799..28dd979 100644 --- a/vendor/guzzlehttp/promises/src/EachPromise.php +++ b/vendor/guzzlehttp/promises/src/EachPromise.php @@ -1,10 +1,14 @@ aggregate) { return $this->aggregate; @@ -82,21 +86,18 @@ class EachPromise implements PromisorInterface $this->refillPending(); } catch (\Throwable $e) { $this->aggregate->reject($e); - } catch (\Exception $e) { - $this->aggregate->reject($e); } /** * @psalm-suppress NullableReturnStatement - * @phpstan-ignore-next-line */ return $this->aggregate; } - private function createPromise() + private function createPromise(): void { $this->mutex = false; - $this->aggregate = new Promise(function () { + $this->aggregate = new Promise(function (): void { if ($this->checkIfFinished()) { return; } @@ -113,7 +114,7 @@ class EachPromise implements PromisorInterface }); // Clear the references when the promise is resolved. - $clearFn = function () { + $clearFn = function (): void { $this->iterable = $this->concurrency = $this->pending = null; $this->onFulfilled = $this->onRejected = null; $this->nextPendingIndex = 0; @@ -122,11 +123,13 @@ class EachPromise implements PromisorInterface $this->aggregate->then($clearFn, $clearFn); } - private function refillPending() + private function refillPending(): void { if (!$this->concurrency) { // Add all pending promises. - while ($this->addPending() && $this->advanceIterator()); + while ($this->addPending() && $this->advanceIterator()) { + } + return; } @@ -147,10 +150,11 @@ class EachPromise implements PromisorInterface // next value to yield until promise callbacks are called. while (--$concurrency && $this->advanceIterator() - && $this->addPending()); + && $this->addPending()) { + } } - private function addPending() + private function addPending(): bool { if (!$this->iterable || !$this->iterable->valid()) { return false; @@ -164,7 +168,7 @@ class EachPromise implements PromisorInterface $idx = $this->nextPendingIndex++; $this->pending[$idx] = $promise->then( - function ($value) use ($idx, $key) { + function ($value) use ($idx, $key): void { if ($this->onFulfilled) { call_user_func( $this->onFulfilled, @@ -175,7 +179,7 @@ class EachPromise implements PromisorInterface } $this->step($idx); }, - function ($reason) use ($idx, $key) { + function ($reason) use ($idx, $key): void { if ($this->onRejected) { call_user_func( $this->onRejected, @@ -191,7 +195,7 @@ class EachPromise implements PromisorInterface return true; } - private function advanceIterator() + private function advanceIterator(): bool { // Place a lock on the iterator so that we ensure to not recurse, // preventing fatal generator errors. @@ -204,19 +208,17 @@ class EachPromise implements PromisorInterface try { $this->iterable->next(); $this->mutex = false; + return true; } catch (\Throwable $e) { $this->aggregate->reject($e); $this->mutex = false; - return false; - } catch (\Exception $e) { - $this->aggregate->reject($e); - $this->mutex = false; + return false; } } - private function step($idx) + private function step(int $idx): void { // If the promise was already resolved, then ignore this step. if (Is::settled($this->aggregate)) { @@ -234,11 +236,12 @@ class EachPromise implements PromisorInterface } } - private function checkIfFinished() + private function checkIfFinished(): bool { if (!$this->pending && !$this->iterable->valid()) { // Resolve the promise if there's nothing left to do. $this->aggregate->resolve(null); + return true; } diff --git a/vendor/guzzlehttp/promises/src/FulfilledPromise.php b/vendor/guzzlehttp/promises/src/FulfilledPromise.php index 98f72a6..ab71296 100644 --- a/vendor/guzzlehttp/promises/src/FulfilledPromise.php +++ b/vendor/guzzlehttp/promises/src/FulfilledPromise.php @@ -1,5 +1,7 @@ value; - $queue->add(static function () use ($p, $value, $onFulfilled) { + $queue->add(static function () use ($p, $value, $onFulfilled): void { if (Is::pending($p)) { try { $p->resolve($onFulfilled($value)); } catch (\Throwable $e) { $p->reject($e); - } catch (\Exception $e) { - $p->reject($e); } } }); @@ -50,34 +55,34 @@ class FulfilledPromise implements PromiseInterface return $p; } - public function otherwise(callable $onRejected) + public function otherwise(callable $onRejected): PromiseInterface { return $this->then(null, $onRejected); } - public function wait($unwrap = true, $defaultDelivery = null) + public function wait(bool $unwrap = true) { return $unwrap ? $this->value : null; } - public function getState() + public function getState(): string { return self::FULFILLED; } - public function resolve($value) + public function resolve($value): void { if ($value !== $this->value) { - throw new \LogicException("Cannot resolve a fulfilled promise"); + throw new \LogicException('Cannot resolve a fulfilled promise'); } } - public function reject($reason) + public function reject($reason): void { - throw new \LogicException("Cannot reject a fulfilled promise"); + throw new \LogicException('Cannot reject a fulfilled promise'); } - public function cancel() + public function cancel(): void { // pass } diff --git a/vendor/guzzlehttp/promises/src/Is.php b/vendor/guzzlehttp/promises/src/Is.php index c3ed8d0..f3f0503 100644 --- a/vendor/guzzlehttp/promises/src/Is.php +++ b/vendor/guzzlehttp/promises/src/Is.php @@ -1,45 +1,39 @@ getState() === PromiseInterface::PENDING; } /** * Returns true if a promise is fulfilled or rejected. - * - * @return bool */ - public static function settled(PromiseInterface $promise) + public static function settled(PromiseInterface $promise): bool { return $promise->getState() !== PromiseInterface::PENDING; } /** * Returns true if a promise is fulfilled. - * - * @return bool */ - public static function fulfilled(PromiseInterface $promise) + public static function fulfilled(PromiseInterface $promise): bool { return $promise->getState() === PromiseInterface::FULFILLED; } /** * Returns true if a promise is rejected. - * - * @return bool */ - public static function rejected(PromiseInterface $promise) + public static function rejected(PromiseInterface $promise): bool { return $promise->getState() === PromiseInterface::REJECTED; } diff --git a/vendor/guzzlehttp/promises/src/Promise.php b/vendor/guzzlehttp/promises/src/Promise.php index 7593905..1b07bdc 100644 --- a/vendor/guzzlehttp/promises/src/Promise.php +++ b/vendor/guzzlehttp/promises/src/Promise.php @@ -1,11 +1,15 @@ state === self::PENDING) { $p = new Promise(null, [$this, 'cancel']); $this->handlers[] = [$p, $onFulfilled, $onRejected]; $p->waitList = $this->waitList; $p->waitList[] = $this; + return $p; } // Return a fulfilled promise and immediately invoke any callbacks. if ($this->state === self::FULFILLED) { $promise = Create::promiseFor($this->result); + return $onFulfilled ? $promise->then($onFulfilled) : $promise; } // It's either cancelled or rejected, so return a rejected promise // and immediately invoke any callbacks. $rejection = Create::rejectionFor($this->result); + return $onRejected ? $rejection->then(null, $onRejected) : $rejection; } - public function otherwise(callable $onRejected) + public function otherwise(callable $onRejected): PromiseInterface { return $this->then(null, $onRejected); } - public function wait($unwrap = true) + public function wait(bool $unwrap = true) { $this->waitIfPending(); @@ -73,12 +80,12 @@ class Promise implements PromiseInterface } } - public function getState() + public function getState(): string { return $this->state; } - public function cancel() + public function cancel(): void { if ($this->state !== self::PENDING) { return; @@ -93,8 +100,6 @@ class Promise implements PromiseInterface $fn(); } catch (\Throwable $e) { $this->reject($e); - } catch (\Exception $e) { - $this->reject($e); } } @@ -105,17 +110,17 @@ class Promise implements PromiseInterface } } - public function resolve($value) + public function resolve($value): void { $this->settle(self::FULFILLED, $value); } - public function reject($reason) + public function reject($reason): void { $this->settle(self::REJECTED, $reason); } - private function settle($state, $value) + private function settle(string $state, $value): void { if ($this->state !== self::PENDING) { // Ignore calls with the same resolution. @@ -148,7 +153,7 @@ class Promise implements PromiseInterface if (!is_object($value) || !method_exists($value, 'then')) { $id = $state === self::FULFILLED ? 1 : 2; // It's a success, so resolve the handlers in the queue. - Utils::queue()->add(static function () use ($id, $value, $handlers) { + Utils::queue()->add(static function () use ($id, $value, $handlers): void { foreach ($handlers as $handler) { self::callHandler($id, $value, $handler); } @@ -159,12 +164,12 @@ class Promise implements PromiseInterface } else { // Resolve the handlers when the forwarded promise is resolved. $value->then( - static function ($value) use ($handlers) { + static function ($value) use ($handlers): void { foreach ($handlers as $handler) { self::callHandler(1, $value, $handler); } }, - static function ($reason) use ($handlers) { + static function ($reason) use ($handlers): void { foreach ($handlers as $handler) { self::callHandler(2, $reason, $handler); } @@ -180,7 +185,7 @@ class Promise implements PromiseInterface * @param mixed $value Value to pass to the callback. * @param array $handler Array of handler data (promise and callbacks). */ - private static function callHandler($index, $value, array $handler) + private static function callHandler(int $index, $value, array $handler): void { /** @var PromiseInterface $promise */ $promise = $handler[0]; @@ -211,12 +216,10 @@ class Promise implements PromiseInterface } } catch (\Throwable $reason) { $promise->reject($reason); - } catch (\Exception $reason) { - $promise->reject($reason); } } - private function waitIfPending() + private function waitIfPending(): void { if ($this->state !== self::PENDING) { return; @@ -227,9 +230,9 @@ class Promise implements PromiseInterface } else { // If there's no wait function, then reject the promise. $this->reject('Cannot wait on a promise that has ' - . 'no internal wait function. You must provide a wait ' - . 'function when constructing the promise to be able to ' - . 'wait on a promise.'); + .'no internal wait function. You must provide a wait ' + .'function when constructing the promise to be able to ' + .'wait on a promise.'); } Utils::queue()->run(); @@ -240,13 +243,13 @@ class Promise implements PromiseInterface } } - private function invokeWaitFn() + private function invokeWaitFn(): void { try { $wfn = $this->waitFn; $this->waitFn = null; $wfn(true); - } catch (\Exception $reason) { + } catch (\Throwable $reason) { if ($this->state === self::PENDING) { // The promise has not been resolved yet, so reject the promise // with the exception. @@ -259,7 +262,7 @@ class Promise implements PromiseInterface } } - private function invokeWaitList() + private function invokeWaitList(): void { $waitList = $this->waitList; $this->waitList = null; diff --git a/vendor/guzzlehttp/promises/src/PromiseInterface.php b/vendor/guzzlehttp/promises/src/PromiseInterface.php index e598331..2824802 100644 --- a/vendor/guzzlehttp/promises/src/PromiseInterface.php +++ b/vendor/guzzlehttp/promises/src/PromiseInterface.php @@ -1,5 +1,7 @@ reason; $p = new Promise([$queue, 'run']); - $queue->add(static function () use ($p, $reason, $onRejected) { + $queue->add(static function () use ($p, $reason, $onRejected): void { if (Is::pending($p)) { try { // Return a resolved promise if onRejected does not throw. @@ -43,9 +50,6 @@ class RejectedPromise implements PromiseInterface } catch (\Throwable $e) { // onRejected threw, so return a rejected promise. $p->reject($e); - } catch (\Exception $e) { - // onRejected threw, so return a rejected promise. - $p->reject($e); } } }); @@ -53,12 +57,12 @@ class RejectedPromise implements PromiseInterface return $p; } - public function otherwise(callable $onRejected) + public function otherwise(callable $onRejected): PromiseInterface { return $this->then(null, $onRejected); } - public function wait($unwrap = true, $defaultDelivery = null) + public function wait(bool $unwrap = true) { if ($unwrap) { throw Create::exceptionFor($this->reason); @@ -67,24 +71,24 @@ class RejectedPromise implements PromiseInterface return null; } - public function getState() + public function getState(): string { return self::REJECTED; } - public function resolve($value) + public function resolve($value): void { - throw new \LogicException("Cannot resolve a rejected promise"); + throw new \LogicException('Cannot resolve a rejected promise'); } - public function reject($reason) + public function reject($reason): void { if ($reason !== $this->reason) { - throw new \LogicException("Cannot reject a rejected promise"); + throw new \LogicException('Cannot reject a rejected promise'); } } - public function cancel() + public function cancel(): void { // pass } diff --git a/vendor/guzzlehttp/promises/src/RejectionException.php b/vendor/guzzlehttp/promises/src/RejectionException.php index e2f1377..0db98ff 100644 --- a/vendor/guzzlehttp/promises/src/RejectionException.php +++ b/vendor/guzzlehttp/promises/src/RejectionException.php @@ -1,5 +1,7 @@ reason; + $message .= ' with reason: '.$this->reason; } elseif ($reason instanceof \JsonSerializable) { - $message .= ' with reason: ' - . json_encode($this->reason, JSON_PRETTY_PRINT); + $message .= ' with reason: '.json_encode($this->reason, JSON_PRETTY_PRINT); } parent::__construct($message); diff --git a/vendor/guzzlehttp/promises/src/TaskQueue.php b/vendor/guzzlehttp/promises/src/TaskQueue.php index f0fba2c..503e0b2 100644 --- a/vendor/guzzlehttp/promises/src/TaskQueue.php +++ b/vendor/guzzlehttp/promises/src/TaskQueue.php @@ -1,5 +1,7 @@ run(); + * + * @final */ class TaskQueue implements TaskQueueInterface { private $enableShutdown = true; private $queue = []; - public function __construct($withShutdown = true) + public function __construct(bool $withShutdown = true) { if ($withShutdown) { - register_shutdown_function(function () { + register_shutdown_function(function (): void { if ($this->enableShutdown) { // Only run the tasks if an E_ERROR didn't occur. $err = error_get_last(); @@ -31,17 +35,17 @@ class TaskQueue implements TaskQueueInterface } } - public function isEmpty() + public function isEmpty(): bool { return !$this->queue; } - public function add(callable $task) + public function add(callable $task): void { $this->queue[] = $task; } - public function run() + public function run(): void { while ($task = array_shift($this->queue)) { /** @var callable $task */ @@ -60,7 +64,7 @@ class TaskQueue implements TaskQueueInterface * * Note: This shutdown will occur before any destructors are triggered. */ - public function disableShutdown() + public function disableShutdown(): void { $this->enableShutdown = false; } diff --git a/vendor/guzzlehttp/promises/src/TaskQueueInterface.php b/vendor/guzzlehttp/promises/src/TaskQueueInterface.php index 723d4d5..34c561a 100644 --- a/vendor/guzzlehttp/promises/src/TaskQueueInterface.php +++ b/vendor/guzzlehttp/promises/src/TaskQueueInterface.php @@ -1,24 +1,24 @@ * - * @param TaskQueueInterface $assign Optionally specify a new queue instance. - * - * @return TaskQueueInterface + * @param TaskQueueInterface|null $assign Optionally specify a new queue instance. */ - public static function queue(TaskQueueInterface $assign = null) + public static function queue(TaskQueueInterface $assign = null): TaskQueueInterface { static $queue; @@ -39,22 +39,18 @@ final class Utils * returns a promise that is fulfilled or rejected with the result. * * @param callable $task Task function to run. - * - * @return PromiseInterface */ - public static function task(callable $task) + public static function task(callable $task): PromiseInterface { $queue = self::queue(); $promise = new Promise([$queue, 'run']); - $queue->add(function () use ($task, $promise) { + $queue->add(function () use ($task, $promise): void { try { if (Is::pending($promise)) { $promise->resolve($task()); } } catch (\Throwable $e) { $promise->reject($e); - } catch (\Exception $e) { - $promise->reject($e); } }); @@ -72,22 +68,18 @@ final class Utils * key mapping to the rejection reason of the promise. * * @param PromiseInterface $promise Promise or value. - * - * @return array */ - public static function inspect(PromiseInterface $promise) + public static function inspect(PromiseInterface $promise): array { try { return [ 'state' => PromiseInterface::FULFILLED, - 'value' => $promise->wait() + 'value' => $promise->wait(), ]; } catch (RejectionException $e) { return ['state' => PromiseInterface::REJECTED, 'reason' => $e->getReason()]; } catch (\Throwable $e) { return ['state' => PromiseInterface::REJECTED, 'reason' => $e]; - } catch (\Exception $e) { - return ['state' => PromiseInterface::REJECTED, 'reason' => $e]; } } @@ -100,10 +92,8 @@ final class Utils * @see inspect for the inspection state array format. * * @param PromiseInterface[] $promises Traversable of promises to wait upon. - * - * @return array */ - public static function inspectAll($promises) + public static function inspectAll($promises): array { $results = []; foreach ($promises as $key => $promise) { @@ -122,12 +112,9 @@ final class Utils * * @param iterable $promises Iterable of PromiseInterface objects to wait on. * - * @return array - * - * @throws \Exception on error - * @throws \Throwable on error in PHP >=7 + * @throws \Throwable on error */ - public static function unwrap($promises) + public static function unwrap($promises): array { $results = []; foreach ($promises as $key => $promise) { @@ -147,22 +134,21 @@ final class Utils * * @param mixed $promises Promises or values. * @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution. - * - * @return PromiseInterface */ - public static function all($promises, $recursive = false) + public static function all($promises, bool $recursive = false): PromiseInterface { $results = []; $promise = Each::of( $promises, - function ($value, $idx) use (&$results) { + function ($value, $idx) use (&$results): void { $results[$idx] = $value; }, - function ($reason, $idx, Promise $aggregate) { + function ($reason, $idx, Promise $aggregate): void { $aggregate->reject($reason); } )->then(function () use (&$results) { ksort($results); + return $results; }); @@ -173,6 +159,7 @@ final class Utils return self::all($promises, $recursive); } } + return $results; }); } @@ -193,17 +180,15 @@ final class Utils * * @param int $count Total number of promises. * @param mixed $promises Promises or values. - * - * @return PromiseInterface */ - public static function some($count, $promises) + public static function some(int $count, $promises): PromiseInterface { $results = []; $rejections = []; return Each::of( $promises, - function ($value, $idx, PromiseInterface $p) use (&$results, $count) { + function ($value, $idx, PromiseInterface $p) use (&$results, $count): void { if (Is::settled($p)) { return; } @@ -212,7 +197,7 @@ final class Utils $p->resolve(null); } }, - function ($reason) use (&$rejections) { + function ($reason) use (&$rejections): void { $rejections[] = $reason; } )->then( @@ -224,6 +209,7 @@ final class Utils ); } ksort($results); + return array_values($results); } ); @@ -234,10 +220,8 @@ final class Utils * fulfillment value is not an array of 1 but the value directly. * * @param mixed $promises Promises or values. - * - * @return PromiseInterface */ - public static function any($promises) + public static function any($promises): PromiseInterface { return self::some(1, $promises)->then(function ($values) { return $values[0]; @@ -253,23 +237,22 @@ final class Utils * @see inspect for the inspection state array format. * * @param mixed $promises Promises or values. - * - * @return PromiseInterface */ - public static function settle($promises) + public static function settle($promises): PromiseInterface { $results = []; return Each::of( $promises, - function ($value, $idx) use (&$results) { + function ($value, $idx) use (&$results): void { $results[$idx] = ['state' => PromiseInterface::FULFILLED, 'value' => $value]; }, - function ($reason, $idx) use (&$results) { + function ($reason, $idx) use (&$results): void { $results[$idx] = ['state' => PromiseInterface::REJECTED, 'reason' => $reason]; } )->then(function () use (&$results) { ksort($results); + return $results; }); } diff --git a/vendor/guzzlehttp/promises/src/functions.php b/vendor/guzzlehttp/promises/src/functions.php deleted file mode 100644 index c03d39d..0000000 --- a/vendor/guzzlehttp/promises/src/functions.php +++ /dev/null @@ -1,363 +0,0 @@ - - * while ($eventLoop->isRunning()) { - * GuzzleHttp\Promise\queue()->run(); - * } - * - * - * @param TaskQueueInterface $assign Optionally specify a new queue instance. - * - * @return TaskQueueInterface - * - * @deprecated queue will be removed in guzzlehttp/promises:2.0. Use Utils::queue instead. - */ -function queue(TaskQueueInterface $assign = null) -{ - return Utils::queue($assign); -} - -/** - * Adds a function to run in the task queue when it is next `run()` and returns - * a promise that is fulfilled or rejected with the result. - * - * @param callable $task Task function to run. - * - * @return PromiseInterface - * - * @deprecated task will be removed in guzzlehttp/promises:2.0. Use Utils::task instead. - */ -function task(callable $task) -{ - return Utils::task($task); -} - -/** - * Creates a promise for a value if the value is not a promise. - * - * @param mixed $value Promise or value. - * - * @return PromiseInterface - * - * @deprecated promise_for will be removed in guzzlehttp/promises:2.0. Use Create::promiseFor instead. - */ -function promise_for($value) -{ - return Create::promiseFor($value); -} - -/** - * Creates a rejected promise for a reason if the reason is not a promise. If - * the provided reason is a promise, then it is returned as-is. - * - * @param mixed $reason Promise or reason. - * - * @return PromiseInterface - * - * @deprecated rejection_for will be removed in guzzlehttp/promises:2.0. Use Create::rejectionFor instead. - */ -function rejection_for($reason) -{ - return Create::rejectionFor($reason); -} - -/** - * Create an exception for a rejected promise value. - * - * @param mixed $reason - * - * @return \Exception|\Throwable - * - * @deprecated exception_for will be removed in guzzlehttp/promises:2.0. Use Create::exceptionFor instead. - */ -function exception_for($reason) -{ - return Create::exceptionFor($reason); -} - -/** - * Returns an iterator for the given value. - * - * @param mixed $value - * - * @return \Iterator - * - * @deprecated iter_for will be removed in guzzlehttp/promises:2.0. Use Create::iterFor instead. - */ -function iter_for($value) -{ - return Create::iterFor($value); -} - -/** - * Synchronously waits on a promise to resolve and returns an inspection state - * array. - * - * Returns a state associative array containing a "state" key mapping to a - * valid promise state. If the state of the promise is "fulfilled", the array - * will contain a "value" key mapping to the fulfilled value of the promise. If - * the promise is rejected, the array will contain a "reason" key mapping to - * the rejection reason of the promise. - * - * @param PromiseInterface $promise Promise or value. - * - * @return array - * - * @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspect instead. - */ -function inspect(PromiseInterface $promise) -{ - return Utils::inspect($promise); -} - -/** - * Waits on all of the provided promises, but does not unwrap rejected promises - * as thrown exception. - * - * Returns an array of inspection state arrays. - * - * @see inspect for the inspection state array format. - * - * @param PromiseInterface[] $promises Traversable of promises to wait upon. - * - * @return array - * - * @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspectAll instead. - */ -function inspect_all($promises) -{ - return Utils::inspectAll($promises); -} - -/** - * Waits on all of the provided promises and returns the fulfilled values. - * - * Returns an array that contains the value of each promise (in the same order - * the promises were provided). An exception is thrown if any of the promises - * are rejected. - * - * @param iterable $promises Iterable of PromiseInterface objects to wait on. - * - * @return array - * - * @throws \Exception on error - * @throws \Throwable on error in PHP >=7 - * - * @deprecated unwrap will be removed in guzzlehttp/promises:2.0. Use Utils::unwrap instead. - */ -function unwrap($promises) -{ - return Utils::unwrap($promises); -} - -/** - * Given an array of promises, return a promise that is fulfilled when all the - * items in the array are fulfilled. - * - * The promise's fulfillment value is an array with fulfillment values at - * respective positions to the original array. If any promise in the array - * rejects, the returned promise is rejected with the rejection reason. - * - * @param mixed $promises Promises or values. - * @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution. - * - * @return PromiseInterface - * - * @deprecated all will be removed in guzzlehttp/promises:2.0. Use Utils::all instead. - */ -function all($promises, $recursive = false) -{ - return Utils::all($promises, $recursive); -} - -/** - * Initiate a competitive race between multiple promises or values (values will - * become immediately fulfilled promises). - * - * When count amount of promises have been fulfilled, the returned promise is - * fulfilled with an array that contains the fulfillment values of the winners - * in order of resolution. - * - * This promise is rejected with a {@see AggregateException} if the number of - * fulfilled promises is less than the desired $count. - * - * @param int $count Total number of promises. - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - * - * @deprecated some will be removed in guzzlehttp/promises:2.0. Use Utils::some instead. - */ -function some($count, $promises) -{ - return Utils::some($count, $promises); -} - -/** - * Like some(), with 1 as count. However, if the promise fulfills, the - * fulfillment value is not an array of 1 but the value directly. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - * - * @deprecated any will be removed in guzzlehttp/promises:2.0. Use Utils::any instead. - */ -function any($promises) -{ - return Utils::any($promises); -} - -/** - * Returns a promise that is fulfilled when all of the provided promises have - * been fulfilled or rejected. - * - * The returned promise is fulfilled with an array of inspection state arrays. - * - * @see inspect for the inspection state array format. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - * - * @deprecated settle will be removed in guzzlehttp/promises:2.0. Use Utils::settle instead. - */ -function settle($promises) -{ - return Utils::settle($promises); -} - -/** - * Given an iterator that yields promises or values, returns a promise that is - * fulfilled with a null value when the iterator has been consumed or the - * aggregate promise has been fulfilled or rejected. - * - * $onFulfilled is a function that accepts the fulfilled value, iterator index, - * and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate if needed. - * - * $onRejected is a function that accepts the rejection reason, iterator index, - * and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate if needed. - * - * @param mixed $iterable Iterator or array to iterate over. - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return PromiseInterface - * - * @deprecated each will be removed in guzzlehttp/promises:2.0. Use Each::of instead. - */ -function each( - $iterable, - callable $onFulfilled = null, - callable $onRejected = null -) { - return Each::of($iterable, $onFulfilled, $onRejected); -} - -/** - * Like each, but only allows a certain number of outstanding promises at any - * given time. - * - * $concurrency may be an integer or a function that accepts the number of - * pending promises and returns a numeric concurrency limit value to allow for - * dynamic a concurrency size. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return PromiseInterface - * - * @deprecated each_limit will be removed in guzzlehttp/promises:2.0. Use Each::ofLimit instead. - */ -function each_limit( - $iterable, - $concurrency, - callable $onFulfilled = null, - callable $onRejected = null -) { - return Each::ofLimit($iterable, $concurrency, $onFulfilled, $onRejected); -} - -/** - * Like each_limit, but ensures that no promise in the given $iterable argument - * is rejected. If any promise is rejected, then the aggregate promise is - * rejected with the encountered rejection. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * - * @return PromiseInterface - * - * @deprecated each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each::ofLimitAll instead. - */ -function each_limit_all( - $iterable, - $concurrency, - callable $onFulfilled = null -) { - return Each::ofLimitAll($iterable, $concurrency, $onFulfilled); -} - -/** - * Returns true if a promise is fulfilled. - * - * @return bool - * - * @deprecated is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is::fulfilled instead. - */ -function is_fulfilled(PromiseInterface $promise) -{ - return Is::fulfilled($promise); -} - -/** - * Returns true if a promise is rejected. - * - * @return bool - * - * @deprecated is_rejected will be removed in guzzlehttp/promises:2.0. Use Is::rejected instead. - */ -function is_rejected(PromiseInterface $promise) -{ - return Is::rejected($promise); -} - -/** - * Returns true if a promise is fulfilled or rejected. - * - * @return bool - * - * @deprecated is_settled will be removed in guzzlehttp/promises:2.0. Use Is::settled instead. - */ -function is_settled(PromiseInterface $promise) -{ - return Is::settled($promise); -} - -/** - * Create a new coroutine. - * - * @see Coroutine - * - * @return PromiseInterface - * - * @deprecated coroutine will be removed in guzzlehttp/promises:2.0. Use Coroutine::of instead. - */ -function coroutine(callable $generatorFn) -{ - return Coroutine::of($generatorFn); -} diff --git a/vendor/guzzlehttp/promises/src/functions_include.php b/vendor/guzzlehttp/promises/src/functions_include.php deleted file mode 100644 index 34cd171..0000000 --- a/vendor/guzzlehttp/promises/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ - - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false diff --git a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml b/vendor/guzzlehttp/psr7/.github/workflows/ci.yml deleted file mode 100644 index 0850470..0000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/ci.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: CI - -on: - pull_request: - -jobs: - build: - name: Build - runs-on: ubuntu-22.04 - strategy: - max-parallel: 10 - matrix: - php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: 'none' - extensions: mbstring - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Install dependencies - run: composer update --no-interaction --no-progress - - - name: Run tests - run: make test diff --git a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml b/vendor/guzzlehttp/psr7/.github/workflows/integration.yml deleted file mode 100644 index a55a256..0000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/integration.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Integration - -on: - pull_request: - -jobs: - build: - name: Test - runs-on: ubuntu-22.04 - strategy: - max-parallel: 10 - matrix: - php: ['7.2', '7.3', '7.4', '8.0', '8.1'] - - steps: - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - coverage: none - - - name: Checkout code - uses: actions/checkout@v3 - - - name: Download dependencies - uses: ramsey/composer-install@v1 - with: - composer-options: --no-interaction --optimize-autoloader - - - name: Start server - run: php -S 127.0.0.1:10002 tests/Integration/server.php & - - - name: Run tests - env: - TEST_SERVER: 127.0.0.1:10002 - run: ./vendor/bin/phpunit --testsuite Integration diff --git a/vendor/guzzlehttp/psr7/.github/workflows/static.yml b/vendor/guzzlehttp/psr7/.github/workflows/static.yml deleted file mode 100644 index f00351b..0000000 --- a/vendor/guzzlehttp/psr7/.github/workflows/static.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Static analysis - -on: - pull_request: - -jobs: - php-cs-fixer: - name: PHP-CS-Fixer - runs-on: ubuntu-22.04 - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.4' - coverage: none - extensions: mbstring - - - name: Download dependencies - run: composer update --no-interaction --no-progress - - - name: Download PHP CS Fixer - run: composer require "friendsofphp/php-cs-fixer:2.18.4" - - - name: Execute PHP CS Fixer - run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run diff --git a/vendor/guzzlehttp/psr7/.php_cs.dist b/vendor/guzzlehttp/psr7/.php_cs.dist deleted file mode 100644 index e4f0bd5..0000000 --- a/vendor/guzzlehttp/psr7/.php_cs.dist +++ /dev/null @@ -1,56 +0,0 @@ -setRiskyAllowed(true) - ->setRules([ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'concat_space' => ['spacing' => 'one'], - 'declare_strict_types' => false, - 'final_static_access' => true, - 'fully_qualified_strict_types' => true, - 'header_comment' => false, - 'is_null' => ['use_yoda_style' => true], - 'list_syntax' => ['syntax' => 'long'], - 'lowercase_cast' => true, - 'magic_method_casing' => true, - 'modernize_types_casting' => true, - 'multiline_comment_opening_closing' => true, - 'no_alias_functions' => true, - 'no_alternative_syntax' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_blank_lines' => true, - 'no_leading_import_slash' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unset_cast' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'ordered_imports' => true, - 'php_unit_ordered_covers' => true, - 'php_unit_test_annotation' => ['style' => 'prefix'], - 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], - 'phpdoc_align' => ['align' => 'vertical'], - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_trim' => true, - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types' => true, - 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], - 'phpdoc_var_without_name' => true, - 'single_trait_insert_per_statement' => true, - 'standardize_not_equals' => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__.'/src') - ->in(__DIR__.'/tests') - ->name('*.php') - ) -; - -return $config; diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md index 9b2b65c..fa716c0 100644 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ b/vendor/guzzlehttp/psr7/CHANGELOG.md @@ -1,50 +1,142 @@ # Change Log - All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## Unreleased -## 1.9.1 - 2023-04-17 +## 2.5.0 - 2023-04-17 + +### Changed + +- Adjusted `psr/http-message` version constraint to `^1.1 || ^2.0` + +## 2.4.5 - 2023-04-17 ### Fixed +- Prevent possible warnings on unset variables in `ServerRequest::normalizeNestedFileSpec` +- Fixed `Message::bodySummary` when `preg_match` fails - Fixed header validation issue -## 1.9.0 - 2022-06-20 +## 2.4.4 - 2023-03-09 + +### Changed + +- Removed the need for `AllowDynamicProperties` in `LazyOpenStream` + +## 2.4.3 - 2022-10-26 + +### Changed + +- Replaced `sha1(uniqid())` by `bin2hex(random_bytes(20))` + +## 2.4.2 - 2022-10-25 + +### Fixed + +- Fixed erroneous behaviour when combining host and relative path + +## 2.4.1 - 2022-08-28 + +### Fixed + +- Rewind body before reading in `Message::bodySummary` + +## 2.4.0 - 2022-06-20 ### Added +- Added provisional PHP 8.2 support - Added `UriComparator::isCrossOrigin` method -## 1.8.5 - 2022-03-20 +## 2.3.0 - 2022-06-09 + +### Fixed + +- Added `Header::splitList` method +- Added `Utils::tryGetContents` method +- Improved `Stream::getContents` method +- Updated mimetype mappings + +## 2.2.2 - 2022-06-08 + +### Fixed + +- Fix `Message::parseRequestUri` for numeric headers +- Re-wrap exceptions thrown in `fread` into runtime exceptions +- Throw an exception when multipart options is misformatted + +## 2.2.1 - 2022-03-20 ### Fixed - Correct header value validation -## 1.8.4 - 2022-03-20 +## 2.2.0 - 2022-03-20 + +### Added + +- A more compressive list of mime types +- Add JsonSerializable to Uri +- Missing return types + +### Fixed + +- Bug MultipartStream no `uri` metadata +- Bug MultipartStream with filename for `data://` streams +- Fixed new line handling in MultipartStream +- Reduced RAM usage when copying streams +- Updated parsing in `Header::normalize()` + +## 2.1.1 - 2022-03-20 ### Fixed - Validate header values properly -## 1.8.3 - 2021-10-05 +## 2.1.0 - 2021-10-06 + +### Changed + +- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic + `InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former + for backwards compatibility. Callers relying on the exception being thrown to detect invalid + URIs should catch the new exception. ### Fixed - Return `null` in caching stream size if remote size is `null` -## 1.8.2 - 2021-04-26 +## 2.0.0 - 2021-06-30 + +Identical to the RC release. + +## 2.0.0@RC-1 - 2021-04-29 ### Fixed - Handle possibly unset `url` in `stream_get_meta_data` +## 2.0.0@beta-1 - 2021-03-21 + +### Added + +- PSR-17 factories +- Made classes final +- PHP7 type hints + +### Changed + +- When building a query string, booleans are represented as 1 and 0. + +### Removed + +- PHP < 7.2 support +- All functions in the `GuzzleHttp\Psr7` namespace + ## 1.8.1 - 2021-03-21 ### Fixed diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md index 64776cb..9566a7d 100644 --- a/vendor/guzzlehttp/psr7/README.md +++ b/vendor/guzzlehttp/psr7/README.md @@ -4,9 +4,15 @@ This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/) message implementation, several stream decorators, and some helpful functionality like query string parsing. +![CI](https://github.com/guzzle/psr7/workflows/CI/badge.svg) +![Static analysis](https://github.com/guzzle/psr7/workflows/Static%20analysis/badge.svg) -[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7) +# Installation + +```shell +composer require guzzlehttp/psr7 +``` # Stream implementation @@ -130,10 +136,9 @@ $fnStream->rewind(); `GuzzleHttp\Psr7\InflateStream` -Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. +Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content. -This stream decorator skips the first 10 bytes of the given stream to remove -the gzip header, converts the provided stream to a PHP stream resource, +This stream decorator converts the provided stream to a PHP stream resource, then appends the zlib.inflate filter. The stream is then converted back to a Guzzle stream resource to be used as a Guzzle stream. @@ -246,6 +251,8 @@ class EofCallbackStream implements StreamInterface private $callback; + private $stream; + public function __construct(StreamInterface $stream, callable $cb) { $this->stream = $stream; @@ -381,10 +388,28 @@ of the header. When a parameter does not contain a value, but just contains a key, this function will inject a key with a '' string value. -## `GuzzleHttp\Psr7\Header::normalize` +## `GuzzleHttp\Psr7\Header::splitList` + +`public static function splitList(string|string[] $header): string[]` + +Splits a HTTP header defined to contain a comma-separated list into +each individual value: + +``` +$knownEtags = Header::splitList($request->getHeader('if-none-match')); +``` + +Example headers include `accept`, `cache-control` and `if-none-match`. + + +## `GuzzleHttp\Psr7\Header::normalize` (deprecated) `public static function normalize(string|array $header): array` +`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist) +which performs the same operation with a cleaned up API and improved +documentation. + Converts an array of header values that may contain comma separated headers into an array of headers with no comma separated values. @@ -528,6 +553,17 @@ When fopen fails, PHP normally raises a warning. This function adds an error handler that checks for errors and throws an exception instead. +## `GuzzleHttp\Psr7\Utils::tryGetContents` + +`public static function tryGetContents(resource $stream): string` + +Safely gets the contents of a given stream. + +When stream_get_contents fails, PHP normally raises a warning. This +function adds an error handler that checks for errors and throws an +exception instead. + + ## `GuzzleHttp\Psr7\Utils::uriFor` `public static function uriFor(string|UriInterface $uri): UriInterface` @@ -555,7 +591,7 @@ Maps a file extensions to a mimetype. ## Upgrading from Function API -The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience: +The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience: | Original Function | Replacement Method | |----------------|----------------| diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json index 2607f22..d51dd62 100644 --- a/vendor/guzzlehttp/psr7/composer.json +++ b/vendor/guzzlehttp/psr7/composer.json @@ -1,7 +1,16 @@ { "name": "guzzlehttp/psr7", "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"], + "keywords": [ + "request", + "response", + "message", + "stream", + "http", + "uri", + "url", + "psr-7" + ], "license": "MIT", "authors": [ { @@ -33,39 +42,52 @@ "name": "Tobias Schultze", "email": "webmaster@tubo-world.de", "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0", - "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10", - "ext-zlib": "*" + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" }, "provide": { + "psr/http-factory-implementation": "1.0", "psr/http-message-implementation": "1.0" }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.1", + "http-interop/http-factory-tests": "^0.9", + "phpunit/phpunit": "^8.5.29 || ^9.5.23" + }, "suggest": { "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" }, "autoload": { "psr-4": { "GuzzleHttp\\Psr7\\": "src/" - }, - "files": ["src/functions_include.php"] + } }, "autoload-dev": { "psr-4": { "GuzzleHttp\\Tests\\Psr7\\": "tests/" } }, + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "config": { - "preferred-install": "dist", - "sort-packages": true, "allow-plugins": { "bamarni/composer-bin-plugin": true - } + }, + "preferred-install": "dist", + "sort-packages": true } } diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php index fa9153d..cbcfaee 100644 --- a/vendor/guzzlehttp/psr7/src/AppendStream.php +++ b/vendor/guzzlehttp/psr7/src/AppendStream.php @@ -1,5 +1,7 @@ rewind(); return $this->getContents(); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } @@ -48,7 +57,7 @@ class AppendStream implements StreamInterface * * @throws \InvalidArgumentException if the stream is not readable */ - public function addStream(StreamInterface $stream) + public function addStream(StreamInterface $stream): void { if (!$stream->isReadable()) { throw new \InvalidArgumentException('Each stream must be readable'); @@ -62,17 +71,15 @@ class AppendStream implements StreamInterface $this->streams[] = $stream; } - public function getContents() + public function getContents(): string { return Utils::copyToString($this); } /** * Closes each attached stream. - * - * {@inheritdoc} */ - public function close() + public function close(): void { $this->pos = $this->current = 0; $this->seekable = true; @@ -88,8 +95,6 @@ class AppendStream implements StreamInterface * Detaches each attached stream. * * Returns null as it's not clear which underlying stream resource to return. - * - * {@inheritdoc} */ public function detach() { @@ -105,7 +110,7 @@ class AppendStream implements StreamInterface return null; } - public function tell() + public function tell(): int { return $this->pos; } @@ -115,10 +120,8 @@ class AppendStream implements StreamInterface * * If any of the streams do not return a valid number, then the size of the * append stream cannot be determined and null is returned. - * - * {@inheritdoc} */ - public function getSize() + public function getSize(): ?int { $size = 0; @@ -133,24 +136,22 @@ class AppendStream implements StreamInterface return $size; } - public function eof() + public function eof(): bool { return !$this->streams || ($this->current >= count($this->streams) - 1 && $this->streams[$this->current]->eof()); } - public function rewind() + public function rewind(): void { $this->seek(0); } /** * Attempts to seek to the given position. Only supports SEEK_SET. - * - * {@inheritdoc} */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { if (!$this->seekable) { throw new \RuntimeException('This AppendStream is not seekable'); @@ -181,10 +182,8 @@ class AppendStream implements StreamInterface /** * Reads from all of the appended streams until the length is met or EOF. - * - * {@inheritdoc} */ - public function read($length) + public function read($length): string { $buffer = ''; $total = count($this->streams) - 1; @@ -192,7 +191,6 @@ class AppendStream implements StreamInterface $progressToNext = false; while ($remaining > 0) { - // Progress to the next stream if needed. if ($progressToNext || $this->streams[$this->current]->eof()) { $progressToNext = false; @@ -204,8 +202,7 @@ class AppendStream implements StreamInterface $result = $this->streams[$this->current]->read($remaining); - // Using a loose comparison here to match on '', false, and null - if ($result == null) { + if ($result === '') { $progressToNext = true; continue; } @@ -219,26 +216,31 @@ class AppendStream implements StreamInterface return $buffer; } - public function isReadable() + public function isReadable(): bool { return true; } - public function isWritable() + public function isWritable(): bool { return false; } - public function isSeekable() + public function isSeekable(): bool { return $this->seekable; } - public function write($string) + public function write($string): int { throw new \RuntimeException('Cannot write to an AppendStream'); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return $key ? null : []; diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php index 783859c..21be8c0 100644 --- a/vendor/guzzlehttp/psr7/src/BufferStream.php +++ b/vendor/guzzlehttp/psr7/src/BufferStream.php @@ -1,5 +1,7 @@ hwm = $hwm; } - public function __toString() + public function __toString(): string { return $this->getContents(); } - public function getContents() + public function getContents(): string { $buffer = $this->buffer; $this->buffer = ''; @@ -44,7 +47,7 @@ class BufferStream implements StreamInterface return $buffer; } - public function close() + public function close(): void { $this->buffer = ''; } @@ -56,42 +59,42 @@ class BufferStream implements StreamInterface return null; } - public function getSize() + public function getSize(): ?int { return strlen($this->buffer); } - public function isReadable() + public function isReadable(): bool { return true; } - public function isWritable() + public function isWritable(): bool { return true; } - public function isSeekable() + public function isSeekable(): bool { return false; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { throw new \RuntimeException('Cannot seek a BufferStream'); } - public function eof() + public function eof(): bool { return strlen($this->buffer) === 0; } - public function tell() + public function tell(): int { throw new \RuntimeException('Cannot determine the position of a BufferStream'); } @@ -99,7 +102,7 @@ class BufferStream implements StreamInterface /** * Reads data from the buffer. */ - public function read($length) + public function read($length): string { $currentLength = strlen($this->buffer); @@ -119,21 +122,25 @@ class BufferStream implements StreamInterface /** * Writes data to the buffer. */ - public function write($string) + public function write($string): int { $this->buffer .= $string; - // TODO: What should happen here? if (strlen($this->buffer) >= $this->hwm) { - return false; + return 0; } return strlen($string); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { - if ($key == 'hwm') { + if ($key === 'hwm') { return $this->hwm; } diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php index febade9..f34722c 100644 --- a/vendor/guzzlehttp/psr7/src/CachingStream.php +++ b/vendor/guzzlehttp/psr7/src/CachingStream.php @@ -1,5 +1,7 @@ stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+')); } - public function getSize() + public function getSize(): ?int { $remoteSize = $this->remoteStream->getSize(); @@ -45,18 +50,18 @@ class CachingStream implements StreamInterface return max($this->stream->getSize(), $remoteSize); } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { - if ($whence == SEEK_SET) { + if ($whence === SEEK_SET) { $byte = $offset; - } elseif ($whence == SEEK_CUR) { + } elseif ($whence === SEEK_CUR) { $byte = $offset + $this->tell(); - } elseif ($whence == SEEK_END) { + } elseif ($whence === SEEK_END) { $size = $this->remoteStream->getSize(); if ($size === null) { $size = $this->cacheEntireStream(); @@ -81,7 +86,7 @@ class CachingStream implements StreamInterface } } - public function read($length) + public function read($length): string { // Perform a regular read on any previously read data from the buffer $data = $this->stream->read($length); @@ -110,7 +115,7 @@ class CachingStream implements StreamInterface return $data; } - public function write($string) + public function write($string): int { // When appending to the end of the currently read stream, you'll want // to skip bytes from being read from the remote stream to emulate @@ -124,7 +129,7 @@ class CachingStream implements StreamInterface return $this->stream->write($string); } - public function eof() + public function eof(): bool { return $this->stream->eof() && $this->remoteStream->eof(); } @@ -132,12 +137,13 @@ class CachingStream implements StreamInterface /** * Close both the remote stream and buffer stream */ - public function close() + public function close(): void { - $this->remoteStream->close() && $this->stream->close(); + $this->remoteStream->close(); + $this->stream->close(); } - private function cacheEntireStream() + private function cacheEntireStream(): int { $target = new FnStream(['write' => 'strlen']); Utils::copyToStream($this, $target); diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php index 9f7420c..6e3d209 100644 --- a/vendor/guzzlehttp/psr7/src/DroppingStream.php +++ b/vendor/guzzlehttp/psr7/src/DroppingStream.php @@ -1,5 +1,7 @@ stream = $stream; $this->maxLength = $maxLength; } - public function write($string) + public function write($string): int { $diff = $this->maxLength - $this->stream->getSize(); diff --git a/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php new file mode 100644 index 0000000..3a08477 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/Exception/MalformedUriException.php @@ -0,0 +1,14 @@ + */ private $methods; - /** @var array Methods that must be implemented in the given array */ - private static $slots = ['__toString', 'close', 'detach', 'rewind', - 'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write', - 'isReadable', 'read', 'getContents', 'getMetadata']; - /** - * @param array $methods Hash of method name to a callable. + * @param array $methods Hash of method name to a callable. */ public function __construct(array $methods) { @@ -40,7 +42,7 @@ class FnStream implements StreamInterface * * @throws \BadMethodCallException */ - public function __get($name) + public function __get(string $name): void { throw new \BadMethodCallException(str_replace('_fn_', '', $name) . '() is not implemented in the FnStream'); @@ -61,7 +63,7 @@ class FnStream implements StreamInterface * * @throws \LogicException */ - public function __wakeup() + public function __wakeup(): void { throw new \LogicException('FnStream should never be unserialized'); } @@ -70,8 +72,8 @@ class FnStream implements StreamInterface * Adds custom functionality to an underlying stream by intercepting * specific method calls. * - * @param StreamInterface $stream Stream to decorate - * @param array $methods Hash of method name to a closure + * @param StreamInterface $stream Stream to decorate + * @param array $methods Hash of method name to a closure * * @return FnStream */ @@ -79,21 +81,31 @@ class FnStream implements StreamInterface { // If any of the required methods were not provided, then simply // proxy to the decorated stream. - foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { - $methods[$diff] = [$stream, $diff]; + foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) { + /** @var callable $callable */ + $callable = [$stream, $diff]; + $methods[$diff] = $callable; } return new self($methods); } - public function __toString() + public function __toString(): string { - return call_user_func($this->_fn___toString); + try { + return call_user_func($this->_fn___toString); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); + return ''; + } } - public function close() + public function close(): void { - return call_user_func($this->_fn_close); + call_user_func($this->_fn_close); } public function detach() @@ -101,61 +113,66 @@ class FnStream implements StreamInterface return call_user_func($this->_fn_detach); } - public function getSize() + public function getSize(): ?int { return call_user_func($this->_fn_getSize); } - public function tell() + public function tell(): int { return call_user_func($this->_fn_tell); } - public function eof() + public function eof(): bool { return call_user_func($this->_fn_eof); } - public function isSeekable() + public function isSeekable(): bool { return call_user_func($this->_fn_isSeekable); } - public function rewind() + public function rewind(): void { call_user_func($this->_fn_rewind); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { call_user_func($this->_fn_seek, $offset, $whence); } - public function isWritable() + public function isWritable(): bool { return call_user_func($this->_fn_isWritable); } - public function write($string) + public function write($string): int { return call_user_func($this->_fn_write, $string); } - public function isReadable() + public function isReadable(): bool { return call_user_func($this->_fn_isReadable); } - public function read($length) + public function read($length): string { return call_user_func($this->_fn_read, $length); } - public function getContents() + public function getContents(): string { return call_user_func($this->_fn_getContents); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return call_user_func($this->_fn_getMetadata, $key); diff --git a/vendor/guzzlehttp/psr7/src/Header.php b/vendor/guzzlehttp/psr7/src/Header.php index 865d742..4d7005b 100644 --- a/vendor/guzzlehttp/psr7/src/Header.php +++ b/vendor/guzzlehttp/psr7/src/Header.php @@ -1,5 +1,7 @@ ]+>|[^=]+/', $kvp, $matches)) { - $m = $matches[0]; - if (isset($m[1])) { - $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); - } else { - $part[] = trim($m[0], $trimmed); + foreach ((array) $header as $value) { + foreach (self::splitList($value) as $val) { + $part = []; + foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { + if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { + $m = $matches[0]; + if (isset($m[1])) { + $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); + } else { + $part[] = trim($m[0], $trimmed); + } } } - } - if ($part) { - $params[] = $part; + if ($part) { + $params[] = $part; + } } } @@ -45,24 +47,85 @@ final class Header * * @param string|array $header Header to normalize. * - * @return array Returns the normalized header field values. + * @deprecated Use self::splitList() instead. */ - public static function normalize($header) + public static function normalize($header): array { - if (!is_array($header)) { - return array_map('trim', explode(',', $header)); + $result = []; + foreach ((array) $header as $value) { + foreach (self::splitList($value) as $parsed) { + $result[] = $parsed; + } + } + + return $result; + } + + /** + * Splits a HTTP header defined to contain a comma-separated list into + * each individual value. Empty values will be removed. + * + * Example headers include 'accept', 'cache-control' and 'if-none-match'. + * + * This method must not be used to parse headers that are not defined as + * a list, such as 'user-agent' or 'set-cookie'. + * + * @param string|string[] $values Header value as returned by MessageInterface::getHeader() + * + * @return string[] + */ + public static function splitList($values): array + { + if (!\is_array($values)) { + $values = [$values]; } $result = []; - foreach ($header as $value) { - foreach ((array) $value as $v) { - if (strpos($v, ',') === false) { - $result[] = $v; + foreach ($values as $value) { + if (!\is_string($value)) { + throw new \TypeError('$header must either be a string or an array containing strings.'); + } + + $v = ''; + $isQuoted = false; + $isEscaped = false; + for ($i = 0, $max = \strlen($value); $i < $max; $i++) { + if ($isEscaped) { + $v .= $value[$i]; + $isEscaped = false; + continue; } - foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { - $result[] = trim($vv); + + if (!$isQuoted && $value[$i] === ',') { + $v = \trim($v); + if ($v !== '') { + $result[] = $v; + } + + $v = ''; + continue; } + + if ($isQuoted && $value[$i] === '\\') { + $isEscaped = true; + $v .= $value[$i]; + + continue; + } + if ($value[$i] === '"') { + $isQuoted = !$isQuoted; + $v .= $value[$i]; + + continue; + } + + $v .= $value[$i]; + } + + $v = \trim($v); + if ($v !== '') { + $result[] = $v; } } diff --git a/vendor/guzzlehttp/psr7/src/HttpFactory.php b/vendor/guzzlehttp/psr7/src/HttpFactory.php new file mode 100644 index 0000000..30be222 --- /dev/null +++ b/vendor/guzzlehttp/psr7/src/HttpFactory.php @@ -0,0 +1,100 @@ +getSize(); + } + + return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType); + } + + public function createStream(string $content = ''): StreamInterface + { + return Utils::streamFor($content); + } + + public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface + { + try { + $resource = Utils::tryFopen($file, $mode); + } catch (\RuntimeException $e) { + if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) { + throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e); + } + + throw $e; + } + + return Utils::streamFor($resource); + } + + public function createStreamFromResource($resource): StreamInterface + { + return Utils::streamFor($resource); + } + + public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface + { + if (empty($method)) { + if (!empty($serverParams['REQUEST_METHOD'])) { + $method = $serverParams['REQUEST_METHOD']; + } else { + throw new \InvalidArgumentException('Cannot determine HTTP method'); + } + } + + return new ServerRequest($method, $uri, [], null, '1.1', $serverParams); + } + + public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface + { + return new Response($code, [], null, '1.1', $reasonPhrase); + } + + public function createRequest(string $method, $uri): RequestInterface + { + return new Request($method, $uri); + } + + public function createUri(string $uri = ''): UriInterface + { + return new Uri($uri); + } +} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php index 0cbd2cc..8e00f1c 100644 --- a/vendor/guzzlehttp/psr7/src/InflateStream.php +++ b/vendor/guzzlehttp/psr7/src/InflateStream.php @@ -1,56 +1,37 @@ read(10); - $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); - // Skip the header, that is 10 + length of filename + 1 (nil) bytes - $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); $resource = StreamWrapper::getResource($stream); - stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); + // Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data + // See http://www.zlib.net/manual.html#Advanced definition of inflateInit2 + // "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection" + // Default window size is 15. + stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]); $this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource)); } - - /** - * @param StreamInterface $stream - * @param $header - * - * @return int - */ - private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) - { - $filename_header_length = 0; - - if (substr(bin2hex($header), 6, 2) === '08') { - // we have a filename, read until nil - $filename_header_length = 1; - while ($stream->read(1) !== chr(0)) { - $filename_header_length++; - } - } - - return $filename_header_length; - } } diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php index 911e127..f6c8490 100644 --- a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +++ b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php @@ -1,5 +1,7 @@ filename = $filename; $this->mode = $mode; + + // unsetting the property forces the first access to go through + // __get(). + unset($this->stream); } /** * Creates the underlying stream lazily when required. - * - * @return StreamInterface */ - protected function createStream() + protected function createStream(): StreamInterface { return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode)); } diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php index 1173ec4..fb22325 100644 --- a/vendor/guzzlehttp/psr7/src/LimitStream.php +++ b/vendor/guzzlehttp/psr7/src/LimitStream.php @@ -1,15 +1,15 @@ stream = $stream; $this->setLimit($limit); $this->setOffset($offset); } - public function eof() + public function eof(): bool { // Always return true if the underlying stream is EOF if ($this->stream->eof()) { @@ -44,7 +47,7 @@ class LimitStream implements StreamInterface } // No limit and the underlying stream is not at EOF - if ($this->limit == -1) { + if ($this->limit === -1) { return false; } @@ -53,13 +56,12 @@ class LimitStream implements StreamInterface /** * Returns the size of the limited subset of data - * {@inheritdoc} */ - public function getSize() + public function getSize(): ?int { if (null === ($length = $this->stream->getSize())) { return null; - } elseif ($this->limit == -1) { + } elseif ($this->limit === -1) { return $length - $this->offset; } else { return min($this->limit, $length - $this->offset); @@ -68,9 +70,8 @@ class LimitStream implements StreamInterface /** * Allow for a bounded seek on the read limited stream - * {@inheritdoc} */ - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { if ($whence !== SEEK_SET || $offset < 0) { throw new \RuntimeException(sprintf( @@ -93,9 +94,8 @@ class LimitStream implements StreamInterface /** * Give a relative tell() - * {@inheritdoc} */ - public function tell() + public function tell(): int { return $this->stream->tell() - $this->offset; } @@ -107,7 +107,7 @@ class LimitStream implements StreamInterface * * @throws \RuntimeException if the stream cannot be seeked. */ - public function setOffset($offset) + public function setOffset(int $offset): void { $current = $this->stream->tell(); @@ -132,14 +132,14 @@ class LimitStream implements StreamInterface * @param int $limit Number of bytes to allow to be read from the stream. * Use -1 for no limit. */ - public function setLimit($limit) + public function setLimit(int $limit): void { $this->limit = $limit; } - public function read($length) + public function read($length): string { - if ($this->limit == -1) { + if ($this->limit === -1) { return $this->stream->read($length); } diff --git a/vendor/guzzlehttp/psr7/src/Message.php b/vendor/guzzlehttp/psr7/src/Message.php index 516d1cb..c1e15f8 100644 --- a/vendor/guzzlehttp/psr7/src/Message.php +++ b/vendor/guzzlehttp/psr7/src/Message.php @@ -1,5 +1,7 @@ getMethod() . ' ' @@ -52,10 +52,8 @@ final class Message * * @param MessageInterface $message The message to get the body summary * @param int $truncateAt The maximum allowed size of the summary - * - * @return string|null */ - public static function bodySummary(MessageInterface $message, $truncateAt = 120) + public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string { $body = $message->getBody(); @@ -69,6 +67,7 @@ final class Message return null; } + $body->rewind(); $summary = $body->read($truncateAt); $body->rewind(); @@ -78,7 +77,7 @@ final class Message // Matches any printable character, including unicode characters: // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) { + if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) { return null; } @@ -95,7 +94,7 @@ final class Message * * @throws \RuntimeException */ - public static function rewindBody(MessageInterface $message) + public static function rewindBody(MessageInterface $message): void { $body = $message->getBody(); @@ -112,10 +111,8 @@ final class Message * array values, and a "body" key containing the body of the message. * * @param string $message HTTP request or response to parse. - * - * @return array */ - public static function parseMessage($message) + public static function parseMessage(string $message): array { if (!$message) { throw new \InvalidArgumentException('Invalid message'); @@ -129,7 +126,7 @@ final class Message throw new \InvalidArgumentException('Invalid message: Missing header delimiter'); } - list($rawHeaders, $body) = $messageParts; + [$rawHeaders, $body] = $messageParts; $rawHeaders .= "\r\n"; // Put back the delimiter we split previously $headerParts = preg_split("/\r?\n/", $rawHeaders, 2); @@ -137,7 +134,7 @@ final class Message throw new \InvalidArgumentException('Invalid message: Missing status line'); } - list($startLine, $rawHeaders) = $headerParts; + [$startLine, $rawHeaders] = $headerParts; if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') { // Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0 @@ -175,12 +172,13 @@ final class Message * * @param string $path Path from the start-line * @param array $headers Array of headers (each value an array). - * - * @return string */ - public static function parseRequestUri($path, array $headers) + public static function parseRequestUri(string $path, array $headers): string { $hostKey = array_filter(array_keys($headers), function ($k) { + // Numeric array keys are converted to int by PHP. + $k = (string) $k; + return strtolower($k) === 'host'; }); @@ -199,10 +197,8 @@ final class Message * Parses a request message string into a request object. * * @param string $message Request message string. - * - * @return Request */ - public static function parseRequest($message) + public static function parseRequest(string $message): RequestInterface { $data = self::parseMessage($message); $matches = []; @@ -227,10 +223,8 @@ final class Message * Parses a response message string into a response object. * * @param string $message Response message string. - * - * @return Response */ - public static function parseResponse($message) + public static function parseResponse(string $message): ResponseInterface { $data = self::parseMessage($message); // According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space @@ -246,7 +240,7 @@ final class Message $data['headers'], $data['body'], explode('/', $parts[0])[1], - isset($parts[2]) ? $parts[2] : null + $parts[2] ?? null ); } } diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php index 0bbd63e..464bdfa 100644 --- a/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ b/vendor/guzzlehttp/psr7/src/MessageTrait.php @@ -1,7 +1,10 @@ array of values */ + /** @var array Map of all registered headers, as original name => array of values */ private $headers = []; - /** @var array Map of lowercase header name => original name at registration */ + /** @var array Map of lowercase header name => original name at registration */ private $headerNames = []; /** @var string */ @@ -21,12 +24,12 @@ trait MessageTrait /** @var StreamInterface|null */ private $stream; - public function getProtocolVersion() + public function getProtocolVersion(): string { return $this->protocol; } - public function withProtocolVersion($version) + public function withProtocolVersion($version): MessageInterface { if ($this->protocol === $version) { return $this; @@ -37,17 +40,17 @@ trait MessageTrait return $new; } - public function getHeaders() + public function getHeaders(): array { return $this->headers; } - public function hasHeader($header) + public function hasHeader($header): bool { return isset($this->headerNames[strtolower($header)]); } - public function getHeader($header) + public function getHeader($header): array { $header = strtolower($header); @@ -60,12 +63,12 @@ trait MessageTrait return $this->headers[$header]; } - public function getHeaderLine($header) + public function getHeaderLine($header): string { return implode(', ', $this->getHeader($header)); } - public function withHeader($header, $value) + public function withHeader($header, $value): MessageInterface { $this->assertHeader($header); $value = $this->normalizeHeaderValue($value); @@ -81,7 +84,7 @@ trait MessageTrait return $new; } - public function withAddedHeader($header, $value) + public function withAddedHeader($header, $value): MessageInterface { $this->assertHeader($header); $value = $this->normalizeHeaderValue($value); @@ -99,7 +102,7 @@ trait MessageTrait return $new; } - public function withoutHeader($header) + public function withoutHeader($header): MessageInterface { $normalized = strtolower($header); @@ -115,7 +118,7 @@ trait MessageTrait return $new; } - public function getBody() + public function getBody(): StreamInterface { if (!$this->stream) { $this->stream = Utils::streamFor(''); @@ -124,7 +127,7 @@ trait MessageTrait return $this->stream; } - public function withBody(StreamInterface $body) + public function withBody(StreamInterface $body): MessageInterface { if ($body === $this->stream) { return $this; @@ -135,15 +138,16 @@ trait MessageTrait return $new; } - private function setHeaders(array $headers) + /** + * @param array $headers + */ + private function setHeaders(array $headers): void { $this->headerNames = $this->headers = []; foreach ($headers as $header => $value) { - if (is_int($header)) { - // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec - // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass. - $header = (string) $header; - } + // Numeric array keys are converted to int by PHP. + $header = (string) $header; + $this->assertHeader($header); $value = $this->normalizeHeaderValue($value); $normalized = strtolower($header); @@ -162,7 +166,7 @@ trait MessageTrait * * @return string[] */ - private function normalizeHeaderValue($value) + private function normalizeHeaderValue($value): array { if (!is_array($value)) { return $this->trimAndValidateHeaderValues([$value]); @@ -189,7 +193,7 @@ trait MessageTrait * * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 */ - private function trimAndValidateHeaderValues(array $values) + private function trimAndValidateHeaderValues(array $values): array { return array_map(function ($value) { if (!is_scalar($value) && null !== $value) { @@ -210,10 +214,8 @@ trait MessageTrait * @see https://tools.ietf.org/html/rfc7230#section-3.2 * * @param mixed $header - * - * @return void */ - private function assertHeader($header) + private function assertHeader($header): void { if (!is_string($header)) { throw new \InvalidArgumentException(sprintf( @@ -222,10 +224,6 @@ trait MessageTrait )); } - if ($header === '') { - throw new \InvalidArgumentException('Header name can not be empty.'); - } - if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) { throw new \InvalidArgumentException( sprintf('"%s" is not valid header name.', $header) @@ -234,10 +232,6 @@ trait MessageTrait } /** - * @param string $value - * - * @return void - * * @see https://tools.ietf.org/html/rfc7230#section-3.2 * * field-value = *( field-content / obs-fold ) @@ -247,7 +241,7 @@ trait MessageTrait * obs-text = %x80-FF * obs-fold = CRLF 1*( SP / HTAB ) */ - private function assertValue($value) + private function assertValue(string $value): void { // The regular expression intentionally does not support the obs-fold production, because as // per RFC 7230#3.2.4: diff --git a/vendor/guzzlehttp/psr7/src/MimeType.php b/vendor/guzzlehttp/psr7/src/MimeType.php index 205c7b1..0debbd1 100644 --- a/vendor/guzzlehttp/psr7/src/MimeType.php +++ b/vendor/guzzlehttp/psr7/src/MimeType.php @@ -1,17 +1,1226 @@ 'application/vnd.1000minds.decision-model+xml', + '3dml' => 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gp', + '3gpp' => 'video/3gpp', + '3mf' => 'model/3mf', + '7z' => 'application/x-7z-compressed', + '7zip' => 'application/x-7z-compressed', + '123' => 'application/vnd.lotus-1-2-3', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/x-acc', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/vnd.nokia.n-gage.ac+xml', + 'ac3' => 'audio/ac3', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'age' => 'application/vnd.age', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/pdf', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'amr' => 'audio/amr', + 'apk' => 'application/vnd.android.package-archive', + 'apng' => 'image/apng', + 'appcache' => 'text/cache-manifest', + 'application' => 'application/x-ms-application', + 'apr' => 'application/vnd.lotus-approach', + 'arc' => 'application/x-freearc', + 'arj' => 'application/x-arj', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomdeleted' => 'application/atomdeleted+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/x-au', + 'avci' => 'image/avci', + 'avcs' => 'image/avcs', + 'avi' => 'video/x-msvideo', + 'avif' => 'image/avif', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azv' => 'image/vnd.airzip.accelerator.azv', + 'azw' => 'application/vnd.amazon.ebook', + 'b16' => 'image/vnd.pco.b16', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bdoc' => 'application/x-bdoc', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmml' => 'application/vnd.balsamiq.bmml+xml', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'bpmn' => 'application/octet-stream', + 'bsp' => 'model/vnd.valve.source.compiled-map', + 'btif' => 'image/prs.btif', + 'buffer' => 'application/octet-stream', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cco' => 'application/x-cocoa', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdfx' => 'application/cdfx+xml', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdr' => 'application/cdr', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cjs' => 'application/node', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/octet-stream', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'coffee' => 'text/coffeescript', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpl' => 'application/cpl+xml', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'crx' => 'application/x-chrome-extension', + 'cryptonote' => 'application/vnd.rig.cryptonote', + 'csh' => 'application/x-csh', + 'csl' => 'application/vnd.citationstyles.style+xml', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'csr' => 'application/octet-stream', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbf' => 'application/vnd.dbf', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'ddf' => 'application/vnd.syncml.dmddf+xml', + 'dds' => 'image/vnd.ms-dds', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'disposition-notification' => 'message/disposition-notification', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/x-apple-diskimage', + 'dmn' => 'application/octet-stream', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dra' => 'audio/vnd.dra', + 'drle' => 'image/dicom-rle', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwd' => 'application/atsc-dwd+xml', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ear' => 'application/java-archive', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'image/emf', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emotionml' => 'application/emotionml+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es' => 'application/ecmascript', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/octet-stream', + 'exi' => 'application/exi', + 'exp' => 'application/express', + 'exr' => 'image/aces', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/mp4', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fdt' => 'application/fdt+xml', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'fits' => 'image/fits', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'fo' => 'application/vnd.software602.filler.form+xml', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'gdoc' => 'application/vnd.google-apps.document', + 'ged' => 'text/vnd.familysearch.gedcom', + 'geo' => 'application/vnd.dynageo', + 'geojson' => 'application/geo+json', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'glb' => 'model/gltf-binary', + 'gltf' => 'model/gltf+json', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gpg' => 'application/gpg-keys', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gsheet' => 'application/vnd.google-apps.spreadsheet', + 'gslides' => 'application/vnd.google-apps.presentation', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/gzip', + 'gzip' => 'application/gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hbs' => 'text/x-handlebars-template', + 'hdd' => 'application/x-virtualbox-hdd', + 'hdf' => 'application/x-hdf', + 'heic' => 'image/heic', + 'heics' => 'image/heic-sequence', + 'heif' => 'image/heif', + 'heifs' => 'image/heif-sequence', + 'hej2' => 'image/hej2k', + 'held' => 'application/atsc-held+xml', + 'hh' => 'text/x-c', + 'hjson' => 'application/hjson', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'hsj2' => 'image/hsj2', + 'htc' => 'text/x-component', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'img' => 'application/octet-stream', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ini' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'its' => 'application/its+xml', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jade' => 'text/jade', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'jardiff' => 'application/x-java-archive-diff', + 'java' => 'text/x-java-source', + 'jhc' => 'image/jphc', + 'jisp' => 'application/vnd.jisp', + 'jls' => 'image/jls', + 'jlt' => 'application/vnd.hp-jlyt', + 'jng' => 'image/x-jng', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpf' => 'image/jpx', + 'jpg' => 'image/jpeg', + 'jpg2' => 'image/jp2', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jph' => 'image/jph', + 'jpm' => 'video/jpm', + 'jpx' => 'image/jpx', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'json5' => 'application/json5', + 'jsonld' => 'application/ld+json', + 'jsonml' => 'application/jsonml+json', + 'jsx' => 'text/jsx', + 'jxr' => 'image/jxr', + 'jxra' => 'image/jxra', + 'jxrs' => 'image/jxrs', + 'jxs' => 'image/jxs', + 'jxsc' => 'image/jxsc', + 'jxsi' => 'image/jxsi', + 'jxss' => 'image/jxss', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kdb' => 'application/octet-stream', + 'kdbx' => 'application/x-keepass2', + 'key' => 'application/x-iwork-keynote-sffkey', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktx2' => 'image/ktx2', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'less' => 'text/less', + 'lgr' => 'application/lgr+xml', + 'lha' => 'application/octet-stream', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'litcoffee' => 'text/coffeescript', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lua' => 'text/x-lua', + 'luac' => 'application/x-lua-bytecode', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/octet-stream', + 'm1v' => 'video/mpeg', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'text/plain', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/x-m4a', + 'm4p' => 'application/mp4', + 'm4s' => 'video/iso.segment', + 'm4u' => 'application/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm21' => 'application/mp21', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'maei' => 'application/mmt-aei+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'manifest' => 'text/cache-manifest', + 'map' => 'application/json', + 'mar' => 'application/octet-stream', + 'markdown' => 'text/markdown', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'md' => 'text/markdown', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'mdx' => 'text/mdx', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mjs' => 'application/javascript', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mkd' => 'text/x-markdown', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mml' => 'text/mathml', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mp21' => 'application/mp21', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpd' => 'application/dash+xml', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpf' => 'application/media-policy-dataset+xml', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msg' => 'application/vnd.ms-outlook', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msl' => 'application/vnd.mobius.msl', + 'msm' => 'application/octet-stream', + 'msp' => 'application/octet-stream', + 'msty' => 'application/vnd.muvee.style', + 'mtl' => 'model/mtl', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musd' => 'application/mmt-usd+xml', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mvt' => 'application/vnd.mapbox-vector-tile', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxmf' => 'audio/mobile-xmf', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nq' => 'application/n-quads', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'nt' => 'application/n-triples', + 'ntf' => 'application/vnd.nitf', + 'numbers' => 'application/x-iwork-numbers-sffnumbers', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obgx' => 'application/vnd.openblox.game+xml', + 'obj' => 'model/obj', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogex' => 'model/vnd.opengex', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'opus' => 'audio/ogg', + 'org' => 'text/x-org', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'osm' => 'application/vnd.openstreetmap.data+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'font/otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'ova' => 'application/x-virtualbox-ova', + 'ovf' => 'application/x-virtualbox-ovf', + 'owl' => 'application/rdf+xml', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p7a' => 'application/x-pkcs7-signature', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'p10' => 'application/x-pkcs10', + 'p12' => 'application/x-pkcs12', + 'pac' => 'application/x-ns-proxy-autoconfig', + 'pages' => 'application/x-iwork-pages-sffpages', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/x-pilot', + 'pde' => 'text/x-processing', + 'pdf' => 'application/pdf', + 'pem' => 'application/x-x509-user-cert', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp', + 'phar' => 'application/octet-stream', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'pkpass' => 'application/vnd.apple.pkpass', + 'pl' => 'application/x-perl', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pm' => 'application/x-perl', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppa' => 'application/vnd.ms-powerpoint', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'model/prc', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'provx' => 'application/provenance+xml', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'application/x-photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'pti' => 'image/prs.pti', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'raml' => 'application/raml+yaml', + 'rapd' => 'application/route-apd+xml', + 'rar' => 'application/x-rar', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'relo' => 'application/p2p-overlay+xml', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'audio/x-pn-realaudio', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'rng' => 'application/xml', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsa' => 'application/x-pkcs7', + 'rsat' => 'application/atsc-rsat+xml', + 'rsd' => 'application/rsd+xml', + 'rsheet' => 'application/urc-ressheet+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', + 'run' => 'application/x-makeself', + 'rusd' => 'application/route-usd+xml', + 'rv' => 'video/vnd.rn-realvideo', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sass' => 'text/x-sass', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scss' => 'text/x-scss', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'sea' => 'application/octet-stream', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'senmlx' => 'application/senml+xml', + 'sensmlx' => 'application/sensml+xml', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shex' => 'text/shex', + 'shf' => 'application/shf+xml', + 'shtml' => 'text/html', + 'sid' => 'image/x-mrsid-image', + 'sieve' => 'application/sieve', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'siv' => 'application/sieve', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slim' => 'text/slim', + 'slm' => 'text/slim', + 'sls' => 'application/route-s-tsid+xml', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spdx' => 'text/spdx', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'sst' => 'application/octet-stream', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'model/stl', + 'stpx' => 'model/step+xml', + 'stpxz' => 'model/step-xml+zip', + 'stpz' => 'model/step+zip', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'styl' => 'text/stylus', + 'stylus' => 'text/stylus', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'swidtag' => 'application/swid+xml', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 't38' => 'image/t38', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tap' => 'image/vnd.tencent.tap', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'td' => 'application/urc-targetdesc+xml', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tfx' => 'image/tiff-fx', + 'tga' => 'image/x-tga', + 'tgz' => 'application/x-tar', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tk' => 'application/x-tcl', + 'tmo' => 'application/vnd.tmobile-livetv', + 'toml' => 'application/toml', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trig' => 'application/trig', + 'trm' => 'application/x-msterminal', + 'ts' => 'video/mp2t', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'font/collection', + 'ttf' => 'font/ttf', + 'ttl' => 'text/turtle', + 'ttml' => 'application/ttml+xml', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u3d' => 'model/u3d', + 'u8dsn' => 'message/global-delivery-status', + 'u8hdr' => 'message/global-headers', + 'u8mdn' => 'message/global-disposition-notification', + 'u8msg' => 'message/global', + 'u32' => 'application/x-authorware-bin', + 'ubj' => 'application/ubjson', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'usdz' => 'model/vnd.usdz+zip', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vbox' => 'application/x-virtualbox-vbox', + 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vdi' => 'application/x-virtualbox-vdi', + 'vds' => 'model/vnd.sap.vds', + 'vhd' => 'application/x-virtualbox-vhd', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vlc' => 'application/videolan', + 'vmdk' => 'application/x-virtualbox-vmdk', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtf' => 'image/vnd.valve.source.texture', + 'vtt' => 'text/vtt', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wadl' => 'application/vnd.sun.wadl+xml', + 'war' => 'application/java-archive', + 'wasm' => 'application/wasm', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webapp' => 'application/x-web-app-manifest+json', + 'webm' => 'video/webm', + 'webmanifest' => 'application/manifest+json', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgt' => 'application/widget', + 'wif' => 'application/watcherinfo+xml', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'image/wmf', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'font/woff', + 'woff2' => 'font/woff2', + 'word' => 'application/msword', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsc' => 'message/vnd.wfa.wsc', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+fastinfoset', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d-vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'x32' => 'application/x-authorware-bin', + 'x_b' => 'model/vnd.parasolid.transmit.binary', + 'x_t' => 'model/vnd.parasolid.transmit.text', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xav' => 'application/xcap-att+xml', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xca' => 'application/xcap-caps+xml', + 'xcs' => 'application/calendar+xml', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xel' => 'application/xcap-el+xml', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/vnd.adobe.xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xl' => 'application/excel', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xns' => 'application/xcap-ns+xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsd' => 'application/xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yaml' => 'text/yaml', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'yml' => 'text/yaml', + 'ymp' => 'text/x-suse-ymp', + 'z' => 'application/x-compress', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + 'zsh' => 'text/x-scriptzsh', + ]; + /** * Determines the mimetype of a file by looking at its extension. * - * @param string $filename - * - * @return string|null + * @link https://raw.githubusercontent.com/jshttp/mime-db/master/db.json */ - public static function fromFilename($filename) + public static function fromFilename(string $filename): ?string { return self::fromExtension(pathinfo($filename, PATHINFO_EXTENSION)); } @@ -19,122 +1228,10 @@ final class MimeType /** * Maps a file extensions to a mimetype. * - * @param string $extension string The file extension. - * - * @return string|null - * - * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types + * @link https://raw.githubusercontent.com/jshttp/mime-db/master/db.json */ - public static function fromExtension($extension) + public static function fromExtension(string $extension): ?string { - static $mimetypes = [ - '3gp' => 'video/3gpp', - '7z' => 'application/x-7z-compressed', - 'aac' => 'audio/x-aac', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'asc' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'atom' => 'application/atom+xml', - 'avi' => 'video/x-msvideo', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bzip2', - 'cer' => 'application/pkix-cert', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'css' => 'text/css', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'deb' => 'application/x-debian-package', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dvi' => 'application/x-dvi', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'etx' => 'text/x-setext', - 'flac' => 'audio/flac', - 'flv' => 'video/x-flv', - 'gif' => 'image/gif', - 'gz' => 'application/gzip', - 'htm' => 'text/html', - 'html' => 'text/html', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ini' => 'text/plain', - 'iso' => 'application/x-iso9660-image', - 'jar' => 'application/java-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'latex' => 'application/x-latex', - 'log' => 'text/plain', - 'm4a' => 'audio/mp4', - 'm4v' => 'video/mp4', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mkv' => 'video/x-matroska', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4v' => 'video/mp4', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'pbm' => 'image/x-portable-bitmap', - 'pdf' => 'application/pdf', - 'pgm' => 'image/x-portable-graymap', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'ppm' => 'image/x-portable-pixmap', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'qt' => 'video/quicktime', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'svg' => 'image/svg+xml', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'torrent' => 'application/x-bittorrent', - 'ttf' => 'application/x-font-ttf', - 'txt' => 'text/plain', - 'wav' => 'audio/x-wav', - 'webm' => 'video/webm', - 'webp' => 'image/webp', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'video/x-ms-wmv', - 'woff' => 'application/x-font-woff', - 'wsdl' => 'application/wsdl+xml', - 'xbm' => 'image/x-xbitmap', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - 'xpm' => 'image/x-xpixmap', - 'xwd' => 'image/x-xwindowdump', - 'yaml' => 'text/yaml', - 'yml' => 'text/yaml', - 'zip' => 'application/zip', - ]; - - $extension = strtolower($extension); - - return isset($mimetypes[$extension]) - ? $mimetypes[$extension] - : null; + return self::MIME_TYPES[strtolower($extension)] ?? null; } } diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php index 5a6079a..3e12b74 100644 --- a/vendor/guzzlehttp/psr7/src/MultipartStream.php +++ b/vendor/guzzlehttp/psr7/src/MultipartStream.php @@ -1,5 +1,7 @@ boundary = $boundary ?: sha1(uniqid('', true)); + $this->boundary = $boundary ?: bin2hex(random_bytes(20)); $this->stream = $this->createStream($elements); } - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() + public function getBoundary(): string { return $this->boundary; } - public function isWritable() + public function isWritable(): bool { return false; } /** * Get the headers needed before transferring the content of a POST file + * + * @param array $headers */ - private function getHeaders(array $headers) + private function getHeaders(array $headers): string { $str = ''; foreach ($headers as $key => $value) { @@ -65,11 +66,14 @@ class MultipartStream implements StreamInterface /** * Create the aggregate stream that will be used to upload the POST data */ - protected function createStream(array $elements) + protected function createStream(array $elements = []): StreamInterface { $stream = new AppendStream(); foreach ($elements as $element) { + if (!is_array($element)) { + throw new \UnexpectedValueException("An array is expected"); + } $this->addElement($stream, $element); } @@ -79,7 +83,7 @@ class MultipartStream implements StreamInterface return $stream; } - private function addElement(AppendStream $stream, array $element) + private function addElement(AppendStream $stream, array $element): void { foreach (['contents', 'name'] as $key) { if (!array_key_exists($key, $element)) { @@ -91,16 +95,16 @@ class MultipartStream implements StreamInterface if (empty($element['filename'])) { $uri = $element['contents']->getMetadata('uri'); - if (substr($uri, 0, 6) !== 'php://') { + if ($uri && \is_string($uri) && \substr($uri, 0, 6) !== 'php://' && \substr($uri, 0, 7) !== 'data://') { $element['filename'] = $uri; } } - list($body, $headers) = $this->createElement( + [$body, $headers] = $this->createElement( $element['name'], $element['contents'], - isset($element['filename']) ? $element['filename'] : null, - isset($element['headers']) ? $element['headers'] : [] + $element['filename'] ?? null, + $element['headers'] ?? [] ); $stream->addStream(Utils::streamFor($this->getHeaders($headers))); @@ -108,10 +112,7 @@ class MultipartStream implements StreamInterface $stream->addStream(Utils::streamFor("\r\n")); } - /** - * @return array - */ - private function createElement($name, StreamInterface $stream, $filename, array $headers) + private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array { // Set a default content-disposition header if one was no provided $disposition = $this->getHeader($headers, 'content-disposition'); @@ -144,7 +145,7 @@ class MultipartStream implements StreamInterface return [$stream, $headers]; } - private function getHeader(array $headers, $key) + private function getHeader(array $headers, string $key) { $lowercaseHeader = strtolower($key); foreach ($headers as $k => $v) { diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php index d66bdde..161a224 100644 --- a/vendor/guzzlehttp/psr7/src/NoSeekStream.php +++ b/vendor/guzzlehttp/psr7/src/NoSeekStream.php @@ -1,24 +1,27 @@ source = $source; - $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; + $this->size = $options['size'] ?? null; + $this->metadata = $options['metadata'] ?? []; $this->buffer = new BufferStream(); } - public function __toString() + public function __toString(): string { try { return Utils::copyToString($this); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function close() + public function close(): void { $this->detach(); } public function detach() { - $this->tellPos = false; + $this->tellPos = 0; $this->source = null; return null; } - public function getSize() + public function getSize(): ?int { return $this->size; } - public function tell() + public function tell(): int { return $this->tellPos; } - public function eof() + public function eof(): bool { - return !$this->source; + return $this->source === null; } - public function isSeekable() + public function isSeekable(): bool { return false; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { throw new \RuntimeException('Cannot seek a PumpStream'); } - public function isWritable() + public function isWritable(): bool { return false; } - public function write($string) + public function write($string): int { throw new \RuntimeException('Cannot write to a PumpStream'); } - public function isReadable() + public function isReadable(): bool { return true; } - public function read($length) + public function read($length): string { $data = $this->buffer->read($length); $readLen = strlen($data); @@ -134,7 +138,7 @@ class PumpStream implements StreamInterface return $data; } - public function getContents() + public function getContents(): string { $result = ''; while (!$this->eof()) { @@ -144,16 +148,21 @@ class PumpStream implements StreamInterface return $result; } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { if (!$key) { return $this->metadata; } - return isset($this->metadata[$key]) ? $this->metadata[$key] : null; + return $this->metadata[$key] ?? null; } - private function pump($length) + private function pump(int $length): void { if ($this->source) { do { diff --git a/vendor/guzzlehttp/psr7/src/Query.php b/vendor/guzzlehttp/psr7/src/Query.php index 5a7cc03..2faab3a 100644 --- a/vendor/guzzlehttp/psr7/src/Query.php +++ b/vendor/guzzlehttp/psr7/src/Query.php @@ -1,5 +1,7 @@ $v) { - $k = $encoder($k); + $k = $encoder((string) $k); if (!is_array($v)) { $qs .= $k; + $v = is_bool($v) ? (int) $v : $v; if ($v !== null) { - $qs .= '=' . $encoder($v); + $qs .= '=' . $encoder((string) $v); } $qs .= '&'; } else { foreach ($v as $vv) { $qs .= $k; + $vv = is_bool($vv) ? (int) $vv : $vv; if ($vv !== null) { - $qs .= '=' . $encoder($vv); + $qs .= '=' . $encoder((string) $vv); } $qs .= '&'; } diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php index c1cdaeb..b17af66 100644 --- a/vendor/guzzlehttp/psr7/src/Request.php +++ b/vendor/guzzlehttp/psr7/src/Request.php @@ -1,5 +1,7 @@ $headers Request headers * @param string|resource|StreamInterface|null $body Request body * @param string $version Protocol version */ public function __construct( - $method, + string $method, $uri, array $headers = [], $body = null, - $version = '1.1' + string $version = '1.1' ) { $this->assertMethod($method); if (!($uri instanceof UriInterface)) { @@ -56,14 +58,14 @@ class Request implements RequestInterface } } - public function getRequestTarget() + public function getRequestTarget(): string { if ($this->requestTarget !== null) { return $this->requestTarget; } $target = $this->uri->getPath(); - if ($target == '') { + if ($target === '') { $target = '/'; } if ($this->uri->getQuery() != '') { @@ -73,7 +75,7 @@ class Request implements RequestInterface return $target; } - public function withRequestTarget($requestTarget) + public function withRequestTarget($requestTarget): RequestInterface { if (preg_match('#\s#', $requestTarget)) { throw new InvalidArgumentException( @@ -86,12 +88,12 @@ class Request implements RequestInterface return $new; } - public function getMethod() + public function getMethod(): string { return $this->method; } - public function withMethod($method) + public function withMethod($method): RequestInterface { $this->assertMethod($method); $new = clone $this; @@ -99,12 +101,12 @@ class Request implements RequestInterface return $new; } - public function getUri() + public function getUri(): UriInterface { return $this->uri; } - public function withUri(UriInterface $uri, $preserveHost = false) + public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface { if ($uri === $this->uri) { return $this; @@ -120,7 +122,7 @@ class Request implements RequestInterface return $new; } - private function updateHostFromUri() + private function updateHostFromUri(): void { $host = $this->uri->getHost(); @@ -143,10 +145,13 @@ class Request implements RequestInterface $this->headers = [$header => [$host]] + $this->headers; } - private function assertMethod($method) + /** + * @param mixed $method + */ + private function assertMethod($method): void { if (!is_string($method) || $method === '') { - throw new \InvalidArgumentException('Method must be a non-empty string.'); + throw new InvalidArgumentException('Method must be a non-empty string.'); } } } diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php index 8c01a0f..4c6ee6f 100644 --- a/vendor/guzzlehttp/psr7/src/Response.php +++ b/vendor/guzzlehttp/psr7/src/Response.php @@ -1,5 +1,7 @@ 'Continue', 101 => 'Switching Protocols', 102 => 'Processing', @@ -34,6 +36,7 @@ class Response implements ResponseInterface 305 => 'Use Proxy', 306 => 'Switch Proxy', 307 => 'Temporary Redirect', + 308 => 'Permanent Redirect', 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', @@ -71,31 +74,30 @@ class Response implements ResponseInterface 506 => 'Variant Also Negotiates', 507 => 'Insufficient Storage', 508 => 'Loop Detected', + 510 => 'Not Extended', 511 => 'Network Authentication Required', ]; /** @var string */ - private $reasonPhrase = ''; + private $reasonPhrase; /** @var int */ - private $statusCode = 200; + private $statusCode; /** * @param int $status Status code - * @param array $headers Response headers + * @param array $headers Response headers * @param string|resource|StreamInterface|null $body Response body * @param string $version Protocol version * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) */ public function __construct( - $status = 200, + int $status = 200, array $headers = [], $body = null, - $version = '1.1', - $reason = null + string $version = '1.1', + string $reason = null ) { - $this->assertStatusCodeIsInteger($status); - $status = (int) $status; $this->assertStatusCodeRange($status); $this->statusCode = $status; @@ -105,8 +107,8 @@ class Response implements ResponseInterface } $this->setHeaders($headers); - if ($reason == '' && isset(self::$phrases[$this->statusCode])) { - $this->reasonPhrase = self::$phrases[$this->statusCode]; + if ($reason == '' && isset(self::PHRASES[$this->statusCode])) { + $this->reasonPhrase = self::PHRASES[$this->statusCode]; } else { $this->reasonPhrase = (string) $reason; } @@ -114,17 +116,17 @@ class Response implements ResponseInterface $this->protocol = $version; } - public function getStatusCode() + public function getStatusCode(): int { return $this->statusCode; } - public function getReasonPhrase() + public function getReasonPhrase(): string { return $this->reasonPhrase; } - public function withStatus($code, $reasonPhrase = '') + public function withStatus($code, $reasonPhrase = ''): ResponseInterface { $this->assertStatusCodeIsInteger($code); $code = (int) $code; @@ -132,21 +134,24 @@ class Response implements ResponseInterface $new = clone $this; $new->statusCode = $code; - if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { - $reasonPhrase = self::$phrases[$new->statusCode]; + if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) { + $reasonPhrase = self::PHRASES[$new->statusCode]; } $new->reasonPhrase = (string) $reasonPhrase; return $new; } - private function assertStatusCodeIsInteger($statusCode) + /** + * @param mixed $statusCode + */ + private function assertStatusCodeIsInteger($statusCode): void { if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) { throw new \InvalidArgumentException('Status code must be an integer value.'); } } - private function assertStatusCodeRange($statusCode) + private function assertStatusCodeRange(int $statusCode): void { if ($statusCode < 100 || $statusCode >= 600) { throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.'); diff --git a/vendor/guzzlehttp/psr7/src/Rfc7230.php b/vendor/guzzlehttp/psr7/src/Rfc7230.php index 51b571f..3022401 100644 --- a/vendor/guzzlehttp/psr7/src/Rfc7230.php +++ b/vendor/guzzlehttp/psr7/src/Rfc7230.php @@ -1,12 +1,16 @@ @,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; - const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; + public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m"; + public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)"; } diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php index e6d26f5..b2aa382 100644 --- a/vendor/guzzlehttp/psr7/src/ServerRequest.php +++ b/vendor/guzzlehttp/psr7/src/ServerRequest.php @@ -1,5 +1,7 @@ $headers Request headers * @param string|resource|StreamInterface|null $body Request body * @param string $version Protocol version * @param array $serverParams Typically the $_SERVER superglobal */ public function __construct( - $method, + string $method, $uri, array $headers = [], $body = null, - $version = '1.1', + string $version = '1.1', array $serverParams = [] ) { $this->serverParams = $serverParams; @@ -78,13 +80,11 @@ class ServerRequest extends Request implements ServerRequestInterface /** * Return an UploadedFile instance array. * - * @param array $files A array which respect $_FILES structure - * - * @return array + * @param array $files An array which respect $_FILES structure * * @throws InvalidArgumentException for unrecognized values */ - public static function normalizeFiles(array $files) + public static function normalizeFiles(array $files): array { $normalized = []; @@ -112,7 +112,7 @@ class ServerRequest extends Request implements ServerRequestInterface * * @param array $value $_FILES struct * - * @return array|UploadedFileInterface + * @return UploadedFileInterface|UploadedFileInterface[] */ private static function createUploadedFileFromSpec(array $value) { @@ -135,21 +135,19 @@ class ServerRequest extends Request implements ServerRequestInterface * Loops through all nested files and returns a normalized array of * UploadedFileInterface instances. * - * @param array $files - * * @return UploadedFileInterface[] */ - private static function normalizeNestedFileSpec(array $files = []) + private static function normalizeNestedFileSpec(array $files = []): array { $normalizedFiles = []; foreach (array_keys($files['tmp_name']) as $key) { $spec = [ 'tmp_name' => $files['tmp_name'][$key], - 'size' => $files['size'][$key], - 'error' => $files['error'][$key], - 'name' => $files['name'][$key], - 'type' => $files['type'][$key], + 'size' => $files['size'][$key] ?? null, + 'error' => $files['error'][$key] ?? null, + 'name' => $files['name'][$key] ?? null, + 'type' => $files['type'][$key] ?? null, ]; $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); } @@ -164,12 +162,10 @@ class ServerRequest extends Request implements ServerRequestInterface * $_COOKIE * $_FILES * $_SERVER - * - * @return ServerRequestInterface */ - public static function fromGlobals() + public static function fromGlobals(): ServerRequestInterface { - $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; + $method = $_SERVER['REQUEST_METHOD'] ?? 'GET'; $headers = getallheaders(); $uri = self::getUriFromGlobals(); $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); @@ -184,7 +180,7 @@ class ServerRequest extends Request implements ServerRequestInterface ->withUploadedFiles(self::normalizeFiles($_FILES)); } - private static function extractHostAndPortFromAuthority($authority) + private static function extractHostAndPortFromAuthority(string $authority): array { $uri = 'http://' . $authority; $parts = parse_url($uri); @@ -192,18 +188,16 @@ class ServerRequest extends Request implements ServerRequestInterface return [null, null]; } - $host = isset($parts['host']) ? $parts['host'] : null; - $port = isset($parts['port']) ? $parts['port'] : null; + $host = $parts['host'] ?? null; + $port = $parts['port'] ?? null; return [$host, $port]; } /** * Get a Uri populated with values from $_SERVER. - * - * @return UriInterface */ - public static function getUriFromGlobals() + public static function getUriFromGlobals(): UriInterface { $uri = new Uri(''); @@ -211,7 +205,7 @@ class ServerRequest extends Request implements ServerRequestInterface $hasPort = false; if (isset($_SERVER['HTTP_HOST'])) { - list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); + [$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']); if ($host !== null) { $uri = $uri->withHost($host); } @@ -247,26 +241,17 @@ class ServerRequest extends Request implements ServerRequestInterface return $uri; } - /** - * {@inheritdoc} - */ - public function getServerParams() + public function getServerParams(): array { return $this->serverParams; } - /** - * {@inheritdoc} - */ - public function getUploadedFiles() + public function getUploadedFiles(): array { return $this->uploadedFiles; } - /** - * {@inheritdoc} - */ - public function withUploadedFiles(array $uploadedFiles) + public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface { $new = clone $this; $new->uploadedFiles = $uploadedFiles; @@ -274,18 +259,12 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getCookieParams() + public function getCookieParams(): array { return $this->cookieParams; } - /** - * {@inheritdoc} - */ - public function withCookieParams(array $cookies) + public function withCookieParams(array $cookies): ServerRequestInterface { $new = clone $this; $new->cookieParams = $cookies; @@ -293,18 +272,12 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getQueryParams() + public function getQueryParams(): array { return $this->queryParams; } - /** - * {@inheritdoc} - */ - public function withQueryParams(array $query) + public function withQueryParams(array $query): ServerRequestInterface { $new = clone $this; $new->queryParams = $query; @@ -314,16 +287,15 @@ class ServerRequest extends Request implements ServerRequestInterface /** * {@inheritdoc} + * + * @return array|object|null */ public function getParsedBody() { return $this->parsedBody; } - /** - * {@inheritdoc} - */ - public function withParsedBody($data) + public function withParsedBody($data): ServerRequestInterface { $new = clone $this; $new->parsedBody = $data; @@ -331,16 +303,15 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } /** * {@inheritdoc} + * + * @return mixed */ public function getAttribute($attribute, $default = null) { @@ -351,10 +322,7 @@ class ServerRequest extends Request implements ServerRequestInterface return $this->attributes[$attribute]; } - /** - * {@inheritdoc} - */ - public function withAttribute($attribute, $value) + public function withAttribute($attribute, $value): ServerRequestInterface { $new = clone $this; $new->attributes[$attribute] = $value; @@ -362,10 +330,7 @@ class ServerRequest extends Request implements ServerRequestInterface return $new; } - /** - * {@inheritdoc} - */ - public function withoutAttribute($attribute) + public function withoutAttribute($attribute): ServerRequestInterface { if (false === array_key_exists($attribute, $this->attributes)) { return $this; diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php index 3865d6d..ecd3186 100644 --- a/vendor/guzzlehttp/psr7/src/Stream.php +++ b/vendor/guzzlehttp/psr7/src/Stream.php @@ -1,33 +1,36 @@ size = $options['size']; } - $this->customMetadata = isset($options['metadata']) - ? $options['metadata'] - : []; - + $this->customMetadata = $options['metadata'] ?? []; $this->stream = $stream; $meta = stream_get_meta_data($this->stream); $this->seekable = $meta['seekable']; @@ -74,34 +74,36 @@ class Stream implements StreamInterface $this->close(); } - public function __toString() + public function __toString(): string { try { if ($this->isSeekable()) { $this->seek(0); } return $this->getContents(); - } catch (\Exception $e) { + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function getContents() + public function getContents(): string { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); } - $contents = stream_get_contents($this->stream); - - if ($contents === false) { - throw new \RuntimeException('Unable to read stream contents'); + if (!$this->readable) { + throw new \RuntimeException('Cannot read from non-readable stream'); } - return $contents; + return Utils::tryGetContents($this->stream); } - public function close() + public function close(): void { if (isset($this->stream)) { if (is_resource($this->stream)) { @@ -125,7 +127,7 @@ class Stream implements StreamInterface return $result; } - public function getSize() + public function getSize(): ?int { if ($this->size !== null) { return $this->size; @@ -141,7 +143,7 @@ class Stream implements StreamInterface } $stats = fstat($this->stream); - if (isset($stats['size'])) { + if (is_array($stats) && isset($stats['size'])) { $this->size = $stats['size']; return $this->size; } @@ -149,22 +151,22 @@ class Stream implements StreamInterface return null; } - public function isReadable() + public function isReadable(): bool { return $this->readable; } - public function isWritable() + public function isWritable(): bool { return $this->writable; } - public function isSeekable() + public function isSeekable(): bool { return $this->seekable; } - public function eof() + public function eof(): bool { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -173,7 +175,7 @@ class Stream implements StreamInterface return feof($this->stream); } - public function tell() + public function tell(): int { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -188,12 +190,12 @@ class Stream implements StreamInterface return $result; } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { $whence = (int) $whence; @@ -209,7 +211,7 @@ class Stream implements StreamInterface } } - public function read($length) + public function read($length): string { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -225,7 +227,12 @@ class Stream implements StreamInterface return ''; } - $string = fread($this->stream, $length); + try { + $string = fread($this->stream, $length); + } catch (\Exception $e) { + throw new \RuntimeException('Unable to read from stream', 0, $e); + } + if (false === $string) { throw new \RuntimeException('Unable to read from stream'); } @@ -233,7 +240,7 @@ class Stream implements StreamInterface return $string; } - public function write($string) + public function write($string): int { if (!isset($this->stream)) { throw new \RuntimeException('Stream is detached'); @@ -253,6 +260,11 @@ class Stream implements StreamInterface return $result; } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { if (!isset($this->stream)) { @@ -265,6 +277,6 @@ class Stream implements StreamInterface $meta = stream_get_meta_data($this->stream); - return isset($meta[$key]) ? $meta[$key] : null; + return $meta[$key] ?? null; } } diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php index 5025dd6..56d4104 100644 --- a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +++ b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php @@ -1,5 +1,7 @@ stream = $this->createStream(); return $this->stream; } @@ -37,22 +37,23 @@ trait StreamDecoratorTrait throw new \UnexpectedValueException("$name not found on class"); } - public function __toString() + public function __toString(): string { try { if ($this->isSeekable()) { $this->seek(0); } return $this->getContents(); - } catch (\Exception $e) { - // Really, PHP? https://bugs.php.net/bug.php?id=53648 - trigger_error('StreamDecorator::__toString exception: ' - . (string) $e, E_USER_ERROR); + } catch (\Throwable $e) { + if (\PHP_VERSION_ID >= 70400) { + throw $e; + } + trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR); return ''; } } - public function getContents() + public function getContents(): string { return Utils::copyToString($this); } @@ -60,24 +61,28 @@ trait StreamDecoratorTrait /** * Allow decorators to implement custom methods * - * @param string $method Missing method name - * @param array $args Method arguments - * * @return mixed */ - public function __call($method, array $args) + public function __call(string $method, array $args) { - $result = call_user_func_array([$this->stream, $method], $args); + /** @var callable $callable */ + $callable = [$this->stream, $method]; + $result = call_user_func_array($callable, $args); // Always return the wrapped object if the result is a return $this return $result === $this->stream ? $this : $result; } - public function close() + public function close(): void { $this->stream->close(); } + /** + * {@inheritdoc} + * + * @return mixed + */ public function getMetadata($key = null) { return $this->stream->getMetadata($key); @@ -88,52 +93,52 @@ trait StreamDecoratorTrait return $this->stream->detach(); } - public function getSize() + public function getSize(): ?int { return $this->stream->getSize(); } - public function eof() + public function eof(): bool { return $this->stream->eof(); } - public function tell() + public function tell(): int { return $this->stream->tell(); } - public function isReadable() + public function isReadable(): bool { return $this->stream->isReadable(); } - public function isWritable() + public function isWritable(): bool { return $this->stream->isWritable(); } - public function isSeekable() + public function isSeekable(): bool { return $this->stream->isSeekable(); } - public function rewind() + public function rewind(): void { $this->seek(0); } - public function seek($offset, $whence = SEEK_SET) + public function seek($offset, $whence = SEEK_SET): void { $this->stream->seek($offset, $whence); } - public function read($length) + public function read($length): string { return $this->stream->read($length); } - public function write($string) + public function write($string): int { return $this->stream->write($string); } @@ -141,11 +146,9 @@ trait StreamDecoratorTrait /** * Implement in subclasses to dynamically create streams when requested. * - * @return StreamInterface - * * @throws \BadMethodCallException */ - protected function createStream() + protected function createStream(): StreamInterface { throw new \BadMethodCallException('Not implemented'); } diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php index fc7cb96..2a93464 100644 --- a/vendor/guzzlehttp/psr7/src/StreamWrapper.php +++ b/vendor/guzzlehttp/psr7/src/StreamWrapper.php @@ -1,5 +1,7 @@ context); @@ -83,41 +83,48 @@ class StreamWrapper return true; } - public function stream_read($count) + public function stream_read(int $count): string { return $this->stream->read($count); } - public function stream_write($data) + public function stream_write(string $data): int { - return (int) $this->stream->write($data); + return $this->stream->write($data); } - public function stream_tell() + public function stream_tell(): int { return $this->stream->tell(); } - public function stream_eof() + public function stream_eof(): bool { return $this->stream->eof(); } - public function stream_seek($offset, $whence) + public function stream_seek(int $offset, int $whence): bool { $this->stream->seek($offset, $whence); return true; } - public function stream_cast($cast_as) + /** + * @return resource|false + */ + public function stream_cast(int $cast_as) { $stream = clone($this->stream); + $resource = $stream->detach(); - return $stream->detach(); + return $resource ?? false; } - public function stream_stat() + /** + * @return array + */ + public function stream_stat(): array { static $modeMap = [ 'r' => 33060, @@ -144,7 +151,10 @@ class StreamWrapper ]; } - public function url_stat($path, $flags) + /** + * @return array + */ + public function url_stat(string $path, int $flags): array { return [ 'dev' => 0, diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php index bf342c4..b1521bc 100644 --- a/vendor/guzzlehttp/psr7/src/UploadedFile.php +++ b/vendor/guzzlehttp/psr7/src/UploadedFile.php @@ -1,5 +1,7 @@ setError($errorStatus); - $this->setSize($size); - $this->setClientFilename($clientFilename); - $this->setClientMediaType($clientMediaType); + $this->size = $size; + $this->clientFilename = $clientFilename; + $this->clientMediaType = $clientMediaType; if ($this->isOk()) { $this->setStreamOrFile($streamOrFile); @@ -85,11 +80,11 @@ class UploadedFile implements UploadedFileInterface /** * Depending on the value set file or stream variable * - * @param mixed $streamOrFile + * @param StreamInterface|string|resource $streamOrFile * * @throws InvalidArgumentException */ - private function setStreamOrFile($streamOrFile) + private function setStreamOrFile($streamOrFile): void { if (is_string($streamOrFile)) { $this->file = $streamOrFile; @@ -105,19 +100,11 @@ class UploadedFile implements UploadedFileInterface } /** - * @param int $error - * * @throws InvalidArgumentException */ - private function setError($error) + private function setError(int $error): void { - if (false === is_int($error)) { - throw new InvalidArgumentException( - 'Upload file error status must be an integer' - ); - } - - if (false === in_array($error, UploadedFile::$errors)) { + if (false === in_array($error, UploadedFile::ERRORS, true)) { throw new InvalidArgumentException( 'Invalid error status for UploadedFile' ); @@ -126,88 +113,20 @@ class UploadedFile implements UploadedFileInterface $this->error = $error; } - /** - * @param int $size - * - * @throws InvalidArgumentException - */ - private function setSize($size) - { - if (false === is_int($size)) { - throw new InvalidArgumentException( - 'Upload file size must be an integer' - ); - } - - $this->size = $size; - } - - /** - * @param mixed $param - * - * @return bool - */ - private function isStringOrNull($param) - { - return in_array(gettype($param), ['string', 'NULL']); - } - - /** - * @param mixed $param - * - * @return bool - */ - private function isStringNotEmpty($param) + private function isStringNotEmpty($param): bool { return is_string($param) && false === empty($param); } - /** - * @param string|null $clientFilename - * - * @throws InvalidArgumentException - */ - private function setClientFilename($clientFilename) - { - if (false === $this->isStringOrNull($clientFilename)) { - throw new InvalidArgumentException( - 'Upload file client filename must be a string or null' - ); - } - - $this->clientFilename = $clientFilename; - } - - /** - * @param string|null $clientMediaType - * - * @throws InvalidArgumentException - */ - private function setClientMediaType($clientMediaType) - { - if (false === $this->isStringOrNull($clientMediaType)) { - throw new InvalidArgumentException( - 'Upload file client media type must be a string or null' - ); - } - - $this->clientMediaType = $clientMediaType; - } - /** * Return true if there is no upload error - * - * @return bool */ - private function isOk() + private function isOk(): bool { return $this->error === UPLOAD_ERR_OK; } - /** - * @return bool - */ - public function isMoved() + public function isMoved(): bool { return $this->moved; } @@ -215,7 +134,7 @@ class UploadedFile implements UploadedFileInterface /** * @throws RuntimeException if is moved or not ok */ - private function validateActive() + private function validateActive(): void { if (false === $this->isOk()) { throw new RuntimeException('Cannot retrieve stream due to upload error'); @@ -226,12 +145,7 @@ class UploadedFile implements UploadedFileInterface } } - /** - * {@inheritdoc} - * - * @throws RuntimeException if the upload was not successful. - */ - public function getStream() + public function getStream(): StreamInterface { $this->validateActive(); @@ -239,23 +153,13 @@ class UploadedFile implements UploadedFileInterface return $this->stream; } - return new LazyOpenStream($this->file, 'r+'); + /** @var string $file */ + $file = $this->file; + + return new LazyOpenStream($file, 'r+'); } - /** - * {@inheritdoc} - * - * @see http://php.net/is_uploaded_file - * @see http://php.net/move_uploaded_file - * - * @param string $targetPath Path to which to move the uploaded file. - * - * @throws RuntimeException if the upload was not successful. - * @throws InvalidArgumentException if the $path specified is invalid. - * @throws RuntimeException on any error during the move operation, or on - * the second or subsequent call to the method. - */ - public function moveTo($targetPath) + public function moveTo($targetPath): void { $this->validateActive(); @@ -266,7 +170,7 @@ class UploadedFile implements UploadedFileInterface } if ($this->file) { - $this->moved = php_sapi_name() == 'cli' + $this->moved = PHP_SAPI === 'cli' ? rename($this->file, $targetPath) : move_uploaded_file($this->file, $targetPath); } else { @@ -285,43 +189,22 @@ class UploadedFile implements UploadedFileInterface } } - /** - * {@inheritdoc} - * - * @return int|null The file size in bytes or null if unknown. - */ - public function getSize() + public function getSize(): ?int { return $this->size; } - /** - * {@inheritdoc} - * - * @see http://php.net/manual/en/features.file-upload.errors.php - * - * @return int One of PHP's UPLOAD_ERR_XXX constants. - */ - public function getError() + public function getError(): int { return $this->error; } - /** - * {@inheritdoc} - * - * @return string|null The filename sent by the client or null if none - * was provided. - */ - public function getClientFilename() + public function getClientFilename(): ?string { return $this->clientFilename; } - /** - * {@inheritdoc} - */ - public function getClientMediaType() + public function getClientMediaType(): ?string { return $this->clientMediaType; } diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php index 0f9f020..09e878d 100644 --- a/vendor/guzzlehttp/psr7/src/Uri.php +++ b/vendor/guzzlehttp/psr7/src/Uri.php @@ -1,7 +1,10 @@ 80, 'https' => 443, 'ftp' => 21, @@ -35,9 +38,20 @@ class Uri implements UriInterface 'ldap' => 389, ]; - private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; - private static $charSubDelims = '!\$&\'\(\)\*\+,;='; - private static $replaceQuery = ['=' => '%3D', '&' => '%26']; + /** + * Unreserved characters for use in a regex. + * + * @link https://tools.ietf.org/html/rfc3986#section-2.3 + */ + private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~'; + + /** + * Sub-delims for use in a regex. + * + * @link https://tools.ietf.org/html/rfc3986#section-2.2 + */ + private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;='; + private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26']; /** @var string Uri scheme. */ private $scheme = ''; @@ -60,21 +74,19 @@ class Uri implements UriInterface /** @var string Uri fragment. */ private $fragment = ''; - /** - * @param string $uri URI to parse - */ - public function __construct($uri = '') + /** @var string|null String representation */ + private $composedComponents; + + public function __construct(string $uri = '') { - // weak type check to also accept null until we can add scalar type hints - if ($uri != '') { + if ($uri !== '') { $parts = self::parse($uri); if ($parts === false) { - throw new \InvalidArgumentException("Unable to parse URI: $uri"); + throw new MalformedUriException("Unable to parse URI: $uri"); } $this->applyParts($parts); } } - /** * UTF-8 aware \parse_url() replacement. * @@ -88,19 +100,19 @@ class Uri implements UriInterface * @see https://www.php.net/manual/en/function.parse-url.php#114817 * @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING * - * @param string $url - * * @return array|false */ - private static function parse($url) + private static function parse(string $url) { // If IPv6 $prefix = ''; if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) { + /** @var array{0:string, 1:string, 2:string} $matches */ $prefix = $matches[1]; $url = $matches[2]; } + /** @var string */ $encodedUrl = preg_replace_callback( '%[^:/@?&=#]+%usD', static function ($matches) { @@ -118,15 +130,19 @@ class Uri implements UriInterface return array_map('urldecode', $result); } - public function __toString() + public function __toString(): string { - return self::composeComponents( - $this->scheme, - $this->getAuthority(), - $this->path, - $this->query, - $this->fragment - ); + if ($this->composedComponents === null) { + $this->composedComponents = self::composeComponents( + $this->scheme, + $this->getAuthority(), + $this->path, + $this->query, + $this->fragment + ); + } + + return $this->composedComponents; } /** @@ -145,17 +161,9 @@ class Uri implements UriInterface * `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to * that format). * - * @param string $scheme - * @param string $authority - * @param string $path - * @param string $query - * @param string $fragment - * - * @return string - * * @link https://tools.ietf.org/html/rfc3986#section-5.3 */ - public static function composeComponents($scheme, $authority, $path, $query, $fragment) + public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string { $uri = ''; @@ -164,10 +172,14 @@ class Uri implements UriInterface $uri .= $scheme . ':'; } - if ($authority != ''|| $scheme === 'file') { + if ($authority != '' || $scheme === 'file') { $uri .= '//' . $authority; } + if ($authority != '' && $path != '' && $path[0] != '/') { + $path = '/' . $path; + } + $uri .= $path; if ($query != '') { @@ -186,15 +198,11 @@ class Uri implements UriInterface * * `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used * independently of the implementation. - * - * @param UriInterface $uri - * - * @return bool */ - public static function isDefaultPort(UriInterface $uri) + public static function isDefaultPort(UriInterface $uri): bool { return $uri->getPort() === null - || (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]); + || (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]); } /** @@ -207,16 +215,12 @@ class Uri implements UriInterface * - absolute-path references, e.g. '/path' * - relative-path references, e.g. 'subpath' * - * @param UriInterface $uri - * - * @return bool - * * @see Uri::isNetworkPathReference * @see Uri::isAbsolutePathReference * @see Uri::isRelativePathReference * @link https://tools.ietf.org/html/rfc3986#section-4 */ - public static function isAbsolute(UriInterface $uri) + public static function isAbsolute(UriInterface $uri): bool { return $uri->getScheme() !== ''; } @@ -226,13 +230,9 @@ class Uri implements UriInterface * * A relative reference that begins with two slash characters is termed an network-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isNetworkPathReference(UriInterface $uri) + public static function isNetworkPathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() !== ''; } @@ -242,13 +242,9 @@ class Uri implements UriInterface * * A relative reference that begins with a single slash character is termed an absolute-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isAbsolutePathReference(UriInterface $uri) + public static function isAbsolutePathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() === '' @@ -261,13 +257,9 @@ class Uri implements UriInterface * * A relative reference that does not begin with a slash character is termed a relative-path reference. * - * @param UriInterface $uri - * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.2 */ - public static function isRelativePathReference(UriInterface $uri) + public static function isRelativePathReference(UriInterface $uri): bool { return $uri->getScheme() === '' && $uri->getAuthority() === '' @@ -284,11 +276,9 @@ class Uri implements UriInterface * @param UriInterface $uri The URI to check * @param UriInterface|null $base An optional base URI to compare against * - * @return bool - * * @link https://tools.ietf.org/html/rfc3986#section-4.4 */ - public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null) + public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool { if ($base !== null) { $uri = UriResolver::resolve($base, $uri); @@ -302,41 +292,6 @@ class Uri implements UriInterface return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === ''; } - /** - * Removes dot segments from a path and returns the new path. - * - * @param string $path - * - * @return string - * - * @deprecated since version 1.4. Use UriResolver::removeDotSegments instead. - * @see UriResolver::removeDotSegments - */ - public static function removeDotSegments($path) - { - return UriResolver::removeDotSegments($path); - } - - /** - * Converts the relative URI into a new URI that is resolved against the base URI. - * - * @param UriInterface $base Base URI - * @param string|UriInterface $rel Relative URI - * - * @return UriInterface - * - * @deprecated since version 1.4. Use UriResolver::resolve instead. - * @see UriResolver::resolve - */ - public static function resolve(UriInterface $base, $rel) - { - if (!($rel instanceof UriInterface)) { - $rel = new self($rel); - } - - return UriResolver::resolve($base, $rel); - } - /** * Creates a new URI with a specific query string value removed. * @@ -345,10 +300,8 @@ class Uri implements UriInterface * * @param UriInterface $uri URI to use as a base. * @param string $key Query string key to remove. - * - * @return UriInterface */ - public static function withoutQueryValue(UriInterface $uri, $key) + public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface { $result = self::getFilteredQueryString($uri, [$key]); @@ -367,10 +320,8 @@ class Uri implements UriInterface * @param UriInterface $uri URI to use as a base. * @param string $key Key to set. * @param string|null $value Value to set - * - * @return UriInterface */ - public static function withQueryValue(UriInterface $uri, $key, $value) + public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface { $result = self::getFilteredQueryString($uri, [$key]); @@ -384,17 +335,15 @@ class Uri implements UriInterface * * It has the same behavior as withQueryValue() but for an associative array of key => value. * - * @param UriInterface $uri URI to use as a base. - * @param array $keyValueArray Associative array of key and values - * - * @return UriInterface + * @param UriInterface $uri URI to use as a base. + * @param array $keyValueArray Associative array of key and values */ - public static function withQueryValues(UriInterface $uri, array $keyValueArray) + public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface { $result = self::getFilteredQueryString($uri, array_keys($keyValueArray)); foreach ($keyValueArray as $key => $value) { - $result[] = self::generateQueryString($key, $value); + $result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null); } return $uri->withQuery(implode('&', $result)); @@ -403,15 +352,11 @@ class Uri implements UriInterface /** * Creates a URI from a hash of `parse_url` components. * - * @param array $parts - * - * @return UriInterface - * * @link http://php.net/manual/en/function.parse-url.php * - * @throws \InvalidArgumentException If the components do not form a valid URI. + * @throws MalformedUriException If the components do not form a valid URI. */ - public static function fromParts(array $parts) + public static function fromParts(array $parts): UriInterface { $uri = new self(); $uri->applyParts($parts); @@ -420,12 +365,12 @@ class Uri implements UriInterface return $uri; } - public function getScheme() + public function getScheme(): string { return $this->scheme; } - public function getAuthority() + public function getAuthority(): string { $authority = $this->host; if ($this->userInfo !== '') { @@ -439,37 +384,37 @@ class Uri implements UriInterface return $authority; } - public function getUserInfo() + public function getUserInfo(): string { return $this->userInfo; } - public function getHost() + public function getHost(): string { return $this->host; } - public function getPort() + public function getPort(): ?int { return $this->port; } - public function getPath() + public function getPath(): string { return $this->path; } - public function getQuery() + public function getQuery(): string { return $this->query; } - public function getFragment() + public function getFragment(): string { return $this->fragment; } - public function withScheme($scheme) + public function withScheme($scheme): UriInterface { $scheme = $this->filterScheme($scheme); @@ -479,13 +424,14 @@ class Uri implements UriInterface $new = clone $this; $new->scheme = $scheme; + $new->composedComponents = null; $new->removeDefaultPort(); $new->validateState(); return $new; } - public function withUserInfo($user, $password = null) + public function withUserInfo($user, $password = null): UriInterface { $info = $this->filterUserInfoComponent($user); if ($password !== null) { @@ -498,12 +444,13 @@ class Uri implements UriInterface $new = clone $this; $new->userInfo = $info; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withHost($host) + public function withHost($host): UriInterface { $host = $this->filterHost($host); @@ -513,12 +460,13 @@ class Uri implements UriInterface $new = clone $this; $new->host = $host; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withPort($port) + public function withPort($port): UriInterface { $port = $this->filterPort($port); @@ -528,13 +476,14 @@ class Uri implements UriInterface $new = clone $this; $new->port = $port; + $new->composedComponents = null; $new->removeDefaultPort(); $new->validateState(); return $new; } - public function withPath($path) + public function withPath($path): UriInterface { $path = $this->filterPath($path); @@ -544,12 +493,13 @@ class Uri implements UriInterface $new = clone $this; $new->path = $path; + $new->composedComponents = null; $new->validateState(); return $new; } - public function withQuery($query) + public function withQuery($query): UriInterface { $query = $this->filterQueryAndFragment($query); @@ -559,11 +509,12 @@ class Uri implements UriInterface $new = clone $this; $new->query = $query; + $new->composedComponents = null; return $new; } - public function withFragment($fragment) + public function withFragment($fragment): UriInterface { $fragment = $this->filterQueryAndFragment($fragment); @@ -573,16 +524,22 @@ class Uri implements UriInterface $new = clone $this; $new->fragment = $fragment; + $new->composedComponents = null; return $new; } + public function jsonSerialize(): string + { + return $this->__toString(); + } + /** * Apply parse_url parts to a URI. * * @param array $parts Array of parse_url parts to apply. */ - private function applyParts(array $parts) + private function applyParts(array $parts): void { $this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) @@ -613,13 +570,11 @@ class Uri implements UriInterface } /** - * @param string $scheme - * - * @return string + * @param mixed $scheme * * @throws \InvalidArgumentException If the scheme is invalid. */ - private function filterScheme($scheme) + private function filterScheme($scheme): string { if (!is_string($scheme)) { throw new \InvalidArgumentException('Scheme must be a string'); @@ -629,33 +584,29 @@ class Uri implements UriInterface } /** - * @param string $component - * - * @return string + * @param mixed $component * * @throws \InvalidArgumentException If the user info is invalid. */ - private function filterUserInfoComponent($component) + private function filterUserInfoComponent($component): string { if (!is_string($component)) { throw new \InvalidArgumentException('User info must be a string'); } return preg_replace_callback( - '/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component ); } /** - * @param string $host - * - * @return string + * @param mixed $host * * @throws \InvalidArgumentException If the host is invalid. */ - private function filterHost($host) + private function filterHost($host): string { if (!is_string($host)) { throw new \InvalidArgumentException('Host must be a string'); @@ -665,13 +616,11 @@ class Uri implements UriInterface } /** - * @param int|null $port - * - * @return int|null + * @param mixed $port * * @throws \InvalidArgumentException If the port is invalid. */ - private function filterPort($port) + private function filterPort($port): ?int { if ($port === null) { return null; @@ -688,12 +637,11 @@ class Uri implements UriInterface } /** - * @param UriInterface $uri - * @param array $keys + * @param string[] $keys * - * @return array + * @return string[] */ - private static function getFilteredQueryString(UriInterface $uri, array $keys) + private static function getFilteredQueryString(UriInterface $uri, array $keys): array { $current = $uri->getQuery(); @@ -708,27 +656,21 @@ class Uri implements UriInterface }); } - /** - * @param string $key - * @param string|null $value - * - * @return string - */ - private static function generateQueryString($key, $value) + private static function generateQueryString(string $key, ?string $value): string { // Query string separators ("=", "&") within the key or value need to be encoded // (while preventing double-encoding) before setting the query string. All other // chars that need percent-encoding will be encoded by withQuery(). - $queryString = strtr($key, self::$replaceQuery); + $queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT); if ($value !== null) { - $queryString .= '=' . strtr($value, self::$replaceQuery); + $queryString .= '=' . strtr($value, self::QUERY_SEPARATORS_REPLACEMENT); } return $queryString; } - private function removeDefaultPort() + private function removeDefaultPort(): void { if ($this->port !== null && self::isDefaultPort($this)) { $this->port = null; @@ -738,20 +680,18 @@ class Uri implements UriInterface /** * Filters the path of a URI * - * @param string $path - * - * @return string + * @param mixed $path * * @throws \InvalidArgumentException If the path is invalid. */ - private function filterPath($path) + private function filterPath($path): string { if (!is_string($path)) { throw new \InvalidArgumentException('Path must be a string'); } return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $path ); @@ -760,31 +700,29 @@ class Uri implements UriInterface /** * Filters the query string or fragment of a URI. * - * @param string $str - * - * @return string + * @param mixed $str * * @throws \InvalidArgumentException If the query or fragment is invalid. */ - private function filterQueryAndFragment($str) + private function filterQueryAndFragment($str): string { if (!is_string($str)) { throw new \InvalidArgumentException('Query and fragment must be a string'); } return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', + '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $str ); } - private function rawurlencodeMatchZero(array $match) + private function rawurlencodeMatchZero(array $match): string { return rawurlencode($match[0]); } - private function validateState() + private function validateState(): void { if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) { $this->host = self::HTTP_DEFAULT_HOST; @@ -792,19 +730,11 @@ class Uri implements UriInterface if ($this->getAuthority() === '') { if (0 === strpos($this->path, '//')) { - throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"'); + throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"'); } if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) { - throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon'); + throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon'); } - } elseif (isset($this->path[0]) && $this->path[0] !== '/') { - @trigger_error( - 'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' . - 'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.', - E_USER_DEPRECATED - ); - $this->path = '/' . $this->path; - //throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty'); } } } diff --git a/vendor/guzzlehttp/psr7/src/UriComparator.php b/vendor/guzzlehttp/psr7/src/UriComparator.php index ccf51ff..70c582a 100644 --- a/vendor/guzzlehttp/psr7/src/UriComparator.php +++ b/vendor/guzzlehttp/psr7/src/UriComparator.php @@ -1,5 +1,7 @@ getHost(), $modified->getHost()) !== 0) { return true; @@ -34,10 +34,7 @@ final class UriComparator return false; } - /** - * @return int - */ - private static function computePort(UriInterface $uri) + private static function computePort(UriInterface $uri): int { $port = $uri->getPort(); diff --git a/vendor/guzzlehttp/psr7/src/UriNormalizer.php b/vendor/guzzlehttp/psr7/src/UriNormalizer.php index 81419ea..e12971e 100644 --- a/vendor/guzzlehttp/psr7/src/UriNormalizer.php +++ b/vendor/guzzlehttp/psr7/src/UriNormalizer.php @@ -1,5 +1,7 @@ getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '') @@ -174,6 +162,7 @@ final class UriResolver // inherit the base query component when resolving. if ($target->getQuery() === '') { $segments = explode('/', $target->getPath()); + /** @var string $lastSegment */ $lastSegment = end($segments); return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); @@ -182,7 +171,7 @@ final class UriResolver return $emptyPathUri; } - private static function getRelativePath(UriInterface $base, UriInterface $target) + private static function getRelativePath(UriInterface $base, UriInterface $target): string { $sourceSegments = explode('/', $base->getPath()); $targetSegments = explode('/', $target->getPath()); diff --git a/vendor/guzzlehttp/psr7/src/Utils.php b/vendor/guzzlehttp/psr7/src/Utils.php index 6b6c8cc..3a4cf39 100644 --- a/vendor/guzzlehttp/psr7/src/Utils.php +++ b/vendor/guzzlehttp/psr7/src/Utils.php @@ -1,5 +1,7 @@ $keys - * - * @return array + * @param string[] $keys */ - public static function caselessRemove($keys, array $data) + public static function caselessRemove(array $keys, array $data): array { $result = []; @@ -25,7 +25,7 @@ final class Utils } foreach ($data as $k => $v) { - if (!in_array(strtolower($k), $keys)) { + if (!is_string($k) || !in_array(strtolower($k), $keys)) { $result[$k] = $v; } } @@ -44,7 +44,7 @@ final class Utils * * @throws \RuntimeException on error. */ - public static function copyToStream(StreamInterface $source, StreamInterface $dest, $maxLen = -1) + public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void { $bufferSize = 8192; @@ -76,19 +76,16 @@ final class Utils * @param int $maxLen Maximum number of bytes to read. Pass -1 * to read the entire stream. * - * @return string - * * @throws \RuntimeException on error. */ - public static function copyToString(StreamInterface $stream, $maxLen = -1) + public static function copyToString(StreamInterface $stream, int $maxLen = -1): string { $buffer = ''; if ($maxLen === -1) { while (!$stream->eof()) { $buf = $stream->read(1048576); - // Using a loose equality here to match on '' and false. - if ($buf == null) { + if ($buf === '') { break; } $buffer .= $buf; @@ -99,8 +96,7 @@ final class Utils $len = 0; while (!$stream->eof() && $len < $maxLen) { $buf = $stream->read($maxLen - $len); - // Using a loose equality here to match on '' and false. - if ($buf == null) { + if ($buf === '') { break; } $buffer .= $buf; @@ -120,11 +116,9 @@ final class Utils * @param string $algo Hash algorithm (e.g. md5, crc32, etc) * @param bool $rawOutput Whether or not to use raw output * - * @return string Returns the hash of the stream - * * @throws \RuntimeException on error. */ - public static function hash(StreamInterface $stream, $algo, $rawOutput = false) + public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string { $pos = $stream->tell(); @@ -137,7 +131,7 @@ final class Utils hash_update($ctx, $stream->read(1048576)); } - $out = hash_final($ctx, (bool) $rawOutput); + $out = hash_final($ctx, $rawOutput); $stream->seek($pos); return $out; @@ -160,10 +154,8 @@ final class Utils * * @param RequestInterface $request Request to clone and modify. * @param array $changes Changes to apply. - * - * @return RequestInterface */ - public static function modifyRequest(RequestInterface $request, array $changes) + public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface { if (!$changes) { return $request; @@ -204,13 +196,11 @@ final class Utils if ($request instanceof ServerRequestInterface) { $new = (new ServerRequest( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $changes['method'] ?? $request->getMethod(), $uri, $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion(), + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion(), $request->getServerParams() )) ->withParsedBody($request->getParsedBody()) @@ -226,13 +216,11 @@ final class Utils } return new Request( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), + $changes['method'] ?? $request->getMethod(), $uri, $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion() + $changes['body'] ?? $request->getBody(), + $changes['version'] ?? $request->getProtocolVersion() ); } @@ -241,17 +229,14 @@ final class Utils * * @param StreamInterface $stream Stream to read from * @param int|null $maxLength Maximum buffer length - * - * @return string */ - public static function readLine(StreamInterface $stream, $maxLength = null) + public static function readLine(StreamInterface $stream, ?int $maxLength = null): string { $buffer = ''; $size = 0; while (!$stream->eof()) { - // Using a loose equality here to match on '' and false. - if (null == ($byte = $stream->read(1))) { + if ('' === ($byte = $stream->read(1))) { return $buffer; } $buffer .= $byte; @@ -294,18 +279,16 @@ final class Utils * buffered and used in subsequent reads. * * @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data - * @param array $options Additional options - * - * @return StreamInterface + * @param array{size?: int, metadata?: array} $options Additional options * * @throws \InvalidArgumentException if the $resource arg is not valid. */ - public static function streamFor($resource = '', array $options = []) + public static function streamFor($resource = '', array $options = []): StreamInterface { if (is_scalar($resource)) { $stream = self::tryFopen('php://temp', 'r+'); if ($resource !== '') { - fwrite($stream, $resource); + fwrite($stream, (string) $resource); fseek($stream, 0); } return new Stream($stream, $options); @@ -317,15 +300,17 @@ final class Utils * The 'php://input' is a special stream with quirks and inconsistencies. * We avoid using that stream by reading it into php://temp */ - $metaData = \stream_get_meta_data($resource); - if (isset($metaData['uri']) && $metaData['uri'] === 'php://input') { + + /** @var resource $resource */ + if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') { $stream = self::tryFopen('php://temp', 'w+'); - fwrite($stream, stream_get_contents($resource)); + stream_copy_to_stream($resource, $stream); fseek($stream, 0); $resource = $stream; } return new Stream($resource, $options); case 'object': + /** @var object $resource */ if ($resource instanceof StreamInterface) { return $resource; } elseif ($resource instanceof \Iterator) { @@ -338,7 +323,7 @@ final class Utils return $result; }, $options); } elseif (method_exists($resource, '__toString')) { - return Utils::streamFor((string) $resource, $options); + return self::streamFor((string) $resource, $options); } break; case 'NULL': @@ -365,21 +350,22 @@ final class Utils * * @throws \RuntimeException if the file cannot be opened */ - public static function tryFopen($filename, $mode) + public static function tryFopen(string $filename, string $mode) { $ex = null; - set_error_handler(function () use ($filename, $mode, &$ex) { + set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool { $ex = new \RuntimeException(sprintf( 'Unable to open "%s" using mode "%s": %s', $filename, $mode, - func_get_args()[1] + $errstr )); return true; }); try { + /** @var resource $handle */ $handle = fopen($filename, $mode); } catch (\Throwable $e) { $ex = new \RuntimeException(sprintf( @@ -400,6 +386,53 @@ final class Utils return $handle; } + /** + * Safely gets the contents of a given stream. + * + * When stream_get_contents fails, PHP normally raises a warning. This + * function adds an error handler that checks for errors and throws an + * exception instead. + * + * @param resource $stream + * + * @throws \RuntimeException if the stream cannot be read + */ + public static function tryGetContents($stream): string + { + $ex = null; + set_error_handler(static function (int $errno, string $errstr) use (&$ex): bool { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $errstr + )); + + return true; + }); + + try { + /** @var string|false $contents */ + $contents = stream_get_contents($stream); + + if ($contents === false) { + $ex = new \RuntimeException('Unable to read stream contents'); + } + } catch (\Throwable $e) { + $ex = new \RuntimeException(sprintf( + 'Unable to read stream contents: %s', + $e->getMessage() + ), 0, $e); + } + + restore_error_handler(); + + if ($ex) { + /** @var $ex \RuntimeException */ + throw $ex; + } + + return $contents; + } + /** * Returns a UriInterface for the given value. * @@ -409,11 +442,9 @@ final class Utils * * @param string|UriInterface $uri * - * @return UriInterface - * * @throws \InvalidArgumentException */ - public static function uriFor($uri) + public static function uriFor($uri): UriInterface { if ($uri instanceof UriInterface) { return $uri; diff --git a/vendor/guzzlehttp/psr7/src/functions.php b/vendor/guzzlehttp/psr7/src/functions.php deleted file mode 100644 index b0901fa..0000000 --- a/vendor/guzzlehttp/psr7/src/functions.php +++ /dev/null @@ -1,422 +0,0 @@ - '1', 'foo[b]' => '2'])`. - * - * @param string $str Query string to parse - * @param int|bool $urlEncoding How the query string is encoded - * - * @return array - * - * @deprecated parse_query will be removed in guzzlehttp/psr7:2.0. Use Query::parse instead. - */ -function parse_query($str, $urlEncoding = true) -{ - return Query::parse($str, $urlEncoding); -} - -/** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of `parse_query()` to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like `http_build_query()` would). - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - * - * @return string - * - * @deprecated build_query will be removed in guzzlehttp/psr7:2.0. Use Query::build instead. - */ -function build_query(array $params, $encoding = PHP_QUERY_RFC3986) -{ - return Query::build($params, $encoding); -} - -/** - * Determines the mimetype of a file by looking at its extension. - * - * @param string $filename - * - * @return string|null - * - * @deprecated mimetype_from_filename will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromFilename instead. - */ -function mimetype_from_filename($filename) -{ - return MimeType::fromFilename($filename); -} - -/** - * Maps a file extensions to a mimetype. - * - * @param $extension string The file extension. - * - * @return string|null - * - * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - * @deprecated mimetype_from_extension will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromExtension instead. - */ -function mimetype_from_extension($extension) -{ - return MimeType::fromExtension($extension); -} - -/** - * Parses an HTTP message into an associative array. - * - * The array contains the "start-line" key containing the start line of - * the message, "headers" key containing an associative array of header - * array values, and a "body" key containing the body of the message. - * - * @param string $message HTTP request or response to parse. - * - * @return array - * - * @internal - * - * @deprecated _parse_message will be removed in guzzlehttp/psr7:2.0. Use Message::parseMessage instead. - */ -function _parse_message($message) -{ - return Message::parseMessage($message); -} - -/** - * Constructs a URI for an HTTP request message. - * - * @param string $path Path from the start-line - * @param array $headers Array of headers (each value an array). - * - * @return string - * - * @internal - * - * @deprecated _parse_request_uri will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequestUri instead. - */ -function _parse_request_uri($path, array $headers) -{ - return Message::parseRequestUri($path, $headers); -} - -/** - * Get a short summary of the message body. - * - * Will return `null` if the response is not printable. - * - * @param MessageInterface $message The message to get the body summary - * @param int $truncateAt The maximum allowed size of the summary - * - * @return string|null - * - * @deprecated get_message_body_summary will be removed in guzzlehttp/psr7:2.0. Use Message::bodySummary instead. - */ -function get_message_body_summary(MessageInterface $message, $truncateAt = 120) -{ - return Message::bodySummary($message, $truncateAt); -} - -/** - * Remove the items given by the keys, case insensitively from the data. - * - * @param iterable $keys - * - * @return array - * - * @internal - * - * @deprecated _caseless_remove will be removed in guzzlehttp/psr7:2.0. Use Utils::caselessRemove instead. - */ -function _caseless_remove($keys, array $data) -{ - return Utils::caselessRemove($keys, $data); -} diff --git a/vendor/guzzlehttp/psr7/src/functions_include.php b/vendor/guzzlehttp/psr7/src/functions_include.php deleted file mode 100644 index 96a4a83..0000000 --- a/vendor/guzzlehttp/psr7/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ - 'QueryList', - 'wd2' => 'teststr' -]); - -//opt - -$rt = GHttp::get('https://www.baidu.com/s',[ - 'wd' => 'QueryList' -],[ - 'headers' => [ - 'referer' => 'https://baidu.com', - 'User-Agent' => 'Mozilla/5.0 (Windows NTChrome/58.0.3029.110 Safari/537.36', - 'Cookie' => 'cookie xxx' - ] -]); - -$rt = GHttp::getJson('https://xxxx.com/json'); - -``` - -#### 2.post / postRaw / postJson -```php -$rt = GHttp::post('https://www.posttestserver.com/post.php',[ - 'name' => 'QueryList', - 'password' => 'ql' -]); - -$rt = GHttp::post('https://www.posttestserver.com/post.php','name=QueryList&password=ql'); - - -$rt = GHttp::postRaw('http://httpbin.org/post','raw data'); -$rt = GHttp::postRaw('http://httpbin.org/post',['aa' => 11,'bb' => 22]); - - -$rt = GHttp::postJson('http://httpbin.org/post',['aa' => 11,'bb' => 22]); -$rt = GHttp::postJson('http://httpbin.org/post','aa=11&bb=22'); - -``` -#### 3.download - -```php -GHttp::download('http://sw.bos.baidu.com/setup.exe','./path/to/xx.exe'); -``` -### 4. concurrent requests -```php -use Jaeger\GHttp; - -$urls = [ - 'http://httpbin.org/get?name=php', - 'http://httpbin.org/get?name=go', - 'http://httpbin.org/get?name=c#', - 'http://httpbin.org/get?name=java' -]; - -GHttp::multiRequest($urls)->withHeaders([ - 'X-Powered-By' => 'Jaeger' -])->withOptions([ - 'timeout' => 10 -])->concurrency(2)->success(function($response,$index){ - print_r((String)$response->getBody()); - print_r($index); -})->error(function($reason,$index){ - print_r($reason); -})->get(); -``` - -```php -use Jaeger\GHttp; -use GuzzleHttp\Psr7\Request; - -$requests = [ - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'php' - ])), - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'go' - ])), - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'c#' - ])) -]; - -GHttp::multiRequest($requests)->success(function($response,$index){ - print_r((String)$response->getBody()); - print_r($index); -})->post(); -``` -### 5. Request with cache - -Base on PHP-Cache: http://www.php-cache.com - -- Use filesystem cache -```php -use Jaeger\GHttp; - -$rt = GHttp::get('http://httpbin.org/get',[ - 'wd' => 'QueryList' -],[ - 'cache' => __DIR__, - 'cache_ttl' => 120 //seconds -]); - -``` - -- Use predis cache - -Install predis adapter: -``` -composer require cache/predis-adapter -``` - -Usage: -```php -use Jaeger\GHttp; -use Cache\Adapter\Predis\PredisCachePool; - -$client = new \Predis\Client('tcp:/127.0.0.1:6379'); -$pool = new PredisCachePool($client); - -$rt = GHttp::get('http://httpbin.org/get',[ - 'wd' => 'QueryList' -],[ - 'cache' => $pool, - 'cache_ttl' => 120 //seconds -]); -``` \ No newline at end of file diff --git a/vendor/jaeger/g-http/composer.json b/vendor/jaeger/g-http/composer.json deleted file mode 100644 index 6781037..0000000 --- a/vendor/jaeger/g-http/composer.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "jaeger/g-http", - "description": "Simple Http client base on GuzzleHttp", - "license": "MIT", - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "require": { - "cache/filesystem-adapter": "^1", - "guzzlehttp/guzzle": "^6.0 | ^7.0" - }, - "autoload":{ - "psr-4":{ - "Jaeger\\":"src" - } - } -} diff --git a/vendor/jaeger/g-http/examples/multi_request.php b/vendor/jaeger/g-http/examples/multi_request.php deleted file mode 100644 index b2a138d..0000000 --- a/vendor/jaeger/g-http/examples/multi_request.php +++ /dev/null @@ -1,27 +0,0 @@ - - * Date: 18/12/10 - * Time: 下午4:04 - */ -require __DIR__.'/../vendor/autoload.php'; -use Jaeger\GHttp; - -$urls = [ - 'http://httpbin.org/get?name=php', - 'http://httpbin.org/get?name=go', - 'http://httpbin.org/get?name=c#', - 'http://httpbin.org/get?name=java' -]; - -GHttp::multiRequest($urls)->withHeaders([ - 'X-Powered-By' => 'Jaeger' -])->withOptions([ - 'timeout' => 10 -])->concurrency(2)->success(function($response,$index){ - print_r((String)$response->getBody()); - print_r($index); -})->error(function($reason,$index){ - print_r($reason); -})->get(); \ No newline at end of file diff --git a/vendor/jaeger/g-http/examples/multi_request_2.php b/vendor/jaeger/g-http/examples/multi_request_2.php deleted file mode 100644 index d66612b..0000000 --- a/vendor/jaeger/g-http/examples/multi_request_2.php +++ /dev/null @@ -1,37 +0,0 @@ - - * Date: 18/12/10 - * Time: 下午6:51 - */ - -require __DIR__.'/../vendor/autoload.php'; -use Jaeger\GHttp; -use GuzzleHttp\Psr7\Request; - -$requests = [ - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'php' - ])), - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'go' - ])), - new Request('POST','http://httpbin.org/post',[ - 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'g-http' - ],http_build_query([ - 'name' => 'c#' - ])) -]; - -GHttp::multiRequest($requests)->success(function($response,$index){ - print_r((String)$response->getBody()); - print_r($index); -})->post(); \ No newline at end of file diff --git a/vendor/jaeger/g-http/examples/request_with_cache.php b/vendor/jaeger/g-http/examples/request_with_cache.php deleted file mode 100644 index cdefdbb..0000000 --- a/vendor/jaeger/g-http/examples/request_with_cache.php +++ /dev/null @@ -1,33 +0,0 @@ - - * Date: 18/12/11 - * Time: 下午6:48 - */ - -require __DIR__.'/../vendor/autoload.php'; -use Jaeger\GHttp; -use Cache\Adapter\Predis\PredisCachePool; - - -$rt = GHttp::get('http://httpbin.org/get',[ - 'wd' => 'QueryList' -],[ - 'cache' => __DIR__, - 'cache_ttl' => 120 -]); - -print_r($rt); - -$client = new \Predis\Client('tcp:/127.0.0.1:6379'); -$pool = new PredisCachePool($client); - -$rt = GHttp::get('http://httpbin.org/get',[ - 'wd' => 'QueryList' -],[ - 'cache' => $pool, - 'cache_ttl' => 120 -]); - -print_r($rt); \ No newline at end of file diff --git a/vendor/jaeger/g-http/examples/simple.php b/vendor/jaeger/g-http/examples/simple.php deleted file mode 100644 index df65510..0000000 --- a/vendor/jaeger/g-http/examples/simple.php +++ /dev/null @@ -1,22 +0,0 @@ - - * Date: 18/12/11 - * Time: 下午6:48 - */ - -require __DIR__.'/../vendor/autoload.php'; -use Jaeger\GHttp; - -$rt = GHttp::get('http://httpbin.org/get',[ - 'wd' => 'QueryList' -],[ - 'headers' => [ - 'referer' => 'https://baidu.com', - 'User-Agent' => 'Mozilla/5.0 (Windows NTChrome/58.0.3029.110 Safari/537.36', - 'Cookie' => 'cookie xxx' - ], -]); - -print_r($rt); diff --git a/vendor/jaeger/g-http/src/Cache.php b/vendor/jaeger/g-http/src/Cache.php deleted file mode 100644 index f163a6e..0000000 --- a/vendor/jaeger/g-http/src/Cache.php +++ /dev/null @@ -1,65 +0,0 @@ - - * Date: 18/12/11 - * Time: 下午6:39 - */ - -namespace Jaeger; - - -use Cache\Adapter\Common\AbstractCachePool; -use Cache\Adapter\Filesystem\FilesystemCachePool; -use League\Flysystem\Adapter\Local; -use League\Flysystem\Filesystem; - -class Cache extends GHttp -{ - public static function remember($name, $arguments) - { - $cachePool = null; - $cacheConfig = self::initCacheConfig($arguments); - - if (empty($cacheConfig['cache'])) { - return self::$name(...$arguments); - } - if (is_string($cacheConfig['cache'])) { - $filesystemAdapter = new Local($cacheConfig['cache']); - $filesystem = new Filesystem($filesystemAdapter); - $cachePool = new FilesystemCachePool($filesystem); - }else if ($cacheConfig['cache'] instanceof AbstractCachePool) { - $cachePool = $cacheConfig['cache']; - } - - $cacheKey = self::getCacheKey($name,$arguments); - $data = $cachePool->get($cacheKey); - if(empty($data)) { - $data = self::$name(...$arguments); - if(!empty($data)) { - $cachePool->set($cacheKey,$data,$cacheConfig['cache_ttl']); - } - } - return $data; - } - - protected static function initCacheConfig($arguments) - { - $cacheConfig = [ - 'cache' => null, - 'cache_ttl' => null - ]; - if(!empty($arguments[2])) { - $cacheConfig = array_merge([ - 'cache' => null, - 'cache_ttl' => null - ],$arguments[2]); - } - return $cacheConfig; - } - - protected static function getCacheKey($name, $arguments) - { - return md5($name.'_'.json_encode($arguments)); - } -} \ No newline at end of file diff --git a/vendor/jaeger/g-http/src/GHttp.php b/vendor/jaeger/g-http/src/GHttp.php deleted file mode 100644 index 8daf808..0000000 --- a/vendor/jaeger/g-http/src/GHttp.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * @Version V1.0 - */ - -namespace Jaeger; - -use GuzzleHttp\Client; - -/** - * Class GHttp - * @package Jaeger - * - * @method static string get($url,$args = null,$otherArgs = []) - * @method static mixed getJson($url, $args = null, $otherArgs = []) - * @method static string post($url,$args = null,$otherArgs = []) - * @method static string postRaw($url, $raw = null, $otherArgs = []) - * @method static string postJson($url, $args = null, $otherArgs = []) - */ -class GHttp -{ - private static $client = null; - - public static function __callStatic($name, $arguments) - { - $protectedName = '_'.$name; - if(method_exists(self::class,$protectedName)){ - return Cache::remember($protectedName, $arguments); - } - throw new MethodNotFoundException('Call undefined method '.self::class.':'.$name.'()'); - } - - public static function getClient(array $config = []) - { - if(self::$client == null){ - self::$client = new Client($config); - } - return self::$client; - } - - /** - * @param $url - * @param array $args - * @param array $otherArgs - * @return string - */ - protected static function _get($url,$args = null,$otherArgs = []) - { - is_string($args) && parse_str($args,$args); - $args = array_merge([ - 'verify' => false, - 'query' => $args, - 'headers' => [ - 'referer' => $url, - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' - ] - ],$otherArgs); - $client = self::getClient(); - $response = $client->request('GET', $url,$args); - return (string)$response->getBody(); - } - - protected static function _getJson($url, $args = null, $otherArgs = []) - { - $data = self::get($url, $args , $otherArgs); - return json_decode($data,JSON_UNESCAPED_UNICODE); - } - - /** - * @param $url - * @param array $args - * @param array $otherArgs - * @return string - */ - protected static function _post($url,$args = null,$otherArgs = []) - { - is_string($args) && parse_str($args,$args); - $args = array_merge([ - 'verify' => false, - 'form_params' => $args, - 'headers' => [ - 'referer' => $url, - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' - ] - ],$otherArgs); - $client = self::getClient(); - $response = $client->request('Post', $url,$args); - return (string)$response->getBody(); - } - - /** - * @param $url - * @param null $raw - * @param array $otherArgs - * @return string - */ - protected static function _postRaw($url, $raw = null, $otherArgs = []) - { - is_array($raw) && $raw = json_encode($raw); - $args = array_merge([ - 'verify' => false, - 'body' => $raw, - 'headers' => [ - 'referer' => $url, - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' - ] - ],$otherArgs); - $client = self::getClient(); - $response = $client->request('Post', $url,$args); - return (string)$response->getBody(); - } - - /** - * @param $url - * @param null $args - * @param array $otherArgs - * @return string - */ - protected static function _postJson($url, $args = null, $otherArgs = []) - { - is_string($args) && parse_str($args,$args); - $args = array_merge([ - 'verify' => false, - 'json' => $args, - 'headers' => [ - 'referer' => $url, - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' - ] - ],$otherArgs); - $client = self::getClient(); - $response = $client->request('Post', $url,$args); - return (string)$response->getBody(); - } - - /** - * @param $url - * @param $filePath - * @param null $args - * @param array $otherArgs - * @return string - */ - public static function download($url,$filePath,$args = null,$otherArgs = []) - { - $otherArgs = array_merge($otherArgs,[ - 'sink' => $filePath, - ]); - return self::get($url,$args,$otherArgs); - } - - /** - * @param $urls - * @return MultiRequest - */ - public static function multiRequest($urls) - { - $client = self::getClient(); - return MultiRequest::newRequest($client)->urls($urls); - } -} \ No newline at end of file diff --git a/vendor/jaeger/g-http/src/MethodNotFoundException.php b/vendor/jaeger/g-http/src/MethodNotFoundException.php deleted file mode 100644 index dc6e527..0000000 --- a/vendor/jaeger/g-http/src/MethodNotFoundException.php +++ /dev/null @@ -1,19 +0,0 @@ - - * Date: 18/12/12 - * Time: 上午10:56 - */ - -namespace Jaeger; -use Exception; -use Throwable; - -class MethodNotFoundException extends Exception -{ - public function __construct($message = "", $code = 0, Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - } -} \ No newline at end of file diff --git a/vendor/jaeger/g-http/src/MultiRequest.php b/vendor/jaeger/g-http/src/MultiRequest.php deleted file mode 100644 index d77fc7f..0000000 --- a/vendor/jaeger/g-http/src/MultiRequest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * Date: 18/12/10 - * Time: 下午6:04 - */ - -namespace Jaeger; -use GuzzleHttp\Client; -use Closure; -use GuzzleHttp\Pool; -use GuzzleHttp\Psr7\Request; - -class MultiRequest -{ - protected $client; - protected $headers = []; - protected $options = []; - protected $successCallback; - protected $errorCallback; - protected $urls = []; - protected $method; - protected $concurrency = 5; - - public function __construct(Client $client) - { - $this->client = $client; - $this->headers = [ - 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' - ]; - } - - public static function newRequest(Client $client) - { - $request = new self($client); - return $request; - } - - public function withHeaders($headers) - { - $this->headers = array_merge($this->headers,$headers); - return $this; - } - - public function withOptions($options) - { - $this->options = $options; - return $this; - } - - public function concurrency($concurrency) - { - $this->concurrency = $concurrency; - return $this; - } - - public function success(Closure $success) - { - $this->successCallback = $success; - return $this; - } - - public function error(Closure $error) - { - $this->errorCallback = $error; - return $this; - } - - public function urls(array $urls) - { - $this->urls = $urls; - return $this; - } - - public function get() - { - $this->method = 'GET'; - $this->send(); - } - - public function post() - { - $this->method = 'POST'; - $this->send(); - } - - protected function send() - { - $client = $this->client; - - $requests = function ($urls) use($client){ - foreach ($urls as $url) { - if (is_string($url)) { - yield new Request($this->method,$url,$this->headers); - } else { - yield $url; - } - } - }; - - $pool = new Pool($client, $requests($this->urls), [ - 'concurrency' => $this->concurrency, - 'fulfilled' => $this->successCallback, - 'rejected' => $this->errorCallback, - 'options' => $this->options - ]); - - $promise = $pool->promise(); - $promise->wait(); - } - -} \ No newline at end of file diff --git a/vendor/jaeger/phpquery-single/README.md b/vendor/jaeger/phpquery-single/README.md deleted file mode 100644 index 903163e..0000000 --- a/vendor/jaeger/phpquery-single/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# phpQuery-single -phpQuery onefile composer.Continuous maintenance,Welcome PR. - -`QueryList` base on phpQuery: https://github.com/jae-jae/QueryList - -phpQuery单文件版本,持续维护,欢迎PR. -> phpQuery项目主页:http://code.google.com/p/phpquery/ - -`QueryList`是基于phpQuery的采集工具: https://github.com/jae-jae/QueryList - -## Composer Installation -Packagist: https://packagist.org/packages/jaeger/phpquery-single -``` -composer require jaeger/phpquery-single -``` - -## Usage -```php -$html = << -
- QueryList官网 - 这是图片 - 这是图片2 -
- 其它的一些文本 - -STR; - -$doc = phpQuery::newDocumentHTML($html); - -$src = $doc->find('.two img:eq(0)')->attr('src'); - -echo $src; -// http://querylist.cc/1.jpg -``` \ No newline at end of file diff --git a/vendor/jaeger/phpquery-single/composer.json b/vendor/jaeger/phpquery-single/composer.json deleted file mode 100644 index 24fe5a4..0000000 --- a/vendor/jaeger/phpquery-single/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "jaeger/phpquery-single", - "description": "phpQuery单文件版本,是Querylist的依赖(http://querylist.cc/),phpQuery项目主页:http://code.google.com/p/phpquery/", - "homepage": "http://code.google.com/p/phpquery/", - "license": "MIT", - "require": { - "PHP":">=5.3.0" - }, - "authors": [ - { - "name": "Tobiasz Cudnik" - ,"email": "tobiasz.cudnik@gmail.com" - ,"homepage": "https://github.com/TobiaszCudnik" - ,"role": "Developer" - } - ,{ - "name": "Jaeger", - "role": "Packager" - } - ], - "autoload":{ - "classmap":["phpQuery.php"] - } -} diff --git a/vendor/jaeger/phpquery-single/phpQuery.php b/vendor/jaeger/phpquery-single/phpQuery.php deleted file mode 100644 index 90391cd..0000000 --- a/vendor/jaeger/phpquery-single/phpQuery.php +++ /dev/null @@ -1,6086 +0,0 @@ - - * @license http://www.opensource.org/licenses/mit-license.php MIT License - * @package phpQuery - */ - -// class names for instanceof -// TODO move them as class constants into phpQuery -define('DOMDOCUMENT', 'DOMDocument'); -define('DOMELEMENT', 'DOMElement'); -define('DOMNODELIST', 'DOMNodeList'); -define('DOMNODE', 'DOMNode'); - -/** - * DOMEvent class. - * - * Based on - * @link http://developer.mozilla.org/En/DOM:event - * @author Tobiasz Cudnik - * @package phpQuery - * @todo implement ArrayAccess ? - */ -class DOMEvent -{ - /** - * Returns a boolean indicating whether the event bubbles up through the DOM or not. - * - * @var unknown_type - */ - public $bubbles = true; - /** - * Returns a boolean indicating whether the event is cancelable. - * - * @var unknown_type - */ - public $cancelable = true; - /** - * Returns a reference to the currently registered target for the event. - * - * @var unknown_type - */ - public $currentTarget; - /** - * Returns detail about the event, depending on the type of event. - * - * @var unknown_type - * @link http://developer.mozilla.org/en/DOM/event.detail - */ - public $detail; // ??? - /** - * Used to indicate which phase of the event flow is currently being evaluated. - * - * NOT IMPLEMENTED - * - * @var unknown_type - * @link http://developer.mozilla.org/en/DOM/event.eventPhase - */ - public $eventPhase; // ??? - /** - * The explicit original target of the event (Mozilla-specific). - * - * NOT IMPLEMENTED - * - * @var unknown_type - */ - public $explicitOriginalTarget; // moz only - /** - * The original target of the event, before any retargetings (Mozilla-specific). - * - * NOT IMPLEMENTED - * - * @var unknown_type - */ - public $originalTarget; // moz only - /** - * Identifies a secondary target for the event. - * - * @var unknown_type - */ - public $relatedTarget; - /** - * Returns a reference to the target to which the event was originally dispatched. - * - * @var unknown_type - */ - public $target; - /** - * Returns the time that the event was created. - * - * @var unknown_type - */ - public $timeStamp; - /** - * Returns the name of the event (case-insensitive). - */ - public $type; - public $runDefault = true; - public $data = null; - public function __construct($data) - { - foreach ($data as $k => $v) { - $this->$k = $v; - } - if (!$this->timeStamp) - $this->timeStamp = time(); - } - /** - * Cancels the event (if it is cancelable). - * - */ - public function preventDefault() - { - $this->runDefault = false; - } - /** - * Stops the propagation of events further along in the DOM. - * - */ - public function stopPropagation() - { - $this->bubbles = false; - } -} - - -/** - * DOMDocumentWrapper class simplifies work with DOMDocument. - * - * Know bug: - * - in XHTML fragments,
changes to
- * - * @todo check XML catalogs compatibility - * @author Tobiasz Cudnik - * @package phpQuery - */ -class DOMDocumentWrapper -{ - /** - * @var DOMDocument - */ - public $document; - public $id; - /** - * @todo Rewrite as method and quess if null. - * @var unknown_type - */ - public $contentType = ''; - public $xpath; - public $uuid = 0; - public $data = array(); - public $dataNodes = array(); - public $events = array(); - public $eventsNodes = array(); - public $eventsGlobal = array(); - /** - * @TODO iframes support http://code.google.com/p/phpquery/issues/detail?id=28 - * @var unknown_type - */ - public $frames = array(); - /** - * Document root, by default equals to document itself. - * Used by documentFragments. - * - * @var DOMNode - */ - public $root; - public $isDocumentFragment; - public $isXML = false; - public $isXHTML = false; - public $isHTML = false; - public $charset; - public function __construct($markup = null, $contentType = null, $newDocumentID = null) - { - if (isset($markup)) - $this->load($markup, $contentType, $newDocumentID); - $this->id = $newDocumentID - ? $newDocumentID - : md5(microtime()); - } - public function load($markup, $contentType = null, $newDocumentID = null) - { - // phpQuery::$documents[$id] = $this; - $this->contentType = strtolower($contentType); - if ($markup instanceof DOMDOCUMENT) { - $this->document = $markup; - $this->root = $this->document; - $this->charset = $this->document->encoding; - // TODO isDocumentFragment - $loaded = true; - } else { - $loaded = $this->loadMarkup($markup); - } - if ($loaded) { - // $this->document->formatOutput = true; - $this->document->preserveWhiteSpace = true; - $this->xpath = new DOMXPath($this->document); - $this->afterMarkupLoad(); - return true; - // remember last loaded document - // return phpQuery::selectDocument($id); - } - return false; - } - protected function afterMarkupLoad() - { - if ($this->isXHTML) { - $this->xpath->registerNamespace("html", "http://www.w3.org/1999/xhtml"); - } - } - protected function loadMarkup($markup) - { - $loaded = false; - if ($this->contentType) { - self::debug("Load markup for content type {$this->contentType}"); - // content determined by contentType - list($contentType, $charset) = $this->contentTypeToArray($this->contentType); - switch ($contentType) { - case 'text/html': - phpQuery::debug("Loading HTML, content type '{$this->contentType}'"); - $loaded = $this->loadMarkupHTML($markup, $charset); - break; - case 'text/xml': - case 'application/xhtml+xml': - phpQuery::debug("Loading XML, content type '{$this->contentType}'"); - $loaded = $this->loadMarkupXML($markup, $charset); - break; - default: - // for feeds or anything that sometimes doesn't use text/xml - if (strpos('xml', $this->contentType) !== false) { - phpQuery::debug("Loading XML, content type '{$this->contentType}'"); - $loaded = $this->loadMarkupXML($markup, $charset); - } else - phpQuery::debug("Could not determine document type from content type '{$this->contentType}'"); - } - } else { - // content type autodetection - if ($this->isXML($markup)) { - phpQuery::debug("Loading XML, isXML() == true"); - $loaded = $this->loadMarkupXML($markup); - if (!$loaded && $this->isXHTML) { - phpQuery::debug('Loading as XML failed, trying to load as HTML, isXHTML == true'); - $loaded = $this->loadMarkupHTML($markup); - } - } else { - phpQuery::debug("Loading HTML, isXML() == false"); - $loaded = $this->loadMarkupHTML($markup); - } - } - return $loaded; - } - protected function loadMarkupReset() - { - $this->isXML = $this->isXHTML = $this->isHTML = false; - } - protected function documentCreate($charset, $version = '1.0') - { - if (!$version) - $version = '1.0'; - $this->document = new DOMDocument($version, $charset); - $this->charset = $this->document->encoding; - // $this->document->encoding = $charset; - $this->document->formatOutput = true; - $this->document->preserveWhiteSpace = true; - } - protected function loadMarkupHTML($markup, $requestedCharset = null) - { - if (phpQuery::$debug) - phpQuery::debug('Full markup load (HTML): ' . substr($markup, 0, 250)); - $this->loadMarkupReset(); - $this->isHTML = true; - if (!isset($this->isDocumentFragment)) - $this->isDocumentFragment = self::isDocumentFragmentHTML($markup); - $charset = null; - $documentCharset = $this->charsetFromHTML($markup); - $addDocumentCharset = false; - if ($documentCharset) { - $charset = $documentCharset; - $markup = $this->charsetFixHTML($markup); - } else if ($requestedCharset) { - $charset = $requestedCharset; - } - if (!$charset) - $charset = phpQuery::$defaultCharset; - // HTTP 1.1 says that the default charset is ISO-8859-1 - // @see http://www.w3.org/International/O-HTTP-charset - if (!$documentCharset) { - $documentCharset = 'ISO-8859-1'; - $addDocumentCharset = true; - } - // Should be careful here, still need 'magic encoding detection' since lots of pages have other 'default encoding' - // Worse, some pages can have mixed encodings... we'll try not to worry about that - $requestedCharset = $requestedCharset ? strtoupper($requestedCharset) : ""; - $documentCharset = strtoupper($documentCharset); - phpQuery::debug("DOC: $documentCharset REQ: $requestedCharset"); - if ($requestedCharset && $documentCharset && $requestedCharset !== $documentCharset) { - phpQuery::debug("CHARSET CONVERT"); - // Document Encoding Conversion - // http://code.google.com/p/phpquery/issues/detail?id=86 - if (function_exists('mb_detect_encoding')) { - $possibleCharsets = array($documentCharset, $requestedCharset, 'AUTO'); - $docEncoding = mb_detect_encoding($markup, implode(', ', $possibleCharsets)); - if (!$docEncoding) - $docEncoding = $documentCharset; // ok trust the document - phpQuery::debug("DETECTED '$docEncoding'"); - // Detected does not match what document says... - if ($docEncoding !== $documentCharset) { - // Tricky.. - } - if ($docEncoding !== $requestedCharset) { - phpQuery::debug("CONVERT $docEncoding => $requestedCharset"); - $markup = mb_convert_encoding($markup, $requestedCharset, $docEncoding); - $markup = $this->charsetAppendToHTML($markup, $requestedCharset); - $charset = $requestedCharset; - } - } else { - phpQuery::debug("TODO: charset conversion without mbstring..."); - } - } - $return = false; - if ($this->isDocumentFragment) { - phpQuery::debug("Full markup load (HTML), DocumentFragment detected, using charset '$charset'"); - $return = $this->documentFragmentLoadMarkup($this, $charset, $markup); - } else { - if ($addDocumentCharset) { - phpQuery::debug("Full markup load (HTML), appending charset: '$charset'"); - $markup = $this->charsetAppendToHTML($markup, $charset); - } - phpQuery::debug("Full markup load (HTML), documentCreate('$charset')"); - $this->documentCreate($charset); - $return = phpQuery::$debug === 2 - ? $this->document->loadHTML($markup) - : @$this->document->loadHTML($markup); - if ($return) - $this->root = $this->document; - } - if ($return && !$this->contentType) - $this->contentType = 'text/html'; - return $return; - } - protected function loadMarkupXML($markup, $requestedCharset = null) - { - if (phpQuery::$debug) - phpQuery::debug('Full markup load (XML): ' . substr($markup, 0, 250)); - $this->loadMarkupReset(); - $this->isXML = true; - // check agains XHTML in contentType or markup - $isContentTypeXHTML = $this->isXHTML(); - $isMarkupXHTML = $this->isXHTML($markup); - if ($isContentTypeXHTML || $isMarkupXHTML) { - self::debug('Full markup load (XML), XHTML detected'); - $this->isXHTML = true; - } - // determine document fragment - if (!isset($this->isDocumentFragment)) - $this->isDocumentFragment = $this->isXHTML - ? self::isDocumentFragmentXHTML($markup) - : self::isDocumentFragmentXML($markup); - // this charset will be used - $charset = null; - // charset from XML declaration @var string - $documentCharset = $this->charsetFromXML($markup); - if (!$documentCharset) { - if ($this->isXHTML) { - // this is XHTML, try to get charset from content-type meta header - $documentCharset = $this->charsetFromHTML($markup); - if ($documentCharset) { - phpQuery::debug("Full markup load (XML), appending XHTML charset '$documentCharset'"); - $this->charsetAppendToXML($markup, $documentCharset); - $charset = $documentCharset; - } - } - if (!$documentCharset) { - // if still no document charset... - $charset = $requestedCharset; - } - } else if ($requestedCharset) { - $charset = $requestedCharset; - } - if (!$charset) { - $charset = phpQuery::$defaultCharset; - } - if ($requestedCharset && $documentCharset && $requestedCharset != $documentCharset) { - // TODO place for charset conversion - // $charset = $requestedCharset; - } - $return = false; - if ($this->isDocumentFragment) { - phpQuery::debug("Full markup load (XML), DocumentFragment detected, using charset '$charset'"); - $return = $this->documentFragmentLoadMarkup($this, $charset, $markup); - } else { - // FIXME ??? - if ($isContentTypeXHTML && !$isMarkupXHTML) - if (!$documentCharset) { - phpQuery::debug("Full markup load (XML), appending charset '$charset'"); - $markup = $this->charsetAppendToXML($markup, $charset); - } - // see http://pl2.php.net/manual/en/book.dom.php#78929 - // LIBXML_DTDLOAD (>= PHP 5.1) - // does XML ctalogues works with LIBXML_NONET - // $this->document->resolveExternals = true; - // TODO test LIBXML_COMPACT for performance improvement - // create document - $this->documentCreate($charset); - if (phpversion() < 5.1) { - $this->document->resolveExternals = true; - $return = phpQuery::$debug === 2 - ? $this->document->loadXML($markup) - : @$this->document->loadXML($markup); - } else { - /** @link http://pl2.php.net/manual/en/libxml.constants.php */ - $libxmlStatic = phpQuery::$debug === 2 - ? LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NONET - : LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOERROR; - $return = $this->document->loadXML($markup, $libxmlStatic); - // if (! $return) - // $return = $this->document->loadHTML($markup); - } - if ($return) - $this->root = $this->document; - } - if ($return) { - if (!$this->contentType) { - if ($this->isXHTML) - $this->contentType = 'application/xhtml+xml'; - else - $this->contentType = 'text/xml'; - } - return $return; - } else { - throw new Exception("Error loading XML markup"); - } - } - protected function isXHTML($markup = null) - { - if (!isset($markup)) { - return strpos($this->contentType, 'xhtml') !== false; - } - // XXX ok ? - return strpos($markup, "doctype) && is_object($dom->doctype) - // ? $dom->doctype->publicId - // : self::$defaultDoctype; - } - protected function isXML($markup) - { - // return strpos($markup, ']+http-equiv\\s*=\\s*(["|\'])Content-Type\\1([^>]+?)>@i', - $markup, - $matches - ); - if (!isset($matches[0])) - return array(null, null); - // get attr 'content' - preg_match('@content\\s*=\\s*(["|\'])(.+?)\\1@', $matches[0], $matches); - if (!isset($matches[0])) - return array(null, null); - return $this->contentTypeToArray($matches[2]); - } - protected function charsetFromHTML($markup) - { - $contentType = $this->contentTypeFromHTML($markup); - return $contentType[1]; - } - protected function charsetFromXML($markup) - { - $matches; - // find declaration - preg_match( - '@<' . '?xml[^>]+encoding\\s*=\\s*(["|\'])(.*?)\\1@i', - $markup, - $matches - ); - return isset($matches[2]) - ? strtolower($matches[2]) - : null; - } - /** - * Repositions meta[type=charset] at the start of head. Bypasses DOMDocument bug. - * - * @link http://code.google.com/p/phpquery/issues/detail?id=80 - * @param $html - */ - protected function charsetFixHTML($markup) - { - $matches = array(); - // find meta tag - preg_match( - '@\s*]+http-equiv\\s*=\\s*(["|\'])Content-Type\\1([^>]+?)>@i', - $markup, - $matches, - PREG_OFFSET_CAPTURE - ); - if (!isset($matches[0])) - return; - $metaContentType = $matches[0][0]; - $markup = substr($markup, 0, $matches[0][1]) - . substr($markup, $matches[0][1] + strlen($metaContentType)); - $headStart = stripos($markup, ''); - $markup = substr($markup, 0, $headStart + 6) . $metaContentType - . substr($markup, $headStart + 6); - return $markup; - } - protected function charsetAppendToHTML($html, $charset, $xhtml = false) - { - // remove existing meta[type=content-type] - $html = preg_replace('@\s*]+http-equiv\\s*=\\s*(["|\'])Content-Type\\1([^>]+?)>@i', '', $html); - $meta = ''; - if (strpos($html, ')@s', - "{$meta}", - $html - ); - } - } else { - return preg_replace( - '@)@s', - '' . $meta, - $html - ); - } - } - protected function charsetAppendToXML($markup, $charset) - { - $declaration = '<' . '?xml version="1.0" encoding="' . $charset . '"?' . '>'; - return $declaration . $markup; - } - public static function isDocumentFragmentHTML($markup) - { - return stripos($markup, 'documentFragmentCreate($node, $sourceCharset); - // if ($fake === false) - // throw new Exception("Error loading documentFragment markup"); - // else - // $return = array_merge($return, - // $this->import($fake->root->childNodes) - // ); - // } else { - // $return[] = $this->document->importNode($node, true); - // } - // } - // return $return; - // } else { - // // string markup - // $fake = $this->documentFragmentCreate($source, $sourceCharset); - // if ($fake === false) - // throw new Exception("Error loading documentFragment markup"); - // else - // return $this->import($fake->root->childNodes); - // } - if (is_array($source) || $source instanceof DOMNODELIST) { - // dom nodes - self::debug('Importing nodes to document'); - foreach ($source as $node) - $return[] = $this->document->importNode($node, true); - } else { - // string markup - $fake = $this->documentFragmentCreate($source, $sourceCharset); - if ($fake === false) - throw new Exception("Error loading documentFragment markup"); - else - return $this->import($fake->root->childNodes); - } - return $return; - } - /** - * Creates new document fragment. - * - * @param $source - * @return DOMDocumentWrapper - */ - protected function documentFragmentCreate($source, $charset = null) - { - $fake = new DOMDocumentWrapper(); - $fake->contentType = $this->contentType; - $fake->isXML = $this->isXML; - $fake->isHTML = $this->isHTML; - $fake->isXHTML = $this->isXHTML; - $fake->root = $fake->document; - if (!$charset) - $charset = $this->charset; - // $fake->documentCreate($this->charset); - if ($source instanceof DOMNODE && !($source instanceof DOMNODELIST)) - $source = array($source); - if (is_array($source) || $source instanceof DOMNODELIST) { - // dom nodes - // load fake document - if (!$this->documentFragmentLoadMarkup($fake, $charset)) - return false; - $nodes = $fake->import($source); - foreach ($nodes as $node) - $fake->root->appendChild($node); - } else { - // string markup - $this->documentFragmentLoadMarkup($fake, $charset, $source); - } - return $fake; - } - /** - * - * @param $document DOMDocumentWrapper - * @param $markup - * @return $document - */ - private function documentFragmentLoadMarkup($fragment, $charset, $markup = null) - { - // TODO error handling - // TODO copy doctype - // tempolary turn off - $fragment->isDocumentFragment = false; - if ($fragment->isXML) { - if ($fragment->isXHTML) { - // add FAKE element to set default namespace - $fragment->loadMarkupXML('' - . '' - . '' . $markup . ''); - $fragment->root = $fragment->document->firstChild->nextSibling; - } else { - $fragment->loadMarkupXML('' . $markup . ''); - $fragment->root = $fragment->document->firstChild; - } - } else { - $markup2 = phpQuery::$defaultDoctype . ''; - if ($markup == null) { - $markup = ""; - } - $noBody = strpos($markup, 'loadMarkupHTML($markup2); - // TODO resolv body tag merging issue - $fragment->root = $noBody - ? $fragment->document->firstChild->nextSibling->firstChild->nextSibling - : $fragment->document->firstChild->nextSibling->firstChild->nextSibling; - } - if (!$fragment->root) - return false; - $fragment->isDocumentFragment = true; - return true; - } - protected function documentFragmentToMarkup($fragment) - { - phpQuery::debug('documentFragmentToMarkup'); - $tmp = $fragment->isDocumentFragment; - $fragment->isDocumentFragment = false; - $markup = $fragment->markup(); - if ($fragment->isXML) { - $markup = substr($markup, 0, strrpos($markup, '')); - if ($fragment->isXHTML) { - $markup = substr($markup, strpos($markup, '') + 6); - } - } else { - $markup = substr($markup, strpos($markup, '') + 6); - $markup = substr($markup, 0, strrpos($markup, '')); - } - $fragment->isDocumentFragment = $tmp; - if (phpQuery::$debug) - phpQuery::debug('documentFragmentToMarkup: ' . substr($markup, 0, 150)); - return $markup; - } - /** - * Return document markup, starting with optional $nodes as root. - * - * @param $nodes DOMNode|DOMNodeList - * @return string - */ - public function markup($nodes = null, $innerMarkup = false) - { - if (isset($nodes) && count($nodes) == 1 && $nodes[0] instanceof DOMDOCUMENT) - $nodes = null; - if (isset($nodes)) { - $markup = ''; - if (!is_array($nodes) && !($nodes instanceof DOMNODELIST)) - $nodes = array($nodes); - if ($this->isDocumentFragment && !$innerMarkup) - foreach ($nodes as $i => $node) - if ($node->isSameNode($this->root)) { - // var_dump($node); - $nodes = array_slice($nodes, 0, $i) - + phpQuery::DOMNodeListToArray($node->childNodes) - + array_slice($nodes, $i + 1); - } - if ($this->isXML && !$innerMarkup) { - self::debug("Getting outerXML with charset '{$this->charset}'"); - // we need outerXML, so we can benefit from - // $node param support in saveXML() - foreach ($nodes as $node) - $markup .= $this->document->saveXML($node); - } else { - $loop = array(); - if ($innerMarkup) - foreach ($nodes as $node) { - if ($node->childNodes) - foreach ($node->childNodes as $child) - $loop[] = $child; - else - $loop[] = $node; - } - else - $loop = $nodes; - self::debug("Getting markup, moving selected nodes (" . count($loop) . ") to new DocumentFragment"); - $fake = $this->documentFragmentCreate($loop); - $markup = $this->documentFragmentToMarkup($fake); - } - if ($this->isXHTML) { - self::debug("Fixing XHTML"); - $markup = self::markupFixXHTML($markup); - } - self::debug("Markup: " . substr($markup, 0, 250)); - return $markup; - } else { - if ($this->isDocumentFragment) { - // documentFragment, html only... - self::debug("Getting markup, DocumentFragment detected"); - // return $this->markup( - //// $this->document->getElementsByTagName('body')->item(0) - // $this->document->root, true - // ); - $markup = $this->documentFragmentToMarkup($this); - // no need for markupFixXHTML, as it's done thought markup($nodes) method - return $markup; - } else { - self::debug("Getting markup (" . ($this->isXML ? 'XML' : 'HTML') . "), final with charset '{$this->charset}'"); - $markup = $this->isXML - ? $this->document->saveXML() - : $this->document->saveHTML(); - if ($this->isXHTML) { - self::debug("Fixing XHTML"); - $markup = self::markupFixXHTML($markup); - } - self::debug("Markup: " . substr($markup, 0, 250)); - return $markup; - } - } - } - protected static function markupFixXHTML($markup) - { - $markup = self::expandEmptyTag('script', $markup); - $markup = self::expandEmptyTag('select', $markup); - $markup = self::expandEmptyTag('textarea', $markup); - return $markup; - } - public static function debug($text) - { - phpQuery::debug($text); - } - /** - * expandEmptyTag - * - * @param $tag - * @param $xml - * @return unknown_type - * @author mjaque at ilkebenson dot com - * @link http://php.net/manual/en/domdocument.savehtml.php#81256 - */ - public static function expandEmptyTag($tag, $xml) - { - $indice = 0; - while ($indice < strlen($xml)) { - $pos = strpos($xml, "<$tag ", $indice); - if ($pos) { - $posCierre = strpos($xml, ">", $pos); - if ($xml[$posCierre - 1] == "/") { - $xml = substr_replace($xml, ">", $posCierre - 1, 2); - } - $indice = $posCierre; - } else break; - } - return $xml; - } -} - -/** - * Event handling class. - * - * @author Tobiasz Cudnik - * @package phpQuery - * @static - */ -abstract class phpQueryEvents -{ - /** - * Trigger a type of event on every matched element. - * - * @param DOMNode|phpQueryObject|string $document - * @param unknown_type $type - * @param unknown_type $data - * - * @TODO exclusive events (with !) - * @TODO global events (test) - * @TODO support more than event in $type (space-separated) - */ - public static function trigger($document, $type, $data = array(), $node = null) - { - // trigger: function(type, data, elem, donative, extra) { - $documentID = phpQuery::getDocumentID($document); - $namespace = null; - if (strpos($type, '.') !== false) - list($name, $namespace) = explode('.', $type); - else - $name = $type; - if (!$node) { - if (self::issetGlobal($documentID, $type)) { - $pq = phpQuery::getDocument($documentID); - // TODO check add($pq->document) - $pq->find('*')->add($pq->document) - ->trigger($type, $data); - } - } else { - if (isset($data[0]) && $data[0] instanceof DOMEvent) { - $event = $data[0]; - $event->relatedTarget = $event->target; - $event->target = $node; - $data = array_slice($data, 1); - } else { - $event = new DOMEvent(array( - 'type' => $type, - 'target' => $node, - 'timeStamp' => time(), - )); - } - $i = 0; - while ($node) { - // TODO whois - phpQuery::debug("Triggering " . ($i ? "bubbled " : '') . "event '{$type}' on " - . "node \n"); //.phpQueryObject::whois($node)."\n"); - $event->currentTarget = $node; - $eventNode = self::getNode($documentID, $node); - if (isset($eventNode->eventHandlers)) { - foreach ($eventNode->eventHandlers as $eventType => $handlers) { - $eventNamespace = null; - if (strpos($type, '.') !== false) - list($eventName, $eventNamespace) = explode('.', $eventType); - else - $eventName = $eventType; - if ($name != $eventName) - continue; - if ($namespace && $eventNamespace && $namespace != $eventNamespace) - continue; - foreach ($handlers as $handler) { - phpQuery::debug("Calling event handler\n"); - $event->data = $handler['data'] - ? $handler['data'] - : null; - $params = array_merge(array($event), $data); - $return = phpQuery::callbackRun($handler['callback'], $params); - if ($return === false) { - $event->bubbles = false; - } - } - } - } - // to bubble or not to bubble... - if (!$event->bubbles) - break; - $node = $node->parentNode; - $i++; - } - } - } - /** - * Binds a handler to one or more events (like click) for each matched element. - * Can also bind custom events. - * - * @param DOMNode|phpQueryObject|string $document - * @param unknown_type $type - * @param unknown_type $data Optional - * @param unknown_type $callback - * - * @TODO support '!' (exclusive) events - * @TODO support more than event in $type (space-separated) - * @TODO support binding to global events - */ - public static function add($document, $node, $type, $data, $callback = null) - { - phpQuery::debug("Binding '$type' event"); - $documentID = phpQuery::getDocumentID($document); - // if (is_null($callback) && is_callable($data)) { - // $callback = $data; - // $data = null; - // } - $eventNode = self::getNode($documentID, $node); - if (!$eventNode) - $eventNode = self::setNode($documentID, $node); - if (!isset($eventNode->eventHandlers[$type])) - $eventNode->eventHandlers[$type] = array(); - $eventNode->eventHandlers[$type][] = array( - 'callback' => $callback, - 'data' => $data, - ); - } - /** - * Enter description here... - * - * @param DOMNode|phpQueryObject|string $document - * @param unknown_type $type - * @param unknown_type $callback - * - * @TODO namespace events - * @TODO support more than event in $type (space-separated) - */ - public static function remove($document, $node, $type = null, $callback = null) - { - $documentID = phpQuery::getDocumentID($document); - $eventNode = self::getNode($documentID, $node); - if (is_object($eventNode) && isset($eventNode->eventHandlers[$type])) { - if ($callback) { - foreach ($eventNode->eventHandlers[$type] as $k => $handler) - if ($handler['callback'] == $callback) - unset($eventNode->eventHandlers[$type][$k]); - } else { - unset($eventNode->eventHandlers[$type]); - } - } - } - protected static function getNode($documentID, $node) - { - foreach (phpQuery::$documents[$documentID]->eventsNodes as $eventNode) { - if ($node->isSameNode($eventNode)) - return $eventNode; - } - } - protected static function setNode($documentID, $node) - { - phpQuery::$documents[$documentID]->eventsNodes[] = $node; - return phpQuery::$documents[$documentID]->eventsNodes[count(phpQuery::$documents[$documentID]->eventsNodes) - 1]; - } - protected static function issetGlobal($documentID, $type) - { - return isset(phpQuery::$documents[$documentID]) - ? in_array($type, phpQuery::$documents[$documentID]->eventsGlobal) - : false; - } -} - - -interface ICallbackNamed -{ - function hasName(); - function getName(); -} -/** - * Callback class introduces currying-like pattern. - * - * Example: - * function foo($param1, $param2, $param3) { - * var_dump($param1, $param2, $param3); - * } - * $fooCurried = new Callback('foo', - * 'param1 is now statically set', - * new CallbackParam, new CallbackParam - * ); - * phpQuery::callbackRun($fooCurried, - * array('param2 value', 'param3 value' - * ); - * - * Callback class is supported in all phpQuery methods which accepts callbacks. - * - * @link http://code.google.com/p/phpquery/wiki/Callbacks#Param_Structures - * @author Tobiasz Cudnik - * - * @TODO??? return fake forwarding function created via create_function - * @TODO honor paramStructure - */ -class Callback -implements ICallbackNamed -{ - public $callback = null; - public $params = null; - protected $name; - public function __construct( - $callback, - $param1 = null, - $param2 = null, - $param3 = null - ) { - $params = func_get_args(); - $params = array_slice($params, 1); - if ($callback instanceof Callback) { - // TODO implement recurention - } else { - $this->callback = $callback; - $this->params = $params; - } - } - public function getName() - { - return 'Callback: ' . $this->name; - } - public function hasName() - { - return isset($this->name) && $this->name; - } - public function setName($name) - { - $this->name = $name; - return $this; - } - // TODO test me - // public function addParams() { - // $params = func_get_args(); - // return new Callback($this->callback, $this->params+$params); - // } -} -/** - * Shorthand for new Callback(create_function(...), ...); - * - * @author Tobiasz Cudnik - */ -class CallbackBody extends Callback -{ - public function __construct( - $paramList, - $code, - $param1 = null, - $param2 = null, - $param3 = null - ) { - $params = func_get_args(); - $params = array_slice($params, 2); - $this->callback = create_function($paramList, $code); - $this->params = $params; - } -} -/** - * Callback type which on execution returns reference passed during creation. - * - * @author Tobiasz Cudnik - */ -class CallbackReturnReference extends Callback -implements ICallbackNamed -{ - protected $reference; - public function __construct(&$reference, $name = null) - { - $this->reference = &$reference; - $this->callback = array($this, 'callback'); - } - public function callback() - { - return $this->reference; - } - public function getName() - { - return 'Callback: ' . $this->name; - } - public function hasName() - { - return isset($this->name) && $this->name; - } -} -/** - * Callback type which on execution returns value passed during creation. - * - * @author Tobiasz Cudnik - */ -class CallbackReturnValue extends Callback -implements ICallbackNamed -{ - protected $value; - protected $name; - public function __construct($value, $name = null) - { - $this->value = &$value; - $this->name = $name; - $this->callback = array($this, 'callback'); - } - public function callback() - { - return $this->value; - } - public function __toString() - { - return $this->getName(); - } - public function getName() - { - return 'Callback: ' . $this->name; - } - public function hasName() - { - return isset($this->name) && $this->name; - } -} -/** - * CallbackParameterToReference can be used when we don't really want a callback, - * only parameter passed to it. CallbackParameterToReference takes first - * parameter's value and passes it to reference. - * - * @author Tobiasz Cudnik - */ -class CallbackParameterToReference extends Callback -{ - /** - * @param $reference - * @TODO implement $paramIndex; - * param index choose which callback param will be passed to reference - */ - public function __construct(&$reference) - { - $this->callback = &$reference; - } -} -//class CallbackReference extends Callback { -// /** -// * -// * @param $reference -// * @param $paramIndex -// * @todo implement $paramIndex; param index choose which callback param will be passed to reference -// */ -// public function __construct(&$reference, $name = null){ -// $this->callback =& $reference; -// } -//} -class CallbackParam -{ -} - -/** - * Class representing phpQuery objects. - * - * @author Tobiasz Cudnik - * @package phpQuery - * @method phpQueryObject clone() clone() - * @method phpQueryObject empty() empty() - * @method phpQueryObject next() next($selector = null) - * @method phpQueryObject prev() prev($selector = null) - * @property Int $length - */ -class phpQueryObject -implements Iterator, Countable, ArrayAccess -{ - public $documentID = null; - /** - * DOMDocument class. - * - * @var DOMDocument - */ - public $document = null; - public $charset = null; - /** - * - * @var DOMDocumentWrapper - */ - public $documentWrapper = null; - /** - * XPath interface. - * - * @var DOMXPath - */ - public $xpath = null; - /** - * Stack of selected elements. - * @TODO refactor to ->nodes - * @var array - */ - public $elements = array(); - /** - * @access private - */ - protected $elementsBackup = array(); - /** - * @access private - */ - protected $previous = null; - /** - * @access private - * @TODO deprecate - */ - protected $root = array(); - /** - * Indicated if doument is just a fragment (no tag). - * - * Every document is realy a full document, so even documentFragments can - * be queried against , but getDocument(id)->htmlOuter() will return - * only contents of . - * - * @var bool - */ - public $documentFragment = true; - /** - * Iterator interface helper - * @access private - */ - protected $elementsInterator = array(); - /** - * Iterator interface helper - * @access private - */ - protected $valid = false; - /** - * Iterator interface helper - * @access private - */ - protected $current = null; - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function __construct($documentID) - { - // if ($documentID instanceof self) - // var_dump($documentID->getDocumentID()); - $id = $documentID instanceof self - ? $documentID->getDocumentID() - : $documentID; - // var_dump($id); - if (!isset(phpQuery::$documents[$id])) { - // var_dump(phpQuery::$documents); - throw new Exception("Document with ID '{$id}' isn't loaded. Use phpQuery::newDocument(\$html) or phpQuery::newDocumentFile(\$file) first."); - } - $this->documentID = $id; - $this->documentWrapper = &phpQuery::$documents[$id]; - $this->document = &$this->documentWrapper->document; - $this->xpath = &$this->documentWrapper->xpath; - $this->charset = &$this->documentWrapper->charset; - $this->documentFragment = &$this->documentWrapper->isDocumentFragment; - // TODO check $this->DOM->documentElement; - // $this->root = $this->document->documentElement; - $this->root = &$this->documentWrapper->root; - // $this->toRoot(); - $this->elements = array($this->root); - } - /** - * - * @access private - * @param $attr - * @return unknown_type - */ - public function __get($attr) - { - switch ($attr) { - // FIXME doesnt work at all ? - case 'length': - return $this->size(); - break; - default: - return $this->$attr; - } - } - /** - * Saves actual object to $var by reference. - * Useful when need to break chain. - * @param phpQueryObject $var - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function toReference(&$var) - { - return $var = $this; - } - public function documentFragment($state = null) - { - if ($state) { - phpQuery::$documents[$this->getDocumentID()]['documentFragment'] = $state; - return $this; - } - return $this->documentFragment; - } - /** - * @access private - * @TODO documentWrapper - */ - protected function isRoot($node) - { - // return $node instanceof DOMDOCUMENT || $node->tagName == 'html'; - return $node instanceof DOMDOCUMENT - || ($node instanceof DOMELEMENT && $node->tagName == 'html') - || $this->root->isSameNode($node); - } - /** - * @access private - */ - protected function stackIsRoot() - { - return $this->size() == 1 && $this->isRoot($this->elements[0]); - } - /** - * Enter description here... - * NON JQUERY METHOD - * - * Watch out, it doesn't creates new instance, can be reverted with end(). - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function toRoot() - { - $this->elements = array($this->root); - return $this; - // return $this->newInstance(array($this->root)); - } - /** - * Saves object's DocumentID to $var by reference. - * - * $myDocumentId; - * phpQuery::newDocument('
') - * ->getDocumentIDRef($myDocumentId) - * ->find('div')->... - * - * - * @param unknown_type $domId - * @see phpQuery::newDocument - * @see phpQuery::newDocumentFile - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function getDocumentIDRef(&$documentID) - { - $documentID = $this->getDocumentID(); - return $this; - } - /** - * Returns object with stack set to document root. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function getDocument() - { - return phpQuery::getDocument($this->getDocumentID()); - } - /** - * - * @return DOMDocument - */ - public function getDOMDocument() - { - return $this->document; - } - /** - * Get object's Document ID. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function getDocumentID() - { - return $this->documentID; - } - /** - * Unloads whole document from memory. - * CAUTION! None further operations will be possible on this document. - * All objects refering to it will be useless. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function unloadDocument() - { - phpQuery::unloadDocuments($this->getDocumentID()); - } - public function isHTML() - { - return $this->documentWrapper->isHTML; - } - public function isXHTML() - { - return $this->documentWrapper->isXHTML; - } - public function isXML() - { - return $this->documentWrapper->isXML; - } - /** - * Enter description here... - * - * @link http://docs.jquery.com/Ajax/serialize - * @return string - */ - public function serialize() - { - return phpQuery::param($this->serializeArray()); - } - /** - * Enter description here... - * - * @link http://docs.jquery.com/Ajax/serializeArray - * @return array - */ - public function serializeArray($submit = null) - { - $source = $this->filter('form, input, select, textarea') - ->find('input, select, textarea') - ->andSelf() - ->not('form'); - $return = array(); - // $source->dumpDie(); - foreach ($source as $input) { - $input = phpQuery::pq($input); - if ($input->is('[disabled]')) - continue; - if (!$input->is('[name]')) - continue; - if ($input->is('[type=checkbox]') && !$input->is('[checked]')) - continue; - // jquery diff - if ($submit && $input->is('[type=submit]')) { - if ($submit instanceof DOMELEMENT && !$input->elements[0]->isSameNode($submit)) - continue; - else if (is_string($submit) && $input->attr('name') != $submit) - continue; - } - $return[] = array( - 'name' => $input->attr('name'), - 'value' => $input->val(), - ); - } - return $return; - } - /** - * @access private - */ - protected function debug($in) - { - if (!phpQuery::$debug) - return; - print('
');
-		print_r($in);
-		// file debug
-		//		file_put_contents(dirname(__FILE__).'/phpQuery.log', print_r($in, true)."\n", FILE_APPEND);
-		// quite handy debug trace
-		//		if ( is_array($in))
-		//			print_r(array_slice(debug_backtrace(), 3));
-		print("
\n"); - } - /** - * @access private - */ - protected function isRegexp($pattern) - { - return in_array( - $pattern[mb_strlen($pattern) - 1], - array('^', '*', '$') - ); - } - /** - * Determines if $char is really a char. - * - * @param string $char - * @return bool - * @todo rewrite me to charcode range ! ;) - * @access private - */ - protected function isChar($char) - { - return extension_loaded('mbstring') && phpQuery::$mbstringSupport - ? mb_eregi('\w', $char) - : preg_match('@\w@', $char); - } - /** - * @access private - */ - protected function parseSelector($query) - { - // clean spaces - // TODO include this inside parsing ? - $query = trim( - preg_replace( - '@\s+@', - ' ', - preg_replace('@\s*(>|\\+|~)\s*@', '\\1', $query) - ) - ); - $queries = array(array()); - if (!$query) - return $queries; - $return = &$queries[0]; - $specialChars = array('>', ' '); - // $specialCharsMapping = array('/' => '>'); - $specialCharsMapping = array(); - $strlen = mb_strlen($query); - $classChars = array('.', '-'); - $pseudoChars = array('-'); - $tagChars = array('*', '|', '-'); - // split multibyte string - // http://code.google.com/p/phpquery/issues/detail?id=76 - $_query = array(); - for ($i = 0; $i < $strlen; $i++) - $_query[] = mb_substr($query, $i, 1); - $query = $_query; - // it works, but i dont like it... - $i = 0; - while ($i < $strlen) { - $c = $query[$i]; - $tmp = ''; - // TAG - if ($this->isChar($c) || in_array($c, $tagChars)) { - while ( - isset($query[$i]) - && ($this->isChar($query[$i]) || in_array($query[$i], $tagChars)) - ) { - $tmp .= $query[$i]; - $i++; - } - $return[] = $tmp; - // IDs - } else if ($c == '#') { - $i++; - while (isset($query[$i]) && ($this->isChar($query[$i]) || $query[$i] == '-')) { - $tmp .= $query[$i]; - $i++; - } - $return[] = '#' . $tmp; - // SPECIAL CHARS - } else if (in_array($c, $specialChars)) { - $return[] = $c; - $i++; - // MAPPED SPECIAL MULTICHARS - // } else if ( $c.$query[$i+1] == '//') { - // $return[] = ' '; - // $i = $i+2; - // MAPPED SPECIAL CHARS - } else if (isset($specialCharsMapping[$c])) { - $return[] = $specialCharsMapping[$c]; - $i++; - // COMMA - } else if ($c == ',') { - $queries[] = array(); - $return = &$queries[count($queries) - 1]; - $i++; - while (isset($query[$i]) && $query[$i] == ' ') - $i++; - // CLASSES - } else if ($c == '.') { - while (isset($query[$i]) && ($this->isChar($query[$i]) || in_array($query[$i], $classChars))) { - $tmp .= $query[$i]; - $i++; - } - $return[] = $tmp; - // ~ General Sibling Selector - } else if ($c == '~') { - $spaceAllowed = true; - $tmp .= $query[$i++]; - while ( - isset($query[$i]) - && ($this->isChar($query[$i]) - || in_array($query[$i], $classChars) - || $query[$i] == '*' - || ($query[$i] == ' ' && $spaceAllowed) - ) - ) { - if ($query[$i] != ' ') - $spaceAllowed = false; - $tmp .= $query[$i]; - $i++; - } - $return[] = $tmp; - // + Adjacent sibling selectors - } else if ($c == '+') { - $spaceAllowed = true; - $tmp .= $query[$i++]; - while ( - isset($query[$i]) - && ($this->isChar($query[$i]) - || in_array($query[$i], $classChars) - || $query[$i] == '*' - || ($spaceAllowed && $query[$i] == ' ') - ) - ) { - if ($query[$i] != ' ') - $spaceAllowed = false; - $tmp .= $query[$i]; - $i++; - } - $return[] = $tmp; - // ATTRS - } else if ($c == '[') { - $stack = 1; - $tmp .= $c; - while (isset($query[++$i])) { - $tmp .= $query[$i]; - if ($query[$i] == '[') { - $stack++; - } else if ($query[$i] == ']') { - $stack--; - if (!$stack) - break; - } - } - $return[] = $tmp; - $i++; - // PSEUDO CLASSES - } else if ($c == ':') { - $stack = 1; - $tmp .= $query[$i++]; - while (isset($query[$i]) && ($this->isChar($query[$i]) || in_array($query[$i], $pseudoChars))) { - $tmp .= $query[$i]; - $i++; - } - // with arguments ? - if (isset($query[$i]) && $query[$i] == '(') { - $tmp .= $query[$i]; - $stack = 1; - while (isset($query[++$i])) { - $tmp .= $query[$i]; - if ($query[$i] == '(') { - $stack++; - } else if ($query[$i] == ')') { - $stack--; - if (!$stack) - break; - } - } - $return[] = $tmp; - $i++; - } else { - $return[] = $tmp; - } - } else { - $i++; - } - } - foreach ($queries as $k => $q) { - if (isset($q[0])) { - if (isset($q[0][0]) && $q[0][0] == ':') - array_unshift($queries[$k], '*'); - if ($q[0] != '>') - array_unshift($queries[$k], ' '); - } - } - return $queries; - } - /** - * Return matched DOM nodes. - * - * @param int $index - * @return array|DOMElement Single DOMElement or array of DOMElement. - */ - public function get($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - $return = isset($index) - ? (isset($this->elements[$index]) ? $this->elements[$index] : null) - : $this->elements; - // pass thou callbacks - $args = func_get_args(); - $args = array_slice($args, 1); - foreach ($args as $callback) { - if (is_array($return)) - foreach ($return as $k => $v) - $return[$k] = phpQuery::callbackRun($callback, array($v)); - else - $return = phpQuery::callbackRun($callback, array($return)); - } - return $return; - } - /** - * Return matched DOM nodes. - * jQuery difference. - * - * @param int $index - * @return array|string Returns string if $index != null - * @todo implement callbacks - * @todo return only arrays ? - * @todo maybe other name... - */ - public function getString($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - if (!is_null($index) && is_int($index)) - $return = $this->eq($index)->text(); - else { - $return = array(); - for ($i = 0; $i < $this->size(); $i++) { - $return[] = $this->eq($i)->text(); - } - } - // pass thou callbacks - $args = func_get_args(); - $args = array_slice($args, 1); - foreach ($args as $callback) { - $return = phpQuery::callbackRun($callback, array($return)); - } - return $return; - } - /** - * Return matched DOM nodes. - * jQuery difference. - * - * @param int $index - * @return array|string Returns string if $index != null - * @todo implement callbacks - * @todo return only arrays ? - * @todo maybe other name... - */ - public function getStrings($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - if (!is_null($index) && is_int($index)) - $return = $this->eq($index)->text(); - else { - $return = array(); - for ($i = 0; $i < $this->size(); $i++) { - $return[] = $this->eq($i)->text(); - } - // pass thou callbacks - $args = func_get_args(); - $args = array_slice($args, 1); - } - foreach ($args as $callback) { - if (is_array($return)) - foreach ($return as $k => $v) - $return[$k] = phpQuery::callbackRun($callback, array($v)); - else - $return = phpQuery::callbackRun($callback, array($return)); - } - return $return; - } - /** - * Returns new instance of actual class. - * - * @param array $newStack Optional. Will replace old stack with new and move old one to history.c - */ - public function newInstance($newStack = null) - { - $class = get_class($this); - // support inheritance by passing old object to overloaded constructor - $new = $class != 'phpQuery' - ? new $class($this, $this->getDocumentID()) - : new phpQueryObject($this->getDocumentID()); - $new->previous = $this; - if (is_null($newStack)) { - $new->elements = $this->elements; - if ($this->elementsBackup) - $this->elements = $this->elementsBackup; - } else if (is_string($newStack)) { - $new->elements = phpQuery::pq($newStack, $this->getDocumentID())->stack(); - } else { - $new->elements = $newStack; - } - return $new; - } - /** - * Enter description here... - * - * In the future, when PHP will support XLS 2.0, then we would do that this way: - * contains(tokenize(@class, '\s'), "something") - * @param unknown_type $class - * @param unknown_type $node - * @return boolean - * @access private - */ - protected function matchClasses($class, $node) - { - // multi-class - if (mb_strpos($class, '.', 1)) { - $classes = explode('.', substr($class, 1)); - $classesCount = count($classes); - $nodeClasses = explode(' ', $node->getAttribute('class')); - $nodeClassesCount = count($nodeClasses); - if ($classesCount > $nodeClassesCount) - return false; - $diff = count( - array_diff( - $classes, - $nodeClasses - ) - ); - if (!$diff) - return true; - // single-class - } else { - return in_array( - // strip leading dot from class name - substr($class, 1), - // get classes for element as array - explode(' ', $node->getAttribute('class')) - ); - } - } - /** - * @access private - */ - protected function runQuery($XQuery, $selector = null, $compare = null) - { - if ($compare && !method_exists($this, $compare)) - return false; - $stack = array(); - if (!$this->elements) - $this->debug('Stack empty, skipping...'); - // var_dump($this->elements[0]->nodeType); - // element, document - foreach ($this->stack(array(1, 9, 13)) as $k => $stackNode) { - $detachAfter = false; - // to work on detached nodes we need temporary place them somewhere - // thats because context xpath queries sucks ;] - $testNode = $stackNode; - while ($testNode) { - if (!$testNode->parentNode && !$this->isRoot($testNode)) { - $this->root->appendChild($testNode); - $detachAfter = $testNode; - break; - } - $testNode = isset($testNode->parentNode) - ? $testNode->parentNode - : null; - } - // XXX tmp ? - $xpath = $this->documentWrapper->isXHTML - ? $this->getNodeXpath($stackNode, 'html') - : $this->getNodeXpath($stackNode); - // FIXME pseudoclasses-only query, support XML - $query = $XQuery == '//' && $xpath == '/html[1]' - ? '//*' - : $xpath . $XQuery; - $this->debug("XPATH: {$query}"); - // run query, get elements - $nodes = $this->xpath->query($query); - $this->debug("QUERY FETCHED"); - if (!$nodes->length) - $this->debug('Nothing found'); - $debug = array(); - foreach ($nodes as $node) { - $matched = false; - if ($compare) { - phpQuery::$debug ? - $this->debug("Found: " . $this->whois($node) . ", comparing with {$compare}()") - : null; - $phpQueryDebug = phpQuery::$debug; - phpQuery::$debug = false; - // TODO ??? use phpQuery::callbackRun() - if (call_user_func_array(array($this, $compare), array($selector, $node))) - $matched = true; - phpQuery::$debug = $phpQueryDebug; - } else { - $matched = true; - } - if ($matched) { - if (phpQuery::$debug) - $debug[] = $this->whois($node); - $stack[] = $node; - } - } - if (phpQuery::$debug) { - $this->debug("Matched " . count($debug) . ": " . implode(', ', $debug)); - } - if ($detachAfter) - $this->root->removeChild($detachAfter); - } - $this->elements = $stack; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function find($selectors, $context = null, $noHistory = false) - { - if (!$noHistory) - // backup last stack /for end()/ - $this->elementsBackup = $this->elements; - // allow to define context - // TODO combine code below with phpQuery::pq() context guessing code - // as generic function - if ($context) { - if (!is_array($context) && $context instanceof DOMELEMENT) - $this->elements = array($context); - else if (is_array($context)) { - $this->elements = array(); - foreach ($context as $c) - if ($c instanceof DOMELEMENT) - $this->elements[] = $c; - } else if ($context instanceof self) - $this->elements = $context->elements; - } - $queries = $this->parseSelector($selectors); - $this->debug(array('FIND', $selectors, $queries)); - $XQuery = ''; - // remember stack state because of multi-queries - $oldStack = $this->elements; - // here we will be keeping found elements - $stack = array(); - foreach ($queries as $selector) { - $this->elements = $oldStack; - $delimiterBefore = false; - foreach ($selector as $s) { - // TAG - $isTag = extension_loaded('mbstring') && phpQuery::$mbstringSupport - ? mb_ereg_match('^[\w|\||-]+$', $s) || $s == '*' - : preg_match('@^[\w|\||-]+$@', $s) || $s == '*'; - if ($isTag) { - if ($this->isXML()) { - // namespace support - if (mb_strpos($s, '|') !== false) { - $ns = $tag = null; - list($ns, $tag) = explode('|', $s); - $XQuery .= "$ns:$tag"; - } else if ($s == '*') { - $XQuery .= "*"; - } else { - $XQuery .= "*[local-name()='$s']"; - } - } else { - $XQuery .= $s; - } - // ID - } else if ($s[0] == '#') { - if ($delimiterBefore) - $XQuery .= '*'; - $XQuery .= "[@id='" . substr($s, 1) . "']"; - // ATTRIBUTES - } else if ($s[0] == '[') { - if ($delimiterBefore) - $XQuery .= '*'; - // strip side brackets - $attr = trim($s, ']['); - $execute = false; - // attr with specifed value - if (mb_strpos($s, '=')) { - $value = null; - list($attr, $value) = explode('=', $attr); - $value = trim($value, "'\""); - if ($this->isRegexp($attr)) { - // cut regexp character - $attr = substr($attr, 0, -1); - $execute = true; - $XQuery .= "[@{$attr}]"; - } else { - $XQuery .= "[@{$attr}='{$value}']"; - } - // attr without specified value - } else { - $XQuery .= "[@{$attr}]"; - } - if ($execute) { - $this->runQuery($XQuery, $s, 'is'); - $XQuery = ''; - if (!$this->length()) - break; - } - // CLASSES - } else if ($s[0] == '.') { - // TODO use return $this->find("./self::*[contains(concat(\" \",@class,\" \"), \" $class \")]"); - // thx wizDom ;) - if ($delimiterBefore) - $XQuery .= '*'; - $XQuery .= '[@class]'; - $this->runQuery($XQuery, $s, 'matchClasses'); - $XQuery = ''; - if (!$this->length()) - break; - // ~ General Sibling Selector - } else if ($s[0] == '~') { - $this->runQuery($XQuery); - $XQuery = ''; - $this->elements = $this - ->siblings( - substr($s, 1) - )->elements; - if (!$this->length()) - break; - // + Adjacent sibling selectors - } else if ($s[0] == '+') { - // TODO /following-sibling:: - $this->runQuery($XQuery); - $XQuery = ''; - $subSelector = substr($s, 1); - $subElements = $this->elements; - $this->elements = array(); - foreach ($subElements as $node) { - // search first DOMElement sibling - $test = $node->nextSibling; - while ($test && !($test instanceof DOMELEMENT)) - $test = $test->nextSibling; - if ($test && $this->is($subSelector, $test)) - $this->elements[] = $test; - } - if (!$this->length()) - break; - // PSEUDO CLASSES - } else if ($s[0] == ':') { - // TODO optimization for :first :last - if ($XQuery) { - $this->runQuery($XQuery); - $XQuery = ''; - } - if (!$this->length()) - break; - $this->pseudoClasses($s); - if (!$this->length()) - break; - // DIRECT DESCENDANDS - } else if ($s == '>') { - $XQuery .= '/'; - $delimiterBefore = 2; - // ALL DESCENDANDS - } else if ($s == ' ') { - $XQuery .= '//'; - $delimiterBefore = 2; - // ERRORS - } else { - phpQuery::debug("Unrecognized token '$s'"); - } - $delimiterBefore = $delimiterBefore === 2; - } - // run query if any - if ($XQuery && $XQuery != '//') { - $this->runQuery($XQuery); - $XQuery = ''; - } - foreach ($this->elements as $node) - if (!$this->elementsContainsNode($node, $stack)) - $stack[] = $node; - } - $this->elements = $stack; - return $this->newInstance(); - } - /** - * @todo create API for classes with pseudoselectors - * @access private - */ - protected function pseudoClasses($class) - { - // TODO clean args parsing ? - $class = ltrim($class, ':'); - $haveArgs = mb_strpos($class, '('); - if ($haveArgs !== false) { - $args = substr($class, $haveArgs + 1, -1); - $class = substr($class, 0, $haveArgs); - } - switch ($class) { - case 'even': - case 'odd': - $stack = array(); - foreach ($this->elements as $i => $node) { - if ($class == 'even' && ($i % 2) == 0) - $stack[] = $node; - else if ($class == 'odd' && $i % 2) - $stack[] = $node; - } - $this->elements = $stack; - break; - case 'eq': - $k = intval($args); - if ($k < 0) { - $this->elements = array($this->elements[count($this->elements) + $k]); - } else { - $this->elements = isset($this->elements[$k]) - ? array($this->elements[$k]) - : array(); - } - break; - case 'gt': - $this->elements = array_slice($this->elements, $args + 1); - break; - case 'lt': - $this->elements = array_slice($this->elements, 0, $args + 1); - break; - case 'first': - if (isset($this->elements[0])) - $this->elements = array($this->elements[0]); - break; - case 'last': - if ($this->elements) - $this->elements = array($this->elements[count($this->elements) - 1]); - break; - /*case 'parent': - $stack = array(); - foreach($this->elements as $node) { - if ( $node->childNodes->length ) - $stack[] = $node; - } - $this->elements = $stack; - break;*/ - case 'contains': - $text = trim($args, "\"'"); - $stack = array(); - foreach ($this->elements as $node) { - if (mb_stripos($node->textContent, $text) === false) - continue; - $stack[] = $node; - } - $this->elements = $stack; - break; - case 'not': - $selector = self::unQuote($args); - $this->elements = $this->not($selector)->stack(); - break; - case 'slice': - // TODO jQuery difference ? - $args = explode( - ',', - str_replace(', ', ',', trim($args, "\"'")) - ); - $start = $args[0]; - $end = isset($args[1]) - ? $args[1] - : null; - if ($end > 0) - $end = $end - $start; - $this->elements = array_slice($this->elements, $start, $end); - break; - case 'has': - $selector = trim($args, "\"'"); - $stack = array(); - foreach ($this->stack(1) as $el) { - if ($this->find($selector, $el, true)->length) - $stack[] = $el; - } - $this->elements = $stack; - break; - case 'submit': - case 'reset': - $this->elements = phpQuery::merge( - $this->map( - array($this, 'is'), - "input[type=$class]", - new CallbackParam() - ), - $this->map( - array($this, 'is'), - "button[type=$class]", - new CallbackParam() - ) - ); - break; - // $stack = array(); - // foreach($this->elements as $node) - // if ($node->is('input[type=submit]') || $node->is('button[type=submit]')) - // $stack[] = $el; - // $this->elements = $stack; - case 'input': - $this->elements = $this->map( - array($this, 'is'), - 'input', - new CallbackParam() - )->elements; - break; - case 'password': - case 'checkbox': - case 'radio': - case 'hidden': - case 'image': - case 'file': - $this->elements = $this->map( - array($this, 'is'), - "input[type=$class]", - new CallbackParam() - )->elements; - break; - case 'parent': - $this->elements = $this->map( - function ($node) { - return $node instanceof DOMELEMENT && $node->childNodes->length - ? $node : null; - } - )->elements; - break; - case 'empty': - $this->elements = $this->map( - function ($node) { - return $node instanceof DOMELEMENT && $node->childNodes->length - ? null : $node; - } - )->elements; - break; - case 'disabled': - case 'selected': - case 'checked': - $this->elements = $this->map( - array($this, 'is'), - "[$class]", - new CallbackParam() - )->elements; - break; - case 'enabled': - $this->elements = $this->map( - function ($node) { - return pq($node)->not(":disabled") ? $node : null; - } - )->elements; - break; - case 'header': - $this->elements = $this->map( - function ($node) { - $isHeader = isset($node->tagName) && in_array($node->tagName, array( - "h1", "h2", "h3", "h4", "h5", "h6", "h7" - )); - return $isHeader - ? $node - : null; - } - )->elements; - // $this->elements = $this->map( - // create_function('$node', '$node = pq($node); - // return $node->is("h1") - // || $node->is("h2") - // || $node->is("h3") - // || $node->is("h4") - // || $node->is("h5") - // || $node->is("h6") - // || $node->is("h7") - // ? $node - // : null;') - // )->elements; - break; - case 'only-child': - $this->elements = $this->map( - function ($node) { - return pq($node)->siblings()->size() == 0 ? $node : null; - } - )->elements; - break; - case 'first-child': - $this->elements = $this->map( - function ($node) { - return pq($node)->prevAll()->size() == 0 ? $node : null; - } - )->elements; - break; - case 'last-child': - $this->elements = $this->map( - function ($node) { - return pq($node)->nextAll()->size() == 0 ? $node : null; - } - )->elements; - break; - case 'nth-child': - $param = trim($args, "\"'"); - if (!$param) - break; - // nth-child(n+b) to nth-child(1n+b) - if ($param[0] == 'n') - $param = '1' . $param; - // :nth-child(index/even/odd/equation) - if ($param == 'even' || $param == 'odd') - $mapped = $this->map( - function ($node, $param) { - $index = pq($node)->prevAll()->size() + 1; - if ($param == "even" && ($index % 2) == 0) - return $node; - else if ($param == "odd" && $index % 2 == 1) - return $node; - else - return null; - }, - new CallbackParam(), - $param - ); - else if (mb_strlen($param) > 1 && preg_match('/^(\d*)n([-+]?)(\d*)/', $param) === 1) - // an+b - $mapped = $this->map( - function ($node, $param) { - $prevs = pq($node)->prevAll()->size(); - $index = 1 + $prevs; - - preg_match("/^(\d*)n([-+]?)(\d*)/", $param, $matches); - $a = intval($matches[1]); - $b = intval($matches[3]); - if ($matches[2] === "-") { - $b = -$b; - } - - if ($a > 0) { - return ($index - $b) % $a == 0 - ? $node - : null; - phpQuery::debug($a . "*" . floor($index / $a) . "+$b-1 == " . ($a * floor($index / $a) + $b - 1) . " ?= $prevs"); - return $a * floor($index / $a) + $b - 1 == $prevs - ? $node - : null; - } else if ($a == 0) - return $index == $b - ? $node - : null; - else - // negative value - return $index <= $b - ? $node - : null; - // if (! $b) - // return $index%$a == 0 - // ? $node - // : null; - // else - // return ($index-$b)%$a == 0 - // ? $node - // : null; - }, - new CallbackParam(), - $param - ); - else - // index - $mapped = $this->map( - function ($node, $index) { - $prevs = pq($node)->prevAll()->size(); - if ($prevs && $prevs == $index - 1) - return $node; - else if (!$prevs && $index == 1) - return $node; - else - return null; - }, - new CallbackParam(), - $param - ); - $this->elements = $mapped->elements; - break; - default: - $this->debug("Unknown pseudoclass '{$class}', skipping..."); - } - } - /** - * @access private - */ - protected function __pseudoClassParam($paramsString) - { - // TODO; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function is($selector, $nodes = null) - { - phpQuery::debug(array("Is:", $selector)); - if (!$selector) - return false; - $oldStack = $this->elements; - $returnArray = false; - if ($nodes && is_array($nodes)) { - $this->elements = $nodes; - } else if ($nodes) - $this->elements = array($nodes); - $this->filter($selector, true); - $stack = $this->elements; - $this->elements = $oldStack; - if ($nodes) - return $stack ? $stack : null; - return (bool)count($stack); - } - /** - * Enter description here... - * jQuery difference. - * - * Callback: - * - $index int - * - $node DOMNode - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @link http://docs.jquery.com/Traversing/filter - */ - public function filterCallback($callback, $_skipHistory = false) - { - if (!$_skipHistory) { - $this->elementsBackup = $this->elements; - $this->debug("Filtering by callback"); - } - $newStack = array(); - foreach ($this->elements as $index => $node) { - $result = phpQuery::callbackRun($callback, array($index, $node)); - if (is_null($result) || (!is_null($result) && $result)) - $newStack[] = $node; - } - $this->elements = $newStack; - return $_skipHistory - ? $this - : $this->newInstance(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @link http://docs.jquery.com/Traversing/filter - */ - public function filter($selectors, $_skipHistory = false) - { - if ($selectors instanceof Callback or $selectors instanceof Closure) - return $this->filterCallback($selectors, $_skipHistory); - if (!$_skipHistory) - $this->elementsBackup = $this->elements; - $notSimpleSelector = array(' ', '>', '~', '+', '/'); - if (!is_array($selectors)) - $selectors = $this->parseSelector($selectors); - if (!$_skipHistory) - $this->debug(array("Filtering:", $selectors)); - $finalStack = array(); - foreach ($selectors as $selector) { - $stack = array(); - if (!$selector) - break; - // avoid first space or / - if (in_array($selector[0], $notSimpleSelector)) - $selector = array_slice($selector, 1); - // PER NODE selector chunks - foreach ($this->stack() as $node) { - $break = false; - foreach ($selector as $s) { - if (!($node instanceof DOMELEMENT)) { - // all besides DOMElement - if ($s[0] == '[') { - $attr = trim($s, '[]'); - if (mb_strpos($attr, '=')) { - list($attr, $val) = explode('=', $attr); - if ($attr == 'nodeType' && $node->nodeType != $val) - $break = true; - } - } else - $break = true; - } else { - // DOMElement only - // ID - if ($s[0] == '#') { - if ($node->getAttribute('id') != substr($s, 1)) - $break = true; - // CLASSES - } else if ($s[0] == '.') { - if (!$this->matchClasses($s, $node)) - $break = true; - // ATTRS - } else if ($s[0] == '[') { - // strip side brackets - $attr = trim($s, '[]'); - if (mb_strpos($attr, '=')) { - list($attr, $val) = explode('=', $attr); - $val = self::unQuote($val); - if ($attr == 'nodeType') { - if ($val != $node->nodeType) - $break = true; - } else if ($this->isRegexp($attr)) { - $val = extension_loaded('mbstring') && phpQuery::$mbstringSupport - ? quotemeta(trim($val, '"\'')) - : preg_quote(trim($val, '"\''), '@'); - // switch last character - switch (substr($attr, -1)) { - // quotemeta used insted of preg_quote - // http://code.google.com/p/phpquery/issues/detail?id=76 - case '^': - $pattern = '^' . $val; - break; - case '*': - $pattern = '.*' . $val . '.*'; - break; - case '$': - $pattern = '.*' . $val . '$'; - break; - } - // cut last character - $attr = substr($attr, 0, -1); - $isMatch = extension_loaded('mbstring') && phpQuery::$mbstringSupport - ? mb_ereg_match($pattern, $node->getAttribute($attr)) - : preg_match("@{$pattern}@", $node->getAttribute($attr)); - if (!$isMatch) - $break = true; - } else if ($node->getAttribute($attr) != $val) - $break = true; - } else if (!$node->hasAttribute($attr)) - $break = true; - // PSEUDO CLASSES - } else if ($s[0] == ':') { - // skip - // TAG - } else if (trim($s)) { - if ($s != '*') { - // TODO namespaces - if (isset($node->tagName)) { - if ($node->tagName != $s) - $break = true; - } else if ($s == 'html' && !$this->isRoot($node)) - $break = true; - } - // AVOID NON-SIMPLE SELECTORS - } else if (in_array($s, $notSimpleSelector)) { - $break = true; - $this->debug(array('Skipping non simple selector', $selector)); - } - } - if ($break) - break; - } - // if element passed all chunks of selector - add it to new stack - if (!$break) - $stack[] = $node; - } - $tmpStack = $this->elements; - $this->elements = $stack; - // PER ALL NODES selector chunks - foreach ($selector as $s) - // PSEUDO CLASSES - if ($s[0] == ':') - $this->pseudoClasses($s); - foreach ($this->elements as $node) - // XXX it should be merged without duplicates - // but jQuery doesnt do that - $finalStack[] = $node; - $this->elements = $tmpStack; - } - $this->elements = $finalStack; - if ($_skipHistory) { - return $this; - } else { - $this->debug("Stack length after filter(): " . count($finalStack)); - return $this->newInstance(); - } - } - /** - * - * @param $value - * @return unknown_type - * @TODO implement in all methods using passed parameters - */ - protected static function unQuote($value) - { - return $value[0] == '\'' || $value[0] == '"' - ? substr($value, 1, -1) - : $value; - } - /** - * Enter description here... - * - * @link http://docs.jquery.com/Ajax/load - * @return phpQuery|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo Support $selector - */ - public function load($url, $data = null, $callback = null) - { - if ($data && !is_array($data)) { - $callback = $data; - $data = null; - } - if (mb_strpos($url, ' ') !== false) { - $matches = null; - if (extension_loaded('mbstring') && phpQuery::$mbstringSupport) - mb_ereg('^([^ ]+) (.*)$', $url, $matches); - else - preg_match('^([^ ]+) (.*)$', $url, $matches); - $url = $matches[1]; - $selector = $matches[2]; - // FIXME this sucks, pass as callback param - $this->_loadSelector = $selector; - } - $ajax = array( - 'url' => $url, - 'type' => $data ? 'POST' : 'GET', - 'data' => $data, - 'complete' => $callback, - 'success' => array($this, '__loadSuccess') - ); - phpQuery::ajax($ajax); - return $this; - } - /** - * @access private - * @param $html - * @return unknown_type - */ - public function __loadSuccess($html) - { - if ($this->_loadSelector) { - $html = phpQuery::newDocument($html)->find($this->_loadSelector); - unset($this->_loadSelector); - } - foreach ($this->stack(1) as $node) { - phpQuery::pq($node, $this->getDocumentID()) - ->markup($html); - } - } - /** - * Enter description here... - * - * @return phpQuery|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo - */ - public function css() - { - // TODO - return $this; - } - /** - * @todo - * - */ - public function show() - { - // TODO - return $this; - } - /** - * @todo - * - */ - public function hide() - { - // TODO - return $this; - } - /** - * Trigger a type of event on every matched element. - * - * @param unknown_type $type - * @param unknown_type $data - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @TODO support more than event in $type (space-separated) - */ - public function trigger($type, $data = array()) - { - foreach ($this->elements as $node) - phpQueryEvents::trigger($this->getDocumentID(), $type, $data, $node); - return $this; - } - /** - * This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browsers default actions. - * - * @param unknown_type $type - * @param unknown_type $data - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @TODO - */ - public function triggerHandler($type, $data = array()) - { - // TODO; - } - /** - * Binds a handler to one or more events (like click) for each matched element. - * Can also bind custom events. - * - * @param unknown_type $type - * @param unknown_type $data Optional - * @param unknown_type $callback - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @TODO support '!' (exclusive) events - * @TODO support more than event in $type (space-separated) - */ - public function bind($type, $data, $callback = null) - { - // TODO check if $data is callable, not using is_callable - if (!isset($callback)) { - $callback = $data; - $data = null; - } - foreach ($this->elements as $node) - phpQueryEvents::add($this->getDocumentID(), $node, $type, $data, $callback); - return $this; - } - /** - * Enter description here... - * - * @param unknown_type $type - * @param unknown_type $callback - * @return unknown - * @TODO namespace events - * @TODO support more than event in $type (space-separated) - */ - public function unbind($type = null, $callback = null) - { - foreach ($this->elements as $node) - phpQueryEvents::remove($this->getDocumentID(), $node, $type, $callback); - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function change($callback = null) - { - if ($callback) - return $this->bind('change', $callback); - return $this->trigger('change'); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function submit($callback = null) - { - if ($callback) - return $this->bind('submit', $callback); - return $this->trigger('submit'); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function click($callback = null) - { - if ($callback) - return $this->bind('click', $callback); - return $this->trigger('click'); - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapAllOld($wrapper) - { - $wrapper = pq($wrapper)->_clone(); - if (!$wrapper->length() || !$this->length()) - return $this; - $wrapper->insertBefore($this->elements[0]); - $deepest = $wrapper->elements[0]; - while ($deepest->firstChild && $deepest->firstChild instanceof DOMELEMENT) - $deepest = $deepest->firstChild; - pq($deepest)->append($this); - return $this; - } - /** - * Enter description here... - * - * TODO testme... - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapAll($wrapper) - { - if (!$this->length()) - return $this; - return phpQuery::pq($wrapper, $this->getDocumentID()) - ->clone() - ->insertBefore($this->get(0)) - ->map(array($this, '___wrapAllCallback')) - ->append($this); - } - /** - * - * @param $node - * @return unknown_type - * @access private - */ - public function ___wrapAllCallback($node) - { - $deepest = $node; - while ($deepest->firstChild && $deepest->firstChild instanceof DOMELEMENT) - $deepest = $deepest->firstChild; - return $deepest; - } - /** - * Enter description here... - * NON JQUERY METHOD - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapAllPHP($codeBefore, $codeAfter) - { - return $this - ->slice(0, 1) - ->beforePHP($codeBefore) - ->end() - ->slice(-1) - ->afterPHP($codeAfter) - ->end(); - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrap($wrapper) - { - foreach ($this->stack() as $node) - phpQuery::pq($node, $this->getDocumentID())->wrapAll($wrapper); - return $this; - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapPHP($codeBefore, $codeAfter) - { - foreach ($this->stack() as $node) - phpQuery::pq($node, $this->getDocumentID())->wrapAllPHP($codeBefore, $codeAfter); - return $this; - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapInner($wrapper) - { - foreach ($this->stack() as $node) - phpQuery::pq($node, $this->getDocumentID())->contents()->wrapAll($wrapper); - return $this; - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function wrapInnerPHP($codeBefore, $codeAfter) - { - foreach ($this->stack(1) as $node) - phpQuery::pq($node, $this->getDocumentID())->contents() - ->wrapAllPHP($codeBefore, $codeAfter); - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @testme Support for text nodes - */ - public function contents() - { - $stack = array(); - foreach ($this->stack(1) as $el) { - // FIXME (fixed) http://code.google.com/p/phpquery/issues/detail?id=56 - // if (! isset($el->childNodes)) - // continue; - foreach ($el->childNodes as $node) { - $stack[] = $node; - } - } - return $this->newInstance($stack); - } - /** - * Enter description here... - * - * jQuery difference. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function contentsUnwrap() - { - foreach ($this->stack(1) as $node) { - if (!$node->parentNode) - continue; - $childNodes = array(); - // any modification in DOM tree breaks childNodes iteration, so cache them first - foreach ($node->childNodes as $chNode) - $childNodes[] = $chNode; - foreach ($childNodes as $chNode) - // $node->parentNode->appendChild($chNode); - $node->parentNode->insertBefore($chNode, $node); - $node->parentNode->removeChild($node); - } - return $this; - } - /** - * Enter description here... - * - * jQuery difference. - */ - public function switchWith($markup) - { - $markup = pq($markup, $this->getDocumentID()); - $content = null; - foreach ($this->stack(1) as $node) { - pq($node) - ->contents()->toReference($content)->end() - ->replaceWith($markup->clone()->append($content)); - } - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function eq($num) - { - $oldStack = $this->elements; - $this->elementsBackup = $this->elements; - $this->elements = array(); - if (isset($oldStack[$num])) - $this->elements[] = $oldStack[$num]; - return $this->newInstance(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function size() - { - return count($this->elements); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @deprecated Use length as attribute - */ - public function length() - { - return $this->size(); - } - - #[\ReturnTypeWillChange] - public function count() - { - return $this->size(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo $level - */ - public function end($level = 1) - { - // $this->elements = array_pop( $this->history ); - // return $this; - // $this->previous->DOM = $this->DOM; - // $this->previous->XPath = $this->XPath; - return $this->previous - ? $this->previous - : $this; - } - /** - * Enter description here... - * Normal use ->clone() . - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @access private - */ - public function _clone() - { - $newStack = array(); - //pr(array('copy... ', $this->whois())); - //$this->dumpHistory('copy'); - $this->elementsBackup = $this->elements; - foreach ($this->elements as $node) { - $newStack[] = $node->cloneNode(true); - } - $this->elements = $newStack; - return $this->newInstance(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function replaceWithPHP($code) - { - return $this->replaceWith(phpQuery::php($code)); - } - /** - * Enter description here... - * - * @param String|phpQuery $content - * @link http://docs.jquery.com/Manipulation/replaceWith#content - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function replaceWith($content) - { - return $this->after($content)->remove(); - } - /** - * Enter description here... - * - * @param String $selector - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo this works ? - */ - public function replaceAll($selector) - { - foreach (phpQuery::pq($selector, $this->getDocumentID()) as $node) - phpQuery::pq($node, $this->getDocumentID()) - ->after($this->_clone()) - ->remove(); - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function remove($selector = null) - { - $loop = $selector - ? $this->filter($selector)->elements - : $this->elements; - foreach ($loop as $node) { - if (!$node->parentNode) - continue; - if (isset($node->tagName)) - $this->debug("Removing '{$node->tagName}'"); - $node->parentNode->removeChild($node); - // Mutation event - $event = new DOMEvent(array( - 'target' => $node, - 'type' => 'DOMNodeRemoved' - )); - phpQueryEvents::trigger( - $this->getDocumentID(), - $event->type, - array($event), - $node - ); - } - return $this; - } - protected function markupEvents($newMarkup, $oldMarkup, $node) - { - if ($node->tagName == 'textarea' && $newMarkup != $oldMarkup) { - $event = new DOMEvent(array( - 'target' => $node, - 'type' => 'change' - )); - phpQueryEvents::trigger( - $this->getDocumentID(), - $event->type, - array($event), - $node - ); - } - } - /** - * jQuey difference - * - * @param $markup - * @return unknown_type - * @TODO trigger change event for textarea - */ - public function markup($markup = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - $args = func_get_args(); - if ($this->documentWrapper->isXML) - return call_user_func_array(array($this, 'xml'), $args); - else - return call_user_func_array(array($this, 'html'), $args); - } - /** - * jQuey difference - * - * @param $markup - * @return unknown_type - */ - public function markupOuter($callback1 = null, $callback2 = null, $callback3 = null) - { - $args = func_get_args(); - if ($this->documentWrapper->isXML) - return call_user_func_array(array($this, 'xmlOuter'), $args); - else - return call_user_func_array(array($this, 'htmlOuter'), $args); - } - /** - * Enter description here... - * - * @param unknown_type $html - * @return string|phpQuery|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @TODO force html result - */ - public function html($html = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - if (isset($html)) { - // INSERT - $nodes = $this->documentWrapper->import($html); - $this->empty(); - foreach ($this->stack(1) as $alreadyAdded => $node) { - // for now, limit events for textarea - if (($this->isXHTML() || $this->isHTML()) && $node->tagName == 'textarea') - $oldHtml = pq($node, $this->getDocumentID())->markup(); - foreach ($nodes as $newNode) { - $node->appendChild( - $alreadyAdded - ? $newNode->cloneNode(true) - : $newNode - ); - } - // for now, limit events for textarea - if (($this->isXHTML() || $this->isHTML()) && $node->tagName == 'textarea') - $this->markupEvents($html, $oldHtml, $node); - } - return $this; - } else { - // FETCH - $return = $this->documentWrapper->markup($this->elements, true); - $args = func_get_args(); - foreach (array_slice($args, 1) as $callback) { - $return = phpQuery::callbackRun($callback, array($return)); - } - return $return; - } - } - /** - * @TODO force xml result - */ - public function xml($xml = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - $args = func_get_args(); - return call_user_func_array(array($this, 'html'), $args); - } - /** - * Enter description here... - * @TODO force html result - * - * @return String - */ - public function htmlOuter($callback1 = null, $callback2 = null, $callback3 = null) - { - $markup = $this->documentWrapper->markup($this->elements); - // pass thou callbacks - $args = func_get_args(); - foreach ($args as $callback) { - $markup = phpQuery::callbackRun($callback, array($markup)); - } - return $markup; - } - /** - * @TODO force xml result - */ - public function xmlOuter($callback1 = null, $callback2 = null, $callback3 = null) - { - $args = func_get_args(); - return call_user_func_array(array($this, 'htmlOuter'), $args); - } - public function __toString() - { - return $this->markupOuter(); - } - /** - * Just like html(), but returns markup with VALID (dangerous) PHP tags. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo support returning markup with PHP tags when called without param - */ - public function php($code = null) - { - return $this->markupPHP($code); - } - /** - * Enter description here... - * - * @param $code - * @return unknown_type - */ - public function markupPHP($code = null) - { - return isset($code) - ? $this->markup(phpQuery::php($code)) - : phpQuery::markupToPHP($this->markup()); - } - /** - * Enter description here... - * - * @param $code - * @return unknown_type - */ - public function markupOuterPHP() - { - return phpQuery::markupToPHP($this->markupOuter()); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function children($selector = null) - { - $stack = array(); - foreach ($this->stack(1) as $node) { - // foreach($node->getElementsByTagName('*') as $newNode) { - foreach ($node->childNodes as $newNode) { - if ($newNode->nodeType != 1) - continue; - if ($selector && !$this->is($selector, $newNode)) - continue; - if ($this->elementsContainsNode($newNode, $stack)) - continue; - $stack[] = $newNode; - } - } - $this->elementsBackup = $this->elements; - $this->elements = $stack; - return $this->newInstance(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function ancestors($selector = null) - { - return $this->children($selector); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function append($content) - { - return $this->insert($content, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function appendPHP($content) - { - return $this->insert("", 'append'); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function appendTo($seletor) - { - return $this->insert($seletor, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function prepend($content) - { - return $this->insert($content, __FUNCTION__); - } - /** - * Enter description here... - * - * @todo accept many arguments, which are joined, arrays maybe also - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function prependPHP($content) - { - return $this->insert("", 'prepend'); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function prependTo($seletor) - { - return $this->insert($seletor, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function before($content) - { - return $this->insert($content, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function beforePHP($content) - { - return $this->insert("", 'before'); - } - /** - * Enter description here... - * - * @param String|phpQuery - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function insertBefore($seletor) - { - return $this->insert($seletor, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function after($content) - { - return $this->insert($content, __FUNCTION__); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function afterPHP($content) - { - return $this->insert("", 'after'); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function insertAfter($seletor) - { - return $this->insert($seletor, __FUNCTION__); - } - /** - * Internal insert method. Don't use it. - * - * @param unknown_type $target - * @param unknown_type $type - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @access private - */ - public function insert($target, $type) - { - $this->debug("Inserting data with '{$type}'"); - $to = false; - switch ($type) { - case 'appendTo': - case 'prependTo': - case 'insertBefore': - case 'insertAfter': - $to = true; - } - switch (gettype($target)) { - case 'string': - $insertFrom = $insertTo = array(); - if ($to) { - // INSERT TO - $insertFrom = $this->elements; - if (phpQuery::isMarkup($target)) { - // $target is new markup, import it - $insertTo = $this->documentWrapper->import($target); - // insert into selected element - } else { - // $tagret is a selector - $thisStack = $this->elements; - $this->toRoot(); - $insertTo = $this->find($target)->elements; - $this->elements = $thisStack; - } - } else { - // INSERT FROM - $insertTo = $this->elements; - $insertFrom = $this->documentWrapper->import($target); - } - break; - case 'object': - $insertFrom = $insertTo = array(); - // phpQuery - if ($target instanceof self) { - if ($to) { - $insertTo = $target->elements; - if ($this->documentFragment && $this->stackIsRoot()) - // get all body children - // $loop = $this->find('body > *')->elements; - // TODO test it, test it hard... - // $loop = $this->newInstance($this->root)->find('> *')->elements; - $loop = $this->root->childNodes; - else - $loop = $this->elements; - // import nodes if needed - $insertFrom = $this->getDocumentID() == $target->getDocumentID() - ? $loop - : $target->documentWrapper->import($loop); - } else { - $insertTo = $this->elements; - if ($target->documentFragment && $target->stackIsRoot()) - // get all body children - // $loop = $target->find('body > *')->elements; - $loop = $target->root->childNodes; - else - $loop = $target->elements; - // import nodes if needed - $insertFrom = $this->getDocumentID() == $target->getDocumentID() - ? $loop - : $this->documentWrapper->import($loop); - } - // DOMNODE - } elseif ($target instanceof DOMNODE) { - // import node if needed - // if ( $target->ownerDocument != $this->DOM ) - // $target = $this->DOM->importNode($target, true); - if ($to) { - $insertTo = array($target); - if ($this->documentFragment && $this->stackIsRoot()) - // get all body children - $loop = $this->root->childNodes; - // $loop = $this->find('body > *')->elements; - else - $loop = $this->elements; - foreach ($loop as $fromNode) - // import nodes if needed - $insertFrom[] = !$fromNode->ownerDocument->isSameNode($target->ownerDocument) - ? $target->ownerDocument->importNode($fromNode, true) - : $fromNode; - } else { - // import node if needed - if (!$target->ownerDocument->isSameNode($this->document)) - $target = $this->document->importNode($target, true); - $insertTo = $this->elements; - $insertFrom[] = $target; - } - } - break; - } - phpQuery::debug("From " . count($insertFrom) . "; To " . count($insertTo) . " nodes"); - foreach ($insertTo as $insertNumber => $toNode) { - // we need static relative elements in some cases - switch ($type) { - case 'prependTo': - case 'prepend': - $firstChild = $toNode->firstChild; - break; - case 'insertAfter': - case 'after': - $nextSibling = $toNode->nextSibling; - break; - } - foreach ($insertFrom as $fromNode) { - // clone if inserted already before - $insert = $insertNumber - ? $fromNode->cloneNode(true) - : $fromNode; - switch ($type) { - case 'appendTo': - case 'append': - // $toNode->insertBefore( - // $fromNode, - // $toNode->lastChild->nextSibling - // ); - $toNode->appendChild($insert); - $eventTarget = $insert; - break; - case 'prependTo': - case 'prepend': - $toNode->insertBefore( - $insert, - $firstChild - ); - break; - case 'insertBefore': - case 'before': - if (!$toNode->parentNode) - throw new Exception("No parentNode, can't do {$type}()"); - else - $toNode->parentNode->insertBefore( - $insert, - $toNode - ); - break; - case 'insertAfter': - case 'after': - if (!$toNode->parentNode) - throw new Exception("No parentNode, can't do {$type}()"); - else - $toNode->parentNode->insertBefore( - $insert, - $nextSibling - ); - break; - } - // Mutation event - $event = new DOMEvent(array( - 'target' => $insert, - 'type' => 'DOMNodeInserted' - )); - phpQueryEvents::trigger( - $this->getDocumentID(), - $event->type, - array($event), - $insert - ); - } - } - return $this; - } - /** - * Enter description here... - * - * @return Int - */ - public function index($subject) - { - $index = -1; - $subject = $subject instanceof phpQueryObject - ? $subject->elements[0] - : $subject; - foreach ($this->newInstance() as $k => $node) { - if ($node->isSameNode($subject)) - $index = $k; - } - return $index; - } - /** - * Enter description here... - * - * @param unknown_type $start - * @param unknown_type $end - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @testme - */ - public function slice($start, $end = null) - { - // $last = count($this->elements)-1; - // $end = $end - // ? min($end, $last) - // : $last; - // if ($start < 0) - // $start = $last+$start; - // if ($start > $last) - // return array(); - if ($end > 0) - $end = $end - $start; - return $this->newInstance( - array_slice($this->elements, $start, $end) - ); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function reverse() - { - $this->elementsBackup = $this->elements; - $this->elements = array_reverse($this->elements); - return $this->newInstance(); - } - /** - * Return joined text content. - * @return String - */ - public function text($text = null, $callback1 = null, $callback2 = null, $callback3 = null) - { - if (isset($text)) - return $this->html(htmlspecialchars($text)); - $args = func_get_args(); - $args = array_slice($args, 1); - $return = ''; - foreach ($this->elements as $node) { - $text = $node->textContent; - if (count($this->elements) > 1 && $text) - $text .= "\n"; - foreach ($args as $callback) { - $text = phpQuery::callbackRun($callback, array($text)); - } - $return .= $text; - } - return $return; - } - /** - * @return The text content of each matching element, like - * text() but returns an array with one entry per matched element. - * Read only. - */ - public function texts($attr = null) - { - $results = array(); - foreach ($this->elements as $node) { - $results[] = $node->textContent; - } - return $results; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function plugin($class, $file = null) - { - phpQuery::plugin($class, $file); - return $this; - } - /** - * Deprecated, use $pq->plugin() instead. - * - * @deprecated - * @param $class - * @param $file - * @return unknown_type - */ - public static function extend($class, $file = null) - { - return $this->plugin($class, $file); - } - /** - * - * @access private - * @param $method - * @param $args - * @return unknown_type - */ - public function __call($method, $args) - { - $aliasMethods = array('clone', 'empty'); - if (isset(phpQuery::$extendMethods[$method])) { - array_unshift($args, $this); - return phpQuery::callbackRun( - phpQuery::$extendMethods[$method], - $args - ); - } else if (isset(phpQuery::$pluginsMethods[$method])) { - array_unshift($args, $this); - $class = phpQuery::$pluginsMethods[$method]; - $realClass = "phpQueryObjectPlugin_$class"; - $return = call_user_func_array( - array($realClass, $method), - $args - ); - // XXX deprecate ? - return is_null($return) - ? $this - : $return; - } else if (in_array($method, $aliasMethods)) { - return call_user_func_array(array($this, '_' . $method), $args); - } else - throw new Exception("Method '{$method}' doesnt exist"); - } - /** - * Safe rename of next(). - * - * Use it ONLY when need to call next() on an iterated object (in same time). - * Normaly there is no need to do such thing ;) - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @access private - */ - public function _next($selector = null) - { - return $this->newInstance( - $this->getElementSiblings('nextSibling', $selector, true) - ); - } - /** - * Use prev() and next(). - * - * @deprecated - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @access private - */ - public function _prev($selector = null) - { - return $this->prev($selector); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function prev($selector = null) - { - return $this->newInstance( - $this->getElementSiblings('previousSibling', $selector, true) - ); - } - /** - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo - */ - public function prevAll($selector = null) - { - return $this->newInstance( - $this->getElementSiblings('previousSibling', $selector) - ); - } - /** - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo FIXME: returns source elements insted of next siblings - */ - public function nextAll($selector = null) - { - return $this->newInstance( - $this->getElementSiblings('nextSibling', $selector) - ); - } - /** - * @access private - */ - protected function getElementSiblings($direction, $selector = null, $limitToOne = false) - { - $stack = array(); - $count = 0; - foreach ($this->stack() as $node) { - $test = $node; - while (isset($test->{$direction}) && $test->{$direction}) { - $test = $test->{$direction}; - if (!$test instanceof DOMELEMENT) - continue; - $stack[] = $test; - if ($limitToOne) - break; - } - } - if ($selector) { - $stackOld = $this->elements; - $this->elements = $stack; - $stack = $this->filter($selector, true)->stack(); - $this->elements = $stackOld; - } - return $stack; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function siblings($selector = null) - { - $stack = array(); - $siblings = array_merge( - $this->getElementSiblings('previousSibling', $selector), - $this->getElementSiblings('nextSibling', $selector) - ); - foreach ($siblings as $node) { - if (!$this->elementsContainsNode($node, $stack)) - $stack[] = $node; - } - return $this->newInstance($stack); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function not($selector = null) - { - if (is_string($selector)) - phpQuery::debug(array('not', $selector)); - else - phpQuery::debug('not'); - $stack = array(); - if ($selector instanceof self || $selector instanceof DOMNODE) { - foreach ($this->stack() as $node) { - if ($selector instanceof self) { - $matchFound = false; - foreach ($selector->stack() as $notNode) { - if ($notNode->isSameNode($node)) - $matchFound = true; - } - if (!$matchFound) - $stack[] = $node; - } else if ($selector instanceof DOMNODE) { - if (!$selector->isSameNode($node)) - $stack[] = $node; - } else { - if (!$this->is($selector)) - $stack[] = $node; - } - } - } else { - $orgStack = $this->stack(); - $matched = $this->filter($selector, true)->stack(); - // $matched = array(); - // // simulate OR in filter() instead of AND 5y - // foreach($this->parseSelector($selector) as $s) { - // $matched = array_merge($matched, - // $this->filter(array($s))->stack() - // ); - // } - foreach ($orgStack as $node) - if (!$this->elementsContainsNode($node, $matched)) - $stack[] = $node; - } - return $this->newInstance($stack); - } - /** - * Enter description here... - * - * @param string|phpQueryObject - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function add($selector = null) - { - if (!$selector) - return $this; - $stack = array(); - $this->elementsBackup = $this->elements; - $found = phpQuery::pq($selector, $this->getDocumentID()); - $this->merge($found->elements); - return $this->newInstance(); - } - /** - * @access private - */ - protected function merge() - { - foreach (func_get_args() as $nodes) - foreach ($nodes as $newNode) - if (!$this->elementsContainsNode($newNode)) - $this->elements[] = $newNode; - } - /** - * @access private - * TODO refactor to stackContainsNode - */ - protected function elementsContainsNode($nodeToCheck, $elementsStack = null) - { - $loop = !is_null($elementsStack) - ? $elementsStack - : $this->elements; - foreach ($loop as $node) { - if ($node->isSameNode($nodeToCheck)) - return true; - } - return false; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function parent($selector = null) - { - $stack = array(); - foreach ($this->elements as $node) - if ($node->parentNode && !$this->elementsContainsNode($node->parentNode, $stack)) - $stack[] = $node->parentNode; - $this->elementsBackup = $this->elements; - $this->elements = $stack; - if ($selector) - $this->filter($selector, true); - return $this->newInstance(); - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function parents($selector = null) - { - $stack = array(); - if (!$this->elements) - $this->debug('parents() - stack empty'); - foreach ($this->elements as $node) { - $test = $node; - while ($test->parentNode) { - $test = $test->parentNode; - if ($this->isRoot($test)) - break; - if (!$this->elementsContainsNode($test, $stack)) { - $stack[] = $test; - continue; - } - } - } - $this->elementsBackup = $this->elements; - $this->elements = $stack; - if ($selector) - $this->filter($selector, true); - return $this->newInstance(); - } - /** - * Internal stack iterator. - * - * @access private - */ - public function stack($nodeTypes = null) - { - if (!isset($nodeTypes)) - return $this->elements; - if (!is_array($nodeTypes)) - $nodeTypes = array($nodeTypes); - $return = array(); - foreach ($this->elements as $node) { - if (in_array($node->nodeType, $nodeTypes)) - $return[] = $node; - } - return $return; - } - // TODO phpdoc; $oldAttr is result of hasAttribute, before any changes - protected function attrEvents($attr, $oldAttr, $oldValue, $node) - { - // skip events for XML documents - if (!$this->isXHTML() && !$this->isHTML()) - return; - $event = null; - // identify - $isInputValue = $node->tagName == 'input' - && (in_array( - $node->getAttribute('type'), - array('text', 'password', 'hidden') - ) - || !$node->getAttribute('type') - ); - $isRadio = $node->tagName == 'input' - && $node->getAttribute('type') == 'radio'; - $isCheckbox = $node->tagName == 'input' - && $node->getAttribute('type') == 'checkbox'; - $isOption = $node->tagName == 'option'; - if ($isInputValue && $attr == 'value' && $oldValue != $node->getAttribute($attr)) { - $event = new DOMEvent(array( - 'target' => $node, - 'type' => 'change' - )); - } else if (($isRadio || $isCheckbox) && $attr == 'checked' && ( - // check - (!$oldAttr && $node->hasAttribute($attr)) - // un-check - || (!$node->hasAttribute($attr) && $oldAttr) - )) { - $event = new DOMEvent(array( - 'target' => $node, - 'type' => 'change' - )); - } else if ($isOption && $node->parentNode && $attr == 'selected' && ( - // select - (!$oldAttr && $node->hasAttribute($attr)) - // un-select - || (!$node->hasAttribute($attr) && $oldAttr) - )) { - $event = new DOMEvent(array( - 'target' => $node->parentNode, - 'type' => 'change' - )); - } - if ($event) { - phpQueryEvents::trigger( - $this->getDocumentID(), - $event->type, - array($event), - $node - ); - } - } - public function attr($attr = null, $value = null) - { - foreach ($this->stack(1) as $node) { - if (!is_null($value)) { - $loop = $attr == '*' - ? $this->getNodeAttrs($node) - : array($attr); - foreach ($loop as $a) { - $oldValue = $node->getAttribute($a); - $oldAttr = $node->hasAttribute($a); - // TODO raises an error when charset other than UTF-8 - // while document's charset is also not UTF-8 - @$node->setAttribute($a, $value); - $this->attrEvents($a, $oldAttr, $oldValue, $node); - } - } else if ($attr == '*') { - // jQuery difference - $return = array(); - foreach ($node->attributes as $n => $v) - $return[$n] = $v->value; - return $return; - } else - return $node->hasAttribute($attr) - ? $node->getAttribute($attr) - : null; - } - return is_null($value) - ? '' : $this; - } - /** - * @return The same attribute of each matching element, like - * attr() but returns an array with one entry per matched element. - * Read only. - */ - public function attrs($attr = null) - { - $results = array(); - foreach ($this->stack(1) as $node) { - $results[] = $node->hasAttribute($attr) - ? $node->getAttribute($attr) - : null; - } - return $results; - } - /** - * @access private - */ - protected function getNodeAttrs($node) - { - $return = array(); - foreach ($node->attributes as $n => $o) - $return[] = $n; - return $return; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo check CDATA ??? - */ - public function attrPHP($attr, $code) - { - if (!is_null($code)) { - $value = '<' . '?php ' . $code . ' ?' . '>'; - // TODO tempolary solution - // http://code.google.com/p/phpquery/issues/detail?id=17 - // if (function_exists('mb_detect_encoding') && mb_detect_encoding($value) == 'ASCII') - // $value = mb_convert_encoding($value, 'UTF-8', 'HTML-ENTITIES'); - } - foreach ($this->stack(1) as $node) { - if (!is_null($code)) { - // $attrNode = $this->DOM->createAttribute($attr); - $node->setAttribute($attr, $value); - // $attrNode->value = $value; - // $node->appendChild($attrNode); - } else if ($attr == '*') { - // jQuery diff - $return = array(); - foreach ($node->attributes as $n => $v) - $return[$n] = $v->value; - return $return; - } else - return $node->getAttribute($attr); - } - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function removeAttr($attr) - { - foreach ($this->stack(1) as $node) { - $loop = $attr == '*' - ? $this->getNodeAttrs($node) - : array($attr); - foreach ($loop as $a) { - $oldValue = $node->getAttribute($a); - $node->removeAttribute($a); - $this->attrEvents($a, $oldValue, null, $node); - } - } - return $this; - } - /** - * Return form element value. - * - * @return String Fields value. - */ - public function val($val = null) - { - if (!isset($val)) { - if ($this->eq(0)->is('select')) { - $selected = $this->eq(0)->find('option[selected=selected]'); - if ($selected->is('[value]')) - return $selected->attr('value'); - else - return $selected->text(); - } else if ($this->eq(0)->is('textarea')) - return $this->eq(0)->markup(); - else - return $this->eq(0)->attr('value'); - } else { - $_val = null; - foreach ($this->stack(1) as $node) { - $node = pq($node, $this->getDocumentID()); - if (is_array($val) && in_array($node->attr('type'), array('checkbox', 'radio'))) { - $isChecked = in_array($node->attr('value'), $val) - || in_array($node->attr('name'), $val); - if ($isChecked) - $node->attr('checked', 'checked'); - else - $node->removeAttr('checked'); - } else if ($node->get(0)->tagName == 'select') { - if (!isset($_val)) { - $_val = array(); - if (!is_array($val)) - $_val = array((string)$val); - else - foreach ($val as $v) - $_val[] = $v; - } - foreach ($node['option']->stack(1) as $option) { - $option = pq($option, $this->getDocumentID()); - $selected = false; - // XXX: workaround for string comparsion, see issue #96 - // http://code.google.com/p/phpquery/issues/detail?id=96 - $selected = is_null($option->attr('value')) - ? in_array($option->markup(), $_val) - : in_array($option->attr('value'), $_val); - // $optionValue = $option->attr('value'); - // $optionText = $option->text(); - // $optionTextLenght = mb_strlen($optionText); - // foreach($_val as $v) - // if ($optionValue == $v) - // $selected = true; - // else if ($optionText == $v && $optionTextLenght == mb_strlen($v)) - // $selected = true; - if ($selected) - $option->attr('selected', 'selected'); - else - $option->removeAttr('selected'); - } - } else if ($node->get(0)->tagName == 'textarea') - $node->markup($val); - else - $node->attr('value', $val); - } - } - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function andSelf() - { - if ($this->previous) - $this->elements = array_merge($this->elements, $this->previous->elements); - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function addClass($className) - { - if (!$className) - return $this; - foreach ($this->stack(1) as $node) { - if (!$this->is(".$className", $node)) - $node->setAttribute( - 'class', - trim($node->getAttribute('class') . ' ' . $className) - ); - } - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function addClassPHP($className) - { - foreach ($this->stack(1) as $node) { - $classes = $node->getAttribute('class'); - $newValue = $classes - ? $classes . ' <' . '?php ' . $className . ' ?' . '>' - : '<' . '?php ' . $className . ' ?' . '>'; - $node->setAttribute('class', $newValue); - } - return $this; - } - /** - * Enter description here... - * - * @param string $className - * @return bool - */ - public function hasClass($className) - { - foreach ($this->stack(1) as $node) { - if ($this->is(".$className", $node)) - return true; - } - return false; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function removeClass($className) - { - foreach ($this->stack(1) as $node) { - $classes = explode(' ', $node->getAttribute('class')); - if (in_array($className, $classes)) { - $classes = array_diff($classes, array($className)); - if ($classes) - $node->setAttribute('class', implode(' ', $classes)); - else - $node->removeAttribute('class'); - } - } - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function toggleClass($className) - { - foreach ($this->stack(1) as $node) { - if ($this->is($node, '.' . $className)) - $this->removeClass($className); - else - $this->addClass($className); - } - return $this; - } - /** - * Proper name without underscore (just ->empty()) also works. - * - * Removes all child nodes from the set of matched elements. - * - * Example: - * pq("p")._empty() - * - * HTML: - *

Hello, Person and person

- * - * Result: - * [

] - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @access private - */ - public function _empty() - { - foreach ($this->stack(1) as $node) { - // thx to 'dave at dgx dot cz' - $node->nodeValue = ''; - } - return $this; - } - /** - * Enter description here... - * - * @param array|string $callback Expects $node as first param, $index as second - * @param array $scope External variables passed to callback. Use compact('varName1', 'varName2'...) and extract($scope) - * @param array $arg1 Will ba passed as third and futher args to callback. - * @param array $arg2 Will ba passed as fourth and futher args to callback, and so on... - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function each($callback, $param1 = null, $param2 = null, $param3 = null) - { - $paramStructure = null; - if (func_num_args() > 1) { - $paramStructure = func_get_args(); - $paramStructure = array_slice($paramStructure, 1); - } - foreach ($this->elements as $v) - phpQuery::callbackRun($callback, array($v), $paramStructure); - return $this; - } - /** - * Run callback on actual object. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public function callback($callback, $param1 = null, $param2 = null, $param3 = null) - { - $params = func_get_args(); - $params[0] = $this; - phpQuery::callbackRun($callback, $params); - return $this; - } - /** - * Enter description here... - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @todo add $scope and $args as in each() ??? - */ - public function map($callback, $param1 = null, $param2 = null, $param3 = null) - { - // $stack = array(); - //// foreach($this->newInstance() as $node) { - // foreach($this->newInstance() as $node) { - // $result = call_user_func($callback, $node); - // if ($result) - // $stack[] = $result; - // } - $params = func_get_args(); - array_unshift($params, $this->elements); - return $this->newInstance( - call_user_func_array(array('phpQuery', 'map'), $params) - // phpQuery::map($this->elements, $callback) - ); - } - /** - * Enter description here... - * - * @param $key - * @param $value - */ - public function data($key, $value = null) - { - if (!isset($value)) { - // TODO? implement specific jQuery behavior od returning parent values - // is child which we look up doesn't exist - return phpQuery::data($this->get(0), $key, $value, $this->getDocumentID()); - } else { - foreach ($this as $node) - phpQuery::data($node, $key, $value, $this->getDocumentID()); - return $this; - } - } - /** - * Enter description here... - * - * @param $key - */ - public function removeData($key) - { - foreach ($this as $node) - phpQuery::removeData($node, $key, $this->getDocumentID()); - return $this; - } - // INTERFACE IMPLEMENTATIONS - - // ITERATOR INTERFACE - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function rewind() - { - $this->debug('iterating foreach'); - // phpQuery::selectDocument($this->getDocumentID()); - $this->elementsBackup = $this->elements; - $this->elementsInterator = $this->elements; - $this->valid = isset($this->elements[0]) - ? 1 : 0; - // $this->elements = $this->valid - // ? array($this->elements[0]) - // : array(); - $this->current = 0; - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function current() - { - return $this->elementsInterator[$this->current]; - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function key() - { - return $this->current; - } - /** - * Double-function method. - * - * First: main iterator interface method. - * Second: Returning next sibling, alias for _next(). - * - * Proper functionality is choosed automagicaly. - * - * @see phpQueryObject::_next() - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - #[\ReturnTypeWillChange] - public function next($cssSelector = null) - { - // if ($cssSelector || $this->valid) - // return $this->_next($cssSelector); - $this->valid = isset($this->elementsInterator[$this->current + 1]) - ? true - : false; - if (!$this->valid && $this->elementsInterator) { - $this->elementsInterator = null; - } else if ($this->valid) { - $this->current++; - } else { - return $this->_next($cssSelector); - } - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function valid() - { - return $this->valid; - } - // ITERATOR INTERFACE END - // ARRAYACCESS INTERFACE - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function offsetExists($offset) - { - return $this->find($offset)->size() > 0; - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - return $this->find($offset); - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) - { - // $this->find($offset)->replaceWith($value); - $this->find($offset)->html($value); - } - /** - * @access private - */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) - { - // empty - throw new Exception("Can't do unset, use array interface only for calling queries and replacing HTML."); - } - // ARRAYACCESS INTERFACE END - /** - * Returns node's XPath. - * - * @param unknown_type $oneNode - * @return string - * @TODO use native getNodePath is avaible - * @access private - */ - protected function getNodeXpath($oneNode = null, $namespace = null) - { - $return = array(); - $loop = $oneNode - ? array($oneNode) - : $this->elements; - // if ($namespace) - // $namespace .= ':'; - foreach ($loop as $node) { - if ($node instanceof DOMDOCUMENT) { - $return[] = ''; - continue; - } - $xpath = array(); - while (!($node instanceof DOMDOCUMENT)) { - $i = 1; - $sibling = $node; - while ($sibling->previousSibling) { - $sibling = $sibling->previousSibling; - $isElement = $sibling instanceof DOMELEMENT; - if ($isElement && $sibling->tagName == $node->tagName) - $i++; - } - $xpath[] = $this->isXML() - ? "*[local-name()='{$node->tagName}'][{$i}]" - : "{$node->tagName}[{$i}]"; - $node = $node->parentNode; - } - $xpath = implode('/', array_reverse($xpath)); - $return[] = '/' . $xpath; - } - return $oneNode - ? $return[0] - : $return; - } - // HELPERS - public function whois($oneNode = null) - { - $return = array(); - $loop = $oneNode - ? array($oneNode) - : $this->elements; - foreach ($loop as $node) { - if (isset($node->tagName)) { - $tag = in_array($node->tagName, array('php', 'js')) - ? strtoupper($node->tagName) - : $node->tagName; - $return[] = $tag - . ($node->getAttribute('id') - ? '#' . $node->getAttribute('id') : '') - . ($node->getAttribute('class') - ? '.' . implode('.', explode(' ', $node->getAttribute('class'))) : '') - . ($node->getAttribute('name') - ? '[name="' . $node->getAttribute('name') . '"]' : '') - . ($node->getAttribute('value') && strpos($node->getAttribute('value'), '<' . '?php') === false - ? '[value="' . substr(str_replace("\n", '', $node->getAttribute('value')), 0, 15) . '"]' : '') - . ($node->getAttribute('value') && strpos($node->getAttribute('value'), '<' . '?php') !== false - ? '[value=PHP]' : '') - . ($node->getAttribute('selected') - ? '[selected]' : '') - . ($node->getAttribute('checked') - ? '[checked]' : ''); - } else if ($node instanceof DOMTEXT) { - if (trim($node->textContent)) - $return[] = 'Text:' . substr(str_replace("\n", ' ', $node->textContent), 0, 15); - } else { - } - } - return $oneNode && isset($return[0]) - ? $return[0] - : $return; - } - /** - * Dump htmlOuter and preserve chain. Usefull for debugging. - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * - */ - public function dump() - { - print 'DUMP #' . (phpQuery::$dumpCount++) . ' '; - $debug = phpQuery::$debug; - phpQuery::$debug = false; - // print __FILE__.':'.__LINE__."\n"; - var_dump($this->htmlOuter()); - return $this; - } - public function dumpWhois() - { - print 'DUMP #' . (phpQuery::$dumpCount++) . ' '; - $debug = phpQuery::$debug; - phpQuery::$debug = false; - // print __FILE__.':'.__LINE__."\n"; - var_dump('whois', $this->whois()); - phpQuery::$debug = $debug; - return $this; - } - public function dumpLength() - { - print 'DUMP #' . (phpQuery::$dumpCount++) . ' '; - $debug = phpQuery::$debug; - phpQuery::$debug = false; - // print __FILE__.':'.__LINE__."\n"; - var_dump('length', $this->length()); - phpQuery::$debug = $debug; - return $this; - } - public function dumpTree($html = true, $title = true) - { - $output = $title - ? 'DUMP #' . (phpQuery::$dumpCount++) . " \n" : ''; - $debug = phpQuery::$debug; - phpQuery::$debug = false; - foreach ($this->stack() as $node) - $output .= $this->__dumpTree($node); - phpQuery::$debug = $debug; - print $html - ? nl2br(str_replace(' ', ' ', $output)) - : $output; - return $this; - } - private function __dumpTree($node, $intend = 0) - { - $whois = $this->whois($node); - $return = ''; - if ($whois) - $return .= str_repeat(' - ', $intend) . $whois . "\n"; - if (isset($node->childNodes)) - foreach ($node->childNodes as $chNode) - $return .= $this->__dumpTree($chNode, $intend + 1); - return $return; - } - /** - * Dump htmlOuter and stop script execution. Usefull for debugging. - * - */ - public function dumpDie() - { - print __FILE__ . ':' . __LINE__; - var_dump($this->htmlOuter()); - die(); - } -} - - -// -- Multibyte Compatibility functions --------------------------------------- -// http://svn.iphonewebdev.com/lace/lib/mb_compat.php - -/** - * mb_internal_encoding() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_internal_encoding')) { - function mb_internal_encoding($enc) - { - return true; - } -} - -/** - * mb_regex_encoding() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_regex_encoding')) { - function mb_regex_encoding($enc) - { - return true; - } -} - -/** - * mb_strlen() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_strlen')) { - function mb_strlen($str) - { - return strlen($str); - } -} - -/** - * mb_strpos() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_strpos')) { - function mb_strpos($haystack, $needle, $offset = 0) - { - return strpos($haystack, $needle, $offset); - } -} -/** - * mb_stripos() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_stripos')) { - function mb_stripos($haystack, $needle, $offset = 0) - { - return stripos($haystack, $needle, $offset); - } -} - -/** - * mb_substr() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_substr')) { - function mb_substr($str, $start, $length = 0) - { - return substr($str, $start, $length); - } -} - -/** - * mb_substr_count() - * - * Included for mbstring pseudo-compatability. - */ -if (!function_exists('mb_substr_count')) { - function mb_substr_count($haystack, $needle) - { - return substr_count($haystack, $needle); - } -} - - -/** - * Static namespace for phpQuery functions. - * - * @author Tobiasz Cudnik - * @package phpQuery - */ -abstract class phpQuery -{ - /** - * XXX: Workaround for mbstring problems - * - * @var bool - */ - public static $mbstringSupport = true; - public static $debug = false; - public static $documents = array(); - public static $defaultDocumentID = null; - // public static $defaultDoctype = 'html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"'; - /** - * Applies only to HTML. - * - * @var unknown_type - */ - public static $defaultDoctype = ''; - public static $defaultCharset = 'UTF-8'; - /** - * Static namespace for plugins. - * - * @var object - */ - public static $plugins = array(); - /** - * List of loaded plugins. - * - * @var unknown_type - */ - public static $pluginsLoaded = array(); - public static $pluginsMethods = array(); - public static $pluginsStaticMethods = array(); - public static $extendMethods = array(); - /** - * @TODO implement - */ - public static $extendStaticMethods = array(); - /** - * Hosts allowed for AJAX connections. - * Dot '.' means $_SERVER['HTTP_HOST'] (if any). - * - * @var array - */ - public static $ajaxAllowedHosts = array( - '.' - ); - /** - * AJAX settings. - * - * @var array - * XXX should it be static or not ? - */ - public static $ajaxSettings = array( - 'url' => '', //TODO - 'global' => true, - 'type' => "GET", - 'timeout' => null, - 'contentType' => "application/x-www-form-urlencoded", - 'processData' => true, - // 'async' => true, - 'data' => null, - 'username' => null, - 'password' => null, - 'accepts' => array( - 'xml' => "application/xml, text/xml", - 'html' => "text/html", - 'script' => "text/javascript, application/javascript", - 'json' => "application/json, text/javascript", - 'text' => "text/plain", - '_default' => "*/*" - ) - ); - public static $lastModified = null; - public static $active = 0; - public static $dumpCount = 0; - /** - * Multi-purpose function. - * Use pq() as shortcut. - * - * In below examples, $pq is any result of pq(); function. - * - * 1. Import markup into existing document (without any attaching): - * - Import into selected document: - * pq('
') // DOESNT accept text nodes at beginning of input string ! - * - Import into document with ID from $pq->getDocumentID(): - * pq('
', $pq->getDocumentID()) - * - Import into same document as DOMNode belongs to: - * pq('
', DOMNode) - * - Import into document from phpQuery object: - * pq('
', $pq) - * - * 2. Run query: - * - Run query on last selected document: - * pq('div.myClass') - * - Run query on document with ID from $pq->getDocumentID(): - * pq('div.myClass', $pq->getDocumentID()) - * - Run query on same document as DOMNode belongs to and use node(s)as root for query: - * pq('div.myClass', DOMNode) - * - Run query on document from phpQuery object - * and use object's stack as root node(s) for query: - * pq('div.myClass', $pq) - * - * @param string|DOMNode|DOMNodeList|array $arg1 HTML markup, CSS Selector, DOMNode or array of DOMNodes - * @param string|phpQueryObject|DOMNode $context DOM ID from $pq->getDocumentID(), phpQuery object (determines also query root) or DOMNode (determines also query root) - * - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery|QueryTemplatesPhpQuery|false - * phpQuery object or false in case of error. - */ - public static function pq($arg1, $context = null) - { - if ($arg1 instanceof DOMNODE && !isset($context)) { - foreach (phpQuery::$documents as $documentWrapper) { - $compare = $arg1 instanceof DOMDocument - ? $arg1 : $arg1->ownerDocument; - if ($documentWrapper->document->isSameNode($compare)) - $context = $documentWrapper->id; - } - } - if (!$context) { - $domId = self::$defaultDocumentID; - if (!$domId) - throw new Exception("Can't use last created DOM, because there isn't any. Use phpQuery::newDocument() first."); - // } else if (is_object($context) && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) - } else if (is_object($context) && $context instanceof phpQueryObject) - $domId = $context->getDocumentID(); - else if ($context instanceof DOMDOCUMENT) { - $domId = self::getDocumentID($context); - if (!$domId) { - //throw new Exception('Orphaned DOMDocument'); - $domId = self::newDocument($context)->getDocumentID(); - } - } else if ($context instanceof DOMNODE) { - $domId = self::getDocumentID($context); - if (!$domId) { - throw new Exception('Orphaned DOMNode'); - // $domId = self::newDocument($context->ownerDocument); - } - } else - $domId = $context; - if ($arg1 instanceof phpQueryObject) { - // if (is_object($arg1) && (get_class($arg1) == 'phpQueryObject' || $arg1 instanceof PHPQUERY || is_subclass_of($arg1, 'phpQueryObject'))) { - /** - * Return $arg1 or import $arg1 stack if document differs: - * pq(pq('
')) - */ - if ($arg1->getDocumentID() == $domId) - return $arg1; - $class = get_class($arg1); - // support inheritance by passing old object to overloaded constructor - $phpQuery = $class != 'phpQuery' - ? new $class($arg1, $domId) - : new phpQueryObject($domId); - $phpQuery->elements = array(); - foreach ($arg1->elements as $node) - $phpQuery->elements[] = $phpQuery->document->importNode($node, true); - return $phpQuery; - } else if ($arg1 instanceof DOMNODE || (is_array($arg1) && isset($arg1[0]) && $arg1[0] instanceof DOMNODE)) { - /* - * Wrap DOM nodes with phpQuery object, import into document when needed: - * pq(array($domNode1, $domNode2)) - */ - $phpQuery = new phpQueryObject($domId); - if (!($arg1 instanceof DOMNODELIST) && !is_array($arg1)) - $arg1 = array($arg1); - $phpQuery->elements = array(); - foreach ($arg1 as $node) { - $sameDocument = $node->ownerDocument instanceof DOMDOCUMENT - && !$node->ownerDocument->isSameNode($phpQuery->document); - $phpQuery->elements[] = $sameDocument - ? $phpQuery->document->importNode($node, true) - : $node; - } - return $phpQuery; - } else if (self::isMarkup($arg1)) { - /** - * Import HTML: - * pq('
') - */ - $phpQuery = new phpQueryObject($domId); - return $phpQuery->newInstance( - $phpQuery->documentWrapper->import($arg1) - ); - } else { - /** - * Run CSS query: - * pq('div.myClass') - */ - $phpQuery = new phpQueryObject($domId); - // if ($context && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) - if ($context && $context instanceof phpQueryObject) - $phpQuery->elements = $context->elements; - else if ($context && $context instanceof DOMNODELIST) { - $phpQuery->elements = array(); - foreach ($context as $node) - $phpQuery->elements[] = $node; - } else if ($context && $context instanceof DOMNODE) - $phpQuery->elements = array($context); - return $phpQuery->find($arg1); - } - } - /** - * Sets default document to $id. Document has to be loaded prior - * to using this method. - * $id can be retrived via getDocumentID() or getDocumentIDRef(). - * - * @param unknown_type $id - */ - public static function selectDocument($id) - { - $id = self::getDocumentID($id); - self::debug("Selecting document '$id' as default one"); - self::$defaultDocumentID = self::getDocumentID($id); - } - /** - * Returns document with id $id or last used as phpQueryObject. - * $id can be retrived via getDocumentID() or getDocumentIDRef(). - * Chainable. - * - * @see phpQuery::selectDocument() - * @param unknown_type $id - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function getDocument($id = null) - { - if ($id) - phpQuery::selectDocument($id); - else - $id = phpQuery::$defaultDocumentID; - return new phpQueryObject($id); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocument($markup = null, $contentType = null) - { - if (!$markup) - $markup = ''; - $documentID = phpQuery::createDocumentWrapper($markup, $contentType); - return new phpQueryObject($documentID); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentHTML($markup = null, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocument($markup, "text/html{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentXML($markup = null, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocument($markup, "text/xml{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentXHTML($markup = null, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocument($markup, "application/xhtml+xml{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentPHP($markup = null, $contentType = "text/html") - { - // TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function) - $markup = phpQuery::phpToMarkup($markup, self::$defaultCharset); - return self::newDocument($markup, $contentType); - } - public static function phpToMarkup($php, $charset = 'utf-8') - { - $regexes = array( - '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)<' . '?php?(.*?)(?:\\?>)([^\']*)\'@s', - '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)<' . '?php?(.*?)(?:\\?>)([^"]*)"@s', - ); - foreach ($regexes as $regex) - while (preg_match($regex, $php, $matches)) { - $php = preg_replace_callback( - $regex, - // create_function('$m, $charset = "'.$charset.'"', - // 'return $m[1].$m[2] - // .htmlspecialchars("<"."?php".$m[4]."?".">", ENT_QUOTES|ENT_NOQUOTES, $charset) - // .$m[5].$m[2];' - // ), - array('phpQuery', '_phpToMarkupCallback'), - $php - ); - } - $regex = '@(^|>[^<]*)+?(<\?php(.*?)(\?>))@s'; - //preg_match_all($regex, $php, $matches); - //var_dump($matches); - $php = preg_replace($regex, '\\1', $php); - return $php; - } - public static function _phpToMarkupCallback($php, $charset = 'utf-8') - { - return $m[1] . $m[2] - . htmlspecialchars("<" . "?php" . $m[4] . "?" . ">", ENT_QUOTES | ENT_NOQUOTES, $charset) - . $m[5] . $m[2]; - } - public static function _markupToPHPCallback($m) - { - return "<" . "?php " . htmlspecialchars_decode($m[1]) . " ?" . ">"; - } - /** - * Converts document markup containing PHP code generated by phpQuery::php() - * into valid (executable) PHP code syntax. - * - * @param string|phpQueryObject $content - * @return string PHP code. - */ - public static function markupToPHP($content) - { - if ($content instanceof phpQueryObject) - $content = $content->markupOuter(); - /* ... to */ - $content = preg_replace_callback( - '@\s*\s*@s', - // create_function('$m', - // 'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";' - // ), - array('phpQuery', '_markupToPHPCallback'), - $content - ); - /* extra space added to save highlighters */ - $regexes = array( - '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:<|%3C)\\?(?:php)?(.*?)(?:\\?(?:>|%3E))([^\']*)\'@s', - '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:<|%3C)\\?(?:php)?(.*?)(?:\\?(?:>|%3E))([^"]*)"@s', - ); - foreach ($regexes as $regex) - while (preg_match($regex, $content)) - $content = preg_replace_callback( - $regex, - function ($m) { - return $m[1] . $m[2] . $m[3] . "", " ", "\n", " ", "{", "$", "}", '"', "[", "]"), - htmlspecialchars_decode($m[4]) - ) - . " ?>" . $m[5] . $m[2]; - }, - $content - ); - return $content; - } - /** - * Creates new document from file $file. - * Chainable. - * - * @param string $file URLs allowed. See File wrapper page at php.net for more supported sources. - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentFile($file, $contentType = null) - { - $documentID = self::createDocumentWrapper( - file_get_contents($file), - $contentType - ); - return new phpQueryObject($documentID); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentFileHTML($file, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocumentFile($file, "text/html{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentFileXML($file, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocumentFile($file, "text/xml{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentFileXHTML($file, $charset = null) - { - $contentType = $charset - ? ";charset=$charset" - : ''; - return self::newDocumentFile($file, "application/xhtml+xml{$contentType}"); - } - /** - * Creates new document from markup. - * Chainable. - * - * @param unknown_type $markup - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - */ - public static function newDocumentFilePHP($file, $contentType = null) - { - return self::newDocumentPHP(file_get_contents($file), $contentType); - } - /** - * Reuses existing DOMDocument object. - * Chainable. - * - * @param $document DOMDocument - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @TODO support DOMDocument - */ - public static function loadDocument($document) - { - // TODO - die('TODO loadDocument'); - } - /** - * Enter description here... - * - * @param unknown_type $html - * @param unknown_type $domId - * @return unknown New DOM ID - * @todo support PHP tags in input - * @todo support passing DOMDocument object from self::loadDocument - */ - protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) - { - if (function_exists('domxml_open_mem')) - throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled."); - // $id = $documentID - // ? $documentID - // : md5(microtime()); - $document = null; - if ($html instanceof DOMDOCUMENT) { - if (self::getDocumentID($html)) { - // document already exists in phpQuery::$documents, make a copy - $document = clone $html; - } else { - // new document, add it to phpQuery::$documents - $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); - } - } else { - $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); - } - // $wrapper->id = $id; - // bind document - phpQuery::$documents[$wrapper->id] = $wrapper; - // remember last loaded document - phpQuery::selectDocument($wrapper->id); - return $wrapper->id; - } - /** - * Extend class namespace. - * - * @param string|array $target - * @param array $source - * @TODO support string $source - * @return unknown_type - */ - public static function extend($target, $source) - { - switch ($target) { - case 'phpQueryObject': - $targetRef = &self::$extendMethods; - $targetRef2 = &self::$pluginsMethods; - break; - case 'phpQuery': - $targetRef = &self::$extendStaticMethods; - $targetRef2 = &self::$pluginsStaticMethods; - break; - default: - throw new Exception("Unsupported \$target type"); - } - if (is_string($source)) - $source = array($source => $source); - foreach ($source as $method => $callback) { - if (isset($targetRef[$method])) { - // throw new Exception - self::debug("Duplicate method '{$method}', can\'t extend '{$target}'"); - continue; - } - if (isset($targetRef2[$method])) { - // throw new Exception - self::debug("Duplicate method '{$method}' from plugin '{$targetRef2[$method]}'," - . " can\'t extend '{$target}'"); - continue; - } - $targetRef[$method] = $callback; - } - return true; - } - /** - * Extend phpQuery with $class from $file. - * - * @param string $class Extending class name. Real class name can be prepended phpQuery_. - * @param string $file Filename to include. Defaults to "{$class}.php". - */ - public static function plugin($class, $file = null) - { - // TODO $class checked agains phpQuery_$class - // if (strpos($class, 'phpQuery') === 0) - // $class = substr($class, 8); - if (in_array($class, self::$pluginsLoaded)) - return true; - if (!$file) - $file = $class . '.php'; - $objectClassExists = class_exists('phpQueryObjectPlugin_' . $class); - $staticClassExists = class_exists('phpQueryPlugin_' . $class); - if (!$objectClassExists && !$staticClassExists) - require_once($file); - self::$pluginsLoaded[] = $class; - // static methods - if (class_exists('phpQueryPlugin_' . $class)) { - $realClass = 'phpQueryPlugin_' . $class; - $vars = get_class_vars($realClass); - $loop = isset($vars['phpQueryMethods']) - && !is_null($vars['phpQueryMethods']) - ? $vars['phpQueryMethods'] - : get_class_methods($realClass); - foreach ($loop as $method) { - if ($method == '__initialize') - continue; - if (!is_callable(array($realClass, $method))) - continue; - if (isset(self::$pluginsStaticMethods[$method])) { - throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '" . self::$pluginsStaticMethods[$method] . "'"); - return; - } - self::$pluginsStaticMethods[$method] = $class; - } - if (method_exists($realClass, '__initialize')) - call_user_func_array(array($realClass, '__initialize'), array()); - } - // object methods - if (class_exists('phpQueryObjectPlugin_' . $class)) { - $realClass = 'phpQueryObjectPlugin_' . $class; - $vars = get_class_vars($realClass); - $loop = isset($vars['phpQueryMethods']) - && !is_null($vars['phpQueryMethods']) - ? $vars['phpQueryMethods'] - : get_class_methods($realClass); - foreach ($loop as $method) { - if (!is_callable(array($realClass, $method))) - continue; - if (isset(self::$pluginsMethods[$method])) { - throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '" . self::$pluginsMethods[$method] . "'"); - continue; - } - self::$pluginsMethods[$method] = $class; - } - } - return true; - } - /** - * Unloades all or specified document from memory. - * - * @param mixed $documentID @see phpQuery::getDocumentID() for supported types. - */ - public static function unloadDocuments($id = null) - { - if (isset($id)) { - if ($id = self::getDocumentID($id)) - unset(phpQuery::$documents[$id]); - } else { - foreach (phpQuery::$documents as $k => $v) { - unset(phpQuery::$documents[$k]); - } - } - } - /** - * Parses phpQuery object or HTML result against PHP tags and makes them active. - * - * @param phpQuery|string $content - * @deprecated - * @return string - */ - public static function unsafePHPTags($content) - { - return self::markupToPHP($content); - } - public static function DOMNodeListToArray($DOMNodeList) - { - $array = array(); - if (!$DOMNodeList) - return $array; - foreach ($DOMNodeList as $node) - $array[] = $node; - return $array; - } - /** - * Checks if $input is HTML string, which has to start with '<'. - * - * @deprecated - * @param String $input - * @return Bool - * @todo still used ? - */ - public static function isMarkup($input) - { - return !is_array($input) && substr(trim($input), 0, 1) == '<'; - } - public static function debug($text) - { - if (self::$debug) - print var_dump($text); - } - /** - * Make an AJAX request. - * - * @param array See $options http://docs.jquery.com/Ajax/jQuery.ajax#toptions - * Additional options are: - * 'document' - document for global events, @see phpQuery::getDocumentID() - * 'referer' - implemented - * 'requested_with' - TODO; not implemented (X-Requested-With) - * @return Zend_Http_Client - * @link http://docs.jquery.com/Ajax/jQuery.ajax - * - * @TODO $options['cache'] - * @TODO $options['processData'] - * @TODO $options['xhr'] - * @TODO $options['data'] as string - * @TODO XHR interface - */ - public static function ajax($options = array(), $xhr = null) - { - $options = array_merge( - self::$ajaxSettings, - $options - ); - $documentID = isset($options['document']) - ? self::getDocumentID($options['document']) - : null; - if ($xhr) { - // reuse existing XHR object, but clean it up - $client = $xhr; - // $client->setParameterPost(null); - // $client->setParameterGet(null); - $client->setAuth(false); - $client->setHeaders("If-Modified-Since", null); - $client->setHeaders("Referer", null); - $client->resetParameters(); - } else { - // create new XHR object - require_once('Zend/Http/Client.php'); - $client = new Zend_Http_Client(); - $client->setCookieJar(); - } - if (isset($options['timeout'])) - $client->setConfig(array( - 'timeout' => $options['timeout'], - )); - // 'maxredirects' => 0, - foreach (self::$ajaxAllowedHosts as $k => $host) - if ($host == '.' && isset($_SERVER['HTTP_HOST'])) - self::$ajaxAllowedHosts[$k] = $_SERVER['HTTP_HOST']; - $host = parse_url($options['url'], PHP_URL_HOST); - if (!in_array($host, self::$ajaxAllowedHosts)) { - throw new Exception("Request not permitted, host '$host' not present in " - . "phpQuery::\$ajaxAllowedHosts"); - } - // JSONP - $jsre = "/=\\?(&|$)/"; - if (isset($options['dataType']) && $options['dataType'] == 'jsonp') { - $jsonpCallbackParam = $options['jsonp'] - ? $options['jsonp'] : 'callback'; - if (strtolower($options['type']) == 'get') { - if (!preg_match($jsre, $options['url'])) { - $sep = strpos($options['url'], '?') - ? '&' : '?'; - $options['url'] .= "$sep$jsonpCallbackParam=?"; - } - } else if ($options['data']) { - $jsonp = false; - foreach ($options['data'] as $n => $v) { - if ($v == '?') - $jsonp = true; - } - if (!$jsonp) { - $options['data'][$jsonpCallbackParam] = '?'; - } - } - $options['dataType'] = 'json'; - } - if (isset($options['dataType']) && $options['dataType'] == 'json') { - $jsonpCallback = 'json_' . md5(microtime()); - $jsonpData = $jsonpUrl = false; - if ($options['data']) { - foreach ($options['data'] as $n => $v) { - if ($v == '?') - $jsonpData = $n; - } - } - if (preg_match($jsre, $options['url'])) - $jsonpUrl = true; - if ($jsonpData !== false || $jsonpUrl) { - // remember callback name for httpData() - $options['_jsonp'] = $jsonpCallback; - if ($jsonpData !== false) - $options['data'][$jsonpData] = $jsonpCallback; - if ($jsonpUrl) - $options['url'] = preg_replace($jsre, "=$jsonpCallback\\1", $options['url']); - } - } - $client->setUri($options['url']); - $client->setMethod(strtoupper($options['type'])); - if (isset($options['referer']) && $options['referer']) - $client->setHeaders('Referer', $options['referer']); - $client->setHeaders(array( - // 'content-type' => $options['contentType'], - 'User-Agent' => 'Mozilla/5.0 (X11; U; Linux x86; en-US; rv:1.9.0.5) Gecko' - . '/2008122010 Firefox/3.0.5', - // TODO custom charset - 'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - // 'Connection' => 'keep-alive', - // 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'Accept-Language' => 'en-us,en;q=0.5', - )); - if ($options['username']) - $client->setAuth($options['username'], $options['password']); - if (isset($options['ifModified']) && $options['ifModified']) - $client->setHeaders( - "If-Modified-Since", - self::$lastModified - ? self::$lastModified - : "Thu, 01 Jan 1970 00:00:00 GMT" - ); - $client->setHeaders( - "Accept", - isset($options['dataType']) - && isset(self::$ajaxSettings['accepts'][$options['dataType']]) - ? self::$ajaxSettings['accepts'][$options['dataType']] . ", */*" - : self::$ajaxSettings['accepts']['_default'] - ); - // TODO $options['processData'] - if ($options['data'] instanceof phpQueryObject) { - $serialized = $options['data']->serializeArray($options['data']); - $options['data'] = array(); - foreach ($serialized as $r) - $options['data'][$r['name']] = $r['value']; - } - if (strtolower($options['type']) == 'get') { - $client->setParameterGet($options['data']); - } else if (strtolower($options['type']) == 'post') { - $client->setEncType($options['contentType']); - $client->setParameterPost($options['data']); - } - if (self::$active == 0 && $options['global']) - phpQueryEvents::trigger($documentID, 'ajaxStart'); - self::$active++; - // beforeSend callback - if (isset($options['beforeSend']) && $options['beforeSend']) - phpQuery::callbackRun($options['beforeSend'], array($client)); - // ajaxSend event - if ($options['global']) - phpQueryEvents::trigger($documentID, 'ajaxSend', array($client, $options)); - if (phpQuery::$debug) { - self::debug("{$options['type']}: {$options['url']}\n"); - self::debug("Options:
" . var_export($options, true) . "
\n"); - // if ($client->getCookieJar()) - // self::debug("Cookies:
".var_export($client->getCookieJar()->getMatchingCookies($options['url']), true)."
\n"); - } - // request - $response = $client->request(); - if (phpQuery::$debug) { - self::debug('Status: ' . $response->getStatus() . ' / ' . $response->getMessage()); - self::debug($client->getLastRequest()); - self::debug($response->getHeaders()); - } - if ($response->isSuccessful()) { - // XXX tempolary - self::$lastModified = $response->getHeader('Last-Modified'); - $data = self::httpData($response->getBody(), $options['dataType'], $options); - if (isset($options['success']) && $options['success']) - phpQuery::callbackRun($options['success'], array($data, $response->getStatus(), $options)); - if ($options['global']) - phpQueryEvents::trigger($documentID, 'ajaxSuccess', array($client, $options)); - } else { - if (isset($options['error']) && $options['error']) - phpQuery::callbackRun($options['error'], array($client, $response->getStatus(), $response->getMessage())); - if ($options['global']) - phpQueryEvents::trigger($documentID, 'ajaxError', array($client, /*$response->getStatus(),*/ $response->getMessage(), $options)); - } - if (isset($options['complete']) && $options['complete']) - phpQuery::callbackRun($options['complete'], array($client, $response->getStatus())); - if ($options['global']) - phpQueryEvents::trigger($documentID, 'ajaxComplete', array($client, $options)); - if ($options['global'] && !--self::$active) - phpQueryEvents::trigger($documentID, 'ajaxStop'); - return $client; - // if (is_null($domId)) - // $domId = self::$defaultDocumentID ? self::$defaultDocumentID : false; - // return new phpQueryAjaxResponse($response, $domId); - } - protected static function httpData($data, $type, $options) - { - if (isset($options['dataFilter']) && $options['dataFilter']) - $data = self::callbackRun($options['dataFilter'], array($data, $type)); - if (is_string($data)) { - if ($type == "json") { - if (isset($options['_jsonp']) && $options['_jsonp']) { - $data = preg_replace('/^\s*\w+\((.*)\)\s*$/s', '$1', $data); - } - $data = self::parseJSON($data); - } - } - return $data; - } - /** - * Enter description here... - * - * @param array|phpQuery $data - * - */ - public static function param($data) - { - return http_build_query($data, null, '&'); - } - public static function get($url, $data = null, $callback = null, $type = null) - { - if (!is_array($data)) { - $callback = $data; - $data = null; - } - // TODO some array_values on this shit - return phpQuery::ajax(array( - 'type' => 'GET', - 'url' => $url, - 'data' => $data, - 'success' => $callback, - 'dataType' => $type, - )); - } - public static function post($url, $data = null, $callback = null, $type = null) - { - if (!is_array($data)) { - $callback = $data; - $data = null; - } - return phpQuery::ajax(array( - 'type' => 'POST', - 'url' => $url, - 'data' => $data, - 'success' => $callback, - 'dataType' => $type, - )); - } - public static function getJSON($url, $data = null, $callback = null) - { - if (!is_array($data)) { - $callback = $data; - $data = null; - } - // TODO some array_values on this shit - return phpQuery::ajax(array( - 'type' => 'GET', - 'url' => $url, - 'data' => $data, - 'success' => $callback, - 'dataType' => 'json', - )); - } - public static function ajaxSetup($options) - { - self::$ajaxSettings = array_merge( - self::$ajaxSettings, - $options - ); - } - public static function ajaxAllowHost($host1, $host2 = null, $host3 = null) - { - $loop = is_array($host1) - ? $host1 - : func_get_args(); - foreach ($loop as $host) { - if ($host && !in_array($host, phpQuery::$ajaxAllowedHosts)) { - phpQuery::$ajaxAllowedHosts[] = $host; - } - } - } - public static function ajaxAllowURL($url1, $url2 = null, $url3 = null) - { - $loop = is_array($url1) - ? $url1 - : func_get_args(); - foreach ($loop as $url) - phpQuery::ajaxAllowHost(parse_url($url, PHP_URL_HOST)); - } - /** - * Returns JSON representation of $data. - * - * @static - * @param mixed $data - * @return string - */ - public static function toJSON($data) - { - if (function_exists('json_encode')) - return json_encode($data); - require_once('Zend/Json/Encoder.php'); - return Zend_Json_Encoder::encode($data); - } - /** - * Parses JSON into proper PHP type. - * - * @static - * @param string $json - * @return mixed - */ - public static function parseJSON($json) - { - if (function_exists('json_decode')) { - $return = json_decode(trim($json), true); - // json_decode and UTF8 issues - if (isset($return)) - return $return; - } - require_once('Zend/Json/Decoder.php'); - return Zend_Json_Decoder::decode($json); - } - /** - * Returns source's document ID. - * - * @param $source DOMNode|phpQueryObject - * @return string - */ - public static function getDocumentID($source) - { - if ($source instanceof DOMDOCUMENT) { - foreach (phpQuery::$documents as $id => $document) { - if ($source->isSameNode($document->document)) - return $id; - } - } else if ($source instanceof DOMNODE) { - foreach (phpQuery::$documents as $id => $document) { - if ($source->ownerDocument->isSameNode($document->document)) - return $id; - } - } else if ($source instanceof phpQueryObject) - return $source->getDocumentID(); - else if (is_string($source) && isset(phpQuery::$documents[$source])) - return $source; - } - /** - * Get DOMDocument object related to $source. - * Returns null if such document doesn't exist. - * - * @param $source DOMNode|phpQueryObject|string - * @return string - */ - public static function getDOMDocument($source) - { - if ($source instanceof DOMDOCUMENT) - return $source; - $source = self::getDocumentID($source); - return $source - ? self::$documents[$id]['document'] - : null; - } - - // UTILITIES - // http://docs.jquery.com/Utilities - - /** - * - * @return unknown_type - * @link http://docs.jquery.com/Utilities/jQuery.makeArray - */ - public static function makeArray($obj) - { - $array = array(); - if (is_object($object) && $object instanceof DOMNODELIST) { - foreach ($object as $value) - $array[] = $value; - } else if (is_object($object) && !($object instanceof Iterator)) { - foreach (get_object_vars($object) as $name => $value) - $array[0][$name] = $value; - } else { - foreach ($object as $name => $value) - $array[0][$name] = $value; - } - return $array; - } - public static function inArray($value, $array) - { - return in_array($value, $array); - } - /** - * - * @param $object - * @param $callback - * @return unknown_type - * @link http://docs.jquery.com/Utilities/jQuery.each - */ - public static function each($object, $callback, $param1 = null, $param2 = null, $param3 = null) - { - $paramStructure = null; - if (func_num_args() > 2) { - $paramStructure = func_get_args(); - $paramStructure = array_slice($paramStructure, 2); - } - if (is_object($object) && !($object instanceof Iterator)) { - foreach (get_object_vars($object) as $name => $value) - phpQuery::callbackRun($callback, array($name, $value), $paramStructure); - } else { - foreach ($object as $name => $value) - phpQuery::callbackRun($callback, array($name, $value), $paramStructure); - } - } - /** - * - * @link http://docs.jquery.com/Utilities/jQuery.map - */ - public static function map($array, $callback, $param1 = null, $param2 = null, $param3 = null) - { - $result = array(); - $paramStructure = null; - if (func_num_args() > 2) { - $paramStructure = func_get_args(); - $paramStructure = array_slice($paramStructure, 2); - } - foreach ($array as $v) { - $vv = phpQuery::callbackRun($callback, array($v), $paramStructure); - // $callbackArgs = $args; - // foreach($args as $i => $arg) { - // $callbackArgs[$i] = $arg instanceof CallbackParam - // ? $v - // : $arg; - // } - // $vv = call_user_func_array($callback, $callbackArgs); - if (is_array($vv)) { - foreach ($vv as $vvv) - $result[] = $vvv; - } else if ($vv !== null) { - $result[] = $vv; - } - } - return $result; - } - /** - * - * @param $callback Callback - * @param $params - * @param $paramStructure - * @return unknown_type - */ - public static function callbackRun($callback, $params = array(), $paramStructure = null) - { - if (!$callback) - return; - if ($callback instanceof CallbackParameterToReference) { - // TODO support ParamStructure to select which $param push to reference - if (isset($params[0])) - $callback->callback = $params[0]; - return true; - } - if ($callback instanceof Callback) { - $paramStructure = $callback->params; - $callback = $callback->callback; - } - if (!$paramStructure) - return call_user_func_array($callback, $params); - $p = 0; - foreach ($paramStructure as $i => $v) { - $paramStructure[$i] = $v instanceof CallbackParam - ? $params[$p++] - : $v; - } - return call_user_func_array($callback, $paramStructure); - } - /** - * Merge 2 phpQuery objects. - * @param array $one - * @param array $two - * @protected - * @todo node lists, phpQueryObject - */ - public static function merge($one, $two) - { - $elements = $one->elements; - foreach ($two->elements as $node) { - $exists = false; - foreach ($elements as $node2) { - if ($node2->isSameNode($node)) - $exists = true; - } - if (!$exists) - $elements[] = $node; - } - return $elements; - // $one = $one->newInstance(); - // $one->elements = $elements; - // return $one; - } - /** - * - * @param $array - * @param $callback - * @param $invert - * @return unknown_type - * @link http://docs.jquery.com/Utilities/jQuery.grep - */ - public static function grep($array, $callback, $invert = false) - { - $result = array(); - foreach ($array as $k => $v) { - $r = call_user_func_array($callback, array($v, $k)); - if ($r === !(bool)$invert) - $result[] = $v; - } - return $result; - } - public static function unique($array) - { - return array_unique($array); - } - /** - * - * @param $function - * @return unknown_type - * @TODO there are problems with non-static methods, second parameter pass it - * but doesnt verify is method is really callable - */ - public static function isFunction($function) - { - return is_callable($function); - } - public static function trim($str) - { - return trim($str); - } - /* PLUGINS NAMESPACE */ - /** - * - * @param $url - * @param $callback - * @param $param1 - * @param $param2 - * @param $param3 - * @return phpQueryObject - */ - public static function browserGet($url, $callback, $param1 = null, $param2 = null, $param3 = null) - { - if (self::plugin('WebBrowser')) { - $params = func_get_args(); - return self::callbackRun(array(self::$plugins, 'browserGet'), $params); - } else { - self::debug('WebBrowser plugin not available...'); - } - } - /** - * - * @param $url - * @param $data - * @param $callback - * @param $param1 - * @param $param2 - * @param $param3 - * @return phpQueryObject - */ - public static function browserPost($url, $data, $callback, $param1 = null, $param2 = null, $param3 = null) - { - if (self::plugin('WebBrowser')) { - $params = func_get_args(); - return self::callbackRun(array(self::$plugins, 'browserPost'), $params); - } else { - self::debug('WebBrowser plugin not available...'); - } - } - /** - * - * @param $ajaxSettings - * @param $callback - * @param $param1 - * @param $param2 - * @param $param3 - * @return phpQueryObject - */ - public static function browser($ajaxSettings, $callback, $param1 = null, $param2 = null, $param3 = null) - { - if (self::plugin('WebBrowser')) { - $params = func_get_args(); - return self::callbackRun(array(self::$plugins, 'browser'), $params); - } else { - self::debug('WebBrowser plugin not available...'); - } - } - /** - * - * @param $code - * @return string - */ - public static function php($code) - { - return self::code('php', $code); - } - /** - * - * @param $type - * @param $code - * @return string - */ - public static function code($type, $code) - { - return "<$type>"; - } - - public static function __callStatic($method, $params) - { - return call_user_func_array( - array(phpQuery::$plugins, $method), - $params - ); - } - protected static function dataSetupNode($node, $documentID) - { - // search are return if alredy exists - foreach (phpQuery::$documents[$documentID]->dataNodes as $dataNode) { - if ($node->isSameNode($dataNode)) - return $dataNode; - } - // if doesn't, add it - phpQuery::$documents[$documentID]->dataNodes[] = $node; - return $node; - } - protected static function dataRemoveNode($node, $documentID) - { - // search are return if alredy exists - foreach (phpQuery::$documents[$documentID]->dataNodes as $k => $dataNode) { - if ($node->isSameNode($dataNode)) { - unset(self::$documents[$documentID]->dataNodes[$k]); - unset(self::$documents[$documentID]->data[$dataNode->dataID]); - } - } - } - public static function data($node, $name, $data, $documentID = null) - { - if (!$documentID) - // TODO check if this works - $documentID = self::getDocumentID($node); - $document = phpQuery::$documents[$documentID]; - $node = self::dataSetupNode($node, $documentID); - if (!isset($node->dataID)) - $node->dataID = ++phpQuery::$documents[$documentID]->uuid; - $id = $node->dataID; - if (!isset($document->data[$id])) - $document->data[$id] = array(); - if (!is_null($data)) - $document->data[$id][$name] = $data; - if ($name) { - if (isset($document->data[$id][$name])) - return $document->data[$id][$name]; - } else - return $id; - } - public static function removeData($node, $name, $documentID) - { - if (!$documentID) - // TODO check if this works - $documentID = self::getDocumentID($node); - $document = phpQuery::$documents[$documentID]; - $node = self::dataSetupNode($node, $documentID); - $id = $node->dataID; - if ($name) { - if (isset($document->data[$id][$name])) - unset($document->data[$id][$name]); - $name = null; - foreach ($document->data[$id] as $name) - break; - if (!$name) - self::removeData($node, $name, $documentID); - } else { - self::dataRemoveNode($node, $documentID); - } - } -} -/** - * Plugins static namespace class. - * - * @author Tobiasz Cudnik - * @package phpQuery - * @todo move plugin methods here (as statics) - */ -class phpQueryPlugins -{ - public function __call($method, $args) - { - if (isset(phpQuery::$extendStaticMethods[$method])) { - $return = call_user_func_array( - phpQuery::$extendStaticMethods[$method], - $args - ); - } else if (isset(phpQuery::$pluginsStaticMethods[$method])) { - $class = phpQuery::$pluginsStaticMethods[$method]; - $realClass = "phpQueryPlugin_$class"; - $return = call_user_func_array( - array($realClass, $method), - $args - ); - return isset($return) - ? $return - : $this; - } else - throw new Exception("Method '{$method}' doesnt exist"); - } -} -/** - * Shortcut to phpQuery::pq($arg1, $context) - * Chainable. - * - * @see phpQuery::pq() - * @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery - * @author Tobiasz Cudnik - * @package phpQuery - */ -function pq($arg1, $context = null) -{ - $args = func_get_args(); - return call_user_func_array( - array('phpQuery', 'pq'), - $args - ); -} -// add plugins dir and Zend framework to include path -set_include_path( - get_include_path() - . PATH_SEPARATOR . dirname(__FILE__) . '/phpQuery/' - . PATH_SEPARATOR . dirname(__FILE__) . '/phpQuery/plugins/' -); -// why ? no __call nor __get for statics in php... -// XXX __callStatic will be available in PHP 5.3 -phpQuery::$plugins = new phpQueryPlugins(); -// include bootstrap file (personal library config) -if (file_exists(dirname(__FILE__) . '/phpQuery/bootstrap.php')) - require_once dirname(__FILE__) . '/phpQuery/bootstrap.php'; diff --git a/vendor/jaeger/querylist/.github/FUNDING.yml b/vendor/jaeger/querylist/.github/FUNDING.yml deleted file mode 100644 index c53fd16..0000000 --- a/vendor/jaeger/querylist/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: querylist # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/vendor/jaeger/querylist/.gitignore b/vendor/jaeger/querylist/.gitignore deleted file mode 100644 index e2ee195..0000000 --- a/vendor/jaeger/querylist/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/vendor/ -.idea/ -composer.lock -.DS_Store -*.cache \ No newline at end of file diff --git a/vendor/jaeger/querylist/README-ZH.md b/vendor/jaeger/querylist/README-ZH.md deleted file mode 100644 index ec34971..0000000 --- a/vendor/jaeger/querylist/README-ZH.md +++ /dev/null @@ -1,309 +0,0 @@ -

- QueryList -
-
-

- -# QueryList 简介 -`QueryList`是一套简洁、优雅、可扩展的PHP采集工具(爬虫),基于phpQuery。 - -## 特性 -- 拥有与jQuery完全相同的CSS3 DOM选择器 -- 拥有与jQuery完全相同的DOM操作API -- 拥有通用的列表采集方案 -- 拥有强大的HTTP请求套件,轻松实现如:模拟登陆、伪造浏览器、HTTP代理等意复杂的网络请求 -- 拥有乱码解决方案 -- 拥有强大的内容过滤功能,可使用jQuey选择器来过滤内容 -- 拥有高度的模块化设计,扩展性强 -- 拥有富有表现力的API -- 拥有高质量文档 -- 拥有丰富的插件 -- 拥有专业的问答社区和交流群 - -通过插件可以轻松实现诸如: -- 多线程采集 -- 采集JavaScript动态渲染的页面 (PhantomJS/headless WebKit) -- 图片本地化 -- 模拟浏览器行为,如:提交Form表单 -- 网络爬虫 -- ..... - -## 环境要求 -- PHP >= 7.1 - -> 如果你的PHP版本还停留在PHP5,或者不会使用Composer,你可以选择使用QueryList3,QueryList3支持php5.3以及手动安装。 -QueryList3 文档:http://v3.querylist.cc - -## 安装 -通过Composer安装: -``` -composer require jaeger/querylist -``` - -## 使用 - -#### 元素操作 -- 采集「昵图网」所有图片地址 - -```php -QueryList::get('http://www.nipic.com')->find('img')->attrs('src'); -``` -- 采集百度搜索结果 - -```php -$ql = QueryList::get('http://www.baidu.com/s?wd=QueryList'); - -$ql->find('title')->text(); // 获取网站标题 -$ql->find('meta[name=keywords]')->content; // 获取网站头部关键词 - -$ql->find('h3>a')->texts(); //获取搜索结果标题列表 -$ql->find('h3>a')->attrs('href'); //获取搜索结果链接列表 - -$ql->find('img')->src; //获取第一张图片的链接地址 -$ql->find('img:eq(1)')->src; //获取第二张图片的链接地址 -$ql->find('img')->eq(2)->src; //获取第三张图片的链接地址 -// 遍历所有图片 -$ql->find('img')->map(function($img){ - echo $img->alt; //打印图片的alt属性 -}); -``` -- 更多用法 - -```php -$ql->find('#head')->append('
追加内容
')->find('div')->htmls(); -$ql->find('.two')->children('img')->attrs('alt'); //获取class为two元素下的所有img孩子节点 -//遍历class为two元素下的所有孩子节点 -$data = $ql->find('.two')->children()->map(function ($item){ - //用is判断节点类型 - if($item->is('a')){ - return $item->text(); - }elseif($item->is('img')) - { - return $item->alt; - } -}); - -$ql->find('a')->attr('href', 'newVal')->removeClass('className')->html('newHtml')->... -$ql->find('div > p')->add('div > ul')->filter(':has(a)')->find('p:first')->nextAll()->andSelf()->... -$ql->find('div.old')->replaceWith( $ql->find('div.new')->clone())->appendTo('.trash')->prepend('Deleted')->... -``` -#### 列表采集 -采集百度搜索结果列表的标题和链接: -```php -$data = QueryList::get('http://www.baidu.com/s?wd=QueryList') - // 设置采集规则 - ->rules([ - 'title'=>array('h3','text'), - 'link'=>array('h3>a','href') - ]) - ->query()->getData(); - -print_r($data->all()); -``` -采集结果: -``` -Array -( - [0] => Array - ( - [title] => QueryList|基于phpQuery的无比强大的PHP采集工具 - [link] => http://www.baidu.com/link?url=GU_YbDT2IHk4ns1tjG2I8_vjmH0SCJEAPuuZN - ) - [1] => Array - ( - [title] => PHP 用QueryList抓取网页内容 - wb145230 - 博客园 - [link] => http://www.baidu.com/link?url=zn0DXBnrvIF2ibRVW34KcRVFG1_bCdZvqvwIhUqiXaS - ) - [2] => Array - ( - [title] => 介绍- QueryList指导文档 - [link] => http://www.baidu.com/link?url=pSypvMovqS4v2sWeQo5fDBJ4EoYhXYi0Lxx - ) - //... -) -``` -#### 编码转换 -```php -// 输出编码:UTF-8,输入编码:GB2312 -QueryList::get('https://top.etao.com')->encoding('UTF-8','GB2312')->find('a')->texts(); - -// 输出编码:UTF-8,输入编码:自动识别 -QueryList::get('https://top.etao.com')->encoding('UTF-8')->find('a')->texts(); -``` - -#### HTTP网络操作(GuzzleHttp) -- 携带cookie登录新浪微博 -```php -//采集新浪微博需要登录才能访问的页面 -$ql = QueryList::get('http://weibo.com','param1=testvalue & params2=somevalue',[ - 'headers' => [ - //填写从浏览器获取到的cookie - 'Cookie' => 'SINAGLOBAL=546064; wb_cmtLike_2112031=1; wvr=6;....' - ] -]); -//echo $ql->getHtml(); -echo $ql->find('title')->text(); -//输出: 我的首页 微博-随时随地发现新鲜事 -``` -- 使用Http代理 -```php -$urlParams = ['param1' => 'testvalue','params2' => 'somevalue']; -$opts = [ - // 设置http代理 - 'proxy' => 'http://222.141.11.17:8118', - //设置超时时间,单位:秒 - 'timeout' => 30, - // 伪造http头 - 'headers' => [ - 'Referer' => 'https://querylist.cc/', - 'User-Agent' => 'testing/1.0', - 'Accept' => 'application/json', - 'X-Foo' => ['Bar', 'Baz'], - 'Cookie' => 'abc=111;xxx=222' - ] -]; -$ql->get('http://httpbin.org/get',$urlParams,$opts); -// echo $ql->getHtml(); -``` - -- 模拟登录 -```php -// 用post登录 -$ql = QueryList::post('http://xxxx.com/login',[ - 'username' => 'admin', - 'password' => '123456' -])->get('http://xxx.com/admin'); -//采集需要登录才能访问的页面 -$ql->get('http://xxx.com/admin/page'); -//echo $ql->getHtml(); -``` - -#### Form表单操作 -模拟登陆GitHub -```php -// 获取QueryList实例 -$ql = QueryList::getInstance(); -//获取到登录表单 -$form = $ql->get('https://github.com/login')->find('form'); - -//填写GitHub用户名和密码 -$form->find('input[name=login]')->val('your github username or email'); -$form->find('input[name=password]')->val('your github password'); - -//序列化表单数据 -$fromData = $form->serializeArray(); -$postData = []; -foreach ($fromData as $item) { - $postData[$item['name']] = $item['value']; -} - -//提交登录表单 -$actionUrl = 'https://github.com'.$form->attr('action'); -$ql->post($actionUrl,$postData); -//判断登录是否成功 -// echo $ql->getHtml(); -$userName = $ql->find('.header-nav-current-user>.css-truncate-target')->text(); -if($userName) -{ - echo '登录成功!欢迎你:'.$userName; -}else{ - echo '登录失败!'; -} -``` -#### Bind功能扩展 -自定义扩展一个`myHttp`方法: -```php -$ql = QueryList::getInstance(); - -//绑定一个myHttp方法到QueryList对象 -$ql->bind('myHttp',function ($url){ - // $this 为当前的QueryList对象 - $html = file_get_contents($url); - $this->setHtml($html); - return $this; -}); - -//然后就可以通过注册的名字来调用 -$data = $ql->myHttp('https://toutiao.io')->find('h3 a')->texts(); -print_r($data->all()); -``` -或者把实现体封装到class,然后这样绑定: -```php -$ql->bind('myHttp',function ($url){ - return new MyHttp($this,$url); -}); -``` - -#### 插件使用 -- 使用PhantomJS插件采集JavaScript动态渲染的页面: - -```php -// 安装时设置PhantomJS二进制文件路径 -$ql = QueryList::use(PhantomJs::class,'/usr/local/bin/phantomjs'); - -// 采集今日头条手机版 -$data = $ql->browser('https://m.toutiao.com')->find('p')->texts(); -print_r($data->all()); - -// 使用HTTP代理 -$ql->browser('https://m.toutiao.com',false,[ - '--proxy' => '192.168.1.42:8080', - '--proxy-type' => 'http' -]) -``` - -- 使用CURL多线程插件,多线程采集GitHub排行榜: - -```php -$ql = QueryList::use(CurlMulti::class); -$ql->curlMulti([ - 'https://github.com/trending/php', - 'https://github.com/trending/go', - //.....more urls -]) - // 每个任务成功完成调用此回调 - ->success(function (QueryList $ql,CurlMulti $curl,$r){ - echo "Current url:{$r['info']['url']} \r\n"; - $data = $ql->find('h3 a')->texts(); - print_r($data->all()); -}) - // 每个任务失败回调 -->error(function ($errorInfo,CurlMulti $curl){ - echo "Current url:{$errorInfo['info']['url']} \r\n"; - print_r($errorInfo['error']); -}) -->start([ - // 最大并发数 - 'maxThread' => 10, - // 错误重试次数 - 'maxTry' => 3, -]); - -``` - -## 插件 -- [jae-jae/QueryList-PhantomJS](https://github.com/jae-jae/QueryList-PhantomJS): 使用PhantomJS采集JavaScript动态渲染的页面 -- [jae-jae/QueryList-CurlMulti](https://github.com/jae-jae/QueryList-CurlMulti) : Curl多线程采集 -- [jae-jae/QueryList-AbsoluteUrl](https://github.com/jae-jae/QueryList-AbsoluteUrl) : 转换URL相对路径到绝对路径 -- [jae-jae/QueryList-Rule-Google](https://github.com/jae-jae/QueryList-Rule-Google) : 谷歌搜索引擎 -- [jae-jae/QueryList-Rule-Baidu](https://github.com/jae-jae/QueryList-Rule-Baidu) : 百度搜索引擎 - - -查看更多的QueryList插件和基于QueryList的产品:[QueryList社区力量](https://github.com/jae-jae/QueryList-Community) - -## 贡献 -欢迎为QueryList贡献代码。关于贡献插件可以查看:[QueryList插件贡献说明](https://github.com/jae-jae/QueryList-Community/blob/master/CONTRIBUTING.md) - -## 寻求帮助? -- QueryList主页: [http://querylist.cc](http://querylist.cc/) -- QueryList文档: [http://doc.querylist.cc](http://doc.querylist.cc/) -- QueryList问答:[http://wenda.querylist.cc](http://wenda.querylist.cc/) -- QueryList交流QQ群:123266961 cafeEX -- GitHub:https://github.com/jae-jae/QueryList -- Git@OSC:http://git.oschina.net/jae/QueryList - -## Author -Jaeger - -## Lisence -QueryList is licensed under the license of MIT. See the LICENSE for more details. diff --git a/vendor/jaeger/querylist/README.md b/vendor/jaeger/querylist/README.md deleted file mode 100644 index 5ec559f..0000000 --- a/vendor/jaeger/querylist/README.md +++ /dev/null @@ -1,304 +0,0 @@ -

- QueryList -
-
-

- -# QueryList -`QueryList` is a simple, elegant, extensible PHP Web Scraper (crawler/spider) ,based on phpQuery. - -[API Documentation](https://github.com/jae-jae/QueryList/wiki) - -[中文文档](README-ZH.md) - -## Features -- Have the same CSS3 DOM selector as jQuery -- Have the same DOM manipulation API as jQuery -- Have a generic list crawling program -- Have a strong HTTP request suite, easy to achieve such as: simulated landing, forged browser, HTTP proxy and other complex network requests -- Have a messy code solution -- Have powerful content filtering, you can use the jQuey selector to filter content -- Has a high degree of modular design, scalability and strong -- Have an expressive API -- Has a wealth of plug-ins - -Through plug-ins you can easily implement things like: -- Multithreaded crawl -- Crawl JavaScript dynamic rendering page (PhantomJS/headless WebKit) -- Image downloads to local -- Simulate browser behavior such as submitting Form forms -- Web crawler -- ..... - -## Requirements -- PHP >= 7.1 - -## Installation -By Composer installation: -``` -composer require jaeger/querylist -``` - -## Usage - -#### DOM Traversal and Manipulation -- Crawl「GitHub」all picture links - -```php -QueryList::get('https://github.com')->find('img')->attrs('src'); -``` -- Crawl Google search results - -```php -$ql = QueryList::get('https://www.google.co.jp/search?q=QueryList'); - -$ql->find('title')->text(); //The page title -$ql->find('meta[name=keywords]')->content; //The page keywords - -$ql->find('h3>a')->texts(); //Get a list of search results titles -$ql->find('h3>a')->attrs('href'); //Get a list of search results links - -$ql->find('img')->src; //Gets the link address of the first image -$ql->find('img:eq(1)')->src; //Gets the link address of the second image -$ql->find('img')->eq(2)->src; //Gets the link address of the third image -// Loop all the images -$ql->find('img')->map(function($img){ - echo $img->alt; //Print the alt attribute of the image -}); -``` -- More usage - -```php -$ql->find('#head')->append('
Append content
')->find('div')->htmls(); -$ql->find('.two')->children('img')->attrs('alt'); // Get the class is the "two" element under all img child nodes -// Loop class is the "two" element under all child nodes -$data = $ql->find('.two')->children()->map(function ($item){ - // Use "is" to determine the node type - if($item->is('a')){ - return $item->text(); - }elseif($item->is('img')) - { - return $item->alt; - } -}); - -$ql->find('a')->attr('href', 'newVal')->removeClass('className')->html('newHtml')->... -$ql->find('div > p')->add('div > ul')->filter(':has(a)')->find('p:first')->nextAll()->andSelf()->... -$ql->find('div.old')->replaceWith( $ql->find('div.new')->clone())->appendTo('.trash')->prepend('Deleted')->... -``` -#### List crawl -Crawl the title and link of the Google search results list: -```php -$data = QueryList::get('https://www.google.co.jp/search?q=QueryList') - // Set the crawl rules - ->rules([ - 'title'=>array('h3','text'), - 'link'=>array('h3>a','href') - ]) - ->query()->getData(); - -print_r($data->all()); -``` - Results: -``` -Array -( - [0] => Array - ( - [title] => Angular - QueryList - [link] => https://angular.io/api/core/QueryList - ) - [1] => Array - ( - [title] => QueryList | @angular/core - Angularリファレンス - Web Creative Park - [link] => http://www.webcreativepark.net/angular/querylist/ - ) - [2] => Array - ( - [title] => QueryListにQueryを追加したり、追加されたことを感知する | TIPS ... - [link] => http://www.webcreativepark.net/angular/querylist_query_add_subscribe/ - ) - //... -) -``` -#### Encode convert -```php -// Out charset :UTF-8 -// In charset :GB2312 -QueryList::get('https://top.etao.com')->encoding('UTF-8','GB2312')->find('a')->texts(); - -// Out charset:UTF-8 -// In charset:Automatic Identification -QueryList::get('https://top.etao.com')->encoding('UTF-8')->find('a')->texts(); -``` - -#### HTTP Client (GuzzleHttp) -- Carry cookie login GitHub -```php -//Crawl GitHub content -$ql = QueryList::get('https://github.com','param1=testvalue & params2=somevalue',[ - 'headers' => [ - // Fill in the cookie from the browser - 'Cookie' => 'SINAGLOBAL=546064; wb_cmtLike_2112031=1; wvr=6;....' - ] -]); -//echo $ql->getHtml(); -$userName = $ql->find('.header-nav-current-user>.css-truncate-target')->text(); -echo $userName; -``` -- Use the Http proxy -```php -$urlParams = ['param1' => 'testvalue','params2' => 'somevalue']; -$opts = [ - // Set the http proxy - 'proxy' => 'http://222.141.11.17:8118', - //Set the timeout time in seconds - 'timeout' => 30, - // Fake HTTP headers - 'headers' => [ - 'Referer' => 'https://querylist.cc/', - 'User-Agent' => 'testing/1.0', - 'Accept' => 'application/json', - 'X-Foo' => ['Bar', 'Baz'], - 'Cookie' => 'abc=111;xxx=222' - ] -]; -$ql->get('http://httpbin.org/get',$urlParams,$opts); -// echo $ql->getHtml(); -``` - -- Analog login -```php -// Post login -$ql = QueryList::post('http://xxxx.com/login',[ - 'username' => 'admin', - 'password' => '123456' -])->get('http://xxx.com/admin'); -// Crawl pages that need to be logged in to access -$ql->get('http://xxx.com/admin/page'); -//echo $ql->getHtml(); -``` - -#### Submit forms -Login GitHub -```php -// Get the QueryList instance -$ql = QueryList::getInstance(); -// Get the login form -$form = $ql->get('https://github.com/login')->find('form'); - -// Fill in the GitHub username and password -$form->find('input[name=login]')->val('your github username or email'); -$form->find('input[name=password]')->val('your github password'); - -// Serialize the form data -$fromData = $form->serializeArray(); -$postData = []; -foreach ($fromData as $item) { - $postData[$item['name']] = $item['value']; -} - -// Submit the login form -$actionUrl = 'https://github.com'.$form->attr('action'); -$ql->post($actionUrl,$postData); -// To determine whether the login is successful -// echo $ql->getHtml(); -$userName = $ql->find('.header-nav-current-user>.css-truncate-target')->text(); -if($userName) -{ - echo 'Login successful ! Welcome:'.$userName; -}else{ - echo 'Login failed !'; -} -``` -#### Bind function extension -Customize the extension of a `myHttp` method: -```php -$ql = QueryList::getInstance(); - -//Bind a `myHttp` method to the QueryList object -$ql->bind('myHttp',function ($url){ - // $this is the current QueryList object - $html = file_get_contents($url); - $this->setHtml($html); - return $this; -}); - -// And then you can call by the name of the binding -$data = $ql->myHttp('https://toutiao.io')->find('h3 a')->texts(); -print_r($data->all()); -``` -Or package to class, and then bind: -```php -$ql->bind('myHttp',function ($url){ - return new MyHttp($this,$url); -}); -``` - -#### Plugin used -- Use the PhantomJS plugin to crawl JavaScript dynamically rendered pages: - -```php -// Set the PhantomJS binary file path during installation -$ql = QueryList::use(PhantomJs::class,'/usr/local/bin/phantomjs'); - -// Crawl「500px」all picture links -$data = $ql->browser('https://500px.com/editors')->find('img')->attrs('src'); -print_r($data->all()); - -// Use the HTTP proxy -$ql->browser('https://500px.com/editors',false,[ - '--proxy' => '192.168.1.42:8080', - '--proxy-type' => 'http' -]) -``` - -- Using the CURL multithreading plug-in, multi-threaded crawling GitHub trending : - -```php -$ql = QueryList::use(CurlMulti::class); -$ql->curlMulti([ - 'https://github.com/trending/php', - 'https://github.com/trending/go', - //.....more urls -]) - // Called if task is success - ->success(function (QueryList $ql,CurlMulti $curl,$r){ - echo "Current url:{$r['info']['url']} \r\n"; - $data = $ql->find('h3 a')->texts(); - print_r($data->all()); -}) - // Task fail callback -->error(function ($errorInfo,CurlMulti $curl){ - echo "Current url:{$errorInfo['info']['url']} \r\n"; - print_r($errorInfo['error']); -}) -->start([ - // Maximum number of threads - 'maxThread' => 10, - // Number of error retries - 'maxTry' => 3, -]); - -``` - -## Plugins -- [jae-jae/QueryList-PhantomJS](https://github.com/jae-jae/QueryList-PhantomJS):Use PhantomJS to crawl Javascript dynamically rendered page. -- [jae-jae/QueryList-CurlMulti](https://github.com/jae-jae/QueryList-CurlMulti) : Curl multi threading. -- [jae-jae/QueryList-AbsoluteUrl](https://github.com/jae-jae/QueryList-AbsoluteUrl) : Converting relative urls to absolute. -- [jae-jae/QueryList-Rule-Google](https://github.com/jae-jae/QueryList-Rule-Google) : Google searcher. -- [jae-jae/QueryList-Rule-Baidu](https://github.com/jae-jae/QueryList-Rule-Baidu) : Baidu searcher. - - -View more QueryList plugins and QueryList-based products: [QueryList Community](https://github.com/jae-jae/QueryList-Community) - -## Contributing -Welcome to contribute code for the QueryList。About Contributing Plugins can be viewed:[QueryList Plugin Contributing Guide](https://github.com/jae-jae/QueryList-Community/blob/master/CONTRIBUTING.md) - -## Author -Jaeger - -If this library is useful for you, say thanks [buying me a beer :beer:](https://www.paypal.me/jaepay)! - -## Lisence -QueryList is licensed under the license of MIT. See the LICENSE for more details. diff --git a/vendor/jaeger/querylist/composer.json b/vendor/jaeger/querylist/composer.json deleted file mode 100644 index e1bcefe..0000000 --- a/vendor/jaeger/querylist/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "jaeger/querylist", - "description": "Simple, elegant, extensible PHP Web Scraper (crawler/spider),Use the css3 dom selector,Based on phpQuery! 简洁、优雅、可扩展的PHP采集工具(爬虫),基于phpQuery。", - "keywords":["QueryList","phpQuery","spider"], - "homepage": "http://querylist.cc", - "require": { - "PHP":">=7.1", - "jaeger/phpquery-single": "^1", - "jaeger/g-http": "^1.1", - "ext-dom": "*", - "tightenco/collect": ">5.0" - }, - "suggest":{ - - }, - "license": "MIT", - "authors": [ - { - "name": "Jaeger", - "email": "JaegerCode@gmail.com" - } - ], - "autoload":{ - "psr-4":{ - "QL\\":"src" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } - }, - "require-dev": { - "symfony/var-dumper": "^3.3", - "phpunit/phpunit": "^8.5" - }, - "scripts": { - "test": "./vendor/bin/phpunit" - } -} diff --git a/vendor/jaeger/querylist/logo.png b/vendor/jaeger/querylist/logo.png deleted file mode 100644 index a29b3e6..0000000 Binary files a/vendor/jaeger/querylist/logo.png and /dev/null differ diff --git a/vendor/jaeger/querylist/phpunit.xml b/vendor/jaeger/querylist/phpunit.xml deleted file mode 100644 index ba72a84..0000000 --- a/vendor/jaeger/querylist/phpunit.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - ./tests - - - - - - src - - - - \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Config.php b/vendor/jaeger/querylist/src/Config.php deleted file mode 100644 index b2ababb..0000000 --- a/vendor/jaeger/querylist/src/Config.php +++ /dev/null @@ -1,94 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL; -use Closure; -use Tightenco\Collect\Support\Collection; - -class Config -{ - protected static $instance = null; - - protected $plugins; - protected $binds; - - /** - * Config constructor. - */ - public function __construct() - { - $this->plugins = new Collection(); - $this->binds = new Collection(); - } - - - /** - * Get the Config instance - * - * @return null|Config - */ - public static function getInstance() - { - self::$instance || self::$instance = new self(); - return self::$instance; - } - - /** - * Global installation plugin - * - * @param $plugins - * @param array ...$opt - * @return $this - */ - public function use($plugins,...$opt) - { - if(is_string($plugins)){ - $this->plugins->push([$plugins,$opt]); - }else{ - $this->plugins = $this->plugins->merge($plugins); - } - return $this; - } - - /** - * Global binding custom method - * - * @param string $name - * @param Closure $provider - * @return $this - */ - public function bind(string $name, Closure $provider) - { - $this->binds[$name] = $provider; - return $this; - } - - public function bootstrap(QueryList $queryList) - { - $this->installPlugins($queryList); - $this->installBind($queryList); - } - - protected function installPlugins(QueryList $queryList) - { - $this->plugins->each(function($plugin) use($queryList){ - if(is_string($plugin)){ - $queryList->use($plugin); - }else{ - $queryList->use($plugin[0],...$plugin[1]); - } - }); - } - - protected function installBind(QueryList $queryList) - { - $this->binds->each(function ($provider,$name) use($queryList){ - $queryList->bind($name,$provider); - }); - } - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Contracts/PluginContract.php b/vendor/jaeger/querylist/src/Contracts/PluginContract.php deleted file mode 100644 index 8bbd498..0000000 --- a/vendor/jaeger/querylist/src/Contracts/PluginContract.php +++ /dev/null @@ -1,15 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Contracts; - -use QL\QueryList; - -interface PluginContract -{ - public static function install(QueryList $queryList,...$opt); -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Contracts/ServiceProviderContract.php b/vendor/jaeger/querylist/src/Contracts/ServiceProviderContract.php deleted file mode 100644 index 1bdf28b..0000000 --- a/vendor/jaeger/querylist/src/Contracts/ServiceProviderContract.php +++ /dev/null @@ -1,15 +0,0 @@ - - * Date: 2017/9/20 - */ - -namespace QL\Contracts; - -use QL\Kernel; - -interface ServiceProviderContract -{ - public function register(Kernel $kernel); -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Dom/Dom.php b/vendor/jaeger/querylist/src/Dom/Dom.php deleted file mode 100644 index 38f71a1..0000000 --- a/vendor/jaeger/querylist/src/Dom/Dom.php +++ /dev/null @@ -1,30 +0,0 @@ - - * Date: 2017/9/19 - */ - -namespace QL\Dom; - -use phpQueryObject; - -class Dom -{ - - protected $document; - - /** - * Dom constructor. - */ - public function __construct(phpQueryObject $document) - { - $this->document = $document; - } - - public function find($selector) - { - $elements = $this->document->find($selector); - return new Elements($elements); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Dom/Elements.php b/vendor/jaeger/querylist/src/Dom/Elements.php deleted file mode 100644 index 943e3ce..0000000 --- a/vendor/jaeger/querylist/src/Dom/Elements.php +++ /dev/null @@ -1,260 +0,0 @@ - - * Date: 2017/9/19 - */ - -namespace QL\Dom; - -use phpDocumentor\Reflection\Types\Null_; -use phpQueryObject; -use Tightenco\Collect\Support\Collection; - -/** - * Class Elements - * @package QL\Dom - * - * @method Elements toReference(&$var) - * @method Elements documentFragment($state = null) - * @method Elements toRoot() - * @method Elements getDocumentIDRef(&$documentID) - * @method Elements getDocument() - * @method \DOMDocument getDOMDocument() - * @method Elements getDocumentID() - * @method Elements unloadDocument() - * @method bool isHTML() - * @method bool isXHTML() - * @method bool isXML() - * @method string serialize() - * @method array serializeArray($submit = null) - * @method \DOMElement|\DOMElement[] get($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method string|array getString($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method string|array getStrings($index = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method Elements newInstance($newStack = null) - * @method Elements find($selectors, $context = null, $noHistory = false) - * @method Elements|bool is($selector, $nodes = null) - * @method Elements filterCallback($callback, $_skipHistory = false) - * @method Elements filter($selectors, $_skipHistory = false) - * @method Elements load($url, $data = null, $callback = null) - * @method Elements trigger($type, $data = []) - * @method Elements triggerHandler($type, $data = []) - * @method Elements bind($type, $data, $callback = null) - * @method Elements unbind($type = null, $callback = null) - * @method Elements change($callback = null) - * @method Elements submit($callback = null) - * @method Elements click($callback = null) - * @method Elements wrapAllOld($wrapper) - * @method Elements wrapAll($wrapper) - * @method Elements wrapAllPHP($codeBefore, $codeAfter) - * @method Elements wrap($wrapper) - * @method Elements wrapPHP($codeBefore, $codeAfter) - * @method Elements wrapInner($wrapper) - * @method Elements wrapInnerPHP($codeBefore, $codeAfter) - * @method Elements contents() - * @method Elements contentsUnwrap() - * @method Elements switchWith($markup) - * @method Elements eq($num) - * @method Elements size() - * @method Elements length() - * @method int count() - * @method Elements end($level = 1) - * @method Elements _clone() - * @method Elements replaceWithPHP($code) - * @method Elements replaceWith($content) - * @method Elements replaceAll($selector) - * @method Elements remove($selector = null) - * @method Elements|string markup($markup = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method string markupOuter($callback1 = null, $callback2 = null, $callback3 = null) - * @method Elements|string html($html = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method Elements|string xml($xml = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method string htmlOuter($callback1 = null, $callback2 = null, $callback3 = null) - * @method string xmlOuter($callback1 = null, $callback2 = null, $callback3 = null) - * @method Elements php($code) - * @method string markupPHP($code) - * @method string markupOuterPHP() - * @method Elements children($selector) - * @method Elements ancestors($selector) - * @method Elements append($content) - * @method Elements appendPHP($content) - * @method Elements appendTo($seletor) - * @method Elements prepend($content) - * @method Elements prependPHP($content) - * @method Elements prependTo($seletor) - * @method Elements before($content) - * @method Elements beforePHP($content) - * @method Elements insertBefore($seletor) - * @method Elements after($content) - * @method Elements afterPHP($content) - * @method Elements insertAfter($seletor) - * @method Elements insert($target, $type) - * @method int index($subject) - * @method Elements slice($start, $end = null) - * @method Elements reverse() - * @method Elements|string text($text = null, $callback1 = null, $callback2 = null, $callback3 = null) - * @method Elements plugin($class, $file = null) - * @method Elements _next($selector = null) - * @method Elements _prev($selector = null) - * @method Elements prev($selector = null) - * @method Elements prevAll($selector = null) - * @method Elements nextAll($selector = null) - * @method Elements siblings($selector = null) - * @method Elements not($selector = null) - * @method Elements add($selector = null) - * @method Elements parent($selector = null) - * @method Elements parents($selector = null) - * @method Elements stack($nodeTypes = null) - * @method Elements|string attr($attr = null, $value = null) - * @method Elements attrPHP($attr, $code) - * @method Elements removeAttr($attr) - * @method Elements|string val($val = null) - * @method Elements andSelf() - * @method Elements addClass($className) - * @method Elements addClassPHP($className) - * @method bool hasClass($className) - * @method Elements removeClass($className) - * @method Elements toggleClass($className) - * @method Elements _empty() - * @method Elements callback($callback, $param1 = null, $param2 = null, $param3 = null) - * @method string data($key, $value = null) - * @method Elements removeData($key) - * @method void rewind() - * @method Elements current() - * @method int key() - * @method Elements next($cssSelector = null) - * @method bool valid() - * @method bool offsetExists($offset) - * @method Elements offsetGet($offset) - * @method void offsetSet($offset, $value) - * @method string whois($oneNode) - * @method Elements dump() - * @method Elements dumpWhois() - * @method Elements dumpLength() - * @method Elements dumpTree($html, $title) - * @method dumpDie() - */ -class Elements -{ - /** - * @var phpQueryObject - */ - protected $elements; - - /** - * Elements constructor. - * @param $elements - */ - public function __construct(phpQueryObject $elements) - { - $this->elements = $elements; - } - - public function __get($name) - { - return property_exists($this->elements, $name) ? $this->elements->$name : $this->elements->attr($name); - } - - public function __call($name, $arguments) - { - $obj = call_user_func_array([$this->elements, $name], $arguments); - if ($obj instanceof phpQueryObject) { - $obj = new self($obj); - } else if (is_string($obj)) { - $obj = trim($obj); - } - return $obj; - } - - /** - * Iterating elements - * - * @param callable $callback - * - * @return $this - */ - public function each(callable $callback) - { - foreach ($this->elements as $key => $element) { - $break = $callback(new self(pq($element)), $key); - if ($break === false) { - break; - } - } - - return $this; - } - - /** - * Iterating elements - * - * @param $callback - * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection - */ - public function map($callback) - { - $collection = new Collection(); - $this->elements->each(function ($dom) use (& $collection, $callback) { - $collection->push($callback(new self(pq($dom)))); - }); - return $collection; - } - - /** - * Gets the attributes of all the elements - * - * @param string $attr HTML attribute name - * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection - */ - public function attrs($attr) - { - return $this->map(function ($item) use ($attr) { - return $item->attr($attr); - }); - } - - /** - * Gets the text of all the elements - * - * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection - */ - public function texts() - { - return $this->map(function ($item) { - return trim($item->text()); - }); - } - - /** - * Gets the html of all the elements - * - * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection - */ - public function htmls() - { - return $this->map(function ($item) { - return trim($item->html()); - }); - } - - /** - * Gets the htmlOuter of all the elements - * - * @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection - */ - public function htmlOuters() - { - return $this->map(function ($item) { - return trim($item->htmlOuter()); - }); - } - - - /** - * @return phpQueryObject - */ - public function getElements(): phpQueryObject - { - return $this->elements; - } - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Dom/Query.php b/vendor/jaeger/querylist/src/Dom/Query.php deleted file mode 100644 index 869a0cc..0000000 --- a/vendor/jaeger/querylist/src/Dom/Query.php +++ /dev/null @@ -1,322 +0,0 @@ - - * Date: 2017/9/21 - */ - -namespace QL\Dom; - -use Tightenco\Collect\Support\Collection; -use phpQuery; -use phpQueryObject; -use QL\QueryList; -use Closure; - -class Query -{ - protected $html; - /** - * @var \phpQueryObject - */ - protected $document; - protected $rules; - protected $range = null; - protected $ql; - /** - * @var Collection - */ - protected $data; - - - public function __construct(QueryList $ql) - { - $this->ql = $ql; - } - - /** - * @param bool $rel - * @return String - */ - public function getHtml($rel = true) - { - return $rel ? $this->document->htmlOuter() : $this->html; - } - - /** - * @param $html - * @param null $charset - * @return QueryList - */ - public function setHtml($html, $charset = null) - { - $this->html = value($html); - $this->destroyDocument(); - $this->document = phpQuery::newDocumentHTML($this->html, $charset); - return $this->ql; - } - - /** - * Get crawl results - * - * @param Closure|null $callback - * @return Collection|static - */ - public function getData(Closure $callback = null) - { - return $this->handleData($this->data, $callback); - } - - /** - * @param Collection $data - */ - public function setData(Collection $data) - { - $this->data = $data; - } - - - /** - * Searches for all elements that match the specified expression. - * - * @param $selector A string containing a selector expression to match elements against. - * @return Elements - */ - public function find($selector) - { - return (new Dom($this->document))->find($selector); - } - - /** - * Set crawl rule - * - * $rules = [ - * 'rule_name1' => ['selector','HTML attribute | text | html','Tag filter list','callback'], - * 'rule_name2' => ['selector','HTML attribute | text | html','Tag filter list','callback'], - * // ... - * ] - * - * @param array $rules - * @return QueryList - */ - public function rules(array $rules) - { - $this->rules = $rules; - return $this->ql; - } - - - /** - * Set the slice area for crawl list - * - * @param $selector - * @return QueryList - */ - public function range($selector) - { - $this->range = $selector; - return $this->ql; - } - - /** - * Remove HTML head,try to solve the garbled - * - * @return QueryList - */ - public function removeHead() - { - $html = preg_replace('/(|).+<\/head>/is', '', $this->html); - $this->setHtml($html); - return $this->ql; - } - - /** - * Execute the query rule - * - * @param Closure|null $callback - * @return QueryList - */ - public function query(Closure $callback = null) - { - $this->data = $this->getList(); - $this->data = $this->handleData($this->data, $callback); - return $this->ql; - } - - public function handleData(Collection $data, $callback) - { - if (is_callable($callback)) { - if (empty($this->range)) { - $data = new Collection($callback($data->all(), null)); - } else { - $data = $data->map($callback); - } - } - - return $data; - } - - protected function getList() - { - $data = []; - if (empty($this->range)) { - foreach ($this->rules as $key => $reg_value) { - $rule = $this->parseRule($reg_value); - $contentElements = $this->document->find($rule['selector']); - $data[$key] = $this->extractContent($contentElements, $key, $rule); - } - } else { - $rangeElements = $this->document->find($this->range); - $i = 0; - foreach ($rangeElements as $element) { - foreach ($this->rules as $key => $reg_value) { - $rule = $this->parseRule($reg_value); - $contentElements = pq($element)->find($rule['selector']); - $data[$i][$key] = $this->extractContent($contentElements, $key, $rule); - } - $i++; - } - } - - return new Collection($data); - } - - protected function extractContent(phpQueryObject $pqObj, $ruleName, $rule) - { - switch ($rule['attr']) { - case 'text': - $content = $this->allowTags($pqObj->html(), $rule['filter_tags']); - break; - case 'texts': - $content = (new Elements($pqObj))->map(function (Elements $element) use ($rule) { - return $this->allowTags($element->html(), $rule['filter_tags']); - })->all(); - break; - case 'html': - $content = $this->stripTags($pqObj->html(), $rule['filter_tags']); - break; - case 'htmls': - $content = (new Elements($pqObj))->map(function (Elements $element) use ($rule) { - return $this->stripTags($element->html(), $rule['filter_tags']); - })->all(); - break; - case 'htmlOuter': - $content = $this->stripTags($pqObj->htmlOuter(), $rule['filter_tags']); - break; - case 'htmlOuters': - $content = (new Elements($pqObj))->map(function (Elements $element) use ($rule) { - return $this->stripTags($element->htmlOuter(), $rule['filter_tags']); - })->all(); - break; - default: - if(preg_match('/attr\((.+)\)/', $rule['attr'], $arr)) { - $content = $pqObj->attr($arr[1]); - } elseif (preg_match('/attrs\((.+)\)/', $rule['attr'], $arr)) { - $content = (new Elements($pqObj))->attrs($arr[1])->all(); - } else { - $content = $pqObj->attr($rule['attr']); - } - break; - } - - if (is_callable($rule['handle_callback'])) { - $content = call_user_func($rule['handle_callback'], $content, $ruleName); - } - - return $content; - } - - protected function parseRule($rule) - { - $result = []; - $result['selector'] = $rule[0]; - $result['attr'] = $rule[1]; - $result['filter_tags'] = $rule[2] ?? ''; - $result['handle_callback'] = $rule[3] ?? null; - - return $result; - } - - /** - * 去除特定的html标签 - * @param string $html - * @param string $tags_str 多个标签名之间用空格隔开 - * @return string - */ - protected function stripTags($html, $tags_str) - { - $tagsArr = $this->tag($tags_str); - $html = $this->removeTags($html, $tagsArr[1]); - $p = array(); - foreach ($tagsArr[0] as $tag) { - $p[] = "/(<(?:\/" . $tag . "|" . $tag . ")[^>]*>)/i"; - } - $html = preg_replace($p, "", trim($html)); - return $html; - } - - /** - * 保留特定的html标签 - * @param string $html - * @param string $tags_str 多个标签名之间用空格隔开 - * @return string - */ - protected function allowTags($html, $tags_str) - { - $tagsArr = $this->tag($tags_str); - $html = $this->removeTags($html, $tagsArr[1]); - $allow = ''; - foreach ($tagsArr[0] as $tag) { - $allow .= "<$tag> "; - } - return strip_tags(trim($html), $allow); - } - - protected function tag($tags_str) - { - $tagArr = preg_split("/\s+/", $tags_str, -1, PREG_SPLIT_NO_EMPTY); - $tags = array(array(), array()); - foreach ($tagArr as $tag) { - if (preg_match('/-(.+)/', $tag, $arr)) { - array_push($tags[1], $arr[1]); - } else { - array_push($tags[0], $tag); - } - } - return $tags; - } - - /** - * 移除特定的html标签 - * @param string $html - * @param array $tags 标签数组 - * @return string - */ - protected function removeTags($html, $tags) - { - $tag_str = ''; - if (count($tags)) { - foreach ($tags as $tag) { - $tag_str .= $tag_str ? ',' . $tag : $tag; - } -// phpQuery::$defaultCharset = $this->inputEncoding?$this->inputEncoding:$this->htmlEncoding; - $doc = phpQuery::newDocumentHTML($html); - pq($doc)->find($tag_str)->remove(); - $html = pq($doc)->htmlOuter(); - $doc->unloadDocument(); - } - return $html; - } - - protected function destroyDocument() - { - if ($this->document instanceof phpQueryObject) { - $this->document->unloadDocument(); - } - } - - public function __destruct() - { - $this->destroyDocument(); - } -} diff --git a/vendor/jaeger/querylist/src/Exceptions/ServiceNotFoundException.php b/vendor/jaeger/querylist/src/Exceptions/ServiceNotFoundException.php deleted file mode 100644 index a8924ad..0000000 --- a/vendor/jaeger/querylist/src/Exceptions/ServiceNotFoundException.php +++ /dev/null @@ -1,15 +0,0 @@ - - * Date: 2017/9/21 - */ - -namespace QL\Exceptions; - -use Exception; - -class ServiceNotFoundException extends Exception -{ - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Kernel.php b/vendor/jaeger/querylist/src/Kernel.php deleted file mode 100644 index 085c21d..0000000 --- a/vendor/jaeger/querylist/src/Kernel.php +++ /dev/null @@ -1,74 +0,0 @@ - - * Date: 2017/9/21 - */ - -namespace QL; - -use QL\Contracts\ServiceProviderContract; -use QL\Exceptions\ServiceNotFoundException; -use QL\Providers\EncodeServiceProvider; -use Closure; -use QL\Providers\HttpServiceProvider; -use QL\Providers\PluginServiceProvider; -use QL\Providers\SystemServiceProvider; -use Tightenco\Collect\Support\Collection; - -class Kernel -{ - protected $providers = [ - SystemServiceProvider::class, - HttpServiceProvider::class, - EncodeServiceProvider::class, - PluginServiceProvider::class - ]; - - protected $binds; - protected $ql; - - /** - * Kernel constructor. - * @param $ql - */ - public function __construct(QueryList $ql) - { - $this->ql = $ql; - $this->binds = new Collection(); - } - - public function bootstrap() - { - //注册服务提供者 - $this->registerProviders(); - return $this; - } - - public function registerProviders() - { - foreach ($this->providers as $provider) { - $this->register(new $provider()); - } - } - - public function bind(string $name,Closure $provider) - { - $this->binds[$name] = $provider; - } - - public function getService(string $name) - { - if(!$this->binds->offsetExists($name)){ - throw new ServiceNotFoundException("Service: {$name} not found!"); - } - return $this->binds[$name]; - } - - private function register(ServiceProviderContract $instance) - { - $instance->register($this); - } - - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Providers/EncodeServiceProvider.php b/vendor/jaeger/querylist/src/Providers/EncodeServiceProvider.php deleted file mode 100644 index e8fd739..0000000 --- a/vendor/jaeger/querylist/src/Providers/EncodeServiceProvider.php +++ /dev/null @@ -1,22 +0,0 @@ - - * Date: 2017/9/20 - */ - -namespace QL\Providers; - -use QL\Contracts\ServiceProviderContract; -use QL\Kernel; -use QL\Services\EncodeService; - -class EncodeServiceProvider implements ServiceProviderContract -{ - public function register(Kernel $kernel) - { - $kernel->bind('encoding',function (string $outputEncoding,string $inputEncoding = null){ - return EncodeService::convert($this,$outputEncoding,$inputEncoding); - }); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Providers/HttpServiceProvider.php b/vendor/jaeger/querylist/src/Providers/HttpServiceProvider.php deleted file mode 100644 index 2b3145f..0000000 --- a/vendor/jaeger/querylist/src/Providers/HttpServiceProvider.php +++ /dev/null @@ -1,40 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Providers; - - -use QL\Contracts\ServiceProviderContract; -use QL\Kernel; -use QL\Services\HttpService; -use QL\Services\MultiRequestService; - -class HttpServiceProvider implements ServiceProviderContract -{ - public function register(Kernel $kernel) - { - $kernel->bind('get',function (...$args){ - return HttpService::get($this,...$args); - }); - - $kernel->bind('post',function (...$args){ - return HttpService::post($this,...$args); - }); - - $kernel->bind('postJson',function (...$args){ - return HttpService::postJson($this,...$args); - }); - - $kernel->bind('multiGet',function (...$args){ - return new MultiRequestService($this,'get',...$args); - }); - - $kernel->bind('multiPost',function (...$args){ - return new MultiRequestService($this,'post',...$args); - }); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Providers/PluginServiceProvider.php b/vendor/jaeger/querylist/src/Providers/PluginServiceProvider.php deleted file mode 100644 index 867b2ec..0000000 --- a/vendor/jaeger/querylist/src/Providers/PluginServiceProvider.php +++ /dev/null @@ -1,23 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Providers; - -use QL\Contracts\ServiceProviderContract; -use QL\Kernel; -use QL\Services\PluginService; - -class PluginServiceProvider implements ServiceProviderContract -{ - public function register(Kernel $kernel) - { - $kernel->bind('use',function ($plugins,...$opt){ - return PluginService::install($this,$plugins,...$opt); - }); - } - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Providers/SystemServiceProvider.php b/vendor/jaeger/querylist/src/Providers/SystemServiceProvider.php deleted file mode 100644 index 76d60d2..0000000 --- a/vendor/jaeger/querylist/src/Providers/SystemServiceProvider.php +++ /dev/null @@ -1,32 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Providers; - -use QL\Contracts\ServiceProviderContract; -use QL\Kernel; -use Closure; - -class SystemServiceProvider implements ServiceProviderContract -{ - public function register(Kernel $kernel) - { - $kernel->bind('html',function (...$args){ - $this->setHtml(...$args); - return $this; - }); - - $kernel->bind('queryData',function (Closure $callback = null){ - return $this->query()->getData($callback)->all(); - }); - - $kernel->bind('pipe',function (Closure $callback = null){ - return $callback($this); - }); - - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/QueryList.php b/vendor/jaeger/querylist/src/QueryList.php deleted file mode 100644 index 4fc1c6c..0000000 --- a/vendor/jaeger/querylist/src/QueryList.php +++ /dev/null @@ -1,133 +0,0 @@ -query = new Query($this); - $this->kernel = (new Kernel($this))->bootstrap(); - Config::getInstance()->bootstrap($this); - } - - public function __call($name, $arguments) - { - if(method_exists($this->query,$name)){ - $result = $this->query->$name(...$arguments); - }else{ - $result = $this->kernel->getService($name)->call($this,...$arguments); - } - return $result; - } - - public static function __callStatic($name, $arguments) - { - $instance = new self(); - return $instance->$name(...$arguments); - } - - public function __destruct() - { - $this->destruct(); - } - - /** - * Get the QueryList single instance - * - * @return QueryList - */ - public static function getInstance() - { - self::$instance || self::$instance = new self(); - return self::$instance; - } - - /** - * Get the Config instance - * @return null|Config - */ - public static function config() - { - return Config::getInstance(); - } - - /** - * Destruction of resources - */ - public function destruct() - { - unset($this->query); - unset($this->kernel); - } - - /** - * Destroy all documents - */ - public static function destructDocuments() - { - phpQuery::$documents = []; - } - - /** - * Bind a custom method to the QueryList object - * - * @param string $name Invoking the name - * @param Closure $provide Called method - * @return $this - */ - public function bind(string $name,Closure $provide) - { - $this->kernel->bind($name,$provide); - return $this; - } - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Services/EncodeService.php b/vendor/jaeger/querylist/src/Services/EncodeService.php deleted file mode 100644 index 704d8b8..0000000 --- a/vendor/jaeger/querylist/src/Services/EncodeService.php +++ /dev/null @@ -1,37 +0,0 @@ - - * Date: 2017/9/20 - * 编码转换服务 - */ - -namespace QL\Services; - -use QL\QueryList; - -class EncodeService -{ - public static function convert(QueryList $ql,string $outputEncoding,string $inputEncoding = null) - { - $html = $ql->getHtml(); - $inputEncoding || $inputEncoding = self::detect($html); - $html = iconv($inputEncoding,$outputEncoding.'//IGNORE',$html); - $ql->setHtml($html); - return $ql; - } - - /** - * Attempts to detect the encoding - * @param $string - * @return bool|false|mixed|string - */ - public static function detect($string) - { - $charset=mb_detect_encoding($string, array('ASCII', 'GB2312', 'GBK', 'UTF-8'),true); - if(strtolower($charset)=='cp936') - $charset='GBK'; - return $charset; - } - -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Services/HttpService.php b/vendor/jaeger/querylist/src/Services/HttpService.php deleted file mode 100644 index 0d2cdec..0000000 --- a/vendor/jaeger/querylist/src/Services/HttpService.php +++ /dev/null @@ -1,59 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Services; - -use GuzzleHttp\Cookie\CookieJar; -use Jaeger\GHttp; -use QL\QueryList; - -class HttpService -{ - protected static $cookieJar = null; - - public static function getCookieJar() - { - if(self::$cookieJar == null) - { - self::$cookieJar = new CookieJar(); - } - return self::$cookieJar; - } - - public static function get(QueryList $ql,$url,$args = null,$otherArgs = []) - { - $otherArgs = array_merge([ - 'cookies' => self::getCookieJar(), - 'verify' => false - ],$otherArgs); - $html = GHttp::get($url,$args,$otherArgs); - $ql->setHtml($html); - return $ql; - } - - public static function post(QueryList $ql,$url,$args = null,$otherArgs = []) - { - $otherArgs = array_merge([ - 'cookies' => self::getCookieJar(), - 'verify' => false - ],$otherArgs); - $html = GHttp::post($url,$args,$otherArgs); - $ql->setHtml($html); - return $ql; - } - - public static function postJson(QueryList $ql,$url,$args = null,$otherArgs = []) - { - $otherArgs = array_merge([ - 'cookies' => self::getCookieJar(), - 'verify' => false - ],$otherArgs); - $html = GHttp::postJson($url,$args,$otherArgs); - $ql->setHtml($html); - return $ql; - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Services/MultiRequestService.php b/vendor/jaeger/querylist/src/Services/MultiRequestService.php deleted file mode 100644 index 803ee80..0000000 --- a/vendor/jaeger/querylist/src/Services/MultiRequestService.php +++ /dev/null @@ -1,66 +0,0 @@ - - * Date: 18/12/10 - * Time: 下午7:05 - */ - -namespace QL\Services; - - -use Jaeger\GHttp; -use Closure; -use GuzzleHttp\Psr7\Response; -use QL\QueryList; -use GuzzleHttp\Exception\RequestException; - -/** - * Class MultiRequestService - * @package QL\Services - * - * @method MultiRequestService withHeaders($headers) - * @method MultiRequestService withOptions($options) - * @method MultiRequestService concurrency($concurrency) - */ -class MultiRequestService -{ - protected $ql; - protected $multiRequest; - protected $method; - - public function __construct(QueryList $ql,$method,$urls) - { - $this->ql = $ql; - $this->method = $method; - $this->multiRequest = GHttp::multiRequest($urls); - } - - public function __call($name, $arguments) - { - $this->multiRequest = $this->multiRequest->$name(...$arguments); - return $this; - } - - public function success(Closure $success) - { - $this->multiRequest = $this->multiRequest->success(function(Response $response, $index) use($success){ - $this->ql->setHtml((String)$response->getBody()); - $success($this->ql,$response, $index); - }); - return $this; - } - - public function error(Closure $error) - { - $this->multiRequest = $this->multiRequest->error(function(RequestException $reason, $index) use($error){ - $error($this->ql,$reason, $index); - }); - return $this; - } - - public function send() - { - $this->multiRequest->{$this->method}(); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/src/Services/PluginService.php b/vendor/jaeger/querylist/src/Services/PluginService.php deleted file mode 100644 index 1afef3a..0000000 --- a/vendor/jaeger/querylist/src/Services/PluginService.php +++ /dev/null @@ -1,26 +0,0 @@ - - * Date: 2017/9/22 - */ - -namespace QL\Services; - -use QL\QueryList; - -class PluginService -{ - public static function install(QueryList $queryList, $plugins, ...$opt) - { - if(is_array($plugins)) - { - foreach ($plugins as $plugin) { - $plugin::install($queryList); - } - }else{ - $plugins::install($queryList,...$opt); - } - return $queryList; - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/Dom/FindTest.php b/vendor/jaeger/querylist/tests/Dom/FindTest.php deleted file mode 100644 index 024df21..0000000 --- a/vendor/jaeger/querylist/tests/Dom/FindTest.php +++ /dev/null @@ -1,71 +0,0 @@ -html = $this->getSnippet('snippet-1'); - $this->ql = QueryList::html($this->html); - } - - /** - * @test - */ - public function find_first_dom_attr() - { - $img = []; - $img[] = $this->ql->find('img')->attr('src'); - $img[] = $this->ql->find('img')->src; - $img[] = $this->ql->find('img:eq(0)')->src; - $img[] = $this->ql->find('img')->eq(0)->src; - - $alt = $this->ql->find('img')->alt; - $abc = $this->ql->find('img')->abc; - - $this->assertCount(1,array_unique($img)); - $this->assertEquals($alt,'这是图片'); - $this->assertEquals($abc,'这是一个自定义属性'); - - } - - /** - * @test - */ - public function find_second_dom_attr() - { - - $img2 = []; - $img2[] = $this->ql->find('img')->eq(1)->alt; - $img2[] = $this->ql->find('img:eq(1)')->alt; - $img2[] = $this->ql->find('.second_pic')->alt; - - $this->assertCount(1,array_unique($img2)); - - } - - /** - * @test - */ - public function find_dom_all_attr() - { - $imgAttr = $this->ql->find('img:eq(0)')->attr('*'); - $linkAttr = $this->ql->find('a:eq(1)')->attr('*'); - $this->assertCount(3,$imgAttr); - $this->assertCount(1,$linkAttr); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/Dom/RulesTest.php b/vendor/jaeger/querylist/tests/Dom/RulesTest.php deleted file mode 100644 index 7c555ca..0000000 --- a/vendor/jaeger/querylist/tests/Dom/RulesTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * Date: 18/12/12 - * Time: 下午12:25 - */ - -namespace Tests\Dom; - - -use QL\QueryList; -use Tests\TestCaseBase; -use Tightenco\Collect\Support\Collection; - -class RulesTest extends TestCaseBase -{ - protected $html; - protected $ql; - - protected function setUp(): void - { - $this->html = $this->getSnippet('snippet-2'); - $this->ql = QueryList::html($this->html); - } - - /** - * @test - */ - public function get_data_by_rules() - { - $rules = [ - 'a' => ['a','text'], - 'img_src' => ['img','src'], - 'img_alt' => ['img','alt'] - ]; - $range = 'ul>li'; - $data = QueryList::rules($rules)->range($range)->html($this->html)->query()->getData(); - $this->assertInstanceOf(Collection::class,$data); - $this->assertCount(3,$data); - $this->assertEquals('http://querylist.com/2.jpg',$data[1]['img_src']); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/Feature/HttpTest.php b/vendor/jaeger/querylist/tests/Feature/HttpTest.php deleted file mode 100644 index 0d723ed..0000000 --- a/vendor/jaeger/querylist/tests/Feature/HttpTest.php +++ /dev/null @@ -1,103 +0,0 @@ -urls = [ - 'http://httpbin.org/get?name=php', - 'http://httpbin.org/get?name=golang', - 'http://httpbin.org/get?name=c++', - 'http://httpbin.org/get?name=java' - ]; - } - - /** - * @test - */ - public function can_post_json_data() - { - $mock = new MockHandler([new Response()]); - $data = [ - 'name' => 'foo' - ]; - QueryList::postJson('http://foo.com',$data,[ - 'handler' => $mock - ]); - $this->assertEquals((string)$mock->getLastRequest()->getBody(),json_encode($data)); - } - - /** - * @test - */ - public function concurrent_requests_base_use() - { - $urls = $this->urls; - QueryList::getInstance() - ->multiGet($urls) - ->success(function(QueryList $ql,Response $response, $index) use($urls){ - $body = json_decode((string)$response->getBody(),true); - $this->assertEquals($urls[$index],$body['url']); - })->send(); - } - - /** - * @test - */ - public function concurrent_requests_advanced_use() - { - $ua = 'QueryList/4.0'; - - $errorUrl = 'http://web-site-not-exist.com'; - $urls = array_merge($this->urls,[$errorUrl]); - - QueryList::rules([]) - ->multiGet($urls) - ->concurrency(2) - ->withOptions([ - 'timeout' => 60 - ]) - ->withHeaders([ - 'User-Agent' => $ua - ]) - ->success(function (QueryList $ql, Response $response, $index) use($ua){ - $body = json_decode((string)$response->getBody(),true); - $this->assertEquals($ua,$body['headers']['User-Agent']); - }) - ->error(function (QueryList $ql, $reason, $index) use($urls,$errorUrl){ - $this->assertEquals($urls[$index],$errorUrl); - }) - ->send(); - } - - /** - * @test - */ - public function request_with_cache() - { - $url = $this->urls[0]; - $data = QueryList::get($url,null,[ - 'cache' => sys_get_temp_dir(), - 'cache_ttl' => 600 - ])->getHtml(); - $data = json_decode($data,true); - $this->assertEquals($url,$data['url']); - - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/Feature/InstanceTest.php b/vendor/jaeger/querylist/tests/Feature/InstanceTest.php deleted file mode 100644 index a659060..0000000 --- a/vendor/jaeger/querylist/tests/Feature/InstanceTest.php +++ /dev/null @@ -1,48 +0,0 @@ -html = $this->getSnippet('snippet-1'); - } - /** - * @test - */ - public function singleton_instance_mode() - { - $ql = QueryList::getInstance()->html($this->html); - $ql2 = QueryList::getInstance(); - $this->assertEquals($ql->getHtml(),$ql2->getHtml()); - - - } - - /** - * @test - */ - public function get_new_object() - { - $ql = (new QueryList())->html($this->html); - $ql2 = (new QueryList())->html(''); - $this->assertNotEquals($ql->getHtml(),$ql2->getHtml()); - - $ql = QueryList::range('')->html($this->html); - $ql2 = QueryList::range('')->html(''); - $this->assertNotEquals($ql->getHtml(),$ql2->getHtml()); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/Feature/MethodTest.php b/vendor/jaeger/querylist/tests/Feature/MethodTest.php deleted file mode 100644 index ca10cf9..0000000 --- a/vendor/jaeger/querylist/tests/Feature/MethodTest.php +++ /dev/null @@ -1,36 +0,0 @@ -html = $this->getSnippet('snippet-1'); - } - - /** - * @test - */ - public function pipe() - { - $html = $this->html; - $qlHtml = QueryList::pipe(function(QueryList $ql) use($html){ - $ql->setHtml($html); - return $ql; - })->getHtml(false); - $this->assertEquals($html,$qlHtml); - } -} \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/TestCaseBase.php b/vendor/jaeger/querylist/tests/TestCaseBase.php deleted file mode 100644 index c88d73e..0000000 --- a/vendor/jaeger/querylist/tests/TestCaseBase.php +++ /dev/null @@ -1,20 +0,0 @@ - - - 其它的一些文本 -
\ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/assets/snippet-2.html b/vendor/jaeger/querylist/tests/assets/snippet-2.html deleted file mode 100644 index 88ae3f0..0000000 --- a/vendor/jaeger/querylist/tests/assets/snippet-2.html +++ /dev/null @@ -1,16 +0,0 @@ - \ No newline at end of file diff --git a/vendor/jaeger/querylist/tests/bootstrap.php b/vendor/jaeger/querylist/tests/bootstrap.php deleted file mode 100644 index eace7af..0000000 --- a/vendor/jaeger/querylist/tests/bootstrap.php +++ /dev/null @@ -1,5 +0,0 @@ - - Build Status - - - Total Downloads - - - Latest Stable Version - - - License - - -## Introduction - -> This project is a fork of the excellent [opis/closure: 3.x](https://github.com/opis/closure) package. At Laravel, we decided to fork this package as the upcoming version [4.x](https://github.com/opis/closure) is a complete rewrite on top of the [FFI extension](https://www.php.net/manual/en/book.ffi.php). As Laravel is a web framework, and FFI is not enabled by default in web requests, this fork allows us to keep using the `3.x` series while adding support for new PHP versions. - -Laravel Serializable Closure provides an easy and secure way to **serialize closures in PHP**. - -## Official Documentation - -### Installation - -> **Requires [PHP 7.4+](https://php.net/releases/)** - -First, install Laravel Serializable Closure via the [Composer](https://getcomposer.org/) package manager: - -```bash -composer require laravel/serializable-closure -``` - -### Usage - -You may serialize a closure this way: - -```php -use Laravel\SerializableClosure\SerializableClosure; - -$closure = fn () => 'james'; - -// Recommended -SerializableClosure::setSecretKey('secret'); - -$serialized = serialize(new SerializableClosure($closure)); -$closure = unserialize($serialized)->getClosure(); - -echo $closure(); // james; -``` - -### Caveats - -1. Creating **anonymous classes** within closures is not supported. -2. Using attributes within closures is not supported. -3. Serializing closures on REPL environments such as Laravel Tinker is not supported. - -## Contributing - -Thank you for considering contributing to Serializable Closure! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). - -## Code of Conduct - -In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). - -## Security Vulnerabilities - -Please review [our security policy](https://github.com/laravel/serializable-closure/security/policy) on how to report security vulnerabilities. - -## License - -Serializable Closure is open-sourced software licensed under the [MIT license](LICENSE.md). diff --git a/vendor/laravel/serializable-closure/composer.json b/vendor/laravel/serializable-closure/composer.json deleted file mode 100644 index 7142366..0000000 --- a/vendor/laravel/serializable-closure/composer.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "laravel/serializable-closure", - "description": "Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.", - "keywords": ["laravel", "Serializable", "closure"], - "license": "MIT", - "support": { - "issues": "https://github.com/laravel/serializable-closure/issues", - "source": "https://github.com/laravel/serializable-closure" - }, - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - }, - { - "name": "Nuno Maduro", - "email": "nuno@laravel.com" - } - ], - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "nesbot/carbon": "^2.61", - "pestphp/pest": "^1.21.3", - "phpstan/phpstan": "^1.8.2", - "symfony/var-dumper": "^5.4.11" - }, - "autoload": { - "psr-4": { - "Laravel\\SerializableClosure\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "config": { - "sort-packages": true, - "allow-plugins": { - "pestphp/pest-plugin": true - } - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/vendor/laravel/serializable-closure/src/Contracts/Serializable.php b/vendor/laravel/serializable-closure/src/Contracts/Serializable.php deleted file mode 100644 index 1a62922..0000000 --- a/vendor/laravel/serializable-closure/src/Contracts/Serializable.php +++ /dev/null @@ -1,20 +0,0 @@ -serializable = Serializers\Signed::$signer - ? new Serializers\Signed($closure) - : new Serializers\Native($closure); - } - - /** - * Resolve the closure with the given arguments. - * - * @return mixed - */ - public function __invoke() - { - if (\PHP_VERSION_ID < 70400) { - throw new PhpVersionNotSupportedException(); - } - - return call_user_func_array($this->serializable, func_get_args()); - } - - /** - * Gets the closure. - * - * @return \Closure - */ - public function getClosure() - { - if (\PHP_VERSION_ID < 70400) { - throw new PhpVersionNotSupportedException(); - } - - return $this->serializable->getClosure(); - } - - /** - * Create a new unsigned serializable closure instance. - * - * @param Closure $closure - * @return \Laravel\SerializableClosure\UnsignedSerializableClosure - */ - public static function unsigned(Closure $closure) - { - return new UnsignedSerializableClosure($closure); - } - - /** - * Sets the serializable closure secret key. - * - * @param string|null $secret - * @return void - */ - public static function setSecretKey($secret) - { - Serializers\Signed::$signer = $secret - ? new Hmac($secret) - : null; - } - - /** - * Sets the serializable closure secret key. - * - * @param \Closure|null $transformer - * @return void - */ - public static function transformUseVariablesUsing($transformer) - { - Serializers\Native::$transformUseVariables = $transformer; - } - - /** - * Sets the serializable closure secret key. - * - * @param \Closure|null $resolver - * @return void - */ - public static function resolveUseVariablesUsing($resolver) - { - Serializers\Native::$resolveUseVariables = $resolver; - } - - /** - * Get the serializable representation of the closure. - * - * @return array - */ - public function __serialize() - { - return [ - 'serializable' => $this->serializable, - ]; - } - - /** - * Restore the closure after serialization. - * - * @param array $data - * @return void - * - * @throws \Laravel\SerializableClosure\Exceptions\InvalidSignatureException - */ - public function __unserialize($data) - { - if (Signed::$signer && ! $data['serializable'] instanceof Signed) { - throw new InvalidSignatureException(); - } - - $this->serializable = $data['serializable']; - } -} diff --git a/vendor/laravel/serializable-closure/src/Serializers/Native.php b/vendor/laravel/serializable-closure/src/Serializers/Native.php deleted file mode 100644 index 4a04b98..0000000 --- a/vendor/laravel/serializable-closure/src/Serializers/Native.php +++ /dev/null @@ -1,514 +0,0 @@ -closure = $closure; - } - - /** - * Resolve the closure with the given arguments. - * - * @return mixed - */ - public function __invoke() - { - return call_user_func_array($this->closure, func_get_args()); - } - - /** - * Gets the closure. - * - * @return \Closure - */ - public function getClosure() - { - return $this->closure; - } - - /** - * Get the serializable representation of the closure. - * - * @return array - */ - public function __serialize() - { - if ($this->scope === null) { - $this->scope = new ClosureScope(); - $this->scope->toSerialize++; - } - - $this->scope->serializations++; - - $scope = $object = null; - $reflector = $this->getReflector(); - - if ($reflector->isBindingRequired()) { - $object = $reflector->getClosureThis(); - - static::wrapClosures($object, $this->scope); - } - - if ($scope = $reflector->getClosureScopeClass()) { - $scope = $scope->name; - } - - $this->reference = spl_object_hash($this->closure); - - $this->scope[$this->closure] = $this; - - $use = $reflector->getUseVariables(); - - if (static::$transformUseVariables) { - $use = call_user_func(static::$transformUseVariables, $reflector->getUseVariables()); - } - - $code = $reflector->getCode(); - - $this->mapByReference($use); - - $data = [ - 'use' => $use, - 'function' => $code, - 'scope' => $scope, - 'this' => $object, - 'self' => $this->reference, - ]; - - if (! --$this->scope->serializations && ! --$this->scope->toSerialize) { - $this->scope = null; - } - - return $data; - } - - /** - * Restore the closure after serialization. - * - * @param array $data - * @return void - */ - public function __unserialize($data) - { - ClosureStream::register(); - - $this->code = $data; - unset($data); - - $this->code['objects'] = []; - - if ($this->code['use']) { - $this->scope = new ClosureScope(); - - if (static::$resolveUseVariables) { - $this->code['use'] = call_user_func(static::$resolveUseVariables, $this->code['use']); - } - - $this->mapPointers($this->code['use']); - - extract($this->code['use'], EXTR_OVERWRITE | EXTR_REFS); - - $this->scope = null; - } - - $this->closure = include ClosureStream::STREAM_PROTO.'://'.$this->code['function']; - - if ($this->code['this'] === $this) { - $this->code['this'] = null; - } - - $this->closure = $this->closure->bindTo($this->code['this'], $this->code['scope']); - - if (! empty($this->code['objects'])) { - foreach ($this->code['objects'] as $item) { - $item['property']->setValue($item['instance'], $item['object']->getClosure()); - } - } - - $this->code = $this->code['function']; - } - - /** - * Ensures the given closures are serializable. - * - * @param mixed $data - * @param \Laravel\SerializableClosure\Support\ClosureScope $storage - * @return void - */ - public static function wrapClosures(&$data, $storage) - { - if ($data instanceof Closure) { - $data = new static($data); - } elseif (is_array($data)) { - if (isset($data[self::ARRAY_RECURSIVE_KEY])) { - return; - } - - $data[self::ARRAY_RECURSIVE_KEY] = true; - - foreach ($data as $key => &$value) { - if ($key === self::ARRAY_RECURSIVE_KEY) { - continue; - } - static::wrapClosures($value, $storage); - } - - unset($value); - unset($data[self::ARRAY_RECURSIVE_KEY]); - } elseif ($data instanceof \stdClass) { - if (isset($storage[$data])) { - $data = $storage[$data]; - - return; - } - - $data = $storage[$data] = clone $data; - - foreach ($data as &$value) { - static::wrapClosures($value, $storage); - } - - unset($value); - } elseif (is_object($data) && ! $data instanceof static && ! $data instanceof UnitEnum) { - if (isset($storage[$data])) { - $data = $storage[$data]; - - return; - } - - $instance = $data; - $reflection = new ReflectionObject($instance); - - if (! $reflection->isUserDefined()) { - $storage[$instance] = $data; - - return; - } - - $storage[$instance] = $data = $reflection->newInstanceWithoutConstructor(); - - do { - if (! $reflection->isUserDefined()) { - break; - } - - foreach ($reflection->getProperties() as $property) { - if ($property->isStatic() || ! $property->getDeclaringClass()->isUserDefined()) { - continue; - } - - $property->setAccessible(true); - - if (PHP_VERSION >= 7.4 && ! $property->isInitialized($instance)) { - continue; - } - - $value = $property->getValue($instance); - - if (is_array($value) || is_object($value)) { - static::wrapClosures($value, $storage); - } - - $property->setValue($data, $value); - } - } while ($reflection = $reflection->getParentClass()); - } - } - - /** - * Gets the closure's reflector. - * - * @return \Laravel\SerializableClosure\Support\ReflectionClosure - */ - public function getReflector() - { - if ($this->reflector === null) { - $this->code = null; - $this->reflector = new ReflectionClosure($this->closure); - } - - return $this->reflector; - } - - /** - * Internal method used to map closure pointers. - * - * @param mixed $data - * @return void - */ - protected function mapPointers(&$data) - { - $scope = $this->scope; - - if ($data instanceof static) { - $data = &$data->closure; - } elseif (is_array($data)) { - if (isset($data[self::ARRAY_RECURSIVE_KEY])) { - return; - } - - $data[self::ARRAY_RECURSIVE_KEY] = true; - - foreach ($data as $key => &$value) { - if ($key === self::ARRAY_RECURSIVE_KEY) { - continue; - } elseif ($value instanceof static) { - $data[$key] = &$value->closure; - } elseif ($value instanceof SelfReference && $value->hash === $this->code['self']) { - $data[$key] = &$this->closure; - } else { - $this->mapPointers($value); - } - } - - unset($value); - unset($data[self::ARRAY_RECURSIVE_KEY]); - } elseif ($data instanceof \stdClass) { - if (isset($scope[$data])) { - return; - } - - $scope[$data] = true; - - foreach ($data as $key => &$value) { - if ($value instanceof SelfReference && $value->hash === $this->code['self']) { - $data->{$key} = &$this->closure; - } elseif (is_array($value) || is_object($value)) { - $this->mapPointers($value); - } - } - - unset($value); - } elseif (is_object($data) && ! ($data instanceof Closure)) { - if (isset($scope[$data])) { - return; - } - - $scope[$data] = true; - $reflection = new ReflectionObject($data); - - do { - if (! $reflection->isUserDefined()) { - break; - } - - foreach ($reflection->getProperties() as $property) { - if ($property->isStatic() || ! $property->getDeclaringClass()->isUserDefined()) { - continue; - } - - $property->setAccessible(true); - - if (PHP_VERSION >= 7.4 && ! $property->isInitialized($data)) { - continue; - } - - $item = $property->getValue($data); - - if ($item instanceof SerializableClosure || $item instanceof UnsignedSerializableClosure || ($item instanceof SelfReference && $item->hash === $this->code['self'])) { - $this->code['objects'][] = [ - 'instance' => $data, - 'property' => $property, - 'object' => $item instanceof SelfReference ? $this : $item, - ]; - } elseif (is_array($item) || is_object($item)) { - $this->mapPointers($item); - $property->setValue($data, $item); - } - } - } while ($reflection = $reflection->getParentClass()); - } - } - - /** - * Internal method used to map closures by reference. - * - * @param mixed $data - * @return void - */ - protected function mapByReference(&$data) - { - if ($data instanceof Closure) { - if ($data === $this->closure) { - $data = new SelfReference($this->reference); - - return; - } - - if (isset($this->scope[$data])) { - $data = $this->scope[$data]; - - return; - } - - $instance = new static($data); - - $instance->scope = $this->scope; - - $data = $this->scope[$data] = $instance; - } elseif (is_array($data)) { - if (isset($data[self::ARRAY_RECURSIVE_KEY])) { - return; - } - - $data[self::ARRAY_RECURSIVE_KEY] = true; - - foreach ($data as $key => &$value) { - if ($key === self::ARRAY_RECURSIVE_KEY) { - continue; - } - - $this->mapByReference($value); - } - - unset($value); - unset($data[self::ARRAY_RECURSIVE_KEY]); - } elseif ($data instanceof \stdClass) { - if (isset($this->scope[$data])) { - $data = $this->scope[$data]; - - return; - } - - $instance = $data; - $this->scope[$instance] = $data = clone $data; - - foreach ($data as &$value) { - $this->mapByReference($value); - } - - unset($value); - } elseif (is_object($data) && ! $data instanceof SerializableClosure && ! $data instanceof UnsignedSerializableClosure) { - if (isset($this->scope[$data])) { - $data = $this->scope[$data]; - - return; - } - - $instance = $data; - - if ($data instanceof DateTimeInterface) { - $this->scope[$instance] = $data; - - return; - } - - if ($data instanceof UnitEnum) { - $this->scope[$instance] = $data; - - return; - } - - $reflection = new ReflectionObject($data); - - if (! $reflection->isUserDefined()) { - $this->scope[$instance] = $data; - - return; - } - - $this->scope[$instance] = $data = $reflection->newInstanceWithoutConstructor(); - - do { - if (! $reflection->isUserDefined()) { - break; - } - - foreach ($reflection->getProperties() as $property) { - if ($property->isStatic() || ! $property->getDeclaringClass()->isUserDefined()) { - continue; - } - - $property->setAccessible(true); - - if (PHP_VERSION >= 7.4 && ! $property->isInitialized($instance)) { - continue; - } - - $value = $property->getValue($instance); - - if (is_array($value) || is_object($value)) { - $this->mapByReference($value); - } - - $property->setValue($data, $value); - } - } while ($reflection = $reflection->getParentClass()); - } - } -} diff --git a/vendor/laravel/serializable-closure/src/Serializers/Signed.php b/vendor/laravel/serializable-closure/src/Serializers/Signed.php deleted file mode 100644 index 391d20d..0000000 --- a/vendor/laravel/serializable-closure/src/Serializers/Signed.php +++ /dev/null @@ -1,91 +0,0 @@ -closure = $closure; - } - - /** - * Resolve the closure with the given arguments. - * - * @return mixed - */ - public function __invoke() - { - return call_user_func_array($this->closure, func_get_args()); - } - - /** - * Gets the closure. - * - * @return \Closure - */ - public function getClosure() - { - return $this->closure; - } - - /** - * Get the serializable representation of the closure. - * - * @return array - */ - public function __serialize() - { - if (! static::$signer) { - throw new MissingSecretKeyException(); - } - - return static::$signer->sign( - serialize(new Native($this->closure)) - ); - } - - /** - * Restore the closure after serialization. - * - * @param array $signature - * @return void - * - * @throws \Laravel\SerializableClosure\Exceptions\InvalidSignatureException - */ - public function __unserialize($signature) - { - if (static::$signer && ! static::$signer->verify($signature)) { - throw new InvalidSignatureException(); - } - - /** @var \Laravel\SerializableClosure\Contracts\Serializable $serializable */ - $serializable = unserialize($signature['serializable']); - - $this->closure = $serializable->getClosure(); - } -} diff --git a/vendor/laravel/serializable-closure/src/Signers/Hmac.php b/vendor/laravel/serializable-closure/src/Signers/Hmac.php deleted file mode 100644 index d94b0a2..0000000 --- a/vendor/laravel/serializable-closure/src/Signers/Hmac.php +++ /dev/null @@ -1,53 +0,0 @@ -secret = $secret; - } - - /** - * Sign the given serializable. - * - * @param string $serialized - * @return array - */ - public function sign($serialized) - { - return [ - 'serializable' => $serialized, - 'hash' => base64_encode(hash_hmac('sha256', $serialized, $this->secret, true)), - ]; - } - - /** - * Verify the given signature. - * - * @param array $signature - * @return bool - */ - public function verify($signature) - { - return hash_equals(base64_encode( - hash_hmac('sha256', $signature['serializable'], $this->secret, true) - ), $signature['hash']); - } -} diff --git a/vendor/laravel/serializable-closure/src/Support/ClosureScope.php b/vendor/laravel/serializable-closure/src/Support/ClosureScope.php deleted file mode 100644 index 64ca19a..0000000 --- a/vendor/laravel/serializable-closure/src/Support/ClosureScope.php +++ /dev/null @@ -1,22 +0,0 @@ -content = "length = strlen($this->content); - - return true; - } - - /** - * Read from stream. - * - * @param int $count - * @return string - */ - public function stream_read($count) - { - $value = substr($this->content, $this->pointer, $count); - - $this->pointer += $count; - - return $value; - } - - /** - * Tests for end-of-file on a file pointer. - * - * @return bool - */ - public function stream_eof() - { - return $this->pointer >= $this->length; - } - - /** - * Change stream options. - * - * @param int $option - * @param int $arg1 - * @param int $arg2 - * @return bool - */ - public function stream_set_option($option, $arg1, $arg2) - { - return false; - } - - /** - * Retrieve information about a file resource. - * - * @return array|bool - */ - public function stream_stat() - { - $stat = stat(__FILE__); - // @phpstan-ignore-next-line - $stat[7] = $stat['size'] = $this->length; - - return $stat; - } - - /** - * Retrieve information about a file. - * - * @param string $path - * @param int $flags - * @return array|bool - */ - public function url_stat($path, $flags) - { - $stat = stat(__FILE__); - // @phpstan-ignore-next-line - $stat[7] = $stat['size'] = $this->length; - - return $stat; - } - - /** - * Seeks to specific location in a stream. - * - * @param int $offset - * @param int $whence - * @return bool - */ - public function stream_seek($offset, $whence = SEEK_SET) - { - $crt = $this->pointer; - - switch ($whence) { - case SEEK_SET: - $this->pointer = $offset; - break; - case SEEK_CUR: - $this->pointer += $offset; - break; - case SEEK_END: - $this->pointer = $this->length + $offset; - break; - } - - if ($this->pointer < 0 || $this->pointer >= $this->length) { - $this->pointer = $crt; - - return false; - } - - return true; - } - - /** - * Retrieve the current position of a stream. - * - * @return int - */ - public function stream_tell() - { - return $this->pointer; - } - - /** - * Registers the stream. - * - * @return void - */ - public static function register() - { - if (! static::$isRegistered) { - static::$isRegistered = stream_wrapper_register(static::STREAM_PROTO, __CLASS__); - } - } -} diff --git a/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php b/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php deleted file mode 100644 index a0d3707..0000000 --- a/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php +++ /dev/null @@ -1,1195 +0,0 @@ -isStaticClosure === null) { - $this->isStaticClosure = strtolower(substr($this->getCode(), 0, 6)) === 'static'; - } - - return $this->isStaticClosure; - } - - /** - * Checks if the closure is a "short closure". - * - * @return bool - */ - public function isShortClosure() - { - if ($this->isShortClosure === null) { - $code = $this->getCode(); - - if ($this->isStatic()) { - $code = substr($code, 6); - } - - $this->isShortClosure = strtolower(substr(trim($code), 0, 2)) === 'fn'; - } - - return $this->isShortClosure; - } - - /** - * Get the closure's code. - * - * @return string - */ - public function getCode() - { - if ($this->code !== null) { - return $this->code; - } - - $fileName = $this->getFileName(); - $line = $this->getStartLine() - 1; - - $className = null; - - if (null !== $className = $this->getClosureScopeClass()) { - $className = '\\'.trim($className->getName(), '\\'); - } - - $builtin_types = self::getBuiltinTypes(); - $class_keywords = ['self', 'static', 'parent']; - - $ns = $this->getClosureNamespaceName(); - $nsf = $ns == '' ? '' : ($ns[0] == '\\' ? $ns : '\\'.$ns); - - $_file = var_export($fileName, true); - $_dir = var_export(dirname($fileName), true); - $_namespace = var_export($ns, true); - $_class = var_export(trim($className ?: '', '\\'), true); - $_function = $ns.($ns == '' ? '' : '\\').'{closure}'; - $_method = ($className == '' ? '' : trim($className, '\\').'::').$_function; - $_function = var_export($_function, true); - $_method = var_export($_method, true); - $_trait = null; - - $tokens = $this->getTokens(); - $state = $lastState = 'start'; - $inside_structure = false; - $isFirstClassCallable = false; - $isShortClosure = false; - - $inside_structure_mark = 0; - $open = 0; - $code = ''; - $id_start = $id_start_ci = $id_name = $context = ''; - $classes = $functions = $constants = null; - $use = []; - $lineAdd = 0; - $isUsingScope = false; - $isUsingThisObject = false; - - for ($i = 0, $l = count($tokens); $i < $l; $i++) { - $token = $tokens[$i]; - - switch ($state) { - case 'start': - if ($token[0] === T_FUNCTION || $token[0] === T_STATIC) { - $code .= $token[1]; - - $state = $token[0] === T_FUNCTION ? 'function' : 'static'; - } elseif ($token[0] === T_FN) { - $isShortClosure = true; - $code .= $token[1]; - $state = 'closure_args'; - } elseif ($token[0] === T_PUBLIC || $token[0] === T_PROTECTED || $token[0] === T_PRIVATE) { - $code = ''; - $isFirstClassCallable = true; - } - break; - case 'static': - if ($token[0] === T_WHITESPACE || $token[0] === T_COMMENT || $token[0] === T_FUNCTION) { - $code .= $token[1]; - if ($token[0] === T_FUNCTION) { - $state = 'function'; - } - } elseif ($token[0] === T_FN) { - $isShortClosure = true; - $code .= $token[1]; - $state = 'closure_args'; - } else { - $code = ''; - $state = 'start'; - } - break; - case 'function': - switch ($token[0]) { - case T_STRING: - if ($isFirstClassCallable) { - $state = 'closure_args'; - break; - } - - $code = ''; - $state = 'named_function'; - break; - case '(': - $code .= '('; - $state = 'closure_args'; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - } - break; - case 'named_function': - if ($token[0] === T_FUNCTION || $token[0] === T_STATIC) { - $code = $token[1]; - $state = $token[0] === T_FUNCTION ? 'function' : 'static'; - } elseif ($token[0] === T_FN) { - $isShortClosure = true; - $code .= $token[1]; - $state = 'closure_args'; - } - break; - case 'closure_args': - switch ($token[0]) { - case T_NAME_QUALIFIED: - [$id_start, $id_start_ci, $id_name] = $this->parseNameQualified($token[1]); - $context = 'args'; - $state = 'id_name'; - $lastState = 'closure_args'; - break; - case T_NS_SEPARATOR: - case T_STRING: - $id_start = $token[1]; - $id_start_ci = strtolower($id_start); - $id_name = ''; - $context = 'args'; - $state = 'id_name'; - $lastState = 'closure_args'; - break; - case T_USE: - $code .= $token[1]; - $state = 'use'; - break; - case T_DOUBLE_ARROW: - $code .= $token[1]; - if ($isShortClosure) { - $state = 'closure'; - } - break; - case ':': - $code .= ':'; - $state = 'return'; - break; - case '{': - $code .= '{'; - $state = 'closure'; - $open++; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - } - break; - case 'use': - switch ($token[0]) { - case T_VARIABLE: - $use[] = substr($token[1], 1); - $code .= $token[1]; - break; - case '{': - $code .= '{'; - $state = 'closure'; - $open++; - break; - case ':': - $code .= ':'; - $state = 'return'; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - break; - } - break; - case 'return': - switch ($token[0]) { - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - $code .= $token[1]; - break; - case T_NS_SEPARATOR: - case T_STRING: - $id_start = $token[1]; - $id_start_ci = strtolower($id_start); - $id_name = ''; - $context = 'return_type'; - $state = 'id_name'; - $lastState = 'return'; - break 2; - case T_NAME_QUALIFIED: - [$id_start, $id_start_ci, $id_name] = $this->parseNameQualified($token[1]); - $context = 'return_type'; - $state = 'id_name'; - $lastState = 'return'; - break 2; - case T_DOUBLE_ARROW: - $code .= $token[1]; - if ($isShortClosure) { - $state = 'closure'; - } - break; - case '{': - $code .= '{'; - $state = 'closure'; - $open++; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - break; - } - break; - case 'closure': - switch ($token[0]) { - case T_CURLY_OPEN: - case T_DOLLAR_OPEN_CURLY_BRACES: - case '{': - $code .= is_array($token) ? $token[1] : $token; - $open++; - break; - case '}': - $code .= '}'; - if (--$open === 0 && ! $isShortClosure) { - break 3; - } elseif ($inside_structure) { - $inside_structure = ! ($open === $inside_structure_mark); - } - break; - case '(': - case '[': - $code .= $token[0]; - if ($isShortClosure) { - $open++; - } - break; - case ')': - case ']': - if ($isShortClosure) { - if ($open === 0) { - break 3; - } - $open--; - } - $code .= $token[0]; - break; - case ',': - case ';': - if ($isShortClosure && $open === 0) { - break 3; - } - $code .= $token[0]; - break; - case T_LINE: - $code .= $token[2] - $line + $lineAdd; - break; - case T_FILE: - $code .= $_file; - break; - case T_DIR: - $code .= $_dir; - break; - case T_NS_C: - $code .= $_namespace; - break; - case T_CLASS_C: - $code .= $inside_structure ? $token[1] : $_class; - break; - case T_FUNC_C: - $code .= $inside_structure ? $token[1] : $_function; - break; - case T_METHOD_C: - $code .= $inside_structure ? $token[1] : $_method; - break; - case T_COMMENT: - if (substr($token[1], 0, 8) === '#trackme') { - $timestamp = time(); - $code .= '/**'.PHP_EOL; - $code .= '* Date : '.date(DATE_W3C, $timestamp).PHP_EOL; - $code .= '* Timestamp : '.$timestamp.PHP_EOL; - $code .= '* Line : '.($line + 1).PHP_EOL; - $code .= '* File : '.$_file.PHP_EOL.'*/'.PHP_EOL; - $lineAdd += 5; - } else { - $code .= $token[1]; - } - break; - case T_VARIABLE: - if ($token[1] == '$this' && ! $inside_structure) { - $isUsingThisObject = true; - } - $code .= $token[1]; - break; - case T_STATIC: - case T_NS_SEPARATOR: - case T_STRING: - $id_start = $token[1]; - $id_start_ci = strtolower($id_start); - $id_name = ''; - $context = 'root'; - $state = 'id_name'; - $lastState = 'closure'; - break 2; - case T_NAME_QUALIFIED: - [$id_start, $id_start_ci, $id_name] = $this->parseNameQualified($token[1]); - $context = 'root'; - $state = 'id_name'; - $lastState = 'closure'; - break 2; - case T_NEW: - $code .= $token[1]; - $context = 'new'; - $state = 'id_start'; - $lastState = 'closure'; - break 2; - case T_USE: - $code .= $token[1]; - $context = 'use'; - $state = 'id_start'; - $lastState = 'closure'; - break; - case T_INSTANCEOF: - case T_INSTEADOF: - $code .= $token[1]; - $context = 'instanceof'; - $state = 'id_start'; - $lastState = 'closure'; - break; - case T_OBJECT_OPERATOR: - case T_NULLSAFE_OBJECT_OPERATOR: - case T_DOUBLE_COLON: - $code .= $token[1]; - $lastState = 'closure'; - $state = 'ignore_next'; - break; - case T_FUNCTION: - $code .= $token[1]; - $state = 'closure_args'; - if (! $inside_structure) { - $inside_structure = true; - $inside_structure_mark = $open; - } - break; - case T_TRAIT_C: - if ($_trait === null) { - $startLine = $this->getStartLine(); - $endLine = $this->getEndLine(); - $structures = $this->getStructures(); - - $_trait = ''; - - foreach ($structures as &$struct) { - if ($struct['type'] === 'trait' && - $struct['start'] <= $startLine && - $struct['end'] >= $endLine - ) { - $_trait = ($ns == '' ? '' : $ns.'\\').$struct['name']; - break; - } - } - - $_trait = var_export($_trait, true); - } - - $code .= $_trait; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - } - break; - case 'ignore_next': - switch ($token[0]) { - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - $code .= $token[1]; - break; - case T_CLASS: - case T_NEW: - case T_STATIC: - case T_VARIABLE: - case T_STRING: - case T_CLASS_C: - case T_FILE: - case T_DIR: - case T_METHOD_C: - case T_FUNC_C: - case T_FUNCTION: - case T_INSTANCEOF: - case T_LINE: - case T_NS_C: - case T_TRAIT_C: - case T_USE: - $code .= $token[1]; - $state = $lastState; - break; - default: - $state = $lastState; - $i--; - } - break; - case 'id_start': - switch ($token[0]) { - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - $code .= $token[1]; - break; - case T_NS_SEPARATOR: - case T_NAME_FULLY_QUALIFIED: - case T_STRING: - case T_STATIC: - $id_start = $token[1]; - $id_start_ci = strtolower($id_start); - $id_name = ''; - $state = 'id_name'; - break 2; - case T_NAME_QUALIFIED: - [$id_start, $id_start_ci, $id_name] = $this->parseNameQualified($token[1]); - $state = 'id_name'; - break 2; - case T_VARIABLE: - $code .= $token[1]; - $state = $lastState; - break; - case T_CLASS: - $code .= $token[1]; - $state = 'anonymous'; - break; - default: - $i--; //reprocess last - $state = 'id_name'; - } - break; - case 'id_name': - switch ($token[0]) { - // named arguments... - case ':': - if ($lastState === 'closure' && $context === 'root') { - $state = 'ignore_next'; - $lastState = 'closure'; - $code .= $id_start.$token; - } - - break; - case T_NAME_QUALIFIED: - case T_NS_SEPARATOR: - case T_STRING: - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - $id_name .= $token[1]; - break; - case '(': - if ($isShortClosure) { - $open++; - } - if ($context === 'new' || false !== strpos($id_name, '\\')) { - if ($id_start_ci === 'self' || $id_start_ci === 'static') { - if (! $inside_structure) { - $isUsingScope = true; - } - } elseif ($id_start !== '\\' && ! in_array($id_start_ci, $class_keywords)) { - if ($classes === null) { - $classes = $this->getClasses(); - } - if (isset($classes[$id_start_ci])) { - $id_start = $classes[$id_start_ci]; - } - if ($id_start[0] !== '\\') { - $id_start = $nsf.'\\'.$id_start; - } - } - } else { - if ($id_start !== '\\') { - if ($functions === null) { - $functions = $this->getFunctions(); - } - if (isset($functions[$id_start_ci])) { - $id_start = $functions[$id_start_ci]; - } elseif ($nsf !== '\\' && function_exists($nsf.'\\'.$id_start)) { - $id_start = $nsf.'\\'.$id_start; - // Cache it to functions array - $functions[$id_start_ci] = $id_start; - } - } - } - $code .= $id_start.$id_name.'('; - $state = $lastState; - break; - case T_VARIABLE: - case T_DOUBLE_COLON: - if ($id_start !== '\\') { - if ($id_start_ci === 'self' || $id_start_ci === 'parent') { - if (! $inside_structure) { - $isUsingScope = true; - } - } elseif ($id_start_ci === 'static') { - if (! $inside_structure) { - $isUsingScope = $token[0] === T_DOUBLE_COLON; - } - } elseif (! (\PHP_MAJOR_VERSION >= 7 && in_array($id_start_ci, $builtin_types))) { - if ($classes === null) { - $classes = $this->getClasses(); - } - if (isset($classes[$id_start_ci])) { - $id_start = $classes[$id_start_ci]; - } - if ($id_start[0] !== '\\') { - $id_start = $nsf.'\\'.$id_start; - } - } - } - - $code .= $id_start.$id_name.$token[1]; - $state = $token[0] === T_DOUBLE_COLON ? 'ignore_next' : $lastState; - break; - default: - if ($id_start !== '\\' && ! defined($id_start)) { - if ($constants === null) { - $constants = $this->getConstants(); - } - if (isset($constants[$id_start])) { - $id_start = $constants[$id_start]; - } elseif ($context === 'new') { - if (in_array($id_start_ci, $class_keywords)) { - if (! $inside_structure) { - $isUsingScope = true; - } - } else { - if ($classes === null) { - $classes = $this->getClasses(); - } - if (isset($classes[$id_start_ci])) { - $id_start = $classes[$id_start_ci]; - } - if ($id_start[0] !== '\\') { - $id_start = $nsf.'\\'.$id_start; - } - } - } elseif ($context === 'use' || - $context === 'instanceof' || - $context === 'args' || - $context === 'return_type' || - $context === 'extends' || - $context === 'root' - ) { - if (in_array($id_start_ci, $class_keywords)) { - if (! $inside_structure && ! $id_start_ci === 'static') { - $isUsingScope = true; - } - } elseif (! (\PHP_MAJOR_VERSION >= 7 && in_array($id_start_ci, $builtin_types))) { - if ($classes === null) { - $classes = $this->getClasses(); - } - if (isset($classes[$id_start_ci])) { - $id_start = $classes[$id_start_ci]; - } - if ($id_start[0] !== '\\') { - $id_start = $nsf.'\\'.$id_start; - } - } - } - } - $code .= $id_start.$id_name; - $state = $lastState; - $i--; //reprocess last token - } - break; - case 'anonymous': - switch ($token[0]) { - case T_NS_SEPARATOR: - case T_STRING: - $id_start = $token[1]; - $id_start_ci = strtolower($id_start); - $id_name = ''; - $state = 'id_name'; - $context = 'extends'; - $lastState = 'anonymous'; - break; - case '{': - $state = 'closure'; - if (! $inside_structure) { - $inside_structure = true; - $inside_structure_mark = $open; - } - $i--; - break; - default: - $code .= is_array($token) ? $token[1] : $token; - } - break; - } - } - - if ($isShortClosure) { - $this->useVariables = $this->getStaticVariables(); - } else { - $this->useVariables = empty($use) ? $use : array_intersect_key($this->getStaticVariables(), array_flip($use)); - } - - $this->isShortClosure = $isShortClosure; - $this->isBindingRequired = $isUsingThisObject; - $this->isScopeRequired = $isUsingScope; - - if (PHP_VERSION_ID >= 80100) { - $attributesCode = array_map(function ($attribute) { - $arguments = $attribute->getArguments(); - - $name = $attribute->getName(); - $arguments = implode(', ', array_map(function ($argument, $key) { - $argument = sprintf("'%s'", str_replace("'", "\\'", $argument)); - - if (is_string($key)) { - $argument = sprintf('%s: %s', $key, $argument); - } - - return $argument; - }, $arguments, array_keys($arguments))); - - return "#[$name($arguments)]"; - }, $this->getAttributes()); - - if (! empty($attributesCode)) { - $code = implode("\n", array_merge($attributesCode, [$code])); - } - } - - $this->code = $code; - - return $this->code; - } - - /** - * Get PHP native built in types. - * - * @return array - */ - protected static function getBuiltinTypes() - { - // PHP 8.1 - if (PHP_VERSION_ID >= 80100) { - return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object', 'mixed', 'false', 'null', 'never']; - } - - // PHP 8 - if (\PHP_MAJOR_VERSION === 8) { - return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object', 'mixed', 'false', 'null']; - } - - // PHP 7 - switch (\PHP_MINOR_VERSION) { - case 0: - return ['array', 'callable', 'string', 'int', 'bool', 'float']; - case 1: - return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void']; - default: - return ['array', 'callable', 'string', 'int', 'bool', 'float', 'iterable', 'void', 'object']; - } - } - - /** - * Gets the use variables by the closure. - * - * @return array - */ - public function getUseVariables() - { - if ($this->useVariables !== null) { - return $this->useVariables; - } - - $tokens = $this->getTokens(); - $use = []; - $state = 'start'; - - foreach ($tokens as &$token) { - $is_array = is_array($token); - - switch ($state) { - case 'start': - if ($is_array && $token[0] === T_USE) { - $state = 'use'; - } - break; - case 'use': - if ($is_array) { - if ($token[0] === T_VARIABLE) { - $use[] = substr($token[1], 1); - } - } elseif ($token == ')') { - break 2; - } - break; - } - } - - $this->useVariables = empty($use) ? $use : array_intersect_key($this->getStaticVariables(), array_flip($use)); - - return $this->useVariables; - } - - /** - * Checks if binding is required. - * - * @return bool - */ - public function isBindingRequired() - { - if ($this->isBindingRequired === null) { - $this->getCode(); - } - - return $this->isBindingRequired; - } - - /** - * Checks if access to the scope is required. - * - * @return bool - */ - public function isScopeRequired() - { - if ($this->isScopeRequired === null) { - $this->getCode(); - } - - return $this->isScopeRequired; - } - - /** - * The the hash of the current file name. - * - * @return string - */ - protected function getHashedFileName() - { - if ($this->hashedName === null) { - $this->hashedName = sha1($this->getFileName()); - } - - return $this->hashedName; - } - - /** - * Get the file tokens. - * - * @return array - */ - protected function getFileTokens() - { - $key = $this->getHashedFileName(); - - if (! isset(static::$files[$key])) { - static::$files[$key] = token_get_all(file_get_contents($this->getFileName())); - } - - return static::$files[$key]; - } - - /** - * Get the tokens. - * - * @return array - */ - protected function getTokens() - { - if ($this->tokens === null) { - $tokens = $this->getFileTokens(); - $startLine = $this->getStartLine(); - $endLine = $this->getEndLine(); - $results = []; - $start = false; - - foreach ($tokens as &$token) { - if (! is_array($token)) { - if ($start) { - $results[] = $token; - } - - continue; - } - - $line = $token[2]; - - if ($line <= $endLine) { - if ($line >= $startLine) { - $start = true; - $results[] = $token; - } - - continue; - } - - break; - } - - $this->tokens = $results; - } - - return $this->tokens; - } - - /** - * Get the classes. - * - * @return array - */ - protected function getClasses() - { - $key = $this->getHashedFileName(); - - if (! isset(static::$classes[$key])) { - $this->fetchItems(); - } - - return static::$classes[$key]; - } - - /** - * Get the functions. - * - * @return array - */ - protected function getFunctions() - { - $key = $this->getHashedFileName(); - - if (! isset(static::$functions[$key])) { - $this->fetchItems(); - } - - return static::$functions[$key]; - } - - /** - * Gets the constants. - * - * @return array - */ - protected function getConstants() - { - $key = $this->getHashedFileName(); - - if (! isset(static::$constants[$key])) { - $this->fetchItems(); - } - - return static::$constants[$key]; - } - - /** - * Get the structures. - * - * @return array - */ - protected function getStructures() - { - $key = $this->getHashedFileName(); - - if (! isset(static::$structures[$key])) { - $this->fetchItems(); - } - - return static::$structures[$key]; - } - - /** - * Fetch the items. - * - * @return void. - */ - protected function fetchItems() - { - $key = $this->getHashedFileName(); - - $classes = []; - $functions = []; - $constants = []; - $structures = []; - $tokens = $this->getFileTokens(); - - $open = 0; - $state = 'start'; - $lastState = ''; - $prefix = ''; - $name = ''; - $alias = ''; - $isFunc = $isConst = false; - - $startLine = $endLine = 0; - $structType = $structName = ''; - $structIgnore = false; - - foreach ($tokens as $token) { - switch ($state) { - case 'start': - switch ($token[0]) { - case T_CLASS: - case T_INTERFACE: - case T_TRAIT: - $state = 'before_structure'; - $startLine = $token[2]; - $structType = $token[0] == T_CLASS - ? 'class' - : ($token[0] == T_INTERFACE ? 'interface' : 'trait'); - break; - case T_USE: - $state = 'use'; - $prefix = $name = $alias = ''; - $isFunc = $isConst = false; - break; - case T_FUNCTION: - $state = 'structure'; - $structIgnore = true; - break; - case T_NEW: - $state = 'new'; - break; - case T_OBJECT_OPERATOR: - case T_DOUBLE_COLON: - $state = 'invoke'; - break; - } - break; - case 'use': - switch ($token[0]) { - case T_FUNCTION: - $isFunc = true; - break; - case T_CONST: - $isConst = true; - break; - case T_NS_SEPARATOR: - $name .= $token[1]; - break; - case T_STRING: - $name .= $token[1]; - $alias = $token[1]; - break; - case T_NAME_QUALIFIED: - $name .= $token[1]; - $pieces = explode('\\', $token[1]); - $alias = end($pieces); - break; - case T_AS: - $lastState = 'use'; - $state = 'alias'; - break; - case '{': - $prefix = $name; - $name = $alias = ''; - $state = 'use-group'; - break; - case ',': - case ';': - if ($name === '' || $name[0] !== '\\') { - $name = '\\'.$name; - } - - if ($alias !== '') { - if ($isFunc) { - $functions[strtolower($alias)] = $name; - } elseif ($isConst) { - $constants[$alias] = $name; - } else { - $classes[strtolower($alias)] = $name; - } - } - $name = $alias = ''; - $state = $token === ';' ? 'start' : 'use'; - break; - } - break; - case 'use-group': - switch ($token[0]) { - case T_NS_SEPARATOR: - $name .= $token[1]; - break; - case T_NAME_QUALIFIED: - $name .= $token[1]; - $pieces = explode('\\', $token[1]); - $alias = end($pieces); - break; - case T_STRING: - $name .= $token[1]; - $alias = $token[1]; - break; - case T_AS: - $lastState = 'use-group'; - $state = 'alias'; - break; - case ',': - case '}': - - if ($prefix === '' || $prefix[0] !== '\\') { - $prefix = '\\'.$prefix; - } - - if ($alias !== '') { - if ($isFunc) { - $functions[strtolower($alias)] = $prefix.$name; - } elseif ($isConst) { - $constants[$alias] = $prefix.$name; - } else { - $classes[strtolower($alias)] = $prefix.$name; - } - } - $name = $alias = ''; - $state = $token === '}' ? 'use' : 'use-group'; - break; - } - break; - case 'alias': - if ($token[0] === T_STRING) { - $alias = $token[1]; - $state = $lastState; - } - break; - case 'new': - switch ($token[0]) { - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - break 2; - case T_CLASS: - $state = 'structure'; - $structIgnore = true; - break; - default: - $state = 'start'; - } - break; - case 'invoke': - switch ($token[0]) { - case T_WHITESPACE: - case T_COMMENT: - case T_DOC_COMMENT: - break 2; - default: - $state = 'start'; - } - break; - case 'before_structure': - if ($token[0] == T_STRING) { - $structName = $token[1]; - $state = 'structure'; - } - break; - case 'structure': - switch ($token[0]) { - case '{': - case T_CURLY_OPEN: - case T_DOLLAR_OPEN_CURLY_BRACES: - $open++; - break; - case '}': - if (--$open == 0) { - if (! $structIgnore) { - $structures[] = [ - 'type' => $structType, - 'name' => $structName, - 'start' => $startLine, - 'end' => $endLine, - ]; - } - $structIgnore = false; - $state = 'start'; - } - break; - default: - if (is_array($token)) { - $endLine = $token[2]; - } - } - break; - } - } - - static::$classes[$key] = $classes; - static::$functions[$key] = $functions; - static::$constants[$key] = $constants; - static::$structures[$key] = $structures; - } - - /** - * Returns the namespace associated to the closure. - * - * @return string - */ - protected function getClosureNamespaceName() - { - $ns = $this->getNamespaceName(); - - // First class callables... - if ($this->getName() !== '{closure}' && empty($ns) && ! is_null($this->getClosureScopeClass())) { - $ns = $this->getClosureScopeClass()->getNamespaceName(); - } - - return $ns; - } - - /** - * Parse the given token. - * - * @param string $token - * @return array - */ - protected function parseNameQualified($token) - { - $pieces = explode('\\', $token); - - $id_start = array_shift($pieces); - - $id_start_ci = strtolower($id_start); - - $id_name = '\\'.implode('\\', $pieces); - - return [$id_start, $id_start_ci, $id_name]; - } -} diff --git a/vendor/laravel/serializable-closure/src/Support/SelfReference.php b/vendor/laravel/serializable-closure/src/Support/SelfReference.php deleted file mode 100644 index 5831950..0000000 --- a/vendor/laravel/serializable-closure/src/Support/SelfReference.php +++ /dev/null @@ -1,24 +0,0 @@ -hash = $hash; - } -} diff --git a/vendor/laravel/serializable-closure/src/UnsignedSerializableClosure.php b/vendor/laravel/serializable-closure/src/UnsignedSerializableClosure.php deleted file mode 100644 index 1588e7c..0000000 --- a/vendor/laravel/serializable-closure/src/UnsignedSerializableClosure.php +++ /dev/null @@ -1,82 +0,0 @@ -serializable = new Serializers\Native($closure); - } - - /** - * Resolve the closure with the given arguments. - * - * @return mixed - */ - public function __invoke() - { - if (\PHP_VERSION_ID < 70400) { - throw new PhpVersionNotSupportedException(); - } - - return call_user_func_array($this->serializable, func_get_args()); - } - - /** - * Gets the closure. - * - * @return \Closure - */ - public function getClosure() - { - if (\PHP_VERSION_ID < 70400) { - throw new PhpVersionNotSupportedException(); - } - - return $this->serializable->getClosure(); - } - - /** - * Get the serializable representation of the closure. - * - * @return array - */ - public function __serialize() - { - return [ - 'serializable' => $this->serializable, - ]; - } - - /** - * Restore the closure after serialization. - * - * @param array $data - * @return void - */ - public function __unserialize($data) - { - $this->serializable = $data['serializable']; - } -} diff --git a/vendor/league/flysystem-cached-adapter/.editorconfig b/vendor/league/flysystem-cached-adapter/.editorconfig deleted file mode 100644 index 153cf3e..0000000 --- a/vendor/league/flysystem-cached-adapter/.editorconfig +++ /dev/null @@ -1,10 +0,0 @@ -; top-most EditorConfig file -root = true - -; Unix-style newlines -[*] -end_of_line = LF - -[*.php] -indent_style = space -indent_size = 4 diff --git a/vendor/league/flysystem-cached-adapter/.gitignore b/vendor/league/flysystem-cached-adapter/.gitignore deleted file mode 100644 index 7aea75f..0000000 --- a/vendor/league/flysystem-cached-adapter/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -coverage -coverage.xml -composer.lock -vendor \ No newline at end of file diff --git a/vendor/league/flysystem-cached-adapter/.php_cs b/vendor/league/flysystem-cached-adapter/.php_cs deleted file mode 100644 index 6643a32..0000000 --- a/vendor/league/flysystem-cached-adapter/.php_cs +++ /dev/null @@ -1,7 +0,0 @@ -level(Symfony\CS\FixerInterface::PSR2_LEVEL) - ->fixers(['-yoda_conditions', 'ordered_use', 'short_array_syntax']) - ->finder(Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__.'/src/')); \ No newline at end of file diff --git a/vendor/league/flysystem-cached-adapter/.scrutinizer.yml b/vendor/league/flysystem-cached-adapter/.scrutinizer.yml deleted file mode 100644 index fa39b52..0000000 --- a/vendor/league/flysystem-cached-adapter/.scrutinizer.yml +++ /dev/null @@ -1,34 +0,0 @@ -filter: - paths: [src/*] -checks: - php: - code_rating: true - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true -tools: - external_code_coverage: - timeout: 900 - runs: 6 - php_code_coverage: false - php_code_sniffer: - config: - standard: PSR2 - filter: - paths: ['src'] - php_loc: - enabled: true - excluded_dirs: [vendor, spec, stubs] - php_cpd: - enabled: true - excluded_dirs: [vendor, spec, stubs] \ No newline at end of file diff --git a/vendor/league/flysystem-cached-adapter/.travis.yml b/vendor/league/flysystem-cached-adapter/.travis.yml deleted file mode 100644 index 6706449..0000000 --- a/vendor/league/flysystem-cached-adapter/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php - -php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - -matrix: - allow_failures: - - php: 5.5 - -env: - - COMPOSER_OPTS="" - - COMPOSER_OPTS="--prefer-lowest" - -install: - - if [[ "${TRAVIS_PHP_VERSION}" == "5.5" ]]; then composer require phpunit/phpunit:^4.8.36 phpspec/phpspec:^2 --prefer-dist --update-with-dependencies; fi - - if [[ "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then composer require phpunit/phpunit:^6.0 --prefer-dist --update-with-dependencies; fi - - travis_retry composer update --prefer-dist $COMPOSER_OPTS - -script: - - vendor/bin/phpspec run - - vendor/bin/phpunit - -after_script: - - wget https://scrutinizer-ci.com/ocular.phar' - - php ocular.phar code-coverage:upload --format=php-clover ./clover/phpunit.xml' diff --git a/vendor/league/flysystem-cached-adapter/clover/.gitignore b/vendor/league/flysystem-cached-adapter/clover/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/vendor/league/flysystem-cached-adapter/clover/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/vendor/league/flysystem-cached-adapter/composer.json b/vendor/league/flysystem-cached-adapter/composer.json deleted file mode 100644 index df7fb7f..0000000 --- a/vendor/league/flysystem-cached-adapter/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "league/flysystem-cached-adapter", - "description": "An adapter decorator to enable meta-data caching.", - "autoload": { - "psr-4": { - "League\\Flysystem\\Cached\\": "src/" - } - }, - "require": { - "league/flysystem": "~1.0", - "psr/cache": "^1.0.0" - }, - "require-dev": { - "phpspec/phpspec": "^3.4", - "phpunit/phpunit": "^5.7", - "mockery/mockery": "~0.9", - "predis/predis": "~1.0", - "tedivm/stash": "~0.12" - }, - "suggest": { - "ext-phpredis": "Pure C implemented extension for PHP" - }, - "license": "MIT", - "authors": [ - { - "name": "frankdejonge", - "email": "info@frenky.net" - } - ] -} diff --git a/vendor/league/flysystem-cached-adapter/phpspec.yml b/vendor/league/flysystem-cached-adapter/phpspec.yml deleted file mode 100644 index 5eabcb2..0000000 --- a/vendor/league/flysystem-cached-adapter/phpspec.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -suites: - cached_adapter_suite: - namespace: League\Flysystem\Cached - psr4_prefix: League\Flysystem\Cached -formatter.name: pretty diff --git a/vendor/league/flysystem-cached-adapter/phpunit.php b/vendor/league/flysystem-cached-adapter/phpunit.php deleted file mode 100644 index d109587..0000000 --- a/vendor/league/flysystem-cached-adapter/phpunit.php +++ /dev/null @@ -1,3 +0,0 @@ - - - - - ./tests/ - - - - - ./src/ - - - - - - - - diff --git a/vendor/league/flysystem-cached-adapter/readme.md b/vendor/league/flysystem-cached-adapter/readme.md deleted file mode 100644 index dd1433d..0000000 --- a/vendor/league/flysystem-cached-adapter/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# Flysystem Cached CachedAdapter - -[![Author](http://img.shields.io/badge/author-@frankdejonge-blue.svg?style=flat-square)](https://twitter.com/frankdejonge) -[![Build Status](https://img.shields.io/travis/thephpleague/flysystem-cached-adapter/master.svg?style=flat-square)](https://travis-ci.org/thephpleague/flysystem-cached-adapter) -[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/thephpleague/flysystem-cached-adapter.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/flysystem-cached-adapter/code-structure) -[![Quality Score](https://img.shields.io/scrutinizer/g/thephpleague/flysystem-cached-adapter.svg?style=flat-square)](https://scrutinizer-ci.com/g/thephpleague/flysystem-cached-adapter) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Packagist Version](https://img.shields.io/packagist/v/league/flysystem-cached-adapter.svg?style=flat-square)](https://packagist.org/packages/league/flysystem-cached-adapter) -[![Total Downloads](https://img.shields.io/packagist/dt/league/flysystem-cached-adapter.svg?style=flat-square)](https://packagist.org/packages/league/flysystem-cached-adapter) - - -The adapter decorator caches metadata and directory listings. - -```bash -composer require league/flysystem-cached-adapter -``` - -## Usage - -[Check out the docs.](https://flysystem.thephpleague.com/docs/advanced/caching/) diff --git a/vendor/league/flysystem-cached-adapter/spec/CachedAdapterSpec.php b/vendor/league/flysystem-cached-adapter/spec/CachedAdapterSpec.php deleted file mode 100644 index 69428d9..0000000 --- a/vendor/league/flysystem-cached-adapter/spec/CachedAdapterSpec.php +++ /dev/null @@ -1,435 +0,0 @@ -adapter = $adapter; - $this->cache = $cache; - $this->cache->load()->shouldBeCalled(); - $this->beConstructedWith($adapter, $cache); - } - - public function it_is_initializable() - { - $this->shouldHaveType('League\Flysystem\Cached\CachedAdapter'); - $this->shouldHaveType('League\Flysystem\AdapterInterface'); - } - - public function it_should_forward_read_streams() - { - $path = 'path.txt'; - $response = ['path' => $path]; - $this->adapter->readStream($path)->willReturn($response); - $this->readStream($path)->shouldbe($response); - } - - public function it_should_cache_writes() - { - $type = 'file'; - $path = 'path.txt'; - $contents = 'contents'; - $config = new Config(); - $response = compact('path', 'contents', 'type'); - $this->adapter->write($path, $contents, $config)->willReturn($response); - $this->cache->updateObject($path, $response, true)->shouldBeCalled(); - $this->write($path, $contents, $config)->shouldBe($response); - } - - public function it_should_cache_streamed_writes() - { - $type = 'file'; - $path = 'path.txt'; - $stream = tmpfile(); - $config = new Config(); - $response = compact('path', 'stream', 'type'); - $this->adapter->writeStream($path, $stream, $config)->willReturn($response); - $this->cache->updateObject($path, ['contents' => false] + $response, true)->shouldBeCalled(); - $this->writeStream($path, $stream, $config)->shouldBe($response); - fclose($stream); - } - - public function it_should_cache_streamed_updates() - { - $type = 'file'; - $path = 'path.txt'; - $stream = tmpfile(); - $config = new Config(); - $response = compact('path', 'stream', 'type'); - $this->adapter->updateStream($path, $stream, $config)->willReturn($response); - $this->cache->updateObject($path, ['contents' => false] + $response, true)->shouldBeCalled(); - $this->updateStream($path, $stream, $config)->shouldBe($response); - fclose($stream); - } - - public function it_should_ignore_failed_writes() - { - $path = 'path.txt'; - $contents = 'contents'; - $config = new Config(); - $this->adapter->write($path, $contents, $config)->willReturn(false); - $this->write($path, $contents, $config)->shouldBe(false); - } - - public function it_should_ignore_failed_streamed_writes() - { - $path = 'path.txt'; - $contents = tmpfile(); - $config = new Config(); - $this->adapter->writeStream($path, $contents, $config)->willReturn(false); - $this->writeStream($path, $contents, $config)->shouldBe(false); - fclose($contents); - } - - public function it_should_cache_updated() - { - $type = 'file'; - $path = 'path.txt'; - $contents = 'contents'; - $config = new Config(); - $response = compact('path', 'contents', 'type'); - $this->adapter->update($path, $contents, $config)->willReturn($response); - $this->cache->updateObject($path, $response, true)->shouldBeCalled(); - $this->update($path, $contents, $config)->shouldBe($response); - } - - public function it_should_ignore_failed_updates() - { - $path = 'path.txt'; - $contents = 'contents'; - $config = new Config(); - $this->adapter->update($path, $contents, $config)->willReturn(false); - $this->update($path, $contents, $config)->shouldBe(false); - } - - public function it_should_ignore_failed_streamed_updates() - { - $path = 'path.txt'; - $contents = tmpfile(); - $config = new Config(); - $this->adapter->updateStream($path, $contents, $config)->willReturn(false); - $this->updateStream($path, $contents, $config)->shouldBe(false); - fclose($contents); - } - - public function it_should_cache_renames() - { - $old = 'old.txt'; - $new = 'new.txt'; - $this->adapter->rename($old, $new)->willReturn(true); - $this->cache->rename($old, $new)->shouldBeCalled(); - $this->rename($old, $new)->shouldBe(true); - } - - public function it_should_ignore_rename_fails() - { - $old = 'old.txt'; - $new = 'new.txt'; - $this->adapter->rename($old, $new)->willReturn(false); - $this->rename($old, $new)->shouldBe(false); - } - - public function it_should_cache_copies() - { - $old = 'old.txt'; - $new = 'new.txt'; - $this->adapter->copy($old, $new)->willReturn(true); - $this->cache->copy($old, $new)->shouldBeCalled(); - $this->copy($old, $new)->shouldBe(true); - } - - public function it_should_ignore_copy_fails() - { - $old = 'old.txt'; - $new = 'new.txt'; - $this->adapter->copy($old, $new)->willReturn(false); - $this->copy($old, $new)->shouldBe(false); - } - - public function it_should_cache_deletes() - { - $delete = 'delete.txt'; - $this->adapter->delete($delete)->willReturn(true); - $this->cache->delete($delete)->shouldBeCalled(); - $this->delete($delete)->shouldBe(true); - } - - public function it_should_ignore_delete_fails() - { - $delete = 'delete.txt'; - $this->adapter->delete($delete)->willReturn(false); - $this->delete($delete)->shouldBe(false); - } - - public function it_should_cache_dir_deletes() - { - $delete = 'delete'; - $this->adapter->deleteDir($delete)->willReturn(true); - $this->cache->deleteDir($delete)->shouldBeCalled(); - $this->deleteDir($delete)->shouldBe(true); - } - - public function it_should_ignore_delete_dir_fails() - { - $delete = 'delete'; - $this->adapter->deleteDir($delete)->willReturn(false); - $this->deleteDir($delete)->shouldBe(false); - } - - public function it_should_cache_dir_creates() - { - $dirname = 'dirname'; - $config = new Config(); - $response = ['path' => $dirname, 'type' => 'dir']; - $this->adapter->createDir($dirname, $config)->willReturn($response); - $this->cache->updateObject($dirname, $response, true)->shouldBeCalled(); - $this->createDir($dirname, $config)->shouldBe($response); - } - - public function it_should_ignore_create_dir_fails() - { - $dirname = 'dirname'; - $config = new Config(); - $this->adapter->createDir($dirname, $config)->willReturn(false); - $this->createDir($dirname, $config)->shouldBe(false); - } - - public function it_should_cache_set_visibility() - { - $path = 'path.txt'; - $visibility = AdapterInterface::VISIBILITY_PUBLIC; - $this->adapter->setVisibility($path, $visibility)->willReturn(true); - $this->cache->updateObject($path, ['path' => $path, 'visibility' => $visibility], true)->shouldBeCalled(); - $this->setVisibility($path, $visibility)->shouldBe(true); - } - - public function it_should_ignore_set_visibility_fails() - { - $dirname = 'delete'; - $visibility = AdapterInterface::VISIBILITY_PUBLIC; - $this->adapter->setVisibility($dirname, $visibility)->willReturn(false); - $this->setVisibility($dirname, $visibility)->shouldBe(false); - } - - public function it_should_indicate_missing_files() - { - $this->cache->has($path = 'path.txt')->willReturn(false); - $this->has($path)->shouldBe(false); - } - - public function it_should_indicate_file_existance() - { - $this->cache->has($path = 'path.txt')->willReturn(true); - $this->has($path)->shouldBe(true); - } - - public function it_should_cache_missing_files() - { - $this->cache->has($path = 'path.txt')->willReturn(null); - $this->adapter->has($path)->willReturn(false); - $this->cache->storeMiss($path)->shouldBeCalled(); - $this->has($path)->shouldBe(false); - } - - public function it_should_delete_when_metadata_is_missing() - { - $path = 'path.txt'; - $this->cache->has($path)->willReturn(true); - $this->cache->getSize($path)->willReturn(['path' => $path]); - $this->adapter->getSize($path)->willReturn($response = ['path' => $path, 'size' => 1024]); - $this->cache->updateObject($path, $response, true)->shouldBeCalled(); - $this->getSize($path)->shouldBe($response); - } - - public function it_should_cache_has() - { - $this->cache->has($path = 'path.txt')->willReturn(null); - $this->adapter->has($path)->willReturn(true); - $this->cache->updateObject($path, compact('path'), true)->shouldBeCalled(); - $this->has($path)->shouldBe(true); - } - - public function it_should_list_cached_contents() - { - $this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(true); - $response = [['path' => 'path.txt']]; - $this->cache->listContents($dirname, $recursive)->willReturn($response); - $this->listContents($dirname, $recursive)->shouldBe($response); - } - - public function it_should_ignore_failed_list_contents() - { - $this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(false); - $this->adapter->listContents($dirname, $recursive)->willReturn(false); - $this->listContents($dirname, $recursive)->shouldBe(false); - } - - public function it_should_cache_contents_listings() - { - $this->cache->isComplete($dirname = 'dirname', $recursive = true)->willReturn(false); - $response = [['path' => 'path.txt']]; - $this->adapter->listContents($dirname, $recursive)->willReturn($response); - $this->cache->storeContents($dirname, $response, $recursive)->shouldBeCalled(); - $this->listContents($dirname, $recursive)->shouldBe($response); - } - - public function it_should_use_cached_visibility() - { - $this->make_it_use_getter_cache('getVisibility', 'path.txt', [ - 'path' => 'path.txt', - 'visibility' => AdapterInterface::VISIBILITY_PUBLIC, - ]); - } - - public function it_should_cache_get_visibility() - { - $path = 'path.txt'; - $response = ['visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'path' => $path]; - $this->make_it_cache_getter('getVisibility', $path, $response); - } - - public function it_should_ignore_failed_get_visibility() - { - $path = 'path.txt'; - $this->make_it_ignore_failed_getter('getVisibility', $path); - } - - public function it_should_use_cached_timestamp() - { - $this->make_it_use_getter_cache('getTimestamp', 'path.txt', [ - 'path' => 'path.txt', - 'timestamp' => 1234, - ]); - } - - public function it_should_cache_timestamps() - { - $this->make_it_cache_getter('getTimestamp', 'path.txt', [ - 'path' => 'path.txt', - 'timestamp' => 1234, - ]); - } - - public function it_should_ignore_failed_get_timestamps() - { - $this->make_it_ignore_failed_getter('getTimestamp', 'path.txt'); - } - - public function it_should_cache_get_metadata() - { - $path = 'path.txt'; - $response = ['visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'path' => $path]; - $this->make_it_cache_getter('getMetadata', $path, $response); - } - - public function it_should_use_cached_metadata() - { - $this->make_it_use_getter_cache('getMetadata', 'path.txt', [ - 'path' => 'path.txt', - 'timestamp' => 1234, - ]); - } - - public function it_should_ignore_failed_get_metadata() - { - $this->make_it_ignore_failed_getter('getMetadata', 'path.txt'); - } - - public function it_should_cache_get_size() - { - $path = 'path.txt'; - $response = ['size' => 1234, 'path' => $path]; - $this->make_it_cache_getter('getSize', $path, $response); - } - - public function it_should_use_cached_size() - { - $this->make_it_use_getter_cache('getSize', 'path.txt', [ - 'path' => 'path.txt', - 'size' => 1234, - ]); - } - - public function it_should_ignore_failed_get_size() - { - $this->make_it_ignore_failed_getter('getSize', 'path.txt'); - } - - public function it_should_cache_get_mimetype() - { - $path = 'path.txt'; - $response = ['mimetype' => 'text/plain', 'path' => $path]; - $this->make_it_cache_getter('getMimetype', $path, $response); - } - - public function it_should_use_cached_mimetype() - { - $this->make_it_use_getter_cache('getMimetype', 'path.txt', [ - 'path' => 'path.txt', - 'mimetype' => 'text/plain', - ]); - } - - public function it_should_ignore_failed_get_mimetype() - { - $this->make_it_ignore_failed_getter('getMimetype', 'path.txt'); - } - - public function it_should_cache_reads() - { - $path = 'path.txt'; - $response = ['path' => $path, 'contents' => 'contents']; - $this->make_it_cache_getter('read', $path, $response); - } - - public function it_should_use_cached_file_contents() - { - $this->make_it_use_getter_cache('read', 'path.txt', [ - 'path' => 'path.txt', - 'contents' => 'contents' - ]); - } - - public function it_should_ignore_failed_reads() - { - $this->make_it_ignore_failed_getter('read', 'path.txt'); - } - - protected function make_it_use_getter_cache($method, $path, $response) - { - $this->cache->{$method}($path)->willReturn($response); - $this->{$method}($path)->shouldBe($response); - } - - protected function make_it_cache_getter($method, $path, $response) - { - $this->cache->{$method}($path)->willReturn(false); - $this->adapter->{$method}($path)->willReturn($response); - $this->cache->updateObject($path, $response, true)->shouldBeCalled(); - $this->{$method}($path)->shouldBe($response); - } - - protected function make_it_ignore_failed_getter($method, $path) - { - $this->cache->{$method}($path)->willReturn(false); - $this->adapter->{$method}($path)->willReturn(false); - $this->{$method}($path)->shouldBe(false); - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/CacheInterface.php b/vendor/league/flysystem-cached-adapter/src/CacheInterface.php deleted file mode 100644 index de3ab3d..0000000 --- a/vendor/league/flysystem-cached-adapter/src/CacheInterface.php +++ /dev/null @@ -1,101 +0,0 @@ -adapter = $adapter; - $this->cache = $cache; - $this->cache->load(); - } - - /** - * Get the underlying Adapter implementation. - * - * @return AdapterInterface - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * Get the used Cache implementation. - * - * @return CacheInterface - */ - public function getCache() - { - return $this->cache; - } - - /** - * {@inheritdoc} - */ - public function write($path, $contents, Config $config) - { - $result = $this->adapter->write($path, $contents, $config); - - if ($result !== false) { - $result['type'] = 'file'; - $this->cache->updateObject($path, $result + compact('path', 'contents'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function writeStream($path, $resource, Config $config) - { - $result = $this->adapter->writeStream($path, $resource, $config); - - if ($result !== false) { - $result['type'] = 'file'; - $contents = false; - $this->cache->updateObject($path, $result + compact('path', 'contents'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function update($path, $contents, Config $config) - { - $result = $this->adapter->update($path, $contents, $config); - - if ($result !== false) { - $result['type'] = 'file'; - $this->cache->updateObject($path, $result + compact('path', 'contents'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function updateStream($path, $resource, Config $config) - { - $result = $this->adapter->updateStream($path, $resource, $config); - - if ($result !== false) { - $result['type'] = 'file'; - $contents = false; - $this->cache->updateObject($path, $result + compact('path', 'contents'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function rename($path, $newPath) - { - $result = $this->adapter->rename($path, $newPath); - - if ($result !== false) { - $this->cache->rename($path, $newPath); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function copy($path, $newpath) - { - $result = $this->adapter->copy($path, $newpath); - - if ($result !== false) { - $this->cache->copy($path, $newpath); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function delete($path) - { - $result = $this->adapter->delete($path); - - if ($result !== false) { - $this->cache->delete($path); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function deleteDir($dirname) - { - $result = $this->adapter->deleteDir($dirname); - - if ($result !== false) { - $this->cache->deleteDir($dirname); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function createDir($dirname, Config $config) - { - $result = $this->adapter->createDir($dirname, $config); - - if ($result !== false) { - $type = 'dir'; - $path = $dirname; - $this->cache->updateObject($dirname, compact('path', 'type'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function setVisibility($path, $visibility) - { - $result = $this->adapter->setVisibility($path, $visibility); - - if ($result !== false) { - $this->cache->updateObject($path, compact('path', 'visibility'), true); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function has($path) - { - $cacheHas = $this->cache->has($path); - - if ($cacheHas !== null) { - return $cacheHas; - } - - $adapterResponse = $this->adapter->has($path); - - if (! $adapterResponse) { - $this->cache->storeMiss($path); - } else { - $cacheEntry = is_array($adapterResponse) ? $adapterResponse : compact('path'); - $this->cache->updateObject($path, $cacheEntry, true); - } - - return $adapterResponse; - } - - /** - * {@inheritdoc} - */ - public function read($path) - { - return $this->callWithFallback('contents', $path, 'read'); - } - - /** - * {@inheritdoc} - */ - public function readStream($path) - { - return $this->adapter->readStream($path); - } - - /** - * Get the path prefix. - * - * @return string|null path prefix or null if pathPrefix is empty - */ - public function getPathPrefix() - { - return $this->adapter->getPathPrefix(); - } - - /** - * Prefix a path. - * - * @param string $path - * - * @return string prefixed path - */ - public function applyPathPrefix($path) - { - return $this->adapter->applyPathPrefix($path); - } - - /** - * {@inheritdoc} - */ - public function listContents($directory = '', $recursive = false) - { - if ($this->cache->isComplete($directory, $recursive)) { - return $this->cache->listContents($directory, $recursive); - } - - $result = $this->adapter->listContents($directory, $recursive); - - if ($result !== false) { - $this->cache->storeContents($directory, $result, $recursive); - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function getMetadata($path) - { - return $this->callWithFallback(null, $path, 'getMetadata'); - } - - /** - * {@inheritdoc} - */ - public function getSize($path) - { - return $this->callWithFallback('size', $path, 'getSize'); - } - - /** - * {@inheritdoc} - */ - public function getMimetype($path) - { - return $this->callWithFallback('mimetype', $path, 'getMimetype'); - } - - /** - * {@inheritdoc} - */ - public function getTimestamp($path) - { - return $this->callWithFallback('timestamp', $path, 'getTimestamp'); - } - - /** - * {@inheritdoc} - */ - public function getVisibility($path) - { - return $this->callWithFallback('visibility', $path, 'getVisibility'); - } - - /** - * Call a method and cache the response. - * - * @param string $property - * @param string $path - * @param string $method - * - * @return mixed - */ - protected function callWithFallback($property, $path, $method) - { - $result = $this->cache->{$method}($path); - - if ($result !== false && ($property === null || array_key_exists($property, $result))) { - return $result; - } - - $result = $this->adapter->{$method}($path); - - if ($result) { - $object = $result + compact('path'); - $this->cache->updateObject($path, $object, true); - } - - return $result; - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/AbstractCache.php b/vendor/league/flysystem-cached-adapter/src/Storage/AbstractCache.php deleted file mode 100644 index 141b468..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/AbstractCache.php +++ /dev/null @@ -1,418 +0,0 @@ -autosave) { - $this->save(); - } - } - - /** - * Get the autosave setting. - * - * @return bool autosave - */ - public function getAutosave() - { - return $this->autosave; - } - - /** - * Get the autosave setting. - * - * @param bool $autosave - */ - public function setAutosave($autosave) - { - $this->autosave = $autosave; - } - - /** - * Store the contents listing. - * - * @param string $directory - * @param array $contents - * @param bool $recursive - * - * @return array contents listing - */ - public function storeContents($directory, array $contents, $recursive = false) - { - $directories = [$directory]; - - foreach ($contents as $object) { - $this->updateObject($object['path'], $object); - $object = $this->cache[$object['path']]; - - if ($recursive && $this->pathIsInDirectory($directory, $object['path'])) { - $directories[] = $object['dirname']; - } - } - - foreach (array_unique($directories) as $directory) { - $this->setComplete($directory, $recursive); - } - - $this->autosave(); - } - - /** - * Update the metadata for an object. - * - * @param string $path object path - * @param array $object object metadata - * @param bool $autosave whether to trigger the autosave routine - */ - public function updateObject($path, array $object, $autosave = false) - { - if (! $this->has($path)) { - $this->cache[$path] = Util::pathinfo($path); - } - - $this->cache[$path] = array_merge($this->cache[$path], $object); - - if ($autosave) { - $this->autosave(); - } - - $this->ensureParentDirectories($path); - } - - /** - * Store object hit miss. - * - * @param string $path - */ - public function storeMiss($path) - { - $this->cache[$path] = false; - $this->autosave(); - } - - /** - * Get the contents listing. - * - * @param string $dirname - * @param bool $recursive - * - * @return array contents listing - */ - public function listContents($dirname = '', $recursive = false) - { - $result = []; - - foreach ($this->cache as $object) { - if ($object === false) { - continue; - } - if ($object['dirname'] === $dirname) { - $result[] = $object; - } elseif ($recursive && $this->pathIsInDirectory($dirname, $object['path'])) { - $result[] = $object; - } - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function has($path) - { - if ($path !== false && array_key_exists($path, $this->cache)) { - return $this->cache[$path] !== false; - } - - if ($this->isComplete(Util::dirname($path), false)) { - return false; - } - } - - /** - * {@inheritdoc} - */ - public function read($path) - { - if (isset($this->cache[$path]['contents']) && $this->cache[$path]['contents'] !== false) { - return $this->cache[$path]; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function readStream($path) - { - return false; - } - - /** - * {@inheritdoc} - */ - public function rename($path, $newpath) - { - if ($this->has($path)) { - $object = $this->cache[$path]; - unset($this->cache[$path]); - $object['path'] = $newpath; - $object = array_merge($object, Util::pathinfo($newpath)); - $this->cache[$newpath] = $object; - $this->autosave(); - } - } - - /** - * {@inheritdoc} - */ - public function copy($path, $newpath) - { - if ($this->has($path)) { - $object = $this->cache[$path]; - $object = array_merge($object, Util::pathinfo($newpath)); - $this->updateObject($newpath, $object, true); - } - } - - /** - * {@inheritdoc} - */ - public function delete($path) - { - $this->storeMiss($path); - } - - /** - * {@inheritdoc} - */ - public function deleteDir($dirname) - { - foreach ($this->cache as $path => $object) { - if ($this->pathIsInDirectory($dirname, $path) || $path === $dirname) { - unset($this->cache[$path]); - } - } - - unset($this->complete[$dirname]); - - $this->autosave(); - } - - /** - * {@inheritdoc} - */ - public function getMimetype($path) - { - if (isset($this->cache[$path]['mimetype'])) { - return $this->cache[$path]; - } - - if (! $result = $this->read($path)) { - return false; - } - - $mimetype = Util::guessMimeType($path, $result['contents']); - $this->cache[$path]['mimetype'] = $mimetype; - - return $this->cache[$path]; - } - - /** - * {@inheritdoc} - */ - public function getSize($path) - { - if (isset($this->cache[$path]['size'])) { - return $this->cache[$path]; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getTimestamp($path) - { - if (isset($this->cache[$path]['timestamp'])) { - return $this->cache[$path]; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getVisibility($path) - { - if (isset($this->cache[$path]['visibility'])) { - return $this->cache[$path]; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getMetadata($path) - { - if (isset($this->cache[$path]['type'])) { - return $this->cache[$path]; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function isComplete($dirname, $recursive) - { - if (! array_key_exists($dirname, $this->complete)) { - return false; - } - - if ($recursive && $this->complete[$dirname] !== 'recursive') { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function setComplete($dirname, $recursive) - { - $this->complete[$dirname] = $recursive ? 'recursive' : true; - } - - /** - * Filter the contents from a listing. - * - * @param array $contents object listing - * - * @return array filtered contents - */ - public function cleanContents(array $contents) - { - $cachedProperties = array_flip([ - 'path', 'dirname', 'basename', 'extension', 'filename', - 'size', 'mimetype', 'visibility', 'timestamp', 'type', - 'md5', - ]); - - foreach ($contents as $path => $object) { - if (is_array($object)) { - $contents[$path] = array_intersect_key($object, $cachedProperties); - } - } - - return $contents; - } - - /** - * {@inheritdoc} - */ - public function flush() - { - $this->cache = []; - $this->complete = []; - $this->autosave(); - } - - /** - * {@inheritdoc} - */ - public function autosave() - { - if ($this->autosave) { - $this->save(); - } - } - - /** - * Retrieve serialized cache data. - * - * @return string serialized data - */ - public function getForStorage() - { - $cleaned = $this->cleanContents($this->cache); - - return json_encode([$cleaned, $this->complete]); - } - - /** - * Load from serialized cache data. - * - * @param string $json - */ - public function setFromStorage($json) - { - list($cache, $complete) = json_decode($json, true); - - if (json_last_error() === JSON_ERROR_NONE && is_array($cache) && is_array($complete)) { - $this->cache = $cache; - $this->complete = $complete; - } - } - - /** - * Ensure parent directories of an object. - * - * @param string $path object path - */ - public function ensureParentDirectories($path) - { - $object = $this->cache[$path]; - - while ($object['dirname'] !== '' && ! isset($this->cache[$object['dirname']])) { - $object = Util::pathinfo($object['dirname']); - $object['type'] = 'dir'; - $this->cache[$object['path']] = $object; - } - } - - /** - * Determines if the path is inside the directory. - * - * @param string $directory - * @param string $path - * - * @return bool - */ - protected function pathIsInDirectory($directory, $path) - { - return $directory === '' || strpos($path, $directory . '/') === 0; - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Adapter.php b/vendor/league/flysystem-cached-adapter/src/Storage/Adapter.php deleted file mode 100644 index 649a60e..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Adapter.php +++ /dev/null @@ -1,115 +0,0 @@ -adapter = $adapter; - $this->file = $file; - $this->setExpire($expire); - } - - /** - * Set the expiration time in seconds. - * - * @param int $expire relative expiration time - */ - protected function setExpire($expire) - { - if ($expire) { - $this->expire = $this->getTime($expire); - } - } - - /** - * Get expiration time in seconds. - * - * @param int $time relative expiration time - * - * @return int actual expiration time - */ - protected function getTime($time = 0) - { - return intval(microtime(true)) + $time; - } - - /** - * {@inheritdoc} - */ - public function setFromStorage($json) - { - list($cache, $complete, $expire) = json_decode($json, true); - - if (! $expire || $expire > $this->getTime()) { - $this->cache = is_array($cache) ? $cache : []; - $this->complete = is_array($complete) ? $complete : []; - } else { - $this->adapter->delete($this->file); - } - } - - /** - * {@inheritdoc} - */ - public function load() - { - if ($this->adapter->has($this->file)) { - $file = $this->adapter->read($this->file); - if ($file && !empty($file['contents'])) { - $this->setFromStorage($file['contents']); - } - } - } - - /** - * {@inheritdoc} - */ - public function getForStorage() - { - $cleaned = $this->cleanContents($this->cache); - - return json_encode([$cleaned, $this->complete, $this->expire]); - } - - /** - * {@inheritdoc} - */ - public function save() - { - $config = new Config(); - $contents = $this->getForStorage(); - - if ($this->adapter->has($this->file)) { - $this->adapter->update($this->file, $contents, $config); - } else { - $this->adapter->write($this->file, $contents, $config); - } - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Memcached.php b/vendor/league/flysystem-cached-adapter/src/Storage/Memcached.php deleted file mode 100644 index f67d271..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Memcached.php +++ /dev/null @@ -1,59 +0,0 @@ -key = $key; - $this->expire = $expire; - $this->memcached = $memcached; - } - - /** - * {@inheritdoc} - */ - public function load() - { - $contents = $this->memcached->get($this->key); - - if ($contents !== false) { - $this->setFromStorage($contents); - } - } - - /** - * {@inheritdoc} - */ - public function save() - { - $contents = $this->getForStorage(); - $expiration = $this->expire === null ? 0 : time() + $this->expire; - $this->memcached->set($this->key, $contents, $expiration); - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Memory.php b/vendor/league/flysystem-cached-adapter/src/Storage/Memory.php deleted file mode 100644 index d0914fa..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Memory.php +++ /dev/null @@ -1,22 +0,0 @@ -client = $client ?: new Redis(); - $this->key = $key; - $this->expire = $expire; - } - - /** - * {@inheritdoc} - */ - public function load() - { - $contents = $this->client->get($this->key); - - if ($contents !== false) { - $this->setFromStorage($contents); - } - } - - /** - * {@inheritdoc} - */ - public function save() - { - $contents = $this->getForStorage(); - $this->client->set($this->key, $contents); - - if ($this->expire !== null) { - $this->client->expire($this->key, $this->expire); - } - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Predis.php b/vendor/league/flysystem-cached-adapter/src/Storage/Predis.php deleted file mode 100644 index 8a29574..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Predis.php +++ /dev/null @@ -1,75 +0,0 @@ -client = $client ?: new Client(); - $this->key = $key; - $this->expire = $expire; - } - - /** - * {@inheritdoc} - */ - public function load() - { - if (($contents = $this->executeCommand('get', [$this->key])) !== null) { - $this->setFromStorage($contents); - } - } - - /** - * {@inheritdoc} - */ - public function save() - { - $contents = $this->getForStorage(); - $this->executeCommand('set', [$this->key, $contents]); - - if ($this->expire !== null) { - $this->executeCommand('expire', [$this->key, $this->expire]); - } - } - - /** - * Execute a Predis command. - * - * @param string $name - * @param array $arguments - * - * @return string - */ - protected function executeCommand($name, array $arguments) - { - $command = $this->client->createCommand($name, $arguments); - - return $this->client->executeCommand($command); - } -} diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Psr6Cache.php b/vendor/league/flysystem-cached-adapter/src/Storage/Psr6Cache.php deleted file mode 100644 index 43be87e..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Psr6Cache.php +++ /dev/null @@ -1,59 +0,0 @@ -pool = $pool; - $this->key = $key; - $this->expire = $expire; - } - - /** - * {@inheritdoc} - */ - public function save() - { - $item = $this->pool->getItem($this->key); - $item->set($this->getForStorage()); - $item->expiresAfter($this->expire); - $this->pool->save($item); - } - - /** - * {@inheritdoc} - */ - public function load() - { - $item = $this->pool->getItem($this->key); - if ($item->isHit()) { - $this->setFromStorage($item->get()); - } - } -} \ No newline at end of file diff --git a/vendor/league/flysystem-cached-adapter/src/Storage/Stash.php b/vendor/league/flysystem-cached-adapter/src/Storage/Stash.php deleted file mode 100644 index e05b832..0000000 --- a/vendor/league/flysystem-cached-adapter/src/Storage/Stash.php +++ /dev/null @@ -1,60 +0,0 @@ -key = $key; - $this->expire = $expire; - $this->pool = $pool; - } - - /** - * {@inheritdoc} - */ - public function load() - { - $item = $this->pool->getItem($this->key); - $contents = $item->get(); - - if ($item->isMiss() === false) { - $this->setFromStorage($contents); - } - } - - /** - * {@inheritdoc} - */ - public function save() - { - $contents = $this->getForStorage(); - $item = $this->pool->getItem($this->key); - $item->set($contents, $this->expire); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/AdapterCacheTests.php b/vendor/league/flysystem-cached-adapter/tests/AdapterCacheTests.php deleted file mode 100644 index b63cba7..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/AdapterCacheTests.php +++ /dev/null @@ -1,104 +0,0 @@ -shouldReceive('has')->once()->with('file.json')->andReturn(false); - $cache = new Adapter($adapter, 'file.json', 10); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadExpired() - { - $response = ['contents' => json_encode([[], ['' => true], 1234567890]), 'path' => 'file.json']; - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true); - $adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response); - $adapter->shouldReceive('delete')->once()->with('file.json'); - $cache = new Adapter($adapter, 'file.json', 10); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = ['contents' => json_encode([[], ['' => true], 9876543210]), 'path' => 'file.json']; - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true); - $adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response); - $cache = new Adapter($adapter, 'file.json', 10); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSaveExists() - { - $response = json_encode([[], [], null]); - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true); - $adapter->shouldReceive('update')->once()->with('file.json', $response, Mockery::any()); - $cache = new Adapter($adapter, 'file.json', null); - $cache->save(); - } - - public function testSaveNew() - { - $response = json_encode([[], [], null]); - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->once()->with('file.json')->andReturn(false); - $adapter->shouldReceive('write')->once()->with('file.json', $response, Mockery::any()); - $cache = new Adapter($adapter, 'file.json', null); - $cache->save(); - } - - public function testStoreContentsRecursive() - { - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->once()->with('file.json')->andReturn(false); - $adapter->shouldReceive('write')->once()->with('file.json', Mockery::any(), Mockery::any()); - - $cache = new Adapter($adapter, 'file.json', null); - - $contents = [ - ['path' => 'foo/bar', 'dirname' => 'foo'], - ['path' => 'afoo/bang', 'dirname' => 'afoo'], - ]; - - $cache->storeContents('foo', $contents, true); - - $this->assertTrue($cache->isComplete('foo', true)); - $this->assertFalse($cache->isComplete('afoo', true)); - } - - public function testDeleteDir() - { - $cache_data = [ - 'foo' => ['path' => 'foo', 'type' => 'dir', 'dirname' => ''], - 'foo/bar' => ['path' => 'foo/bar', 'type' => 'file', 'dirname' => 'foo'], - 'foobaz' => ['path' => 'foobaz', 'type' => 'file', 'dirname' => ''], - ]; - - $response = [ - 'contents' => json_encode([$cache_data, [], null]), - 'path' => 'file.json', - ]; - - $adapter = Mockery::mock('League\Flysystem\AdapterInterface'); - $adapter->shouldReceive('has')->zeroOrMoreTimes()->with('file.json')->andReturn(true); - $adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response); - $adapter->shouldReceive('update')->once()->with('file.json', Mockery::any(), Mockery::any())->andReturn(true); - - $cache = new Adapter($adapter, 'file.json', null); - $cache->load(); - - $cache->deleteDir('foo', true); - - $this->assertSame(1, count($cache->listContents('', true))); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/InspectionTests.php b/vendor/league/flysystem-cached-adapter/tests/InspectionTests.php deleted file mode 100644 index 40d4c91..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/InspectionTests.php +++ /dev/null @@ -1,16 +0,0 @@ -shouldReceive('load')->once(); - $cached_adapter = new CachedAdapter($adapter, $cache); - $this->assertInstanceOf('League\Flysystem\AdapterInterface', $cached_adapter->getAdapter()); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/MemcachedTests.php b/vendor/league/flysystem-cached-adapter/tests/MemcachedTests.php deleted file mode 100644 index e3d9ad9..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/MemcachedTests.php +++ /dev/null @@ -1,35 +0,0 @@ -shouldReceive('get')->once()->andReturn(false); - $cache = new Memcached($client); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = json_encode([[], ['' => true]]); - $client = Mockery::mock('Memcached'); - $client->shouldReceive('get')->once()->andReturn($response); - $cache = new Memcached($client); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSave() - { - $response = json_encode([[], []]); - $client = Mockery::mock('Memcached'); - $client->shouldReceive('set')->once()->andReturn($response); - $cache = new Memcached($client); - $cache->save(); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/MemoryCacheTests.php b/vendor/league/flysystem-cached-adapter/tests/MemoryCacheTests.php deleted file mode 100644 index 3ac58fd..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/MemoryCacheTests.php +++ /dev/null @@ -1,255 +0,0 @@ -setAutosave(true); - $this->assertTrue($cache->getAutosave()); - $cache->setAutosave(false); - $this->assertFalse($cache->getAutosave()); - } - - public function testCacheMiss() - { - $cache = new Memory(); - $cache->storeMiss('path.txt'); - $this->assertFalse($cache->has('path.txt')); - } - - public function testIsComplete() - { - $cache = new Memory(); - $this->assertFalse($cache->isComplete('dirname', false)); - $cache->setComplete('dirname', false); - $this->assertFalse($cache->isComplete('dirname', true)); - $cache->setComplete('dirname', true); - $this->assertTrue($cache->isComplete('dirname', true)); - } - - public function testCleanContents() - { - $cache = new Memory(); - $input = [[ - 'path' => 'path.txt', - 'visibility' => 'public', - 'invalid' => 'thing', - ]]; - - $expected = [[ - 'path' => 'path.txt', - 'visibility' => 'public', - ]]; - - $output = $cache->cleanContents($input); - $this->assertEquals($expected, $output); - } - - public function testGetForStorage() - { - $cache = new Memory(); - $input = [[ - 'path' => 'path.txt', - 'visibility' => 'public', - 'type' => 'file', - ]]; - - $cache->storeContents('', $input, true); - $contents = $cache->listContents('', true); - $cached = []; - foreach ($contents as $item) { - $cached[$item['path']] = $item; - } - - $this->assertEquals(json_encode([$cached, ['' => 'recursive']]), $cache->getForStorage()); - } - - public function testParentCompleteIsUsedDuringHas() - { - $cache = new Memory(); - $cache->setComplete('dirname', false); - $this->assertFalse($cache->has('dirname/path.txt')); - } - - public function testFlush() - { - $cache = new Memory(); - $cache->setComplete('dirname', true); - $cache->updateObject('path.txt', [ - 'path' => 'path.txt', - 'visibility' => 'public', - ]); - $cache->flush(); - $this->assertFalse($cache->isComplete('dirname', true)); - $this->assertNull($cache->has('path.txt')); - } - - public function testSetFromStorage() - { - $cache = new Memory(); - $json = [[ - 'path.txt' => ['path' => 'path.txt', 'type' => 'file'], - ], ['dirname' => 'recursive']]; - $jsonString = json_encode($json); - $cache->setFromStorage($jsonString); - $this->assertTrue($cache->has('path.txt')); - $this->assertTrue($cache->isComplete('dirname', true)); - } - - public function testGetMetadataFail() - { - $cache = new Memory(); - $this->assertFalse($cache->getMetadata('path.txt')); - } - - public function metaGetterProvider() - { - return [ - ['getTimestamp', 'timestamp', 12344], - ['getMimetype', 'mimetype', 'text/plain'], - ['getSize', 'size', 12], - ['getVisibility', 'visibility', 'private'], - ['read', 'contents', '__contents__'], - ]; - } - - /** - * @dataProvider metaGetterProvider - * - * @param $method - * @param $key - * @param $value - */ - public function testMetaGetters($method, $key, $value) - { - $cache = new Memory(); - $this->assertFalse($cache->{$method}('path.txt')); - $cache->updateObject('path.txt', $object = [ - 'path' => 'path.txt', - 'type' => 'file', - $key => $value, - ] + Util::pathinfo('path.txt'), true); - $this->assertEquals($object, $cache->{$method}('path.txt')); - $this->assertEquals($object, $cache->getMetadata('path.txt')); - } - - public function testGetDerivedMimetype() - { - $cache = new Memory(); - $cache->updateObject('path.txt', [ - 'contents' => 'something', - ]); - $response = $cache->getMimetype('path.txt'); - $this->assertEquals('text/plain', $response['mimetype']); - } - - public function testCopyFail() - { - $cache = new Memory(); - $cache->copy('one', 'two'); - $this->assertNull($cache->has('two')); - $this->assertNull($cache->load()); - } - - public function testStoreContents() - { - $cache = new Memory(); - $cache->storeContents('dirname', [ - ['path' => 'dirname', 'type' => 'dir'], - ['path' => 'dirname/nested', 'type' => 'dir'], - ['path' => 'dirname/nested/deep', 'type' => 'dir'], - ['path' => 'other/nested/deep', 'type' => 'dir'], - ], true); - - $this->isTrue($cache->isComplete('other/nested', true)); - } - - public function testDelete() - { - $cache = new Memory(); - $cache->updateObject('path.txt', ['type' => 'file']); - $this->assertTrue($cache->has('path.txt')); - $cache->delete('path.txt'); - $this->assertFalse($cache->has('path.txt')); - } - - public function testDeleteDir() - { - $cache = new Memory(); - $cache->storeContents('dirname', [ - ['path' => 'dirname/path.txt', 'type' => 'file'], - ]); - $this->assertTrue($cache->isComplete('dirname', false)); - $this->assertTrue($cache->has('dirname/path.txt')); - $cache->deleteDir('dirname'); - $this->assertFalse($cache->isComplete('dirname', false)); - $this->assertNull($cache->has('dirname/path.txt')); - } - - public function testReadStream() - { - $cache = new Memory(); - $this->assertFalse($cache->readStream('path.txt')); - } - - public function testRename() - { - $cache = new Memory(); - $cache->updateObject('path.txt', ['type' => 'file']); - $cache->rename('path.txt', 'newpath.txt'); - $this->assertTrue($cache->has('newpath.txt')); - } - - public function testCopy() - { - $cache = new Memory(); - $cache->updateObject('path.txt', ['type' => 'file']); - $cache->copy('path.txt', 'newpath.txt'); - $this->assertTrue($cache->has('newpath.txt')); - } - - public function testComplextListContents() - { - $cache = new Memory(); - $cache->storeContents('', [ - ['path' => 'dirname', 'type' => 'dir'], - ['path' => 'dirname/file.txt', 'type' => 'file'], - ['path' => 'other', 'type' => 'dir'], - ['path' => 'other/file.txt', 'type' => 'file'], - ['path' => 'other/nested/file.txt', 'type' => 'file'], - ]); - - $this->assertCount(3, $cache->listContents('other', true)); - } - - public function testComplextListContentsWithDeletedFile() - { - $cache = new Memory(); - $cache->storeContents('', [ - ['path' => 'dirname', 'type' => 'dir'], - ['path' => 'dirname/file.txt', 'type' => 'file'], - ['path' => 'other', 'type' => 'dir'], - ['path' => 'other/file.txt', 'type' => 'file'], - ['path' => 'other/another_file.txt', 'type' => 'file'], - ]); - - $cache->delete('other/another_file.txt'); - $this->assertCount(4, $cache->listContents('', true)); - } - - public function testCacheMissIfContentsIsFalse() - { - $cache = new Memory(); - $cache->updateObject('path.txt', [ - 'path' => 'path.txt', - 'contents' => false, - ], true); - - $this->assertFalse($cache->read('path.txt')); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/NoopCacheTests.php b/vendor/league/flysystem-cached-adapter/tests/NoopCacheTests.php deleted file mode 100644 index 148616f..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/NoopCacheTests.php +++ /dev/null @@ -1,35 +0,0 @@ -assertEquals($cache, $cache->storeMiss('file.txt')); - $this->assertNull($cache->setComplete('', false)); - $this->assertNull($cache->load()); - $this->assertNull($cache->flush()); - $this->assertNull($cache->has('path.txt')); - $this->assertNull($cache->autosave()); - $this->assertFalse($cache->isComplete('', false)); - $this->assertFalse($cache->read('something')); - $this->assertFalse($cache->readStream('something')); - $this->assertFalse($cache->getMetadata('something')); - $this->assertFalse($cache->getMimetype('something')); - $this->assertFalse($cache->getSize('something')); - $this->assertFalse($cache->getTimestamp('something')); - $this->assertFalse($cache->getVisibility('something')); - $this->assertEmpty($cache->listContents('', false)); - $this->assertFalse($cache->rename('', '')); - $this->assertFalse($cache->copy('', '')); - $this->assertNull($cache->save()); - $object = ['path' => 'path.ext']; - $this->assertEquals($object, $cache->updateObject('path.txt', $object)); - $this->assertEquals([['path' => 'some/file.txt']], $cache->storeContents('unknwon', [ - ['path' => 'some/file.txt'], - ], false)); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/PhpRedisTests.php b/vendor/league/flysystem-cached-adapter/tests/PhpRedisTests.php deleted file mode 100644 index d1ccb65..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/PhpRedisTests.php +++ /dev/null @@ -1,45 +0,0 @@ -shouldReceive('get')->with('flysystem')->once()->andReturn(false); - $cache = new PhpRedis($client); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = json_encode([[], ['' => true]]); - $client = Mockery::mock('Redis'); - $client->shouldReceive('get')->with('flysystem')->once()->andReturn($response); - $cache = new PhpRedis($client); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSave() - { - $data = json_encode([[], []]); - $client = Mockery::mock('Redis'); - $client->shouldReceive('set')->with('flysystem', $data)->once(); - $cache = new PhpRedis($client); - $cache->save(); - } - - public function testSaveWithExpire() - { - $data = json_encode([[], []]); - $client = Mockery::mock('Redis'); - $client->shouldReceive('set')->with('flysystem', $data)->once(); - $client->shouldReceive('expire')->with('flysystem', 20)->once(); - $cache = new PhpRedis($client, 'flysystem', 20); - $cache->save(); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/PredisTests.php b/vendor/league/flysystem-cached-adapter/tests/PredisTests.php deleted file mode 100644 index e33e104..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/PredisTests.php +++ /dev/null @@ -1,55 +0,0 @@ -shouldReceive('createCommand')->with('get', ['flysystem'])->once()->andReturn($command); - $client->shouldReceive('executeCommand')->with($command)->andReturn(null); - $cache = new Predis($client); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = json_encode([[], ['' => true]]); - $client = Mockery::mock('Predis\Client'); - $command = Mockery::mock('Predis\Command\CommandInterface'); - $client->shouldReceive('createCommand')->with('get', ['flysystem'])->once()->andReturn($command); - $client->shouldReceive('executeCommand')->with($command)->andReturn($response); - $cache = new Predis($client); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSave() - { - $data = json_encode([[], []]); - $client = Mockery::mock('Predis\Client'); - $command = Mockery::mock('Predis\Command\CommandInterface'); - $client->shouldReceive('createCommand')->with('set', ['flysystem', $data])->once()->andReturn($command); - $client->shouldReceive('executeCommand')->with($command)->once(); - $cache = new Predis($client); - $cache->save(); - } - - public function testSaveWithExpire() - { - $data = json_encode([[], []]); - $client = Mockery::mock('Predis\Client'); - $command = Mockery::mock('Predis\Command\CommandInterface'); - $client->shouldReceive('createCommand')->with('set', ['flysystem', $data])->once()->andReturn($command); - $client->shouldReceive('executeCommand')->with($command)->once(); - $expireCommand = Mockery::mock('Predis\Command\CommandInterface'); - $client->shouldReceive('createCommand')->with('expire', ['flysystem', 20])->once()->andReturn($expireCommand); - $client->shouldReceive('executeCommand')->with($expireCommand)->once(); - $cache = new Predis($client, 'flysystem', 20); - $cache->save(); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/Psr6CacheTest.php b/vendor/league/flysystem-cached-adapter/tests/Psr6CacheTest.php deleted file mode 100644 index d5e5700..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/Psr6CacheTest.php +++ /dev/null @@ -1,45 +0,0 @@ -shouldReceive('isHit')->once()->andReturn(false); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $cache = new Psr6Cache($pool); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = json_encode([[], ['' => true]]); - $pool = Mockery::mock('Psr\Cache\CacheItemPoolInterface'); - $item = Mockery::mock('Psr\Cache\CacheItemInterface'); - $item->shouldReceive('get')->once()->andReturn($response); - $item->shouldReceive('isHit')->once()->andReturn(true); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $cache = new Psr6Cache($pool); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSave() - { - $response = json_encode([[], []]); - $ttl = 4711; - $pool = Mockery::mock('Psr\Cache\CacheItemPoolInterface'); - $item = Mockery::mock('Psr\Cache\CacheItemInterface'); - $item->shouldReceive('expiresAfter')->once()->with($ttl); - $item->shouldReceive('set')->once()->andReturn($response); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $pool->shouldReceive('save')->once()->with($item); - $cache = new Psr6Cache($pool, 'foo', $ttl); - $cache->save(); - } -} diff --git a/vendor/league/flysystem-cached-adapter/tests/StashTest.php b/vendor/league/flysystem-cached-adapter/tests/StashTest.php deleted file mode 100644 index 29e142d..0000000 --- a/vendor/league/flysystem-cached-adapter/tests/StashTest.php +++ /dev/null @@ -1,43 +0,0 @@ -shouldReceive('get')->once()->andReturn(null); - $item->shouldReceive('isMiss')->once()->andReturn(true); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $cache = new Stash($pool); - $cache->load(); - $this->assertFalse($cache->isComplete('', false)); - } - - public function testLoadSuccess() - { - $response = json_encode([[], ['' => true]]); - $pool = Mockery::mock('Stash\Pool'); - $item = Mockery::mock('Stash\Item'); - $item->shouldReceive('get')->once()->andReturn($response); - $item->shouldReceive('isMiss')->once()->andReturn(false); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $cache = new Stash($pool); - $cache->load(); - $this->assertTrue($cache->isComplete('', false)); - } - - public function testSave() - { - $response = json_encode([[], []]); - $pool = Mockery::mock('Stash\Pool'); - $item = Mockery::mock('Stash\Item'); - $item->shouldReceive('set')->once()->andReturn($response); - $pool->shouldReceive('getItem')->once()->andReturn($item); - $cache = new Stash($pool); - $cache->save(); - } -} diff --git a/vendor/league/flysystem/CODE_OF_CONDUCT.md b/vendor/league/flysystem/CODE_OF_CONDUCT.md deleted file mode 100644 index 89569c0..0000000 --- a/vendor/league/flysystem/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,76 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at info+flysystem@frankdejonge.nl. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq diff --git a/vendor/league/flysystem/INFO.md b/vendor/league/flysystem/INFO.md deleted file mode 100644 index 8a44d14..0000000 --- a/vendor/league/flysystem/INFO.md +++ /dev/null @@ -1,2 +0,0 @@ -View the docs at: https://flysystem.thephpleague.com/v2/ -Changelog at: https://github.com/thephpleague/flysystem/blob/2.x/CHANGELOG.md diff --git a/vendor/league/flysystem/LICENSE b/vendor/league/flysystem/LICENSE deleted file mode 100644 index f2684c8..0000000 --- a/vendor/league/flysystem/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013-2019 Frank de Jonge - -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. diff --git a/vendor/league/flysystem/SECURITY.md b/vendor/league/flysystem/SECURITY.md deleted file mode 100644 index f5b205e..0000000 --- a/vendor/league/flysystem/SECURITY.md +++ /dev/null @@ -1,16 +0,0 @@ -# Security Policy - -## Supported Versions - -| Version | Supported | -| ------- | ------------------ | -| 1.0.x | :white_check_mark: | -| 2.0.x | :x: | - -## Reporting a Vulnerability - -When you've encountered a security vulnerability, please disclose it securely. - -The security process is described at: -[https://flysystem.thephpleague.com/docs/security/](https://flysystem.thephpleague.com/docs/security/) - diff --git a/vendor/league/flysystem/composer.json b/vendor/league/flysystem/composer.json deleted file mode 100644 index 32ec81d..0000000 --- a/vendor/league/flysystem/composer.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "league/flysystem", - "type": "library", - "description": "Filesystem abstraction: Many filesystems, one API.", - "keywords": [ - "filesystem", "filesystems", "files", "storage", "dropbox", "aws", - "abstraction", "s3", "ftp", "sftp", "remote", "webdav", - "file systems", "cloud", "cloud files", "rackspace", "copy.com" - ], - "funding": [ - { - "type": "other", - "url": "https://offset.earth/frankdejonge" - } - ], - "license": "MIT", - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frenky.net" - } - ], - "require": { - "php": "^7.2.5 || ^8.0", - "ext-fileinfo": "*", - "league/mime-type-detection": "^1.3" - }, - "require-dev": { - "phpspec/prophecy": "^1.11.1", - "phpunit/phpunit": "^8.5.8" - }, - "autoload": { - "psr-4": { - "League\\Flysystem\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "League\\Flysystem\\Stub\\": "stub/" - } - }, - "suggest": { - "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem", - "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files", - "league/flysystem-azure": "Allows you to use Windows Azure Blob storage", - "league/flysystem-webdav": "Allows you to use WebDAV storage", - "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2", - "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3", - "spatie/flysystem-dropbox": "Allows you to use Dropbox storage", - "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications", - "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching", - "ext-ftp": "Allows you to use FTP server storage", - "ext-openssl": "Allows you to use FTPS server storage", - "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib", - "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter" - }, - "conflict": { - "league/flysystem-sftp": "<1.0.6" - }, - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "scripts": { - "phpstan": "php phpstan.php" - } -} diff --git a/vendor/league/flysystem/config.subsplit-publish.json b/vendor/league/flysystem/config.subsplit-publish.json deleted file mode 100644 index b0de91e..0000000 --- a/vendor/league/flysystem/config.subsplit-publish.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "sub-splits": [ - { - "name": "ftp", - "directory": "src/Ftp", - "target": "git@github.com:thephpleague/flysystem-ftp.git" - }, - { - "name": "sftp", - "directory": "src/PhpseclibV2", - "target": "git@github.com:thephpleague/flysystem-sftp.git" - }, - { - "name": "sftp-v3", - "directory": "src/PhpseclibV3", - "target": "git@github.com:thephpleague/flysystem-sftp-v3.git" - }, - { - "name": "memory", - "directory": "src/InMemory", - "target": "git@github.com:thephpleague/flysystem-memory.git" - }, - { - "name": "ziparchive", - "directory": "src/ZipArchive", - "target": "git@github.com:thephpleague/flysystem-ziparchive.git" - }, - { - "name": "aws-s3-v3", - "directory": "src/AwsS3V3", - "target": "git@github.com:thephpleague/flysystem-aws-s3-v3.git" - }, - { - "name": "async-aws-s3", - "directory": "src/AsyncAwsS3", - "target": "git@github.com:thephpleague/flysystem-async-aws-s3.git" - }, - { - "name": "google-cloud-storage", - "directory": "src/GoogleCloudStorage", - "target": "git@github.com:thephpleague/flysystem-google-cloud-storage.git" - }, - { - "name": "adapter-test-utilities", - "directory": "src/AdapterTestUtilities", - "target": "git@github.com:thephpleague/flysystem-adapter-test-utilities.git" - } - ] -} diff --git a/vendor/league/flysystem/deprecations.md b/vendor/league/flysystem/deprecations.md deleted file mode 100644 index c336a42..0000000 --- a/vendor/league/flysystem/deprecations.md +++ /dev/null @@ -1,19 +0,0 @@ -# Deprecations - -This document lists all the planned deprecations. - -## Handlers will be removed in 2.0 - -The `Handler` type and associated calls will be removed in version 2.0. - -### Upgrade path - -You should create your own implementation for handling OOP usage, -but it's recommended to move away from using an OOP-style wrapper entirely. - -The reason for this is that it's too easy for implementation details (for -your application this is Flysystem) to leak into the application. The most -important part for Flysystem is that it improves portability and creates a -solid boundary between your application core and the infrastructure you use. -The OOP-style handling breaks this principle, therefore I want to stop -promoting it. diff --git a/vendor/league/flysystem/docker-compose.yml b/vendor/league/flysystem/docker-compose.yml deleted file mode 100644 index 3ab6b77..0000000 --- a/vendor/league/flysystem/docker-compose.yml +++ /dev/null @@ -1,58 +0,0 @@ ---- -version: "3" -services: - webdav: - image: bytemark/webdav - restart: always - ports: - - "80:80" - environment: - AUTH_TYPE: Digest - USERNAME: alice - PASSWORD: secret1234 - sftp: - container_name: sftp - restart: always - image: atmoz/sftp - volumes: - - ./test_files/sftp/users.conf:/etc/sftp/users.conf - - ./test_files/sftp/ssh_host_ed25519_key:/etc/ssh/ssh_host_ed25519_key - - ./test_files/sftp/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key - - ./test_files/sftp/id_rsa.pub:/home/bar/.ssh/keys/id_rsa.pub - ports: - - "2222:22" - ftp: - container_name: ftp - restart: always - image: delfer/alpine-ftp-server - environment: - USERS: 'foo|pass|/home/foo/upload' - ADDRESS: 'localhost' - ports: - - "2121:21" - - "21000-21010:21000-21010" - ftpd: - container_name: ftpd - restart: always - environment: - PUBLICHOST: localhost - FTP_USER_NAME: foo - FTP_USER_PASS: pass - FTP_USER_HOME: /home/foo - image: stilliard/pure-ftpd - ports: - - "2122:21" - - "30000-30009:30000-30009" - command: "/run.sh -l puredb:/etc/pure-ftpd/pureftpd.pdb -E -j -P localhost" - toxiproxy: - container_name: toxiproxy - restart: unless-stopped - image: ghcr.io/shopify/toxiproxy - command: "-host 0.0.0.0 -config /opt/toxiproxy/config.json" - volumes: - - ./test_files/toxiproxy/toxiproxy.json:/opt/toxiproxy/config.json:ro - ports: - - "8474:8474" # HTTP API - - "8222:8222" # SFTP - - "8121:8121" # FTP - - "8122:8122" # FTPD diff --git a/vendor/league/flysystem/readme.md b/vendor/league/flysystem/readme.md deleted file mode 100644 index 0c0b98e..0000000 --- a/vendor/league/flysystem/readme.md +++ /dev/null @@ -1,45 +0,0 @@ -# League\Flysystem - -[![Author](https://img.shields.io/badge/author-@frankdejonge-blue.svg)](https://twitter.com/frankdejonge) -[![Source Code](https://img.shields.io/badge/source-thephpleague/flysystem-blue.svg)](https://github.com/thephpleague/flysystem) -[![Latest Version](https://img.shields.io/github/tag/thephpleague/flysystem.svg)](https://github.com/thephpleague/flysystem/releases) -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/thephpleague/flysystem/blob/master/LICENSE) -[![Quality Assurance](https://github.com/thephpleague/flysystem/workflows/Quality%20Assurance/badge.svg?branch=2.x)](https://github.com/thephpleague/flysystem/actions?query=workflow%3A%22Quality+Assurance%22) -[![Total Downloads](https://img.shields.io/packagist/dt/league/flysystem.svg)](https://packagist.org/packages/league/flysystem) -![php 7.2+](https://img.shields.io/badge/php-min%207.2-red.svg) - -## About Flysystem - -Flysystem is a file storage library for PHP. It provides one interface to -interact with many types of filesystems. When you use Flysystem, you're -not only protected from vendor lock-in, you'll also have a consistent experience -for which ever storage is right for you. - -## Getting Started - -* **[New in V2](https://flysystem.thephpleague.com/v2/docs/what-is-new/)**: What it new in Flysystem V2? -* **[Architecture](https://flysystem.thephpleague.com/v2/docs/architecture/)**: Flysystem's internal architecture -* **[Flysystem API](https://flysystem.thephpleague.com/v2/docs/usage/filesystem-api/)**: How to interact with your Flysystem instance -* **[Upgrade to V2](https://flysystem.thephpleague.com/v2/docs/advanced/upgrade-to-2.0.0/)**: How to upgrade your Flysystem V1 instance to V2 - -### Commonly-Used Adapters - -* **[AsyncAws S3](https://flysystem.thephpleague.com/v2/docs/adapter/async-aws-s3/)** -* **[AWS S3](https://flysystem.thephpleague.com/v2/docs/adapter/aws-s3-v3/)** -* **[Local](https://flysystem.thephpleague.com/v2/docs/adapter/local/)** -* **[Memory](https://flysystem.thephpleague.com/v2/docs/adapter/in-memory/)** - -### Third party Adapters - -* **[Gitlab](https://github.com/RoyVoetman/flysystem-gitlab-storage)** -* **[Google Drive (using regular paths)](https://github.com/masbug/flysystem-google-drive-ext)** - -You can always [create an adapter](https://flysystem.thephpleague.com/v2/docs/advanced/creating-an-adapter/) yourself. - -## Security - -If you discover any security related issues, please email info@frankdejonge.nl instead of using the issue tracker. - -## Enjoy - -Oh, and if you've come down this far, you might as well follow me on [twitter](https://twitter.com/frankdejonge). diff --git a/vendor/league/flysystem/src/Adapter/AbstractAdapter.php b/vendor/league/flysystem/src/Adapter/AbstractAdapter.php deleted file mode 100644 index a6a8ed0..0000000 --- a/vendor/league/flysystem/src/Adapter/AbstractAdapter.php +++ /dev/null @@ -1,72 +0,0 @@ -pathPrefix = null; - - return; - } - - $this->pathPrefix = rtrim($prefix, '\\/') . $this->pathSeparator; - } - - /** - * Get the path prefix. - * - * @return string|null path prefix or null if pathPrefix is empty - */ - public function getPathPrefix() - { - return $this->pathPrefix; - } - - /** - * Prefix a path. - * - * @param string $path - * - * @return string prefixed path - */ - public function applyPathPrefix($path) - { - return $this->getPathPrefix() . ltrim($path, '\\/'); - } - - /** - * Remove a path prefix. - * - * @param string $path - * - * @return string path without the prefix - */ - public function removePathPrefix($path) - { - return substr($path, strlen((string) $this->getPathPrefix())); - } -} diff --git a/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php b/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php deleted file mode 100644 index 25d949e..0000000 --- a/vendor/league/flysystem/src/Adapter/AbstractFtpAdapter.php +++ /dev/null @@ -1,705 +0,0 @@ -safeStorage = new SafeStorage(); - $this->setConfig($config); - } - - /** - * Set the config. - * - * @param array $config - * - * @return $this - */ - public function setConfig(array $config) - { - foreach ($this->configurable as $setting) { - if ( ! isset($config[$setting])) { - continue; - } - - $method = 'set' . ucfirst($setting); - - if (method_exists($this, $method)) { - $this->$method($config[$setting]); - } - } - - return $this; - } - - /** - * Returns the host. - * - * @return string - */ - public function getHost() - { - return $this->host; - } - - /** - * Set the host. - * - * @param string $host - * - * @return $this - */ - public function setHost($host) - { - $this->host = $host; - - return $this; - } - - /** - * Set the public permission value. - * - * @param int $permPublic - * - * @return $this - */ - public function setPermPublic($permPublic) - { - $this->permPublic = $permPublic; - - return $this; - } - - /** - * Set the private permission value. - * - * @param int $permPrivate - * - * @return $this - */ - public function setPermPrivate($permPrivate) - { - $this->permPrivate = $permPrivate; - - return $this; - } - - /** - * Returns the ftp port. - * - * @return int - */ - public function getPort() - { - return $this->port; - } - - /** - * Returns the root folder to work from. - * - * @return string - */ - public function getRoot() - { - return $this->root; - } - - /** - * Set the ftp port. - * - * @param int|string $port - * - * @return $this - */ - public function setPort($port) - { - $this->port = (int) $port; - - return $this; - } - - /** - * Set the root folder to work from. - * - * @param string $root - * - * @return $this - */ - public function setRoot($root) - { - $this->root = rtrim($root, '\\/') . $this->separator; - - return $this; - } - - /** - * Returns the ftp username. - * - * @return string username - */ - public function getUsername() - { - $username = $this->safeStorage->retrieveSafely('username'); - - return $username !== null ? $username : 'anonymous'; - } - - /** - * Set ftp username. - * - * @param string $username - * - * @return $this - */ - public function setUsername($username) - { - $this->safeStorage->storeSafely('username', $username); - - return $this; - } - - /** - * Returns the password. - * - * @return string password - */ - public function getPassword() - { - return $this->safeStorage->retrieveSafely('password'); - } - - /** - * Set the ftp password. - * - * @param string $password - * - * @return $this - */ - public function setPassword($password) - { - $this->safeStorage->storeSafely('password', $password); - - return $this; - } - - /** - * Returns the amount of seconds before the connection will timeout. - * - * @return int - */ - public function getTimeout() - { - return $this->timeout; - } - - /** - * Set the amount of seconds before the connection should timeout. - * - * @param int $timeout - * - * @return $this - */ - public function setTimeout($timeout) - { - $this->timeout = (int) $timeout; - - return $this; - } - - /** - * Return the FTP system type. - * - * @return string - */ - public function getSystemType() - { - return $this->systemType; - } - - /** - * Set the FTP system type (windows or unix). - * - * @param string $systemType - * - * @return $this - */ - public function setSystemType($systemType) - { - $this->systemType = strtolower($systemType); - - return $this; - } - - /** - * True to enable timestamps for FTP servers that return unix-style listings. - * - * @param bool $bool - * - * @return $this - */ - public function setEnableTimestampsOnUnixListings($bool = false) - { - $this->enableTimestampsOnUnixListings = $bool; - - return $this; - } - - /** - * @inheritdoc - */ - public function listContents($directory = '', $recursive = false) - { - return $this->listDirectoryContents($directory, $recursive); - } - - abstract protected function listDirectoryContents($directory, $recursive = false); - - /** - * Normalize a directory listing. - * - * @param array $listing - * @param string $prefix - * - * @return array directory listing - */ - protected function normalizeListing(array $listing, $prefix = '') - { - $base = $prefix; - $result = []; - $listing = $this->removeDotDirectories($listing); - - while ($item = array_shift($listing)) { - if (preg_match('#^.*:$#', $item)) { - $base = preg_replace('~^\./*|:$~', '', $item); - continue; - } - - $result[] = $this->normalizeObject($item, $base); - } - - return $this->sortListing($result); - } - - /** - * Sort a directory listing. - * - * @param array $result - * - * @return array sorted listing - */ - protected function sortListing(array $result) - { - $compare = function ($one, $two) { - return strnatcmp($one['path'], $two['path']); - }; - - usort($result, $compare); - - return $result; - } - - /** - * Normalize a file entry. - * - * @param string $item - * @param string $base - * - * @return array normalized file array - * - * @throws NotSupportedException - */ - protected function normalizeObject($item, $base) - { - $systemType = $this->systemType ?: $this->detectSystemType($item); - - if ($systemType === 'unix') { - return $this->normalizeUnixObject($item, $base); - } elseif ($systemType === 'windows') { - return $this->normalizeWindowsObject($item, $base); - } - - throw NotSupportedException::forFtpSystemType($systemType); - } - - /** - * Normalize a Unix file entry. - * - * Given $item contains: - * '-rw-r--r-- 1 ftp ftp 409 Aug 19 09:01 file1.txt' - * - * This function will return: - * [ - * 'type' => 'file', - * 'path' => 'file1.txt', - * 'visibility' => 'public', - * 'size' => 409, - * 'timestamp' => 1566205260 - * ] - * - * @param string $item - * @param string $base - * - * @return array normalized file array - */ - protected function normalizeUnixObject($item, $base) - { - $item = preg_replace('#\s+#', ' ', trim($item), 7); - - if (count(explode(' ', $item, 9)) !== 9) { - throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts."); - } - - list($permissions, /* $number */, /* $owner */, /* $group */, $size, $month, $day, $timeOrYear, $name) = explode(' ', $item, 9); - $type = $this->detectType($permissions); - $path = $base === '' ? $name : $base . $this->separator . $name; - - if ($type === 'dir') { - $result = compact('type', 'path'); - if ($this->enableTimestampsOnUnixListings) { - $timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear); - $result += compact('timestamp'); - } - - return $result; - } - - $permissions = $this->normalizePermissions($permissions); - $visibility = $permissions & 0044 ? AdapterInterface::VISIBILITY_PUBLIC : AdapterInterface::VISIBILITY_PRIVATE; - $size = (int) $size; - - $result = compact('type', 'path', 'visibility', 'size'); - if ($this->enableTimestampsOnUnixListings) { - $timestamp = $this->normalizeUnixTimestamp($month, $day, $timeOrYear); - $result += compact('timestamp'); - } - - return $result; - } - - /** - * Only accurate to the minute (current year), or to the day. - * - * Inadequacies in timestamp accuracy are due to limitations of the FTP 'LIST' command - * - * Note: The 'MLSD' command is a machine-readable replacement for 'LIST' - * but many FTP servers do not support it :( - * - * @param string $month e.g. 'Aug' - * @param string $day e.g. '19' - * @param string $timeOrYear e.g. '09:01' OR '2015' - * - * @return int - */ - protected function normalizeUnixTimestamp($month, $day, $timeOrYear) - { - if (is_numeric($timeOrYear)) { - $year = $timeOrYear; - $hour = '00'; - $minute = '00'; - $seconds = '00'; - } else { - $year = date('Y'); - list($hour, $minute) = explode(':', $timeOrYear); - $seconds = '00'; - } - $dateTime = DateTime::createFromFormat('Y-M-j-G:i:s', "{$year}-{$month}-{$day}-{$hour}:{$minute}:{$seconds}"); - - return $dateTime->getTimestamp(); - } - - /** - * Normalize a Windows/DOS file entry. - * - * @param string $item - * @param string $base - * - * @return array normalized file array - */ - protected function normalizeWindowsObject($item, $base) - { - $item = preg_replace('#\s+#', ' ', trim($item), 3); - - if (count(explode(' ', $item, 4)) !== 4) { - throw new RuntimeException("Metadata can't be parsed from item '$item' , not enough parts."); - } - - list($date, $time, $size, $name) = explode(' ', $item, 4); - $path = $base === '' ? $name : $base . $this->separator . $name; - - // Check for the correct date/time format - $format = strlen($date) === 8 ? 'm-d-yH:iA' : 'Y-m-dH:i'; - $dt = DateTime::createFromFormat($format, $date . $time); - $timestamp = $dt ? $dt->getTimestamp() : (int) strtotime("$date $time"); - - if ($size === '') { - $type = 'dir'; - - return compact('type', 'path', 'timestamp'); - } - - $type = 'file'; - $visibility = AdapterInterface::VISIBILITY_PUBLIC; - $size = (int) $size; - - return compact('type', 'path', 'visibility', 'size', 'timestamp'); - } - - /** - * Get the system type from a listing item. - * - * @param string $item - * - * @return string the system type - */ - protected function detectSystemType($item) - { - return preg_match('/^[0-9]{2,4}-[0-9]{2}-[0-9]{2}/', trim($item)) ? 'windows' : 'unix'; - } - - /** - * Get the file type from the permissions. - * - * @param string $permissions - * - * @return string file type - */ - protected function detectType($permissions) - { - return substr($permissions, 0, 1) === 'd' ? 'dir' : 'file'; - } - - /** - * Normalize a permissions string. - * - * @param string $permissions - * - * @return int - */ - protected function normalizePermissions($permissions) - { - if (is_numeric($permissions)) { - return ((int) $permissions) & 0777; - } - - // remove the type identifier - $permissions = substr($permissions, 1); - - // map the string rights to the numeric counterparts - $map = ['-' => '0', 'r' => '4', 'w' => '2', 'x' => '1']; - $permissions = strtr($permissions, $map); - - // split up the permission groups - $parts = str_split($permissions, 3); - - // convert the groups - $mapper = function ($part) { - return array_sum(str_split($part)); - }; - - // converts to decimal number - return octdec(implode('', array_map($mapper, $parts))); - } - - /** - * Filter out dot-directories. - * - * @param array $list - * - * @return array - */ - public function removeDotDirectories(array $list) - { - $filter = function ($line) { - return $line !== '' && ! preg_match('#.* \.(\.)?$|^total#', $line); - }; - - return array_filter($list, $filter); - } - - /** - * @inheritdoc - */ - public function has($path) - { - return $this->getMetadata($path); - } - - /** - * @inheritdoc - */ - public function getSize($path) - { - return $this->getMetadata($path); - } - - /** - * @inheritdoc - */ - public function getVisibility($path) - { - return $this->getMetadata($path); - } - - /** - * Ensure a directory exists. - * - * @param string $dirname - */ - public function ensureDirectory($dirname) - { - $dirname = (string) $dirname; - - if ($dirname !== '' && ! $this->has($dirname)) { - $this->createDir($dirname, new Config()); - } - } - - /** - * @return mixed - */ - public function getConnection() - { - if ( ! $this->isConnected()) { - $this->disconnect(); - $this->connect(); - } - - return $this->connection; - } - - /** - * Get the public permission value. - * - * @return int - */ - public function getPermPublic() - { - return $this->permPublic; - } - - /** - * Get the private permission value. - * - * @return int - */ - public function getPermPrivate() - { - return $this->permPrivate; - } - - /** - * Disconnect on destruction. - */ - public function __destruct() - { - $this->disconnect(); - } - - /** - * Establish a connection. - */ - abstract public function connect(); - - /** - * Close the connection. - */ - abstract public function disconnect(); - - /** - * Check if a connection is active. - * - * @return bool - */ - abstract public function isConnected(); - - protected function escapePath($path) - { - return str_replace(['*', '[', ']'], ['\\*', '\\[', '\\]'], $path); - } -} diff --git a/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php b/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php deleted file mode 100644 index fd8d216..0000000 --- a/vendor/league/flysystem/src/Adapter/CanOverwriteFiles.php +++ /dev/null @@ -1,12 +0,0 @@ -transferMode = $mode; - - return $this; - } - - /** - * Set if Ssl is enabled. - * - * @param bool $ssl - * - * @return $this - */ - public function setSsl($ssl) - { - $this->ssl = (bool) $ssl; - - return $this; - } - - /** - * Set if passive mode should be used. - * - * @param bool $passive - */ - public function setPassive($passive = true) - { - $this->passive = $passive; - } - - /** - * @param bool $ignorePassiveAddress - */ - public function setIgnorePassiveAddress($ignorePassiveAddress) - { - $this->ignorePassiveAddress = $ignorePassiveAddress; - } - - /** - * @param bool $recurseManually - */ - public function setRecurseManually($recurseManually) - { - $this->recurseManually = $recurseManually; - } - - /** - * @param bool $utf8 - */ - public function setUtf8($utf8) - { - $this->utf8 = (bool) $utf8; - } - - /** - * Connect to the FTP server. - */ - public function connect() - { - $tries = 3; - start_connecting: - - if ($this->ssl) { - $this->connection = @ftp_ssl_connect($this->getHost(), $this->getPort(), $this->getTimeout()); - } else { - $this->connection = @ftp_connect($this->getHost(), $this->getPort(), $this->getTimeout()); - } - - if ( ! $this->connection) { - $tries--; - - if ($tries > 0) goto start_connecting; - - throw new ConnectionRuntimeException('Could not connect to host: ' . $this->getHost() . ', port:' . $this->getPort()); - } - - $this->login(); - $this->setUtf8Mode(); - $this->setConnectionPassiveMode(); - $this->setConnectionRoot(); - $this->isPureFtpd = $this->isPureFtpdServer(); - } - - /** - * Set the connection to UTF-8 mode. - */ - protected function setUtf8Mode() - { - if ($this->utf8) { - $response = ftp_raw($this->connection, "OPTS UTF8 ON"); - if (!in_array(substr($response[0], 0, 3), ['200', '202'])) { - throw new ConnectionRuntimeException( - 'Could not set UTF-8 mode for connection: ' . $this->getHost() . '::' . $this->getPort() - ); - } - } - } - - /** - * Set the connections to passive mode. - * - * @throws ConnectionRuntimeException - */ - protected function setConnectionPassiveMode() - { - if (is_bool($this->ignorePassiveAddress) && defined('FTP_USEPASVADDRESS')) { - ftp_set_option($this->connection, FTP_USEPASVADDRESS, ! $this->ignorePassiveAddress); - } - - if ( ! ftp_pasv($this->connection, $this->passive)) { - throw new ConnectionRuntimeException( - 'Could not set passive mode for connection: ' . $this->getHost() . '::' . $this->getPort() - ); - } - } - - /** - * Set the connection root. - */ - protected function setConnectionRoot() - { - $root = $this->getRoot(); - $connection = $this->connection; - - if ($root && ! ftp_chdir($connection, $root)) { - throw new InvalidRootException('Root is invalid or does not exist: ' . $this->getRoot()); - } - - // Store absolute path for further reference. - // This is needed when creating directories and - // initial root was a relative path, else the root - // would be relative to the chdir'd path. - $this->root = ftp_pwd($connection); - } - - /** - * Login. - * - * @throws ConnectionRuntimeException - */ - protected function login() - { - set_error_handler(function () { - }); - $isLoggedIn = ftp_login( - $this->connection, - $this->getUsername(), - $this->getPassword() - ); - restore_error_handler(); - - if ( ! $isLoggedIn) { - $this->disconnect(); - throw new ConnectionRuntimeException( - 'Could not login with connection: ' . $this->getHost() . '::' . $this->getPort( - ) . ', username: ' . $this->getUsername() - ); - } - } - - /** - * Disconnect from the FTP server. - */ - public function disconnect() - { - if ($this->hasFtpConnection()) { - @ftp_close($this->connection); - } - - $this->connection = null; - } - - /** - * @inheritdoc - */ - public function write($path, $contents, Config $config) - { - $stream = fopen('php://temp', 'w+b'); - fwrite($stream, $contents); - rewind($stream); - $result = $this->writeStream($path, $stream, $config); - fclose($stream); - - if ($result === false) { - return false; - } - - $result['contents'] = $contents; - $result['mimetype'] = $config->get('mimetype') ?: Util::guessMimeType($path, $contents); - - return $result; - } - - /** - * @inheritdoc - */ - public function writeStream($path, $resource, Config $config) - { - $this->ensureDirectory(Util::dirname($path)); - - if ( ! ftp_fput($this->getConnection(), $path, $resource, $this->transferMode)) { - return false; - } - - if ($visibility = $config->get('visibility')) { - $this->setVisibility($path, $visibility); - } - - $type = 'file'; - - return compact('type', 'path', 'visibility'); - } - - /** - * @inheritdoc - */ - public function update($path, $contents, Config $config) - { - return $this->write($path, $contents, $config); - } - - /** - * @inheritdoc - */ - public function updateStream($path, $resource, Config $config) - { - return $this->writeStream($path, $resource, $config); - } - - /** - * @inheritdoc - */ - public function rename($path, $newpath) - { - return ftp_rename($this->getConnection(), $path, $newpath); - } - - /** - * @inheritdoc - */ - public function delete($path) - { - return ftp_delete($this->getConnection(), $path); - } - - /** - * @inheritdoc - */ - public function deleteDir($dirname) - { - $connection = $this->getConnection(); - $contents = array_reverse($this->listDirectoryContents($dirname, false)); - - foreach ($contents as $object) { - if ($object['type'] === 'file') { - if ( ! ftp_delete($connection, $object['path'])) { - return false; - } - } elseif ( ! $this->deleteDir($object['path'])) { - return false; - } - } - - return ftp_rmdir($connection, $dirname); - } - - /** - * @inheritdoc - */ - public function createDir($dirname, Config $config) - { - $connection = $this->getConnection(); - $directories = explode('/', $dirname); - - foreach ($directories as $directory) { - if (false === $this->createActualDirectory($directory, $connection)) { - $this->setConnectionRoot(); - - return false; - } - - ftp_chdir($connection, $directory); - } - - $this->setConnectionRoot(); - - return ['type' => 'dir', 'path' => $dirname]; - } - - /** - * Create a directory. - * - * @param string $directory - * @param resource $connection - * - * @return bool - */ - protected function createActualDirectory($directory, $connection) - { - // List the current directory - $listing = ftp_nlist($connection, '.') ?: []; - - foreach ($listing as $key => $item) { - if (preg_match('~^\./.*~', $item)) { - $listing[$key] = substr($item, 2); - } - } - - if (in_array($directory, $listing, true)) { - return true; - } - - return (boolean) ftp_mkdir($connection, $directory); - } - - /** - * @inheritdoc - */ - public function getMetadata($path) - { - if ($path === '') { - return ['type' => 'dir', 'path' => '']; - } - - if (@ftp_chdir($this->getConnection(), $path) === true) { - $this->setConnectionRoot(); - - return ['type' => 'dir', 'path' => $path]; - } - - $listing = $this->ftpRawlist('-A', $path); - - if (empty($listing) || in_array('total 0', $listing, true)) { - return false; - } - - if (preg_match('/.* not found/', $listing[0])) { - return false; - } - - if (preg_match('/^total [0-9]*$/', $listing[0])) { - array_shift($listing); - } - - return $this->normalizeObject($listing[0], ''); - } - - /** - * @inheritdoc - */ - public function getMimetype($path) - { - if ( ! $metadata = $this->getMetadata($path)) { - return false; - } - - $metadata['mimetype'] = MimeType::detectByFilename($path); - - return $metadata; - } - - /** - * @inheritdoc - */ - public function getTimestamp($path) - { - $timestamp = ftp_mdtm($this->getConnection(), $path); - - return ($timestamp !== -1) ? ['path' => $path, 'timestamp' => $timestamp] : false; - } - - /** - * @inheritdoc - */ - public function read($path) - { - if ( ! $object = $this->readStream($path)) { - return false; - } - - $object['contents'] = stream_get_contents($object['stream']); - fclose($object['stream']); - unset($object['stream']); - - return $object; - } - - /** - * @inheritdoc - */ - public function readStream($path) - { - $stream = fopen('php://temp', 'w+b'); - $result = ftp_fget($this->getConnection(), $stream, $path, $this->transferMode); - rewind($stream); - - if ( ! $result) { - fclose($stream); - - return false; - } - - return ['type' => 'file', 'path' => $path, 'stream' => $stream]; - } - - /** - * @inheritdoc - */ - public function setVisibility($path, $visibility) - { - $mode = $visibility === AdapterInterface::VISIBILITY_PUBLIC ? $this->getPermPublic() : $this->getPermPrivate(); - - if ( ! ftp_chmod($this->getConnection(), $mode, $path)) { - return false; - } - - return compact('path', 'visibility'); - } - - /** - * @inheritdoc - * - * @param string $directory - */ - protected function listDirectoryContents($directory, $recursive = true) - { - if ($recursive && $this->recurseManually) { - return $this->listDirectoryContentsRecursive($directory); - } - - $options = $recursive ? '-alnR' : '-aln'; - $listing = $this->ftpRawlist($options, $directory); - - return $listing ? $this->normalizeListing($listing, $directory) : []; - } - - /** - * @inheritdoc - * - * @param string $directory - */ - protected function listDirectoryContentsRecursive($directory) - { - $listing = $this->normalizeListing($this->ftpRawlist('-aln', $directory) ?: [], $directory); - $output = []; - - foreach ($listing as $item) { - $output[] = $item; - if ($item['type'] !== 'dir') { - continue; - } - $output = array_merge($output, $this->listDirectoryContentsRecursive($item['path'])); - } - - return $output; - } - - /** - * Check if the connection is open. - * - * @return bool - * - * @throws ConnectionErrorException - */ - public function isConnected() - { - return $this->hasFtpConnection() && $this->getRawExecResponseCode('NOOP') === 200; - } - - /** - * @return bool - */ - protected function isPureFtpdServer() - { - $response = ftp_raw($this->connection, 'HELP'); - - return stripos(implode(' ', $response), 'Pure-FTPd') !== false; - } - - /** - * The ftp_rawlist function with optional escaping. - * - * @param string $options - * @param string $path - * - * @return array - */ - protected function ftpRawlist($options, $path) - { - $connection = $this->getConnection(); - - if ($this->isPureFtpd) { - $path = str_replace([' ', '[', ']'], ['\ ', '\\[', '\\]'], $path); - } - - return ftp_rawlist($connection, $options . ' ' . $this->escapePath($path)); - } - - private function getRawExecResponseCode($command) - { - $response = @ftp_raw($this->connection, trim($command)) ?: []; - - return (int) preg_replace('/\D/', '', implode(' ', (array) $response)); - } - - private function hasFtpConnection(): bool - { - return is_resource($this->connection) || $this->connection instanceof \FTP\Connection; - } -} diff --git a/vendor/league/flysystem/src/Adapter/Ftpd.php b/vendor/league/flysystem/src/Adapter/Ftpd.php deleted file mode 100644 index 7e71d19..0000000 --- a/vendor/league/flysystem/src/Adapter/Ftpd.php +++ /dev/null @@ -1,48 +0,0 @@ - 'dir', 'path' => '']; - } - - if (@ftp_chdir($this->getConnection(), $path) === true) { - $this->setConnectionRoot(); - - return ['type' => 'dir', 'path' => $path]; - } - - $object = ftp_raw($this->getConnection(), 'STAT ' . $this->escapePath($path)); - - if ( ! $object || count($object) < 3) { - return false; - } - - if (substr($object[1], 0, 5) === "ftpd:") { - return false; - } - - return $this->normalizeObject($object[1], ''); - } - - /** - * @inheritdoc - */ - protected function listDirectoryContents($directory, $recursive = true) - { - $listing = ftp_rawlist($this->getConnection(), $this->escapePath($directory), $recursive); - - if ($listing === false || ( ! empty($listing) && substr($listing[0], 0, 5) === "ftpd:")) { - return []; - } - - return $this->normalizeListing($listing, $directory); - } -} diff --git a/vendor/league/flysystem/src/Adapter/Local.php b/vendor/league/flysystem/src/Adapter/Local.php deleted file mode 100644 index 747c463..0000000 --- a/vendor/league/flysystem/src/Adapter/Local.php +++ /dev/null @@ -1,533 +0,0 @@ - [ - 'public' => 0644, - 'private' => 0600, - ], - 'dir' => [ - 'public' => 0755, - 'private' => 0700, - ], - ]; - - /** - * @var string - */ - protected $pathSeparator = DIRECTORY_SEPARATOR; - - /** - * @var array - */ - protected $permissionMap; - - /** - * @var int - */ - protected $writeFlags; - - /** - * @var int - */ - private $linkHandling; - - /** - * Constructor. - * - * @param string $root - * @param int $writeFlags - * @param int $linkHandling - * @param array $permissions - * - * @throws LogicException - */ - public function __construct($root, $writeFlags = LOCK_EX, $linkHandling = self::DISALLOW_LINKS, array $permissions = []) - { - $root = is_link($root) ? realpath($root) : $root; - $this->permissionMap = array_replace_recursive(static::$permissions, $permissions); - $this->ensureDirectory($root); - - if ( ! is_dir($root) || ! is_readable($root)) { - throw new LogicException('The root path ' . $root . ' is not readable.'); - } - - $this->setPathPrefix($root); - $this->writeFlags = $writeFlags; - $this->linkHandling = $linkHandling; - } - - /** - * Ensure the root directory exists. - * - * @param string $root root directory path - * - * @return void - * - * @throws Exception in case the root directory can not be created - */ - protected function ensureDirectory($root) - { - if ( ! is_dir($root)) { - $umask = umask(0); - - if ( ! @mkdir($root, $this->permissionMap['dir']['public'], true)) { - $mkdirError = error_get_last(); - } - - umask($umask); - clearstatcache(false, $root); - - if ( ! is_dir($root)) { - $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : ''; - throw new Exception(sprintf('Impossible to create the root directory "%s". %s', $root, $errorMessage)); - } - } - } - - /** - * @inheritdoc - */ - public function has($path) - { - $location = $this->applyPathPrefix($path); - - return file_exists($location); - } - - /** - * @inheritdoc - */ - public function write($path, $contents, Config $config) - { - $location = $this->applyPathPrefix($path); - $this->ensureDirectory(dirname($location)); - - if (($size = file_put_contents($location, $contents, $this->writeFlags)) === false) { - return false; - } - - $type = 'file'; - $result = compact('contents', 'type', 'size', 'path'); - - if ($visibility = $config->get('visibility')) { - $result['visibility'] = $visibility; - $this->setVisibility($path, $visibility); - } - - return $result; - } - - /** - * @inheritdoc - */ - public function writeStream($path, $resource, Config $config) - { - $location = $this->applyPathPrefix($path); - $this->ensureDirectory(dirname($location)); - $stream = fopen($location, 'w+b'); - - if ( ! $stream || stream_copy_to_stream($resource, $stream) === false || ! fclose($stream)) { - return false; - } - - $type = 'file'; - $result = compact('type', 'path'); - - if ($visibility = $config->get('visibility')) { - $this->setVisibility($path, $visibility); - $result['visibility'] = $visibility; - } - - return $result; - } - - /** - * @inheritdoc - */ - public function readStream($path) - { - $location = $this->applyPathPrefix($path); - $stream = fopen($location, 'rb'); - - return ['type' => 'file', 'path' => $path, 'stream' => $stream]; - } - - /** - * @inheritdoc - */ - public function updateStream($path, $resource, Config $config) - { - return $this->writeStream($path, $resource, $config); - } - - /** - * @inheritdoc - */ - public function update($path, $contents, Config $config) - { - $location = $this->applyPathPrefix($path); - $size = file_put_contents($location, $contents, $this->writeFlags); - - if ($size === false) { - return false; - } - - $type = 'file'; - - $result = compact('type', 'path', 'size', 'contents'); - - if ($visibility = $config->get('visibility')) { - $this->setVisibility($path, $visibility); - $result['visibility'] = $visibility; - } - - return $result; - } - - /** - * @inheritdoc - */ - public function read($path) - { - $location = $this->applyPathPrefix($path); - $contents = @file_get_contents($location); - - if ($contents === false) { - return false; - } - - return ['type' => 'file', 'path' => $path, 'contents' => $contents]; - } - - /** - * @inheritdoc - */ - public function rename($path, $newpath) - { - $location = $this->applyPathPrefix($path); - $destination = $this->applyPathPrefix($newpath); - $parentDirectory = $this->applyPathPrefix(Util::dirname($newpath)); - $this->ensureDirectory($parentDirectory); - - return rename($location, $destination); - } - - /** - * @inheritdoc - */ - public function copy($path, $newpath) - { - $location = $this->applyPathPrefix($path); - $destination = $this->applyPathPrefix($newpath); - $this->ensureDirectory(dirname($destination)); - - return copy($location, $destination); - } - - /** - * @inheritdoc - */ - public function delete($path) - { - $location = $this->applyPathPrefix($path); - - return @unlink($location); - } - - /** - * @inheritdoc - */ - public function listContents($directory = '', $recursive = false) - { - $result = []; - $location = $this->applyPathPrefix($directory); - - if ( ! is_dir($location)) { - return []; - } - - $iterator = $recursive ? $this->getRecursiveDirectoryIterator($location) : $this->getDirectoryIterator($location); - - foreach ($iterator as $file) { - $path = $this->getFilePath($file); - - if (preg_match('#(^|/|\\\\)\.{1,2}$#', $path)) { - continue; - } - - $result[] = $this->normalizeFileInfo($file); - } - - unset($iterator); - - return array_filter($result); - } - - /** - * @inheritdoc - */ - public function getMetadata($path) - { - $location = $this->applyPathPrefix($path); - clearstatcache(false, $location); - $info = new SplFileInfo($location); - - return $this->normalizeFileInfo($info); - } - - /** - * @inheritdoc - */ - public function getSize($path) - { - return $this->getMetadata($path); - } - - /** - * @inheritdoc - */ - public function getMimetype($path) - { - $location = $this->applyPathPrefix($path); - $finfo = new Finfo(FILEINFO_MIME_TYPE); - $mimetype = $finfo->file($location); - - if (in_array($mimetype, ['application/octet-stream', 'inode/x-empty', 'application/x-empty'])) { - $mimetype = Util\MimeType::detectByFilename($location); - } - - return ['path' => $path, 'type' => 'file', 'mimetype' => $mimetype]; - } - - /** - * @inheritdoc - */ - public function getTimestamp($path) - { - return $this->getMetadata($path); - } - - /** - * @inheritdoc - */ - public function getVisibility($path) - { - $location = $this->applyPathPrefix($path); - clearstatcache(false, $location); - $permissions = octdec(substr(sprintf('%o', fileperms($location)), -4)); - $type = is_dir($location) ? 'dir' : 'file'; - - foreach ($this->permissionMap[$type] as $visibility => $visibilityPermissions) { - if ($visibilityPermissions == $permissions) { - return compact('path', 'visibility'); - } - } - - $visibility = substr(sprintf('%o', fileperms($location)), -4); - - return compact('path', 'visibility'); - } - - /** - * @inheritdoc - */ - public function setVisibility($path, $visibility) - { - $location = $this->applyPathPrefix($path); - $type = is_dir($location) ? 'dir' : 'file'; - $success = chmod($location, $this->permissionMap[$type][$visibility]); - - if ($success === false) { - return false; - } - - return compact('path', 'visibility'); - } - - /** - * @inheritdoc - */ - public function createDir($dirname, Config $config) - { - $location = $this->applyPathPrefix($dirname); - $umask = umask(0); - $visibility = $config->get('visibility', 'public'); - $return = ['path' => $dirname, 'type' => 'dir']; - - if ( ! is_dir($location)) { - if (false === @mkdir($location, $this->permissionMap['dir'][$visibility], true) - || false === is_dir($location)) { - $return = false; - } - } - - umask($umask); - - return $return; - } - - /** - * @inheritdoc - */ - public function deleteDir($dirname) - { - $location = $this->applyPathPrefix($dirname); - - if ( ! is_dir($location)) { - return false; - } - - $contents = $this->getRecursiveDirectoryIterator($location, RecursiveIteratorIterator::CHILD_FIRST); - - /** @var SplFileInfo $file */ - foreach ($contents as $file) { - $this->guardAgainstUnreadableFileInfo($file); - $this->deleteFileInfoObject($file); - } - - unset($contents); - - return rmdir($location); - } - - /** - * @param SplFileInfo $file - */ - protected function deleteFileInfoObject(SplFileInfo $file) - { - switch ($file->getType()) { - case 'dir': - rmdir($file->getRealPath()); - break; - case 'link': - unlink($file->getPathname()); - break; - default: - unlink($file->getRealPath()); - } - } - - /** - * Normalize the file info. - * - * @param SplFileInfo $file - * - * @return array|void - * - * @throws NotSupportedException - */ - protected function normalizeFileInfo(SplFileInfo $file) - { - if ( ! $file->isLink()) { - return $this->mapFileInfo($file); - } - - if ($this->linkHandling & self::DISALLOW_LINKS) { - throw NotSupportedException::forLink($file); - } - } - - /** - * Get the normalized path from a SplFileInfo object. - * - * @param SplFileInfo $file - * - * @return string - */ - protected function getFilePath(SplFileInfo $file) - { - $location = $file->getPathname(); - $path = $this->removePathPrefix($location); - - return trim(str_replace('\\', '/', $path), '/'); - } - - /** - * @param string $path - * @param int $mode - * - * @return RecursiveIteratorIterator - */ - protected function getRecursiveDirectoryIterator($path, $mode = RecursiveIteratorIterator::SELF_FIRST) - { - return new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), - $mode - ); - } - - /** - * @param string $path - * - * @return DirectoryIterator - */ - protected function getDirectoryIterator($path) - { - $iterator = new DirectoryIterator($path); - - return $iterator; - } - - /** - * @param SplFileInfo $file - * - * @return array - */ - protected function mapFileInfo(SplFileInfo $file) - { - $normalized = [ - 'type' => $file->getType(), - 'path' => $this->getFilePath($file), - ]; - - $normalized['timestamp'] = $file->getMTime(); - - if ($normalized['type'] === 'file') { - $normalized['size'] = $file->getSize(); - } - - return $normalized; - } - - /** - * @param SplFileInfo $file - * - * @throws UnreadableFileException - */ - protected function guardAgainstUnreadableFileInfo(SplFileInfo $file) - { - if ( ! $file->isReadable()) { - throw UnreadableFileException::forFileInfo($file); - } - } -} diff --git a/vendor/league/flysystem/src/Adapter/NullAdapter.php b/vendor/league/flysystem/src/Adapter/NullAdapter.php deleted file mode 100644 index 2527087..0000000 --- a/vendor/league/flysystem/src/Adapter/NullAdapter.php +++ /dev/null @@ -1,144 +0,0 @@ -get('visibility')) { - $result['visibility'] = $visibility; - } - - return $result; - } - - /** - * @inheritdoc - */ - public function update($path, $contents, Config $config) - { - return false; - } - - /** - * @inheritdoc - */ - public function read($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function rename($path, $newpath) - { - return false; - } - - /** - * @inheritdoc - */ - public function delete($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function listContents($directory = '', $recursive = false) - { - return []; - } - - /** - * @inheritdoc - */ - public function getMetadata($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function getSize($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function getMimetype($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function getTimestamp($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function getVisibility($path) - { - return false; - } - - /** - * @inheritdoc - */ - public function setVisibility($path, $visibility) - { - return compact('visibility'); - } - - /** - * @inheritdoc - */ - public function createDir($dirname, Config $config) - { - return ['path' => $dirname, 'type' => 'dir']; - } - - /** - * @inheritdoc - */ - public function deleteDir($dirname) - { - return false; - } -} diff --git a/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php b/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php deleted file mode 100644 index fc0a747..0000000 --- a/vendor/league/flysystem/src/Adapter/Polyfill/NotSupportingVisibilityTrait.php +++ /dev/null @@ -1,33 +0,0 @@ -readStream($path); - - if ($response === false || ! is_resource($response['stream'])) { - return false; - } - - $result = $this->writeStream($newpath, $response['stream'], new Config()); - - if ($result !== false && is_resource($response['stream'])) { - fclose($response['stream']); - } - - return $result !== false; - } - - // Required abstract method - - /** - * @param string $path - * - * @return resource - */ - abstract public function readStream($path); - - /** - * @param string $path - * @param resource $resource - * @param Config $config - * - * @return resource - */ - abstract public function writeStream($path, $resource, Config $config); -} diff --git a/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php b/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php deleted file mode 100644 index 2b31c01..0000000 --- a/vendor/league/flysystem/src/Adapter/Polyfill/StreamedReadingTrait.php +++ /dev/null @@ -1,44 +0,0 @@ -read($path)) { - return false; - } - - $stream = fopen('php://temp', 'w+b'); - fwrite($stream, $data['contents']); - rewind($stream); - $data['stream'] = $stream; - unset($data['contents']); - - return $data; - } - - /** - * Reads a file. - * - * @param string $path - * - * @return array|false - * - * @see League\Flysystem\ReadInterface::read() - */ - abstract public function read($path); -} diff --git a/vendor/league/flysystem/src/Adapter/Polyfill/StreamedTrait.php b/vendor/league/flysystem/src/Adapter/Polyfill/StreamedTrait.php deleted file mode 100644 index 8042496..0000000 --- a/vendor/league/flysystem/src/Adapter/Polyfill/StreamedTrait.php +++ /dev/null @@ -1,9 +0,0 @@ -stream($path, $resource, $config, 'write'); - } - - /** - * Update a file using a stream. - * - * @param string $path - * @param resource $resource - * @param Config $config Config object or visibility setting - * - * @return mixed false of file metadata - */ - public function updateStream($path, $resource, Config $config) - { - return $this->stream($path, $resource, $config, 'update'); - } - - // Required abstract methods - abstract public function write($pash, $contents, Config $config); - abstract public function update($pash, $contents, Config $config); -} diff --git a/vendor/league/flysystem/src/Adapter/SynologyFtp.php b/vendor/league/flysystem/src/Adapter/SynologyFtp.php deleted file mode 100644 index fe0d344..0000000 --- a/vendor/league/flysystem/src/Adapter/SynologyFtp.php +++ /dev/null @@ -1,8 +0,0 @@ -settings = $settings; - } - - /** - * Get a setting. - * - * @param string $key - * @param mixed $default - * - * @return mixed config setting or default when not found - */ - public function get($key, $default = null) - { - if ( ! array_key_exists($key, $this->settings)) { - return $this->getDefault($key, $default); - } - - return $this->settings[$key]; - } - - /** - * Check if an item exists by key. - * - * @param string $key - * - * @return bool - */ - public function has($key) - { - if (array_key_exists($key, $this->settings)) { - return true; - } - - return $this->fallback instanceof Config - ? $this->fallback->has($key) - : false; - } - - /** - * Try to retrieve a default setting from a config fallback. - * - * @param string $key - * @param mixed $default - * - * @return mixed config setting or default when not found - */ - protected function getDefault($key, $default) - { - if ( ! $this->fallback) { - return $default; - } - - return $this->fallback->get($key, $default); - } - - /** - * Set a setting. - * - * @param string $key - * @param mixed $value - * - * @return $this - */ - public function set($key, $value) - { - $this->settings[$key] = $value; - - return $this; - } - - /** - * Set the fallback. - * - * @param Config $fallback - * - * @return $this - */ - public function setFallback(Config $fallback) - { - $this->fallback = $fallback; - - return $this; - } -} diff --git a/vendor/league/flysystem/src/ConfigAwareTrait.php b/vendor/league/flysystem/src/ConfigAwareTrait.php deleted file mode 100644 index 202d605..0000000 --- a/vendor/league/flysystem/src/ConfigAwareTrait.php +++ /dev/null @@ -1,49 +0,0 @@ -config = $config ? Util::ensureConfig($config) : new Config; - } - - /** - * Get the Config. - * - * @return Config config object - */ - public function getConfig() - { - return $this->config; - } - - /** - * Convert a config array to a Config object with the correct fallback. - * - * @param array $config - * - * @return Config - */ - protected function prepareConfig(array $config) - { - $config = new Config($config); - $config->setFallback($this->getConfig()); - - return $config; - } -} diff --git a/vendor/league/flysystem/src/ConnectionErrorException.php b/vendor/league/flysystem/src/ConnectionErrorException.php deleted file mode 100644 index adb651d..0000000 --- a/vendor/league/flysystem/src/ConnectionErrorException.php +++ /dev/null @@ -1,9 +0,0 @@ -filesystem->deleteDir($this->path); - } - - /** - * List the directory contents. - * - * @param bool $recursive - * - * @return array|bool directory contents or false - */ - public function getContents($recursive = false) - { - return $this->filesystem->listContents($this->path, $recursive); - } -} diff --git a/vendor/league/flysystem/src/DirectoryAttributes.php b/vendor/league/flysystem/src/DirectoryAttributes.php deleted file mode 100644 index 94e6218..0000000 --- a/vendor/league/flysystem/src/DirectoryAttributes.php +++ /dev/null @@ -1,110 +0,0 @@ -path = $path; - $this->visibility = $visibility; - $this->lastModified = $lastModified; - $this->extraMetadata = $extraMetadata; - } - - public function path(): string - { - return $this->path; - } - - public function type(): string - { - return StorageAttributes::TYPE_DIRECTORY; - } - - public function visibility(): ?string - { - return $this->visibility; - } - - public function lastModified(): ?int - { - return $this->lastModified; - } - - public function extraMetadata(): array - { - return $this->extraMetadata; - } - - public function isFile(): bool - { - return false; - } - - public function isDir(): bool - { - return true; - } - - public function withPath(string $path): StorageAttributes - { - $clone = clone $this; - $clone->path = $path; - - return $clone; - } - - public static function fromArray(array $attributes): StorageAttributes - { - return new DirectoryAttributes( - $attributes[StorageAttributes::ATTRIBUTE_PATH], - $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? [] - ); - } - - /** - * @inheritDoc - */ - public function jsonSerialize(): array - { - return [ - StorageAttributes::ATTRIBUTE_TYPE => $this->type, - StorageAttributes::ATTRIBUTE_PATH => $this->path, - StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility, - StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified, - StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, - ]; - } -} diff --git a/vendor/league/flysystem/src/DirectoryListing.php b/vendor/league/flysystem/src/DirectoryListing.php deleted file mode 100644 index 0f429a8..0000000 --- a/vendor/league/flysystem/src/DirectoryListing.php +++ /dev/null @@ -1,84 +0,0 @@ - - */ - private $listing; - - /** - * @param iterable $listing - */ - public function __construct(iterable $listing) - { - $this->listing = $listing; - } - - public function filter(callable $filter): DirectoryListing - { - $generator = (static function (iterable $listing) use ($filter): Generator { - foreach ($listing as $item) { - if ($filter($item)) { - yield $item; - } - } - })($this->listing); - - return new DirectoryListing($generator); - } - - public function map(callable $mapper): DirectoryListing - { - $generator = (static function (iterable $listing) use ($mapper): Generator { - foreach ($listing as $item) { - yield $mapper($item); - } - })($this->listing); - - return new DirectoryListing($generator); - } - - public function sortByPath(): DirectoryListing - { - $listing = $this->toArray(); - - usort($listing, function (StorageAttributes $a, StorageAttributes $b) { - return $a->path() <=> $b->path(); - }); - - return new DirectoryListing($listing); - } - - /** - * @return Traversable - */ - public function getIterator(): Traversable - { - return $this->listing instanceof Traversable - ? $this->listing - : new ArrayIterator($this->listing); - } - - /** - * @return T[] - */ - public function toArray(): array - { - return $this->listing instanceof Traversable - ? iterator_to_array($this->listing, false) - : (array) $this->listing; - } -} diff --git a/vendor/league/flysystem/src/Exception.php b/vendor/league/flysystem/src/Exception.php deleted file mode 100644 index 4596c0a..0000000 --- a/vendor/league/flysystem/src/Exception.php +++ /dev/null @@ -1,8 +0,0 @@ -filesystem->has($this->path); - } - - /** - * Read the file. - * - * @return string|false file contents - */ - public function read() - { - return $this->filesystem->read($this->path); - } - - /** - * Read the file as a stream. - * - * @return resource|false file stream - */ - public function readStream() - { - return $this->filesystem->readStream($this->path); - } - - /** - * Write the new file. - * - * @param string $content - * - * @return bool success boolean - */ - public function write($content) - { - return $this->filesystem->write($this->path, $content); - } - - /** - * Write the new file using a stream. - * - * @param resource $resource - * - * @return bool success boolean - */ - public function writeStream($resource) - { - return $this->filesystem->writeStream($this->path, $resource); - } - - /** - * Update the file contents. - * - * @param string $content - * - * @return bool success boolean - */ - public function update($content) - { - return $this->filesystem->update($this->path, $content); - } - - /** - * Update the file contents with a stream. - * - * @param resource $resource - * - * @return bool success boolean - */ - public function updateStream($resource) - { - return $this->filesystem->updateStream($this->path, $resource); - } - - /** - * Create the file or update if exists. - * - * @param string $content - * - * @return bool success boolean - */ - public function put($content) - { - return $this->filesystem->put($this->path, $content); - } - - /** - * Create the file or update if exists using a stream. - * - * @param resource $resource - * - * @return bool success boolean - */ - public function putStream($resource) - { - return $this->filesystem->putStream($this->path, $resource); - } - - /** - * Rename the file. - * - * @param string $newpath - * - * @return bool success boolean - */ - public function rename($newpath) - { - if ($this->filesystem->rename($this->path, $newpath)) { - $this->path = $newpath; - - return true; - } - - return false; - } - - /** - * Copy the file. - * - * @param string $newpath - * - * @return File|false new file or false - */ - public function copy($newpath) - { - if ($this->filesystem->copy($this->path, $newpath)) { - return new File($this->filesystem, $newpath); - } - - return false; - } - - /** - * Get the file's timestamp. - * - * @return string|false The timestamp or false on failure. - */ - public function getTimestamp() - { - return $this->filesystem->getTimestamp($this->path); - } - - /** - * Get the file's mimetype. - * - * @return string|false The file mime-type or false on failure. - */ - public function getMimetype() - { - return $this->filesystem->getMimetype($this->path); - } - - /** - * Get the file's visibility. - * - * @return string|false The visibility (public|private) or false on failure. - */ - public function getVisibility() - { - return $this->filesystem->getVisibility($this->path); - } - - /** - * Get the file's metadata. - * - * @return array|false The file metadata or false on failure. - */ - public function getMetadata() - { - return $this->filesystem->getMetadata($this->path); - } - - /** - * Get the file size. - * - * @return int|false The file size or false on failure. - */ - public function getSize() - { - return $this->filesystem->getSize($this->path); - } - - /** - * Delete the file. - * - * @return bool success boolean - */ - public function delete() - { - return $this->filesystem->delete($this->path); - } -} diff --git a/vendor/league/flysystem/src/FileAttributes.php b/vendor/league/flysystem/src/FileAttributes.php deleted file mode 100644 index 2efd9c4..0000000 --- a/vendor/league/flysystem/src/FileAttributes.php +++ /dev/null @@ -1,139 +0,0 @@ -path = $path; - $this->fileSize = $fileSize; - $this->visibility = $visibility; - $this->lastModified = $lastModified; - $this->mimeType = $mimeType; - $this->extraMetadata = $extraMetadata; - } - - public function type(): string - { - return $this->type; - } - - public function path(): string - { - return $this->path; - } - - public function fileSize(): ?int - { - return $this->fileSize; - } - - public function visibility(): ?string - { - return $this->visibility; - } - - public function lastModified(): ?int - { - return $this->lastModified; - } - - public function mimeType(): ?string - { - return $this->mimeType; - } - - public function extraMetadata(): array - { - return $this->extraMetadata; - } - - public function isFile(): bool - { - return true; - } - - public function isDir(): bool - { - return false; - } - - public function withPath(string $path): StorageAttributes - { - $clone = clone $this; - $clone->path = $path; - - return $clone; - } - - public static function fromArray(array $attributes): StorageAttributes - { - return new FileAttributes( - $attributes[StorageAttributes::ATTRIBUTE_PATH], - $attributes[StorageAttributes::ATTRIBUTE_FILE_SIZE] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_VISIBILITY] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_LAST_MODIFIED] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_MIME_TYPE] ?? null, - $attributes[StorageAttributes::ATTRIBUTE_EXTRA_METADATA] ?? [] - ); - } - - public function jsonSerialize(): array - { - return [ - StorageAttributes::ATTRIBUTE_TYPE => self::TYPE_FILE, - StorageAttributes::ATTRIBUTE_PATH => $this->path, - StorageAttributes::ATTRIBUTE_FILE_SIZE => $this->fileSize, - StorageAttributes::ATTRIBUTE_VISIBILITY => $this->visibility, - StorageAttributes::ATTRIBUTE_LAST_MODIFIED => $this->lastModified, - StorageAttributes::ATTRIBUTE_MIME_TYPE => $this->mimeType, - StorageAttributes::ATTRIBUTE_EXTRA_METADATA => $this->extraMetadata, - ]; - } -} diff --git a/vendor/league/flysystem/src/FileExistsException.php b/vendor/league/flysystem/src/FileExistsException.php deleted file mode 100644 index c82e20c..0000000 --- a/vendor/league/flysystem/src/FileExistsException.php +++ /dev/null @@ -1,37 +0,0 @@ -path = $path; - - parent::__construct('File already exists at path: ' . $this->getPath(), $code, $previous); - } - - /** - * Get the path which was found. - * - * @return string - */ - public function getPath() - { - return $this->path; - } -} diff --git a/vendor/league/flysystem/src/FileNotFoundException.php b/vendor/league/flysystem/src/FileNotFoundException.php deleted file mode 100644 index 989df69..0000000 --- a/vendor/league/flysystem/src/FileNotFoundException.php +++ /dev/null @@ -1,37 +0,0 @@ -path = $path; - - parent::__construct('File not found at path: ' . $this->getPath(), $code, $previous); - } - - /** - * Get the path which was not found. - * - * @return string - */ - public function getPath() - { - return $this->path; - } -} diff --git a/vendor/league/flysystem/src/Filesystem.php b/vendor/league/flysystem/src/Filesystem.php deleted file mode 100644 index c4eaf27..0000000 --- a/vendor/league/flysystem/src/Filesystem.php +++ /dev/null @@ -1,409 +0,0 @@ -adapter = $adapter; - $this->setConfig($config); - } - - /** - * Get the Adapter. - * - * @return AdapterInterface adapter - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * @inheritdoc - */ - public function has($path) - { - $path = Util::normalizePath($path); - - return strlen($path) === 0 ? false : (bool) $this->getAdapter()->has($path); - } - - /** - * @inheritdoc - */ - public function write($path, $contents, array $config = []) - { - $path = Util::normalizePath($path); - $this->assertAbsent($path); - $config = $this->prepareConfig($config); - - return (bool) $this->getAdapter()->write($path, $contents, $config); - } - - /** - * @inheritdoc - */ - public function writeStream($path, $resource, array $config = []) - { - if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') { - throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); - } - - $path = Util::normalizePath($path); - $this->assertAbsent($path); - $config = $this->prepareConfig($config); - - Util::rewindStream($resource); - - return (bool) $this->getAdapter()->writeStream($path, $resource, $config); - } - - /** - * @inheritdoc - */ - public function put($path, $contents, array $config = []) - { - $path = Util::normalizePath($path); - $config = $this->prepareConfig($config); - - if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) { - return (bool) $this->getAdapter()->update($path, $contents, $config); - } - - return (bool) $this->getAdapter()->write($path, $contents, $config); - } - - /** - * @inheritdoc - */ - public function putStream($path, $resource, array $config = []) - { - if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') { - throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); - } - - $path = Util::normalizePath($path); - $config = $this->prepareConfig($config); - Util::rewindStream($resource); - - if ( ! $this->getAdapter() instanceof CanOverwriteFiles && $this->has($path)) { - return (bool) $this->getAdapter()->updateStream($path, $resource, $config); - } - - return (bool) $this->getAdapter()->writeStream($path, $resource, $config); - } - - /** - * @inheritdoc - */ - public function readAndDelete($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - $contents = $this->read($path); - - if ($contents === false) { - return false; - } - - $this->delete($path); - - return $contents; - } - - /** - * @inheritdoc - */ - public function update($path, $contents, array $config = []) - { - $path = Util::normalizePath($path); - $config = $this->prepareConfig($config); - - $this->assertPresent($path); - - return (bool) $this->getAdapter()->update($path, $contents, $config); - } - - /** - * @inheritdoc - */ - public function updateStream($path, $resource, array $config = []) - { - if ( ! is_resource($resource) || get_resource_type($resource) !== 'stream') { - throw new InvalidArgumentException(__METHOD__ . ' expects argument #2 to be a valid resource.'); - } - - $path = Util::normalizePath($path); - $config = $this->prepareConfig($config); - $this->assertPresent($path); - Util::rewindStream($resource); - - return (bool) $this->getAdapter()->updateStream($path, $resource, $config); - } - - /** - * @inheritdoc - */ - public function read($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if ( ! ($object = $this->getAdapter()->read($path))) { - return false; - } - - return $object['contents']; - } - - /** - * @inheritdoc - */ - public function readStream($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if ( ! $object = $this->getAdapter()->readStream($path)) { - return false; - } - - return $object['stream']; - } - - /** - * @inheritdoc - */ - public function rename($path, $newpath) - { - $path = Util::normalizePath($path); - $newpath = Util::normalizePath($newpath); - $this->assertPresent($path); - $this->assertAbsent($newpath); - - return (bool) $this->getAdapter()->rename($path, $newpath); - } - - /** - * @inheritdoc - */ - public function copy($path, $newpath) - { - $path = Util::normalizePath($path); - $newpath = Util::normalizePath($newpath); - $this->assertPresent($path); - $this->assertAbsent($newpath); - - return $this->getAdapter()->copy($path, $newpath); - } - - /** - * @inheritdoc - */ - public function delete($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - return $this->getAdapter()->delete($path); - } - - /** - * @inheritdoc - */ - public function deleteDir($dirname) - { - $dirname = Util::normalizePath($dirname); - - if ($dirname === '') { - throw new RootViolationException('Root directories can not be deleted.'); - } - - return (bool) $this->getAdapter()->deleteDir($dirname); - } - - /** - * @inheritdoc - */ - public function createDir($dirname, array $config = []) - { - $dirname = Util::normalizePath($dirname); - $config = $this->prepareConfig($config); - - return (bool) $this->getAdapter()->createDir($dirname, $config); - } - - /** - * @inheritdoc - */ - public function listContents($directory = '', $recursive = false) - { - $directory = Util::normalizePath($directory); - $contents = $this->getAdapter()->listContents($directory, $recursive); - - return (new ContentListingFormatter($directory, $recursive, $this->config->get('case_sensitive', true))) - ->formatListing($contents); - } - - /** - * @inheritdoc - */ - public function getMimetype($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if (( ! $object = $this->getAdapter()->getMimetype($path)) || ! array_key_exists('mimetype', $object)) { - return false; - } - - return $object['mimetype']; - } - - /** - * @inheritdoc - */ - public function getTimestamp($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if (( ! $object = $this->getAdapter()->getTimestamp($path)) || ! array_key_exists('timestamp', $object)) { - return false; - } - - return (int) $object['timestamp']; - } - - /** - * @inheritdoc - */ - public function getVisibility($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if (( ! $object = $this->getAdapter()->getVisibility($path)) || ! array_key_exists('visibility', $object)) { - return false; - } - - return $object['visibility']; - } - - /** - * @inheritdoc - */ - public function getSize($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - if (( ! $object = $this->getAdapter()->getSize($path)) || ! array_key_exists('size', $object)) { - return false; - } - - return (int) $object['size']; - } - - /** - * @inheritdoc - */ - public function setVisibility($path, $visibility) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - return (bool) $this->getAdapter()->setVisibility($path, $visibility); - } - - /** - * @inheritdoc - */ - public function getMetadata($path) - { - $path = Util::normalizePath($path); - $this->assertPresent($path); - - return $this->getAdapter()->getMetadata($path); - } - - /** - * @inheritdoc - */ - public function get($path, Handler $handler = null) - { - $path = Util::normalizePath($path); - - if ( ! $handler) { - $metadata = $this->getMetadata($path); - $handler = ($metadata && $metadata['type'] === 'file') ? new File($this, $path) : new Directory($this, $path); - } - - $handler->setPath($path); - $handler->setFilesystem($this); - - return $handler; - } - - /** - * Assert a file is present. - * - * @param string $path path to file - * - * @throws FileNotFoundException - * - * @return void - */ - public function assertPresent($path) - { - if ($this->config->get('disable_asserts', false) === false && ! $this->has($path)) { - throw new FileNotFoundException($path); - } - } - - /** - * Assert a file is absent. - * - * @param string $path path to file - * - * @throws FileExistsException - * - * @return void - */ - public function assertAbsent($path) - { - if ($this->config->get('disable_asserts', false) === false && $this->has($path)) { - throw new FileExistsException($path); - } - } -} diff --git a/vendor/league/flysystem/src/FilesystemAdapter.php b/vendor/league/flysystem/src/FilesystemAdapter.php deleted file mode 100644 index 6dcb51e..0000000 --- a/vendor/league/flysystem/src/FilesystemAdapter.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * @throws FilesystemException - */ - public function listContents(string $path, bool $deep): iterable; - - /** - * @throws UnableToMoveFile - * @throws FilesystemException - */ - public function move(string $source, string $destination, Config $config): void; - - /** - * @throws UnableToCopyFile - * @throws FilesystemException - */ - public function copy(string $source, string $destination, Config $config): void; -} diff --git a/vendor/league/flysystem/src/FilesystemException.php b/vendor/league/flysystem/src/FilesystemException.php deleted file mode 100644 index 3121e53..0000000 --- a/vendor/league/flysystem/src/FilesystemException.php +++ /dev/null @@ -1,7 +0,0 @@ - - * - * @throws FilesystemException - */ - public function listContents(string $location, bool $deep = self::LIST_SHALLOW): DirectoryListing; - - /** - * @throws UnableToRetrieveMetadata - * @throws FilesystemException - */ - public function lastModified(string $path): int; - - /** - * @throws UnableToRetrieveMetadata - * @throws FilesystemException - */ - public function fileSize(string $path): int; - - /** - * @throws UnableToRetrieveMetadata - * @throws FilesystemException - */ - public function mimeType(string $path): string; - - /** - * @throws UnableToRetrieveMetadata - * @throws FilesystemException - */ - public function visibility(string $path): string; -} diff --git a/vendor/league/flysystem/src/FilesystemWriter.php b/vendor/league/flysystem/src/FilesystemWriter.php deleted file mode 100644 index a24bb0f..0000000 --- a/vendor/league/flysystem/src/FilesystemWriter.php +++ /dev/null @@ -1,58 +0,0 @@ -path = $path; - $this->filesystem = $filesystem; - } - - /** - * Check whether the entree is a directory. - * - * @return bool - */ - public function isDir() - { - return $this->getType() === 'dir'; - } - - /** - * Check whether the entree is a file. - * - * @return bool - */ - public function isFile() - { - return $this->getType() === 'file'; - } - - /** - * Retrieve the entree type (file|dir). - * - * @return string file or dir - */ - public function getType() - { - $metadata = $this->filesystem->getMetadata($this->path); - - return $metadata ? $metadata['type'] : 'dir'; - } - - /** - * Set the Filesystem object. - * - * @param FilesystemInterface $filesystem - * - * @return $this - */ - public function setFilesystem(FilesystemInterface $filesystem) - { - $this->filesystem = $filesystem; - - return $this; - } - - /** - * Retrieve the Filesystem object. - * - * @return FilesystemInterface - */ - public function getFilesystem() - { - return $this->filesystem; - } - - /** - * Set the entree path. - * - * @param string $path - * - * @return $this - */ - public function setPath($path) - { - $this->path = $path; - - return $this; - } - - /** - * Retrieve the entree path. - * - * @return string path - */ - public function getPath() - { - return $this->path; - } - - /** - * Plugins pass-through. - * - * @param string $method - * @param array $arguments - * - * @return mixed - */ - public function __call($method, array $arguments) - { - array_unshift($arguments, $this->path); - $callback = [$this->filesystem, $method]; - - try { - return call_user_func_array($callback, $arguments); - } catch (BadMethodCallException $e) { - throw new BadMethodCallException( - 'Call to undefined method ' - . get_called_class() - . '::' . $method - ); - } - } -} diff --git a/vendor/league/flysystem/src/InvalidRootException.php b/vendor/league/flysystem/src/InvalidRootException.php deleted file mode 100644 index 468d1d5..0000000 --- a/vendor/league/flysystem/src/InvalidRootException.php +++ /dev/null @@ -1,9 +0,0 @@ -prefixer = new PathPrefixer($location, DIRECTORY_SEPARATOR); - $this->writeFlags = $writeFlags; - $this->linkHandling = $linkHandling; - $this->visibility = $visibility ?: new PortableVisibilityConverter(); - $this->ensureDirectoryExists($location, $this->visibility->defaultForDirectories()); - $this->mimeTypeDetector = $mimeTypeDetector ?: new FinfoMimeTypeDetector(); - } - - public function write(string $path, string $contents, Config $config): void - { - $this->writeToFile($path, $contents, $config); - } - - public function writeStream(string $path, $contents, Config $config): void - { - $this->writeToFile($path, $contents, $config); - } - - /** - * @param resource|string $contents - */ - private function writeToFile(string $path, $contents, Config $config): void - { - $prefixedLocation = $this->prefixer->prefixPath($path); - $this->ensureDirectoryExists( - dirname($prefixedLocation), - $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) - ); - error_clear_last(); - - if (@file_put_contents($prefixedLocation, $contents, $this->writeFlags) === false) { - throw UnableToWriteFile::atLocation($path, error_get_last()['message'] ?? ''); - } - - if ($visibility = $config->get(Config::OPTION_VISIBILITY)) { - $this->setVisibility($path, (string) $visibility); - } - } - - public function delete(string $path): void - { - $location = $this->prefixer->prefixPath($path); - - if ( ! file_exists($location)) { - return; - } - - error_clear_last(); - - if ( ! @unlink($location)) { - throw UnableToDeleteFile::atLocation($location, error_get_last()['message'] ?? ''); - } - } - - public function deleteDirectory(string $prefix): void - { - $location = $this->prefixer->prefixPath($prefix); - - if ( ! is_dir($location)) { - return; - } - - $contents = $this->listDirectoryRecursively($location, RecursiveIteratorIterator::CHILD_FIRST); - - /** @var SplFileInfo $file */ - foreach ($contents as $file) { - if ( ! $this->deleteFileInfoObject($file)) { - throw UnableToDeleteDirectory::atLocation($prefix, "Unable to delete file at " . $file->getPathname()); - } - } - - unset($contents); - - if ( ! @rmdir($location)) { - throw UnableToDeleteDirectory::atLocation($prefix, error_get_last()['message'] ?? ''); - } - } - - private function listDirectoryRecursively( - string $path, - int $mode = RecursiveIteratorIterator::SELF_FIRST - ): Generator { - yield from new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS), - $mode - ); - } - - protected function deleteFileInfoObject(SplFileInfo $file): bool - { - switch ($file->getType()) { - case 'dir': - return @rmdir((string) $file->getRealPath()); - case 'link': - return @unlink((string) $file->getPathname()); - default: - return @unlink((string) $file->getRealPath()); - } - } - - public function listContents(string $path, bool $deep): iterable - { - $location = $this->prefixer->prefixPath($path); - - if ( ! is_dir($location)) { - return; - } - - /** @var SplFileInfo[] $iterator */ - $iterator = $deep ? $this->listDirectoryRecursively($location) : $this->listDirectory($location); - - foreach ($iterator as $fileInfo) { - if ($fileInfo->isLink()) { - if ($this->linkHandling & self::SKIP_LINKS) { - continue; - } - throw SymbolicLinkEncountered::atLocation($fileInfo->getPathname()); - } - - $path = $this->prefixer->stripPrefix($fileInfo->getPathname()); - $lastModified = $fileInfo->getMTime(); - $isDirectory = $fileInfo->isDir(); - $permissions = octdec(substr(sprintf('%o', $fileInfo->getPerms()), -4)); - $visibility = $isDirectory ? $this->visibility->inverseForDirectory($permissions) : $this->visibility->inverseForFile($permissions); - - yield $isDirectory ? new DirectoryAttributes($path, $visibility, $lastModified) : new FileAttributes( - str_replace('\\', '/', $path), - $fileInfo->getSize(), - $visibility, - $lastModified - ); - } - } - - public function move(string $source, string $destination, Config $config): void - { - $sourcePath = $this->prefixer->prefixPath($source); - $destinationPath = $this->prefixer->prefixPath($destination); - $this->ensureDirectoryExists( - dirname($destinationPath), - $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) - ); - - if ( ! @rename($sourcePath, $destinationPath)) { - throw UnableToMoveFile::fromLocationTo($sourcePath, $destinationPath); - } - } - - public function copy(string $source, string $destination, Config $config): void - { - $sourcePath = $this->prefixer->prefixPath($source); - $destinationPath = $this->prefixer->prefixPath($destination); - $this->ensureDirectoryExists( - dirname($destinationPath), - $this->resolveDirectoryVisibility($config->get(Config::OPTION_DIRECTORY_VISIBILITY)) - ); - - if ( ! @copy($sourcePath, $destinationPath)) { - throw UnableToCopyFile::fromLocationTo($sourcePath, $destinationPath); - } - } - - public function read(string $path): string - { - $location = $this->prefixer->prefixPath($path); - error_clear_last(); - $contents = @file_get_contents($location); - - if ($contents === false) { - throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? ''); - } - - return $contents; - } - - public function readStream(string $path) - { - $location = $this->prefixer->prefixPath($path); - error_clear_last(); - $contents = @fopen($location, 'rb'); - - if ($contents === false) { - throw UnableToReadFile::fromLocation($path, error_get_last()['message'] ?? ''); - } - - return $contents; - } - - protected function ensureDirectoryExists(string $dirname, int $visibility): void - { - if (is_dir($dirname)) { - return; - } - - error_clear_last(); - - if ( ! @mkdir($dirname, $visibility, true)) { - $mkdirError = error_get_last(); - } - - clearstatcache(true, $dirname); - - if ( ! is_dir($dirname)) { - $errorMessage = isset($mkdirError['message']) ? $mkdirError['message'] : ''; - - throw UnableToCreateDirectory::atLocation($dirname, $errorMessage); - } - } - - public function fileExists(string $location): bool - { - $location = $this->prefixer->prefixPath($location); - - return is_file($location); - } - - public function createDirectory(string $path, Config $config): void - { - $location = $this->prefixer->prefixPath($path); - $visibility = $config->get(Config::OPTION_VISIBILITY, $config->get(Config::OPTION_DIRECTORY_VISIBILITY)); - $permissions = $this->resolveDirectoryVisibility($visibility); - - if (is_dir($location)) { - $this->setPermissions($location, $permissions); - - return; - } - - error_clear_last(); - - if ( ! @mkdir($location, $permissions, true)) { - throw UnableToCreateDirectory::atLocation($path, error_get_last()['message'] ?? ''); - } - } - - public function setVisibility(string $path, string $visibility): void - { - $path = $this->prefixer->prefixPath($path); - $visibility = is_dir($path) ? $this->visibility->forDirectory($visibility) : $this->visibility->forFile( - $visibility - ); - - $this->setPermissions($path, $visibility); - } - - public function visibility(string $path): FileAttributes - { - $location = $this->prefixer->prefixPath($path); - clearstatcache(false, $location); - error_clear_last(); - $fileperms = @fileperms($location); - - if ($fileperms === false) { - throw UnableToRetrieveMetadata::visibility($path, error_get_last()['message'] ?? ''); - } - - $permissions = $fileperms & 0777; - $visibility = $this->visibility->inverseForFile($permissions); - - return new FileAttributes($path, null, $visibility); - } - - private function resolveDirectoryVisibility(?string $visibility): int - { - return $visibility === null ? $this->visibility->defaultForDirectories() : $this->visibility->forDirectory( - $visibility - ); - } - - public function mimeType(string $path): FileAttributes - { - $location = $this->prefixer->prefixPath($path); - error_clear_last(); - $mimeType = $this->mimeTypeDetector->detectMimeTypeFromFile($location); - - if ($mimeType === null) { - throw UnableToRetrieveMetadata::mimeType($path, error_get_last()['message'] ?? ''); - } - - return new FileAttributes($path, null, null, null, $mimeType); - } - - public function lastModified(string $path): FileAttributes - { - $location = $this->prefixer->prefixPath($path); - error_clear_last(); - $lastModified = @filemtime($location); - - if ($lastModified === false) { - throw UnableToRetrieveMetadata::lastModified($path, error_get_last()['message'] ?? ''); - } - - return new FileAttributes($path, null, null, $lastModified); - } - - public function fileSize(string $path): FileAttributes - { - $location = $this->prefixer->prefixPath($path); - error_clear_last(); - - if (is_file($location) && ($fileSize = @filesize($location)) !== false) { - return new FileAttributes($path, $fileSize); - } - - throw UnableToRetrieveMetadata::fileSize($path, error_get_last()['message'] ?? ''); - } - - private function listDirectory(string $location): Generator - { - $iterator = new DirectoryIterator($location); - - foreach ($iterator as $item) { - if ($item->isDot()) { - continue; - } - - yield $item; - } - } - - private function setPermissions(string $location, int $visibility): void - { - error_clear_last(); - if ( ! @chmod($location, $visibility)) { - $extraMessage = error_get_last()['message'] ?? ''; - throw UnableToSetVisibility::atLocation($this->prefixer->stripPrefix($location), $extraMessage); - } - } -} diff --git a/vendor/league/flysystem/src/MountManager.php b/vendor/league/flysystem/src/MountManager.php deleted file mode 100644 index 620f540..0000000 --- a/vendor/league/flysystem/src/MountManager.php +++ /dev/null @@ -1,648 +0,0 @@ - Filesystem,] - * - * @throws InvalidArgumentException - */ - public function __construct(array $filesystems = []) - { - $this->mountFilesystems($filesystems); - } - - /** - * Mount filesystems. - * - * @param FilesystemInterface[] $filesystems [:prefix => Filesystem,] - * - * @throws InvalidArgumentException - * - * @return $this - */ - public function mountFilesystems(array $filesystems) - { - foreach ($filesystems as $prefix => $filesystem) { - $this->mountFilesystem($prefix, $filesystem); - } - - return $this; - } - - /** - * Mount filesystems. - * - * @param string $prefix - * @param FilesystemInterface $filesystem - * - * @throws InvalidArgumentException - * - * @return $this - */ - public function mountFilesystem($prefix, FilesystemInterface $filesystem) - { - if ( ! is_string($prefix)) { - throw new InvalidArgumentException(__METHOD__ . ' expects argument #1 to be a string.'); - } - - $this->filesystems[$prefix] = $filesystem; - - return $this; - } - - /** - * Get the filesystem with the corresponding prefix. - * - * @param string $prefix - * - * @throws FilesystemNotFoundException - * - * @return FilesystemInterface - */ - public function getFilesystem($prefix) - { - if ( ! isset($this->filesystems[$prefix])) { - throw new FilesystemNotFoundException('No filesystem mounted with prefix ' . $prefix); - } - - return $this->filesystems[$prefix]; - } - - /** - * Retrieve the prefix from an arguments array. - * - * @param array $arguments - * - * @throws InvalidArgumentException - * - * @return array [:prefix, :arguments] - */ - public function filterPrefix(array $arguments) - { - if (empty($arguments)) { - throw new InvalidArgumentException('At least one argument needed'); - } - - $path = array_shift($arguments); - - if ( ! is_string($path)) { - throw new InvalidArgumentException('First argument should be a string'); - } - - list($prefix, $path) = $this->getPrefixAndPath($path); - array_unshift($arguments, $path); - - return [$prefix, $arguments]; - } - - /** - * @param string $directory - * @param bool $recursive - * - * @throws InvalidArgumentException - * @throws FilesystemNotFoundException - * - * @return array - */ - public function listContents($directory = '', $recursive = false) - { - list($prefix, $directory) = $this->getPrefixAndPath($directory); - $filesystem = $this->getFilesystem($prefix); - $result = $filesystem->listContents($directory, $recursive); - - foreach ($result as &$file) { - $file['filesystem'] = $prefix; - } - - return $result; - } - - /** - * Call forwarder. - * - * @param string $method - * @param array $arguments - * - * @throws InvalidArgumentException - * @throws FilesystemNotFoundException - * - * @return mixed - */ - public function __call($method, $arguments) - { - list($prefix, $arguments) = $this->filterPrefix($arguments); - - return $this->invokePluginOnFilesystem($method, $arguments, $prefix); - } - - /** - * @param string $from - * @param string $to - * @param array $config - * - * @throws InvalidArgumentException - * @throws FilesystemNotFoundException - * @throws FileExistsException - * - * @return bool - */ - public function copy($from, $to, array $config = []) - { - list($prefixFrom, $from) = $this->getPrefixAndPath($from); - - $buffer = $this->getFilesystem($prefixFrom)->readStream($from); - - if ($buffer === false) { - return false; - } - - list($prefixTo, $to) = $this->getPrefixAndPath($to); - - $result = $this->getFilesystem($prefixTo)->writeStream($to, $buffer, $config); - - if (is_resource($buffer)) { - fclose($buffer); - } - - return $result; - } - - /** - * List with plugin adapter. - * - * @param array $keys - * @param string $directory - * @param bool $recursive - * - * @throws InvalidArgumentException - * @throws FilesystemNotFoundException - * - * @return array - */ - public function listWith(array $keys = [], $directory = '', $recursive = false) - { - list($prefix, $directory) = $this->getPrefixAndPath($directory); - $arguments = [$keys, $directory, $recursive]; - - return $this->invokePluginOnFilesystem('listWith', $arguments, $prefix); - } - - /** - * Move a file. - * - * @param string $from - * @param string $to - * @param array $config - * - * @throws InvalidArgumentException - * @throws FilesystemNotFoundException - * - * @return bool - */ - public function move($from, $to, array $config = []) - { - list($prefixFrom, $pathFrom) = $this->getPrefixAndPath($from); - list($prefixTo, $pathTo) = $this->getPrefixAndPath($to); - - if ($prefixFrom === $prefixTo) { - $filesystem = $this->getFilesystem($prefixFrom); - $renamed = $filesystem->rename($pathFrom, $pathTo); - - if ($renamed && isset($config['visibility'])) { - return $filesystem->setVisibility($pathTo, $config['visibility']); - } - - return $renamed; - } - - $copied = $this->copy($from, $to, $config); - - if ($copied) { - return $this->delete($from); - } - - return false; - } - - /** - * Invoke a plugin on a filesystem mounted on a given prefix. - * - * @param string $method - * @param array $arguments - * @param string $prefix - * - * @throws FilesystemNotFoundException - * - * @return mixed - */ - public function invokePluginOnFilesystem($method, $arguments, $prefix) - { - $filesystem = $this->getFilesystem($prefix); - - try { - return $this->invokePlugin($method, $arguments, $filesystem); - } catch (PluginNotFoundException $e) { - // Let it pass, it's ok, don't panic. - } - - $callback = [$filesystem, $method]; - - return call_user_func_array($callback, $arguments); - } - - /** - * @param string $path - * - * @throws InvalidArgumentException - * - * @return string[] [:prefix, :path] - */ - protected function getPrefixAndPath($path) - { - if (strpos($path, '://') < 1) { - throw new InvalidArgumentException('No prefix detected in path: ' . $path); - } - - return explode('://', $path, 2); - } - - /** - * Check whether a file exists. - * - * @param string $path - * - * @return bool - */ - public function has($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->has($path); - } - - /** - * Read a file. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return string|false The file contents or false on failure. - */ - public function read($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->read($path); - } - - /** - * Retrieves a read-stream for a path. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return resource|false The path resource or false on failure. - */ - public function readStream($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->readStream($path); - } - - /** - * Get a file's metadata. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return array|false The file metadata or false on failure. - */ - public function getMetadata($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->getMetadata($path); - } - - /** - * Get a file's size. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return int|false The file size or false on failure. - */ - public function getSize($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->getSize($path); - } - - /** - * Get a file's mime-type. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return string|false The file mime-type or false on failure. - */ - public function getMimetype($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->getMimetype($path); - } - - /** - * Get a file's timestamp. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return string|false The timestamp or false on failure. - */ - public function getTimestamp($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->getTimestamp($path); - } - - /** - * Get a file's visibility. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return string|false The visibility (public|private) or false on failure. - */ - public function getVisibility($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->getVisibility($path); - } - - /** - * Write a new file. - * - * @param string $path The path of the new file. - * @param string $contents The file contents. - * @param array $config An optional configuration array. - * - * @throws FileExistsException - * - * @return bool True on success, false on failure. - */ - public function write($path, $contents, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->write($path, $contents, $config); - } - - /** - * Write a new file using a stream. - * - * @param string $path The path of the new file. - * @param resource $resource The file handle. - * @param array $config An optional configuration array. - * - * @throws InvalidArgumentException If $resource is not a file handle. - * @throws FileExistsException - * - * @return bool True on success, false on failure. - */ - public function writeStream($path, $resource, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->writeStream($path, $resource, $config); - } - - /** - * Update an existing file. - * - * @param string $path The path of the existing file. - * @param string $contents The file contents. - * @param array $config An optional configuration array. - * - * @throws FileNotFoundException - * - * @return bool True on success, false on failure. - */ - public function update($path, $contents, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->update($path, $contents, $config); - } - - /** - * Update an existing file using a stream. - * - * @param string $path The path of the existing file. - * @param resource $resource The file handle. - * @param array $config An optional configuration array. - * - * @throws InvalidArgumentException If $resource is not a file handle. - * @throws FileNotFoundException - * - * @return bool True on success, false on failure. - */ - public function updateStream($path, $resource, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->updateStream($path, $resource, $config); - } - - /** - * Rename a file. - * - * @param string $path Path to the existing file. - * @param string $newpath The new path of the file. - * - * @throws FileExistsException Thrown if $newpath exists. - * @throws FileNotFoundException Thrown if $path does not exist. - * - * @return bool True on success, false on failure. - */ - public function rename($path, $newpath) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->rename($path, $newpath); - } - - /** - * Delete a file. - * - * @param string $path - * - * @throws FileNotFoundException - * - * @return bool True on success, false on failure. - */ - public function delete($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->delete($path); - } - - /** - * Delete a directory. - * - * @param string $dirname - * - * @throws RootViolationException Thrown if $dirname is empty. - * - * @return bool True on success, false on failure. - */ - public function deleteDir($dirname) - { - list($prefix, $dirname) = $this->getPrefixAndPath($dirname); - - return $this->getFilesystem($prefix)->deleteDir($dirname); - } - - /** - * Create a directory. - * - * @param string $dirname The name of the new directory. - * @param array $config An optional configuration array. - * - * @return bool True on success, false on failure. - */ - public function createDir($dirname, array $config = []) - { - list($prefix, $dirname) = $this->getPrefixAndPath($dirname); - - return $this->getFilesystem($prefix)->createDir($dirname); - } - - /** - * Set the visibility for a file. - * - * @param string $path The path to the file. - * @param string $visibility One of 'public' or 'private'. - * - * @throws FileNotFoundException - * - * @return bool True on success, false on failure. - */ - public function setVisibility($path, $visibility) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->setVisibility($path, $visibility); - } - - /** - * Create a file or update if exists. - * - * @param string $path The path to the file. - * @param string $contents The file contents. - * @param array $config An optional configuration array. - * - * @return bool True on success, false on failure. - */ - public function put($path, $contents, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->put($path, $contents, $config); - } - - /** - * Create a file or update if exists. - * - * @param string $path The path to the file. - * @param resource $resource The file handle. - * @param array $config An optional configuration array. - * - * @throws InvalidArgumentException Thrown if $resource is not a resource. - * - * @return bool True on success, false on failure. - */ - public function putStream($path, $resource, array $config = []) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->putStream($path, $resource, $config); - } - - /** - * Read and delete a file. - * - * @param string $path The path to the file. - * - * @throws FileNotFoundException - * - * @return string|false The file contents, or false on failure. - */ - public function readAndDelete($path) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->readAndDelete($path); - } - - /** - * Get a file/directory handler. - * - * @deprecated - * - * @param string $path The path to the file. - * @param Handler $handler An optional existing handler to populate. - * - * @return Handler Either a file or directory handler. - */ - public function get($path, Handler $handler = null) - { - list($prefix, $path) = $this->getPrefixAndPath($path); - - return $this->getFilesystem($prefix)->get($path); - } -} diff --git a/vendor/league/flysystem/src/NotSupportedException.php b/vendor/league/flysystem/src/NotSupportedException.php deleted file mode 100644 index e0a989b..0000000 --- a/vendor/league/flysystem/src/NotSupportedException.php +++ /dev/null @@ -1,37 +0,0 @@ -getPathname()); - } - - /** - * Create a new exception for a link. - * - * @param string $systemType - * - * @return static - */ - public static function forFtpSystemType($systemType) - { - $message = "The FTP system type '$systemType' is currently not supported."; - - return new static($message); - } -} diff --git a/vendor/league/flysystem/src/PathNormalizer.php b/vendor/league/flysystem/src/PathNormalizer.php deleted file mode 100644 index 54da201..0000000 --- a/vendor/league/flysystem/src/PathNormalizer.php +++ /dev/null @@ -1,10 +0,0 @@ -prefix = rtrim($prefix, '\\/'); - - if ($this->prefix !== '' || $prefix === $separator) { - $this->prefix .= $separator; - } - - $this->separator = $separator; - } - - public function prefixPath(string $path): string - { - return $this->prefix . ltrim($path, '\\/'); - } - - public function stripPrefix(string $path): string - { - /* @var string */ - return substr($path, strlen($this->prefix)); - } - - public function stripDirectoryPrefix(string $path): string - { - return rtrim($this->stripPrefix($path), '\\/'); - } - - public function prefixDirectoryPath(string $path): string - { - $prefixedPath = $this->prefixPath(rtrim($path, '\\/')); - - if ((substr($prefixedPath, -1) === $this->separator) || $prefixedPath === '') { - return $prefixedPath; - } - - return $prefixedPath . $this->separator; - } -} diff --git a/vendor/league/flysystem/src/PathTraversalDetected.php b/vendor/league/flysystem/src/PathTraversalDetected.php deleted file mode 100644 index d149997..0000000 --- a/vendor/league/flysystem/src/PathTraversalDetected.php +++ /dev/null @@ -1,28 +0,0 @@ -path; - } - - public static function forPath(string $path): PathTraversalDetected - { - $e = new PathTraversalDetected("Path traversal detected: {$path}"); - $e->path = $path; - - return $e; - } -} diff --git a/vendor/league/flysystem/src/Plugin/AbstractPlugin.php b/vendor/league/flysystem/src/Plugin/AbstractPlugin.php deleted file mode 100644 index 0d56789..0000000 --- a/vendor/league/flysystem/src/Plugin/AbstractPlugin.php +++ /dev/null @@ -1,24 +0,0 @@ -filesystem = $filesystem; - } -} diff --git a/vendor/league/flysystem/src/Plugin/EmptyDir.php b/vendor/league/flysystem/src/Plugin/EmptyDir.php deleted file mode 100644 index b5ae7f5..0000000 --- a/vendor/league/flysystem/src/Plugin/EmptyDir.php +++ /dev/null @@ -1,34 +0,0 @@ -filesystem->listContents($dirname, false); - - foreach ($listing as $item) { - if ($item['type'] === 'dir') { - $this->filesystem->deleteDir($item['path']); - } else { - $this->filesystem->delete($item['path']); - } - } - } -} diff --git a/vendor/league/flysystem/src/Plugin/ForcedCopy.php b/vendor/league/flysystem/src/Plugin/ForcedCopy.php deleted file mode 100644 index a41e9f3..0000000 --- a/vendor/league/flysystem/src/Plugin/ForcedCopy.php +++ /dev/null @@ -1,44 +0,0 @@ -filesystem->delete($newpath); - } catch (FileNotFoundException $e) { - // The destination path does not exist. That's ok. - $deleted = true; - } - - if ($deleted) { - return $this->filesystem->copy($path, $newpath); - } - - return false; - } -} diff --git a/vendor/league/flysystem/src/Plugin/ForcedRename.php b/vendor/league/flysystem/src/Plugin/ForcedRename.php deleted file mode 100644 index 3f51cd6..0000000 --- a/vendor/league/flysystem/src/Plugin/ForcedRename.php +++ /dev/null @@ -1,44 +0,0 @@ -filesystem->delete($newpath); - } catch (FileNotFoundException $e) { - // The destination path does not exist. That's ok. - $deleted = true; - } - - if ($deleted) { - return $this->filesystem->rename($path, $newpath); - } - - return false; - } -} diff --git a/vendor/league/flysystem/src/Plugin/GetWithMetadata.php b/vendor/league/flysystem/src/Plugin/GetWithMetadata.php deleted file mode 100644 index 2f13d2f..0000000 --- a/vendor/league/flysystem/src/Plugin/GetWithMetadata.php +++ /dev/null @@ -1,51 +0,0 @@ -filesystem->getMetadata($path); - - if ( ! $object) { - return false; - } - - $keys = array_diff($metadata, array_keys($object)); - - foreach ($keys as $key) { - if ( ! method_exists($this->filesystem, $method = 'get' . ucfirst($key))) { - throw new InvalidArgumentException('Could not fetch metadata: ' . $key); - } - - $object[$key] = $this->filesystem->{$method}($path); - } - - return $object; - } -} diff --git a/vendor/league/flysystem/src/Plugin/ListFiles.php b/vendor/league/flysystem/src/Plugin/ListFiles.php deleted file mode 100644 index 9669fe7..0000000 --- a/vendor/league/flysystem/src/Plugin/ListFiles.php +++ /dev/null @@ -1,35 +0,0 @@ -filesystem->listContents($directory, $recursive); - - $filter = function ($object) { - return $object['type'] === 'file'; - }; - - return array_values(array_filter($contents, $filter)); - } -} diff --git a/vendor/league/flysystem/src/Plugin/ListPaths.php b/vendor/league/flysystem/src/Plugin/ListPaths.php deleted file mode 100644 index 0889d1f..0000000 --- a/vendor/league/flysystem/src/Plugin/ListPaths.php +++ /dev/null @@ -1,36 +0,0 @@ -filesystem->listContents($directory, $recursive); - - foreach ($contents as $object) { - $result[] = $object['path']; - } - - return $result; - } -} diff --git a/vendor/league/flysystem/src/Plugin/ListWith.php b/vendor/league/flysystem/src/Plugin/ListWith.php deleted file mode 100644 index d64debe..0000000 --- a/vendor/league/flysystem/src/Plugin/ListWith.php +++ /dev/null @@ -1,60 +0,0 @@ -filesystem->listContents($directory, $recursive); - - foreach ($contents as $index => $object) { - if ($object['type'] === 'file') { - $missingKeys = array_diff($keys, array_keys($object)); - $contents[$index] = array_reduce($missingKeys, [$this, 'getMetadataByName'], $object); - } - } - - return $contents; - } - - /** - * Get a meta-data value by key name. - * - * @param array $object - * @param string $key - * - * @return array - */ - protected function getMetadataByName(array $object, $key) - { - $method = 'get' . ucfirst($key); - - if ( ! method_exists($this->filesystem, $method)) { - throw new \InvalidArgumentException('Could not get meta-data for key: ' . $key); - } - - $object[$key] = $this->filesystem->{$method}($object['path']); - - return $object; - } -} diff --git a/vendor/league/flysystem/src/Plugin/PluggableTrait.php b/vendor/league/flysystem/src/Plugin/PluggableTrait.php deleted file mode 100644 index 922edfe..0000000 --- a/vendor/league/flysystem/src/Plugin/PluggableTrait.php +++ /dev/null @@ -1,97 +0,0 @@ -plugins[$plugin->getMethod()] = $plugin; - - return $this; - } - - /** - * Find a specific plugin. - * - * @param string $method - * - * @throws PluginNotFoundException - * - * @return PluginInterface - */ - protected function findPlugin($method) - { - if ( ! isset($this->plugins[$method])) { - throw new PluginNotFoundException('Plugin not found for method: ' . $method); - } - - return $this->plugins[$method]; - } - - /** - * Invoke a plugin by method name. - * - * @param string $method - * @param array $arguments - * @param FilesystemInterface $filesystem - * - * @throws PluginNotFoundException - * - * @return mixed - */ - protected function invokePlugin($method, array $arguments, FilesystemInterface $filesystem) - { - $plugin = $this->findPlugin($method); - $plugin->setFilesystem($filesystem); - $callback = [$plugin, 'handle']; - - return call_user_func_array($callback, $arguments); - } - - /** - * Plugins pass-through. - * - * @param string $method - * @param array $arguments - * - * @throws BadMethodCallException - * - * @return mixed - */ - public function __call($method, array $arguments) - { - try { - return $this->invokePlugin($method, $arguments, $this); - } catch (PluginNotFoundException $e) { - throw new BadMethodCallException( - 'Call to undefined method ' - . get_class($this) - . '::' . $method - ); - } - } -} diff --git a/vendor/league/flysystem/src/Plugin/PluginNotFoundException.php b/vendor/league/flysystem/src/Plugin/PluginNotFoundException.php deleted file mode 100644 index fd1d7e7..0000000 --- a/vendor/league/flysystem/src/Plugin/PluginNotFoundException.php +++ /dev/null @@ -1,10 +0,0 @@ -formatPropertyName((string) $offset); - - return isset($this->{$property}); - } - - /** - * @param mixed $offset - * - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) - { - $property = $this->formatPropertyName((string) $offset); - - return $this->{$property}; - } - - /** - * @param mixed $offset - * @param mixed $value - */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value): void - { - throw new RuntimeException('Properties can not be manipulated'); - } - - /** - * @param mixed $offset - */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset): void - { - throw new RuntimeException('Properties can not be manipulated'); - } -} diff --git a/vendor/league/flysystem/src/ReadInterface.php b/vendor/league/flysystem/src/ReadInterface.php deleted file mode 100644 index 898a8d5..0000000 --- a/vendor/league/flysystem/src/ReadInterface.php +++ /dev/null @@ -1,88 +0,0 @@ -hash = spl_object_hash($this); - static::$safeStorage[$this->hash] = []; - } - - public function storeSafely($key, $value) - { - static::$safeStorage[$this->hash][$key] = $value; - } - - public function retrieveSafely($key) - { - if (array_key_exists($key, static::$safeStorage[$this->hash])) { - return static::$safeStorage[$this->hash][$key]; - } - } - - public function __destruct() - { - unset(static::$safeStorage[$this->hash]); - } -} diff --git a/vendor/league/flysystem/src/StorageAttributes.php b/vendor/league/flysystem/src/StorageAttributes.php deleted file mode 100644 index 6be6235..0000000 --- a/vendor/league/flysystem/src/StorageAttributes.php +++ /dev/null @@ -1,40 +0,0 @@ -location; - } - - public static function atLocation(string $pathName): SymbolicLinkEncountered - { - $e = new static("Unsupported symbolic link encountered at location $pathName"); - $e->location = $pathName; - - return $e; - } -} diff --git a/vendor/league/flysystem/src/UnableToCheckFileExistence.php b/vendor/league/flysystem/src/UnableToCheckFileExistence.php deleted file mode 100644 index d78e4ee..0000000 --- a/vendor/league/flysystem/src/UnableToCheckFileExistence.php +++ /dev/null @@ -1,21 +0,0 @@ -source; - } - - public function destination(): string - { - return $this->destination; - } - - public static function fromLocationTo( - string $sourcePath, - string $destinationPath, - Throwable $previous = null - ): UnableToCopyFile { - $e = new static("Unable to copy file from $sourcePath to $destinationPath", 0 , $previous); - $e->source = $sourcePath; - $e->destination = $destinationPath; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_COPY; - } -} diff --git a/vendor/league/flysystem/src/UnableToCreateDirectory.php b/vendor/league/flysystem/src/UnableToCreateDirectory.php deleted file mode 100644 index 8298f9f..0000000 --- a/vendor/league/flysystem/src/UnableToCreateDirectory.php +++ /dev/null @@ -1,44 +0,0 @@ -location = $dirname; - - return $e; - } - - public static function dueToFailure(string $dirname, Throwable $previous): UnableToCreateDirectory - { - $message = "Unable to create a directory at {$dirname}"; - $e = new static($message, 0, $previous); - $e->location = $dirname; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_CREATE_DIRECTORY; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnableToDeleteDirectory.php b/vendor/league/flysystem/src/UnableToDeleteDirectory.php deleted file mode 100644 index eeeab24..0000000 --- a/vendor/league/flysystem/src/UnableToDeleteDirectory.php +++ /dev/null @@ -1,48 +0,0 @@ -location = $location; - $e->reason = $reason; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_DELETE_DIRECTORY; - } - - public function reason(): string - { - return $this->reason; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnableToDeleteFile.php b/vendor/league/flysystem/src/UnableToDeleteFile.php deleted file mode 100644 index 18f7215..0000000 --- a/vendor/league/flysystem/src/UnableToDeleteFile.php +++ /dev/null @@ -1,45 +0,0 @@ -location = $location; - $e->reason = $reason; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_DELETE; - } - - public function reason(): string - { - return $this->reason; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnableToMountFilesystem.php b/vendor/league/flysystem/src/UnableToMountFilesystem.php deleted file mode 100644 index bd41bc9..0000000 --- a/vendor/league/flysystem/src/UnableToMountFilesystem.php +++ /dev/null @@ -1,32 +0,0 @@ -source; - } - - public function destination(): string - { - return $this->destination; - } - - public static function fromLocationTo( - string $sourcePath, - string $destinationPath, - Throwable $previous = null - ): UnableToMoveFile { - $e = new static("Unable to move file from $sourcePath to $destinationPath", 0, $previous); - $e->source = $sourcePath; - $e->destination = $destinationPath; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_MOVE; - } -} diff --git a/vendor/league/flysystem/src/UnableToReadFile.php b/vendor/league/flysystem/src/UnableToReadFile.php deleted file mode 100644 index 766b563..0000000 --- a/vendor/league/flysystem/src/UnableToReadFile.php +++ /dev/null @@ -1,45 +0,0 @@ -location = $location; - $e->reason = $reason; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_READ; - } - - public function reason(): string - { - return $this->reason; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php b/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php deleted file mode 100644 index 91a9ee3..0000000 --- a/vendor/league/flysystem/src/UnableToResolveFilesystemMount.php +++ /dev/null @@ -1,20 +0,0 @@ -reason = $reason; - $e->location = $location; - $e->metadataType = $type; - - return $e; - } - - public function reason(): string - { - return $this->reason; - } - - public function location(): string - { - return $this->location; - } - - public function metadataType(): string - { - return $this->metadataType; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_RETRIEVE_METADATA; - } -} diff --git a/vendor/league/flysystem/src/UnableToSetVisibility.php b/vendor/league/flysystem/src/UnableToSetVisibility.php deleted file mode 100644 index 5862d0e..0000000 --- a/vendor/league/flysystem/src/UnableToSetVisibility.php +++ /dev/null @@ -1,49 +0,0 @@ -reason; - } - - public static function atLocation(string $filename, string $extraMessage = '', Throwable $previous = null): self - { - $message = "Unable to set visibility for file {$filename}. $extraMessage"; - $e = new static(rtrim($message), 0, $previous); - $e->reason = $extraMessage; - $e->location = $filename; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_SET_VISIBILITY; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnableToWriteFile.php b/vendor/league/flysystem/src/UnableToWriteFile.php deleted file mode 100644 index 5de7866..0000000 --- a/vendor/league/flysystem/src/UnableToWriteFile.php +++ /dev/null @@ -1,45 +0,0 @@ -location = $location; - $e->reason = $reason; - - return $e; - } - - public function operation(): string - { - return FilesystemOperationFailed::OPERATION_WRITE; - } - - public function reason(): string - { - return $this->reason; - } - - public function location(): string - { - return $this->location; - } -} diff --git a/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php b/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php deleted file mode 100644 index 5cc1eb2..0000000 --- a/vendor/league/flysystem/src/UnixVisibility/PortableVisibilityConverter.php +++ /dev/null @@ -1,109 +0,0 @@ -filePublic = $filePublic; - $this->filePrivate = $filePrivate; - $this->directoryPublic = $directoryPublic; - $this->directoryPrivate = $directoryPrivate; - $this->defaultForDirectories = $defaultForDirectories; - } - - public function forFile(string $visibility): int - { - PortableVisibilityGuard::guardAgainstInvalidInput($visibility); - - return $visibility === Visibility::PUBLIC - ? $this->filePublic - : $this->filePrivate; - } - - public function forDirectory(string $visibility): int - { - PortableVisibilityGuard::guardAgainstInvalidInput($visibility); - - return $visibility === Visibility::PUBLIC - ? $this->directoryPublic - : $this->directoryPrivate; - } - - public function inverseForFile(int $visibility): string - { - if ($visibility === $this->filePublic) { - return Visibility::PUBLIC; - } elseif ($visibility === $this->filePrivate) { - return Visibility::PRIVATE; - } - - return Visibility::PUBLIC; // default - } - - public function inverseForDirectory(int $visibility): string - { - if ($visibility === $this->directoryPublic) { - return Visibility::PUBLIC; - } elseif ($visibility === $this->directoryPrivate) { - return Visibility::PRIVATE; - } - - return Visibility::PUBLIC; // default - } - - public function defaultForDirectories(): int - { - return $this->defaultForDirectories === Visibility::PUBLIC ? $this->directoryPublic : $this->directoryPrivate; - } - - /** - * @param array $permissionMap - */ - public static function fromArray(array $permissionMap, string $defaultForDirectories = Visibility::PRIVATE): PortableVisibilityConverter - { - return new PortableVisibilityConverter( - $permissionMap['file']['public'] ?? 0644, - $permissionMap['file']['private'] ?? 0600, - $permissionMap['dir']['public'] ?? 0755, - $permissionMap['dir']['private'] ?? 0700, - $defaultForDirectories - ); - } -} diff --git a/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php b/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php deleted file mode 100644 index 64af86a..0000000 --- a/vendor/league/flysystem/src/UnixVisibility/VisibilityConverter.php +++ /dev/null @@ -1,14 +0,0 @@ -location; - } - - public static function atLocation(string $location): UnreadableFileEncountered - { - $e = new static("Unreadable file encountered at location {$location}."); - $e->location = $location; - - return $e; - } -} diff --git a/vendor/league/flysystem/src/UnreadableFileException.php b/vendor/league/flysystem/src/UnreadableFileException.php deleted file mode 100644 index e668033..0000000 --- a/vendor/league/flysystem/src/UnreadableFileException.php +++ /dev/null @@ -1,18 +0,0 @@ -getRealPath() - ) - ); - } -} diff --git a/vendor/league/flysystem/src/Util.php b/vendor/league/flysystem/src/Util.php deleted file mode 100644 index 1a2db71..0000000 --- a/vendor/league/flysystem/src/Util.php +++ /dev/null @@ -1,354 +0,0 @@ - '']; - } - - /** - * Normalize a dirname return value. - * - * @param string $dirname - * - * @return string normalized dirname - */ - public static function normalizeDirname($dirname) - { - return $dirname === '.' ? '' : $dirname; - } - - /** - * Get a normalized dirname from a path. - * - * @param string $path - * - * @return string dirname - */ - public static function dirname($path) - { - return static::normalizeDirname(dirname($path)); - } - - /** - * Map result arrays. - * - * @param array $object - * @param array $map - * - * @return array mapped result - */ - public static function map(array $object, array $map) - { - $result = []; - - foreach ($map as $from => $to) { - if ( ! isset($object[$from])) { - continue; - } - - $result[$to] = $object[$from]; - } - - return $result; - } - - /** - * Normalize path. - * - * @param string $path - * - * @throws LogicException - * - * @return string - */ - public static function normalizePath($path) - { - return static::normalizeRelativePath($path); - } - - /** - * Normalize relative directories in a path. - * - * @param string $path - * - * @throws LogicException - * - * @return string - */ - public static function normalizeRelativePath($path) - { - $path = str_replace('\\', '/', $path); - $path = static::removeFunkyWhiteSpace($path); - $parts = []; - - foreach (explode('/', $path) as $part) { - switch ($part) { - case '': - case '.': - break; - - case '..': - if (empty($parts)) { - throw new LogicException( - 'Path is outside of the defined root, path: [' . $path . ']' - ); - } - array_pop($parts); - break; - - default: - $parts[] = $part; - break; - } - } - - $path = implode('/', $parts); - - return $path; - } - - /** - * Rejects unprintable characters and invalid unicode characters. - * - * @param string $path - * - * @return string $path - */ - protected static function removeFunkyWhiteSpace($path) - { - if (preg_match('#\p{C}+#u', $path)) { - throw CorruptedPathDetected::forPath($path); - } - - return $path; - } - - /** - * Normalize prefix. - * - * @param string $prefix - * @param string $separator - * - * @return string normalized path - */ - public static function normalizePrefix($prefix, $separator) - { - return rtrim($prefix, $separator) . $separator; - } - - /** - * Get content size. - * - * @param string $contents - * - * @return int content size - */ - public static function contentSize($contents) - { - return defined('MB_OVERLOAD_STRING') ? mb_strlen($contents, '8bit') : strlen($contents); - } - - /** - * Guess MIME Type based on the path of the file and it's content. - * - * @param string $path - * @param string|resource $content - * - * @return string|null MIME Type or NULL if no extension detected - */ - public static function guessMimeType($path, $content) - { - $mimeType = MimeType::detectByContent($content); - - if ( ! (empty($mimeType) || in_array($mimeType, ['application/x-empty', 'text/plain', 'text/x-asm']))) { - return $mimeType; - } - - return MimeType::detectByFilename($path); - } - - /** - * Emulate directories. - * - * @param array $listing - * - * @return array listing with emulated directories - */ - public static function emulateDirectories(array $listing) - { - $directories = []; - $listedDirectories = []; - - foreach ($listing as $object) { - [$directories, $listedDirectories] = static::emulateObjectDirectories($object, $directories, $listedDirectories); - } - - $directories = array_diff(array_unique($directories), array_unique($listedDirectories)); - - foreach ($directories as $directory) { - $listing[] = static::pathinfo($directory) + ['type' => 'dir']; - } - - return $listing; - } - - /** - * Ensure a Config instance. - * - * @param null|array|Config $config - * - * @return Config config instance - * - * @throw LogicException - */ - public static function ensureConfig($config) - { - if ($config === null) { - return new Config(); - } - - if ($config instanceof Config) { - return $config; - } - - if (is_array($config)) { - return new Config($config); - } - - throw new LogicException('A config should either be an array or a Flysystem\Config object.'); - } - - /** - * Rewind a stream. - * - * @param resource $resource - */ - public static function rewindStream($resource) - { - if (ftell($resource) !== 0 && static::isSeekableStream($resource)) { - rewind($resource); - } - } - - public static function isSeekableStream($resource) - { - $metadata = stream_get_meta_data($resource); - - return $metadata['seekable']; - } - - /** - * Get the size of a stream. - * - * @param resource $resource - * - * @return int|null stream size - */ - public static function getStreamSize($resource) - { - $stat = fstat($resource); - - if ( ! is_array($stat) || ! isset($stat['size'])) { - return null; - } - - return $stat['size']; - } - - /** - * Emulate the directories of a single object. - * - * @param array $object - * @param array $directories - * @param array $listedDirectories - * - * @return array - */ - protected static function emulateObjectDirectories(array $object, array $directories, array $listedDirectories) - { - if ($object['type'] === 'dir') { - $listedDirectories[] = $object['path']; - } - - if ( ! isset($object['dirname']) || trim($object['dirname']) === '') { - return [$directories, $listedDirectories]; - } - - $parent = $object['dirname']; - - while (isset($parent) && trim($parent) !== '' && ! in_array($parent, $directories)) { - $directories[] = $parent; - $parent = static::dirname($parent); - } - - if (isset($object['type']) && $object['type'] === 'dir') { - $listedDirectories[] = $object['path']; - - return [$directories, $listedDirectories]; - } - - return [$directories, $listedDirectories]; - } - - /** - * Returns the trailing name component of the path. - * - * @param string $path - * - * @return string - */ - private static function basename($path) - { - $separators = DIRECTORY_SEPARATOR === '/' ? '/' : '\/'; - - $path = rtrim($path, $separators); - - $basename = preg_replace('#.*?([^' . preg_quote($separators, '#') . ']+$)#', '$1', $path); - - if (DIRECTORY_SEPARATOR === '/') { - return $basename; - } - // @codeCoverageIgnoreStart - // Extra Windows path munging. This is tested via AppVeyor, but code - // coverage is not reported. - - // Handle relative paths with drive letters. c:file.txt. - while (preg_match('#^[a-zA-Z]{1}:[^\\\/]#', $basename)) { - $basename = substr($basename, 2); - } - - // Remove colon for standalone drive letter names. - if (preg_match('#^[a-zA-Z]{1}:$#', $basename)) { - $basename = rtrim($basename, ':'); - } - - return $basename; - // @codeCoverageIgnoreEnd - } -} diff --git a/vendor/league/flysystem/src/Util/ContentListingFormatter.php b/vendor/league/flysystem/src/Util/ContentListingFormatter.php deleted file mode 100644 index ae0d3b9..0000000 --- a/vendor/league/flysystem/src/Util/ContentListingFormatter.php +++ /dev/null @@ -1,122 +0,0 @@ -directory = rtrim($directory, '/'); - $this->recursive = $recursive; - $this->caseSensitive = $caseSensitive; - } - - /** - * Format contents listing. - * - * @param array $listing - * - * @return array - */ - public function formatListing(array $listing) - { - $listing = array_filter(array_map([$this, 'addPathInfo'], $listing), [$this, 'isEntryOutOfScope']); - - return $this->sortListing(array_values($listing)); - } - - private function addPathInfo(array $entry) - { - return $entry + Util::pathinfo($entry['path']); - } - - /** - * Determine if the entry is out of scope. - * - * @param array $entry - * - * @return bool - */ - private function isEntryOutOfScope(array $entry) - { - if (empty($entry['path']) && $entry['path'] !== '0') { - return false; - } - - if ($this->recursive) { - return $this->residesInDirectory($entry); - } - - return $this->isDirectChild($entry); - } - - /** - * Check if the entry resides within the parent directory. - * - * @param array $entry - * - * @return bool - */ - private function residesInDirectory(array $entry) - { - if ($this->directory === '') { - return true; - } - - return $this->caseSensitive - ? strpos($entry['path'], $this->directory . '/') === 0 - : stripos($entry['path'], $this->directory . '/') === 0; - } - - /** - * Check if the entry is a direct child of the directory. - * - * @param array $entry - * - * @return bool - */ - private function isDirectChild(array $entry) - { - return $this->caseSensitive - ? $entry['dirname'] === $this->directory - : strcasecmp($this->directory, $entry['dirname']) === 0; - } - - /** - * @param array $listing - * - * @return array - */ - private function sortListing(array $listing) - { - usort($listing, function ($a, $b) { - return strcasecmp($a['path'], $b['path']); - }); - - return $listing; - } -} diff --git a/vendor/league/flysystem/src/Util/MimeType.php b/vendor/league/flysystem/src/Util/MimeType.php deleted file mode 100644 index 35cba3f..0000000 --- a/vendor/league/flysystem/src/Util/MimeType.php +++ /dev/null @@ -1,80 +0,0 @@ -detectMimeTypeFromBuffer($content); - } - - return 'text/plain'; - } - - /** - * Detects MIME Type based on file extension. - * - * @param string $extension - * - * @return string MIME Type - */ - public static function detectByFileExtension($extension) - { - return static::detector()->detectMimeTypeFromPath('artificial.' . $extension) ?: 'text/plain'; - } - - /** - * @param string $filename - * - * @return string MIME Type - */ - public static function detectByFilename($filename) - { - return static::detector()->detectMimeTypeFromPath($filename) ?: 'text/plain'; - } - - /** - * @return array Map of file extension to MIME Type - */ - public static function getExtensionToMimeTypeMap() - { - return static::$extensionToMimeTypeMap; - } -} diff --git a/vendor/league/flysystem/src/Util/StreamHasher.php b/vendor/league/flysystem/src/Util/StreamHasher.php deleted file mode 100644 index 938ec5d..0000000 --- a/vendor/league/flysystem/src/Util/StreamHasher.php +++ /dev/null @@ -1,36 +0,0 @@ -algo = $algo; - } - - /** - * @param resource $resource - * - * @return string - */ - public function hash($resource) - { - rewind($resource); - $context = hash_init($this->algo); - hash_update_stream($context, $resource); - fclose($resource); - - return hash_final($context); - } -} diff --git a/vendor/league/flysystem/src/Visibility.php b/vendor/league/flysystem/src/Visibility.php deleted file mode 100644 index 071ca00..0000000 --- a/vendor/league/flysystem/src/Visibility.php +++ /dev/null @@ -1,11 +0,0 @@ -rejectFunkyWhiteSpace($path); - - return $this->normalizeRelativePath($path); - } - - private function rejectFunkyWhiteSpace(string $path): void - { - if (preg_match('#\p{C}+#u', $path)) { - throw CorruptedPathDetected::forPath($path); - } - } - - private function normalizeRelativePath(string $path): string - { - $parts = []; - - foreach (explode('/', $path) as $part) { - switch ($part) { - case '': - case '.': - break; - - case '..': - if (empty($parts)) { - throw PathTraversalDetected::forPath($path); - } - array_pop($parts); - break; - - default: - $parts[] = $part; - break; - } - } - - return implode('/', $parts); - } -} diff --git a/vendor/league/mime-type-detection/CHANGELOG.md b/vendor/league/mime-type-detection/CHANGELOG.md deleted file mode 100644 index 2264f7a..0000000 --- a/vendor/league/mime-type-detection/CHANGELOG.md +++ /dev/null @@ -1,31 +0,0 @@ -# Changelog - -## 1.10.0 - 2022-04-11 - -### Fixed - -- Added Flysystem v1 inconclusive mime-types and made it configurable as a constructor parameter. - -## 1.9.0 - 2021-11-21 - -### Updated - -- Updated lookup - -## 1.8.0 - 2021-09-25 - -### Added - -- Added the decorator `OverridingExtensionToMimeTypeMap` which allows you to override values. - -## 1.7.0 - 2021-01-18 - -### Added - -- Added a `bufferSampleSize` parameter to the `FinfoMimeTypeDetector` class that allows you to send a reduced content sample which costs less memory. - -## 1.6.0 - 2021-01-18 - -### Changes - -- Updated generated mime-type map diff --git a/vendor/league/mime-type-detection/LICENSE b/vendor/league/mime-type-detection/LICENSE deleted file mode 100644 index 1f01652..0000000 --- a/vendor/league/mime-type-detection/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2013-2022 Frank de Jonge - -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. diff --git a/vendor/league/mime-type-detection/composer.json b/vendor/league/mime-type-detection/composer.json deleted file mode 100644 index 80ca1af..0000000 --- a/vendor/league/mime-type-detection/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "league/mime-type-detection", - "description": "Mime-type detection for Flysystem", - "license": "MIT", - "authors": [ - { - "name": "Frank de Jonge", - "email": "info@frankdejonge.nl" - } - ], - "scripts": { - "test": "vendor/bin/phpunit", - "phpstan": "vendor/bin/phpstan analyse -l 6 src" - }, - "require": { - "php": "^7.2 || ^8.0", - "ext-fileinfo": "*" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.8 || ^9.3", - "phpstan/phpstan": "^0.12.68", - "friendsofphp/php-cs-fixer": "^3.2" - }, - "autoload": { - "psr-4": { - "League\\MimeTypeDetection\\": "src" - } - }, - "config": { - "platform": { - "php": "7.2.0" - } - } -} diff --git a/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php deleted file mode 100644 index fc04241..0000000 --- a/vendor/league/mime-type-detection/src/EmptyExtensionToMimeTypeMap.php +++ /dev/null @@ -1,13 +0,0 @@ -extensions = $extensions ?: new GeneratedExtensionToMimeTypeMap(); - } - - public function detectMimeType(string $path, $contents): ?string - { - return $this->detectMimeTypeFromPath($path); - } - - public function detectMimeTypeFromPath(string $path): ?string - { - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); - - return $this->extensions->lookupMimeType($extension); - } - - public function detectMimeTypeFromFile(string $path): ?string - { - return $this->detectMimeTypeFromPath($path); - } - - public function detectMimeTypeFromBuffer(string $contents): ?string - { - return null; - } -} diff --git a/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php deleted file mode 100644 index 1dad7bc..0000000 --- a/vendor/league/mime-type-detection/src/ExtensionToMimeTypeMap.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ - private $inconclusiveMimetypes; - - public function __construct( - string $magicFile = '', - ExtensionToMimeTypeMap $extensionMap = null, - ?int $bufferSampleSize = null, - array $inconclusiveMimetypes = self::INCONCLUSIVE_MIME_TYPES - ) { - $this->finfo = new finfo(FILEINFO_MIME_TYPE, $magicFile); - $this->extensionMap = $extensionMap ?: new GeneratedExtensionToMimeTypeMap(); - $this->bufferSampleSize = $bufferSampleSize; - $this->inconclusiveMimetypes = $inconclusiveMimetypes; - } - - public function detectMimeType(string $path, $contents): ?string - { - $mimeType = is_string($contents) - ? (@$this->finfo->buffer($this->takeSample($contents)) ?: null) - : null; - - if ($mimeType !== null && ! in_array($mimeType, $this->inconclusiveMimetypes)) { - return $mimeType; - } - - return $this->detectMimeTypeFromPath($path); - } - - public function detectMimeTypeFromPath(string $path): ?string - { - $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); - - return $this->extensionMap->lookupMimeType($extension); - } - - public function detectMimeTypeFromFile(string $path): ?string - { - return @$this->finfo->file($path) ?: null; - } - - public function detectMimeTypeFromBuffer(string $contents): ?string - { - return @$this->finfo->buffer($this->takeSample($contents)) ?: null; - } - - private function takeSample(string $contents): string - { - if ($this->bufferSampleSize === null) { - return $contents; - } - - return (string) substr($contents, 0, $this->bufferSampleSize); - } -} diff --git a/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php b/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php deleted file mode 100644 index f092388..0000000 --- a/vendor/league/mime-type-detection/src/GeneratedExtensionToMimeTypeMap.php +++ /dev/null @@ -1,1227 +0,0 @@ - 'application/vnd.1000minds.decision-model+xml', - '3dml' => 'text/vnd.in3d.3dml', - '3ds' => 'image/x-3ds', - '3g2' => 'video/3gpp2', - '3gp' => 'video/3gp', - '3gpp' => 'video/3gpp', - '3mf' => 'model/3mf', - '7z' => 'application/x-7z-compressed', - '7zip' => 'application/x-7z-compressed', - '123' => 'application/vnd.lotus-1-2-3', - 'aab' => 'application/x-authorware-bin', - 'aac' => 'audio/x-acc', - 'aam' => 'application/x-authorware-map', - 'aas' => 'application/x-authorware-seg', - 'abw' => 'application/x-abiword', - 'ac' => 'application/vnd.nokia.n-gage.ac+xml', - 'ac3' => 'audio/ac3', - 'acc' => 'application/vnd.americandynamics.acc', - 'ace' => 'application/x-ace-compressed', - 'acu' => 'application/vnd.acucobol', - 'acutc' => 'application/vnd.acucorp', - 'adp' => 'audio/adpcm', - 'aep' => 'application/vnd.audiograph', - 'afm' => 'application/x-font-type1', - 'afp' => 'application/vnd.ibm.modcap', - 'age' => 'application/vnd.age', - 'ahead' => 'application/vnd.ahead.space', - 'ai' => 'application/pdf', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'air' => 'application/vnd.adobe.air-application-installer-package+zip', - 'ait' => 'application/vnd.dvb.ait', - 'ami' => 'application/vnd.amiga.ami', - 'amr' => 'audio/amr', - 'apk' => 'application/vnd.android.package-archive', - 'apng' => 'image/apng', - 'appcache' => 'text/cache-manifest', - 'application' => 'application/x-ms-application', - 'apr' => 'application/vnd.lotus-approach', - 'arc' => 'application/x-freearc', - 'arj' => 'application/x-arj', - 'asc' => 'application/pgp-signature', - 'asf' => 'video/x-ms-asf', - 'asm' => 'text/x-asm', - 'aso' => 'application/vnd.accpac.simply.aso', - 'asx' => 'video/x-ms-asf', - 'atc' => 'application/vnd.acucorp', - 'atom' => 'application/atom+xml', - 'atomcat' => 'application/atomcat+xml', - 'atomdeleted' => 'application/atomdeleted+xml', - 'atomsvc' => 'application/atomsvc+xml', - 'atx' => 'application/vnd.antix.game-component', - 'au' => 'audio/x-au', - 'avci' => 'image/avci', - 'avcs' => 'image/avcs', - 'avi' => 'video/x-msvideo', - 'avif' => 'image/avif', - 'aw' => 'application/applixware', - 'azf' => 'application/vnd.airzip.filesecure.azf', - 'azs' => 'application/vnd.airzip.filesecure.azs', - 'azv' => 'image/vnd.airzip.accelerator.azv', - 'azw' => 'application/vnd.amazon.ebook', - 'b16' => 'image/vnd.pco.b16', - 'bat' => 'application/x-msdownload', - 'bcpio' => 'application/x-bcpio', - 'bdf' => 'application/x-font-bdf', - 'bdm' => 'application/vnd.syncml.dm+wbxml', - 'bdoc' => 'application/x-bdoc', - 'bed' => 'application/vnd.realvnc.bed', - 'bh2' => 'application/vnd.fujitsu.oasysprs', - 'bin' => 'application/octet-stream', - 'blb' => 'application/x-blorb', - 'blorb' => 'application/x-blorb', - 'bmi' => 'application/vnd.bmi', - 'bmml' => 'application/vnd.balsamiq.bmml+xml', - 'bmp' => 'image/bmp', - 'book' => 'application/vnd.framemaker', - 'box' => 'application/vnd.previewsystems.box', - 'boz' => 'application/x-bzip2', - 'bpk' => 'application/octet-stream', - 'bpmn' => 'application/octet-stream', - 'bsp' => 'model/vnd.valve.source.compiled-map', - 'btif' => 'image/prs.btif', - 'buffer' => 'application/octet-stream', - 'bz' => 'application/x-bzip', - 'bz2' => 'application/x-bzip2', - 'c' => 'text/x-c', - 'c4d' => 'application/vnd.clonk.c4group', - 'c4f' => 'application/vnd.clonk.c4group', - 'c4g' => 'application/vnd.clonk.c4group', - 'c4p' => 'application/vnd.clonk.c4group', - 'c4u' => 'application/vnd.clonk.c4group', - 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', - 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', - 'cab' => 'application/vnd.ms-cab-compressed', - 'caf' => 'audio/x-caf', - 'cap' => 'application/vnd.tcpdump.pcap', - 'car' => 'application/vnd.curl.car', - 'cat' => 'application/vnd.ms-pki.seccat', - 'cb7' => 'application/x-cbr', - 'cba' => 'application/x-cbr', - 'cbr' => 'application/x-cbr', - 'cbt' => 'application/x-cbr', - 'cbz' => 'application/x-cbr', - 'cc' => 'text/x-c', - 'cco' => 'application/x-cocoa', - 'cct' => 'application/x-director', - 'ccxml' => 'application/ccxml+xml', - 'cdbcmsg' => 'application/vnd.contact.cmsg', - 'cdf' => 'application/x-netcdf', - 'cdfx' => 'application/cdfx+xml', - 'cdkey' => 'application/vnd.mediastation.cdkey', - 'cdmia' => 'application/cdmi-capability', - 'cdmic' => 'application/cdmi-container', - 'cdmid' => 'application/cdmi-domain', - 'cdmio' => 'application/cdmi-object', - 'cdmiq' => 'application/cdmi-queue', - 'cdr' => 'application/cdr', - 'cdx' => 'chemical/x-cdx', - 'cdxml' => 'application/vnd.chemdraw+xml', - 'cdy' => 'application/vnd.cinderella', - 'cer' => 'application/pkix-cert', - 'cfs' => 'application/x-cfs-compressed', - 'cgm' => 'image/cgm', - 'chat' => 'application/x-chat', - 'chm' => 'application/vnd.ms-htmlhelp', - 'chrt' => 'application/vnd.kde.kchart', - 'cif' => 'chemical/x-cif', - 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', - 'cil' => 'application/vnd.ms-artgalry', - 'cjs' => 'application/node', - 'cla' => 'application/vnd.claymore', - 'class' => 'application/octet-stream', - 'clkk' => 'application/vnd.crick.clicker.keyboard', - 'clkp' => 'application/vnd.crick.clicker.palette', - 'clkt' => 'application/vnd.crick.clicker.template', - 'clkw' => 'application/vnd.crick.clicker.wordbank', - 'clkx' => 'application/vnd.crick.clicker', - 'clp' => 'application/x-msclip', - 'cmc' => 'application/vnd.cosmocaller', - 'cmdf' => 'chemical/x-cmdf', - 'cml' => 'chemical/x-cml', - 'cmp' => 'application/vnd.yellowriver-custom-menu', - 'cmx' => 'image/x-cmx', - 'cod' => 'application/vnd.rim.cod', - 'coffee' => 'text/coffeescript', - 'com' => 'application/x-msdownload', - 'conf' => 'text/plain', - 'cpio' => 'application/x-cpio', - 'cpl' => 'application/cpl+xml', - 'cpp' => 'text/x-c', - 'cpt' => 'application/mac-compactpro', - 'crd' => 'application/x-mscardfile', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'crx' => 'application/x-chrome-extension', - 'cryptonote' => 'application/vnd.rig.cryptonote', - 'csh' => 'application/x-csh', - 'csl' => 'application/vnd.citationstyles.style+xml', - 'csml' => 'chemical/x-csml', - 'csp' => 'application/vnd.commonspace', - 'csr' => 'application/octet-stream', - 'css' => 'text/css', - 'cst' => 'application/x-director', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'curl' => 'text/vnd.curl', - 'cww' => 'application/prs.cww', - 'cxt' => 'application/x-director', - 'cxx' => 'text/x-c', - 'dae' => 'model/vnd.collada+xml', - 'daf' => 'application/vnd.mobius.daf', - 'dart' => 'application/vnd.dart', - 'dataless' => 'application/vnd.fdsn.seed', - 'davmount' => 'application/davmount+xml', - 'dbf' => 'application/vnd.dbf', - 'dbk' => 'application/docbook+xml', - 'dcr' => 'application/x-director', - 'dcurl' => 'text/vnd.curl.dcurl', - 'dd2' => 'application/vnd.oma.dd2+xml', - 'ddd' => 'application/vnd.fujixerox.ddd', - 'ddf' => 'application/vnd.syncml.dmddf+xml', - 'dds' => 'image/vnd.ms-dds', - 'deb' => 'application/x-debian-package', - 'def' => 'text/plain', - 'deploy' => 'application/octet-stream', - 'der' => 'application/x-x509-ca-cert', - 'dfac' => 'application/vnd.dreamfactory', - 'dgc' => 'application/x-dgc-compressed', - 'dic' => 'text/x-c', - 'dir' => 'application/x-director', - 'dis' => 'application/vnd.mobius.dis', - 'disposition-notification' => 'message/disposition-notification', - 'dist' => 'application/octet-stream', - 'distz' => 'application/octet-stream', - 'djv' => 'image/vnd.djvu', - 'djvu' => 'image/vnd.djvu', - 'dll' => 'application/octet-stream', - 'dmg' => 'application/x-apple-diskimage', - 'dmn' => 'application/octet-stream', - 'dmp' => 'application/vnd.tcpdump.pcap', - 'dms' => 'application/octet-stream', - 'dna' => 'application/vnd.dna', - 'doc' => 'application/msword', - 'docm' => 'application/vnd.ms-word.template.macroEnabled.12', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dot' => 'application/msword', - 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', - 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', - 'dp' => 'application/vnd.osgi.dp', - 'dpg' => 'application/vnd.dpgraph', - 'dra' => 'audio/vnd.dra', - 'drle' => 'image/dicom-rle', - 'dsc' => 'text/prs.lines.tag', - 'dssc' => 'application/dssc+der', - 'dtb' => 'application/x-dtbook+xml', - 'dtd' => 'application/xml-dtd', - 'dts' => 'audio/vnd.dts', - 'dtshd' => 'audio/vnd.dts.hd', - 'dump' => 'application/octet-stream', - 'dvb' => 'video/vnd.dvb.file', - 'dvi' => 'application/x-dvi', - 'dwd' => 'application/atsc-dwd+xml', - 'dwf' => 'model/vnd.dwf', - 'dwg' => 'image/vnd.dwg', - 'dxf' => 'image/vnd.dxf', - 'dxp' => 'application/vnd.spotfire.dxp', - 'dxr' => 'application/x-director', - 'ear' => 'application/java-archive', - 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', - 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', - 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', - 'ecma' => 'application/ecmascript', - 'edm' => 'application/vnd.novadigm.edm', - 'edx' => 'application/vnd.novadigm.edx', - 'efif' => 'application/vnd.picsel', - 'ei6' => 'application/vnd.pg.osasli', - 'elc' => 'application/octet-stream', - 'emf' => 'image/emf', - 'eml' => 'message/rfc822', - 'emma' => 'application/emma+xml', - 'emotionml' => 'application/emotionml+xml', - 'emz' => 'application/x-msmetafile', - 'eol' => 'audio/vnd.digital-winds', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'es' => 'application/ecmascript', - 'es3' => 'application/vnd.eszigno3+xml', - 'esa' => 'application/vnd.osgi.subsystem', - 'esf' => 'application/vnd.epson.esf', - 'et3' => 'application/vnd.eszigno3+xml', - 'etx' => 'text/x-setext', - 'eva' => 'application/x-eva', - 'evy' => 'application/x-envoy', - 'exe' => 'application/octet-stream', - 'exi' => 'application/exi', - 'exp' => 'application/express', - 'exr' => 'image/aces', - 'ext' => 'application/vnd.novadigm.ext', - 'ez' => 'application/andrew-inset', - 'ez2' => 'application/vnd.ezpix-album', - 'ez3' => 'application/vnd.ezpix-package', - 'f' => 'text/x-fortran', - 'f4v' => 'video/mp4', - 'f77' => 'text/x-fortran', - 'f90' => 'text/x-fortran', - 'fbs' => 'image/vnd.fastbidsheet', - 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', - 'fcs' => 'application/vnd.isac.fcs', - 'fdf' => 'application/vnd.fdf', - 'fdt' => 'application/fdt+xml', - 'fe_launch' => 'application/vnd.denovo.fcselayout-link', - 'fg5' => 'application/vnd.fujitsu.oasysgp', - 'fgd' => 'application/x-director', - 'fh' => 'image/x-freehand', - 'fh4' => 'image/x-freehand', - 'fh5' => 'image/x-freehand', - 'fh7' => 'image/x-freehand', - 'fhc' => 'image/x-freehand', - 'fig' => 'application/x-xfig', - 'fits' => 'image/fits', - 'flac' => 'audio/x-flac', - 'fli' => 'video/x-fli', - 'flo' => 'application/vnd.micrografx.flo', - 'flv' => 'video/x-flv', - 'flw' => 'application/vnd.kde.kivio', - 'flx' => 'text/vnd.fmi.flexstor', - 'fly' => 'text/vnd.fly', - 'fm' => 'application/vnd.framemaker', - 'fnc' => 'application/vnd.frogans.fnc', - 'fo' => 'application/vnd.software602.filler.form+xml', - 'for' => 'text/x-fortran', - 'fpx' => 'image/vnd.fpx', - 'frame' => 'application/vnd.framemaker', - 'fsc' => 'application/vnd.fsc.weblaunch', - 'fst' => 'image/vnd.fst', - 'ftc' => 'application/vnd.fluxtime.clip', - 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', - 'fvt' => 'video/vnd.fvt', - 'fxp' => 'application/vnd.adobe.fxp', - 'fxpl' => 'application/vnd.adobe.fxp', - 'fzs' => 'application/vnd.fuzzysheet', - 'g2w' => 'application/vnd.geoplan', - 'g3' => 'image/g3fax', - 'g3w' => 'application/vnd.geospace', - 'gac' => 'application/vnd.groove-account', - 'gam' => 'application/x-tads', - 'gbr' => 'application/rpki-ghostbusters', - 'gca' => 'application/x-gca-compressed', - 'gdl' => 'model/vnd.gdl', - 'gdoc' => 'application/vnd.google-apps.document', - 'ged' => 'text/vnd.familysearch.gedcom', - 'geo' => 'application/vnd.dynageo', - 'geojson' => 'application/geo+json', - 'gex' => 'application/vnd.geometry-explorer', - 'ggb' => 'application/vnd.geogebra.file', - 'ggt' => 'application/vnd.geogebra.tool', - 'ghf' => 'application/vnd.groove-help', - 'gif' => 'image/gif', - 'gim' => 'application/vnd.groove-identity-message', - 'glb' => 'model/gltf-binary', - 'gltf' => 'model/gltf+json', - 'gml' => 'application/gml+xml', - 'gmx' => 'application/vnd.gmx', - 'gnumeric' => 'application/x-gnumeric', - 'gpg' => 'application/gpg-keys', - 'gph' => 'application/vnd.flographit', - 'gpx' => 'application/gpx+xml', - 'gqf' => 'application/vnd.grafeq', - 'gqs' => 'application/vnd.grafeq', - 'gram' => 'application/srgs', - 'gramps' => 'application/x-gramps-xml', - 'gre' => 'application/vnd.geometry-explorer', - 'grv' => 'application/vnd.groove-injector', - 'grxml' => 'application/srgs+xml', - 'gsf' => 'application/x-font-ghostscript', - 'gsheet' => 'application/vnd.google-apps.spreadsheet', - 'gslides' => 'application/vnd.google-apps.presentation', - 'gtar' => 'application/x-gtar', - 'gtm' => 'application/vnd.groove-tool-message', - 'gtw' => 'model/vnd.gtw', - 'gv' => 'text/vnd.graphviz', - 'gxf' => 'application/gxf', - 'gxt' => 'application/vnd.geonext', - 'gz' => 'application/gzip', - 'gzip' => 'application/gzip', - 'h' => 'text/x-c', - 'h261' => 'video/h261', - 'h263' => 'video/h263', - 'h264' => 'video/h264', - 'hal' => 'application/vnd.hal+xml', - 'hbci' => 'application/vnd.hbci', - 'hbs' => 'text/x-handlebars-template', - 'hdd' => 'application/x-virtualbox-hdd', - 'hdf' => 'application/x-hdf', - 'heic' => 'image/heic', - 'heics' => 'image/heic-sequence', - 'heif' => 'image/heif', - 'heifs' => 'image/heif-sequence', - 'hej2' => 'image/hej2k', - 'held' => 'application/atsc-held+xml', - 'hh' => 'text/x-c', - 'hjson' => 'application/hjson', - 'hlp' => 'application/winhlp', - 'hpgl' => 'application/vnd.hp-hpgl', - 'hpid' => 'application/vnd.hp-hpid', - 'hps' => 'application/vnd.hp-hps', - 'hqx' => 'application/mac-binhex40', - 'hsj2' => 'image/hsj2', - 'htc' => 'text/x-component', - 'htke' => 'application/vnd.kenameaapp', - 'htm' => 'text/html', - 'html' => 'text/html', - 'hvd' => 'application/vnd.yamaha.hv-dic', - 'hvp' => 'application/vnd.yamaha.hv-voice', - 'hvs' => 'application/vnd.yamaha.hv-script', - 'i2g' => 'application/vnd.intergeo', - 'icc' => 'application/vnd.iccprofile', - 'ice' => 'x-conference/x-cooltalk', - 'icm' => 'application/vnd.iccprofile', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ief' => 'image/ief', - 'ifb' => 'text/calendar', - 'ifm' => 'application/vnd.shana.informed.formdata', - 'iges' => 'model/iges', - 'igl' => 'application/vnd.igloader', - 'igm' => 'application/vnd.insors.igm', - 'igs' => 'model/iges', - 'igx' => 'application/vnd.micrografx.igx', - 'iif' => 'application/vnd.shana.informed.interchange', - 'img' => 'application/octet-stream', - 'imp' => 'application/vnd.accpac.simply.imp', - 'ims' => 'application/vnd.ms-ims', - 'in' => 'text/plain', - 'ini' => 'text/plain', - 'ink' => 'application/inkml+xml', - 'inkml' => 'application/inkml+xml', - 'install' => 'application/x-install-instructions', - 'iota' => 'application/vnd.astraea-software.iota', - 'ipfix' => 'application/ipfix', - 'ipk' => 'application/vnd.shana.informed.package', - 'irm' => 'application/vnd.ibm.rights-management', - 'irp' => 'application/vnd.irepository.package+xml', - 'iso' => 'application/x-iso9660-image', - 'itp' => 'application/vnd.shana.informed.formtemplate', - 'its' => 'application/its+xml', - 'ivp' => 'application/vnd.immervision-ivp', - 'ivu' => 'application/vnd.immervision-ivu', - 'jad' => 'text/vnd.sun.j2me.app-descriptor', - 'jade' => 'text/jade', - 'jam' => 'application/vnd.jam', - 'jar' => 'application/java-archive', - 'jardiff' => 'application/x-java-archive-diff', - 'java' => 'text/x-java-source', - 'jhc' => 'image/jphc', - 'jisp' => 'application/vnd.jisp', - 'jls' => 'image/jls', - 'jlt' => 'application/vnd.hp-jlyt', - 'jng' => 'image/x-jng', - 'jnlp' => 'application/x-java-jnlp-file', - 'joda' => 'application/vnd.joost.joda-archive', - 'jp2' => 'image/jp2', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpf' => 'image/jpx', - 'jpg' => 'image/jpeg', - 'jpg2' => 'image/jp2', - 'jpgm' => 'video/jpm', - 'jpgv' => 'video/jpeg', - 'jph' => 'image/jph', - 'jpm' => 'video/jpm', - 'jpx' => 'image/jpx', - 'js' => 'application/javascript', - 'json' => 'application/json', - 'json5' => 'application/json5', - 'jsonld' => 'application/ld+json', - 'jsonml' => 'application/jsonml+json', - 'jsx' => 'text/jsx', - 'jxr' => 'image/jxr', - 'jxra' => 'image/jxra', - 'jxrs' => 'image/jxrs', - 'jxs' => 'image/jxs', - 'jxsc' => 'image/jxsc', - 'jxsi' => 'image/jxsi', - 'jxss' => 'image/jxss', - 'kar' => 'audio/midi', - 'karbon' => 'application/vnd.kde.karbon', - 'kdb' => 'application/octet-stream', - 'kdbx' => 'application/x-keepass2', - 'key' => 'application/x-iwork-keynote-sffkey', - 'kfo' => 'application/vnd.kde.kformula', - 'kia' => 'application/vnd.kidspiration', - 'kml' => 'application/vnd.google-earth.kml+xml', - 'kmz' => 'application/vnd.google-earth.kmz', - 'kne' => 'application/vnd.kinar', - 'knp' => 'application/vnd.kinar', - 'kon' => 'application/vnd.kde.kontour', - 'kpr' => 'application/vnd.kde.kpresenter', - 'kpt' => 'application/vnd.kde.kpresenter', - 'kpxx' => 'application/vnd.ds-keypoint', - 'ksp' => 'application/vnd.kde.kspread', - 'ktr' => 'application/vnd.kahootz', - 'ktx' => 'image/ktx', - 'ktx2' => 'image/ktx2', - 'ktz' => 'application/vnd.kahootz', - 'kwd' => 'application/vnd.kde.kword', - 'kwt' => 'application/vnd.kde.kword', - 'lasxml' => 'application/vnd.las.las+xml', - 'latex' => 'application/x-latex', - 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', - 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', - 'les' => 'application/vnd.hhe.lesson-player', - 'less' => 'text/less', - 'lgr' => 'application/lgr+xml', - 'lha' => 'application/octet-stream', - 'link66' => 'application/vnd.route66.link66+xml', - 'list' => 'text/plain', - 'list3820' => 'application/vnd.ibm.modcap', - 'listafp' => 'application/vnd.ibm.modcap', - 'litcoffee' => 'text/coffeescript', - 'lnk' => 'application/x-ms-shortcut', - 'log' => 'text/plain', - 'lostxml' => 'application/lost+xml', - 'lrf' => 'application/octet-stream', - 'lrm' => 'application/vnd.ms-lrm', - 'ltf' => 'application/vnd.frogans.ltf', - 'lua' => 'text/x-lua', - 'luac' => 'application/x-lua-bytecode', - 'lvp' => 'audio/vnd.lucent.voice', - 'lwp' => 'application/vnd.lotus-wordpro', - 'lzh' => 'application/octet-stream', - 'm1v' => 'video/mpeg', - 'm2a' => 'audio/mpeg', - 'm2v' => 'video/mpeg', - 'm3a' => 'audio/mpeg', - 'm3u' => 'text/plain', - 'm3u8' => 'application/vnd.apple.mpegurl', - 'm4a' => 'audio/x-m4a', - 'm4p' => 'application/mp4', - 'm4s' => 'video/iso.segment', - 'm4u' => 'application/vnd.mpegurl', - 'm4v' => 'video/x-m4v', - 'm13' => 'application/x-msmediaview', - 'm14' => 'application/x-msmediaview', - 'm21' => 'application/mp21', - 'ma' => 'application/mathematica', - 'mads' => 'application/mads+xml', - 'maei' => 'application/mmt-aei+xml', - 'mag' => 'application/vnd.ecowin.chart', - 'maker' => 'application/vnd.framemaker', - 'man' => 'text/troff', - 'manifest' => 'text/cache-manifest', - 'map' => 'application/json', - 'mar' => 'application/octet-stream', - 'markdown' => 'text/markdown', - 'mathml' => 'application/mathml+xml', - 'mb' => 'application/mathematica', - 'mbk' => 'application/vnd.mobius.mbk', - 'mbox' => 'application/mbox', - 'mc1' => 'application/vnd.medcalcdata', - 'mcd' => 'application/vnd.mcd', - 'mcurl' => 'text/vnd.curl.mcurl', - 'md' => 'text/markdown', - 'mdb' => 'application/x-msaccess', - 'mdi' => 'image/vnd.ms-modi', - 'mdx' => 'text/mdx', - 'me' => 'text/troff', - 'mesh' => 'model/mesh', - 'meta4' => 'application/metalink4+xml', - 'metalink' => 'application/metalink+xml', - 'mets' => 'application/mets+xml', - 'mfm' => 'application/vnd.mfmp', - 'mft' => 'application/rpki-manifest', - 'mgp' => 'application/vnd.osgeo.mapguide.package', - 'mgz' => 'application/vnd.proteus.magazine', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mie' => 'application/x-mie', - 'mif' => 'application/vnd.mif', - 'mime' => 'message/rfc822', - 'mj2' => 'video/mj2', - 'mjp2' => 'video/mj2', - 'mjs' => 'application/javascript', - 'mk3d' => 'video/x-matroska', - 'mka' => 'audio/x-matroska', - 'mkd' => 'text/x-markdown', - 'mks' => 'video/x-matroska', - 'mkv' => 'video/x-matroska', - 'mlp' => 'application/vnd.dolby.mlp', - 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', - 'mmf' => 'application/vnd.smaf', - 'mml' => 'text/mathml', - 'mmr' => 'image/vnd.fujixerox.edmics-mmr', - 'mng' => 'video/x-mng', - 'mny' => 'application/x-msmoney', - 'mobi' => 'application/x-mobipocket-ebook', - 'mods' => 'application/mods+xml', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp2a' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4s' => 'application/mp4', - 'mp4v' => 'video/mp4', - 'mp21' => 'application/mp21', - 'mpc' => 'application/vnd.mophun.certificate', - 'mpd' => 'application/dash+xml', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpf' => 'application/media-policy-dataset+xml', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'mpga' => 'audio/mpeg', - 'mpkg' => 'application/vnd.apple.installer+xml', - 'mpm' => 'application/vnd.blueice.multipass', - 'mpn' => 'application/vnd.mophun.application', - 'mpp' => 'application/vnd.ms-project', - 'mpt' => 'application/vnd.ms-project', - 'mpy' => 'application/vnd.ibm.minipay', - 'mqy' => 'application/vnd.mobius.mqy', - 'mrc' => 'application/marc', - 'mrcx' => 'application/marcxml+xml', - 'ms' => 'text/troff', - 'mscml' => 'application/mediaservercontrol+xml', - 'mseed' => 'application/vnd.fdsn.mseed', - 'mseq' => 'application/vnd.mseq', - 'msf' => 'application/vnd.epson.msf', - 'msg' => 'application/vnd.ms-outlook', - 'msh' => 'model/mesh', - 'msi' => 'application/x-msdownload', - 'msl' => 'application/vnd.mobius.msl', - 'msm' => 'application/octet-stream', - 'msp' => 'application/octet-stream', - 'msty' => 'application/vnd.muvee.style', - 'mtl' => 'model/mtl', - 'mts' => 'model/vnd.mts', - 'mus' => 'application/vnd.musician', - 'musd' => 'application/mmt-usd+xml', - 'musicxml' => 'application/vnd.recordare.musicxml+xml', - 'mvb' => 'application/x-msmediaview', - 'mvt' => 'application/vnd.mapbox-vector-tile', - 'mwf' => 'application/vnd.mfer', - 'mxf' => 'application/mxf', - 'mxl' => 'application/vnd.recordare.musicxml', - 'mxmf' => 'audio/mobile-xmf', - 'mxml' => 'application/xv+xml', - 'mxs' => 'application/vnd.triscape.mxs', - 'mxu' => 'video/vnd.mpegurl', - 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', - 'n3' => 'text/n3', - 'nb' => 'application/mathematica', - 'nbp' => 'application/vnd.wolfram.player', - 'nc' => 'application/x-netcdf', - 'ncx' => 'application/x-dtbncx+xml', - 'nfo' => 'text/x-nfo', - 'ngdat' => 'application/vnd.nokia.n-gage.data', - 'nitf' => 'application/vnd.nitf', - 'nlu' => 'application/vnd.neurolanguage.nlu', - 'nml' => 'application/vnd.enliven', - 'nnd' => 'application/vnd.noblenet-directory', - 'nns' => 'application/vnd.noblenet-sealer', - 'nnw' => 'application/vnd.noblenet-web', - 'npx' => 'image/vnd.net-fpx', - 'nq' => 'application/n-quads', - 'nsc' => 'application/x-conference', - 'nsf' => 'application/vnd.lotus-notes', - 'nt' => 'application/n-triples', - 'ntf' => 'application/vnd.nitf', - 'numbers' => 'application/x-iwork-numbers-sffnumbers', - 'nzb' => 'application/x-nzb', - 'oa2' => 'application/vnd.fujitsu.oasys2', - 'oa3' => 'application/vnd.fujitsu.oasys3', - 'oas' => 'application/vnd.fujitsu.oasys', - 'obd' => 'application/x-msbinder', - 'obgx' => 'application/vnd.openblox.game+xml', - 'obj' => 'model/obj', - 'oda' => 'application/oda', - 'odb' => 'application/vnd.oasis.opendocument.database', - 'odc' => 'application/vnd.oasis.opendocument.chart', - 'odf' => 'application/vnd.oasis.opendocument.formula', - 'odft' => 'application/vnd.oasis.opendocument.formula-template', - 'odg' => 'application/vnd.oasis.opendocument.graphics', - 'odi' => 'application/vnd.oasis.opendocument.image', - 'odm' => 'application/vnd.oasis.opendocument.text-master', - 'odp' => 'application/vnd.oasis.opendocument.presentation', - 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - 'odt' => 'application/vnd.oasis.opendocument.text', - 'oga' => 'audio/ogg', - 'ogex' => 'model/vnd.opengex', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'omdoc' => 'application/omdoc+xml', - 'onepkg' => 'application/onenote', - 'onetmp' => 'application/onenote', - 'onetoc' => 'application/onenote', - 'onetoc2' => 'application/onenote', - 'opf' => 'application/oebps-package+xml', - 'opml' => 'text/x-opml', - 'oprc' => 'application/vnd.palm', - 'opus' => 'audio/ogg', - 'org' => 'text/x-org', - 'osf' => 'application/vnd.yamaha.openscoreformat', - 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', - 'osm' => 'application/vnd.openstreetmap.data+xml', - 'otc' => 'application/vnd.oasis.opendocument.chart-template', - 'otf' => 'font/otf', - 'otg' => 'application/vnd.oasis.opendocument.graphics-template', - 'oth' => 'application/vnd.oasis.opendocument.text-web', - 'oti' => 'application/vnd.oasis.opendocument.image-template', - 'otp' => 'application/vnd.oasis.opendocument.presentation-template', - 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', - 'ott' => 'application/vnd.oasis.opendocument.text-template', - 'ova' => 'application/x-virtualbox-ova', - 'ovf' => 'application/x-virtualbox-ovf', - 'owl' => 'application/rdf+xml', - 'oxps' => 'application/oxps', - 'oxt' => 'application/vnd.openofficeorg.extension', - 'p' => 'text/x-pascal', - 'p7a' => 'application/x-pkcs7-signature', - 'p7b' => 'application/x-pkcs7-certificates', - 'p7c' => 'application/pkcs7-mime', - 'p7m' => 'application/pkcs7-mime', - 'p7r' => 'application/x-pkcs7-certreqresp', - 'p7s' => 'application/pkcs7-signature', - 'p8' => 'application/pkcs8', - 'p10' => 'application/x-pkcs10', - 'p12' => 'application/x-pkcs12', - 'pac' => 'application/x-ns-proxy-autoconfig', - 'pages' => 'application/x-iwork-pages-sffpages', - 'pas' => 'text/x-pascal', - 'paw' => 'application/vnd.pawaafile', - 'pbd' => 'application/vnd.powerbuilder6', - 'pbm' => 'image/x-portable-bitmap', - 'pcap' => 'application/vnd.tcpdump.pcap', - 'pcf' => 'application/x-font-pcf', - 'pcl' => 'application/vnd.hp-pcl', - 'pclxl' => 'application/vnd.hp-pclxl', - 'pct' => 'image/x-pict', - 'pcurl' => 'application/vnd.curl.pcurl', - 'pcx' => 'image/x-pcx', - 'pdb' => 'application/x-pilot', - 'pde' => 'text/x-processing', - 'pdf' => 'application/pdf', - 'pem' => 'application/x-x509-user-cert', - 'pfa' => 'application/x-font-type1', - 'pfb' => 'application/x-font-type1', - 'pfm' => 'application/x-font-type1', - 'pfr' => 'application/font-tdpfr', - 'pfx' => 'application/x-pkcs12', - 'pgm' => 'image/x-portable-graymap', - 'pgn' => 'application/x-chess-pgn', - 'pgp' => 'application/pgp', - 'phar' => 'application/octet-stream', - 'php' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'phtml' => 'application/x-httpd-php', - 'pic' => 'image/x-pict', - 'pkg' => 'application/octet-stream', - 'pki' => 'application/pkixcmp', - 'pkipath' => 'application/pkix-pkipath', - 'pkpass' => 'application/vnd.apple.pkpass', - 'pl' => 'application/x-perl', - 'plb' => 'application/vnd.3gpp.pic-bw-large', - 'plc' => 'application/vnd.mobius.plc', - 'plf' => 'application/vnd.pocketlearn', - 'pls' => 'application/pls+xml', - 'pm' => 'application/x-perl', - 'pml' => 'application/vnd.ctc-posml', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'portpkg' => 'application/vnd.macports.portpkg', - 'pot' => 'application/vnd.ms-powerpoint', - 'potm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', - 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', - 'ppa' => 'application/vnd.ms-powerpoint', - 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', - 'ppd' => 'application/vnd.cups-ppd', - 'ppm' => 'image/x-portable-pixmap', - 'pps' => 'application/vnd.ms-powerpoint', - 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', - 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', - 'ppt' => 'application/powerpoint', - 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'pqa' => 'application/vnd.palm', - 'prc' => 'model/prc', - 'pre' => 'application/vnd.lotus-freelance', - 'prf' => 'application/pics-rules', - 'provx' => 'application/provenance+xml', - 'ps' => 'application/postscript', - 'psb' => 'application/vnd.3gpp.pic-bw-small', - 'psd' => 'application/x-photoshop', - 'psf' => 'application/x-font-linux-psf', - 'pskcxml' => 'application/pskc+xml', - 'pti' => 'image/prs.pti', - 'ptid' => 'application/vnd.pvi.ptid1', - 'pub' => 'application/x-mspublisher', - 'pvb' => 'application/vnd.3gpp.pic-bw-var', - 'pwn' => 'application/vnd.3m.post-it-notes', - 'pya' => 'audio/vnd.ms-playready.media.pya', - 'pyv' => 'video/vnd.ms-playready.media.pyv', - 'qam' => 'application/vnd.epson.quickanime', - 'qbo' => 'application/vnd.intu.qbo', - 'qfx' => 'application/vnd.intu.qfx', - 'qps' => 'application/vnd.publishare-delta-tree', - 'qt' => 'video/quicktime', - 'qwd' => 'application/vnd.quark.quarkxpress', - 'qwt' => 'application/vnd.quark.quarkxpress', - 'qxb' => 'application/vnd.quark.quarkxpress', - 'qxd' => 'application/vnd.quark.quarkxpress', - 'qxl' => 'application/vnd.quark.quarkxpress', - 'qxt' => 'application/vnd.quark.quarkxpress', - 'ra' => 'audio/x-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'raml' => 'application/raml+yaml', - 'rapd' => 'application/route-apd+xml', - 'rar' => 'application/x-rar', - 'ras' => 'image/x-cmu-raster', - 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', - 'rdf' => 'application/rdf+xml', - 'rdz' => 'application/vnd.data-vision.rdz', - 'relo' => 'application/p2p-overlay+xml', - 'rep' => 'application/vnd.businessobjects', - 'res' => 'application/x-dtbresource+xml', - 'rgb' => 'image/x-rgb', - 'rif' => 'application/reginfo+xml', - 'rip' => 'audio/vnd.rip', - 'ris' => 'application/x-research-info-systems', - 'rl' => 'application/resource-lists+xml', - 'rlc' => 'image/vnd.fujixerox.edmics-rlc', - 'rld' => 'application/resource-lists-diff+xml', - 'rm' => 'audio/x-pn-realaudio', - 'rmi' => 'audio/midi', - 'rmp' => 'audio/x-pn-realaudio-plugin', - 'rms' => 'application/vnd.jcp.javame.midlet-rms', - 'rmvb' => 'application/vnd.rn-realmedia-vbr', - 'rnc' => 'application/relax-ng-compact-syntax', - 'rng' => 'application/xml', - 'roa' => 'application/rpki-roa', - 'roff' => 'text/troff', - 'rp9' => 'application/vnd.cloanto.rp9', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'rpss' => 'application/vnd.nokia.radio-presets', - 'rpst' => 'application/vnd.nokia.radio-preset', - 'rq' => 'application/sparql-query', - 'rs' => 'application/rls-services+xml', - 'rsa' => 'application/x-pkcs7', - 'rsat' => 'application/atsc-rsat+xml', - 'rsd' => 'application/rsd+xml', - 'rsheet' => 'application/urc-ressheet+xml', - 'rss' => 'application/rss+xml', - 'rtf' => 'text/rtf', - 'rtx' => 'text/richtext', - 'run' => 'application/x-makeself', - 'rusd' => 'application/route-usd+xml', - 'rv' => 'video/vnd.rn-realvideo', - 's' => 'text/x-asm', - 's3m' => 'audio/s3m', - 'saf' => 'application/vnd.yamaha.smaf-audio', - 'sass' => 'text/x-sass', - 'sbml' => 'application/sbml+xml', - 'sc' => 'application/vnd.ibm.secure-container', - 'scd' => 'application/x-msschedule', - 'scm' => 'application/vnd.lotus-screencam', - 'scq' => 'application/scvp-cv-request', - 'scs' => 'application/scvp-cv-response', - 'scss' => 'text/x-scss', - 'scurl' => 'text/vnd.curl.scurl', - 'sda' => 'application/vnd.stardivision.draw', - 'sdc' => 'application/vnd.stardivision.calc', - 'sdd' => 'application/vnd.stardivision.impress', - 'sdkd' => 'application/vnd.solent.sdkm+xml', - 'sdkm' => 'application/vnd.solent.sdkm+xml', - 'sdp' => 'application/sdp', - 'sdw' => 'application/vnd.stardivision.writer', - 'sea' => 'application/octet-stream', - 'see' => 'application/vnd.seemail', - 'seed' => 'application/vnd.fdsn.seed', - 'sema' => 'application/vnd.sema', - 'semd' => 'application/vnd.semd', - 'semf' => 'application/vnd.semf', - 'senmlx' => 'application/senml+xml', - 'sensmlx' => 'application/sensml+xml', - 'ser' => 'application/java-serialized-object', - 'setpay' => 'application/set-payment-initiation', - 'setreg' => 'application/set-registration-initiation', - 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', - 'sfs' => 'application/vnd.spotfire.sfs', - 'sfv' => 'text/x-sfv', - 'sgi' => 'image/sgi', - 'sgl' => 'application/vnd.stardivision.writer-global', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'sh' => 'application/x-sh', - 'shar' => 'application/x-shar', - 'shex' => 'text/shex', - 'shf' => 'application/shf+xml', - 'shtml' => 'text/html', - 'sid' => 'image/x-mrsid-image', - 'sieve' => 'application/sieve', - 'sig' => 'application/pgp-signature', - 'sil' => 'audio/silk', - 'silo' => 'model/mesh', - 'sis' => 'application/vnd.symbian.install', - 'sisx' => 'application/vnd.symbian.install', - 'sit' => 'application/x-stuffit', - 'sitx' => 'application/x-stuffitx', - 'siv' => 'application/sieve', - 'skd' => 'application/vnd.koan', - 'skm' => 'application/vnd.koan', - 'skp' => 'application/vnd.koan', - 'skt' => 'application/vnd.koan', - 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', - 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', - 'slim' => 'text/slim', - 'slm' => 'text/slim', - 'sls' => 'application/route-s-tsid+xml', - 'slt' => 'application/vnd.epson.salt', - 'sm' => 'application/vnd.stepmania.stepchart', - 'smf' => 'application/vnd.stardivision.math', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'smv' => 'video/x-smv', - 'smzip' => 'application/vnd.stepmania.package', - 'snd' => 'audio/basic', - 'snf' => 'application/x-font-snf', - 'so' => 'application/octet-stream', - 'spc' => 'application/x-pkcs7-certificates', - 'spdx' => 'text/spdx', - 'spf' => 'application/vnd.yamaha.smaf-phrase', - 'spl' => 'application/x-futuresplash', - 'spot' => 'text/vnd.in3d.spot', - 'spp' => 'application/scvp-vp-response', - 'spq' => 'application/scvp-vp-request', - 'spx' => 'audio/ogg', - 'sql' => 'application/x-sql', - 'src' => 'application/x-wais-source', - 'srt' => 'application/x-subrip', - 'sru' => 'application/sru+xml', - 'srx' => 'application/sparql-results+xml', - 'ssdl' => 'application/ssdl+xml', - 'sse' => 'application/vnd.kodak-descriptor', - 'ssf' => 'application/vnd.epson.ssf', - 'ssml' => 'application/ssml+xml', - 'sst' => 'application/octet-stream', - 'st' => 'application/vnd.sailingtracker.track', - 'stc' => 'application/vnd.sun.xml.calc.template', - 'std' => 'application/vnd.sun.xml.draw.template', - 'stf' => 'application/vnd.wt.stf', - 'sti' => 'application/vnd.sun.xml.impress.template', - 'stk' => 'application/hyperstudio', - 'stl' => 'model/stl', - 'stpx' => 'model/step+xml', - 'stpxz' => 'model/step-xml+zip', - 'stpz' => 'model/step+zip', - 'str' => 'application/vnd.pg.format', - 'stw' => 'application/vnd.sun.xml.writer.template', - 'styl' => 'text/stylus', - 'stylus' => 'text/stylus', - 'sub' => 'text/vnd.dvb.subtitle', - 'sus' => 'application/vnd.sus-calendar', - 'susp' => 'application/vnd.sus-calendar', - 'sv4cpio' => 'application/x-sv4cpio', - 'sv4crc' => 'application/x-sv4crc', - 'svc' => 'application/vnd.dvb.service', - 'svd' => 'application/vnd.svd', - 'svg' => 'image/svg+xml', - 'svgz' => 'image/svg+xml', - 'swa' => 'application/x-director', - 'swf' => 'application/x-shockwave-flash', - 'swi' => 'application/vnd.aristanetworks.swi', - 'swidtag' => 'application/swid+xml', - 'sxc' => 'application/vnd.sun.xml.calc', - 'sxd' => 'application/vnd.sun.xml.draw', - 'sxg' => 'application/vnd.sun.xml.writer.global', - 'sxi' => 'application/vnd.sun.xml.impress', - 'sxm' => 'application/vnd.sun.xml.math', - 'sxw' => 'application/vnd.sun.xml.writer', - 't' => 'text/troff', - 't3' => 'application/x-t3vm-image', - 't38' => 'image/t38', - 'taglet' => 'application/vnd.mynfc', - 'tao' => 'application/vnd.tao.intent-module-archive', - 'tap' => 'image/vnd.tencent.tap', - 'tar' => 'application/x-tar', - 'tcap' => 'application/vnd.3gpp2.tcap', - 'tcl' => 'application/x-tcl', - 'td' => 'application/urc-targetdesc+xml', - 'teacher' => 'application/vnd.smart.teacher', - 'tei' => 'application/tei+xml', - 'teicorpus' => 'application/tei+xml', - 'tex' => 'application/x-tex', - 'texi' => 'application/x-texinfo', - 'texinfo' => 'application/x-texinfo', - 'text' => 'text/plain', - 'tfi' => 'application/thraud+xml', - 'tfm' => 'application/x-tex-tfm', - 'tfx' => 'image/tiff-fx', - 'tga' => 'image/x-tga', - 'tgz' => 'application/x-tar', - 'thmx' => 'application/vnd.ms-officetheme', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'tk' => 'application/x-tcl', - 'tmo' => 'application/vnd.tmobile-livetv', - 'toml' => 'application/toml', - 'torrent' => 'application/x-bittorrent', - 'tpl' => 'application/vnd.groove-tool-template', - 'tpt' => 'application/vnd.trid.tpt', - 'tr' => 'text/troff', - 'tra' => 'application/vnd.trueapp', - 'trig' => 'application/trig', - 'trm' => 'application/x-msterminal', - 'ts' => 'video/mp2t', - 'tsd' => 'application/timestamped-data', - 'tsv' => 'text/tab-separated-values', - 'ttc' => 'font/collection', - 'ttf' => 'font/ttf', - 'ttl' => 'text/turtle', - 'ttml' => 'application/ttml+xml', - 'twd' => 'application/vnd.simtech-mindmapper', - 'twds' => 'application/vnd.simtech-mindmapper', - 'txd' => 'application/vnd.genomatix.tuxedo', - 'txf' => 'application/vnd.mobius.txf', - 'txt' => 'text/plain', - 'u3d' => 'model/u3d', - 'u8dsn' => 'message/global-delivery-status', - 'u8hdr' => 'message/global-headers', - 'u8mdn' => 'message/global-disposition-notification', - 'u8msg' => 'message/global', - 'u32' => 'application/x-authorware-bin', - 'ubj' => 'application/ubjson', - 'udeb' => 'application/x-debian-package', - 'ufd' => 'application/vnd.ufdl', - 'ufdl' => 'application/vnd.ufdl', - 'ulx' => 'application/x-glulx', - 'umj' => 'application/vnd.umajin', - 'unityweb' => 'application/vnd.unity', - 'uoml' => 'application/vnd.uoml+xml', - 'uri' => 'text/uri-list', - 'uris' => 'text/uri-list', - 'urls' => 'text/uri-list', - 'usdz' => 'model/vnd.usdz+zip', - 'ustar' => 'application/x-ustar', - 'utz' => 'application/vnd.uiq.theme', - 'uu' => 'text/x-uuencode', - 'uva' => 'audio/vnd.dece.audio', - 'uvd' => 'application/vnd.dece.data', - 'uvf' => 'application/vnd.dece.data', - 'uvg' => 'image/vnd.dece.graphic', - 'uvh' => 'video/vnd.dece.hd', - 'uvi' => 'image/vnd.dece.graphic', - 'uvm' => 'video/vnd.dece.mobile', - 'uvp' => 'video/vnd.dece.pd', - 'uvs' => 'video/vnd.dece.sd', - 'uvt' => 'application/vnd.dece.ttml+xml', - 'uvu' => 'video/vnd.uvvu.mp4', - 'uvv' => 'video/vnd.dece.video', - 'uvva' => 'audio/vnd.dece.audio', - 'uvvd' => 'application/vnd.dece.data', - 'uvvf' => 'application/vnd.dece.data', - 'uvvg' => 'image/vnd.dece.graphic', - 'uvvh' => 'video/vnd.dece.hd', - 'uvvi' => 'image/vnd.dece.graphic', - 'uvvm' => 'video/vnd.dece.mobile', - 'uvvp' => 'video/vnd.dece.pd', - 'uvvs' => 'video/vnd.dece.sd', - 'uvvt' => 'application/vnd.dece.ttml+xml', - 'uvvu' => 'video/vnd.uvvu.mp4', - 'uvvv' => 'video/vnd.dece.video', - 'uvvx' => 'application/vnd.dece.unspecified', - 'uvvz' => 'application/vnd.dece.zip', - 'uvx' => 'application/vnd.dece.unspecified', - 'uvz' => 'application/vnd.dece.zip', - 'vbox' => 'application/x-virtualbox-vbox', - 'vbox-extpack' => 'application/x-virtualbox-vbox-extpack', - 'vcard' => 'text/vcard', - 'vcd' => 'application/x-cdlink', - 'vcf' => 'text/x-vcard', - 'vcg' => 'application/vnd.groove-vcard', - 'vcs' => 'text/x-vcalendar', - 'vcx' => 'application/vnd.vcx', - 'vdi' => 'application/x-virtualbox-vdi', - 'vds' => 'model/vnd.sap.vds', - 'vhd' => 'application/x-virtualbox-vhd', - 'vis' => 'application/vnd.visionary', - 'viv' => 'video/vnd.vivo', - 'vlc' => 'application/videolan', - 'vmdk' => 'application/x-virtualbox-vmdk', - 'vob' => 'video/x-ms-vob', - 'vor' => 'application/vnd.stardivision.writer', - 'vox' => 'application/x-authorware-bin', - 'vrml' => 'model/vrml', - 'vsd' => 'application/vnd.visio', - 'vsf' => 'application/vnd.vsf', - 'vss' => 'application/vnd.visio', - 'vst' => 'application/vnd.visio', - 'vsw' => 'application/vnd.visio', - 'vtf' => 'image/vnd.valve.source.texture', - 'vtt' => 'text/vtt', - 'vtu' => 'model/vnd.vtu', - 'vxml' => 'application/voicexml+xml', - 'w3d' => 'application/x-director', - 'wad' => 'application/x-doom', - 'wadl' => 'application/vnd.sun.wadl+xml', - 'war' => 'application/java-archive', - 'wasm' => 'application/wasm', - 'wav' => 'audio/x-wav', - 'wax' => 'audio/x-ms-wax', - 'wbmp' => 'image/vnd.wap.wbmp', - 'wbs' => 'application/vnd.criticaltools.wbs+xml', - 'wbxml' => 'application/wbxml', - 'wcm' => 'application/vnd.ms-works', - 'wdb' => 'application/vnd.ms-works', - 'wdp' => 'image/vnd.ms-photo', - 'weba' => 'audio/webm', - 'webapp' => 'application/x-web-app-manifest+json', - 'webm' => 'video/webm', - 'webmanifest' => 'application/manifest+json', - 'webp' => 'image/webp', - 'wg' => 'application/vnd.pmi.widget', - 'wgt' => 'application/widget', - 'wif' => 'application/watcherinfo+xml', - 'wks' => 'application/vnd.ms-works', - 'wm' => 'video/x-ms-wm', - 'wma' => 'audio/x-ms-wma', - 'wmd' => 'application/x-ms-wmd', - 'wmf' => 'image/wmf', - 'wml' => 'text/vnd.wap.wml', - 'wmlc' => 'application/wmlc', - 'wmls' => 'text/vnd.wap.wmlscript', - 'wmlsc' => 'application/vnd.wap.wmlscriptc', - 'wmv' => 'video/x-ms-wmv', - 'wmx' => 'video/x-ms-wmx', - 'wmz' => 'application/x-msmetafile', - 'woff' => 'font/woff', - 'woff2' => 'font/woff2', - 'word' => 'application/msword', - 'wpd' => 'application/vnd.wordperfect', - 'wpl' => 'application/vnd.ms-wpl', - 'wps' => 'application/vnd.ms-works', - 'wqd' => 'application/vnd.wqd', - 'wri' => 'application/x-mswrite', - 'wrl' => 'model/vrml', - 'wsc' => 'message/vnd.wfa.wsc', - 'wsdl' => 'application/wsdl+xml', - 'wspolicy' => 'application/wspolicy+xml', - 'wtb' => 'application/vnd.webturbo', - 'wvx' => 'video/x-ms-wvx', - 'x3d' => 'model/x3d+xml', - 'x3db' => 'model/x3d+fastinfoset', - 'x3dbz' => 'model/x3d+binary', - 'x3dv' => 'model/x3d-vrml', - 'x3dvz' => 'model/x3d+vrml', - 'x3dz' => 'model/x3d+xml', - 'x32' => 'application/x-authorware-bin', - 'x_b' => 'model/vnd.parasolid.transmit.binary', - 'x_t' => 'model/vnd.parasolid.transmit.text', - 'xaml' => 'application/xaml+xml', - 'xap' => 'application/x-silverlight-app', - 'xar' => 'application/vnd.xara', - 'xav' => 'application/xcap-att+xml', - 'xbap' => 'application/x-ms-xbap', - 'xbd' => 'application/vnd.fujixerox.docuworks.binder', - 'xbm' => 'image/x-xbitmap', - 'xca' => 'application/xcap-caps+xml', - 'xcs' => 'application/calendar+xml', - 'xdf' => 'application/xcap-diff+xml', - 'xdm' => 'application/vnd.syncml.dm+xml', - 'xdp' => 'application/vnd.adobe.xdp+xml', - 'xdssc' => 'application/dssc+xml', - 'xdw' => 'application/vnd.fujixerox.docuworks', - 'xel' => 'application/xcap-el+xml', - 'xenc' => 'application/xenc+xml', - 'xer' => 'application/patch-ops-error+xml', - 'xfdf' => 'application/vnd.adobe.xfdf', - 'xfdl' => 'application/vnd.xfdl', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xhvml' => 'application/xv+xml', - 'xif' => 'image/vnd.xiff', - 'xl' => 'application/excel', - 'xla' => 'application/vnd.ms-excel', - 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', - 'xlc' => 'application/vnd.ms-excel', - 'xlf' => 'application/xliff+xml', - 'xlm' => 'application/vnd.ms-excel', - 'xls' => 'application/vnd.ms-excel', - 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', - 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xlt' => 'application/vnd.ms-excel', - 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', - 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', - 'xlw' => 'application/vnd.ms-excel', - 'xm' => 'audio/xm', - 'xml' => 'application/xml', - 'xns' => 'application/xcap-ns+xml', - 'xo' => 'application/vnd.olpc-sugar', - 'xop' => 'application/xop+xml', - 'xpi' => 'application/x-xpinstall', - 'xpl' => 'application/xproc+xml', - 'xpm' => 'image/x-xpixmap', - 'xpr' => 'application/vnd.is-xpr', - 'xps' => 'application/vnd.ms-xpsdocument', - 'xpw' => 'application/vnd.intercon.formnet', - 'xpx' => 'application/vnd.intercon.formnet', - 'xsd' => 'application/xml', - 'xsl' => 'application/xml', - 'xslt' => 'application/xslt+xml', - 'xsm' => 'application/vnd.syncml+xml', - 'xspf' => 'application/xspf+xml', - 'xul' => 'application/vnd.mozilla.xul+xml', - 'xvm' => 'application/xv+xml', - 'xvml' => 'application/xv+xml', - 'xwd' => 'image/x-xwindowdump', - 'xyz' => 'chemical/x-xyz', - 'xz' => 'application/x-xz', - 'yaml' => 'text/yaml', - 'yang' => 'application/yang', - 'yin' => 'application/yin+xml', - 'yml' => 'text/yaml', - 'ymp' => 'text/x-suse-ymp', - 'z' => 'application/x-compress', - 'z1' => 'application/x-zmachine', - 'z2' => 'application/x-zmachine', - 'z3' => 'application/x-zmachine', - 'z4' => 'application/x-zmachine', - 'z5' => 'application/x-zmachine', - 'z6' => 'application/x-zmachine', - 'z7' => 'application/x-zmachine', - 'z8' => 'application/x-zmachine', - 'zaz' => 'application/vnd.zzazz.deck+xml', - 'zip' => 'application/zip', - 'zir' => 'application/vnd.zul', - 'zirz' => 'application/vnd.zul', - 'zmm' => 'application/vnd.handheld-entertainment+xml', - 'zsh' => 'text/x-scriptzsh', - ]; - - public function lookupMimeType(string $extension): ?string - { - return self::MIME_TYPES_FOR_EXTENSIONS[$extension] ?? null; - } -} diff --git a/vendor/league/mime-type-detection/src/MimeTypeDetector.php b/vendor/league/mime-type-detection/src/MimeTypeDetector.php deleted file mode 100644 index 5d799d2..0000000 --- a/vendor/league/mime-type-detection/src/MimeTypeDetector.php +++ /dev/null @@ -1,19 +0,0 @@ - $overrides - */ - public function __construct(ExtensionToMimeTypeMap $innerMap, array $overrides) - { - $this->innerMap = $innerMap; - $this->overrides = $overrides; - } - - public function lookupMimeType(string $extension): ?string - { - return $this->overrides[$extension] ?? $this->innerMap->lookupMimeType($extension); - } -} diff --git a/vendor/liliuwei/thinkphp-social/.gitignore b/vendor/liliuwei/thinkphp-social/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/liliuwei/thinkphp-social/LICENSE b/vendor/liliuwei/thinkphp-social/LICENSE deleted file mode 100644 index 8dada3e..0000000 --- a/vendor/liliuwei/thinkphp-social/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/liliuwei/thinkphp-social/README.md b/vendor/liliuwei/thinkphp-social/README.md deleted file mode 100644 index 304f0bc..0000000 --- a/vendor/liliuwei/thinkphp-social/README.md +++ /dev/null @@ -1,99 +0,0 @@ -## thinkphp-social -适用于thinkphp5.1 thinkphp6.0的社会化登录扩展 - -目前已支持:QQ、微信、新浪、百度、Gitee、Github、Oschina、Google、Facebook、淘宝、抖音、小米、钉钉 - -欢迎提交pr或者建议! - -有问题可以联系邮箱:974829947@qq.com - -## 安装(扩展包) -```php -composer require liliuwei/thinkphp-social -``` - -# 配置Config信息 -```php -// 安装之后会在config目录里自动生成social.php配置文件 - [ - 'app_key' => '*******', //应用注册成功后分配的 APP ID - 'app_secret' => '*******', //应用注册成功后分配的KEY - 'callback' => 'http://www.youquanya.com/oauth/callback/type/qq', // 应用回调地址 - ], - //微信扫码登录配置 - 'weixin' => [ - 'app_key' => '*******', //应用注册成功后分配的 APP ID - 'app_secret' => '*******', //应用注册成功后分配的KEY - 'callback' => 'http://www.youquanya.com/oauth/callback/type/weixin', // 应用回调地址 - ], -]; - -``` - -## 用法示例 -```` -QQ登录 -新浪微博登录 -微信登录 -百度登录 -gitee登录 -github登录 -oschaina登录 -google登录 -facebook登录 -淘宝登录 -抖音登录 -小米登录 -钉钉登录 - ```` -```php -//设置路由 -Route::get('oauth/callback','index/oauth/callback'); -``` - -```php -error('参数错误'); - } - // 获取对象实例 - $sns = \liliuwei\social\Oauth::getInstance($type); - //跳转到授权页面 - $this->redirect($sns->getRequestCodeURL()); - } - - //授权回调地址 - public function callback($type = null, $code = null) - { - if ($type == null || $code == null) { - $this->error('参数错误'); - } - $sns = \liliuwei\social\Oauth::getInstance($type); - // 获取TOKEN - $token = $sns->getAccessToken($code); - //获取当前第三方登录用户信息 - if (is_array($token)) { - $user_info = \liliuwei\social\GetInfo::getInstance($type, $token); - dump($user_info);// 获取第三方用户资料 - $sns->openid();//统一使用$sns->openid()获取openid - //$sns->unionid();//QQ和微信、淘宝可以获取unionid - dump($sns->openid()); - echo '登录成功!!'; - echo '正在持续开发中,敬请期待!!'; - } else { - echo "获取第三方用户的基本信息失败"; - } - } -} -``` diff --git a/vendor/liliuwei/thinkphp-social/composer.json b/vendor/liliuwei/thinkphp-social/composer.json deleted file mode 100644 index b9673f3..0000000 --- a/vendor/liliuwei/thinkphp-social/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "liliuwei/thinkphp-social", - "description": "适用于thinkphp5.1和6.0的社会化登录扩展", - "keywords": ["第三方授权登录","QQ登录","微信登录","新浪登录","百度登录","谷歌登录","Google登录","Facebook登录","Gitee登录","Github登录","Oschina登录","淘宝登录","抖音登录","小米登录","钉钉登录","think-social","thinkphp-social","oauth", "thinkphp","thinkphp5.1","thinkphp6.0"], - "license": "Apache-2.0", - "type": "think-extend", - "require": { - "php": ">=5.6.0", - "topthink/think-installer": "^2.0", - "topthink/framework": "^5.1 || ^6.0" - }, - "authors": [ - { - "name": "liliuwei", - "email": "974829947@qq.com" - } - ], - "autoload" : { - "psr-4" : { - "liliuwei\\social\\" : "src/" - } - }, - "extra": { - "think-config": { - "social": "src/config/config.php" - }, - "think": { - "config": { - "social": "src/config/config.php" - } - } - } -} diff --git a/vendor/liliuwei/thinkphp-social/src/GetInfo.php b/vendor/liliuwei/thinkphp-social/src/GetInfo.php deleted file mode 100644 index 46823c1..0000000 --- a/vendor/liliuwei/thinkphp-social/src/GetInfo.php +++ /dev/null @@ -1,280 +0,0 @@ -call('user/get_user_info'); - if ($data['ret'] == 0) { - $userInfo['type'] = 'qq'; - $userInfo['name'] = $data['nickname']; - $userInfo['nickname'] = $data['nickname']; - $userInfo['avatar'] = $data['figureurl_2']; - $userInfo['gender'] = $data['gender']; - return $userInfo; - } else { - throw new \Exception("获取腾讯QQ用户信息失败:{$data['msg']}"); - } - } - - //微信用户信息 - public static function weixin($token) - { - $weixin = Oauth::getInstance('weixin', $token); - $data = $weixin->call('sns/userinfo'); - if (isset($data['errcode'])) { - throw new \Exception("获取微信用户信息失败:errcode:{$data['errcode']} errmsg: {$data['errmsg']}"); - } - if ($data['openid']) { - $userInfo['type'] = 'weixin'; - $userInfo['name'] = $data['nickname']; - $userInfo['nickname'] = $data['nickname']; - $userInfo['avatar'] = $data['headimgurl']; - $userInfo['openid'] = $data['openid']; - $userInfo['unionid'] = $data['unionid']; - $userInfo['province'] = $data['province']; - $userInfo['city'] = $data['city']; - $userInfo['country'] = $data['country']; - $userInfo['sex'] = $data['sex']==1?'男':'女'; - return $userInfo; - } else { - throw new \Exception("获取微信用户信息失败"); - } - } - - //新浪微博用户信息 - public static function sina($token) - { - $sina = Oauth::getInstance('sina', $token); - $data = $sina->call('users/show',"uid={$sina->openid()}"); - if ($data['id']) { - $userInfo['type'] = 'sina'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['screen_name']; - $userInfo['avatar'] = $data['avatar_large']; - $userInfo['openid'] = $data['id']; - $userInfo['idstr'] = $data['idstr']; - $userInfo['province'] = $data['province']; - $userInfo['city'] = $data['city']; - $userInfo['location'] = $data['location']; - $userInfo['created_at'] = $data['created_at']; - $userInfo['gender'] = $data['gender']=='m'?'男':($data['gender']=='f'?'女':'未知'); - $userInfo['followers_count'] = $data['followers_count']; - $userInfo['friends_count'] = $data['friends_count']; - $userInfo['statuses_count'] = $data['statuses_count']; - $userInfo['favourites_count'] = $data['favourites_count']; - $userInfo['description'] = $data['description']; - $userInfo['url'] = $data['url']; - $userInfo['profile_url'] = $data['profile_url']; - return $userInfo; - } else { - throw new \Exception("获取新浪微博用户信息失败:{$data['error']}"); - } - } - - //Baidu用户信息 - public static function baidu($token) - { - $baidu = Oauth::getInstance('baidu', $token); - $data = $baidu->call('passport/users/getInfo'); - if (isset($data['userid'])) { - $userInfo['type'] = 'baidu'; - $userInfo['name'] = $data['username']; - $userInfo['nickname'] = isset($data['realname'])?$data['realname']:''; - $userInfo['avatar'] = 'http://tb.himg.baidu.com/sys/portrait/item/'.$data['portrait']; - $userInfo['openid'] = $data['userid']; - $userInfo['sex'] = $data['sex']==1?'男':'女'; - return $userInfo; - } else { - throw new \Exception("获取Baidu用户信息失败"); - } - } - - //Gitee用户信息 - public static function gitee($token) - { - $google = Oauth::getInstance('gitee', $token); - $data = $google->call('user'); - if (isset($data['id'])) { - $userInfo['type'] = 'gitee'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['login']; - $userInfo['avatar'] = $data['avatar_url']; - $userInfo['openid'] = $data['id']; - $userInfo['html_url'] = $data['html_url']; - $userInfo['blog'] = $data['blog']; - $userInfo['email'] = $data['email']; - return $userInfo; - } else { - throw new \Exception("获取Gitee用户信息失败"); - } - } - - //Github用户信息 - public static function github($token) - { - $google = Oauth::getInstance('github', $token); - $data = $google->call('user'); - if (isset($data['id'])) { - $userInfo['type'] = 'github'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['login']; - $userInfo['avatar'] = $data['avatar_url']; - $userInfo['openid'] = $data['id']; - $userInfo['html_url'] = $data['html_url']; - $userInfo['blog'] = $data['blog']; - $userInfo['email'] = $data['email']; - return $userInfo; - } else { - throw new \Exception("获取Gitee用户信息失败"); - } - } - - //Google用户信息 - public static function google($token) - { - $google = Oauth::getInstance('google', $token); - $data = $google->call('userinfo'); - if (isset($data['id'])) { - $userInfo['type'] = 'google'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['name']; - $userInfo['avatar'] = $data['picture']; - $userInfo['openid'] = $data['id']; - $userInfo['given_name'] = $data['given_name']; - $userInfo['family_name'] = $data['family_name']; - $userInfo['locale'] = $data['locale']; - $userInfo['email'] = $data['email']; - return $userInfo; - } else { - throw new \Exception("获取Google用户信息失败"); - } - } - - //Facebook用户信息 - public static function facebook($token) - { - $facebook = Oauth::getInstance('facebook', $token); - $data = $facebook->call('me', 'fields=name,picture,first_name,last_name,short_name,email'); - if (isset($data['id'])) { - $userInfo['type'] = 'facebook'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['name']; - $userInfo['avatar'] = $data['picture']['data']['url']; - $userInfo['openid'] = $data['id']; - $userInfo['first_name'] = $data['first_name']; - $userInfo['last_name'] = $data['last_name']; - $userInfo['short_name'] = $data['short_name']; - $userInfo['email'] = $data['email']; - return $userInfo; - } else { - throw new \Exception("获取Facebook用户信息失败"); - } - } - - //Oschina用户信息 - public static function oschina($token) - { - $oschina = Oauth::getInstance('oschina', $token); - $data = $oschina->call('action/openapi/user'); - if (isset($data['id'])) { - $userInfo['type'] = 'gitee'; - $userInfo['name'] = $data['name']; - $userInfo['nickname'] = $data['name']; - $userInfo['avatar'] = $data['avatar']; - $userInfo['openid'] = $data['id']; - $userInfo['email'] = $data['email']; - $userInfo['location'] = $data['location']; - return $userInfo; - } else { - throw new \Exception("获取Gitee用户信息失败"); - } - } - - //Taobao用户信息 - public static function taobao($token) - { - $data = $token; - if (isset($data['taobao_user_id'])) { - $userInfo['type'] = 'taobao'; - $userInfo['name'] = urldecode($data['taobao_user_nick']); - $userInfo['nickname'] = urldecode($data['taobao_user_nick']); - $userInfo['avatar'] = ''; - $userInfo['openid'] = $data['taobao_user_id']; - $userInfo['taobao_open_uid'] = $data['taobao_open_uid']; - return $userInfo; - } else { - throw new \Exception("获取淘宝用户信息失败"); - } - } - - //Douyin用户信息 - public static function douyin($token) - { - $douyin = Oauth::getInstance('douyin', $token); - $data = $douyin->call('oauth/userinfo'); - $data = $data['data']; - if (isset($data['open_id'])) { - $userInfo['type'] = 'douyin'; - $userInfo['name'] = $data['nickname']; - $userInfo['nickname'] = $data['nickname']; - $userInfo['avatar'] = $data['avatar']; - $userInfo['openid'] = $data['open_id']; - $userInfo['unionid'] = $data['union_id']; - $userInfo['gender'] = $data['sex']==1?'男':'女'; - $userInfo['city'] = $data['city']; - $userInfo['province'] = $data['province']; - $userInfo['country'] = $data['country']; - return $userInfo; - } else { - throw new \Exception("获取抖音用户信息失败"); - } - } - - //Xiaomi用户信息 - public static function xiaomi($token) - { - $xiaomi = Oauth::getInstance('xiaomi', $token); - $data = $xiaomi->call('user/profile'); - $data = $data['data']; - if (isset($data['unionId'])) { - $userInfo['type'] = 'xiaomi'; - $userInfo['name'] = $data['miliaoNick']; - $userInfo['nickname'] = $data['miliaoNick']; - $userInfo['avatar'] = $data['miliaoIcon']; - $userInfo['openid'] = array_key_exists('userId',$data)?$data['userId']:$data['unionId']; - $userInfo['unionid'] = $data['unionId']; - return $userInfo; - } else { - throw new \Exception("获取小米用户信息失败"); - } - } - - //Dingtalk用户信息 - public static function dingtalk($token) - { - $data = $token; - if ($data['openid']) { - $userInfo['type'] = 'dingtalk'; - $userInfo['name'] = $data['nick']; - $userInfo['nickname'] = $data['nick']; - $userInfo['avatar'] = ''; - $userInfo['openid'] = $data['openid']; - $userInfo['unionid'] = $data['unionid']; - return $userInfo; - } else { - throw new \Exception("获取钉钉用户信息失败"); - } - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/Oauth.php b/vendor/liliuwei/thinkphp-social/src/Oauth.php deleted file mode 100644 index 7c251d1..0000000 --- a/vendor/liliuwei/thinkphp-social/src/Oauth.php +++ /dev/null @@ -1,267 +0,0 @@ -Type = strtolower($re_str); - - //获取应用配置 - $config = config("social.{$this->Type}"); - if (empty($config['app_key']) || empty($config['app_secret'])) { - throw new \Exception('请配置您申请的app_key和app_secret'); - } else { - $this->AppKey = $config['app_key']; - $this->AppSecret = $config['app_secret']; - $this->Token = $token; //设置获取到的TOKEN - } - } - - /** - * 取得Oauth实例 - * @static - * @return mixed 返回Oauth - */ - public static function getInstance($type, $token = null) - { - $sdk = [ - 'Qq', 'Weixin', 'Sina', 'Baidu', 'Gitee', 'Github', 'Google', 'Facebook', 'Taobao', 'Oschina', 'Douyin', 'Xiaomi', 'Dingtalk' - ]; - $name = ucfirst(strtolower($type)); - if (in_array($name, $sdk)) { - $class = '\\liliuwei\\social\\sdk\\' . $name; - return new $class($token); - } else { - header('content-type:text/html;charset=utf-8'); - throw new \Exception('暂时还不支持该' . $name . '的扩展'); - } - } - - /** - * 初始化配置 - */ - protected function config() - { - $config = config("social.{$this->Type}"); - if (!empty($config['authorize'])) - $this->Authorize = $config['authorize']; - if (!empty($config['callback'])) - $this->Callback = $config['callback']; - else - throw new \Exception('请配置回调页面地址'); - } - - /** - * 请求code - */ - public function getRequestCodeURL() - { - $this->config(); - //Oauth 标准参数 - $params = array( - 'client_id' => $this->AppKey, - 'redirect_uri' => $this->Callback, - 'response_type' => $this->ResponseType, - ); - - //获取额外参数 - if ($this->Authorize) { - parse_str($this->Authorize, $_param); - if (is_array($_param)) { - $params = array_merge($params, $_param); - } else { - throw new \Exception('AUTHORIZE配置不正确!'); - } - } - return $this->GetRequestCodeURL . '?' . http_build_query($params); - } - - /** - * 获取access_token - * @param string $code 上一步请求到的code - */ - public function getAccessToken($code, $extend = null) - { - $this->config(); - $params = array( - 'client_id' => $this->AppKey, - 'client_secret' => $this->AppSecret, - 'grant_type' => $this->GrantType, - 'code' => $code, - 'redirect_uri' => $this->Callback, - ); - - $data = $this->http($this->GetAccessTokenURL, $params, 'POST'); - $this->Token = $this->parseToken($data, $extend); - return $this->Token; - } - - /** - * 合并默认参数和额外参数 - * @param array $params 默认参数 - * @param array/string $param 额外参数 - * @return array: - */ - protected function param($params, $param) - { - if (is_string($param)) - parse_str($param, $param); - return array_merge($params, $param); - } - - /** - * 获取指定API请求的URL - * @param string $api API名称 - * @param string $fix api后缀 - * @return string 请求的完整URL - */ - protected function url($api = '', $fix = '') - { - return $this->ApiBase . $api . $fix; - } - - /** - * 发送HTTP请求方法,目前只支持CURL发送请求 - * @param string $url 请求URL - * @param array $params 请求参数 - * @param string $method 请求方法GET/POST - * @return array $data 响应数据 - */ - protected function http($url, $params, $method = 'GET', $header = array(), $multi = false) - { - $opts = array( - CURLOPT_TIMEOUT => 30, - CURLOPT_RETURNTRANSFER => 1, - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_HTTPHEADER => $header - ); - - /* 根据请求类型设置特定参数 */ - switch (strtoupper($method)) { - case 'GET': - $opts[CURLOPT_URL] = $url . '?' . http_build_query($params); - break; - case 'POST': - //判断是否传输文件 - $params = $multi ? $params : http_build_query($params); - $opts[CURLOPT_URL] = $url; - $opts[CURLOPT_POST] = 1; - $opts[CURLOPT_POSTFIELDS] = $params; - break; - default: - throw new \Exception('不支持的请求方式!'); - } - - /* 初始化并执行curl请求 */ - $ch = curl_init(); - curl_setopt_array($ch, $opts); - $data = curl_exec($ch); - $error = curl_error($ch); - curl_close($ch); - if ($error) throw new \Exception('请求发生错误:' . $error); - return $data; - } - - /** - * 抽象方法,在SNSSDK中实现 - * 组装接口调用参数 并调用接口 - */ - abstract protected function call($api, $param = '', $method = 'GET', $multi = false); - - /** - * 抽象方法,在SNSSDK中实现 - * 解析access_token方法请求后的返回值 - */ - abstract protected function parseToken($result, $extend); - - /** - * 抽象方法,在SNSSDK中实现 - * 获取当前授权用户的SNS标识 - */ - abstract public function openid(); -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/config/config.php b/vendor/liliuwei/thinkphp-social/src/config/config.php deleted file mode 100644 index 4f1cc58..0000000 --- a/vendor/liliuwei/thinkphp-social/src/config/config.php +++ /dev/null @@ -1,85 +0,0 @@ - [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //微信扫码登录配置 - 'weixin' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //新浪登录配置 - 'sina' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Baidu登录配置 - 'baidu' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Gitee登录配置 - 'gitee' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Github登录配置 - 'github' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Google登录配置 - 'google' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Facebook登录配置 - 'facebook' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Oschina登录配置 - 'oschina' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Taobao登录配置 - 'taobao' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Douyin登录配置 - 'douyin' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Xiaomi登录配置 - 'xiaomi' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ], - //Dingtalk登录配置 - 'dingtalk' => [ - 'app_key' => '', //应用注册成功后分配的 APP ID - 'app_secret' => '', //应用注册成功后分配的KEY - 'callback' => '', // 应用回调地址 - ] -]; diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php b/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php deleted file mode 100644 index 8e9e86a..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Baidu.php +++ /dev/null @@ -1,74 +0,0 @@ - $this->Token['access_token'], - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['expires_in'] && $data['refresh_token']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取百度ACCESS_TOKEN出错:{$data['error']}"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('passport/users/getInfo'); - if (isset($data['userid'])) - return $data['userid']; - else - throw new \Exception('没有获取到百度用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php b/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php deleted file mode 100644 index c2bda4b..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Dingtalk.php +++ /dev/null @@ -1,170 +0,0 @@ -getMicrotime(); - // 根据timestamp, appSecret计算签名值 - $s = hash_hmac('sha256', $time, $this->AppSecret, true); - $signature = base64_encode($s); - $urlencode_signature = urlencode($signature); - /* Dingtalk 调用公共参数 */ - $params = array( - 'tmp_auth_code'=>$param['code'], - ); - $data = $this->http($this->url($api.'?signature='.$urlencode_signature.'×tamp='.$time.'&accessKey='.$this->AppKey), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 发送HTTP请求方法,目前只支持CURL发送请求 - * @param string $url 请求URL - * @param array $params 请求参数 - * @param string $method 请求方法GET/POST - * @return array $data 响应数据 - */ - public function http($url, $params, $method = 'POST', $header = array(), $multi = false) - { - $data_string = json_encode($params); - $ch = curl_init($url); - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen($data_string)) - ); - - $result = curl_exec($ch); - return $result; - } - - /** - * 时间戳 - 精确到毫秒 - * @return float - */ - public function getMicrotime() - { - list($t1, $t2) = explode(' ', microtime()); - return (float)sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000); - } - - /** - * 请求code - */ - public function getRequestCodeURL() - { - $this->config(); - //Oauth 标准参数 - $params = array( - 'appid' => $this->AppKey, - 'redirect_uri' => $this->Callback, - 'response_type' => $this->ResponseType, - ); - - //获取额外参数 - if ($this->Authorize) { - parse_str($this->Authorize, $_param); - if (is_array($_param)) { - $params = array_merge($params, $_param); - } else { - throw new \Exception('AUTHORIZE配置不正确!'); - } - } - return $this->GetRequestCodeURL . '?' . http_build_query($params); - } - - /** - * 获取access_token - * @param string $code 上一步请求到的code - */ - public function getAccessToken($code, $extend = null) - { - $result = $this->call('sns/getuserinfo_bycode',['code'=>$code]); - $data = $result['user_info']; - $this->Token = [ - 'nick'=>$data['nick'], - 'openid'=>$data['openid'], - 'unionid'=>$data['unionid'], - ]; - return $this->Token; - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend){} - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid($unionid=false) - { - if ($unionid){ - return $this->unionid(); - } - $data = $this->Token; - if (isset($data['openid'])){ - return $data['openid']; - }else{ - throw new \Exception('没有获取到 Dingtalk 用户openid!'); - } - } - - /** - * 获取当前授权应用的unionid - */ - public function unionid() - { - $data = $this->Token; - if (isset($data['unionid'])){ - return $data['unionid']; - }else{ - throw new \Exception('没有获取到 Dingtalk 用户unionid!'); - } - } - -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php b/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php deleted file mode 100644 index 834f609..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Douyin.php +++ /dev/null @@ -1,141 +0,0 @@ -config(); - $params = array( - 'client_key ' => $this->AppKey, - 'redirect_uri' => $this->Callback, - 'response_type' => $this->ResponseType, - ); - - //获取额外参数 - if ($this->Authorize) { - parse_str($this->Authorize, $_param); - if (is_array($_param)) { - $params = array_merge($params, $_param); - } else { - throw new \Exception('AUTHORIZE配置不正确!'); - } - } - return $this->GetRequestCodeURL . '?' . http_build_query($params); - } - - /** - * 获取access_token - * @param string $code 上一步请求到的code - */ - public function getAccessToken($code, $extend = null) - { - $this->config(); - $params = array( - 'client_key' => $this->AppKey, - 'client_secret ' => $this->AppSecret, - 'grant_type' => $this->GrantType, - 'code' => $code, - ); - $data = $this->http($this->GetAccessTokenURL, $params, 'GET'); - $this->Token = $this->parseToken($data, $extend); - return $this->Token; - } - - /** - * 组装接口调用参数 并调用接口 - * @param string $api Douyin API - * @param string $param 调用API的额外参数 - * @param string $method HTTP请求方法 默认为GET - * @return json - */ - public function call($api, $param = '', $method = 'GET', $multi = false) - { - /* Douyin 调用公共参数 */ - $params = array( - 'access_token' => $this->Token['access_token'], - 'open_id' => $this->openid(), - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - $data = $data['data']; - if ($data['access_token'] && $data['expires_in']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取 抖音 ACCESS_TOKEN出错:未知错误"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid($unionid=false) - { - if ($unionid){ - return $this->unionid(); - } - $data = $this->call('oauth/userinfo'); - $data = $data['data']; - if (isset($data['open_id'])) - return $data['open_id']; - else - throw new \Exception('没有获取到 抖音 用户openid!'); - } - - /** - * 获取当前授权应用的unionid - */ - public function unionid() - { - $data = $this->call('oauth/userinfo'); - $data = $data['data']; - if (isset($data['union_id'])) - return $data['union_id']; - else - exit('没有获取到 抖音 用户unionid!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php b/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php deleted file mode 100644 index 58dd342..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Facebook.php +++ /dev/null @@ -1,83 +0,0 @@ - $this->Token['access_token']); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - * @param mix $extend - * @return array - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if (is_array($data) && $data['access_token'] && $data['expires_in']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else { - throw new \Exception("获取 facebook ACCESS_TOKEN出错:未知错误"); - } - - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('me'); - if (isset($data['id'])) - return $data['id']; - else - throw new \Exception('没有获取到 facebook 用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php b/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php deleted file mode 100644 index 5fcd481..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Gitee.php +++ /dev/null @@ -1,79 +0,0 @@ -Token['access_token']}"); - $data = $this->http($this->url($api), $this->param($params, $param), $method, $header); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['token_type']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取 Gitee ACCESS_TOKEN出错:未知错误"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('user'); - if (isset($data['id'])) - return $data['id']; - else - throw new \Exception('没有获取到 Gitee 用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Github.php b/vendor/liliuwei/thinkphp-social/src/sdk/Github.php deleted file mode 100644 index d821e05..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Github.php +++ /dev/null @@ -1,73 +0,0 @@ -Token['access_token']}","User-Agent:thinkphp-social"); - $data = $this->http($this->url($api), $this->param($params, $param), $method, $header); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - parse_str($result, $data); - if ($data['access_token'] && $data['token_type']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取 Github ACCESS_TOKEN出错:未知错误"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('user'); - if (isset($data['id'])) - return $data['id']; - else - throw new \Exception('没有获取到 Github 用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Google.php b/vendor/liliuwei/thinkphp-social/src/sdk/Google.php deleted file mode 100644 index 4502807..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Google.php +++ /dev/null @@ -1,80 +0,0 @@ - $this->Token['access_token'], - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['expires_in']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取Google ACCESS_TOKEN 出错:{$result}"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('userinfo'); - if (isset($data['id'])) - return $data['id']; - else - throw new \Exception('没有获取到 Google 用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php b/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php deleted file mode 100644 index feac8f1..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Oschina.php +++ /dev/null @@ -1,81 +0,0 @@ - $this->Token['access_token'], - 'dataType' => 'json' - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['token_type']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取 Oschina ACCESS_TOKEN出错:未知错误"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->call('action/openapi/user'); - if (isset($data['id'])) - return $data['id']; - else - throw new \Exception('没有获取到 Oschina 用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php b/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php deleted file mode 100644 index e81f00a..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Qq.php +++ /dev/null @@ -1,111 +0,0 @@ - $this->AppKey, - 'access_token' => $this->Token['access_token'], - 'openid' => $this->openid(), - 'format' => 'json' - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - parse_str($result, $data); - if ($data['access_token'] && $data['expires_in']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid($unionid=false) - { - if ($unionid){ - return $this->unionid(); - } - $data = $this->Token; - if ($data['access_token']) { - $data = $this->http($this->url('oauth2.0/me'), array('access_token' => $data['access_token'])); - $data = json_decode(trim(substr($data, 9), " );\n"), true); - if (isset($data['openid'])) - return $data['openid']; - else - throw new \Exception("获取用户openid出错:{$data['error_description']}"); - } else { - throw new \Exception('没有获取到openid!'); - } - } - - /** - * 获取当前授权应用的unionid - * @return string - */ - public function unionid() - { - $data = $this->Token; - if ($data['access_token']) { - $data = $this->http($this->url('oauth2.0/me'), array('access_token' => $data['access_token'],'unionid'=>1)); - $data = json_decode(trim(substr($data, 9), " );\n"), true); - if (isset($data['unionid'])) - return $data['unionid']; - else - throw new \Exception("获取用户unionid出错:{$data['error_description']}"); - } else { - throw new \Exception('没有获取到unionid!'); - } - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php b/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php deleted file mode 100644 index d9ea774..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Sina.php +++ /dev/null @@ -1,74 +0,0 @@ - $this->Token['access_token'], - ); - $data = $this->http($this->url($api, '.json'), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['expires_in'] && $data['remind_in'] && $data['uid']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid() - { - $data = $this->Token; - if (isset($data['uid'])) - return $data['uid']; - else - throw new \Exception('没有获取到新浪微博用户ID!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php b/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php deleted file mode 100644 index bb76551..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Taobao.php +++ /dev/null @@ -1,106 +0,0 @@ - $api, - 'access_token' => $this->Token['access_token'], - 'format' => 'json', - 'v' => '2.0', - ); - $paramsAll = $this->param($params, $param); - ksort($paramsAll); - $str = ''; - foreach ($paramsAll as $key => $value) { - $str .= $key . $value; - } - $sign = strtoupper(md5($this->AppSecret . $str . $this->AppSecret)); - $params_sign = array( - 'sign' => $sign, - ); - $data = $this->http($this->url(), array_merge($paramsAll, $params_sign), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['expires_in'] && $data['taobao_user_id']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else { - throw new \Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}"); - } - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid($unionid = false) - { - if ($unionid) { - return $this->unionid(); - } - $data = $this->Token; - if (isset($data['taobao_user_id'])) { - return $data['taobao_user_id']; - } else { - throw new \Exception('没有获取到淘宝网用户openid!'); - } - } - - /** - * 获取当前授权应用的unionid - * @return string - */ - public function unionid() - { - $data = $this->Token; - if (isset($data['taobao_open_uid'])) { - return $data['taobao_open_uid']; - } else { - throw new \Exception('没有获取到淘宝网用户unionid!'); - } - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php b/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php deleted file mode 100644 index 9582d2a..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Weixin.php +++ /dev/null @@ -1,137 +0,0 @@ -config(); - $params = array( - 'appid' => $this->AppKey, - 'redirect_uri' => $this->Callback, - 'response_type' => $this->ResponseType, - ); - - //获取额外参数 - if ($this->Authorize) { - parse_str($this->Authorize, $_param); - if (is_array($_param)) { - $params = array_merge($params, $_param); - } else { - throw new \Exception('AUTHORIZE配置不正确!'); - } - } - return $this->GetRequestCodeURL . '?' . http_build_query($params) . "#wechat_redirect"; - } - - /** - * 获取access_token - * @param string $code 上一步请求到的code - */ - public function getAccessToken($code, $extend = null) - { - $this->config(); - $params = array( - 'appid' => $this->AppKey, - 'secret' => $this->AppSecret, - 'grant_type' => $this->GrantType, - 'code' => $code, - ); - $data = $this->http($this->GetAccessTokenURL, $params, 'POST'); - $this->Token = $this->parseToken($data, $extend); - return $this->Token; - } - - /** - * 组装接口调用参数 并调用接口 - * @param string $api 微信 API - * @param string $param 调用API的额外参数 - * @param string $method HTTP请求方法 默认为GET - * @return json - */ - public function call($api, $param = '', $method = 'GET', $multi = false) - { - /* 微信调用公共参数 */ - $params = array( - 'access_token' => $this->Token['access_token'], - 'openid' => $this->openid(), - 'lang' => 'zh_CN', - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['expires_in']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取微信 ACCESS_TOKEN 出错:{$result}"); - } - - /** - * 获取当前授权应用的openid - */ - public function openid($unionid=false) - { - if ($unionid){ - return $this->unionid(); - } - $data = $this->Token; - if (isset($data['openid'])) - return $data['openid']; - else - exit('没有获取到微信用户openid!'); - } - - /** - * 获取当前授权应用的unionid - */ - public function unionid() - { - $data = $this->Token; - if (isset($data['unionid'])) - return $data['unionid']; - else - exit('没有获取到微信用户unionid!'); - } -} \ No newline at end of file diff --git a/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php b/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php deleted file mode 100644 index f38366e..0000000 --- a/vendor/liliuwei/thinkphp-social/src/sdk/Xiaomi.php +++ /dev/null @@ -1,104 +0,0 @@ - $this->Token['access_token'], - 'clientId' => $this->AppKey - ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); - return json_decode($data, true); - } - - /** - * 解析access_token方法请求后的返回值 - * @param string $result 获取access_token的方法的返回值 - */ - protected function parseToken($result, $extend) - { - $data = json_decode($result, true); - if ($data['access_token'] && $data['token_type']) { - $this->Token = $data; - $data['openid'] = $this->openid(); - return $data; - } else - throw new \Exception("获取 Xiaomi ACCESS_TOKEN出错:未知错误"); - } - - /** - * 获取当前授权应用的openid - * @return string - */ - public function openid($unionid=false) - { - if ($unionid){ - return $this->unionid(); - } - $data = $this->call('user/profile'); - if ($data['result']=='ok'){ - $data = $data['data']; - if (isset($data['userId'])){ - return $data['userId']; - }else{ - return $this->unionid(); - } - }else{ - throw new \Exception('没有获取到 Xiaomi 用户openid!'); - } - } - - /** - * 获取当前授权应用的unionid - * @return string - */ - public function unionid() - { - $data = $this->call('user/profile'); - $data = $data['data']; - if (isset($data['unionId'])) - return $data['unionId']; - else - throw new \Exception('没有获取到 Xiaomi 用户unionid!'); - } -} \ No newline at end of file diff --git a/vendor/lotofbadcode/phpspirit_databackup/.gitignore b/vendor/lotofbadcode/phpspirit_databackup/.gitignore deleted file mode 100644 index bfcd881..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/.idea -/.vscode -/vendor -*.log -.env -*.sql -*.rar -*.zip -*.7z -/demo/backup \ No newline at end of file diff --git a/vendor/lotofbadcode/phpspirit_databackup/README.md b/vendor/lotofbadcode/phpspirit_databackup/README.md deleted file mode 100644 index f70da54..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/README.md +++ /dev/null @@ -1 +0,0 @@ -# 一个php备份恢复数据库的扩展 相关文档:https://www.kancloud.cn/lotofbadcode/php_spirit/content diff --git a/vendor/lotofbadcode/phpspirit_databackup/composer.json b/vendor/lotofbadcode/phpspirit_databackup/composer.json deleted file mode 100644 index e4ee82d..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "lotofbadcode/phpspirit_databackup", - "description": "一个PHP数据库备份恢复的插件", - "license": "Apache-2.0", - "type": "library", - "keywords": [ - "php", - "library" - ], - "authors": [ - { - "name": "代码庸医", - "email": "3359964266@qq.com" - } - ], - "require": { - "php": ">=7.0" - }, - "autoload": { - "psr-4": { - "phpspirit\\databackup\\": "src/" - } - } -} \ No newline at end of file diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/.htaccess b/vendor/lotofbadcode/phpspirit_databackup/demo/.htaccess deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.gif b/vendor/lotofbadcode/phpspirit_databackup/demo/backup.gif deleted file mode 100644 index 8ac0914..0000000 Binary files a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.gif and /dev/null differ diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.html b/vendor/lotofbadcode/phpspirit_databackup/demo/backup.html deleted file mode 100644 index 01fad4c..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - - 数据备份 - - - - - - - - - -
-
- -
-
- - - diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.php b/vendor/lotofbadcode/phpspirit_databackup/demo/backup.php deleted file mode 100644 index dda5565..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/backup.php +++ /dev/null @@ -1,35 +0,0 @@ -setbackdir($backupdir) - ->settablelist(['md_menu', 'md_api_group']) - ->setstructuretable(['md_api_group']) - ->setvolsize(0.2); -do { - $result = $backup->backup(); - echo str_repeat(' ', 1000); //这里会把浏览器缓存装满 - ob_flush(); //把php缓存写入apahce缓存 - flush(); //把apahce缓存写入浏览器缓存 - if ($result['totalpercentage'] > 0) { - echo '完成' . $result['totalpercentage'] . '%
'; - } -} while ($result['totalpercentage'] < 100); diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/backupajax.php b/vendor/lotofbadcode/phpspirit_databackup/demo/backupajax.php deleted file mode 100644 index 0135d25..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/backupajax.php +++ /dev/null @@ -1,31 +0,0 @@ -setbackdir($backupdir) - ->setvolsize(0.2) - ->setonlystructure(false) //设置是否只备份目录结构 - //->settablelist(['md_menu', 'md_api_group','cmseasy_b_category']) //设置要备份的表, 默认全部表 - //->setstructuretable(['md_api_group']) //设置哪些表只备份结构不备份数据 - ->ajaxbackup($_POST); - -echo json_encode($result); diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/css/jquery.circliful.css b/vendor/lotofbadcode/phpspirit_databackup/demo/css/jquery.circliful.css deleted file mode 100644 index d4ea801..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/css/jquery.circliful.css +++ /dev/null @@ -1,20 +0,0 @@ -.circliful { - position: relative; -} - -.circle-text, .circle-info, .circle-text-half, .circle-info-half { - width: 100%; - position: absolute; - text-align: center; - display: inline-block; -} - -.circle-info, .circle-info-half { - color: #999; -} - -.circliful .fa { - margin: -10px 3px 0 3px; - position: relative; - bottom: 4px; -} diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.js b/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.js deleted file mode 100644 index 3b81a5f..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.js +++ /dev/null @@ -1,191 +0,0 @@ - (function( $ ) { - - $.fn.circliful = function(options) { - - var settings = $.extend({ - // These are the defaults. - foregroundColor: "#556b2f", - backgroundColor: "#eee", - fillColor: false, - width: 15, - dimension: 200, - size: 15, - percent: 50, - animationStep: 1.0 - }, options ); - return this.each(function() { - var dimension = ''; - var text = ''; - var info = ''; - var width = ''; - var size = 0; - var percent = 0; - var endPercent = 100; - var fgcolor = ''; - var bgcolor = ''; - var icon = ''; - var animationstep = 0.0; - - $(this).addClass('circliful'); - - if($(this).data('dimension') != undefined) { - dimension = $(this).data('dimension'); - } else { - dimension = settings.dimension; - } - - if($(this).data('width') != undefined) { - width = $(this).data('width'); - } else { - width = settings.width; - } - - if($(this).data('fontsize') != undefined) { - size = $(this).data('fontsize'); - } else { - size = settings.size; - } - - if($(this).data('percent') != undefined) { - percent = $(this).data('percent') / 100; - endPercent = $(this).data('percent'); - } else { - percent = settings.percent / 100; - } - - if($(this).data('fgcolor') != undefined) { - fgcolor = $(this).data('fgcolor'); - } else { - fgcolor = settings.foregroundColor; - } - - if($(this).data('bgcolor') != undefined) { - bgcolor = $(this).data('bgcolor'); - } else { - bgcolor = settings.backgroundColor; - } - - if($(this).data('animation-step') != undefined) { - animationstep = parseFloat($(this).data('animation-step')); - } else { - animationstep = settings.animationStep; - } - if($(this).data('text') != undefined) { - text = $(this).data('text'); - - if($(this).data('icon') != undefined) { - icon = ''; - } - - if($(this).data('type') != undefined) { - type = $(this).data('type'); - - if(type == 'half') { - $(this).append('' + icon + text + ''); - $(this).find('.circle-text-half').css({'line-height': (dimension / 1.45) + 'px', 'font-size' : size + 'px' }); - } else { - $(this).append('' + icon + text + ''); - $(this).find('.circle-text').css({'line-height': dimension + 'px', 'font-size' : size + 'px' }); - } - } else { - $(this).append('' + icon + text + ''); - $(this).find('.circle-text').css({'line-height': dimension + 'px', 'font-size' : size + 'px' }); - } - } else if($(this).data('icon') != undefined) { - - } - - if($(this).data('info') != undefined) { - info = $(this).data('info'); - - if($(this).data('type') != undefined) { - type = $(this).data('type'); - - if(type == 'half') { - $(this).append('' + info + ''); - $(this).find('.circle-info-half').css({'line-height': (dimension * 0.9) + 'px', }); - } else { - $(this).append('' + info + ''); - $(this).find('.circle-info').css({'line-height': (dimension * 1.25) + 'px', }); - } - } else { - $(this).append('' + info + ''); - $(this).find('.circle-info').css({'line-height': (dimension * 1.25) + 'px', }); - } - } - - $(this).width(dimension + 'px'); - - var canvas = $('').attr({ width: dimension, height: dimension }).appendTo($(this)).get(0); - var context = canvas.getContext('2d'); - var x = canvas.width / 2; - var y = canvas.height / 2; - var degrees = percent * 360.0; - var radians = degrees * (Math.PI / 180); - var radius = canvas.width / 2.5; - var startAngle = 2.3 * Math.PI; - var endAngle = 0; - var counterClockwise = false; - var curPerc = animationstep === 0.0 ? endPercent : 0.0; - var curStep = Math.max(animationstep, 0.0); - var circ = Math.PI * 2; - var quart = Math.PI / 2; - var type = ''; - var fill = false; - - if($(this).data('type') != undefined) { - type = $(this).data('type'); - - if(type == 'half') { - var startAngle = 2.0 * Math.PI; - var endAngle = 3.13; - var circ = Math.PI * 1.0; - var quart = Math.PI / 0.996; - } - } - - if($(this).data('fill') != undefined) { - fill = $(this).data('fill'); - } else { - fill = settings.fillColor; - } - //animate foreground circle - function animate(current) { - context.clearRect(0, 0, canvas.width, canvas.height); - - context.beginPath(); - context.arc(x, y, radius, endAngle, startAngle, false); - context.lineWidth = width - 1; - - // line color - context.strokeStyle = bgcolor; - context.stroke(); - - if(fill) { - context.fillStyle = fill; - context.fill(); - } - - context.beginPath(); - context.arc(x, y, radius, -(quart), ((circ) * current) - quart, false); - context.lineWidth = width; - // line color - context.strokeStyle = fgcolor; - context.stroke(); - - if (curPerc < endPercent) { - curPerc += curStep; - // requestAnimationFrame(function () { - animate(Math.min(curPerc, endPercent) / 100); - //}); - } - - } - - animate(curPerc / 100); - - }); - - }; - -}( jQuery )); \ No newline at end of file diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.min.js b/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.min.js deleted file mode 100644 index 2cadf09..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/js/jquery.circliful.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){a.fn.circliful=function(b){var c=a.extend({foregroundColor:"#556b2f",backgroundColor:"#eee",fillColor:false,width:15,dimension:200,size:15,percent:50,animationStep:1},b);return this.each(function(){var F="";var s="";var E="";var v="";var t=0;var e=0;var l=100;var B="";var d="";var D="";var q=0;a(this).addClass("circliful");if(a(this).data("dimension")!=undefined){F=a(this).data("dimension")}else{F=c.dimension}if(a(this).data("width")!=undefined){v=a(this).data("width")}else{v=c.width}if(a(this).data("fontsize")!=undefined){t=a(this).data("fontsize")}else{t=c.size}if(a(this).data("percent")!=undefined){e=a(this).data("percent")/100;l=a(this).data("percent")}else{e=c.percent/100}if(a(this).data("fgcolor")!=undefined){B=a(this).data("fgcolor")}else{B=c.foregroundColor}if(a(this).data("bgcolor")!=undefined){d=a(this).data("bgcolor")}else{d=c.backgroundColor}if(a(this).data("animation-step")!=undefined){q=parseFloat(a(this).data("animation-step"))}else{q=c.animationStep}if(a(this).data("text")!=undefined){s=a(this).data("text");if(a(this).data("icon")!=undefined){D=''}if(a(this).data("type")!=undefined){i=a(this).data("type");if(i=="half"){a(this).append(''+D+s+"");a(this).find(".circle-text-half").css({"line-height":(F/1.45)+"px","font-size":t+"px"})}else{a(this).append(''+D+s+"");a(this).find(".circle-text").css({"line-height":F+"px","font-size":t+"px"})}}else{a(this).append(''+D+s+"");a(this).find(".circle-text").css({"line-height":F+"px","font-size":t+"px"})}}else{if(a(this).data("icon")!=undefined){}}if(a(this).data("info")!=undefined){E=a(this).data("info");if(a(this).data("type")!=undefined){i=a(this).data("type");if(i=="half"){a(this).append(''+E+"");a(this).find(".circle-info-half").css({"line-height":(F*0.9)+"px",})}else{a(this).append(''+E+"");a(this).find(".circle-info").css({"line-height":(F*1.25)+"px",})}}else{a(this).append(''+E+"");a(this).find(".circle-info").css({"line-height":(F*1.25)+"px",})}}a(this).width(F+"px");var h=a("").attr({width:F,height:F}).appendTo(a(this)).get(0);var f=h.getContext("2d");var p=h.width/2;var o=h.height/2;var A=e*360;var G=A*(Math.PI/180);var j=h.width/2.5;var z=2.3*Math.PI;var u=0;var C=false;var m=q===0?l:0;var n=Math.max(q,0);var r=Math.PI*2;var g=Math.PI/2;var i="";var w=false;if(a(this).data("type")!=undefined){i=a(this).data("type");if(i=="half"){var z=2*Math.PI;var u=3.13;var r=Math.PI*1;var g=Math.PI/0.996}}if(a(this).data("fill")!=undefined){w=a(this).data("fill")}else{w=c.fillColor}function k(x){f.clearRect(0,0,h.width,h.height);f.beginPath();f.arc(p,o,j,u,z,false);f.lineWidth=v-1;f.strokeStyle=d;f.stroke();if(w){f.fillStyle=w;f.fill()}f.beginPath();f.arc(p,o,j,-(g),((r)*x)-g,false);f.lineWidth=v;f.strokeStyle=B;f.stroke();if(m - - 数据恢复 - - - - - - - - - -
-
- -
- -
-
-
- - - diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/recovery.php b/vendor/lotofbadcode/phpspirit_databackup/demo/recovery.php deleted file mode 100644 index 012ddc1..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/recovery.php +++ /dev/null @@ -1,25 +0,0 @@ -setSqlfiledir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'backup'.DIRECTORY_SEPARATOR.'20191205010418'); - - -do -{ - $result = $recovery->recovery(); - echo str_repeat(' ', 1000); //这里会把浏览器缓存装满 - ob_flush(); //把php缓存写入apahce缓存 - flush(); //把apahce缓存写入浏览器缓存 - if ($result['totalpercentage'] > 0) - { - echo '完成' . $result['totalpercentage'] . '%
'; - } -} while ($result['totalpercentage'] < 100); diff --git a/vendor/lotofbadcode/phpspirit_databackup/demo/recoveryajax.php b/vendor/lotofbadcode/phpspirit_databackup/demo/recoveryajax.php deleted file mode 100644 index f8eb1ab..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/demo/recoveryajax.php +++ /dev/null @@ -1,13 +0,0 @@ -setSqlfiledir(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'backup'.DIRECTORY_SEPARATOR.'20191205010418') - ->ajaxrecovery($_POST); - -echo json_encode($result); diff --git a/vendor/lotofbadcode/phpspirit_databackup/src/BackupFactory.php b/vendor/lotofbadcode/phpspirit_databackup/src/BackupFactory.php deleted file mode 100644 index 463f9aa..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/src/BackupFactory.php +++ /dev/null @@ -1,25 +0,0 @@ - "SET NAMES'" . $code . "';"]); - self::$instance[$args] = new Backup($pdo); - } - } - return self::$instance[$args]; - } -} diff --git a/vendor/lotofbadcode/phpspirit_databackup/src/IBackup.php b/vendor/lotofbadcode/phpspirit_databackup/src/IBackup.php deleted file mode 100644 index cec3d21..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/src/IBackup.php +++ /dev/null @@ -1,36 +0,0 @@ - "SET NAMES'" . $code . "';"]); - self::$instance[$args] = new Recovery($pdo); - } - } - return self::$instance[$args]; - } -} diff --git a/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Backup.php b/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Backup.php deleted file mode 100644 index e0b1b77..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Backup.php +++ /dev/null @@ -1,347 +0,0 @@ -_pdo = $pdo; - } - - public function setvolsize($size) - { - $this->_volsize = $size; - return $this; - } - - public function settablelist($tablelist = []) - { - $this->_tablelist = $tablelist; - return $this; - } - - public function gettablelist() - { - if (!$this->_tablelist) { - $rs = $this->_pdo->query('show table status'); - $res = $rs->fetchAll(PDO::FETCH_ASSOC); - foreach ($res as $r) { - $this->_tablelist[] = $r['Name']; - } - } - return $this->_tablelist; - } - - /** - * 设置备份目录 - */ - public function setbackdir($dir) - { - if ($this->_backdir) { - return $this; - } - $this->_backdir = $dir; - if (!is_dir($dir)) { - mkdir($dir, 0777); - } - return $this; - } - - public function getbackdir() - { - return $this->_backdir; - } - - /** - * 设置文件名 - * @param string $filename - * @return $this - */ - public function setfilename($filename) - { - - $this->_filename = $filename; - if (!is_file($this->_backdir . '/' . $this->_filename)) { - fopen($this->_backdir . '/' . $this->_filename, "x+"); - } - // return $this; - } - - /** - * 获取文件名 - * @return string - */ - public function getfilename() - { - if (!$this->_filename) { - $this->_filename = isset($this->_tablelist[$this->_nowtableidx]) ? $this->_tablelist[$this->_nowtableidx] . '#0.sql' : ''; - } - if (!is_file($this->_backdir . '/' . $this->_filename)) { - fopen($this->_backdir . '/' . $this->_filename, "x+"); - } - return $this->_filename; - } - - - - /** - * 设置是否仅备份结构 - */ - public function setonlystructure($bool) - { - $this->_onlystructure = $bool; - return $this; - } - - public function getonlystructure() - { - return $this->_onlystructure; - } - - - /** - * 设置仅备份表结构 不备份数据的表 - */ - public function setstructuretable($table = []) - { - $this->_structuretable = $table; - return $this; - } - - public function getstructuretable() - { - return $this->_structuretable; - } - /** - * 备份 - * - * 正在备份的表 - * 正在备份的表的索引 - * 正在备份的表已备份的记录数 - * 正在备份的表总记录数 - * 当前备份表百分比 - * 总百分比 - */ - public function backup() - { - $totalpercentage = 100; //默认总百分比 0% - $tablelist = $this->gettablelist(); //所有的表列表 - - $nowtable = ''; - - //上一次备份的表完成100% 将备份下一个表 - if ( - $this->_nowtablepercentage >= 100 && - isset($tablelist[$this->_nowtableidx + 1]) - ) { - $this->_nowtableidx = $this->_nowtableidx + 1; - $this->_nowtableexeccount = $this->_nowtabletotal = 0; - $this->setfilename($tablelist[$this->_nowtableidx] . '#0.sql'); - } - - //备份表开始 默认第一个 - if (isset($tablelist[$this->_nowtableidx])) { - - $nowtable = $tablelist[$this->_nowtableidx]; //当前正在备份的表 - - $sqlstr = ''; - if ($this->_nowtableexeccount == 0) { //将要执行表已备份的sql记录数 - //Drop 建表 - $sqlstr .= 'DROP TABLE IF EXISTS `' . $nowtable . '`;' . PHP_EOL; - $rs = $this->_pdo->query('SHOW CREATE TABLE `' . $nowtable . '`'); - $res = $rs->fetchAll(); - $sqlstr .= $res[0][1] . ';' . PHP_EOL; - file_put_contents($this->_backdir . DIRECTORY_SEPARATOR . $this->getfilename(), file_get_contents($this->_backdir . DIRECTORY_SEPARATOR . $this->getfilename()) . $sqlstr); - - if ($this->getonlystructure() === false && !in_array($nowtable, $this->getstructuretable())) { - $this->gettabletotal($nowtable); //当前备份表总条数 - } - } - - if ($this->_nowtableexeccount < $this->_nowtabletotal) { - - //建记录SQL语句 并设置已经备份的条数 - $this->_singleinsertrecord($nowtable, $this->_nowtableexeccount); - } - - - //计算单表百分比 - if ($this->_nowtabletotal != 0) { - $this->_nowtablepercentage = $this->_nowtableexeccount / $this->_nowtabletotal * 100; - } else { - $this->_nowtablepercentage = 100; - } - - if ($this->_nowtablepercentage == 100) { - $totalpercentage = ($this->_nowtableidx + 1) / count($tablelist) * 100; - } else { - $totalpercentage = ($this->_nowtableidx) / count($tablelist) * 100; - } - } - - return [ - 'nowtable' => $nowtable, //当前正在备份的表 - 'nowtableidx' => $this->_nowtableidx, //当前正在备份表的索引 - 'nowtableexeccount' => $this->_nowtableexeccount, //当前表已备份条数 - 'nowtabletotal' => $this->_nowtabletotal, //当前表总条数 - 'totalpercentage' => (int) $totalpercentage, //总百分比 - 'tablepercentage' => (int) $this->_nowtablepercentage, //当前表百分比 - 'backfilename' => $this->getfilename(), - ]; - } - - public function ajaxbackup($preresult = []) - { - - if ($this->getbackdir() == '' && !isset($preresult['backdir'])) { - throw new Exception('请先设置备份目录'); - } - - if (isset($preresult['backdir'])) { - $this->setbackdir($preresult['backdir']); - } - unset($preresult['backdir']); - if ($preresult) { - $this->_nowtableidx = $preresult['nowtableidx']; - $this->_nowtableexeccount = $preresult['nowtableexeccount']; - $this->_nowtabletotal = $preresult['nowtabletotal']; - $this->_nowtablepercentage = (int) $preresult['tablepercentage']; - $this->setfilename($preresult['backfilename']); - } - - $result = $this->backup(); - $result['backdir'] = $this->getbackdir(); - return $result; - } - - //获取表中总条数 - public function gettabletotal($table) - { - $value = $this->_pdo->query('select count(*) from ' . $table); - $counts = $value->fetchAll(PDO::FETCH_NUM); - return $this->_nowtabletotal = $counts[0][0]; - } - - private function _singleinsertrecord($tablename, $limit) - { - $sql = 'select * from `' . $tablename . '` limit ' . $limit . ',' . $this->_totallimit; - $valuers = $this->_pdo->query($sql); - $valueres = $valuers->fetchAll(PDO::FETCH_NUM); - $insertsqlv = ''; - $insertsql = 'insert into `' . $tablename . '` VALUES '; - foreach ($valueres as $v) { - $insertsqlv .= ' ( '; - - foreach ($v as $_v) { - $insertsqlv .= $this->_pdo->quote($_v) . ","; - } - $insertsqlv = rtrim($insertsqlv, ','); - $insertsqlv .= ' ),'; - } - $insertsql .= rtrim($insertsqlv, ',') . ' ;' . PHP_EOL; - $this->_checkfilesize(); - file_put_contents($this->_backdir . '/' . $this->getfilename(), file_get_contents($this->_backdir . '/' . $this->getfilename()) . $insertsql); - $this->_nowtableexeccount += $this->_totallimit; - $this->_nowtableexeccount = $this->_nowtableexeccount >= $this->_nowtabletotal ? $this->_nowtabletotal : $this->_nowtableexeccount; - } - - /** - * 检查文件大小 - */ - private function _checkfilesize() - { - clearstatcache(); - $b = filesize($this->_backdir . '/' . $this->getfilename()) < $this->_volsize * 1024 * 1024 ? true : false; - if ($b === false) { - $filearr = explode('#', $this->getfilename()); - if (count($filearr) == 2) { - $fileext = explode('.', $filearr[1]); //.sql - $filename = $filearr[0] . '#' . ($fileext[0] + 1) . '.sql'; - $this->setfilename($filename); - } - } - } -} diff --git a/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Recovery.php b/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Recovery.php deleted file mode 100644 index a54b9f1..0000000 --- a/vendor/lotofbadcode/phpspirit_databackup/src/mysql/Recovery.php +++ /dev/null @@ -1,126 +0,0 @@ -_pdo = $pdo; - } - - public function setSqlfiledir($dir) - { - $this->_sqlfiledir = $dir; - return $this; - } - - public function getfiles() - { - if (!$this->_sqlfilesarr) { - $dir = $this->_sqlfiledir; - $iterator = new \DirectoryIterator($dir); - $filesarr = []; - foreach ($iterator as $it) { - if (!$it->isDot()) { - $filenameinfo = explode('#', $it->getFilename()); - $fileext = explode('.', $filenameinfo[1]); - $filesarr[$filenameinfo[0]][$fileext[0]] = $it->getFilename(); - } - } - ksort($filesarr); - foreach ($filesarr as $k => $f) { - ksort($f); - $filesarr[$k] = $f; - } - foreach ($filesarr as $f) { - foreach ($f as $_f) { - $this->_sqlfilesarr[] = $_f; - } - } - } - return $this->_sqlfilesarr; - } - - public function recovery() - { - try { - $filesarr = $this->getfiles(); - $totalpercentage = 100; - $this->_nowfileidx = $this->_nextfileidx; - if (isset($filesarr[$this->_nowfileidx])) { - $this->_importsqlfile($this->_sqlfiledir . DIRECTORY_SEPARATOR . $filesarr[$this->_nowfileidx]); - $totalpercentage = $this->_nowfileidx / count($this->_sqlfilesarr) * 100; - $this->_nextfileidx = $this->_nowfileidx + 1; - } - return [ - 'nowfileidex' => $this->_nowfileidx, //当前正在恢复的文件 - 'nextfileidx' => $this->_nextfileidx, - 'totalpercentage' => (int) $totalpercentage, //总百分比 - ]; - } catch (Exception $ex) { - throw $ex; - } - } - - public function ajaxrecovery($preresult = []) - { - if($preresult) - { - $this->_nowfileidx = $preresult['nowfileidex']; - $this->_nextfileidx = $preresult['nextfileidx']; - } - $result = $this->recovery(); - return $result; - } - - private function _importsqlfile($sqlfile) - { - if (is_file($sqlfile)) { - try { - $content = file_get_contents($sqlfile); - $arr = explode(';' . PHP_EOL, $content); - foreach ($arr as $a) { - if (trim($a) != '') { - $this->_pdo->exec($a); - } - } - } catch (Exception $ex) { - return false; - } - } - return true; - } -} diff --git a/vendor/php-di/invoker/.github/CONTRIBUTING.md b/vendor/php-di/invoker/.github/CONTRIBUTING.md deleted file mode 100644 index 7ff968f..0000000 --- a/vendor/php-di/invoker/.github/CONTRIBUTING.md +++ /dev/null @@ -1,13 +0,0 @@ -# Contributing - -First of all, **thank you** for contributing! - -Here are a few rules to follow in order to ease code reviews and merging: - -- follow the coding standard of the project -- run the test suite -- write (or update) tests when applicable -- write documentation for new features -- use [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) - -When creating your pull request on GitHub, please write a description which gives the context and/or explains why you are creating it. diff --git a/vendor/php-di/invoker/.github/FUNDING.yml b/vendor/php-di/invoker/.github/FUNDING.yml deleted file mode 100644 index 12bc4cd..0000000 --- a/vendor/php-di/invoker/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: mnapoli # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/vendor/php-di/invoker/.github/pull_request_template.md b/vendor/php-di/invoker/.github/pull_request_template.md deleted file mode 100644 index 712d96f..0000000 --- a/vendor/php-di/invoker/.github/pull_request_template.md +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/vendor/php-di/invoker/.github/workflows/ci.yml b/vendor/php-di/invoker/.github/workflows/ci.yml deleted file mode 100644 index 33c8111..0000000 --- a/vendor/php-di/invoker/.github/workflows/ci.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: CI - -on: - push: - branches: ['master'] - pull_request: - branches: ['*'] - schedule: - - cron: '0 0 * * *' - -jobs: - - tests: - name: Tests - PHP ${{ matrix.php }} ${{ matrix.dependency-version }} - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - matrix: - php: [ '7.3', '7.4', '8.0' ] - dependency-version: [ '' ] - include: - - php: '7.3' - dependency-version: '--prefer-lowest' - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - coverage: none - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }} - restore-keys: php-${{ matrix.php }}-composer-locked- - - name: Install PHP dependencies - run: composer update ${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress --no-suggest - - name: PHPUnit - run: vendor/bin/phpunit - - cs: - name: Coding standards - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - tools: composer:v2, cs2pr - coverage: none - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: php-composer-locked-${{ hashFiles('composer.lock') }} - restore-keys: php-composer-locked- - - name: Install PHP dependencies - run: composer install --no-interaction --no-progress --no-suggest - - name: PHP CodeSniffer - run: vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr diff --git a/vendor/php-di/invoker/.phpcs.xml.dist b/vendor/php-di/invoker/.phpcs.xml.dist deleted file mode 100644 index 9e33c11..0000000 --- a/vendor/php-di/invoker/.phpcs.xml.dist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - src - - - - - src/ParameterResolver/ParameterResolver.php - - - - 0 - - - 0 - - - diff --git a/vendor/php-di/invoker/CONTRIBUTING.md b/vendor/php-di/invoker/CONTRIBUTING.md deleted file mode 100644 index 852fd1a..0000000 --- a/vendor/php-di/invoker/CONTRIBUTING.md +++ /dev/null @@ -1,15 +0,0 @@ -# Contributing - -First of all, **thank you** for contributing! - -Here are a few rules to follow in order to ease code reviews and merging: - -- follow [PSR-1](http://www.php-fig.org/psr/1/) and [PSR-2](http://www.php-fig.org/psr/2/) -- run the test suite -- write (or update) unit tests when applicable -- write documentation for new features -- use [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) - -One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) too. This is used to "clean" your pull request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.). - -When creating your pull request on GitHub, please write a description which gives the context and/or explains why you are creating it. diff --git a/vendor/php-di/invoker/LICENSE b/vendor/php-di/invoker/LICENSE deleted file mode 100644 index b2b0416..0000000 --- a/vendor/php-di/invoker/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Matthieu Napoli - -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. diff --git a/vendor/php-di/invoker/README.md b/vendor/php-di/invoker/README.md deleted file mode 100644 index 34bc22e..0000000 --- a/vendor/php-di/invoker/README.md +++ /dev/null @@ -1,233 +0,0 @@ -# Invoker - -Generic and extensible callable invoker. - -[![Build Status](https://img.shields.io/travis/PHP-DI/Invoker.svg?style=flat-square)](https://travis-ci.org/PHP-DI/Invoker) -[![Latest Version](https://img.shields.io/github/release/PHP-DI/invoker.svg?style=flat-square)](https://packagist.org/packages/PHP-DI/invoker) -[![Total Downloads](https://img.shields.io/packagist/dt/php-di/invoker.svg?style=flat-square)](https://packagist.org/packages/php-di/invoker) - -## Why? - -Who doesn't need an over-engineered `call_user_func()`? - -### Named parameters - -Does this [Silex](http://silex.sensiolabs.org) example look familiar: - -```php -$app->get('/project/{project}/issue/{issue}', function ($project, $issue) { - // ... -}); -``` - -Or this command defined with [Silly](https://github.com/mnapoli/silly#usage): - -```php -$app->command('greet [name] [--yell]', function ($name, $yell) { - // ... -}); -``` - -Same pattern in [Slim](http://www.slimframework.com): - -```php -$app->get('/hello/:name', function ($name) { - // ... -}); -``` - -You get the point. These frameworks invoke the controller/command/handler using something akin to named parameters: whatever the order of the parameters, they are matched by their name. - -**This library allows to invoke callables with named parameters in a generic and extensible way.** - -### Dependency injection - -Anyone familiar with AngularJS is familiar with how dependency injection is performed: - -```js -angular.controller('MyController', ['dep1', 'dep2', function(dep1, dep2) { - // ... -}]); -``` - -In PHP we find this pattern again in some frameworks and DI containers with partial to full support. For example in Silex you can type-hint the application to get it injected, but it only works with `Silex\Application`: - -```php -$app->get('/hello/{name}', function (Silex\Application $app, $name) { - // ... -}); -``` - -In Silly, it only works with `OutputInterface` to inject the application output: - -```php -$app->command('greet [name]', function ($name, OutputInterface $output) { - // ... -}); -``` - -[PHP-DI](http://php-di.org/doc/container.html) provides a way to invoke a callable and resolve all dependencies from the container using type-hints: - -```php -$container->call(function (Logger $logger, EntityManager $em) { - // ... -}); -``` - -**This library provides clear extension points to let frameworks implement any kind of dependency injection support they want.** - -### TL/DR - -In short, this library is meant to be a base building block for calling a function with named parameters and/or dependency injection. - -## Installation - -```sh -$ composer require PHP-DI/invoker -``` - -## Usage - -### Default behavior - -By default the `Invoker` can call using named parameters: - -```php -$invoker = new Invoker\Invoker; - -$invoker->call(function () { - echo 'Hello world!'; -}); - -// Simple parameter array -$invoker->call(function ($name) { - echo 'Hello ' . $name; -}, ['John']); - -// Named parameters -$invoker->call(function ($name) { - echo 'Hello ' . $name; -}, [ - 'name' => 'John' -]); - -// Use the default value -$invoker->call(function ($name = 'world') { - echo 'Hello ' . $name; -}); - -// Invoke any PHP callable -$invoker->call(['MyClass', 'myStaticMethod']); - -// Using Class::method syntax -$invoker->call('MyClass::myStaticMethod'); -``` - -Dependency injection in parameters is supported but needs to be configured with your container. Read on or jump to [*Built-in support for dependency injection*](#built-in-support-for-dependency-injection) if you are impatient. - -Additionally, callables can also be resolved from your container. Read on or jump to [*Resolving callables from a container*](#resolving-callables-from-a-container) if you are impatient. - -### Parameter resolvers - -Extending the behavior of the `Invoker` is easy and is done by implementing a [`ParameterResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ParameterResolver.php). - -This is explained in details the [Parameter resolvers documentation](doc/parameter-resolvers.md). - -#### Built-in support for dependency injection - -Rather than have you re-implement support for dependency injection with different containers every time, this package ships with 2 optional resolvers: - -- [`TypeHintContainerResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/Container/TypeHintContainerResolver.php) - - This resolver will inject container entries by searching for the class name using the type-hint: - - ```php - $invoker->call(function (Psr\Logger\LoggerInterface $logger) { - // ... - }); - ``` - - In this example it will `->get('Psr\Logger\LoggerInterface')` from the container and inject it. - - This resolver is only useful if you store objects in your container using the class (or interface) name. Silex or Symfony for example store services under a custom name (e.g. `twig`, `db`, etc.) instead of the class name: in that case use the resolver shown below. - -- [`ParameterNameContainerResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/Container/ParameterNameContainerResolver.php) - - This resolver will inject container entries by searching for the name of the parameter: - - ```php - $invoker->call(function ($twig) { - // ... - }); - ``` - - In this example it will `->get('twig')` from the container and inject it. - -These resolvers can work with any dependency injection container compliant with [PSR-11](http://www.php-fig.org/psr/psr-11/). - -Setting up those resolvers is simple: - -```php -// $container must be an instance of Psr\Container\ContainerInterface -$container = ... - -$containerResolver = new TypeHintContainerResolver($container); -// or -$containerResolver = new ParameterNameContainerResolver($container); - -$invoker = new Invoker\Invoker; -// Register it before all the other parameter resolvers -$invoker->getParameterResolver()->prependResolver($containerResolver); -``` - -You can also register both resolvers at the same time if you wish by prepending both. Implementing support for more tricky things is easy and up to you! - -### Resolving callables from a container - -The `Invoker` can be wired to your DI container to resolve the callables. - -For example with an invokable class: - -```php -class MyHandler -{ - public function __invoke() - { - // ... - } -} - -// By default this doesn't work: an instance of the class should be provided -$invoker->call('MyHandler'); - -// If we set up the container to use -$invoker = new Invoker\Invoker(null, $container); -// Now 'MyHandler' is resolved using the container! -$invoker->call('MyHandler'); -``` - -The same works for a class method: - -```php -class WelcomeController -{ - public function home() - { - // ... - } -} - -// By default this doesn't work: home() is not a static method -$invoker->call(['WelcomeController', 'home']); - -// If we set up the container to use -$invoker = new Invoker\Invoker(null, $container); -// Now 'WelcomeController' is resolved using the container! -$invoker->call(['WelcomeController', 'home']); -// Alternatively we can use the Class::method syntax -$invoker->call('WelcomeController::home'); -``` - -That feature can be used as the base building block for a framework's dispatcher. - -Again, any [PSR-11](http://www.php-fig.org/psr/psr-11/) compliant container can be provided. diff --git a/vendor/php-di/invoker/composer.json b/vendor/php-di/invoker/composer.json deleted file mode 100644 index e78e406..0000000 --- a/vendor/php-di/invoker/composer.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "php-di/invoker", - "description": "Generic and extensible callable invoker", - "keywords": ["invoker", "dependency-injection", "dependency", "injection", "callable", "invoke"], - "homepage": "https://github.com/PHP-DI/Invoker", - "license": "MIT", - "type": "library", - "autoload": { - "psr-4": { - "Invoker\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Invoker\\Test\\": "tests/" - } - }, - "require": { - "php": ">=7.3", - "psr/container": "^1.0|^2.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.0", - "athletic/athletic": "~0.1.8", - "mnapoli/hard-mode": "~0.3.0" - } -} diff --git a/vendor/php-di/invoker/doc/parameter-resolvers.md b/vendor/php-di/invoker/doc/parameter-resolvers.md deleted file mode 100644 index bfccb7f..0000000 --- a/vendor/php-di/invoker/doc/parameter-resolvers.md +++ /dev/null @@ -1,109 +0,0 @@ -# Parameter resolvers - -Extending the behavior of the `Invoker` is easy and is done by implementing a [`ParameterResolver`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ParameterResolver.php): - -```php -interface ParameterResolver -{ - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ); -} -``` - -- `$providedParameters` contains the parameters provided by the user when calling `$invoker->call($callable, $parameters)` -- `$resolvedParameters` contains parameters that have already been resolved by other parameter resolvers - -An `Invoker` can chain multiple parameter resolvers to mix behaviors, e.g. you can mix "named parameters" support with "dependency injection" support. This is why a `ParameterResolver` should skip parameters that are already resolved in `$resolvedParameters`. - -Here is an implementation example for dumb dependency injection that creates a new instance of the classes type-hinted: - -```php -class MyParameterResolver implements ParameterResolver -{ - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ) { - foreach ($reflection->getParameters() as $index => $parameter) { - if (array_key_exists($index, $resolvedParameters)) { - // Skip already resolved parameters - continue; - } - - $class = $parameter->getClass(); - - if ($class) { - $resolvedParameters[$index] = $class->newInstance(); - } - } - - return $resolvedParameters; - } -} -``` - -To use it: - -```php -$invoker = new Invoker\Invoker(new MyParameterResolver); - -$invoker->call(function (ArticleManager $articleManager) { - $articleManager->publishArticle('Hello world', 'This is the article content.'); -}); -``` - -A new instance of `ArticleManager` will be created by our parameter resolver. - -## Chaining parameter resolvers - -The fun starts to happen when we want to add support for many things: - -- named parameters -- dependency injection for type-hinted parameters -- ... - -This is where we should use the [`ResolverChain`](https://github.com/PHP-DI/Invoker/blob/master/src/ParameterResolver/ResolverChain.php). This resolver implements the [Chain of responsibility](http://en.wikipedia.org/wiki/Chain-of-responsibility_pattern) design pattern. - -For example the default chain is: - -```php -$parameterResolver = new ResolverChain([ - new NumericArrayResolver, - new AssociativeArrayResolver, - new DefaultValueResolver, -]); -``` - -It allows to support even the weirdest use cases like: - -```php -$parameters = []; - -// First parameter will receive "Welcome" -$parameters[] = 'Welcome'; - -// Parameter named "content" will receive "Hello world!" -$parameters['content'] = 'Hello world!'; - -// $published is not defined so it will use its default value -$invoker->call(function ($title, $content, $published = true) { - // ... -}, $parameters); -``` - -We can put our custom parameter resolver in the list and created a super-duper invoker that also supports basic dependency injection: - -```php -$parameterResolver = new ResolverChain([ - new MyParameterResolver, // Our resolver is at the top for highest priority - new NumericArrayResolver, - new AssociativeArrayResolver, - new DefaultValueResolver, -]); - -$invoker = new Invoker\Invoker($parameterResolver); -``` diff --git a/vendor/php-di/invoker/src/CallableResolver.php b/vendor/php-di/invoker/src/CallableResolver.php deleted file mode 100644 index e3b11b2..0000000 --- a/vendor/php-di/invoker/src/CallableResolver.php +++ /dev/null @@ -1,124 +0,0 @@ -container = $container; - } - - /** - * Resolve the given callable into a real PHP callable. - * - * @param callable|string|array $callable - * @return callable Real PHP callable. - * @throws NotCallableException|ReflectionException - */ - public function resolve($callable): callable - { - if (is_string($callable) && strpos($callable, '::') !== false) { - $callable = explode('::', $callable, 2); - } - - $callable = $this->resolveFromContainer($callable); - - if (! is_callable($callable)) { - throw NotCallableException::fromInvalidCallable($callable, true); - } - - return $callable; - } - - /** - * @param callable|string|array $callable - * @return callable|mixed - * @throws NotCallableException|ReflectionException - */ - private function resolveFromContainer($callable) - { - // Shortcut for a very common use case - if ($callable instanceof Closure) { - return $callable; - } - - // If it's already a callable there is nothing to do - if (is_callable($callable)) { - // TODO with PHP 8 that should not be necessary to check this anymore - if (! $this->isStaticCallToNonStaticMethod($callable)) { - return $callable; - } - } - - // The callable is a container entry name - if (is_string($callable)) { - try { - return $this->container->get($callable); - } catch (NotFoundExceptionInterface $e) { - if ($this->container->has($callable)) { - throw $e; - } - throw NotCallableException::fromInvalidCallable($callable, true); - } - } - - // The callable is an array whose first item is a container entry name - // e.g. ['some-container-entry', 'methodToCall'] - if (is_array($callable) && is_string($callable[0])) { - try { - // Replace the container entry name by the actual object - $callable[0] = $this->container->get($callable[0]); - return $callable; - } catch (NotFoundExceptionInterface $e) { - if ($this->container->has($callable[0])) { - throw $e; - } - throw new NotCallableException(sprintf( - 'Cannot call %s() on %s because it is not a class nor a valid container entry', - $callable[1], - $callable[0] - )); - } - } - - // Unrecognized stuff, we let it fail later - return $callable; - } - - /** - * Check if the callable represents a static call to a non-static method. - * - * @param mixed $callable - * @throws ReflectionException - */ - private function isStaticCallToNonStaticMethod($callable): bool - { - if (is_array($callable) && is_string($callable[0])) { - [$class, $method] = $callable; - - if (! method_exists($class, $method)) { - return false; - } - - $reflection = new ReflectionMethod($class, $method); - - return ! $reflection->isStatic(); - } - - return false; - } -} diff --git a/vendor/php-di/invoker/src/Exception/InvocationException.php b/vendor/php-di/invoker/src/Exception/InvocationException.php deleted file mode 100644 index 90f6585..0000000 --- a/vendor/php-di/invoker/src/Exception/InvocationException.php +++ /dev/null @@ -1,10 +0,0 @@ -parameterResolver = $parameterResolver ?: $this->createParameterResolver(); - $this->container = $container; - - if ($container) { - $this->callableResolver = new CallableResolver($container); - } - } - - /** - * {@inheritdoc} - */ - public function call($callable, array $parameters = []) - { - if ($this->callableResolver) { - $callable = $this->callableResolver->resolve($callable); - } - - if (! is_callable($callable)) { - throw new NotCallableException(sprintf( - '%s is not a callable', - is_object($callable) ? 'Instance of ' . get_class($callable) : var_export($callable, true) - )); - } - - $callableReflection = CallableReflection::create($callable); - - $args = $this->parameterResolver->getParameters($callableReflection, $parameters, []); - - // Sort by array key because call_user_func_array ignores numeric keys - ksort($args); - - // Check all parameters are resolved - $diff = array_diff_key($callableReflection->getParameters(), $args); - $parameter = reset($diff); - if ($parameter && \assert($parameter instanceof ReflectionParameter) && ! $parameter->isVariadic()) { - throw new NotEnoughParametersException(sprintf( - 'Unable to invoke the callable because no value was given for parameter %d ($%s)', - $parameter->getPosition() + 1, - $parameter->name - )); - } - - return call_user_func_array($callable, $args); - } - - /** - * Create the default parameter resolver. - */ - private function createParameterResolver(): ParameterResolver - { - return new ResolverChain([ - new NumericArrayResolver, - new AssociativeArrayResolver, - new DefaultValueResolver, - ]); - } - - /** - * @return ParameterResolver By default it's a ResolverChain - */ - public function getParameterResolver(): ParameterResolver - { - return $this->parameterResolver; - } - - public function getContainer(): ?ContainerInterface - { - return $this->container; - } - - /** - * @return CallableResolver|null Returns null if no container was given in the constructor. - */ - public function getCallableResolver(): ?CallableResolver - { - return $this->callableResolver; - } -} diff --git a/vendor/php-di/invoker/src/InvokerInterface.php b/vendor/php-di/invoker/src/InvokerInterface.php deleted file mode 100644 index 06f0064..0000000 --- a/vendor/php-di/invoker/src/InvokerInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -call($callable, ['foo' => 'bar'])` will inject the string `'bar'` - * in the parameter named `$foo`. - * - * Parameters that are not indexed by a string are ignored. - */ -class AssociativeArrayResolver implements ParameterResolver -{ - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ): array { - $parameters = $reflection->getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - if (array_key_exists($parameter->name, $providedParameters)) { - $resolvedParameters[$index] = $providedParameters[$parameter->name]; - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/Container/ParameterNameContainerResolver.php b/vendor/php-di/invoker/src/ParameterResolver/Container/ParameterNameContainerResolver.php deleted file mode 100644 index 126e14c..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/Container/ParameterNameContainerResolver.php +++ /dev/null @@ -1,47 +0,0 @@ -container = $container; - } - - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ): array { - $parameters = $reflection->getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - $name = $parameter->name; - - if ($name && $this->container->has($name)) { - $resolvedParameters[$index] = $this->container->get($name); - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/Container/TypeHintContainerResolver.php b/vendor/php-di/invoker/src/ParameterResolver/Container/TypeHintContainerResolver.php deleted file mode 100644 index 014956e..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/Container/TypeHintContainerResolver.php +++ /dev/null @@ -1,65 +0,0 @@ -container = $container; - } - - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ): array { - $parameters = $reflection->getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - $parameterType = $parameter->getType(); - if (! $parameterType) { - // No type - continue; - } - if (! $parameterType instanceof ReflectionNamedType) { - // Union types are not supported - continue; - } - if ($parameterType->isBuiltin()) { - // Primitive types are not supported - continue; - } - - $parameterClass = $parameterType->getName(); - if ($parameterClass === 'self') { - $parameterClass = $parameter->getDeclaringClass()->getName(); - } - - if ($this->container->has($parameterClass)) { - $resolvedParameters[$index] = $this->container->get($parameterClass); - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/DefaultValueResolver.php b/vendor/php-di/invoker/src/ParameterResolver/DefaultValueResolver.php deleted file mode 100644 index 3fdf7b7..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/DefaultValueResolver.php +++ /dev/null @@ -1,43 +0,0 @@ -getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - \assert($parameter instanceof \ReflectionParameter); - if ($parameter->isDefaultValueAvailable()) { - try { - $resolvedParameters[$index] = $parameter->getDefaultValue(); - } catch (ReflectionException $e) { - // Can't get default values from PHP internal classes and functions - } - } else { - $parameterType = $parameter->getType(); - if ($parameterType && $parameterType->allowsNull()) { - $resolvedParameters[$index] = null; - } - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/NumericArrayResolver.php b/vendor/php-di/invoker/src/ParameterResolver/NumericArrayResolver.php deleted file mode 100644 index 07d8ece..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/NumericArrayResolver.php +++ /dev/null @@ -1,37 +0,0 @@ -call($callable, ['foo', 'bar'])` will simply resolve the parameters - * to `['foo', 'bar']`. - * - * Parameters that are not indexed by a number (i.e. parameter position) - * will be ignored. - */ -class NumericArrayResolver implements ParameterResolver -{ - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ): array { - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $providedParameters = array_diff_key($providedParameters, $resolvedParameters); - } - - foreach ($providedParameters as $key => $value) { - if (is_int($key)) { - $resolvedParameters[$key] = $value; - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/ParameterResolver.php b/vendor/php-di/invoker/src/ParameterResolver/ParameterResolver.php deleted file mode 100644 index 85046c3..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/ParameterResolver.php +++ /dev/null @@ -1,30 +0,0 @@ -resolvers = $resolvers; - } - - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ): array { - $reflectionParameters = $reflection->getParameters(); - - foreach ($this->resolvers as $resolver) { - $resolvedParameters = $resolver->getParameters( - $reflection, - $providedParameters, - $resolvedParameters - ); - - $diff = array_diff_key($reflectionParameters, $resolvedParameters); - if (empty($diff)) { - // Stop traversing: all parameters are resolved - return $resolvedParameters; - } - } - - return $resolvedParameters; - } - - /** - * Push a parameter resolver after the ones already registered. - */ - public function appendResolver(ParameterResolver $resolver): void - { - $this->resolvers[] = $resolver; - } - - /** - * Insert a parameter resolver before the ones already registered. - */ - public function prependResolver(ParameterResolver $resolver): void - { - array_unshift($this->resolvers, $resolver); - } -} diff --git a/vendor/php-di/invoker/src/ParameterResolver/TypeHintResolver.php b/vendor/php-di/invoker/src/ParameterResolver/TypeHintResolver.php deleted file mode 100644 index 3ccc2e0..0000000 --- a/vendor/php-di/invoker/src/ParameterResolver/TypeHintResolver.php +++ /dev/null @@ -1,54 +0,0 @@ -getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - $parameterType = $parameter->getType(); - if (! $parameterType) { - // No type - continue; - } - if (! $parameterType instanceof ReflectionNamedType) { - // Union types are not supported - continue; - } - if ($parameterType->isBuiltin()) { - // Primitive types are not supported - continue; - } - - $parameterClass = $parameterType->getName(); - if ($parameterClass === 'self') { - $parameterClass = $parameter->getDeclaringClass()->getName(); - } - - if (array_key_exists($parameterClass, $providedParameters)) { - $resolvedParameters[$index] = $providedParameters[$parameterClass]; - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/invoker/src/Reflection/CallableReflection.php b/vendor/php-di/invoker/src/Reflection/CallableReflection.php deleted file mode 100644 index 3f19f33..0000000 --- a/vendor/php-di/invoker/src/Reflection/CallableReflection.php +++ /dev/null @@ -1,56 +0,0 @@ - DI\factory(function ($host) {...}) - ->parameter('host', DI\get('db.host')), - ]; - ``` - Read the [factories documentation](https://php-di.org/doc/php-definitions.html#factories) to learn more. Feature implemented by [@predakanga](https://github.com/predakanga). - -Improvements: - -- [#429](https://github.com/PHP-DI/PHP-DI/pull/429): performance improvements in definition resolution (by [@mnapoli](https://github.com/mnapoli)) -- [#421](https://github.com/PHP-DI/PHP-DI/issues/421): once a `ContainerBuilder` has built a container, it is locked to prevent confusion when adding new definitions to it (by [@mnapoli](https://github.com/mnapoli)) -- [#423](https://github.com/PHP-DI/PHP-DI/pull/423): improved exception messages (by [@mnapoli](https://github.com/mnapoli)) - -## 5.3 - -Read the [news entry](news/19-php-di-5-3-released.md). - -- release of the [2.0 version](https://github.com/PHP-DI/Symfony-Bridge/releases/tag/2.0.0) of the Symfony bridge (by [@mnapoli](https://github.com/mnapoli)) -- PHP 5.5 or above is now required -- a lot of documentation improvements by 9 different contributors -- [#389](https://github.com/PHP-DI/PHP-DI/pull/389): exception message improvement by [@mopahle](https://github.com/mopahle) -- [#359](https://github.com/PHP-DI/PHP-DI/issues/359), [#411](https://github.com/PHP-DI/PHP-DI/issues/411), [#414](https://github.com/PHP-DI/PHP-DI/pull/414), [#412](https://github.com/PHP-DI/PHP-DI/pull/412): compatibility with ProxyManager 1.* and 2.* (by [@holtkamp](https://github.com/holtkamp) and [@mnapoli](https://github.com/mnapoli)) -- [#416](https://github.com/PHP-DI/PHP-DI/pull/416): dumping definitions was refactored into a more lightweight and simple solution; definition "dumpers" have been removed (internal classes), definitions can now be cast to string directly (by [@mnapoli](https://github.com/mnapoli)) - -## 5.2 - -Read the [news entry](news/17-php-di-5-2-released.md). - -Improvements: - -- [#347](https://github.com/PHP-DI/PHP-DI/pull/347) (includes [#333](https://github.com/PHP-DI/PHP-DI/pull/333) and [#345](https://github.com/PHP-DI/PHP-DI/pull/345)): by [@jdreesen](https://github.com/jdreesen), [@quimcalpe](https://github.com/quimcalpe) and [@mnapoli](https://github.com/mnapoli) - - Allow injection of any container object as factory parameter via type hinting - - Allow injection of a `DI\Factory\RequestedEntry` object to get the requested entry name -- [#272](https://github.com/PHP-DI/PHP-DI/issues/272): Support `"Class::method""` syntax for callables (by [@jdreesen](https://github.com/jdreesen)) -- [#332](https://github.com/PHP-DI/PHP-DI/issues/332): IDE support (plugin and documentation) (by [@pulyaevskiy](https://github.com/pulyaevskiy), [@avant1](https://github.com/avant1) and [@mnapoli](https://github.com/mnapoli)) -- [#326](https://github.com/PHP-DI/PHP-DI/pull/326): Exception messages are simpler and more consistent (by [@mnapoli](https://github.com/mnapoli)) -- [#325](https://github.com/PHP-DI/PHP-DI/pull/325): Add a "Edit this page" button in the website to encourage users to improve the documentation (by [@jdreesen](https://github.com/jdreesen)) - -Bugfixes: - -- [#321](https://github.com/PHP-DI/PHP-DI/pull/321): Allow factory definitions to reference arbitrary container entries as callables (by [@jdreesen](https://github.com/jdreesen)) -- [#335](https://github.com/PHP-DI/PHP-DI/issues/335): Class imports in traits are now considered when parsing annotations (by [@thebigb](https://github.com/thebigb)) - -## 5.1 - -Read the [news entry](news/16-php-di-5-1-released.md). - -Improvements: - -- [Zend Framework 2 integration](https://github.com/PHP-DI/ZF2-Bridge) (by @Rastusik) -- [#308](https://github.com/PHP-DI/PHP-DI/pull/308): Instantiate factories using the container (`DI\factory(['FooFactory', 'create'])`) -- Many performances improvements - some benchmarks show up to 35% performance improvements, real results may vary of course -- Many documentation improvements (@jdreesen, @mindplay-dk, @mnapoli, @holtkamp, @Rastusik) -- [#296](https://github.com/PHP-DI/PHP-DI/issues/296): Provide a faster `ArrayCache` implementation, mostly useful in micro-benchmarks - -Bugfixes: - -- [#257](https://github.com/PHP-DI/PHP-DI/issues/257) & [#274](https://github.com/PHP-DI/PHP-DI/issues/274): Private properties of parent classes are not injected when using annotations -- [#300](https://github.com/PHP-DI/PHP-DI/pull/300): Exception if object definition extends an incompatible definition -- [#306](https://github.com/PHP-DI/PHP-DI/issues/306): Errors when using parameters passed by reference (fixed by @bradynpoulsen) -- [#318](https://github.com/PHP-DI/PHP-DI/issues/318): `Container::call()` ignores parameter's default value - -Internal changes: - -- [#276](https://github.com/PHP-DI/PHP-DI/pull/276): Tests now pass on Windows (@bgaillard) - -## 5.0 - -This is the complete change log. You can also read the [migration guide](doc/migration/5.0.md) for upgrading, or [the news article](news/15-php-di-5-0-released.md) for a nicer introduction to this new version. - -Improvements: - -- Moved to an organization on GitHub: [github.com/PHP-DI/PHP-DI](https://github.com/PHP-DI/PHP-DI) -- The package has been renamed to: from `mnapoli/php-di` to [`php-di/php-di`](https://packagist.org/packages/php-di/php-di) -- New [Silex integration](doc/frameworks/silex.md) -- Lighter package: from 10 to 3 Composer dependencies! -- [#235](https://github.com/PHP-DI/PHP-DI/issues/235): `DI\link()` is now deprecated in favor of `DI\get()`. There is no BC break as `DI\link()` still works. -- [#207](https://github.com/PHP-DI/PHP-DI/issues/207): Support for `DI\link()` in arrays -- [#203](https://github.com/PHP-DI/PHP-DI/issues/203): New `DI\string()` helper ([documentation](doc/php-definitions.md)) -- [#208](https://github.com/PHP-DI/PHP-DI/issues/208): Support for nested definitions -- [#226](https://github.com/PHP-DI/PHP-DI/pull/226): `DI\factory()` can now be omitted with closures: - - ```php - // before - 'My\Class' => DI\factory(function () { ... }) - // now (optional shortcut) - 'My\Class' => function () { ... } - ``` -- [#193](https://github.com/PHP-DI/PHP-DI/issues/193): `DI\object()->method()` now supports calling the same method twice (or more). -- [#248](https://github.com/PHP-DI/PHP-DI/issues/248): New `DI\decorate()` helper to decorate a previously defined entry ([documentation](doc/definition-overriding.md)) -- [#215](https://github.com/PHP-DI/PHP-DI/pull/215): New `DI\add()` helper to add entries to an existing array ([documentation](doc/definition-overriding.md)) -- [#218](https://github.com/PHP-DI/PHP-DI/issues/218): `ContainerBuilder::addDefinitions()` can now take an array of definitions -- [#211](https://github.com/PHP-DI/PHP-DI/pull/211): `ContainerBuilder::addDefinitions()` is now fluent (return `$this`) -- [#250](https://github.com/PHP-DI/PHP-DI/issues/250): `Container::call()` now also accepts parameters not indexed by name as well as embedded definitions ([documentation](doc/container.md)) -- Various performance improvements, e.g. lower the number of files loaded, simpler architecture, … - -BC breaks: - -- PHP-DI now requires a version of PHP >= 5.4.0 -- The package is lighter by default: - - [#251](https://github.com/PHP-DI/PHP-DI/issues/251): Annotations are disabled by default, if you use annotations enable them with `$containerBuilder->useAnnotations(true)`. Additionally the `doctrine/annotations` package isn't required by default anymore, so you also need to run `composer require doctrine/annotations`. - - `doctrine/cache` is not installed by default anymore, you need to require it in `composer.json` (`~1.0`) if you want to configure a cache for PHP-DI - - [#198](https://github.com/PHP-DI/PHP-DI/issues/198): `ocramius/proxy-manager` is not installed by default anymore, you need to require it in `composer.json` (`~1.0`) if you want to use **lazy injection** -- Closures are now converted into factory definitions automatically. If you ever defined a closure as a value (e.g. to have the closure injected in a class), you need to wrap the closure with the new `DI\value()` helper. -- [#223](https://github.com/PHP-DI/PHP-DI/issues/223): `DI\ContainerInterface` was deprecated since v4.1 and has been removed - -Internal changes in case you were replacing/extending some parts: - -- the definition sources architecture has been refactored, if you defined custom definition sources you will need to update your code (it should be much easier now) -- [#252](https://github.com/PHP-DI/PHP-DI/pull/252): `DI\Scope` internal implementation has changed. You are encouraged to use the constants (`DI\Scope::SINGLETON` and `DI\Scope::PROTOTYPE`) instead of the static methods, but backward compatibility is kept (static methods still work). -- [#241](https://github.com/PHP-DI/PHP-DI/issues/241): `Container::call()` now uses the *Invoker* external library - -## 4.4 - -Read the [news entry](news/13-php-di-4-4-released.md). - -- [#185](https://github.com/PHP-DI/PHP-DI/issues/185) Support for invokable objects in `Container::call()` -- [#192](https://github.com/PHP-DI/PHP-DI/pull/192) Support for invokable classes in `Container::call()` (will instantiate the class) -- [#184](https://github.com/PHP-DI/PHP-DI/pull/184) Option to ignore phpdoc errors - -## 4.3 - -Read the [news entry](news/11-php-di-4-3-released.md). - -- [#176](https://github.com/PHP-DI/PHP-DI/pull/176) New definition type for reading environment variables: `DI\env()` -- [#181](https://github.com/PHP-DI/PHP-DI/pull/181) `DI\FactoryInterface` and `DI\InvokerInterface` are now auto-registered inside the container so that you can inject them without any configuration needed -- [#173](https://github.com/PHP-DI/PHP-DI/pull/173) `$container->call(['MyClass', 'method]);` will get `MyClass` from the container if `method()` is not a static method - -## 4.2.2 - -- Fixed [#180](https://github.com/PHP-DI/PHP-DI/pull/180): `Container::call()` with object methods (`[$object, 'method']`) is now supported - -## 4.2.1 - -- Support for PHP 5.3.3, which was previously incomplete because of a bug in the reflection (there is now a workaround for this bug) - -But if you can, seriously avoid this (really old) PHP version and upgrade. - -## 4.2 - -Read the [news entry](news/10-php-di-4-2-released.md). - -**Minor BC-break**: Optional parameters (that were not configured) were injected, they are now ignored, which is what naturally makes sense since they are optional. -Example: - -```php - public function __construct(Bar $bar = null) - { - $this->bar = $bar ?: $this->createDefaultBar(); - } -``` - -Before 4.2, PHP-DI would try to inject a `Bar` instance. From 4.2 and onwards, it will inject `null`. - -Of course, you can still explicitly define an injection for the optional parameters and that will work. - -All changes: - -* [#162](https://github.com/PHP-DI/PHP-DI/pull/162) Added `Container::call()` to call functions with dependency injection -* [#156](https://github.com/PHP-DI/PHP-DI/issues/156) Wildcards (`*`) in definitions -* [#164](https://github.com/PHP-DI/PHP-DI/issues/164) Prototype scope is now available for `factory()` definitions too -* FIXED [#168](https://github.com/PHP-DI/PHP-DI/pull/168) `Container::has()` now returns false for interfaces and abstract classes that are not mapped in the definitions -* FIXED [#171](https://github.com/PHP-DI/PHP-DI/issues/171) Optional parameters are now ignored (not injected) if not set in the definitions (see the BC-break warning above) - -## 4.1 - -Read the [news entry](news/09-php-di-4-1-released.md). - -BC-breaks: None. - -* [#138](https://github.com/PHP-DI/PHP-DI/issues/138) [Container-interop](https://github.com/container-interop/container-interop) compliance -* [#143](https://github.com/PHP-DI/PHP-DI/issues/143) Much more explicit exception messages -* [#157](https://github.com/PHP-DI/PHP-DI/issues/157) HHVM support -* [#158](https://github.com/PHP-DI/PHP-DI/issues/158) Improved the documentation for [Symfony 2 integration](https://php-di.org/doc/frameworks/symfony2.html) - -## 4.0 - -Major changes: - -* The configuration format has changed ([read more here to understand why](news/06-php-di-4-0-new-definitions.md)) - -Read the migration guide if you are using 3.x: [Migration guide from 3.x to 4.0](doc/migration/4.0.md). - -BC-breaks: - -* YAML, XML and JSON definitions have been removed, and the PHP definition format has changed (see above) -* `ContainerSingleton` has been removed -* You cannot configure an injection as lazy anymore, you can only configure a container entry as lazy -* The Container constructor now takes mandatory parameters. Use the ContainerBuilder to create a Container. -* Removed `ContainerBuilder::setDefinitionsValidation()` (no definition validation anymore) -* `ContainerBuilder::useReflection()` is now named: `ContainerBuilder::useAutowiring()` -* `ContainerBuilder::addDefinitionsFromFile()` is now named: `ContainerBuilder::addDefinitions()` -* The `$proxy` parameter in `Container::get($name, $proxy = true)` hase been removed. To get a proxy, you now need to define an entry as "lazy". - -Other changes: - -* Added `ContainerInterface` and `FactoryInterface`, both implemented by the container. -* [#115](https://github.com/PHP-DI/PHP-DI/issues/115) Added `Container::has()` -* [#142](https://github.com/PHP-DI/PHP-DI/issues/142) Added `Container::make()` to resolve an entry -* [#127](https://github.com/PHP-DI/PHP-DI/issues/127) Added support for cases where PHP-DI is wrapped by another container (like Acclimate): PHP-DI can now use the wrapping container to perform injections -* [#128](https://github.com/PHP-DI/PHP-DI/issues/128) Configure entry aliases -* [#110](https://github.com/PHP-DI/PHP-DI/issues/110) XML definitions are not supported anymore -* [#122](https://github.com/PHP-DI/PHP-DI/issues/122) JSON definitions are not supported anymore -* `ContainerSingleton` has finally been removed -* Added `ContainerBuilder::buildDevContainer()` to get started with a default container very easily. -* [#99](https://github.com/PHP-DI/PHP-DI/issues/99) Fixed "`@param` with PHP internal type throws exception" - -## 3.5.1 - -* FIXED [#126](https://github.com/PHP-DI/PHP-DI/issues/126): `Container::set` without effect if a value has already been set and retrieved - -## 3.5 - -Read the [news entry](news/05-php-di-3-5.md). - -* Importing `@Inject` and `@Injectable` annotations is now optional! It means that you don't have to write `use DI\Annotation\Inject` anymore -* FIXED [#124](https://github.com/PHP-DI/PHP-DI/issues/124): `@Injects` annotation conflicts with other annotations - -## 3.4 - -Read the [news entry](news/04-php-di-3-4.md). - -* [#106](https://github.com/PHP-DI/PHP-DI/pull/106) You can now define arrays of values (in YAML, PHP, …) thanks to [@unkind](https://github.com/unkind) -* [#98](https://github.com/PHP-DI/PHP-DI/issues/98) `ContainerBuilder` is now fluent thanks to [@drdamour](https://github.com/drdamour) -* [#101](https://github.com/PHP-DI/PHP-DI/pull/101) Optional parameters are now supported: if you don't define a value to inject, their default value will be used -* XML definitions have been deprecated, there weren't even documented and were not maintained. They will be removed in 4.0. -* FIXED [#100](https://github.com/PHP-DI/PHP-DI/issues/100): bug for lazy injection in constructors - -## 3.3 - -Read the [news entry](news/03-php-di-3-3.md). - -* Inject dependencies on an existing instance with `Container::injectOn` (work from [Jeff Flitton](https://github.com/jflitton): [#89](https://github.com/PHP-DI/PHP-DI/pull/89)). -* [#86](https://github.com/PHP-DI/PHP-DI/issues/86): Optimized definition lookup (faster) -* FIXED [#87](https://github.com/PHP-DI/PHP-DI/issues/87): Rare bug in the `PhpDocParser`, fixed by [drdamour](https://github.com/drdamour) - -## 3.2 - -Read the [news entry](news/02-php-di-3-2.md). - -Small BC-break: PHP-DI 3.0 and 3.1 injected properties before calling the constructor. This was confusing and [not supported for internal classes](https://github.com/PHP-DI/PHP-DI/issues/74). -From 3.2 and on, properties are injected after calling the constructor. - -* **[Lazy injection](doc/lazy-injection.md)**: it is now possible to use lazy injection on properties and methods (setters and constructors). -* Lazy dependencies are now proxies that extend the class they proxy, so type-hinting works. -* Addition of the **`ContainerBuilder`** object, that helps to [create and configure a `Container`](doc/container-configuration.md). -* Some methods for configuring the Container have gone **deprecated** in favor of the `ContainerBuilder`. Fear not, these deprecated methods will remain until next major version (4.0). - * `Container::useReflection`, use ContainerBuilder::useReflection instead - * `Container::useAnnotations`, use ContainerBuilder::useAnnotations instead - * `Container::setDefinitionCache`, use ContainerBuilder::setDefinitionCache instead - * `Container::setDefinitionsValidation`, use ContainerBuilder::setDefinitionsValidation instead -* The container is now auto-registered (as 'DI\Container'). You can now inject the container without registering it. - -## 3.1.1 - -* Value definitions (`$container->set('foo', 80)`) are not cached anymore -* FIXED [#82](https://github.com/PHP-DI/PHP-DI/issues/82): Serialization error when using a cache - -## 3.1 - -Read the [news entry](news/01-php-di-3-1.md). - -* Zend Framework 1 integration through the [PHP-DI-ZF1 project](https://github.com/PHP-DI/PHP-DI-ZF1) -* Fixed the order of priorities when you mix different definition sources (reflection, annotations, files, …). See [Definition overriding](doc/definition-overriding.md) -* Now possible to define null values with `$container->set('foo', null)` (see [#79](https://github.com/PHP-DI/PHP-DI/issues/79)). -* Deprecated usage of `ContainerSingleton`, will be removed in next major version (4.0) - -## 3.0.6 - -* FIXED [#76](https://github.com/PHP-DI/PHP-DI/issues/76): Definition conflict when setting a closure for a class name - -## 3.0.5 - -* FIXED [#70](https://github.com/PHP-DI/PHP-DI/issues/70): Definition conflict when setting a value for a class name - -## 3.0.4 - -* FIXED [#69](https://github.com/PHP-DI/PHP-DI/issues/69): YamlDefinitionFileLoader crashes if YAML file is empty - -## 3.0.3 - -* Fixed over-restrictive dependencies in composer.json - -## 3.0.2 - -* [#64](https://github.com/PHP-DI/PHP-DI/issues/64): Non PHP-DI exceptions are not captured-rethrown anymore when injecting dependencies (cleaner stack trace) - -## 3.0.1 - -* [#62](https://github.com/PHP-DI/PHP-DI/issues/62): When using aliases, definitions are now merged - -## 3.0 - -Major compatibility breaks with 2.x. - -* The container is no longer a Singleton (but `ContainerSingleton::getInstance()` is available for fools who like it) -* Setter injection -* Constructor injection -* Scopes: singleton (share the same instance of the class) or prototype (create a new instance each time it is fetched). Defined at class level. -* Configuration is reworked from scratch. Now every configuration backend can do 100% of the job. -* Provided configuration backends: - * Reflection - * Annotations: @Inject, @Injectable - * PHP code (`Container::set()`) - * PHP array - * YAML file -* As a consequence, annotations are not mandatory anymore, all functionalities can be used with or without annotations. -* Renamed `DI\Annotations\` to `DI\Annotation\` -* `Container` no longer implements ArrayAccess, use only `$container->get($key)` now -* ZF1 integration broken and removed (work in progress for next releases) -* Code now follows PSR1 and PSR2 coding styles -* FIXED: [#58](https://github.com/PHP-DI/PHP-DI/issues/58) Getting a proxy of an alias didn't work - -## 2.1 - -* `use` statements to import classes from other namespaces are now taken into account with the `@var` annotation -* Updated and lightened the dependencies : `doctrine/common` has been replaced with more specific `doctrine/annotations` and `doctrine/cache` - -## 2.0 - -Major compatibility breaks with 1.x. - -* `Container::resolveDependencies()` has been renamed to `Container::injectAll()` -* Dependencies are now injected **before** the constructor is called, and thus are available in the constructor -* Merged `@Value` annotation with `@Inject`: no difference between value and bean injection anymore -* Container implements ArrayAccess for get() and set() (`$container['db.host'] = 'localhost';`) -* Ini configuration files removed: configuration is done in PHP -* Allow to define beans within closures for lazy-loading -* Switched to MIT License - -Warning: - -* If you use PHP 5.3 and __wakeup() methods, they will be called when PHP-DI creates new instances of those classes. - -## 1.1 - -* Caching of annotations based on Doctrine caches - -## 1.0 - -* DependencyManager renamed to Container -* Refactored basic Container usage with `get` and `set` -* Allow named injection `@Inject(name="")` -* Zend Framework integration diff --git a/vendor/php-di/php-di/composer.json b/vendor/php-di/php-di/composer.json deleted file mode 100644 index 16b5f26..0000000 --- a/vendor/php-di/php-di/composer.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "php-di/php-di", - "type": "library", - "description": "The dependency injection container for humans", - "keywords": ["di", "dependency injection", "container", "ioc", "psr-11", "psr11", "container-interop"], - "homepage": "https://php-di.org/", - "license": "MIT", - "autoload": { - "psr-4": { - "DI\\": "src/" - }, - "files": [ - "src/functions.php" - ] - }, - "autoload-dev": { - "psr-4": { - "DI\\Test\\IntegrationTest\\": "tests/IntegrationTest/", - "DI\\Test\\UnitTest\\": "tests/UnitTest/" - } - }, - "scripts": { - "test": "phpunit", - "format-code": "php-cs-fixer fix --allow-risky=yes", - "phpstan": "phpstan analyse -l 5 -c phpstan.neon src" - }, - "require": { - "php": ">=7.4.0", - "psr/container": "^1.0", - "php-di/invoker": "^2.0", - "php-di/phpdoc-reader": "^2.0.1", - "laravel/serializable-closure": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.5", - "mnapoli/phpunit-easymock": "^1.2", - "doctrine/annotations": "~1.10", - "ocramius/proxy-manager": "^2.11.2", - "friendsofphp/php-cs-fixer": "^2.4", - "phpstan/phpstan": "^0.12" - }, - "provide": { - "psr/container-implementation": "^1.0" - }, - "suggest": { - "doctrine/annotations": "Install it if you want to use annotations (version ~1.2)", - "ocramius/proxy-manager": "Install it if you want to use lazy injection (version ~2.0)" - } -} diff --git a/vendor/php-di/php-di/src/Annotation/Inject.php b/vendor/php-di/php-di/src/Annotation/Inject.php deleted file mode 100644 index c0eef19..0000000 --- a/vendor/php-di/php-di/src/Annotation/Inject.php +++ /dev/null @@ -1,93 +0,0 @@ - - */ -final class Inject -{ - /** - * Entry name. - * @var string - */ - private $name; - - /** - * Parameters, indexed by the parameter number (index) or name. - * - * Used if the annotation is set on a method - * @var array - */ - private $parameters = []; - - /** - * @throws InvalidAnnotation - */ - public function __construct(array $values) - { - // Process the parameters as a list AND as a parameter array (we don't know on what the annotation is) - - // @Inject(name="foo") - if (isset($values['name']) && is_string($values['name'])) { - $this->name = $values['name']; - - return; - } - - // @Inject - if (! isset($values['value'])) { - return; - } - - $values = $values['value']; - - // @Inject("foo") - if (is_string($values)) { - $this->name = $values; - } - - // @Inject({...}) on a method - if (is_array($values)) { - foreach ($values as $key => $value) { - if (! is_string($value)) { - throw new InvalidAnnotation(sprintf( - '@Inject({"param" = "value"}) expects "value" to be a string, %s given.', - json_encode($value) - )); - } - - $this->parameters[$key] = $value; - } - } - } - - /** - * @return string|null Name of the entry to inject - */ - public function getName() - { - return $this->name; - } - - /** - * @return array Parameters, indexed by the parameter number (index) or name - */ - public function getParameters() : array - { - return $this->parameters; - } -} diff --git a/vendor/php-di/php-di/src/Annotation/Injectable.php b/vendor/php-di/php-di/src/Annotation/Injectable.php deleted file mode 100644 index ea15944..0000000 --- a/vendor/php-di/php-di/src/Annotation/Injectable.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @author Matthieu Napoli - */ -final class Injectable -{ - /** - * Should the object be lazy-loaded. - * @var bool|null - */ - private $lazy; - - public function __construct(array $values) - { - if (isset($values['lazy'])) { - $this->lazy = (bool) $values['lazy']; - } - } - - /** - * @return bool|null - */ - public function isLazy() - { - return $this->lazy; - } -} diff --git a/vendor/php-di/php-di/src/CompiledContainer.php b/vendor/php-di/php-di/src/CompiledContainer.php deleted file mode 100644 index 31fc017..0000000 --- a/vendor/php-di/php-di/src/CompiledContainer.php +++ /dev/null @@ -1,129 +0,0 @@ - - */ -abstract class CompiledContainer extends Container -{ - /** - * This const is overridden in child classes (compiled containers). - * @var array - */ - protected const METHOD_MAPPING = []; - - /** - * @var InvokerInterface - */ - private $factoryInvoker; - - /** - * {@inheritdoc} - */ - public function get($name) - { - // Try to find the entry in the singleton map - if (isset($this->resolvedEntries[$name]) || array_key_exists($name, $this->resolvedEntries)) { - return $this->resolvedEntries[$name]; - } - - $method = static::METHOD_MAPPING[$name] ?? null; - - // If it's a compiled entry, then there is a method in this class - if ($method !== null) { - // Check if we are already getting this entry -> circular dependency - if (isset($this->entriesBeingResolved[$name])) { - throw new DependencyException("Circular dependency detected while trying to resolve entry '$name'"); - } - $this->entriesBeingResolved[$name] = true; - - try { - $value = $this->$method(); - } finally { - unset($this->entriesBeingResolved[$name]); - } - - // Store the entry to always return it without recomputing it - $this->resolvedEntries[$name] = $value; - - return $value; - } - - return parent::get($name); - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - if (! is_string($name)) { - throw new \InvalidArgumentException(sprintf( - 'The name parameter must be of type string, %s given', - is_object($name) ? get_class($name) : gettype($name) - )); - } - - // The parent method is overridden to check in our array, it avoids resolving definitions - if (isset(static::METHOD_MAPPING[$name])) { - return true; - } - - return parent::has($name); - } - - protected function setDefinition(string $name, Definition $definition) - { - // It needs to be forbidden because that would mean get() must go through the definitions - // every time, which kinds of defeats the performance gains of the compiled container - throw new \LogicException('You cannot set a definition at runtime on a compiled container. You can either put your definitions in a file, disable compilation or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.'); - } - - /** - * Invoke the given callable. - */ - protected function resolveFactory($callable, $entryName, array $extraParameters = []) - { - // Initialize the factory resolver - if (! $this->factoryInvoker) { - $parameterResolver = new ResolverChain([ - new AssociativeArrayResolver, - new FactoryParameterResolver($this->delegateContainer), - new NumericArrayResolver, - new DefaultValueResolver, - ]); - - $this->factoryInvoker = new Invoker($parameterResolver, $this->delegateContainer); - } - - $parameters = [$this->delegateContainer, new RequestedEntryHolder($entryName)]; - - $parameters = array_merge($parameters, $extraParameters); - - try { - return $this->factoryInvoker->call($callable, $parameters); - } catch (NotCallableException $e) { - throw new InvalidDefinition("Entry \"$entryName\" cannot be resolved: factory " . $e->getMessage()); - } catch (NotEnoughParametersException $e) { - throw new InvalidDefinition("Entry \"$entryName\" cannot be resolved: " . $e->getMessage()); - } - } -} diff --git a/vendor/php-di/php-di/src/Compiler/Compiler.php b/vendor/php-di/php-di/src/Compiler/Compiler.php deleted file mode 100644 index ca5d494..0000000 --- a/vendor/php-di/php-di/src/Compiler/Compiler.php +++ /dev/null @@ -1,422 +0,0 @@ - - */ -class Compiler -{ - /** - * @var string - */ - private $containerClass; - - /** - * @var string - */ - private $containerParentClass; - - /** - * Definitions indexed by the entry name. The value can be null if the definition needs to be fetched. - * - * Keys are strings, values are `Definition` objects or null. - * - * @var \ArrayIterator - */ - private $entriesToCompile; - - /** - * Progressive counter for definitions. - * - * Each key in $entriesToCompile is defined as 'SubEntry' + counter - * and each definition has always the same key in the CompiledContainer - * if PHP-DI configuration does not change. - * - * @var int - */ - private $subEntryCounter; - - /** - * Progressive counter for CompiledContainer get methods. - * - * Each CompiledContainer method name is defined as 'get' + counter - * and remains the same after each recompilation - * if PHP-DI configuration does not change. - * - * @var int - */ - private $methodMappingCounter; - - /** - * Map of entry names to method names. - * - * @var string[] - */ - private $entryToMethodMapping = []; - - /** - * @var string[] - */ - private $methods = []; - - /** - * @var bool - */ - private $autowiringEnabled; - - /** - * @var ProxyFactory - */ - private $proxyFactory; - - public function __construct(ProxyFactory $proxyFactory) - { - $this->proxyFactory = $proxyFactory; - } - - public function getProxyFactory() : ProxyFactory - { - return $this->proxyFactory; - } - - /** - * Compile the container. - * - * @return string The compiled container file name. - */ - public function compile( - DefinitionSource $definitionSource, - string $directory, - string $className, - string $parentClassName, - bool $autowiringEnabled - ) : string { - $fileName = rtrim($directory, '/') . '/' . $className . '.php'; - - if (file_exists($fileName)) { - // The container is already compiled - return $fileName; - } - - $this->autowiringEnabled = $autowiringEnabled; - - // Validate that a valid class name was provided - $validClassName = preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $className); - if (!$validClassName) { - throw new InvalidArgumentException("The container cannot be compiled: `$className` is not a valid PHP class name"); - } - - $this->entriesToCompile = new \ArrayIterator($definitionSource->getDefinitions()); - - // We use an ArrayIterator so that we can keep adding new items to the list while we compile entries - foreach ($this->entriesToCompile as $entryName => $definition) { - $silenceErrors = false; - // This is an entry found by reference during autowiring - if (!$definition) { - $definition = $definitionSource->getDefinition($entryName); - // We silence errors for those entries because type-hints may reference interfaces/abstract classes - // which could later be defined, or even not used (we don't want to block the compilation for those) - $silenceErrors = true; - } - if (!$definition) { - // We do not throw a `NotFound` exception here because the dependency - // could be defined at runtime - continue; - } - // Check that the definition can be compiled - $errorMessage = $this->isCompilable($definition); - if ($errorMessage !== true) { - continue; - } - try { - $this->compileDefinition($entryName, $definition); - } catch (InvalidDefinition $e) { - if ($silenceErrors) { - // forget the entry - unset($this->entryToMethodMapping[$entryName]); - } else { - throw $e; - } - } - } - - $this->containerClass = $className; - $this->containerParentClass = $parentClassName; - - ob_start(); - require __DIR__ . '/Template.php'; - $fileContent = ob_get_clean(); - - $fileContent = "createCompilationDirectory(dirname($fileName)); - $this->writeFileAtomic($fileName, $fileContent); - - return $fileName; - } - - private function writeFileAtomic(string $fileName, string $content) : int - { - $tmpFile = @tempnam(dirname($fileName), 'swap-compile'); - if ($tmpFile === false) { - throw new InvalidArgumentException( - sprintf('Error while creating temporary file in %s', dirname($fileName)) - ); - } - @chmod($tmpFile, 0666); - - $written = file_put_contents($tmpFile, $content); - if ($written === false) { - @unlink($tmpFile); - - throw new InvalidArgumentException(sprintf('Error while writing to %s', $tmpFile)); - } - - @chmod($tmpFile, 0666); - $renamed = @rename($tmpFile, $fileName); - if (!$renamed) { - @unlink($tmpFile); - throw new InvalidArgumentException(sprintf('Error while renaming %s to %s', $tmpFile, $fileName)); - } - - return $written; - } - - /** - * @throws DependencyException - * @throws InvalidDefinition - * @return string The method name - */ - private function compileDefinition(string $entryName, Definition $definition) : string - { - // Generate a unique method name - $methodName = 'get' . (++$this->methodMappingCounter); - $this->entryToMethodMapping[$entryName] = $methodName; - - switch (true) { - case $definition instanceof ValueDefinition: - $value = $definition->getValue(); - $code = 'return ' . $this->compileValue($value) . ';'; - break; - case $definition instanceof Reference: - $targetEntryName = $definition->getTargetEntryName(); - $code = 'return $this->delegateContainer->get(' . $this->compileValue($targetEntryName) . ');'; - // If this method is not yet compiled we store it for compilation - if (!isset($this->entriesToCompile[$targetEntryName])) { - $this->entriesToCompile[$targetEntryName] = null; - } - break; - case $definition instanceof StringDefinition: - $entryName = $this->compileValue($definition->getName()); - $expression = $this->compileValue($definition->getExpression()); - $code = 'return \DI\Definition\StringDefinition::resolveExpression(' . $entryName . ', ' . $expression . ', $this->delegateContainer);'; - break; - case $definition instanceof EnvironmentVariableDefinition: - $variableName = $this->compileValue($definition->getVariableName()); - $isOptional = $this->compileValue($definition->isOptional()); - $defaultValue = $this->compileValue($definition->getDefaultValue()); - $code = <<getVariableName()}' has not been defined"); - } - return $defaultValue; -PHP; - break; - case $definition instanceof ArrayDefinition: - try { - $code = 'return ' . $this->compileValue($definition->getValues()) . ';'; - } catch (\Exception $e) { - throw new DependencyException(sprintf( - 'Error while compiling %s. %s', - $definition->getName(), - $e->getMessage() - ), 0, $e); - } - break; - case $definition instanceof ObjectDefinition: - $compiler = new ObjectCreationCompiler($this); - $code = $compiler->compile($definition); - $code .= "\n return \$object;"; - break; - case $definition instanceof DecoratorDefinition: - $decoratedDefinition = $definition->getDecoratedDefinition(); - if (! $decoratedDefinition instanceof Definition) { - if (! $definition->getName()) { - throw new InvalidDefinition('Decorators cannot be nested in another definition'); - } - throw new InvalidDefinition(sprintf( - 'Entry "%s" decorates nothing: no previous definition with the same name was found', - $definition->getName() - )); - } - $code = sprintf( - 'return call_user_func(%s, %s, $this->delegateContainer);', - $this->compileValue($definition->getCallable()), - $this->compileValue($decoratedDefinition) - ); - break; - case $definition instanceof FactoryDefinition: - $value = $definition->getCallable(); - - // Custom error message to help debugging - $isInvokableClass = is_string($value) && class_exists($value) && method_exists($value, '__invoke'); - if ($isInvokableClass && !$this->autowiringEnabled) { - throw new InvalidDefinition(sprintf( - 'Entry "%s" cannot be compiled. Invokable classes cannot be automatically resolved if autowiring is disabled on the container, you need to enable autowiring or define the entry manually.', - $entryName - )); - } - - $definitionParameters = ''; - if (!empty($definition->getParameters())) { - $definitionParameters = ', ' . $this->compileValue($definition->getParameters()); - } - - $code = sprintf( - 'return $this->resolveFactory(%s, %s%s);', - $this->compileValue($value), - var_export($entryName, true), - $definitionParameters - ); - - break; - default: - // This case should not happen (so it cannot be tested) - throw new \Exception('Cannot compile definition of type ' . get_class($definition)); - } - - $this->methods[$methodName] = $code; - - return $methodName; - } - - public function compileValue($value) : string - { - // Check that the value can be compiled - $errorMessage = $this->isCompilable($value); - if ($errorMessage !== true) { - throw new InvalidDefinition($errorMessage); - } - - if ($value instanceof Definition) { - // Give it an arbitrary unique name - $subEntryName = 'subEntry' . (++$this->subEntryCounter); - // Compile the sub-definition in another method - $methodName = $this->compileDefinition($subEntryName, $value); - // The value is now a method call to that method (which returns the value) - return "\$this->$methodName()"; - } - - if (is_array($value)) { - $value = array_map(function ($value, $key) { - $compiledValue = $this->compileValue($value); - $key = var_export($key, true); - - return " $key => $compiledValue,\n"; - }, $value, array_keys($value)); - $value = implode('', $value); - - return "[\n$value ]"; - } - - if ($value instanceof \Closure) { - return $this->compileClosure($value); - } - - return var_export($value, true); - } - - private function createCompilationDirectory(string $directory) - { - if (!is_dir($directory) && !@mkdir($directory, 0777, true) && !is_dir($directory)) { - throw new InvalidArgumentException(sprintf('Compilation directory does not exist and cannot be created: %s.', $directory)); - } - if (!is_writable($directory)) { - throw new InvalidArgumentException(sprintf('Compilation directory is not writable: %s.', $directory)); - } - } - - /** - * @return string|true If true is returned that means that the value is compilable. - */ - private function isCompilable($value) - { - if ($value instanceof ValueDefinition) { - return $this->isCompilable($value->getValue()); - } - if ($value instanceof DecoratorDefinition) { - if (empty($value->getName())) { - return 'Decorators cannot be nested in another definition'; - } - } - // All other definitions are compilable - if ($value instanceof Definition) { - return true; - } - if ($value instanceof \Closure) { - return true; - } - if (is_object($value)) { - return 'An object was found but objects cannot be compiled'; - } - if (is_resource($value)) { - return 'A resource was found but resources cannot be compiled'; - } - - return true; - } - - /** - * @throws \DI\Definition\Exception\InvalidDefinition - */ - private function compileClosure(\Closure $closure) : string - { - $reflector = new ReflectionClosure($closure); - - if ($reflector->getUseVariables()) { - throw new InvalidDefinition('Cannot compile closures which import variables using the `use` keyword'); - } - - if ($reflector->isBindingRequired() || $reflector->isScopeRequired()) { - throw new InvalidDefinition('Cannot compile closures which use $this or self/static/parent references'); - } - - // Force all closures to be static (add the `static` keyword), i.e. they can't use - // $this, which makes sense since their code is copied into another class. - $code = ($reflector->isStatic() ? '' : 'static ') . $reflector->getCode(); - - $code = trim($code, "\t\n\r;"); - - return $code; - } -} diff --git a/vendor/php-di/php-di/src/Compiler/ObjectCreationCompiler.php b/vendor/php-di/php-di/src/Compiler/ObjectCreationCompiler.php deleted file mode 100644 index 9f19d4c..0000000 --- a/vendor/php-di/php-di/src/Compiler/ObjectCreationCompiler.php +++ /dev/null @@ -1,201 +0,0 @@ - - */ -class ObjectCreationCompiler -{ - /** - * @var Compiler - */ - private $compiler; - - public function __construct(Compiler $compiler) - { - $this->compiler = $compiler; - } - - public function compile(ObjectDefinition $definition) : string - { - $this->assertClassIsNotAnonymous($definition); - $this->assertClassIsInstantiable($definition); - - // Lazy? - if ($definition->isLazy()) { - return $this->compileLazyDefinition($definition); - } - - try { - $classReflection = new ReflectionClass($definition->getClassName()); - $constructorArguments = $this->resolveParameters($definition->getConstructorInjection(), $classReflection->getConstructor()); - $dumpedConstructorArguments = array_map(function ($value) { - return $this->compiler->compileValue($value); - }, $constructorArguments); - - $code = []; - $code[] = sprintf( - '$object = new %s(%s);', - $definition->getClassName(), - implode(', ', $dumpedConstructorArguments) - ); - - // Property injections - foreach ($definition->getPropertyInjections() as $propertyInjection) { - $value = $propertyInjection->getValue(); - $value = $this->compiler->compileValue($value); - - $className = $propertyInjection->getClassName() ?: $definition->getClassName(); - $property = new ReflectionProperty($className, $propertyInjection->getPropertyName()); - if ($property->isPublic()) { - $code[] = sprintf('$object->%s = %s;', $propertyInjection->getPropertyName(), $value); - } else { - // Private/protected property - $code[] = sprintf( - '\DI\Definition\Resolver\ObjectCreator::setPrivatePropertyValue(%s, $object, \'%s\', %s);', - var_export($propertyInjection->getClassName(), true), - $propertyInjection->getPropertyName(), - $value - ); - } - } - - // Method injections - foreach ($definition->getMethodInjections() as $methodInjection) { - $methodReflection = new \ReflectionMethod($definition->getClassName(), $methodInjection->getMethodName()); - $parameters = $this->resolveParameters($methodInjection, $methodReflection); - - $dumpedParameters = array_map(function ($value) { - return $this->compiler->compileValue($value); - }, $parameters); - - $code[] = sprintf( - '$object->%s(%s);', - $methodInjection->getMethodName(), - implode(', ', $dumpedParameters) - ); - } - } catch (InvalidDefinition $e) { - throw InvalidDefinition::create($definition, sprintf( - 'Entry "%s" cannot be compiled: %s', - $definition->getName(), - $e->getMessage() - )); - } - - return implode("\n ", $code); - } - - public function resolveParameters(MethodInjection $definition = null, ReflectionMethod $method = null) : array - { - $args = []; - - if (! $method) { - return $args; - } - - $definitionParameters = $definition ? $definition->getParameters() : []; - - foreach ($method->getParameters() as $index => $parameter) { - if (array_key_exists($index, $definitionParameters)) { - // Look in the definition - $value = &$definitionParameters[$index]; - } elseif ($parameter->isOptional()) { - // If the parameter is optional and wasn't specified, we take its default value - $args[] = $this->getParameterDefaultValue($parameter, $method); - continue; - } else { - throw new InvalidDefinition(sprintf( - 'Parameter $%s of %s has no value defined or guessable', - $parameter->getName(), - $this->getFunctionName($method) - )); - } - - $args[] = &$value; - } - - return $args; - } - - private function compileLazyDefinition(ObjectDefinition $definition) : string - { - $subDefinition = clone $definition; - $subDefinition->setLazy(false); - $subDefinition = $this->compiler->compileValue($subDefinition); - - $this->compiler->getProxyFactory()->generateProxyClass($definition->getClassName()); - - return <<proxyFactory->createProxy( - '{$definition->getClassName()}', - function (&\$wrappedObject, \$proxy, \$method, \$params, &\$initializer) { - \$wrappedObject = $subDefinition; - \$initializer = null; // turning off further lazy initialization - return true; - } - ); -PHP; - } - - /** - * Returns the default value of a function parameter. - * - * @throws InvalidDefinition Can't get default values from PHP internal classes and functions - * @return mixed - */ - private function getParameterDefaultValue(ReflectionParameter $parameter, ReflectionMethod $function) - { - try { - return $parameter->getDefaultValue(); - } catch (\ReflectionException $e) { - throw new InvalidDefinition(sprintf( - 'The parameter "%s" of %s has no type defined or guessable. It has a default value, ' - . 'but the default value can\'t be read through Reflection because it is a PHP internal class.', - $parameter->getName(), - $this->getFunctionName($function) - )); - } - } - - private function getFunctionName(ReflectionMethod $method) : string - { - return $method->getName() . '()'; - } - - private function assertClassIsNotAnonymous(ObjectDefinition $definition) - { - if (strpos($definition->getClassName(), '@') !== false) { - throw InvalidDefinition::create($definition, sprintf( - 'Entry "%s" cannot be compiled: anonymous classes cannot be compiled', - $definition->getName() - )); - } - } - - private function assertClassIsInstantiable(ObjectDefinition $definition) - { - if ($definition->isInstantiable()) { - return; - } - - $message = ! $definition->classExists() - ? 'Entry "%s" cannot be compiled: the class doesn\'t exist' - : 'Entry "%s" cannot be compiled: the class is not instantiable'; - - throw InvalidDefinition::create($definition, sprintf($message, $definition->getName())); - } -} diff --git a/vendor/php-di/php-di/src/Compiler/RequestedEntryHolder.php b/vendor/php-di/php-di/src/Compiler/RequestedEntryHolder.php deleted file mode 100644 index 68b5bc2..0000000 --- a/vendor/php-di/php-di/src/Compiler/RequestedEntryHolder.php +++ /dev/null @@ -1,28 +0,0 @@ - - */ -class RequestedEntryHolder implements RequestedEntry -{ - /** - * @var string - */ - private $name; - - public function __construct(string $name) - { - $this->name = $name; - } - - public function getName() : string - { - return $this->name; - } -} diff --git a/vendor/php-di/php-di/src/Compiler/Template.php b/vendor/php-di/php-di/src/Compiler/Template.php deleted file mode 100644 index e053639..0000000 --- a/vendor/php-di/php-di/src/Compiler/Template.php +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This class has been auto-generated by PHP-DI. - */ -class containerClass; ?> extends containerParentClass; ?> -{ - const METHOD_MAPPING = entryToMethodMapping); ?>; - -methods as $methodName => $methodContent) : ?> - protected function () - { - - - } - - -} diff --git a/vendor/php-di/php-di/src/Container.php b/vendor/php-di/php-di/src/Container.php deleted file mode 100644 index a9c95de..0000000 --- a/vendor/php-di/php-di/src/Container.php +++ /dev/null @@ -1,433 +0,0 @@ - - */ -class Container implements ContainerInterface, FactoryInterface, InvokerInterface -{ - /** - * Map of entries that are already resolved. - * @var array - */ - protected $resolvedEntries = []; - - /** - * @var MutableDefinitionSource - */ - private $definitionSource; - - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * Map of definitions that are already fetched (local cache). - * - * @var (Definition|null)[] - */ - private $fetchedDefinitions = []; - - /** - * Array of entries being resolved. Used to avoid circular dependencies and infinite loops. - * @var array - */ - protected $entriesBeingResolved = []; - - /** - * @var InvokerInterface|null - */ - private $invoker; - - /** - * Container that wraps this container. If none, points to $this. - * - * @var ContainerInterface - */ - protected $delegateContainer; - - /** - * @var ProxyFactory - */ - protected $proxyFactory; - - /** - * Use `$container = new Container()` if you want a container with the default configuration. - * - * If you want to customize the container's behavior, you are discouraged to create and pass the - * dependencies yourself, the ContainerBuilder class is here to help you instead. - * - * @see ContainerBuilder - * - * @param ContainerInterface $wrapperContainer If the container is wrapped by another container. - */ - public function __construct( - MutableDefinitionSource $definitionSource = null, - ProxyFactory $proxyFactory = null, - ContainerInterface $wrapperContainer = null - ) { - $this->delegateContainer = $wrapperContainer ?: $this; - - $this->definitionSource = $definitionSource ?: $this->createDefaultDefinitionSource(); - $this->proxyFactory = $proxyFactory ?: new ProxyFactory(false); - $this->definitionResolver = new ResolverDispatcher($this->delegateContainer, $this->proxyFactory); - - // Auto-register the container - $this->resolvedEntries = [ - self::class => $this, - ContainerInterface::class => $this->delegateContainer, - FactoryInterface::class => $this, - InvokerInterface::class => $this, - ]; - } - - /** - * Returns an entry of the container by its name. - * - * @template T - * @param string|class-string $name Entry name or a class name. - * - * @throws DependencyException Error while resolving the entry. - * @throws NotFoundException No entry found for the given name. - * @return mixed|T - */ - public function get($name) - { - // If the entry is already resolved we return it - if (isset($this->resolvedEntries[$name]) || array_key_exists($name, $this->resolvedEntries)) { - return $this->resolvedEntries[$name]; - } - - $definition = $this->getDefinition($name); - if (! $definition) { - throw new NotFoundException("No entry or class found for '$name'"); - } - - $value = $this->resolveDefinition($definition); - - $this->resolvedEntries[$name] = $value; - - return $value; - } - - /** - * @param string $name - * - * @return Definition|null - */ - private function getDefinition($name) - { - // Local cache that avoids fetching the same definition twice - if (!array_key_exists($name, $this->fetchedDefinitions)) { - $this->fetchedDefinitions[$name] = $this->definitionSource->getDefinition($name); - } - - return $this->fetchedDefinitions[$name]; - } - - /** - * Build an entry of the container by its name. - * - * This method behave like get() except resolves the entry again every time. - * For example if the entry is a class then a new instance will be created each time. - * - * This method makes the container behave like a factory. - * - * @template T - * @param string|class-string $name Entry name or a class name. - * @param array $parameters Optional parameters to use to build the entry. Use this to force - * specific parameters to specific values. Parameters not defined in this - * array will be resolved using the container. - * - * @throws InvalidArgumentException The name parameter must be of type string. - * @throws DependencyException Error while resolving the entry. - * @throws NotFoundException No entry found for the given name. - * @return mixed|T - */ - public function make($name, array $parameters = []) - { - if (! is_string($name)) { - throw new InvalidArgumentException(sprintf( - 'The name parameter must be of type string, %s given', - is_object($name) ? get_class($name) : gettype($name) - )); - } - - $definition = $this->getDefinition($name); - if (! $definition) { - // If the entry is already resolved we return it - if (array_key_exists($name, $this->resolvedEntries)) { - return $this->resolvedEntries[$name]; - } - - throw new NotFoundException("No entry or class found for '$name'"); - } - - return $this->resolveDefinition($definition, $parameters); - } - - /** - * Test if the container can provide something for the given name. - * - * @param string $name Entry name or a class name. - * - * @throws InvalidArgumentException The name parameter must be of type string. - * @return bool - */ - public function has($name) - { - if (! is_string($name)) { - throw new InvalidArgumentException(sprintf( - 'The name parameter must be of type string, %s given', - is_object($name) ? get_class($name) : gettype($name) - )); - } - - if (array_key_exists($name, $this->resolvedEntries)) { - return true; - } - - $definition = $this->getDefinition($name); - if ($definition === null) { - return false; - } - - return $this->definitionResolver->isResolvable($definition); - } - - /** - * Inject all dependencies on an existing instance. - * - * @template T - * @param object|T $instance Object to perform injection upon - * @throws InvalidArgumentException - * @throws DependencyException Error while injecting dependencies - * @return object|T $instance Returns the same instance - */ - public function injectOn($instance) - { - if (!$instance) { - return $instance; - } - - $className = get_class($instance); - - // If the class is anonymous, don't cache its definition - // Checking for anonymous classes is cleaner via Reflection, but also slower - $objectDefinition = false !== strpos($className, '@anonymous') - ? $this->definitionSource->getDefinition($className) - : $this->getDefinition($className); - - if (! $objectDefinition instanceof ObjectDefinition) { - return $instance; - } - - $definition = new InstanceDefinition($instance, $objectDefinition); - - $this->definitionResolver->resolve($definition); - - return $instance; - } - - /** - * Call the given function using the given parameters. - * - * Missing parameters will be resolved from the container. - * - * @param callable $callable Function to call. - * @param array $parameters Parameters to use. Can be indexed by the parameter names - * or not indexed (same order as the parameters). - * The array can also contain DI definitions, e.g. DI\get(). - * - * @return mixed Result of the function. - */ - public function call($callable, array $parameters = []) - { - return $this->getInvoker()->call($callable, $parameters); - } - - /** - * Define an object or a value in the container. - * - * @param string $name Entry name - * @param mixed|DefinitionHelper $value Value, use definition helpers to define objects - */ - public function set(string $name, $value) - { - if ($value instanceof DefinitionHelper) { - $value = $value->getDefinition($name); - } elseif ($value instanceof \Closure) { - $value = new FactoryDefinition($name, $value); - } - - if ($value instanceof ValueDefinition) { - $this->resolvedEntries[$name] = $value->getValue(); - } elseif ($value instanceof Definition) { - $value->setName($name); - $this->setDefinition($name, $value); - } else { - $this->resolvedEntries[$name] = $value; - } - } - - /** - * Get defined container entries. - * - * @return string[] - */ - public function getKnownEntryNames() : array - { - $entries = array_unique(array_merge( - array_keys($this->definitionSource->getDefinitions()), - array_keys($this->resolvedEntries) - )); - sort($entries); - - return $entries; - } - - /** - * Get entry debug information. - * - * @param string $name Entry name - * - * @throws InvalidDefinition - * @throws NotFoundException - */ - public function debugEntry(string $name) : string - { - $definition = $this->definitionSource->getDefinition($name); - if ($definition instanceof Definition) { - return (string) $definition; - } - - if (array_key_exists($name, $this->resolvedEntries)) { - return $this->getEntryType($this->resolvedEntries[$name]); - } - - throw new NotFoundException("No entry or class found for '$name'"); - } - - /** - * Get formatted entry type. - * - * @param mixed $entry - */ - private function getEntryType($entry) : string - { - if (is_object($entry)) { - return sprintf("Object (\n class = %s\n)", get_class($entry)); - } - - if (is_array($entry)) { - return preg_replace(['/^array \(/', '/\)$/'], ['[', ']'], var_export($entry, true)); - } - - if (is_string($entry)) { - return sprintf('Value (\'%s\')', $entry); - } - - if (is_bool($entry)) { - return sprintf('Value (%s)', $entry === true ? 'true' : 'false'); - } - - return sprintf('Value (%s)', is_scalar($entry) ? $entry : ucfirst(gettype($entry))); - } - - /** - * Resolves a definition. - * - * Checks for circular dependencies while resolving the definition. - * - * @throws DependencyException Error while resolving the entry. - * @return mixed - */ - private function resolveDefinition(Definition $definition, array $parameters = []) - { - $entryName = $definition->getName(); - - // Check if we are already getting this entry -> circular dependency - if (isset($this->entriesBeingResolved[$entryName])) { - throw new DependencyException("Circular dependency detected while trying to resolve entry '$entryName'"); - } - $this->entriesBeingResolved[$entryName] = true; - - // Resolve the definition - try { - $value = $this->definitionResolver->resolve($definition, $parameters); - } finally { - unset($this->entriesBeingResolved[$entryName]); - } - - return $value; - } - - protected function setDefinition(string $name, Definition $definition) - { - // Clear existing entry if it exists - if (array_key_exists($name, $this->resolvedEntries)) { - unset($this->resolvedEntries[$name]); - } - $this->fetchedDefinitions = []; // Completely clear this local cache - - $this->definitionSource->addDefinition($definition); - } - - private function getInvoker() : InvokerInterface - { - if (! $this->invoker) { - $parameterResolver = new ResolverChain([ - new DefinitionParameterResolver($this->definitionResolver), - new NumericArrayResolver, - new AssociativeArrayResolver, - new DefaultValueResolver, - new TypeHintContainerResolver($this->delegateContainer), - ]); - - $this->invoker = new Invoker($parameterResolver, $this); - } - - return $this->invoker; - } - - private function createDefaultDefinitionSource() : SourceChain - { - $source = new SourceChain([new ReflectionBasedAutowiring]); - $source->setMutableDefinitionSource(new DefinitionArray([], new ReflectionBasedAutowiring)); - - return $source; - } -} diff --git a/vendor/php-di/php-di/src/ContainerBuilder.php b/vendor/php-di/php-di/src/ContainerBuilder.php deleted file mode 100644 index 3ee747f..0000000 --- a/vendor/php-di/php-di/src/ContainerBuilder.php +++ /dev/null @@ -1,385 +0,0 @@ -build(); - * - * @api - * - * @since 3.2 - * @author Matthieu Napoli - */ -class ContainerBuilder -{ - /** - * Name of the container class, used to create the container. - * @var string - */ - private $containerClass; - - /** - * Name of the container parent class, used on compiled container. - * @var string - */ - private $containerParentClass; - - /** - * @var bool - */ - private $useAutowiring = true; - - /** - * @var bool - */ - private $useAnnotations = false; - - /** - * @var bool - */ - private $ignorePhpDocErrors = false; - - /** - * If true, write the proxies to disk to improve performances. - * @var bool - */ - private $writeProxiesToFile = false; - - /** - * Directory where to write the proxies (if $writeProxiesToFile is enabled). - * @var string|null - */ - private $proxyDirectory; - - /** - * If PHP-DI is wrapped in another container, this references the wrapper. - * @var ContainerInterface - */ - private $wrapperContainer; - - /** - * @var DefinitionSource[]|string[]|array[] - */ - private $definitionSources = []; - - /** - * Whether the container has already been built. - * @var bool - */ - private $locked = false; - - /** - * @var string|null - */ - private $compileToDirectory; - - /** - * @var bool - */ - private $sourceCache = false; - - /** - * @var string - */ - protected $sourceCacheNamespace; - - /** - * Build a container configured for the dev environment. - */ - public static function buildDevContainer() : Container - { - return new Container; - } - - /** - * @param string $containerClass Name of the container class, used to create the container. - */ - public function __construct(string $containerClass = Container::class) - { - $this->containerClass = $containerClass; - } - - /** - * Build and return a container. - * - * @return Container - */ - public function build() - { - $sources = array_reverse($this->definitionSources); - - if ($this->useAnnotations) { - $autowiring = new AnnotationBasedAutowiring($this->ignorePhpDocErrors); - $sources[] = $autowiring; - } elseif ($this->useAutowiring) { - $autowiring = new ReflectionBasedAutowiring; - $sources[] = $autowiring; - } else { - $autowiring = new NoAutowiring; - } - - $sources = array_map(function ($definitions) use ($autowiring) { - if (is_string($definitions)) { - // File - return new DefinitionFile($definitions, $autowiring); - } elseif (is_array($definitions)) { - return new DefinitionArray($definitions, $autowiring); - } - - return $definitions; - }, $sources); - $source = new SourceChain($sources); - - // Mutable definition source - $source->setMutableDefinitionSource(new DefinitionArray([], $autowiring)); - - if ($this->sourceCache) { - if (!SourceCache::isSupported()) { - throw new \Exception('APCu is not enabled, PHP-DI cannot use it as a cache'); - } - // Wrap the source with the cache decorator - $source = new SourceCache($source, $this->sourceCacheNamespace); - } - - $proxyFactory = new ProxyFactory( - $this->writeProxiesToFile, - $this->proxyDirectory - ); - - $this->locked = true; - - $containerClass = $this->containerClass; - - if ($this->compileToDirectory) { - $compiler = new Compiler($proxyFactory); - $compiledContainerFile = $compiler->compile( - $source, - $this->compileToDirectory, - $containerClass, - $this->containerParentClass, - $this->useAutowiring || $this->useAnnotations - ); - // Only load the file if it hasn't been already loaded - // (the container can be created multiple times in the same process) - if (!class_exists($containerClass, false)) { - require $compiledContainerFile; - } - } - - return new $containerClass($source, $proxyFactory, $this->wrapperContainer); - } - - /** - * Compile the container for optimum performances. - * - * Be aware that the container is compiled once and never updated! - * - * Therefore: - * - * - in production you should clear that directory every time you deploy - * - in development you should not compile the container - * - * @see https://php-di.org/doc/performances.html - * - * @param string $directory Directory in which to put the compiled container. - * @param string $containerClass Name of the compiled class. Customize only if necessary. - * @param string $containerParentClass Name of the compiled container parent class. Customize only if necessary. - */ - public function enableCompilation( - string $directory, - string $containerClass = 'CompiledContainer', - string $containerParentClass = CompiledContainer::class - ) : self { - $this->ensureNotLocked(); - - $this->compileToDirectory = $directory; - $this->containerClass = $containerClass; - $this->containerParentClass = $containerParentClass; - - return $this; - } - - /** - * Enable or disable the use of autowiring to guess injections. - * - * Enabled by default. - * - * @return $this - */ - public function useAutowiring(bool $bool) : self - { - $this->ensureNotLocked(); - - $this->useAutowiring = $bool; - - return $this; - } - - /** - * Enable or disable the use of annotations to guess injections. - * - * Disabled by default. - * - * @return $this - */ - public function useAnnotations(bool $bool) : self - { - $this->ensureNotLocked(); - - $this->useAnnotations = $bool; - - return $this; - } - - /** - * Enable or disable ignoring phpdoc errors (non-existent classes in `@param` or `@var`). - * - * @return $this - */ - public function ignorePhpDocErrors(bool $bool) : self - { - $this->ensureNotLocked(); - - $this->ignorePhpDocErrors = $bool; - - return $this; - } - - /** - * Configure the proxy generation. - * - * For dev environment, use `writeProxiesToFile(false)` (default configuration) - * For production environment, use `writeProxiesToFile(true, 'tmp/proxies')` - * - * @see https://php-di.org/doc/lazy-injection.html - * - * @param bool $writeToFile If true, write the proxies to disk to improve performances - * @param string|null $proxyDirectory Directory where to write the proxies - * @throws InvalidArgumentException when writeToFile is set to true and the proxy directory is null - * @return $this - */ - public function writeProxiesToFile(bool $writeToFile, string $proxyDirectory = null) : self - { - $this->ensureNotLocked(); - - $this->writeProxiesToFile = $writeToFile; - - if ($writeToFile && $proxyDirectory === null) { - throw new InvalidArgumentException( - 'The proxy directory must be specified if you want to write proxies on disk' - ); - } - $this->proxyDirectory = $proxyDirectory; - - return $this; - } - - /** - * If PHP-DI's container is wrapped by another container, we can - * set this so that PHP-DI will use the wrapper rather than itself for building objects. - * - * @return $this - */ - public function wrapContainer(ContainerInterface $otherContainer) : self - { - $this->ensureNotLocked(); - - $this->wrapperContainer = $otherContainer; - - return $this; - } - - /** - * Add definitions to the container. - * - * @param string|array|DefinitionSource ...$definitions Can be an array of definitions, the - * name of a file containing definitions - * or a DefinitionSource object. - * @return $this - */ - public function addDefinitions(...$definitions) : self - { - $this->ensureNotLocked(); - - foreach ($definitions as $definition) { - if (!is_string($definition) && !is_array($definition) && !($definition instanceof DefinitionSource)) { - throw new InvalidArgumentException(sprintf( - '%s parameter must be a string, an array or a DefinitionSource object, %s given', - 'ContainerBuilder::addDefinitions()', - is_object($definition) ? get_class($definition) : gettype($definition) - )); - } - - $this->definitionSources[] = $definition; - } - - return $this; - } - - /** - * Enables the use of APCu to cache definitions. - * - * You must have APCu enabled to use it. - * - * Before using this feature, you should try these steps first: - * - enable compilation if not already done (see `enableCompilation()`) - * - if you use autowiring or annotations, add all the classes you are using into your configuration so that - * PHP-DI knows about them and compiles them - * Once this is done, you can try to optimize performances further with APCu. It can also be useful if you use - * `Container::make()` instead of `get()` (`make()` calls cannot be compiled so they are not optimized). - * - * Remember to clear APCu on each deploy else your application will have a stale cache. Do not enable the cache - * in development environment: any change you will make to the code will be ignored because of the cache. - * - * @see https://php-di.org/doc/performances.html - * - * @param string $cacheNamespace use unique namespace per container when sharing a single APC memory pool to prevent cache collisions - * @return $this - */ - public function enableDefinitionCache(string $cacheNamespace = '') : self - { - $this->ensureNotLocked(); - - $this->sourceCache = true; - $this->sourceCacheNamespace = $cacheNamespace; - - return $this; - } - - /** - * Are we building a compiled container? - */ - public function isCompilationEnabled() : bool - { - return (bool) $this->compileToDirectory; - } - - private function ensureNotLocked() - { - if ($this->locked) { - throw new \LogicException('The ContainerBuilder cannot be modified after the container has been built'); - } - } -} diff --git a/vendor/php-di/php-di/src/Definition/ArrayDefinition.php b/vendor/php-di/php-di/src/Definition/ArrayDefinition.php deleted file mode 100644 index ef77100..0000000 --- a/vendor/php-di/php-di/src/Definition/ArrayDefinition.php +++ /dev/null @@ -1,73 +0,0 @@ - - */ -class ArrayDefinition implements Definition -{ - /** - * Entry name. - * @var string - */ - private $name = ''; - - /** - * @var array - */ - private $values; - - public function __construct(array $values) - { - $this->values = $values; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - public function getValues() : array - { - return $this->values; - } - - public function replaceNestedDefinitions(callable $replacer) - { - $this->values = array_map($replacer, $this->values); - } - - public function __toString() - { - $str = '[' . \PHP_EOL; - - foreach ($this->values as $key => $value) { - if (is_string($key)) { - $key = "'" . $key . "'"; - } - - $str .= ' ' . $key . ' => '; - - if ($value instanceof Definition) { - $str .= str_replace(\PHP_EOL, \PHP_EOL . ' ', (string) $value); - } else { - $str .= var_export($value, true); - } - - $str .= ',' . \PHP_EOL; - } - - return $str . ']'; - } -} diff --git a/vendor/php-di/php-di/src/Definition/ArrayDefinitionExtension.php b/vendor/php-di/php-di/src/Definition/ArrayDefinitionExtension.php deleted file mode 100644 index b494873..0000000 --- a/vendor/php-di/php-di/src/Definition/ArrayDefinitionExtension.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ -class ArrayDefinitionExtension extends ArrayDefinition implements ExtendsPreviousDefinition -{ - /** - * @var ArrayDefinition - */ - private $subDefinition; - - public function getValues() : array - { - if (! $this->subDefinition) { - return parent::getValues(); - } - - return array_merge($this->subDefinition->getValues(), parent::getValues()); - } - - public function setExtendedDefinition(Definition $definition) - { - if (! $definition instanceof ArrayDefinition) { - throw new InvalidDefinition(sprintf( - 'Definition %s tries to add array entries but the previous definition is not an array', - $this->getName() - )); - } - - $this->subDefinition = $definition; - } -} diff --git a/vendor/php-di/php-di/src/Definition/AutowireDefinition.php b/vendor/php-di/php-di/src/Definition/AutowireDefinition.php deleted file mode 100644 index 25dc3ec..0000000 --- a/vendor/php-di/php-di/src/Definition/AutowireDefinition.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -class AutowireDefinition extends ObjectDefinition -{ -} diff --git a/vendor/php-di/php-di/src/Definition/DecoratorDefinition.php b/vendor/php-di/php-di/src/Definition/DecoratorDefinition.php deleted file mode 100644 index 4489485..0000000 --- a/vendor/php-di/php-di/src/Definition/DecoratorDefinition.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ -class DecoratorDefinition extends FactoryDefinition implements Definition, ExtendsPreviousDefinition -{ - /** - * @var Definition|null - */ - private $decorated; - - public function setExtendedDefinition(Definition $definition) - { - $this->decorated = $definition; - } - - /** - * @return Definition|null - */ - public function getDecoratedDefinition() - { - return $this->decorated; - } - - public function replaceNestedDefinitions(callable $replacer) - { - // no nested definitions - } - - public function __toString() - { - return 'Decorate(' . $this->getName() . ')'; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Definition.php b/vendor/php-di/php-di/src/Definition/Definition.php deleted file mode 100644 index 696838d..0000000 --- a/vendor/php-di/php-di/src/Definition/Definition.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -interface Definition extends RequestedEntry -{ - /** - * Returns the name of the entry in the container. - */ - public function getName() : string; - - /** - * Set the name of the entry in the container. - */ - public function setName(string $name); - - /** - * Apply a callable that replaces the definitions nested in this definition. - */ - public function replaceNestedDefinitions(callable $replacer); - - /** - * Definitions can be cast to string for debugging information. - */ - public function __toString(); -} diff --git a/vendor/php-di/php-di/src/Definition/Dumper/ObjectDefinitionDumper.php b/vendor/php-di/php-di/src/Definition/Dumper/ObjectDefinitionDumper.php deleted file mode 100644 index b99695f..0000000 --- a/vendor/php-di/php-di/src/Definition/Dumper/ObjectDefinitionDumper.php +++ /dev/null @@ -1,135 +0,0 @@ - - */ -class ObjectDefinitionDumper -{ - /** - * Returns the definition as string representation. - */ - public function dump(ObjectDefinition $definition) : string - { - $className = $definition->getClassName(); - $classExist = class_exists($className) || interface_exists($className); - - // Class - if (! $classExist) { - $warning = '#UNKNOWN# '; - } else { - $class = new \ReflectionClass($className); - $warning = $class->isInstantiable() ? '' : '#NOT INSTANTIABLE# '; - } - $str = sprintf(' class = %s%s', $warning, $className); - - // Lazy - $str .= \PHP_EOL . ' lazy = ' . var_export($definition->isLazy(), true); - - if ($classExist) { - // Constructor - $str .= $this->dumpConstructor($className, $definition); - - // Properties - $str .= $this->dumpProperties($definition); - - // Methods - $str .= $this->dumpMethods($className, $definition); - } - - return sprintf('Object (' . \PHP_EOL . '%s' . \PHP_EOL . ')', $str); - } - - private function dumpConstructor(string $className, ObjectDefinition $definition) : string - { - $str = ''; - - $constructorInjection = $definition->getConstructorInjection(); - - if ($constructorInjection !== null) { - $parameters = $this->dumpMethodParameters($className, $constructorInjection); - - $str .= sprintf(\PHP_EOL . ' __construct(' . \PHP_EOL . ' %s' . \PHP_EOL . ' )', $parameters); - } - - return $str; - } - - private function dumpProperties(ObjectDefinition $definition) : string - { - $str = ''; - - foreach ($definition->getPropertyInjections() as $propertyInjection) { - $value = $propertyInjection->getValue(); - $valueStr = $value instanceof Definition ? (string) $value : var_export($value, true); - - $str .= sprintf(\PHP_EOL . ' $%s = %s', $propertyInjection->getPropertyName(), $valueStr); - } - - return $str; - } - - private function dumpMethods(string $className, ObjectDefinition $definition) : string - { - $str = ''; - - foreach ($definition->getMethodInjections() as $methodInjection) { - $parameters = $this->dumpMethodParameters($className, $methodInjection); - - $str .= sprintf(\PHP_EOL . ' %s(' . \PHP_EOL . ' %s' . \PHP_EOL . ' )', $methodInjection->getMethodName(), $parameters); - } - - return $str; - } - - private function dumpMethodParameters(string $className, MethodInjection $methodInjection) : string - { - $methodReflection = new \ReflectionMethod($className, $methodInjection->getMethodName()); - - $args = []; - - $definitionParameters = $methodInjection->getParameters(); - - foreach ($methodReflection->getParameters() as $index => $parameter) { - if (array_key_exists($index, $definitionParameters)) { - $value = $definitionParameters[$index]; - $valueStr = $value instanceof Definition ? (string) $value : var_export($value, true); - - $args[] = sprintf('$%s = %s', $parameter->getName(), $valueStr); - - continue; - } - - // If the parameter is optional and wasn't specified, we take its default value - if ($parameter->isOptional()) { - try { - $value = $parameter->getDefaultValue(); - - $args[] = sprintf( - '$%s = (default value) %s', - $parameter->getName(), - var_export($value, true) - ); - continue; - } catch (ReflectionException $e) { - // The default value can't be read through Reflection because it is a PHP internal class - } - } - - $args[] = sprintf('$%s = #UNDEFINED#', $parameter->getName()); - } - - return implode(\PHP_EOL . ' ', $args); - } -} diff --git a/vendor/php-di/php-di/src/Definition/EnvironmentVariableDefinition.php b/vendor/php-di/php-di/src/Definition/EnvironmentVariableDefinition.php deleted file mode 100644 index b2a80c3..0000000 --- a/vendor/php-di/php-di/src/Definition/EnvironmentVariableDefinition.php +++ /dev/null @@ -1,112 +0,0 @@ - - */ -class EnvironmentVariableDefinition implements Definition -{ - /** - * Entry name. - * @var string - */ - private $name = ''; - - /** - * The name of the environment variable. - * @var string - */ - private $variableName; - - /** - * Whether or not the environment variable definition is optional. - * - * If true and the environment variable given by $variableName has not been - * defined, $defaultValue is used. - * - * @var bool - */ - private $isOptional; - - /** - * The default value to use if the environment variable is optional and not provided. - * @var mixed - */ - private $defaultValue; - - /** - * @param string $variableName The name of the environment variable - * @param bool $isOptional Whether or not the environment variable definition is optional - * @param mixed $defaultValue The default value to use if the environment variable is optional and not provided - */ - public function __construct(string $variableName, bool $isOptional = false, $defaultValue = null) - { - $this->variableName = $variableName; - $this->isOptional = $isOptional; - $this->defaultValue = $defaultValue; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return string The name of the environment variable - */ - public function getVariableName() : string - { - return $this->variableName; - } - - /** - * @return bool Whether or not the environment variable definition is optional - */ - public function isOptional() : bool - { - return $this->isOptional; - } - - /** - * @return mixed The default value to use if the environment variable is optional and not provided - */ - public function getDefaultValue() - { - return $this->defaultValue; - } - - public function replaceNestedDefinitions(callable $replacer) - { - $this->defaultValue = $replacer($this->defaultValue); - } - - public function __toString() - { - $str = ' variable = ' . $this->variableName . \PHP_EOL - . ' optional = ' . ($this->isOptional ? 'yes' : 'no'); - - if ($this->isOptional) { - if ($this->defaultValue instanceof Definition) { - $nestedDefinition = (string) $this->defaultValue; - $defaultValueStr = str_replace(\PHP_EOL, \PHP_EOL . ' ', $nestedDefinition); - } else { - $defaultValueStr = var_export($this->defaultValue, true); - } - - $str .= \PHP_EOL . ' default = ' . $defaultValueStr; - } - - return sprintf('Environment variable (' . \PHP_EOL . '%s' . \PHP_EOL . ')', $str); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Exception/InvalidAnnotation.php b/vendor/php-di/php-di/src/Definition/Exception/InvalidAnnotation.php deleted file mode 100644 index 630c34a..0000000 --- a/vendor/php-di/php-di/src/Definition/Exception/InvalidAnnotation.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -class InvalidAnnotation extends InvalidDefinition -{ -} diff --git a/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php b/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php deleted file mode 100644 index f00d93e..0000000 --- a/vendor/php-di/php-di/src/Definition/Exception/InvalidDefinition.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class InvalidDefinition extends \Exception implements ContainerExceptionInterface -{ - public static function create(Definition $definition, string $message, \Exception $previous = null) : self - { - return new self(sprintf( - '%s' . \PHP_EOL . 'Full definition:' . \PHP_EOL . '%s', - $message, - (string) $definition - ), 0, $previous); - } -} diff --git a/vendor/php-di/php-di/src/Definition/ExtendsPreviousDefinition.php b/vendor/php-di/php-di/src/Definition/ExtendsPreviousDefinition.php deleted file mode 100644 index 0b26933..0000000 --- a/vendor/php-di/php-di/src/Definition/ExtendsPreviousDefinition.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ -interface ExtendsPreviousDefinition extends Definition -{ - public function setExtendedDefinition(Definition $definition); -} diff --git a/vendor/php-di/php-di/src/Definition/FactoryDefinition.php b/vendor/php-di/php-di/src/Definition/FactoryDefinition.php deleted file mode 100644 index ed0936f..0000000 --- a/vendor/php-di/php-di/src/Definition/FactoryDefinition.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ -class FactoryDefinition implements Definition -{ - /** - * Entry name. - * @var string - */ - private $name; - - /** - * Callable that returns the value. - * @var callable - */ - private $factory; - - /** - * Factory parameters. - * @var mixed[] - */ - private $parameters = []; - - /** - * @param string $name Entry name - * @param callable $factory Callable that returns the value associated to the entry name. - * @param array $parameters Parameters to be passed to the callable - */ - public function __construct(string $name, $factory, array $parameters = []) - { - $this->name = $name; - $this->factory = $factory; - $this->parameters = $parameters; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return callable Callable that returns the value associated to the entry name. - */ - public function getCallable() - { - return $this->factory; - } - - /** - * @return array Array containing the parameters to be passed to the callable, indexed by name. - */ - public function getParameters() : array - { - return $this->parameters; - } - - public function replaceNestedDefinitions(callable $replacer) - { - $this->parameters = array_map($replacer, $this->parameters); - } - - public function __toString() - { - return 'Factory'; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Helper/AutowireDefinitionHelper.php b/vendor/php-di/php-di/src/Definition/Helper/AutowireDefinitionHelper.php deleted file mode 100644 index 8dfa4e2..0000000 --- a/vendor/php-di/php-di/src/Definition/Helper/AutowireDefinitionHelper.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -class AutowireDefinitionHelper extends CreateDefinitionHelper -{ - const DEFINITION_CLASS = AutowireDefinition::class; - - /** - * Defines a value for a specific argument of the constructor. - * - * This method is usually used together with annotations or autowiring, when a parameter - * is not (or cannot be) type-hinted. Using this method instead of constructor() allows to - * avoid defining all the parameters (letting them being resolved using annotations or autowiring) - * and only define one. - * - * @param string|int $parameter Parameter name of position for which the value will be given. - * @param mixed $value Value to give to this parameter. - * - * @return $this - */ - public function constructorParameter($parameter, $value) - { - $this->constructor[$parameter] = $value; - - return $this; - } - - /** - * Defines a method to call and a value for a specific argument. - * - * This method is usually used together with annotations or autowiring, when a parameter - * is not (or cannot be) type-hinted. Using this method instead of method() allows to - * avoid defining all the parameters (letting them being resolved using annotations or - * autowiring) and only define one. - * - * If multiple calls to the method have been configured already (e.g. in a previous definition) - * then this method only overrides the parameter for the *first* call. - * - * @param string $method Name of the method to call. - * @param string|int $parameter Parameter name of position for which the value will be given. - * @param mixed $value Value to give to this parameter. - * - * @return $this - */ - public function methodParameter(string $method, $parameter, $value) - { - // Special case for the constructor - if ($method === '__construct') { - $this->constructor[$parameter] = $value; - - return $this; - } - - if (! isset($this->methods[$method])) { - $this->methods[$method] = [0 => []]; - } - - $this->methods[$method][0][$parameter] = $value; - - return $this; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Helper/CreateDefinitionHelper.php b/vendor/php-di/php-di/src/Definition/Helper/CreateDefinitionHelper.php deleted file mode 100644 index aeae071..0000000 --- a/vendor/php-di/php-di/src/Definition/Helper/CreateDefinitionHelper.php +++ /dev/null @@ -1,202 +0,0 @@ - - */ -class CreateDefinitionHelper implements DefinitionHelper -{ - const DEFINITION_CLASS = ObjectDefinition::class; - - /** - * @var string|null - */ - private $className; - - /** - * @var bool|null - */ - private $lazy; - - /** - * Array of constructor parameters. - * @var array - */ - protected $constructor = []; - - /** - * Array of properties and their value. - * @var array - */ - private $properties = []; - - /** - * Array of methods and their parameters. - * @var array - */ - protected $methods = []; - - /** - * Helper for defining an object. - * - * @param string|null $className Class name of the object. - * If null, the name of the entry (in the container) will be used as class name. - */ - public function __construct(string $className = null) - { - $this->className = $className; - } - - /** - * Define the entry as lazy. - * - * A lazy entry is created only when it is used, a proxy is injected instead. - * - * @return $this - */ - public function lazy() - { - $this->lazy = true; - - return $this; - } - - /** - * Defines the arguments to use to call the constructor. - * - * This method takes a variable number of arguments, example: - * ->constructor($param1, $param2, $param3) - * - * @param mixed... $parameters Parameters to use for calling the constructor of the class. - * - * @return $this - */ - public function constructor(...$parameters) - { - $this->constructor = $parameters; - - return $this; - } - - /** - * Defines a value to inject in a property of the object. - * - * @param string $property Entry in which to inject the value. - * @param mixed $value Value to inject in the property. - * - * @return $this - */ - public function property(string $property, $value) - { - $this->properties[$property] = $value; - - return $this; - } - - /** - * Defines a method to call and the arguments to use. - * - * This method takes a variable number of arguments after the method name, example: - * - * ->method('myMethod', $param1, $param2) - * - * Can be used multiple times to declare multiple calls. - * - * @param string $method Name of the method to call. - * @param mixed... $parameters Parameters to use for calling the method. - * - * @return $this - */ - public function method(string $method, ...$parameters) - { - if (! isset($this->methods[$method])) { - $this->methods[$method] = []; - } - - $this->methods[$method][] = $parameters; - - return $this; - } - - /** - * @return ObjectDefinition - */ - public function getDefinition(string $entryName) : Definition - { - $class = $this::DEFINITION_CLASS; - /** @var ObjectDefinition $definition */ - $definition = new $class($entryName, $this->className); - - if ($this->lazy !== null) { - $definition->setLazy($this->lazy); - } - - if (! empty($this->constructor)) { - $parameters = $this->fixParameters($definition, '__construct', $this->constructor); - $constructorInjection = MethodInjection::constructor($parameters); - $definition->setConstructorInjection($constructorInjection); - } - - if (! empty($this->properties)) { - foreach ($this->properties as $property => $value) { - $definition->addPropertyInjection( - new PropertyInjection($property, $value) - ); - } - } - - if (! empty($this->methods)) { - foreach ($this->methods as $method => $calls) { - foreach ($calls as $parameters) { - $parameters = $this->fixParameters($definition, $method, $parameters); - $methodInjection = new MethodInjection($method, $parameters); - $definition->addMethodInjection($methodInjection); - } - } - } - - return $definition; - } - - /** - * Fixes parameters indexed by the parameter name -> reindex by position. - * - * This is necessary so that merging definitions between sources is possible. - * - * @throws InvalidDefinition - */ - private function fixParameters(ObjectDefinition $definition, string $method, array $parameters) : array - { - $fixedParameters = []; - - foreach ($parameters as $index => $parameter) { - // Parameter indexed by the parameter name, we reindex it with its position - if (is_string($index)) { - $callable = [$definition->getClassName(), $method]; - - try { - $reflectionParameter = new \ReflectionParameter($callable, $index); - } catch (\ReflectionException $e) { - throw InvalidDefinition::create($definition, sprintf("Parameter with name '%s' could not be found. %s.", $index, $e->getMessage())); - } - - $index = $reflectionParameter->getPosition(); - } - - $fixedParameters[$index] = $parameter; - } - - return $fixedParameters; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Helper/DefinitionHelper.php b/vendor/php-di/php-di/src/Definition/Helper/DefinitionHelper.php deleted file mode 100644 index 327167e..0000000 --- a/vendor/php-di/php-di/src/Definition/Helper/DefinitionHelper.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -interface DefinitionHelper -{ - /** - * @param string $entryName Container entry name - */ - public function getDefinition(string $entryName) : Definition; -} diff --git a/vendor/php-di/php-di/src/Definition/Helper/FactoryDefinitionHelper.php b/vendor/php-di/php-di/src/Definition/Helper/FactoryDefinitionHelper.php deleted file mode 100644 index 0a22319..0000000 --- a/vendor/php-di/php-di/src/Definition/Helper/FactoryDefinitionHelper.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ -class FactoryDefinitionHelper implements DefinitionHelper -{ - /** - * @var callable - */ - private $factory; - - /** - * @var bool - */ - private $decorate; - - /** - * @var array - */ - private $parameters = []; - - /** - * @param callable $factory - * @param bool $decorate Is the factory decorating a previous definition? - */ - public function __construct($factory, bool $decorate = false) - { - $this->factory = $factory; - $this->decorate = $decorate; - } - - /** - * @param string $entryName Container entry name - * @return FactoryDefinition - */ - public function getDefinition(string $entryName) : Definition - { - if ($this->decorate) { - return new DecoratorDefinition($entryName, $this->factory, $this->parameters); - } - - return new FactoryDefinition($entryName, $this->factory, $this->parameters); - } - - /** - * Defines arguments to pass to the factory. - * - * Because factory methods do not yet support annotations or autowiring, this method - * should be used to define all parameters except the ContainerInterface and RequestedEntry. - * - * Multiple calls can be made to the method to override individual values. - * - * @param string $parameter Name or index of the parameter for which the value will be given. - * @param mixed $value Value to give to this parameter. - * - * @return $this - */ - public function parameter(string $parameter, $value) - { - $this->parameters[$parameter] = $value; - - return $this; - } -} diff --git a/vendor/php-di/php-di/src/Definition/InstanceDefinition.php b/vendor/php-di/php-di/src/Definition/InstanceDefinition.php deleted file mode 100644 index 4c281c6..0000000 --- a/vendor/php-di/php-di/src/Definition/InstanceDefinition.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class InstanceDefinition implements Definition -{ - /** - * Instance on which to inject dependencies. - * - * @var object - */ - private $instance; - - /** - * @var ObjectDefinition - */ - private $objectDefinition; - - /** - * @param object $instance - */ - public function __construct($instance, ObjectDefinition $objectDefinition) - { - $this->instance = $instance; - $this->objectDefinition = $objectDefinition; - } - - public function getName() : string - { - // Name are superfluous for instance definitions - return ''; - } - - public function setName(string $name) - { - // Name are superfluous for instance definitions - } - - /** - * @return object - */ - public function getInstance() - { - return $this->instance; - } - - public function getObjectDefinition() : ObjectDefinition - { - return $this->objectDefinition; - } - - public function replaceNestedDefinitions(callable $replacer) - { - $this->objectDefinition->replaceNestedDefinitions($replacer); - } - - public function __toString() - { - return 'Instance'; - } -} diff --git a/vendor/php-di/php-di/src/Definition/ObjectDefinition.php b/vendor/php-di/php-di/src/Definition/ObjectDefinition.php deleted file mode 100644 index 8d8d5b6..0000000 --- a/vendor/php-di/php-di/src/Definition/ObjectDefinition.php +++ /dev/null @@ -1,266 +0,0 @@ - - */ -class ObjectDefinition implements Definition -{ - /** - * Entry name (most of the time, same as $classname). - * @var string - */ - private $name; - - /** - * Class name (if null, then the class name is $name). - * @var string|null - */ - protected $className; - - /** - * Constructor parameter injection. - * @var MethodInjection|null - */ - protected $constructorInjection; - - /** - * Property injections. - * @var PropertyInjection[] - */ - protected $propertyInjections = []; - - /** - * Method calls. - * @var MethodInjection[][] - */ - protected $methodInjections = []; - - /** - * @var bool|null - */ - protected $lazy; - - /** - * Store if the class exists. Storing it (in cache) avoids recomputing this. - * - * @var bool - */ - private $classExists; - - /** - * Store if the class is instantiable. Storing it (in cache) avoids recomputing this. - * - * @var bool - */ - private $isInstantiable; - - /** - * @param string $name Entry name - */ - public function __construct(string $name, string $className = null) - { - $this->name = $name; - $this->setClassName($className); - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - public function setClassName(string $className = null) - { - $this->className = $className; - - $this->updateCache(); - } - - public function getClassName() : string - { - if ($this->className !== null) { - return $this->className; - } - - return $this->name; - } - - /** - * @return MethodInjection|null - */ - public function getConstructorInjection() - { - return $this->constructorInjection; - } - - public function setConstructorInjection(MethodInjection $constructorInjection) - { - $this->constructorInjection = $constructorInjection; - } - - public function completeConstructorInjection(MethodInjection $injection) - { - if ($this->constructorInjection !== null) { - // Merge - $this->constructorInjection->merge($injection); - } else { - // Set - $this->constructorInjection = $injection; - } - } - - /** - * @return PropertyInjection[] Property injections - */ - public function getPropertyInjections() : array - { - return $this->propertyInjections; - } - - public function addPropertyInjection(PropertyInjection $propertyInjection) - { - $className = $propertyInjection->getClassName(); - if ($className) { - // Index with the class name to avoid collisions between parent and - // child private properties with the same name - $key = $className . '::' . $propertyInjection->getPropertyName(); - } else { - $key = $propertyInjection->getPropertyName(); - } - - $this->propertyInjections[$key] = $propertyInjection; - } - - /** - * @return MethodInjection[] Method injections - */ - public function getMethodInjections() : array - { - // Return array leafs - $injections = []; - array_walk_recursive($this->methodInjections, function ($injection) use (&$injections) { - $injections[] = $injection; - }); - - return $injections; - } - - public function addMethodInjection(MethodInjection $methodInjection) - { - $method = $methodInjection->getMethodName(); - if (! isset($this->methodInjections[$method])) { - $this->methodInjections[$method] = []; - } - $this->methodInjections[$method][] = $methodInjection; - } - - public function completeFirstMethodInjection(MethodInjection $injection) - { - $method = $injection->getMethodName(); - - if (isset($this->methodInjections[$method][0])) { - // Merge - $this->methodInjections[$method][0]->merge($injection); - } else { - // Set - $this->addMethodInjection($injection); - } - } - - public function setLazy(bool $lazy = null) - { - $this->lazy = $lazy; - } - - public function isLazy() : bool - { - if ($this->lazy !== null) { - return $this->lazy; - } - // Default value - return false; - } - - public function classExists() : bool - { - return $this->classExists; - } - - public function isInstantiable() : bool - { - return $this->isInstantiable; - } - - public function replaceNestedDefinitions(callable $replacer) - { - array_walk($this->propertyInjections, function (PropertyInjection $propertyInjection) use ($replacer) { - $propertyInjection->replaceNestedDefinition($replacer); - }); - - if ($this->constructorInjection) { - $this->constructorInjection->replaceNestedDefinitions($replacer); - } - - array_walk($this->methodInjections, function ($injectionArray) use ($replacer) { - array_walk($injectionArray, function (MethodInjection $methodInjection) use ($replacer) { - $methodInjection->replaceNestedDefinitions($replacer); - }); - }); - } - - /** - * Replaces all the wildcards in the string with the given replacements. - * - * @param string[] $replacements - */ - public function replaceWildcards(array $replacements) - { - $className = $this->getClassName(); - - foreach ($replacements as $replacement) { - $pos = strpos($className, DefinitionArray::WILDCARD); - if ($pos !== false) { - $className = substr_replace($className, $replacement, $pos, 1); - } - } - - $this->setClassName($className); - } - - public function __toString() - { - return (new ObjectDefinitionDumper)->dump($this); - } - - private function updateCache() - { - $className = $this->getClassName(); - - $this->classExists = class_exists($className) || interface_exists($className); - - if (! $this->classExists) { - $this->isInstantiable = false; - - return; - } - - $class = new ReflectionClass($className); - $this->isInstantiable = $class->isInstantiable(); - } -} diff --git a/vendor/php-di/php-di/src/Definition/ObjectDefinition/MethodInjection.php b/vendor/php-di/php-di/src/Definition/ObjectDefinition/MethodInjection.php deleted file mode 100644 index 5fb67ce..0000000 --- a/vendor/php-di/php-di/src/Definition/ObjectDefinition/MethodInjection.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ -class MethodInjection implements Definition -{ - /** - * @var string - */ - private $methodName; - - /** - * @var mixed[] - */ - private $parameters = []; - - public function __construct(string $methodName, array $parameters = []) - { - $this->methodName = $methodName; - $this->parameters = $parameters; - } - - public static function constructor(array $parameters = []) : self - { - return new self('__construct', $parameters); - } - - public function getMethodName() : string - { - return $this->methodName; - } - - /** - * @return mixed[] - */ - public function getParameters() : array - { - return $this->parameters; - } - - /** - * Replace the parameters of the definition by a new array of parameters. - */ - public function replaceParameters(array $parameters) - { - $this->parameters = $parameters; - } - - public function merge(self $definition) - { - // In case of conflicts, the current definition prevails. - $this->parameters = $this->parameters + $definition->parameters; - } - - public function getName() : string - { - return ''; - } - - public function setName(string $name) - { - // The name does not matter for method injections - } - - public function replaceNestedDefinitions(callable $replacer) - { - $this->parameters = array_map($replacer, $this->parameters); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return sprintf('method(%s)', $this->methodName); - } -} diff --git a/vendor/php-di/php-di/src/Definition/ObjectDefinition/PropertyInjection.php b/vendor/php-di/php-di/src/Definition/ObjectDefinition/PropertyInjection.php deleted file mode 100644 index 307ba64..0000000 --- a/vendor/php-di/php-di/src/Definition/ObjectDefinition/PropertyInjection.php +++ /dev/null @@ -1,70 +0,0 @@ - - */ -class PropertyInjection -{ - /** - * Property name. - * @var string - */ - private $propertyName; - - /** - * Value that should be injected in the property. - * @var mixed - */ - private $value; - - /** - * Use for injecting in properties of parent classes: the class name - * must be the name of the parent class because private properties - * can be attached to the parent classes, not the one we are resolving. - * @var string|null - */ - private $className; - - /** - * @param string $propertyName Property name - * @param mixed $value Value that should be injected in the property - */ - public function __construct(string $propertyName, $value, string $className = null) - { - $this->propertyName = $propertyName; - $this->value = $value; - $this->className = $className; - } - - public function getPropertyName() : string - { - return $this->propertyName; - } - - /** - * @return mixed Value that should be injected in the property - */ - public function getValue() - { - return $this->value; - } - - /** - * @return string|null - */ - public function getClassName() - { - return $this->className; - } - - public function replaceNestedDefinition(callable $replacer) - { - $this->value = $replacer($this->value); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Reference.php b/vendor/php-di/php-di/src/Definition/Reference.php deleted file mode 100644 index 5b4597a..0000000 --- a/vendor/php-di/php-di/src/Definition/Reference.php +++ /dev/null @@ -1,73 +0,0 @@ - - */ -class Reference implements Definition, SelfResolvingDefinition -{ - /** - * Entry name. - * @var string - */ - private $name = ''; - - /** - * Name of the target entry. - * @var string - */ - private $targetEntryName; - - /** - * @param string $targetEntryName Name of the target entry - */ - public function __construct(string $targetEntryName) - { - $this->targetEntryName = $targetEntryName; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - public function getTargetEntryName() : string - { - return $this->targetEntryName; - } - - public function resolve(ContainerInterface $container) - { - return $container->get($this->getTargetEntryName()); - } - - public function isResolvable(ContainerInterface $container) : bool - { - return $container->has($this->getTargetEntryName()); - } - - public function replaceNestedDefinitions(callable $replacer) - { - // no nested definitions - } - - public function __toString() - { - return sprintf( - 'get(%s)', - $this->targetEntryName - ); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/ArrayResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/ArrayResolver.php deleted file mode 100644 index 30a715b..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/ArrayResolver.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ -class ArrayResolver implements DefinitionResolver -{ - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * @param DefinitionResolver $definitionResolver Used to resolve nested definitions. - */ - public function __construct(DefinitionResolver $definitionResolver) - { - $this->definitionResolver = $definitionResolver; - } - - /** - * Resolve an array definition to a value. - * - * An array definition can contain simple values or references to other entries. - * - * @param ArrayDefinition $definition - */ - public function resolve(Definition $definition, array $parameters = []) : array - { - $values = $definition->getValues(); - - // Resolve nested definitions - array_walk_recursive($values, function (& $value, $key) use ($definition) { - if ($value instanceof Definition) { - $value = $this->resolveDefinition($value, $definition, $key); - } - }); - - return $values; - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return true; - } - - private function resolveDefinition(Definition $value, ArrayDefinition $definition, $key) - { - try { - return $this->definitionResolver->resolve($value); - } catch (DependencyException $e) { - throw $e; - } catch (Exception $e) { - throw new DependencyException(sprintf( - 'Error while resolving %s[%s]. %s', - $definition->getName(), - $key, - $e->getMessage() - ), 0, $e); - } - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/DecoratorResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/DecoratorResolver.php deleted file mode 100644 index 03585ea..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/DecoratorResolver.php +++ /dev/null @@ -1,82 +0,0 @@ - - */ -class DecoratorResolver implements DefinitionResolver -{ - /** - * @var ContainerInterface - */ - private $container; - - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * The resolver needs a container. This container will be passed to the factory as a parameter - * so that the factory can access other entries of the container. - * - * @param DefinitionResolver $definitionResolver Used to resolve nested definitions. - */ - public function __construct(ContainerInterface $container, DefinitionResolver $definitionResolver) - { - $this->container = $container; - $this->definitionResolver = $definitionResolver; - } - - /** - * Resolve a decorator definition to a value. - * - * This will call the callable of the definition and pass it the decorated entry. - * - * @param DecoratorDefinition $definition - */ - public function resolve(Definition $definition, array $parameters = []) - { - $callable = $definition->getCallable(); - - if (! is_callable($callable)) { - throw new InvalidDefinition(sprintf( - 'The decorator "%s" is not callable', - $definition->getName() - )); - } - - $decoratedDefinition = $definition->getDecoratedDefinition(); - - if (! $decoratedDefinition instanceof Definition) { - if (! $definition->getName()) { - throw new InvalidDefinition('Decorators cannot be nested in another definition'); - } - - throw new InvalidDefinition(sprintf( - 'Entry "%s" decorates nothing: no previous definition with the same name was found', - $definition->getName() - )); - } - - $decorated = $this->definitionResolver->resolve($decoratedDefinition, $parameters); - - return call_user_func($callable, $decorated, $this->container); - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return true; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/DefinitionResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/DefinitionResolver.php deleted file mode 100644 index 56b5383..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/DefinitionResolver.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -interface DefinitionResolver -{ - /** - * Resolve a definition to a value. - * - * @param Definition $definition Object that defines how the value should be obtained. - * @param array $parameters Optional parameters to use to build the entry. - * - * @throws InvalidDefinition If the definition cannot be resolved. - * - * @return mixed Value obtained from the definition. - */ - public function resolve(Definition $definition, array $parameters = []); - - /** - * Check if a definition can be resolved. - * - * @param Definition $definition Object that defines how the value should be obtained. - * @param array $parameters Optional parameters to use to build the entry. - */ - public function isResolvable(Definition $definition, array $parameters = []) : bool; -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/EnvironmentVariableResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/EnvironmentVariableResolver.php deleted file mode 100644 index 77f5b92..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/EnvironmentVariableResolver.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ -class EnvironmentVariableResolver implements DefinitionResolver -{ - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * @var callable - */ - private $variableReader; - - public function __construct(DefinitionResolver $definitionResolver, $variableReader = null) - { - $this->definitionResolver = $definitionResolver; - $this->variableReader = $variableReader ?? [$this, 'getEnvVariable']; - } - - /** - * Resolve an environment variable definition to a value. - * - * @param EnvironmentVariableDefinition $definition - */ - public function resolve(Definition $definition, array $parameters = []) - { - $value = call_user_func($this->variableReader, $definition->getVariableName()); - - if (false !== $value) { - return $value; - } - - if (!$definition->isOptional()) { - throw new InvalidDefinition(sprintf( - "The environment variable '%s' has not been defined", - $definition->getVariableName() - )); - } - - $value = $definition->getDefaultValue(); - - // Nested definition - if ($value instanceof Definition) { - return $this->definitionResolver->resolve($value); - } - - return $value; - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return true; - } - - protected function getEnvVariable(string $variableName) - { - if (isset($_ENV[$variableName])) { - return $_ENV[$variableName]; - } elseif (isset($_SERVER[$variableName])) { - return $_SERVER[$variableName]; - } - - return getenv($variableName); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/FactoryResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/FactoryResolver.php deleted file mode 100644 index c36a1aa..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/FactoryResolver.php +++ /dev/null @@ -1,123 +0,0 @@ - - */ -class FactoryResolver implements DefinitionResolver -{ - /** - * @var ContainerInterface - */ - private $container; - - /** - * @var Invoker|null - */ - private $invoker; - - /** - * @var DefinitionResolver - */ - private $resolver; - - /** - * The resolver needs a container. This container will be passed to the factory as a parameter - * so that the factory can access other entries of the container. - */ - public function __construct(ContainerInterface $container, DefinitionResolver $resolver) - { - $this->container = $container; - $this->resolver = $resolver; - } - - /** - * Resolve a factory definition to a value. - * - * This will call the callable of the definition. - * - * @param FactoryDefinition $definition - */ - public function resolve(Definition $definition, array $parameters = []) - { - if (! $this->invoker) { - $parameterResolver = new ResolverChain([ - new AssociativeArrayResolver, - new FactoryParameterResolver($this->container), - new NumericArrayResolver, - new DefaultValueResolver, - ]); - - $this->invoker = new Invoker($parameterResolver, $this->container); - } - - $callable = $definition->getCallable(); - - try { - $providedParams = [$this->container, $definition]; - $extraParams = $this->resolveExtraParams($definition->getParameters()); - $providedParams = array_merge($providedParams, $extraParams, $parameters); - - return $this->invoker->call($callable, $providedParams); - } catch (NotCallableException $e) { - // Custom error message to help debugging - if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) { - throw new InvalidDefinition(sprintf( - 'Entry "%s" cannot be resolved: factory %s. Invokable classes cannot be automatically resolved if autowiring is disabled on the container, you need to enable autowiring or define the entry manually.', - $definition->getName(), - $e->getMessage() - )); - } - - throw new InvalidDefinition(sprintf( - 'Entry "%s" cannot be resolved: factory %s', - $definition->getName(), - $e->getMessage() - )); - } catch (NotEnoughParametersException $e) { - throw new InvalidDefinition(sprintf( - 'Entry "%s" cannot be resolved: %s', - $definition->getName(), - $e->getMessage() - )); - } - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return true; - } - - private function resolveExtraParams(array $params) : array - { - $resolved = []; - foreach ($params as $key => $value) { - // Nested definitions - if ($value instanceof Definition) { - $value = $this->resolver->resolve($value); - } - $resolved[$key] = $value; - } - - return $resolved; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/InstanceInjector.php b/vendor/php-di/php-di/src/Definition/Resolver/InstanceInjector.php deleted file mode 100644 index 60ea24a..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/InstanceInjector.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class InstanceInjector extends ObjectCreator -{ - /** - * Injects dependencies on an existing instance. - * - * @param InstanceDefinition $definition - */ - public function resolve(Definition $definition, array $parameters = []) - { - try { - $this->injectMethodsAndProperties($definition->getInstance(), $definition->getObjectDefinition()); - } catch (NotFoundExceptionInterface $e) { - $message = sprintf( - 'Error while injecting dependencies into %s: %s', - get_class($definition->getInstance()), - $e->getMessage() - ); - - throw new DependencyException($message, 0, $e); - } - - return $definition; - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return true; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php b/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php deleted file mode 100644 index 3f1f1e6..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/ObjectCreator.php +++ /dev/null @@ -1,222 +0,0 @@ - - */ -class ObjectCreator implements DefinitionResolver -{ - /** - * @var ProxyFactory - */ - private $proxyFactory; - - /** - * @var ParameterResolver - */ - private $parameterResolver; - - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * @param DefinitionResolver $definitionResolver Used to resolve nested definitions. - * @param ProxyFactory $proxyFactory Used to create proxies for lazy injections. - */ - public function __construct( - DefinitionResolver $definitionResolver, - ProxyFactory $proxyFactory - ) { - $this->definitionResolver = $definitionResolver; - $this->proxyFactory = $proxyFactory; - $this->parameterResolver = new ParameterResolver($definitionResolver); - } - - /** - * Resolve a class definition to a value. - * - * This will create a new instance of the class using the injections points defined. - * - * @param ObjectDefinition $definition - * - * @return object|null - */ - public function resolve(Definition $definition, array $parameters = []) - { - // Lazy? - if ($definition->isLazy()) { - return $this->createProxy($definition, $parameters); - } - - return $this->createInstance($definition, $parameters); - } - - /** - * The definition is not resolvable if the class is not instantiable (interface or abstract) - * or if the class doesn't exist. - * - * @param ObjectDefinition $definition - */ - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - return $definition->isInstantiable(); - } - - /** - * Returns a proxy instance. - */ - private function createProxy(ObjectDefinition $definition, array $parameters) : LazyLoadingInterface - { - /** @noinspection PhpUnusedParameterInspection */ - $proxy = $this->proxyFactory->createProxy( - $definition->getClassName(), - function (& $wrappedObject, $proxy, $method, $params, & $initializer) use ($definition, $parameters) { - $wrappedObject = $this->createInstance($definition, $parameters); - $initializer = null; // turning off further lazy initialization - - return true; - } - ); - - return $proxy; - } - - /** - * Creates an instance of the class and injects dependencies.. - * - * @param array $parameters Optional parameters to use to create the instance. - * - * @throws InvalidDefinition - * @throws DependencyException - * @return object - */ - private function createInstance(ObjectDefinition $definition, array $parameters) - { - // Check that the class is instantiable - if (! $definition->isInstantiable()) { - // Check that the class exists - if (! $definition->classExists()) { - throw InvalidDefinition::create($definition, sprintf( - 'Entry "%s" cannot be resolved: the class doesn\'t exist', - $definition->getName() - )); - } - - throw InvalidDefinition::create($definition, sprintf( - 'Entry "%s" cannot be resolved: the class is not instantiable', - $definition->getName() - )); - } - - $classname = $definition->getClassName(); - $classReflection = new ReflectionClass($classname); - - $constructorInjection = $definition->getConstructorInjection(); - - try { - $args = $this->parameterResolver->resolveParameters( - $constructorInjection, - $classReflection->getConstructor(), - $parameters - ); - - $object = new $classname(...$args); - - $this->injectMethodsAndProperties($object, $definition); - } catch (NotFoundExceptionInterface $e) { - throw new DependencyException(sprintf( - 'Error while injecting dependencies into %s: %s', - $classReflection->getName(), - $e->getMessage() - ), 0, $e); - } catch (InvalidDefinition $e) { - throw InvalidDefinition::create($definition, sprintf( - 'Entry "%s" cannot be resolved: %s', - $definition->getName(), - $e->getMessage() - )); - } - - return $object; - } - - protected function injectMethodsAndProperties($object, ObjectDefinition $objectDefinition) - { - // Property injections - foreach ($objectDefinition->getPropertyInjections() as $propertyInjection) { - $this->injectProperty($object, $propertyInjection); - } - - // Method injections - foreach ($objectDefinition->getMethodInjections() as $methodInjection) { - $methodReflection = new \ReflectionMethod($object, $methodInjection->getMethodName()); - $args = $this->parameterResolver->resolveParameters($methodInjection, $methodReflection); - - $methodReflection->invokeArgs($object, $args); - } - } - - /** - * Inject dependencies into properties. - * - * @param object $object Object to inject dependencies into - * @param PropertyInjection $propertyInjection Property injection definition - * - * @throws DependencyException - * @throws InvalidDefinition - */ - private function injectProperty($object, PropertyInjection $propertyInjection) - { - $propertyName = $propertyInjection->getPropertyName(); - - $value = $propertyInjection->getValue(); - - if ($value instanceof Definition) { - try { - $value = $this->definitionResolver->resolve($value); - } catch (DependencyException $e) { - throw $e; - } catch (Exception $e) { - throw new DependencyException(sprintf( - 'Error while injecting in %s::%s. %s', - get_class($object), - $propertyName, - $e->getMessage() - ), 0, $e); - } - } - - self::setPrivatePropertyValue($propertyInjection->getClassName(), $object, $propertyName, $value); - } - - public static function setPrivatePropertyValue(string $className = null, $object, string $propertyName, $propertyValue) - { - $className = $className ?: get_class($object); - - $property = new ReflectionProperty($className, $propertyName); - if (! $property->isPublic()) { - $property->setAccessible(true); - } - $property->setValue($object, $propertyValue); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/ParameterResolver.php b/vendor/php-di/php-di/src/Definition/Resolver/ParameterResolver.php deleted file mode 100644 index c9a4640..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/ParameterResolver.php +++ /dev/null @@ -1,112 +0,0 @@ - - */ -class ParameterResolver -{ - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - /** - * @param DefinitionResolver $definitionResolver Will be used to resolve nested definitions. - */ - public function __construct(DefinitionResolver $definitionResolver) - { - $this->definitionResolver = $definitionResolver; - } - - /** - * @throws InvalidDefinition A parameter has no value defined or guessable. - * @return array Parameters to use to call the function. - */ - public function resolveParameters( - MethodInjection $definition = null, - ReflectionMethod $method = null, - array $parameters = [] - ) { - $args = []; - - if (! $method) { - return $args; - } - - $definitionParameters = $definition ? $definition->getParameters() : []; - - foreach ($method->getParameters() as $index => $parameter) { - if (array_key_exists($parameter->getName(), $parameters)) { - // Look in the $parameters array - $value = &$parameters[$parameter->getName()]; - } elseif (array_key_exists($index, $definitionParameters)) { - // Look in the definition - $value = &$definitionParameters[$index]; - } else { - // If the parameter is optional and wasn't specified, we take its default value - if ($parameter->isDefaultValueAvailable() || $parameter->isOptional()) { - $args[] = $this->getParameterDefaultValue($parameter, $method); - continue; - } - - throw new InvalidDefinition(sprintf( - 'Parameter $%s of %s has no value defined or guessable', - $parameter->getName(), - $this->getFunctionName($method) - )); - } - - // Nested definitions - if ($value instanceof Definition) { - // If the container cannot produce the entry, we can use the default parameter value - if ($parameter->isOptional() && ! $this->definitionResolver->isResolvable($value)) { - $value = $this->getParameterDefaultValue($parameter, $method); - } else { - $value = $this->definitionResolver->resolve($value); - } - } - - $args[] = &$value; - } - - return $args; - } - - /** - * Returns the default value of a function parameter. - * - * @throws InvalidDefinition Can't get default values from PHP internal classes and functions - * @return mixed - */ - private function getParameterDefaultValue(ReflectionParameter $parameter, ReflectionMethod $function) - { - try { - return $parameter->getDefaultValue(); - } catch (\ReflectionException $e) { - throw new InvalidDefinition(sprintf( - 'The parameter "%s" of %s has no type defined or guessable. It has a default value, ' - . 'but the default value can\'t be read through Reflection because it is a PHP internal class.', - $parameter->getName(), - $this->getFunctionName($function) - )); - } - } - - private function getFunctionName(ReflectionMethod $method) : string - { - return $method->getName() . '()'; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php b/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php deleted file mode 100644 index 7c0edcc..0000000 --- a/vendor/php-di/php-di/src/Definition/Resolver/ResolverDispatcher.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ -class ResolverDispatcher implements DefinitionResolver -{ - /** - * @var ContainerInterface - */ - private $container; - - /** - * @var ProxyFactory - */ - private $proxyFactory; - - private $arrayResolver; - private $factoryResolver; - private $decoratorResolver; - private $objectResolver; - private $instanceResolver; - private $envVariableResolver; - - public function __construct(ContainerInterface $container, ProxyFactory $proxyFactory) - { - $this->container = $container; - $this->proxyFactory = $proxyFactory; - } - - /** - * Resolve a definition to a value. - * - * @param Definition $definition Object that defines how the value should be obtained. - * @param array $parameters Optional parameters to use to build the entry. - * - * @throws InvalidDefinition If the definition cannot be resolved. - * - * @return mixed Value obtained from the definition. - */ - public function resolve(Definition $definition, array $parameters = []) - { - // Special case, tested early for speed - if ($definition instanceof SelfResolvingDefinition) { - return $definition->resolve($this->container); - } - - $definitionResolver = $this->getDefinitionResolver($definition); - - return $definitionResolver->resolve($definition, $parameters); - } - - public function isResolvable(Definition $definition, array $parameters = []) : bool - { - // Special case, tested early for speed - if ($definition instanceof SelfResolvingDefinition) { - return $definition->isResolvable($this->container); - } - - $definitionResolver = $this->getDefinitionResolver($definition); - - return $definitionResolver->isResolvable($definition, $parameters); - } - - /** - * Returns a resolver capable of handling the given definition. - * - * @throws \RuntimeException No definition resolver was found for this type of definition. - */ - private function getDefinitionResolver(Definition $definition) : DefinitionResolver - { - switch (true) { - case $definition instanceof ObjectDefinition: - if (! $this->objectResolver) { - $this->objectResolver = new ObjectCreator($this, $this->proxyFactory); - } - - return $this->objectResolver; - case $definition instanceof DecoratorDefinition: - if (! $this->decoratorResolver) { - $this->decoratorResolver = new DecoratorResolver($this->container, $this); - } - - return $this->decoratorResolver; - case $definition instanceof FactoryDefinition: - if (! $this->factoryResolver) { - $this->factoryResolver = new FactoryResolver($this->container, $this); - } - - return $this->factoryResolver; - case $definition instanceof ArrayDefinition: - if (! $this->arrayResolver) { - $this->arrayResolver = new ArrayResolver($this); - } - - return $this->arrayResolver; - case $definition instanceof EnvironmentVariableDefinition: - if (! $this->envVariableResolver) { - $this->envVariableResolver = new EnvironmentVariableResolver($this); - } - - return $this->envVariableResolver; - case $definition instanceof InstanceDefinition: - if (! $this->instanceResolver) { - $this->instanceResolver = new InstanceInjector($this, $this->proxyFactory); - } - - return $this->instanceResolver; - default: - throw new \RuntimeException('No definition resolver was configured for definition of type ' . get_class($definition)); - } - } -} diff --git a/vendor/php-di/php-di/src/Definition/SelfResolvingDefinition.php b/vendor/php-di/php-di/src/Definition/SelfResolvingDefinition.php deleted file mode 100644 index 7452403..0000000 --- a/vendor/php-di/php-di/src/Definition/SelfResolvingDefinition.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -interface SelfResolvingDefinition -{ - /** - * Resolve the definition and return the resulting value. - * - * @return mixed - */ - public function resolve(ContainerInterface $container); - - /** - * Check if a definition can be resolved. - */ - public function isResolvable(ContainerInterface $container) : bool; -} diff --git a/vendor/php-di/php-di/src/Definition/Source/AnnotationBasedAutowiring.php b/vendor/php-di/php-di/src/Definition/Source/AnnotationBasedAutowiring.php deleted file mode 100644 index ee3273a..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/AnnotationBasedAutowiring.php +++ /dev/null @@ -1,297 +0,0 @@ - - */ -class AnnotationBasedAutowiring implements DefinitionSource, Autowiring -{ - /** - * @var Reader - */ - private $annotationReader; - - /** - * @var PhpDocReader - */ - private $phpDocReader; - - /** - * @var bool - */ - private $ignorePhpDocErrors; - - public function __construct($ignorePhpDocErrors = false) - { - $this->ignorePhpDocErrors = (bool) $ignorePhpDocErrors; - } - - public function autowire(string $name, ObjectDefinition $definition = null) - { - $className = $definition ? $definition->getClassName() : $name; - - if (!class_exists($className) && !interface_exists($className)) { - return $definition; - } - - $definition = $definition ?: new ObjectDefinition($name); - - $class = new ReflectionClass($className); - - $this->readInjectableAnnotation($class, $definition); - - // Browse the class properties looking for annotated properties - $this->readProperties($class, $definition); - - // Browse the object's methods looking for annotated methods - $this->readMethods($class, $definition); - - return $definition; - } - - /** - * {@inheritdoc} - * @throws InvalidAnnotation - * @throws InvalidArgumentException The class doesn't exist - */ - public function getDefinition(string $name) - { - return $this->autowire($name); - } - - /** - * Autowiring cannot guess all existing definitions. - */ - public function getDefinitions() : array - { - return []; - } - - /** - * Browse the class properties looking for annotated properties. - */ - private function readProperties(ReflectionClass $class, ObjectDefinition $definition) - { - foreach ($class->getProperties() as $property) { - if ($property->isStatic()) { - continue; - } - $this->readProperty($property, $definition); - } - - // Read also the *private* properties of the parent classes - /** @noinspection PhpAssignmentInConditionInspection */ - while ($class = $class->getParentClass()) { - foreach ($class->getProperties(ReflectionProperty::IS_PRIVATE) as $property) { - if ($property->isStatic()) { - continue; - } - $this->readProperty($property, $definition, $class->getName()); - } - } - } - - private function readProperty(ReflectionProperty $property, ObjectDefinition $definition, $classname = null) - { - // Look for @Inject annotation - $annotation = $this->getAnnotationReader()->getPropertyAnnotation($property, 'DI\Annotation\Inject'); - if (!$annotation instanceof Inject) { - return; - } - - // Try to @Inject("name") or look for @var content - $entryName = $annotation->getName() ?: $this->getPhpDocReader()->getPropertyClass($property); - - // Try using PHP7.4 typed properties - if (\PHP_VERSION_ID > 70400 - && $entryName === null - && $property->getType() instanceof ReflectionNamedType - && (class_exists($property->getType()->getName()) || interface_exists($property->getType()->getName())) - ) { - $entryName = $property->getType()->getName(); - } - - if ($entryName === null) { - throw new InvalidAnnotation(sprintf( - '@Inject found on property %s::%s but unable to guess what to inject, use a @var annotation', - $property->getDeclaringClass()->getName(), - $property->getName() - )); - } - - $definition->addPropertyInjection( - new PropertyInjection($property->getName(), new Reference($entryName), $classname) - ); - } - - /** - * Browse the object's methods looking for annotated methods. - */ - private function readMethods(ReflectionClass $class, ObjectDefinition $objectDefinition) - { - // This will look in all the methods, including those of the parent classes - foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { - if ($method->isStatic()) { - continue; - } - - $methodInjection = $this->getMethodInjection($method); - - if (! $methodInjection) { - continue; - } - - if ($method->isConstructor()) { - $objectDefinition->completeConstructorInjection($methodInjection); - } else { - $objectDefinition->completeFirstMethodInjection($methodInjection); - } - } - } - - /** - * @return MethodInjection|null - */ - private function getMethodInjection(ReflectionMethod $method) - { - // Look for @Inject annotation - try { - $annotation = $this->getAnnotationReader()->getMethodAnnotation($method, 'DI\Annotation\Inject'); - } catch (InvalidAnnotation $e) { - throw new InvalidAnnotation(sprintf( - '@Inject annotation on %s::%s is malformed. %s', - $method->getDeclaringClass()->getName(), - $method->getName(), - $e->getMessage() - ), 0, $e); - } - - // @Inject on constructor is implicit - if (! ($annotation || $method->isConstructor())) { - return null; - } - - $annotationParameters = $annotation instanceof Inject ? $annotation->getParameters() : []; - - $parameters = []; - foreach ($method->getParameters() as $index => $parameter) { - $entryName = $this->getMethodParameter($index, $parameter, $annotationParameters); - - if ($entryName !== null) { - $parameters[$index] = new Reference($entryName); - } - } - - if ($method->isConstructor()) { - return MethodInjection::constructor($parameters); - } - - return new MethodInjection($method->getName(), $parameters); - } - - /** - * @param int $parameterIndex - * - * @return string|null Entry name or null if not found. - */ - private function getMethodParameter($parameterIndex, ReflectionParameter $parameter, array $annotationParameters) - { - // @Inject has definition for this parameter (by index, or by name) - if (isset($annotationParameters[$parameterIndex])) { - return $annotationParameters[$parameterIndex]; - } - if (isset($annotationParameters[$parameter->getName()])) { - return $annotationParameters[$parameter->getName()]; - } - - // Skip optional parameters if not explicitly defined - if ($parameter->isOptional()) { - return null; - } - - // Try to use the type-hinting - $parameterType = $parameter->getType(); - if ($parameterType && $parameterType instanceof ReflectionNamedType && !$parameterType->isBuiltin()) { - return $parameterType->getName(); - } - - // Last resort, look for @param tag - return $this->getPhpDocReader()->getParameterClass($parameter); - } - - /** - * @return Reader The annotation reader - */ - public function getAnnotationReader() - { - if ($this->annotationReader === null) { - AnnotationRegistry::registerLoader('class_exists'); - $this->annotationReader = new SimpleAnnotationReader(); - $this->annotationReader->addNamespace('DI\Annotation'); - } - - return $this->annotationReader; - } - - /** - * @return PhpDocReader - */ - private function getPhpDocReader() - { - if ($this->phpDocReader === null) { - $this->phpDocReader = new PhpDocReader($this->ignorePhpDocErrors); - } - - return $this->phpDocReader; - } - - private function readInjectableAnnotation(ReflectionClass $class, ObjectDefinition $definition) - { - try { - /** @var Injectable|null $annotation */ - $annotation = $this->getAnnotationReader() - ->getClassAnnotation($class, 'DI\Annotation\Injectable'); - } catch (UnexpectedValueException $e) { - throw new InvalidAnnotation(sprintf( - 'Error while reading @Injectable on %s: %s', - $class->getName(), - $e->getMessage() - ), 0, $e); - } - - if (! $annotation) { - return; - } - - if ($annotation->isLazy() !== null) { - $definition->setLazy($annotation->isLazy()); - } - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/Autowiring.php b/vendor/php-di/php-di/src/Definition/Source/Autowiring.php deleted file mode 100644 index ae7682a..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/Autowiring.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -interface Autowiring -{ - /** - * Autowire the given definition. - * - * @throws InvalidDefinition An invalid definition was found. - * @return ObjectDefinition|null - */ - public function autowire(string $name, ObjectDefinition $definition = null); -} diff --git a/vendor/php-di/php-di/src/Definition/Source/DefinitionArray.php b/vendor/php-di/php-di/src/Definition/Source/DefinitionArray.php deleted file mode 100644 index 88f2cac..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/DefinitionArray.php +++ /dev/null @@ -1,127 +0,0 @@ - - */ -class DefinitionArray implements DefinitionSource, MutableDefinitionSource -{ - const WILDCARD = '*'; - /** - * Matches anything except "\". - */ - const WILDCARD_PATTERN = '([^\\\\]+)'; - - /** - * DI definitions in a PHP array. - * @var array - */ - private $definitions = []; - - /** - * Cache of wildcard definitions. - * @var array|null - */ - private $wildcardDefinitions; - - /** - * @var DefinitionNormalizer - */ - private $normalizer; - - public function __construct(array $definitions = [], Autowiring $autowiring = null) - { - if (isset($definitions[0])) { - throw new \Exception('The PHP-DI definition is not indexed by an entry name in the definition array'); - } - - $this->definitions = $definitions; - - $autowiring = $autowiring ?: new NoAutowiring; - $this->normalizer = new DefinitionNormalizer($autowiring); - } - - /** - * @param array $definitions DI definitions in a PHP array indexed by the definition name. - */ - public function addDefinitions(array $definitions) - { - if (isset($definitions[0])) { - throw new \Exception('The PHP-DI definition is not indexed by an entry name in the definition array'); - } - - // The newly added data prevails - // "for keys that exist in both arrays, the elements from the left-hand array will be used" - $this->definitions = $definitions + $this->definitions; - - // Clear cache - $this->wildcardDefinitions = null; - } - - /** - * {@inheritdoc} - */ - public function addDefinition(Definition $definition) - { - $this->definitions[$definition->getName()] = $definition; - - // Clear cache - $this->wildcardDefinitions = null; - } - - public function getDefinition(string $name) - { - // Look for the definition by name - if (array_key_exists($name, $this->definitions)) { - $definition = $this->definitions[$name]; - $definition = $this->normalizer->normalizeRootDefinition($definition, $name); - - return $definition; - } - - // Build the cache of wildcard definitions - if ($this->wildcardDefinitions === null) { - $this->wildcardDefinitions = []; - foreach ($this->definitions as $key => $definition) { - if (strpos($key, self::WILDCARD) !== false) { - $this->wildcardDefinitions[$key] = $definition; - } - } - } - - // Look in wildcards definitions - foreach ($this->wildcardDefinitions as $key => $definition) { - // Turn the pattern into a regex - $key = preg_quote($key); - $key = '#' . str_replace('\\' . self::WILDCARD, self::WILDCARD_PATTERN, $key) . '#'; - if (preg_match($key, $name, $matches) === 1) { - array_shift($matches); - $definition = $this->normalizer->normalizeRootDefinition($definition, $name, $matches); - - return $definition; - } - } - - return null; - } - - public function getDefinitions() : array - { - // Return all definitions except wildcard definitions - $definitions = []; - foreach ($this->definitions as $key => $definition) { - if (strpos($key, self::WILDCARD) === false) { - $definitions[$key] = $definition; - } - } - - return $definitions; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/DefinitionFile.php b/vendor/php-di/php-di/src/Definition/Source/DefinitionFile.php deleted file mode 100644 index 0c6caff..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/DefinitionFile.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class DefinitionFile extends DefinitionArray -{ - /** - * @var bool - */ - private $initialized = false; - - /** - * File containing definitions, or null if the definitions are given as a PHP array. - * @var string|null - */ - private $file; - - /** - * @param string $file File in which the definitions are returned as an array. - */ - public function __construct($file, Autowiring $autowiring = null) - { - // Lazy-loading to improve performances - $this->file = $file; - - parent::__construct([], $autowiring); - } - - public function getDefinition(string $name) - { - $this->initialize(); - - return parent::getDefinition($name); - } - - public function getDefinitions() : array - { - $this->initialize(); - - return parent::getDefinitions(); - } - - /** - * Lazy-loading of the definitions. - */ - private function initialize() - { - if ($this->initialized === true) { - return; - } - - $definitions = require $this->file; - - if (! is_array($definitions)) { - throw new \Exception("File {$this->file} should return an array of definitions"); - } - - $this->addDefinitions($definitions); - - $this->initialized = true; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/DefinitionNormalizer.php b/vendor/php-di/php-di/src/Definition/Source/DefinitionNormalizer.php deleted file mode 100644 index 99ea36b..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/DefinitionNormalizer.php +++ /dev/null @@ -1,120 +0,0 @@ - - */ -class DefinitionNormalizer -{ - /** - * @var Autowiring - */ - private $autowiring; - - public function __construct(Autowiring $autowiring) - { - $this->autowiring = $autowiring; - } - - /** - * Normalize a definition that is *not* nested in another one. - * - * This is usually a definition declared at the root of a definition array. - * - * @param mixed $definition - * @param string $name The definition name. - * @param string[] $wildcardsReplacements Replacements for wildcard definitions. - * - * @throws InvalidDefinition - */ - public function normalizeRootDefinition($definition, string $name, array $wildcardsReplacements = null) : Definition - { - if ($definition instanceof DefinitionHelper) { - $definition = $definition->getDefinition($name); - } elseif (is_array($definition)) { - $definition = new ArrayDefinition($definition); - } elseif ($definition instanceof \Closure) { - $definition = new FactoryDefinition($name, $definition); - } elseif (! $definition instanceof Definition) { - $definition = new ValueDefinition($definition); - } - - // For a class definition, we replace * in the class name with the matches - // *Interface -> *Impl => FooInterface -> FooImpl - if ($wildcardsReplacements && $definition instanceof ObjectDefinition) { - $definition->replaceWildcards($wildcardsReplacements); - } - - if ($definition instanceof AutowireDefinition) { - $definition = $this->autowiring->autowire($name, $definition); - } - - $definition->setName($name); - - try { - $definition->replaceNestedDefinitions([$this, 'normalizeNestedDefinition']); - } catch (InvalidDefinition $e) { - throw InvalidDefinition::create($definition, sprintf( - 'Definition "%s" contains an error: %s', - $definition->getName(), - $e->getMessage() - ), $e); - } - - return $definition; - } - - /** - * Normalize a definition that is nested in another one. - * - * @param mixed $definition - * @return mixed - * - * @throws InvalidDefinition - */ - public function normalizeNestedDefinition($definition) - { - $name = ''; - - if ($definition instanceof DefinitionHelper) { - $definition = $definition->getDefinition($name); - } elseif (is_array($definition)) { - $definition = new ArrayDefinition($definition); - } elseif ($definition instanceof \Closure) { - $definition = new FactoryDefinition($name, $definition); - } - - if ($definition instanceof DecoratorDefinition) { - throw new InvalidDefinition('Decorators cannot be nested in another definition'); - } - - if ($definition instanceof AutowireDefinition) { - $definition = $this->autowiring->autowire($name, $definition); - } - - if ($definition instanceof Definition) { - $definition->setName($name); - - // Recursively traverse nested definitions - $definition->replaceNestedDefinitions([$this, 'normalizeNestedDefinition']); - } - - return $definition; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/DefinitionSource.php b/vendor/php-di/php-di/src/Definition/Source/DefinitionSource.php deleted file mode 100644 index 5aa95dd..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/DefinitionSource.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ -interface DefinitionSource -{ - /** - * Returns the DI definition for the entry name. - * - * @throws InvalidDefinition An invalid definition was found. - * @return Definition|null - */ - public function getDefinition(string $name); - - /** - * @return Definition[] Definitions indexed by their name. - */ - public function getDefinitions() : array; -} diff --git a/vendor/php-di/php-di/src/Definition/Source/MutableDefinitionSource.php b/vendor/php-di/php-di/src/Definition/Source/MutableDefinitionSource.php deleted file mode 100644 index 0422174..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/MutableDefinitionSource.php +++ /dev/null @@ -1,17 +0,0 @@ - - */ -interface MutableDefinitionSource extends DefinitionSource -{ - public function addDefinition(Definition $definition); -} diff --git a/vendor/php-di/php-di/src/Definition/Source/NoAutowiring.php b/vendor/php-di/php-di/src/Definition/Source/NoAutowiring.php deleted file mode 100644 index dda3e30..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/NoAutowiring.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ -class NoAutowiring implements Autowiring -{ - public function autowire(string $name, ObjectDefinition $definition = null) - { - throw new InvalidDefinition(sprintf( - 'Cannot autowire entry "%s" because autowiring is disabled', - $name - )); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/ReflectionBasedAutowiring.php b/vendor/php-di/php-di/src/Definition/Source/ReflectionBasedAutowiring.php deleted file mode 100644 index fdc3748..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/ReflectionBasedAutowiring.php +++ /dev/null @@ -1,85 +0,0 @@ - - */ -class ReflectionBasedAutowiring implements DefinitionSource, Autowiring -{ - public function autowire(string $name, ObjectDefinition $definition = null) - { - $className = $definition ? $definition->getClassName() : $name; - - if (!class_exists($className) && !interface_exists($className)) { - return $definition; - } - - $definition = $definition ?: new ObjectDefinition($name); - - // Constructor - $class = new \ReflectionClass($className); - $constructor = $class->getConstructor(); - if ($constructor && $constructor->isPublic()) { - $constructorInjection = MethodInjection::constructor($this->getParametersDefinition($constructor)); - $definition->completeConstructorInjection($constructorInjection); - } - - return $definition; - } - - public function getDefinition(string $name) - { - return $this->autowire($name); - } - - /** - * Autowiring cannot guess all existing definitions. - */ - public function getDefinitions() : array - { - return []; - } - - /** - * Read the type-hinting from the parameters of the function. - */ - private function getParametersDefinition(\ReflectionFunctionAbstract $constructor) : array - { - $parameters = []; - - foreach ($constructor->getParameters() as $index => $parameter) { - // Skip optional parameters - if ($parameter->isOptional()) { - continue; - } - - $parameterType = $parameter->getType(); - if (!$parameterType) { - // No type - continue; - } - if (!$parameterType instanceof ReflectionNamedType) { - // Union types are not supported - continue; - } - if ($parameterType->isBuiltin()) { - // Primitive types are not supported - continue; - } - - $parameters[$index] = new Reference($parameterType->getName()); - } - - return $parameters; - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/SourceCache.php b/vendor/php-di/php-di/src/Definition/Source/SourceCache.php deleted file mode 100644 index 6487c2c..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/SourceCache.php +++ /dev/null @@ -1,88 +0,0 @@ - - */ -class SourceCache implements DefinitionSource, MutableDefinitionSource -{ - /** - * @var string - */ - const CACHE_KEY = 'php-di.definitions.'; - - /** - * @var DefinitionSource - */ - private $cachedSource; - - /** - * @var string - */ - private $cacheNamespace; - - public function __construct(DefinitionSource $cachedSource, string $cacheNamespace = '') - { - $this->cachedSource = $cachedSource; - $this->cacheNamespace = $cacheNamespace; - } - - public function getDefinition(string $name) - { - $definition = apcu_fetch($this->getCacheKey($name)); - - if ($definition === false) { - $definition = $this->cachedSource->getDefinition($name); - - // Update the cache - if ($this->shouldBeCached($definition)) { - apcu_store($this->getCacheKey($name), $definition); - } - } - - return $definition; - } - - /** - * Used only for the compilation so we can skip the cache safely. - */ - public function getDefinitions() : array - { - return $this->cachedSource->getDefinitions(); - } - - public static function isSupported() : bool - { - return function_exists('apcu_fetch') - && ini_get('apc.enabled') - && ! ('cli' === \PHP_SAPI && ! ini_get('apc.enable_cli')); - } - - public function getCacheKey(string $name) : string - { - return self::CACHE_KEY . $this->cacheNamespace . $name; - } - - public function addDefinition(Definition $definition) - { - throw new \LogicException('You cannot set a definition at runtime on a container that has caching enabled. Doing so would risk caching the definition for the next execution, where it might be different. You can either put your definitions in a file, remove the cache or ->set() a raw value directly (PHP object, string, int, ...) instead of a PHP-DI definition.'); - } - - private function shouldBeCached(Definition $definition = null) : bool - { - return - // Cache missing definitions - ($definition === null) - // Object definitions are used with `make()` - || ($definition instanceof ObjectDefinition) - // Autowired definitions cannot be all compiled and are used with `make()` - || ($definition instanceof AutowireDefinition); - } -} diff --git a/vendor/php-di/php-di/src/Definition/Source/SourceChain.php b/vendor/php-di/php-di/src/Definition/Source/SourceChain.php deleted file mode 100644 index b82d618..0000000 --- a/vendor/php-di/php-di/src/Definition/Source/SourceChain.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ -class SourceChain implements DefinitionSource, MutableDefinitionSource -{ - /** - * @var DefinitionSource[] - */ - private $sources; - - /** - * @var DefinitionSource - */ - private $rootSource; - - /** - * @var MutableDefinitionSource|null - */ - private $mutableSource; - - /** - * @param DefinitionSource[] $sources - */ - public function __construct(array $sources) - { - // We want a numerically indexed array to ease the traversal later - $this->sources = array_values($sources); - $this->rootSource = $this; - } - - /** - * {@inheritdoc} - * - * @param int $startIndex Use this parameter to start looking from a specific - * point in the source chain. - */ - public function getDefinition(string $name, int $startIndex = 0) - { - $count = count($this->sources); - for ($i = $startIndex; $i < $count; ++$i) { - $source = $this->sources[$i]; - - $definition = $source->getDefinition($name); - - if ($definition) { - if ($definition instanceof ExtendsPreviousDefinition) { - $this->resolveExtendedDefinition($definition, $i); - } - - return $definition; - } - } - - return null; - } - - public function getDefinitions() : array - { - $names = []; - foreach ($this->sources as $source) { - $names = array_merge($names, $source->getDefinitions()); - } - $names = array_keys($names); - - $definitions = array_combine($names, array_map(function (string $name) { - return $this->getDefinition($name); - }, $names)); - - return $definitions; - } - - public function addDefinition(Definition $definition) - { - if (! $this->mutableSource) { - throw new \LogicException("The container's definition source has not been initialized correctly"); - } - - $this->mutableSource->addDefinition($definition); - } - - private function resolveExtendedDefinition(ExtendsPreviousDefinition $definition, int $currentIndex) - { - // Look in the next sources only (else infinite recursion, and we can only extend - // entries defined in the previous definition files - a previous == next here because - // the array was reversed ;) ) - $subDefinition = $this->getDefinition($definition->getName(), $currentIndex + 1); - - if ($subDefinition) { - $definition->setExtendedDefinition($subDefinition); - } - } - - public function setMutableDefinitionSource(MutableDefinitionSource $mutableSource) - { - $this->mutableSource = $mutableSource; - - array_unshift($this->sources, $mutableSource); - } -} diff --git a/vendor/php-di/php-di/src/Definition/StringDefinition.php b/vendor/php-di/php-di/src/Definition/StringDefinition.php deleted file mode 100644 index 52207e7..0000000 --- a/vendor/php-di/php-di/src/Definition/StringDefinition.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -class StringDefinition implements Definition, SelfResolvingDefinition -{ - /** - * Entry name. - * @var string - */ - private $name = ''; - - /** - * @var string - */ - private $expression; - - public function __construct(string $expression) - { - $this->expression = $expression; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - public function getExpression() : string - { - return $this->expression; - } - - public function resolve(ContainerInterface $container) : string - { - return self::resolveExpression($this->name, $this->expression, $container); - } - - public function isResolvable(ContainerInterface $container) : bool - { - return true; - } - - public function replaceNestedDefinitions(callable $replacer) - { - // no nested definitions - } - - public function __toString() - { - return $this->expression; - } - - /** - * Resolve a string expression. - */ - public static function resolveExpression( - string $entryName, - string $expression, - ContainerInterface $container - ) : string { - $callback = function (array $matches) use ($entryName, $container) { - try { - return $container->get($matches[1]); - } catch (NotFoundExceptionInterface $e) { - throw new DependencyException(sprintf( - "Error while parsing string expression for entry '%s': %s", - $entryName, - $e->getMessage() - ), 0, $e); - } - }; - - $result = preg_replace_callback('#\{([^\{\}]+)\}#', $callback, $expression); - if ($result === null) { - throw new \RuntimeException(sprintf('An unknown error occurred while parsing the string definition: \'%s\'', $expression)); - } - - return $result; - } -} diff --git a/vendor/php-di/php-di/src/Definition/ValueDefinition.php b/vendor/php-di/php-di/src/Definition/ValueDefinition.php deleted file mode 100644 index d647582..0000000 --- a/vendor/php-di/php-di/src/Definition/ValueDefinition.php +++ /dev/null @@ -1,72 +0,0 @@ - - */ -class ValueDefinition implements Definition, SelfResolvingDefinition -{ - /** - * Entry name. - * @var string - */ - private $name = ''; - - /** - * @var mixed - */ - private $value; - - /** - * @param mixed $value - */ - public function __construct($value) - { - $this->value = $value; - } - - public function getName() : string - { - return $this->name; - } - - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return mixed - */ - public function getValue() - { - return $this->value; - } - - public function resolve(ContainerInterface $container) - { - return $this->getValue(); - } - - public function isResolvable(ContainerInterface $container) : bool - { - return true; - } - - public function replaceNestedDefinitions(callable $replacer) - { - // no nested definitions - } - - public function __toString() - { - return sprintf('Value (%s)', var_export($this->value, true)); - } -} diff --git a/vendor/php-di/php-di/src/DependencyException.php b/vendor/php-di/php-di/src/DependencyException.php deleted file mode 100644 index 63b5fdd..0000000 --- a/vendor/php-di/php-di/src/DependencyException.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -interface RequestedEntry -{ - /** - * Returns the name of the entry that was requested by the container. - */ - public function getName() : string; -} diff --git a/vendor/php-di/php-di/src/FactoryInterface.php b/vendor/php-di/php-di/src/FactoryInterface.php deleted file mode 100644 index 59b410f..0000000 --- a/vendor/php-di/php-di/src/FactoryInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -interface FactoryInterface -{ - /** - * Resolves an entry by its name. If given a class name, it will return a new instance of that class. - * - * @param string $name Entry name or a class name. - * @param array $parameters Optional parameters to use to build the entry. Use this to force specific - * parameters to specific values. Parameters not defined in this array will - * be automatically resolved. - * - * @throws \InvalidArgumentException The name parameter must be of type string. - * @throws DependencyException Error while resolving the entry. - * @throws NotFoundException No entry or class found for the given name. - * @return mixed - */ - public function make($name, array $parameters = []); -} diff --git a/vendor/php-di/php-di/src/Invoker/DefinitionParameterResolver.php b/vendor/php-di/php-di/src/Invoker/DefinitionParameterResolver.php deleted file mode 100644 index b17ebd9..0000000 --- a/vendor/php-di/php-di/src/Invoker/DefinitionParameterResolver.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class DefinitionParameterResolver implements ParameterResolver -{ - /** - * @var DefinitionResolver - */ - private $definitionResolver; - - public function __construct(DefinitionResolver $definitionResolver) - { - $this->definitionResolver = $definitionResolver; - } - - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ) : array { - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $providedParameters = array_diff_key($providedParameters, $resolvedParameters); - } - - foreach ($providedParameters as $key => $value) { - if ($value instanceof DefinitionHelper) { - $value = $value->getDefinition(''); - } - - if (! $value instanceof Definition) { - continue; - } - - $value = $this->definitionResolver->resolve($value); - - if (is_int($key)) { - // Indexed by position - $resolvedParameters[$key] = $value; - } else { - // Indexed by parameter name - // TODO optimize? - $reflectionParameters = $reflection->getParameters(); - foreach ($reflectionParameters as $reflectionParameter) { - if ($key === $reflectionParameter->name) { - $resolvedParameters[$reflectionParameter->getPosition()] = $value; - } - } - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/php-di/src/Invoker/FactoryParameterResolver.php b/vendor/php-di/php-di/src/Invoker/FactoryParameterResolver.php deleted file mode 100644 index f5ace87..0000000 --- a/vendor/php-di/php-di/src/Invoker/FactoryParameterResolver.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @author Matthieu Napoli - */ -class FactoryParameterResolver implements ParameterResolver -{ - /** - * @var ContainerInterface - */ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - public function getParameters( - ReflectionFunctionAbstract $reflection, - array $providedParameters, - array $resolvedParameters - ) : array { - $parameters = $reflection->getParameters(); - - // Skip parameters already resolved - if (! empty($resolvedParameters)) { - $parameters = array_diff_key($parameters, $resolvedParameters); - } - - foreach ($parameters as $index => $parameter) { - $parameterType = $parameter->getType(); - if (!$parameterType) { - // No type - continue; - } - if (!$parameterType instanceof ReflectionNamedType) { - // Union types are not supported - continue; - } - if ($parameterType->isBuiltin()) { - // Primitive types are not supported - continue; - } - - $parameterClass = $parameterType->getName(); - - if ($parameterClass === 'Psr\Container\ContainerInterface') { - $resolvedParameters[$index] = $this->container; - } elseif ($parameterClass === 'DI\Factory\RequestedEntry') { - // By convention the second parameter is the definition - $resolvedParameters[$index] = $providedParameters[1]; - } elseif ($this->container->has($parameterClass)) { - $resolvedParameters[$index] = $this->container->get($parameterClass); - } - } - - return $resolvedParameters; - } -} diff --git a/vendor/php-di/php-di/src/NotFoundException.php b/vendor/php-di/php-di/src/NotFoundException.php deleted file mode 100644 index 67dbacd..0000000 --- a/vendor/php-di/php-di/src/NotFoundException.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ -class ProxyFactory -{ - /** - * If true, write the proxies to disk to improve performances. - * @var bool - */ - private $writeProxiesToFile; - - /** - * Directory where to write the proxies (if $writeProxiesToFile is enabled). - * @var string|null - */ - private $proxyDirectory; - - /** - * @var LazyLoadingValueHolderFactory|null - */ - private $proxyManager; - - public function __construct(bool $writeProxiesToFile = false, string $proxyDirectory = null) - { - $this->writeProxiesToFile = $writeProxiesToFile; - $this->proxyDirectory = $proxyDirectory; - } - - /** - * Creates a new lazy proxy instance of the given class with - * the given initializer. - * - * @param string $className name of the class to be proxied - * @param \Closure $initializer initializer to be passed to the proxy - */ - public function createProxy(string $className, \Closure $initializer) : LazyLoadingInterface - { - $this->createProxyManager(); - - return $this->proxyManager->createProxy($className, $initializer); - } - - /** - * Generates and writes the proxy class to file. - * - * @param string $className name of the class to be proxied - */ - public function generateProxyClass(string $className) - { - // If proxy classes a written to file then we pre-generate the class - // If they are not written to file then there is no point to do this - if ($this->writeProxiesToFile) { - $this->createProxyManager(); - $this->createProxy($className, function () {}); - } - } - - private function createProxyManager() - { - if ($this->proxyManager !== null) { - return; - } - - if (! class_exists(Configuration::class)) { - throw new \RuntimeException('The ocramius/proxy-manager library is not installed. Lazy injection requires that library to be installed with Composer in order to work. Run "composer require ocramius/proxy-manager:~2.0".'); - } - - $config = new Configuration(); - - if ($this->writeProxiesToFile) { - $config->setProxiesTargetDir($this->proxyDirectory); - $config->setGeneratorStrategy(new FileWriterGeneratorStrategy(new FileLocator($this->proxyDirectory))); - // @phpstan-ignore-next-line - spl_autoload_register($config->getProxyAutoloader()); - } else { - $config->setGeneratorStrategy(new EvaluatingGeneratorStrategy()); - } - - $this->proxyManager = new LazyLoadingValueHolderFactory($config); - } -} diff --git a/vendor/php-di/php-di/src/functions.php b/vendor/php-di/php-di/src/functions.php deleted file mode 100644 index 0504edb..0000000 --- a/vendor/php-di/php-di/src/functions.php +++ /dev/null @@ -1,156 +0,0 @@ - decorate(function ($foo, $container) { - * return new CachedFoo($foo, $container->get('cache')); - * }) - * - * @param callable $callable The callable takes the decorated object as first parameter and - * the container as second. - */ - function decorate($callable) : FactoryDefinitionHelper - { - return new FactoryDefinitionHelper($callable, true); - } -} - -if (! function_exists('DI\get')) { - /** - * Helper for referencing another container entry in an object definition. - */ - function get(string $entryName) : Reference - { - return new Reference($entryName); - } -} - -if (! function_exists('DI\env')) { - /** - * Helper for referencing environment variables. - * - * @param string $variableName The name of the environment variable. - * @param mixed $defaultValue The default value to be used if the environment variable is not defined. - */ - function env(string $variableName, $defaultValue = null) : EnvironmentVariableDefinition - { - // Only mark as optional if the default value was *explicitly* provided. - $isOptional = 2 === func_num_args(); - - return new EnvironmentVariableDefinition($variableName, $isOptional, $defaultValue); - } -} - -if (! function_exists('DI\add')) { - /** - * Helper for extending another definition. - * - * Example: - * - * 'log.backends' => DI\add(DI\get('My\Custom\LogBackend')) - * - * or: - * - * 'log.backends' => DI\add([ - * DI\get('My\Custom\LogBackend') - * ]) - * - * @param mixed|array $values A value or an array of values to add to the array. - * - * @since 5.0 - */ - function add($values) : ArrayDefinitionExtension - { - if (! is_array($values)) { - $values = [$values]; - } - - return new ArrayDefinitionExtension($values); - } -} - -if (! function_exists('DI\string')) { - /** - * Helper for concatenating strings. - * - * Example: - * - * 'log.filename' => DI\string('{app.path}/app.log') - * - * @param string $expression A string expression. Use the `{}` placeholders to reference other container entries. - * - * @since 5.0 - */ - function string(string $expression) : StringDefinition - { - return new StringDefinition($expression); - } -} diff --git a/vendor/php-di/php-di/support.md b/vendor/php-di/php-di/support.md deleted file mode 100644 index 22dd39a..0000000 --- a/vendor/php-di/php-di/support.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -layout: documentation -current_menu: enterprise-support -title: Enterprise support for PHP-DI ---- - -# PHP-DI for Enterprise - -> *Available as part of the Tidelift Subscription* - -Tidelift is working with the maintainers of PHP-DI and thousands of other -open source projects to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. - -#### [Learn more](https://tidelift.com/subscription/pkg/packagist-php-di-php-di?utm_source=packagist-php-di-php-di&utm_medium=referral&utm_campaign=enterprise) | [**Request a demo**](https://tidelift.com/subscription/request-a-demo?utm_source=packagist-php-di-php-di&utm_medium=referral&utm_campaign=enterprise) - -## Enterprise-ready open source software—managed for you - -The Tidelift Subscription is a managed open source subscription for application dependencies covering millions of open source projects across JavaScript, Python, Java, PHP, Ruby, .NET, and more. - -Your subscription includes: - -- **Security updates** - Tidelift’s security response team coordinates patches for new breaking security vulnerabilities and alerts immediately through a private channel, so your software supply chain is always secure. - -- **Licensing verification and indemnification** - Tidelift verifies license information to enable easy policy enforcement and adds intellectual property indemnification to cover creators and users in case something goes wrong. You always have a 100% up-to-date bill of materials for your dependencies to share with your legal team, customers, or partners. - -- **Maintenance and code improvement** - Tidelift ensures the software you rely on keeps working as long as you need it to work. Your managed dependencies are actively maintained and we recruit additional maintainers where required. - -- **Package selection and version guidance** - We help you choose the best open source packages from the start—and then guide you through updates to stay on the best releases as new issues arise. - -- **Roadmap input** - Take a seat at the table with the creators behind the software you use. Tidelift’s participating maintainers earn more income as their software is used by more subscribers, so they’re interested in knowing what you need. - -- **Tooling and cloud integration** - Tidelift works with GitHub, GitLab, BitBucket, and more. We support every cloud platform (and other deployment targets, too). - -The end result? All of the capabilities you expect from commercial-grade software, for the full breadth of open source you use. That means less time grappling with esoteric open source trivia, and more time building your own applications—and your business. - -[Learn more](https://tidelift.com/subscription/pkg/packagist-php-di-php-di?utm_source=packagist-php-di-php-di&utm_medium=referral&utm_campaign=enterprise) | [**Request a demo**](https://tidelift.com/subscription/request-a-demo?utm_source=packagist-php-di-php-di&utm_medium=referral&utm_campaign=enterprise) diff --git a/vendor/php-di/phpdoc-reader/.gitattributes b/vendor/php-di/phpdoc-reader/.gitattributes deleted file mode 100644 index 912292c..0000000 --- a/vendor/php-di/phpdoc-reader/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -# .gitattributes -tests/ export-ignore -phpunit.xml.dist export-ignore -.travis.yml export-ignore - -# Auto detect text files and perform LF normalization -* text=auto diff --git a/vendor/php-di/phpdoc-reader/.github/workflows/ci.yml b/vendor/php-di/phpdoc-reader/.github/workflows/ci.yml deleted file mode 100644 index 5b7421d..0000000 --- a/vendor/php-di/phpdoc-reader/.github/workflows/ci.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: CI - -on: - push: - branches: ['master'] - pull_request: - branches: ['*'] - schedule: - - cron: '0 0 * * *' - -jobs: - - tests: - name: Tests - PHP ${{ matrix.php }} ${{ matrix.dependency-version }} - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - matrix: - php: [ '7.2', '7.3', '7.4', '8.0' ] - dependency-version: [ '' ] - include: - - php: '7.2' - dependency-version: '--prefer-lowest' - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer:v2 - coverage: none - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: php-${{ matrix.php }}-composer-locked-${{ hashFiles('composer.lock') }} - restore-keys: php-${{ matrix.php }}-composer-locked- - - name: Install PHP dependencies - run: composer update ${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-progress --no-suggest - - name: PHPUnit - run: vendor/bin/phpunit - - cs: - name: Coding standards - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 7.4 - tools: composer:v2, cs2pr - coverage: none - - name: Cache Composer dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache - key: php-74-composer-locked-${{ hashFiles('composer.lock') }} - restore-keys: php-74-composer-locked- - - name: Install PHP dependencies - run: composer install --no-interaction --no-progress --no-suggest - - name: PHP CodeSniffer - run: vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr diff --git a/vendor/php-di/phpdoc-reader/.gitignore b/vendor/php-di/phpdoc-reader/.gitignore deleted file mode 100644 index 9abe135..0000000 --- a/vendor/php-di/phpdoc-reader/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.DS_Store -.idea/* -vendor/* -composer.phar -composer.lock -.phpcs-cache -.phpunit.result.cache diff --git a/vendor/php-di/phpdoc-reader/.phpcs.xml.dist b/vendor/php-di/phpdoc-reader/.phpcs.xml.dist deleted file mode 100644 index 191db96..0000000 --- a/vendor/php-di/phpdoc-reader/.phpcs.xml.dist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - src - src/PhpDocReader/PhpParser/TokenParser.php - tests - tests/Fixtures - - - - - - 0 - - - diff --git a/vendor/php-di/phpdoc-reader/LICENSE b/vendor/php-di/phpdoc-reader/LICENSE deleted file mode 100644 index f3d2a02..0000000 --- a/vendor/php-di/phpdoc-reader/LICENSE +++ /dev/null @@ -1,16 +0,0 @@ -Copyright (C) 2019 Matthieu Napoli - -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. diff --git a/vendor/php-di/phpdoc-reader/README.md b/vendor/php-di/phpdoc-reader/README.md deleted file mode 100644 index bfaa6c3..0000000 --- a/vendor/php-di/phpdoc-reader/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# PhpDocReader - -![](https://img.shields.io/packagist/dt/PHP-DI/phpdoc-reader.svg) - -This project is used by: - -- [PHP-DI 6](http://php-di.org/) -- [phockito-unit-php-di](https://github.com/balihoo/phockito-unit-php-di) - -Fork the README to add your project here. - -## Features - -PhpDocReader parses `@var` and `@param` values in PHP docblocks: - -```php - -use My\Cache\Backend; - -class Cache -{ - /** - * @var Backend - */ - protected $backend; - - /** - * @param Backend $backend - */ - public function __construct($backend) - { - } -} -``` - -It supports namespaced class names with the same resolution rules as PHP: - -- fully qualified name (starting with `\`) -- imported class name (eg. `use My\Cache\Backend;`) -- relative class name (from the current namespace, like `SubNamespace\MyClass`) -- aliased class name (eg. `use My\Cache\Backend as FooBar;`) - -Primitive types (`@var string`) are ignored (returns null), only valid class names are returned. - -## Usage - -```php -$reader = new PhpDocReader(); - -// Read a property type (@var phpdoc) -$property = new ReflectionProperty($className, $propertyName); -$propertyClass = $reader->getPropertyClass($property); - -// Read a parameter type (@param phpdoc) -$parameter = new ReflectionParameter(array($className, $methodName), $parameterName); -$parameterClass = $reader->getParameterClass($parameter); -``` diff --git a/vendor/php-di/phpdoc-reader/composer.json b/vendor/php-di/phpdoc-reader/composer.json deleted file mode 100644 index 64d7262..0000000 --- a/vendor/php-di/phpdoc-reader/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "php-di/phpdoc-reader", - "type": "library", - "description": "PhpDocReader parses @var and @param values in PHP docblocks (supports namespaced class names with the same resolution rules as PHP)", - "keywords": ["phpdoc", "reflection"], - "license": "MIT", - "autoload": { - "psr-4": { - "PhpDocReader\\": "src/PhpDocReader" - } - }, - "autoload-dev": { - "psr-4": { - "UnitTest\\PhpDocReader\\": "tests/" - } - }, - "require": { - "php": ">=7.2.0" - }, - "require-dev": { - "phpunit/phpunit": "^8.5|^9.0", - "mnapoli/hard-mode": "~0.3.0" - } -} diff --git a/vendor/php-di/phpdoc-reader/src/PhpDocReader/AnnotationException.php b/vendor/php-di/phpdoc-reader/src/PhpDocReader/AnnotationException.php deleted file mode 100644 index 1466a9b..0000000 --- a/vendor/php-di/phpdoc-reader/src/PhpDocReader/AnnotationException.php +++ /dev/null @@ -1,10 +0,0 @@ - 'bool', - 'boolean' => 'bool', - 'string' => 'string', - 'int' => 'int', - 'integer' => 'int', - 'float' => 'float', - 'double' => 'float', - 'array' => 'array', - 'object' => 'object', - 'callable' => 'callable', - 'resource' => 'resource', - 'mixed' => 'mixed', - 'iterable' => 'iterable', - ]; - - /** @var bool */ - private $ignorePhpDocErrors; - - /** - * @param bool $ignorePhpDocErrors Enable or disable throwing errors when PhpDoc errors occur (when parsing annotations). - */ - public function __construct(bool $ignorePhpDocErrors = false) - { - $this->parser = new UseStatementParser; - $this->ignorePhpDocErrors = $ignorePhpDocErrors; - } - - /** - * Parse the docblock of the property to get the type (class or primitive type) of the var annotation. - * - * @return string|null Type of the property (content of var annotation) - * @throws AnnotationException - */ - public function getPropertyType(ReflectionProperty $property): ?string - { - return $this->readPropertyType($property, true); - } - - /** - * Parse the docblock of the property to get the class of the var annotation. - * - * @return string|null Type of the property (content of var annotation) - * @throws AnnotationException - */ - public function getPropertyClass(ReflectionProperty $property): ?string - { - return $this->readPropertyType($property, false); - } - - private function readPropertyType(ReflectionProperty $property, bool $allowPrimitiveTypes): ?string - { - // Get the content of the @var annotation - $docComment = $property->getDocComment(); - if (! $docComment) { - return null; - } - if (preg_match('/@var\s+([^\s]+)/', $docComment, $matches)) { - [, $type] = $matches; - } else { - return null; - } - - // Ignore primitive types - if (isset(self::PRIMITIVE_TYPES[$type])) { - if ($allowPrimitiveTypes) { - return self::PRIMITIVE_TYPES[$type]; - } - return null; - } - - // Ignore types containing special characters ([], <> ...) - if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) { - return null; - } - - $class = $property->getDeclaringClass(); - - // If the class name is not fully qualified (i.e. doesn't start with a \) - if ($type[0] !== '\\') { - // Try to resolve the FQN using the class context - $resolvedType = $this->tryResolveFqn($type, $class, $property); - - if (! $resolvedType && ! $this->ignorePhpDocErrors) { - throw new AnnotationException(sprintf( - 'The @var annotation on %s::%s contains a non existent class "%s". ' - . 'Did you maybe forget to add a "use" statement for this annotation?', - $class->name, - $property->getName(), - $type - )); - } - - $type = $resolvedType; - } - - if (! $this->ignorePhpDocErrors && ! $this->classExists($type)) { - throw new AnnotationException(sprintf( - 'The @var annotation on %s::%s contains a non existent class "%s"', - $class->name, - $property->getName(), - $type - )); - } - - // Remove the leading \ (FQN shouldn't contain it) - $type = is_string($type) ? ltrim($type, '\\') : null; - - return $type; - } - - /** - * Parse the docblock of the property to get the type (class or primitive type) of the param annotation. - * - * @return string|null Type of the property (content of var annotation) - * @throws AnnotationException - */ - public function getParameterType(ReflectionParameter $parameter): ?string - { - return $this->readParameterClass($parameter, true); - } - - /** - * Parse the docblock of the property to get the class of the param annotation. - * - * @return string|null Type of the property (content of var annotation) - * @throws AnnotationException - */ - public function getParameterClass(ReflectionParameter $parameter): ?string - { - return $this->readParameterClass($parameter, false); - } - - private function readParameterClass(ReflectionParameter $parameter, bool $allowPrimitiveTypes): ?string - { - // Use reflection - $parameterType = $parameter->getType(); - if ($parameterType && $parameterType instanceof \ReflectionNamedType && ! $parameterType->isBuiltin()) { - return $parameterType->getName(); - } - - $parameterName = $parameter->name; - // Get the content of the @param annotation - $method = $parameter->getDeclaringFunction(); - $docComment = $method->getDocComment(); - if (! $docComment) { - return null; - } - if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $docComment, $matches)) { - [, $type] = $matches; - } else { - return null; - } - - // Ignore primitive types - if (isset(self::PRIMITIVE_TYPES[$type])) { - if ($allowPrimitiveTypes) { - return self::PRIMITIVE_TYPES[$type]; - } - return null; - } - - // Ignore types containing special characters ([], <> ...) - if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) { - return null; - } - - $class = $parameter->getDeclaringClass(); - - // If the class name is not fully qualified (i.e. doesn't start with a \) - if ($type[0] !== '\\') { - // Try to resolve the FQN using the class context - $resolvedType = $this->tryResolveFqn($type, $class, $parameter); - - if (! $resolvedType && ! $this->ignorePhpDocErrors) { - throw new AnnotationException(sprintf( - 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". ' - . 'Did you maybe forget to add a "use" statement for this annotation?', - $parameterName, - $class->name, - $method->name, - $type - )); - } - - $type = $resolvedType; - } - - if (! $this->ignorePhpDocErrors && ! $this->classExists($type)) { - throw new AnnotationException(sprintf( - 'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"', - $parameterName, - $class->name, - $method->name, - $type - )); - } - - // Remove the leading \ (FQN shouldn't contain it) - $type = is_string($type) ? ltrim($type, '\\') : null; - - return $type; - } - - /** - * Attempts to resolve the FQN of the provided $type based on the $class and $member context. - * - * @return string|null Fully qualified name of the type, or null if it could not be resolved - */ - private function tryResolveFqn(string $type, ReflectionClass $class, Reflector $member): ?string - { - $alias = ($pos = strpos($type, '\\')) === false ? $type : substr($type, 0, $pos); - $loweredAlias = strtolower($alias); - - // Retrieve "use" statements - $uses = $this->parser->parseUseStatements($class); - - if (isset($uses[$loweredAlias])) { - // Imported classes - if ($pos !== false) { - return $uses[$loweredAlias] . substr($type, $pos); - } - return $uses[$loweredAlias]; - } - - if ($this->classExists($class->getNamespaceName() . '\\' . $type)) { - return $class->getNamespaceName() . '\\' . $type; - } - - if (isset($uses['__NAMESPACE__']) && $this->classExists($uses['__NAMESPACE__'] . '\\' . $type)) { - // Class namespace - return $uses['__NAMESPACE__'] . '\\' . $type; - } - - if ($this->classExists($type)) { - // No namespace - return $type; - } - - // If all fail, try resolving through related traits - return $this->tryResolveFqnInTraits($type, $class, $member); - } - - /** - * Attempts to resolve the FQN of the provided $type based on the $class and $member context, specifically searching - * through the traits that are used by the provided $class. - * - * @return string|null Fully qualified name of the type, or null if it could not be resolved - */ - private function tryResolveFqnInTraits(string $type, ReflectionClass $class, Reflector $member): ?string - { - /** @var ReflectionClass[] $traits */ - $traits = []; - - // Get traits for the class and its parents - while ($class) { - $traits = array_merge($traits, $class->getTraits()); - $class = $class->getParentClass(); - } - - foreach ($traits as $trait) { - // Eliminate traits that don't have the property/method/parameter - if ($member instanceof ReflectionProperty && ! $trait->hasProperty($member->name)) { - continue; - } - if ($member instanceof ReflectionMethod && ! $trait->hasMethod($member->name)) { - continue; - } - if ($member instanceof ReflectionParameter && ! $trait->hasMethod($member->getDeclaringFunction()->name)) { - continue; - } - - // Run the resolver again with the ReflectionClass instance for the trait - $resolvedType = $this->tryResolveFqn($type, $trait, $member); - - if ($resolvedType) { - return $resolvedType; - } - } - - return null; - } - - private function classExists(string $class): bool - { - return class_exists($class) || interface_exists($class); - } -} diff --git a/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/TokenParser.php b/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/TokenParser.php deleted file mode 100644 index 1f6ec70..0000000 --- a/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/TokenParser.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @author Christian Kaps - */ -class TokenParser -{ - /** - * The token list. - * - * @var list - */ - private $tokens; - - /** - * The number of tokens. - * - * @var int - */ - private $numTokens; - - /** - * The current array pointer. - * - * @var int - */ - private $pointer = 0; - - /** - * @param string $contents - */ - public function __construct($contents) - { - $this->tokens = token_get_all($contents); - - // The PHP parser sets internal compiler globals for certain things. Annoyingly, the last docblock comment it - // saw gets stored in doc_comment. When it comes to compile the next thing to be include()d this stored - // doc_comment becomes owned by the first thing the compiler sees in the file that it considers might have a - // docblock. If the first thing in the file is a class without a doc block this would cause calls to - // getDocBlock() on said class to return our long lost doc_comment. Argh. - // To workaround, cause the parser to parse an empty docblock. Sure getDocBlock() will return this, but at least - // it's harmless to us. - token_get_all("numTokens = count($this->tokens); - } - - /** - * Gets all use statements. - * - * @param string $namespaceName The namespace name of the reflected class. - * - * @return array A list with all found use statements. - */ - public function parseUseStatements($namespaceName) - { - $statements = []; - while (($token = $this->next())) { - if ($token[0] === T_USE) { - $statements = array_merge($statements, $this->parseUseStatement()); - continue; - } - - if ($token[0] !== T_NAMESPACE || $this->parseNamespace() !== $namespaceName) { - continue; - } - - // Get fresh array for new namespace. This is to prevent the parser to collect the use statements - // for a previous namespace with the same name. This is the case if a namespace is defined twice - // or if a namespace with the same name is commented out. - $statements = []; - } - - return $statements; - } - - /** - * Gets the next non whitespace and non comment token. - * - * @param bool $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped. - * If FALSE then only whitespace and normal comments are skipped. - * - * @return mixed[]|string|null The token if exists, null otherwise. - */ - private function next($docCommentIsComment = true) - { - for ($i = $this->pointer; $i < $this->numTokens; $i++) { - $this->pointer++; - if ( - $this->tokens[$i][0] === T_WHITESPACE || - $this->tokens[$i][0] === T_COMMENT || - ($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT) - ) { - continue; - } - - return $this->tokens[$i]; - } - - return null; - } - - /** - * Parses a single use statement. - * - * @return array A list with all found class names for a use statement. - */ - private function parseUseStatement() - { - $groupRoot = ''; - $class = ''; - $alias = ''; - $statements = []; - $explicitAlias = false; - while (($token = $this->next())) { - if (! $explicitAlias && $token[0] === T_STRING) { - $class .= $token[1]; - $alias = $token[1]; - } elseif ($explicitAlias && $token[0] === T_STRING) { - $alias = $token[1]; - } elseif ( - PHP_VERSION_ID >= 80000 && - ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED) - ) { - $class .= $token[1]; - - $classSplit = explode('\\', $token[1]); - $alias = $classSplit[count($classSplit) - 1]; - } elseif ($token[0] === T_NS_SEPARATOR) { - $class .= '\\'; - $alias = ''; - } elseif ($token[0] === T_AS) { - $explicitAlias = true; - $alias = ''; - } elseif ($token === ',') { - $statements[strtolower($alias)] = $groupRoot . $class; - $class = ''; - $alias = ''; - $explicitAlias = false; - } elseif ($token === ';') { - $statements[strtolower($alias)] = $groupRoot . $class; - break; - } elseif ($token === '{') { - $groupRoot = $class; - $class = ''; - } elseif ($token === '}') { - continue; - } else { - break; - } - } - - return $statements; - } - - /** - * Gets the namespace. - * - * @return string The found namespace. - */ - private function parseNamespace() - { - $name = ''; - while ( - ($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR || ( - PHP_VERSION_ID >= 80000 && - ($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED) - )) - ) { - $name .= $token[1]; - } - - return $name; - } -} diff --git a/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/UseStatementParser.php b/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/UseStatementParser.php deleted file mode 100644 index 39515df..0000000 --- a/vendor/php-di/phpdoc-reader/src/PhpDocReader/PhpParser/UseStatementParser.php +++ /dev/null @@ -1,64 +0,0 @@ - and Christian Kaps - */ -class UseStatementParser -{ - /** - * @return array A list with use statements in the form (Alias => FQN). - */ - public function parseUseStatements(\ReflectionClass $class): array - { - $filename = $class->getFilename(); - if ($filename === false) { - return []; - } - - $content = $this->getFileContent($filename, $class->getStartLine()); - - if ($content === null) { - return []; - } - - $namespace = preg_quote($class->getNamespaceName(), '/'); - $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content); - $tokenizer = new TokenParser('parseUseStatements($class->getNamespaceName()); - } - - /** - * Gets the content of the file right up to the given line number. - * - * @param string $filename The name of the file to load. - * @param int $lineNumber The number of lines to read from file. - */ - private function getFileContent(string $filename, int $lineNumber): string - { - if (! is_file($filename)) { - throw new \RuntimeException("Unable to read file $filename"); - } - - $content = ''; - $lineCnt = 0; - $file = new SplFileObject($filename); - while (! $file->eof()) { - if ($lineCnt++ === $lineNumber) { - break; - } - - $content .= $file->fgets(); - } - - return $content; - } -} diff --git a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php b/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php deleted file mode 100644 index 500c952..0000000 --- a/vendor/phpmailer/phpmailer/language/phpmailer.lang-ch.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ - -$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:身份验证失败。'; -$PHPMAILER_LANG['connect_host'] = 'SMTP 错误: 不能连接SMTP主机。'; -$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误: 数据不可接受。'; -//$PHPMAILER_LANG['empty_message'] = 'Message body empty'; -$PHPMAILER_LANG['encoding'] = '未知编码:'; -$PHPMAILER_LANG['execute'] = '不能执行: '; -$PHPMAILER_LANG['file_access'] = '不能访问文件:'; -$PHPMAILER_LANG['file_open'] = '文件错误:不能打开文件:'; -$PHPMAILER_LANG['from_failed'] = '下面的发送地址邮件发送失败了: '; -$PHPMAILER_LANG['instantiate'] = '不能实现mail方法。'; -//$PHPMAILER_LANG['invalid_address'] = 'Invalid address: '; -$PHPMAILER_LANG['mailer_not_supported'] = ' 您所选择的发送邮件的方法并不支持。'; -$PHPMAILER_LANG['provide_address'] = '您必须提供至少一个 收信人的email地址。'; -$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误: 下面的 收件人失败了: '; -//$PHPMAILER_LANG['signing'] = 'Signing Error: '; -//$PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP Connect() failed.'; -//$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: '; -//$PHPMAILER_LANG['variable_set'] = 'Cannot set or reset variable: '; -//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; diff --git a/vendor/psr/cache/CHANGELOG.md b/vendor/psr/cache/CHANGELOG.md deleted file mode 100644 index 58ddab0..0000000 --- a/vendor/psr/cache/CHANGELOG.md +++ /dev/null @@ -1,16 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file, in reverse chronological order by release. - -## 1.0.1 - 2016-08-06 - -### Fixed - -- Make spacing consistent in phpdoc annotations php-fig/cache#9 - chalasr -- Fix grammar in phpdoc annotations php-fig/cache#10 - chalasr -- Be more specific in docblocks that `getItems()` and `deleteItems()` take an array of strings (`string[]`) compared to just `array` php-fig/cache#8 - GrahamCampbell -- For `expiresAt()` and `expiresAfter()` in CacheItemInterface fix docblock to specify null as a valid parameters as well as an implementation of DateTimeInterface php-fig/cache#7 - GrahamCampbell - -## 1.0.0 - 2015-12-11 - -Initial stable release; reflects accepted PSR-6 specification diff --git a/vendor/psr/cache/LICENSE.txt b/vendor/psr/cache/LICENSE.txt deleted file mode 100644 index b1c2c97..0000000 --- a/vendor/psr/cache/LICENSE.txt +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 PHP Framework Interoperability Group - -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. diff --git a/vendor/psr/cache/README.md b/vendor/psr/cache/README.md deleted file mode 100644 index c8706ce..0000000 --- a/vendor/psr/cache/README.md +++ /dev/null @@ -1,9 +0,0 @@ -PSR Cache -========= - -This repository holds all interfaces defined by -[PSR-6](http://www.php-fig.org/psr/psr-6/). - -Note that this is not a Cache implementation of its own. It is merely an -interface that describes a Cache implementation. See the specification for more -details. diff --git a/vendor/psr/cache/composer.json b/vendor/psr/cache/composer.json deleted file mode 100644 index e828fec..0000000 --- a/vendor/psr/cache/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "psr/cache", - "description": "Common interface for caching libraries", - "keywords": ["psr", "psr-6", "cache"], - "license": "MIT", - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/vendor/psr/cache/src/CacheException.php b/vendor/psr/cache/src/CacheException.php deleted file mode 100644 index e27f22f..0000000 --- a/vendor/psr/cache/src/CacheException.php +++ /dev/null @@ -1,10 +0,0 @@ -=7.2.0" - }, - "autoload": { - "psr-4": { - "Psr\\EventDispatcher\\": "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/vendor/psr/event-dispatcher/src/EventDispatcherInterface.php b/vendor/psr/event-dispatcher/src/EventDispatcherInterface.php deleted file mode 100644 index 4306fa9..0000000 --- a/vendor/psr/event-dispatcher/src/EventDispatcherInterface.php +++ /dev/null @@ -1,21 +0,0 @@ -=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/psr/http-factory/src/RequestFactoryInterface.php b/vendor/psr/http-factory/src/RequestFactoryInterface.php new file mode 100644 index 0000000..cb39a08 --- /dev/null +++ b/vendor/psr/http-factory/src/RequestFactoryInterface.php @@ -0,0 +1,18 @@ +log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param mixed[] $context - * - * @return void - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/vendor/psr/log/Psr/Log/Test/DummyTest.php b/vendor/psr/log/Psr/Log/Test/DummyTest.php deleted file mode 100644 index 9638c11..0000000 --- a/vendor/psr/log/Psr/Log/Test/DummyTest.php +++ /dev/null @@ -1,18 +0,0 @@ - ". - * - * Example ->error('Foo') would yield "error Foo". - * - * @return string[] - */ - abstract public function getLogs(); - - public function testImplements() - { - $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); - } - - /** - * @dataProvider provideLevelsAndMessages - */ - public function testLogsAtAllLevels($level, $message) - { - $logger = $this->getLogger(); - $logger->{$level}($message, array('user' => 'Bob')); - $logger->log($level, $message, array('user' => 'Bob')); - - $expected = array( - $level.' message of level '.$level.' with context: Bob', - $level.' message of level '.$level.' with context: Bob', - ); - $this->assertEquals($expected, $this->getLogs()); - } - - public function provideLevelsAndMessages() - { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidLevel() - { - $logger = $this->getLogger(); - $logger->log('invalid level', 'Foo'); - } - - public function testContextReplacement() - { - $logger = $this->getLogger(); - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - - $expected = array('info {Message {nothing} Bob Bar a}'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testObjectCastToString() - { - if (method_exists($this, 'createPartialMock')) { - $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString')); - } else { - $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); - } - $dummy->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('DUMMY')); - - $this->getLogger()->warning($dummy); - - $expected = array('warning DUMMY'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextCanContainAnything() - { - $closed = fopen('php://memory', 'r'); - fclose($closed); - - $context = array( - 'bool' => true, - 'null' => null, - 'string' => 'Foo', - 'int' => 0, - 'float' => 0.5, - 'nested' => array('with object' => new DummyTest), - 'object' => new \DateTime, - 'resource' => fopen('php://memory', 'r'), - 'closed' => $closed, - ); - - $this->getLogger()->warning('Crazy context data', $context); - - $expected = array('warning Crazy context data'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextExceptionKeyCanBeExceptionOrOtherValues() - { - $logger = $this->getLogger(); - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); - - $expected = array( - 'warning Random message', - 'critical Uncaught Exception!' - ); - $this->assertEquals($expected, $this->getLogs()); - } -} diff --git a/vendor/psr/log/Psr/Log/Test/TestLogger.php b/vendor/psr/log/Psr/Log/Test/TestLogger.php deleted file mode 100644 index 1be3230..0000000 --- a/vendor/psr/log/Psr/Log/Test/TestLogger.php +++ /dev/null @@ -1,147 +0,0 @@ - $level, - 'message' => $message, - 'context' => $context, - ]; - - $this->recordsByLevel[$record['level']][] = $record; - $this->records[] = $record; - } - - public function hasRecords($level) - { - return isset($this->recordsByLevel[$level]); - } - - public function hasRecord($record, $level) - { - if (is_string($record)) { - $record = ['message' => $record]; - } - return $this->hasRecordThatPasses(function ($rec) use ($record) { - if ($rec['message'] !== $record['message']) { - return false; - } - if (isset($record['context']) && $rec['context'] !== $record['context']) { - return false; - } - return true; - }, $level); - } - - public function hasRecordThatContains($message, $level) - { - return $this->hasRecordThatPasses(function ($rec) use ($message) { - return strpos($rec['message'], $message) !== false; - }, $level); - } - - public function hasRecordThatMatches($regex, $level) - { - return $this->hasRecordThatPasses(function ($rec) use ($regex) { - return preg_match($regex, $rec['message']) > 0; - }, $level); - } - - public function hasRecordThatPasses(callable $predicate, $level) - { - if (!isset($this->recordsByLevel[$level])) { - return false; - } - foreach ($this->recordsByLevel[$level] as $i => $rec) { - if (call_user_func($predicate, $rec, $i)) { - return true; - } - } - return false; - } - - public function __call($method, $args) - { - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { - $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3]; - $level = strtolower($matches[2]); - if (method_exists($this, $genericMethod)) { - $args[] = $level; - return call_user_func_array([$this, $genericMethod], $args); - } - } - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); - } - - public function reset() - { - $this->records = []; - $this->recordsByLevel = []; - } -} diff --git a/vendor/psr/log/composer.json b/vendor/psr/log/composer.json index ca05695..879fc6f 100644 --- a/vendor/psr/log/composer.json +++ b/vendor/psr/log/composer.json @@ -11,16 +11,16 @@ } ], "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Log\\": "src" } }, "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "3.x-dev" } } } diff --git a/vendor/psr/log/src/AbstractLogger.php b/vendor/psr/log/src/AbstractLogger.php new file mode 100644 index 0000000..d60a091 --- /dev/null +++ b/vendor/psr/log/src/AbstractLogger.php @@ -0,0 +1,15 @@ +logger = $logger; } diff --git a/vendor/psr/log/Psr/Log/LoggerInterface.php b/vendor/psr/log/src/LoggerInterface.php similarity index 66% rename from vendor/psr/log/Psr/Log/LoggerInterface.php rename to vendor/psr/log/src/LoggerInterface.php index 2206cfd..b3a24b5 100644 --- a/vendor/psr/log/Psr/Log/LoggerInterface.php +++ b/vendor/psr/log/src/LoggerInterface.php @@ -22,12 +22,12 @@ interface LoggerInterface /** * System is unusable. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function emergency($message, array $context = array()); + public function emergency(string|\Stringable $message, array $context = []): void; /** * Action must be taken immediately. @@ -35,35 +35,35 @@ interface LoggerInterface * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function alert($message, array $context = array()); + public function alert(string|\Stringable $message, array $context = []): void; /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function critical($message, array $context = array()); + public function critical(string|\Stringable $message, array $context = []): void; /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function error($message, array $context = array()); + public function error(string|\Stringable $message, array $context = []): void; /** * Exceptional occurrences that are not errors. @@ -71,55 +71,55 @@ interface LoggerInterface * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function warning($message, array $context = array()); + public function warning(string|\Stringable $message, array $context = []): void; /** * Normal but significant events. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function notice($message, array $context = array()); + public function notice(string|\Stringable $message, array $context = []): void; /** * Interesting events. * * Example: User logs in, SQL logs. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function info($message, array $context = array()); + public function info(string|\Stringable $message, array $context = []): void; /** * Detailed debug information. * - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void */ - public function debug($message, array $context = array()); + public function debug(string|\Stringable $message, array $context = []): void; /** * Logs with an arbitrary level. * * @param mixed $level - * @param string $message + * @param string|\Stringable $message * @param mixed[] $context * * @return void * * @throws \Psr\Log\InvalidArgumentException */ - public function log($level, $message, array $context = array()); + public function log($level, string|\Stringable $message, array $context = []): void; } diff --git a/vendor/psr/log/Psr/Log/LoggerTrait.php b/vendor/psr/log/src/LoggerTrait.php similarity index 69% rename from vendor/psr/log/Psr/Log/LoggerTrait.php rename to vendor/psr/log/src/LoggerTrait.php index e392fef..9c8733f 100644 --- a/vendor/psr/log/Psr/Log/LoggerTrait.php +++ b/vendor/psr/log/src/LoggerTrait.php @@ -15,12 +15,12 @@ trait LoggerTrait /** * System is unusable. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function emergency($message, array $context = array()) + public function emergency(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::EMERGENCY, $message, $context); } @@ -31,12 +31,12 @@ trait LoggerTrait * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function alert($message, array $context = array()) + public function alert(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::ALERT, $message, $context); } @@ -46,12 +46,12 @@ trait LoggerTrait * * Example: Application component unavailable, unexpected exception. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function critical($message, array $context = array()) + public function critical(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::CRITICAL, $message, $context); } @@ -60,12 +60,12 @@ trait LoggerTrait * Runtime errors that do not require immediate action but should typically * be logged and monitored. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function error($message, array $context = array()) + public function error(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::ERROR, $message, $context); } @@ -76,12 +76,12 @@ trait LoggerTrait * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function warning($message, array $context = array()) + public function warning(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::WARNING, $message, $context); } @@ -89,12 +89,12 @@ trait LoggerTrait /** * Normal but significant events. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function notice($message, array $context = array()) + public function notice(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::NOTICE, $message, $context); } @@ -104,12 +104,12 @@ trait LoggerTrait * * Example: User logs in, SQL logs. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function info($message, array $context = array()) + public function info(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::INFO, $message, $context); } @@ -117,12 +117,12 @@ trait LoggerTrait /** * Detailed debug information. * - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void */ - public function debug($message, array $context = array()) + public function debug(string|\Stringable $message, array $context = []): void { $this->log(LogLevel::DEBUG, $message, $context); } @@ -131,12 +131,12 @@ trait LoggerTrait * Logs with an arbitrary level. * * @param mixed $level - * @param string $message + * @param string|\Stringable $message * @param array $context * * @return void * * @throws \Psr\Log\InvalidArgumentException */ - abstract public function log($level, $message, array $context = array()); + abstract public function log($level, string|\Stringable $message, array $context = []): void; } diff --git a/vendor/psr/log/Psr/Log/NullLogger.php b/vendor/psr/log/src/NullLogger.php similarity index 78% rename from vendor/psr/log/Psr/Log/NullLogger.php rename to vendor/psr/log/src/NullLogger.php index c8f7293..c1cc3c0 100644 --- a/vendor/psr/log/Psr/Log/NullLogger.php +++ b/vendor/psr/log/src/NullLogger.php @@ -16,14 +16,14 @@ class NullLogger extends AbstractLogger * Logs with an arbitrary level. * * @param mixed $level - * @param string $message - * @param array $context + * @param string|\Stringable $message + * @param array $context * * @return void * * @throws \Psr\Log\InvalidArgumentException */ - public function log($level, $message, array $context = array()) + public function log($level, string|\Stringable $message, array $context = []): void { // noop } diff --git a/vendor/psr/simple-cache/composer.json b/vendor/psr/simple-cache/composer.json index 2978fa5..f307a84 100644 --- a/vendor/psr/simple-cache/composer.json +++ b/vendor/psr/simple-cache/composer.json @@ -6,11 +6,11 @@ "authors": [ { "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "homepage": "https://www.php-fig.org/" } ], "require": { - "php": ">=5.3.0" + "php": ">=8.0.0" }, "autoload": { "psr-4": { @@ -19,7 +19,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "3.0.x-dev" } } } diff --git a/vendor/psr/simple-cache/src/CacheException.php b/vendor/psr/simple-cache/src/CacheException.php index eba5381..f61b24c 100644 --- a/vendor/psr/simple-cache/src/CacheException.php +++ b/vendor/psr/simple-cache/src/CacheException.php @@ -5,6 +5,6 @@ namespace Psr\SimpleCache; /** * Interface used for all types of exceptions thrown by the implementing library. */ -interface CacheException +interface CacheException extends \Throwable { } diff --git a/vendor/psr/simple-cache/src/CacheInterface.php b/vendor/psr/simple-cache/src/CacheInterface.php index 99e8d95..671e340 100644 --- a/vendor/psr/simple-cache/src/CacheInterface.php +++ b/vendor/psr/simple-cache/src/CacheInterface.php @@ -15,7 +15,7 @@ interface CacheInterface * @throws \Psr\SimpleCache\InvalidArgumentException * MUST be thrown if the $key string is not a legal value. */ - public function get($key, $default = null); + public function get(string $key, mixed $default = null): mixed; /** * Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. @@ -31,7 +31,7 @@ interface CacheInterface * @throws \Psr\SimpleCache\InvalidArgumentException * MUST be thrown if the $key string is not a legal value. */ - public function set($key, $value, $ttl = null); + public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool; /** * Delete an item from the cache by its unique key. @@ -43,28 +43,28 @@ interface CacheInterface * @throws \Psr\SimpleCache\InvalidArgumentException * MUST be thrown if the $key string is not a legal value. */ - public function delete($key); + public function delete(string $key): bool; /** * Wipes clean the entire cache's keys. * * @return bool True on success and false on failure. */ - public function clear(); + public function clear(): bool; /** * Obtains multiple cache items by their unique keys. * - * @param iterable $keys A list of keys that can obtained in a single operation. - * @param mixed $default Default value to return for keys that do not exist. + * @param iterable $keys A list of keys that can be obtained in a single operation. + * @param mixed $default Default value to return for keys that do not exist. * - * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. + * @return iterable A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value. * * @throws \Psr\SimpleCache\InvalidArgumentException * MUST be thrown if $keys is neither an array nor a Traversable, * or if any of the $keys are not a legal value. */ - public function getMultiple($keys, $default = null); + public function getMultiple(iterable $keys, mixed $default = null): iterable; /** * Persists a set of key => value pairs in the cache, with an optional TTL. @@ -80,12 +80,12 @@ interface CacheInterface * MUST be thrown if $values is neither an array nor a Traversable, * or if any of the $values are not a legal value. */ - public function setMultiple($values, $ttl = null); + public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool; /** * Deletes multiple cache items in a single operation. * - * @param iterable $keys A list of string-based keys to be deleted. + * @param iterable $keys A list of string-based keys to be deleted. * * @return bool True if the items were successfully removed. False if there was an error. * @@ -93,7 +93,7 @@ interface CacheInterface * MUST be thrown if $keys is neither an array nor a Traversable, * or if any of the $keys are not a legal value. */ - public function deleteMultiple($keys); + public function deleteMultiple(iterable $keys): bool; /** * Determines whether an item is present in the cache. @@ -110,5 +110,5 @@ interface CacheInterface * @throws \Psr\SimpleCache\InvalidArgumentException * MUST be thrown if the $key string is not a legal value. */ - public function has($key); + public function has(string $key): bool; } diff --git a/vendor/services.php b/vendor/services.php index 4426f92..2cf0142 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,10 +1,8 @@ 'taoser\\addons\\Service', 1 => 'think\\captcha\\CaptchaService', - 2 => 'think\\migration\\Service', - 3 => 'think\\app\\Service', - 4 => 'think\\trace\\Service', + 2 => 'think\\app\\Service', ); \ No newline at end of file diff --git a/vendor/symfony/deprecation-contracts/CHANGELOG.md b/vendor/symfony/deprecation-contracts/CHANGELOG.md new file mode 100644 index 0000000..7932e26 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/CHANGELOG.md @@ -0,0 +1,5 @@ +CHANGELOG +========= + +The changelog is maintained for all Symfony contracts at the following URL: +https://github.com/symfony/contracts/blob/main/CHANGELOG.md diff --git a/vendor/league/flysystem-cached-adapter/LICENSE b/vendor/symfony/deprecation-contracts/LICENSE similarity index 95% rename from vendor/league/flysystem-cached-adapter/LICENSE rename to vendor/symfony/deprecation-contracts/LICENSE index 666f6c8..0ed3a24 100644 --- a/vendor/league/flysystem-cached-adapter/LICENSE +++ b/vendor/symfony/deprecation-contracts/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015 Frank de Jonge +Copyright (c) 2020-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/symfony/deprecation-contracts/README.md b/vendor/symfony/deprecation-contracts/README.md new file mode 100644 index 0000000..9814864 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/README.md @@ -0,0 +1,26 @@ +Symfony Deprecation Contracts +============================= + +A generic function and convention to trigger deprecation notices. + +This package provides a single global function named `trigger_deprecation()` that triggers silenced deprecation notices. + +By using a custom PHP error handler such as the one provided by the Symfony ErrorHandler component, +the triggered deprecations can be caught and logged for later discovery, both on dev and prod environments. + +The function requires at least 3 arguments: + - the name of the Composer package that is triggering the deprecation + - the version of the package that introduced the deprecation + - the message of the deprecation + - more arguments can be provided: they will be inserted in the message using `printf()` formatting + +Example: +```php +trigger_deprecation('symfony/blockchain', '8.9', 'Using "%s" is deprecated, use "%s" instead.', 'bitcoin', 'fabcoin'); +``` + +This will generate the following message: +`Since symfony/blockchain 8.9: Using "bitcoin" is deprecated, use "fabcoin" instead.` + +While not recommended, the deprecation notices can be completely ignored by declaring an empty +`function trigger_deprecation() {}` in your application. diff --git a/vendor/symfony/polyfill-php72/composer.json b/vendor/symfony/deprecation-contracts/composer.json similarity index 52% rename from vendor/symfony/polyfill-php72/composer.json rename to vendor/symfony/deprecation-contracts/composer.json index 5f17af3..c6d02d8 100644 --- a/vendor/symfony/polyfill-php72/composer.json +++ b/vendor/symfony/deprecation-contracts/composer.json @@ -1,8 +1,7 @@ { - "name": "symfony/polyfill-php72", + "name": "symfony/deprecation-contracts", "type": "library", - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], + "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "license": "MIT", "authors": [ @@ -16,20 +15,21 @@ } ], "require": { - "php": ">=7.1" + "php": ">=8.1" }, "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php72\\": "" }, - "files": [ "bootstrap.php" ] + "files": [ + "function.php" + ] }, "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "3.4-dev" }, "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } } } diff --git a/vendor/symfony/deprecation-contracts/function.php b/vendor/symfony/deprecation-contracts/function.php new file mode 100644 index 0000000..2d56512 --- /dev/null +++ b/vendor/symfony/deprecation-contracts/function.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (!function_exists('trigger_deprecation')) { + /** + * Triggers a silenced deprecation notice. + * + * @param string $package The name of the Composer package that is triggering the deprecation + * @param string $version The version of the package that introduced the deprecation + * @param string $message The message of the deprecation + * @param mixed ...$args Values to insert in the message using printf() formatting + * + * @author Nicolas Grekas + */ + function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void + { + @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED); + } +} diff --git a/vendor/symfony/polyfill-mbstring/LICENSE b/vendor/symfony/polyfill-mbstring/LICENSE deleted file mode 100644 index 4cd8bdd..0000000 --- a/vendor/symfony/polyfill-mbstring/LICENSE +++ /dev/null @@ -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. diff --git a/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php deleted file mode 100644 index bce5c4a..0000000 --- a/vendor/symfony/polyfill-mbstring/Mbstring.php +++ /dev/null @@ -1,874 +0,0 @@ - - * - * 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 - * - * @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) || (null !== $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, -1, \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; - } - if (\is_int($c) || 'long' === $c || 'entity' === $c) { - 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; - } -} diff --git a/vendor/symfony/polyfill-mbstring/README.md b/vendor/symfony/polyfill-mbstring/README.md deleted file mode 100644 index 478b40d..0000000 --- a/vendor/symfony/polyfill-mbstring/README.md +++ /dev/null @@ -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/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php deleted file mode 100644 index fac60b0..0000000 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php +++ /dev/null @@ -1,1397 +0,0 @@ - 'a', - 'B' => 'b', - 'C' => 'c', - 'D' => 'd', - 'E' => 'e', - 'F' => 'f', - 'G' => 'g', - 'H' => 'h', - 'I' => 'i', - 'J' => 'j', - 'K' => 'k', - 'L' => 'l', - 'M' => 'm', - 'N' => 'n', - 'O' => 'o', - 'P' => 'p', - 'Q' => 'q', - 'R' => 'r', - 'S' => 's', - 'T' => 't', - 'U' => 'u', - 'V' => 'v', - 'W' => 'w', - 'X' => 'x', - 'Y' => 'y', - 'Z' => 'z', - 'À' => 'à', - 'Á' => 'á', - 'Â' => 'â', - 'Ã' => 'ã', - 'Ä' => 'ä', - 'Å' => 'å', - 'Æ' => 'æ', - 'Ç' => 'ç', - 'È' => 'è', - 'É' => 'é', - 'Ê' => 'ê', - 'Ë' => 'ë', - 'Ì' => 'ì', - 'Í' => 'í', - 'Î' => 'î', - 'Ï' => 'ï', - 'Ð' => 'ð', - 'Ñ' => 'ñ', - 'Ò' => 'ò', - 'Ó' => 'ó', - 'Ô' => 'ô', - 'Õ' => 'õ', - 'Ö' => 'ö', - 'Ø' => 'ø', - 'Ù' => 'ù', - 'Ú' => 'ú', - 'Û' => 'û', - 'Ü' => 'ü', - 'Ý' => 'ý', - 'Þ' => 'þ', - 'Ā' => 'ā', - 'Ă' => 'ă', - 'Ą' => 'ą', - 'Ć' => 'ć', - 'Ĉ' => 'ĉ', - 'Ċ' => 'ċ', - 'Č' => 'č', - 'Ď' => 'ď', - 'Đ' => 'đ', - 'Ē' => 'ē', - 'Ĕ' => 'ĕ', - 'Ė' => 'ė', - 'Ę' => 'ę', - 'Ě' => 'ě', - 'Ĝ' => 'ĝ', - 'Ğ' => 'ğ', - 'Ġ' => 'ġ', - 'Ģ' => 'ģ', - 'Ĥ' => 'ĥ', - 'Ħ' => 'ħ', - 'Ĩ' => 'ĩ', - 'Ī' => 'ī', - 'Ĭ' => 'ĭ', - 'Į' => 'į', - 'İ' => 'i̇', - 'IJ' => 'ij', - 'Ĵ' => 'ĵ', - 'Ķ' => 'ķ', - 'Ĺ' => 'ĺ', - 'Ļ' => 'ļ', - 'Ľ' => 'ľ', - 'Ŀ' => 'ŀ', - 'Ł' => 'ł', - 'Ń' => 'ń', - 'Ņ' => 'ņ', - 'Ň' => 'ň', - 'Ŋ' => 'ŋ', - 'Ō' => 'ō', - 'Ŏ' => 'ŏ', - 'Ő' => 'ő', - 'Œ' => 'œ', - 'Ŕ' => 'ŕ', - 'Ŗ' => 'ŗ', - 'Ř' => 'ř', - 'Ś' => 'ś', - 'Ŝ' => 'ŝ', - 'Ş' => 'ş', - 'Š' => 'š', - 'Ţ' => 'ţ', - 'Ť' => 'ť', - 'Ŧ' => 'ŧ', - 'Ũ' => 'ũ', - 'Ū' => 'ū', - 'Ŭ' => 'ŭ', - 'Ů' => 'ů', - 'Ű' => 'ű', - 'Ų' => 'ų', - 'Ŵ' => 'ŵ', - 'Ŷ' => 'ŷ', - 'Ÿ' => 'ÿ', - 'Ź' => 'ź', - 'Ż' => 'ż', - 'Ž' => 'ž', - 'Ɓ' => 'ɓ', - 'Ƃ' => 'ƃ', - 'Ƅ' => 'ƅ', - 'Ɔ' => 'ɔ', - 'Ƈ' => 'ƈ', - 'Ɖ' => 'ɖ', - 'Ɗ' => 'ɗ', - 'Ƌ' => 'ƌ', - 'Ǝ' => 'ǝ', - 'Ə' => 'ə', - 'Ɛ' => 'ɛ', - 'Ƒ' => 'ƒ', - 'Ɠ' => 'ɠ', - 'Ɣ' => 'ɣ', - 'Ɩ' => 'ɩ', - 'Ɨ' => 'ɨ', - 'Ƙ' => 'ƙ', - 'Ɯ' => 'ɯ', - 'Ɲ' => 'ɲ', - 'Ɵ' => 'ɵ', - 'Ơ' => 'ơ', - 'Ƣ' => 'ƣ', - 'Ƥ' => 'ƥ', - 'Ʀ' => 'ʀ', - 'Ƨ' => 'ƨ', - 'Ʃ' => 'ʃ', - 'Ƭ' => 'ƭ', - 'Ʈ' => 'ʈ', - 'Ư' => 'ư', - 'Ʊ' => 'ʊ', - 'Ʋ' => 'ʋ', - 'Ƴ' => 'ƴ', - 'Ƶ' => 'ƶ', - 'Ʒ' => 'ʒ', - 'Ƹ' => 'ƹ', - 'Ƽ' => 'ƽ', - 'DŽ' => 'dž', - 'Dž' => 'dž', - 'LJ' => 'lj', - 'Lj' => 'lj', - 'NJ' => 'nj', - 'Nj' => 'nj', - 'Ǎ' => 'ǎ', - 'Ǐ' => 'ǐ', - 'Ǒ' => 'ǒ', - 'Ǔ' => 'ǔ', - 'Ǖ' => 'ǖ', - 'Ǘ' => 'ǘ', - 'Ǚ' => 'ǚ', - 'Ǜ' => 'ǜ', - 'Ǟ' => 'ǟ', - 'Ǡ' => 'ǡ', - 'Ǣ' => 'ǣ', - 'Ǥ' => 'ǥ', - 'Ǧ' => 'ǧ', - 'Ǩ' => 'ǩ', - 'Ǫ' => 'ǫ', - 'Ǭ' => 'ǭ', - 'Ǯ' => 'ǯ', - 'DZ' => 'dz', - 'Dz' => 'dz', - 'Ǵ' => 'ǵ', - 'Ƕ' => 'ƕ', - 'Ƿ' => 'ƿ', - 'Ǹ' => 'ǹ', - 'Ǻ' => 'ǻ', - 'Ǽ' => 'ǽ', - 'Ǿ' => 'ǿ', - 'Ȁ' => 'ȁ', - 'Ȃ' => 'ȃ', - 'Ȅ' => 'ȅ', - 'Ȇ' => 'ȇ', - 'Ȉ' => 'ȉ', - 'Ȋ' => 'ȋ', - 'Ȍ' => 'ȍ', - 'Ȏ' => 'ȏ', - 'Ȑ' => 'ȑ', - 'Ȓ' => 'ȓ', - 'Ȕ' => 'ȕ', - 'Ȗ' => 'ȗ', - 'Ș' => 'ș', - 'Ț' => 'ț', - 'Ȝ' => 'ȝ', - 'Ȟ' => 'ȟ', - 'Ƞ' => 'ƞ', - 'Ȣ' => 'ȣ', - 'Ȥ' => 'ȥ', - 'Ȧ' => 'ȧ', - 'Ȩ' => 'ȩ', - 'Ȫ' => 'ȫ', - 'Ȭ' => 'ȭ', - 'Ȯ' => 'ȯ', - 'Ȱ' => 'ȱ', - 'Ȳ' => 'ȳ', - 'Ⱥ' => 'ⱥ', - 'Ȼ' => 'ȼ', - 'Ƚ' => 'ƚ', - 'Ⱦ' => 'ⱦ', - 'Ɂ' => 'ɂ', - 'Ƀ' => 'ƀ', - 'Ʉ' => 'ʉ', - 'Ʌ' => 'ʌ', - 'Ɇ' => 'ɇ', - 'Ɉ' => 'ɉ', - 'Ɋ' => 'ɋ', - 'Ɍ' => 'ɍ', - 'Ɏ' => 'ɏ', - 'Ͱ' => 'ͱ', - 'Ͳ' => 'ͳ', - 'Ͷ' => 'ͷ', - 'Ϳ' => 'ϳ', - 'Ά' => 'ά', - 'Έ' => 'έ', - 'Ή' => 'ή', - 'Ί' => 'ί', - 'Ό' => 'ό', - 'Ύ' => 'ύ', - 'Ώ' => 'ώ', - 'Α' => 'α', - 'Β' => 'β', - 'Γ' => 'γ', - 'Δ' => 'δ', - 'Ε' => 'ε', - 'Ζ' => 'ζ', - 'Η' => 'η', - 'Θ' => 'θ', - 'Ι' => 'ι', - 'Κ' => 'κ', - 'Λ' => 'λ', - 'Μ' => 'μ', - 'Ν' => 'ν', - 'Ξ' => 'ξ', - 'Ο' => 'ο', - 'Π' => 'π', - 'Ρ' => 'ρ', - 'Σ' => 'σ', - 'Τ' => 'τ', - 'Υ' => 'υ', - 'Φ' => 'φ', - 'Χ' => 'χ', - 'Ψ' => 'ψ', - 'Ω' => 'ω', - 'Ϊ' => 'ϊ', - 'Ϋ' => 'ϋ', - 'Ϗ' => 'ϗ', - 'Ϙ' => 'ϙ', - 'Ϛ' => 'ϛ', - 'Ϝ' => 'ϝ', - 'Ϟ' => 'ϟ', - 'Ϡ' => 'ϡ', - 'Ϣ' => 'ϣ', - 'Ϥ' => 'ϥ', - 'Ϧ' => 'ϧ', - 'Ϩ' => 'ϩ', - 'Ϫ' => 'ϫ', - 'Ϭ' => 'ϭ', - 'Ϯ' => 'ϯ', - 'ϴ' => 'θ', - 'Ϸ' => 'ϸ', - 'Ϲ' => 'ϲ', - 'Ϻ' => 'ϻ', - 'Ͻ' => 'ͻ', - 'Ͼ' => 'ͼ', - 'Ͽ' => 'ͽ', - 'Ѐ' => 'ѐ', - 'Ё' => 'ё', - 'Ђ' => 'ђ', - 'Ѓ' => 'ѓ', - 'Є' => 'є', - 'Ѕ' => 'ѕ', - 'І' => 'і', - 'Ї' => 'ї', - 'Ј' => 'ј', - 'Љ' => 'љ', - 'Њ' => 'њ', - 'Ћ' => 'ћ', - 'Ќ' => 'ќ', - 'Ѝ' => 'ѝ', - 'Ў' => 'ў', - 'Џ' => 'џ', - 'А' => 'а', - 'Б' => 'б', - 'В' => 'в', - 'Г' => 'г', - 'Д' => 'д', - 'Е' => 'е', - 'Ж' => 'ж', - 'З' => 'з', - 'И' => 'и', - 'Й' => 'й', - 'К' => 'к', - 'Л' => 'л', - 'М' => 'м', - 'Н' => 'н', - 'О' => 'о', - 'П' => 'п', - 'Р' => 'р', - 'С' => 'с', - 'Т' => 'т', - 'У' => 'у', - 'Ф' => 'ф', - 'Х' => 'х', - 'Ц' => 'ц', - 'Ч' => 'ч', - 'Ш' => 'ш', - 'Щ' => 'щ', - 'Ъ' => 'ъ', - 'Ы' => 'ы', - 'Ь' => 'ь', - 'Э' => 'э', - 'Ю' => 'ю', - 'Я' => 'я', - 'Ѡ' => 'ѡ', - 'Ѣ' => 'ѣ', - 'Ѥ' => 'ѥ', - 'Ѧ' => 'ѧ', - 'Ѩ' => 'ѩ', - 'Ѫ' => 'ѫ', - 'Ѭ' => 'ѭ', - 'Ѯ' => 'ѯ', - 'Ѱ' => 'ѱ', - 'Ѳ' => 'ѳ', - 'Ѵ' => 'ѵ', - 'Ѷ' => 'ѷ', - 'Ѹ' => 'ѹ', - 'Ѻ' => 'ѻ', - 'Ѽ' => 'ѽ', - 'Ѿ' => 'ѿ', - 'Ҁ' => 'ҁ', - 'Ҋ' => 'ҋ', - 'Ҍ' => 'ҍ', - 'Ҏ' => 'ҏ', - 'Ґ' => 'ґ', - 'Ғ' => 'ғ', - 'Ҕ' => 'ҕ', - 'Җ' => 'җ', - 'Ҙ' => 'ҙ', - 'Қ' => 'қ', - 'Ҝ' => 'ҝ', - 'Ҟ' => 'ҟ', - 'Ҡ' => 'ҡ', - 'Ң' => 'ң', - 'Ҥ' => 'ҥ', - 'Ҧ' => 'ҧ', - 'Ҩ' => 'ҩ', - 'Ҫ' => 'ҫ', - 'Ҭ' => 'ҭ', - 'Ү' => 'ү', - 'Ұ' => 'ұ', - 'Ҳ' => 'ҳ', - 'Ҵ' => 'ҵ', - 'Ҷ' => 'ҷ', - 'Ҹ' => 'ҹ', - 'Һ' => 'һ', - 'Ҽ' => 'ҽ', - 'Ҿ' => 'ҿ', - 'Ӏ' => 'ӏ', - 'Ӂ' => 'ӂ', - 'Ӄ' => 'ӄ', - 'Ӆ' => 'ӆ', - 'Ӈ' => 'ӈ', - 'Ӊ' => 'ӊ', - 'Ӌ' => 'ӌ', - 'Ӎ' => 'ӎ', - 'Ӑ' => 'ӑ', - 'Ӓ' => 'ӓ', - 'Ӕ' => 'ӕ', - 'Ӗ' => 'ӗ', - 'Ә' => 'ә', - 'Ӛ' => 'ӛ', - 'Ӝ' => 'ӝ', - 'Ӟ' => 'ӟ', - 'Ӡ' => 'ӡ', - 'Ӣ' => 'ӣ', - 'Ӥ' => 'ӥ', - 'Ӧ' => 'ӧ', - 'Ө' => 'ө', - 'Ӫ' => 'ӫ', - 'Ӭ' => 'ӭ', - 'Ӯ' => 'ӯ', - 'Ӱ' => 'ӱ', - 'Ӳ' => 'ӳ', - 'Ӵ' => 'ӵ', - 'Ӷ' => 'ӷ', - 'Ӹ' => 'ӹ', - 'Ӻ' => 'ӻ', - 'Ӽ' => 'ӽ', - 'Ӿ' => 'ӿ', - 'Ԁ' => 'ԁ', - 'Ԃ' => 'ԃ', - 'Ԅ' => 'ԅ', - 'Ԇ' => 'ԇ', - 'Ԉ' => 'ԉ', - 'Ԋ' => 'ԋ', - 'Ԍ' => 'ԍ', - 'Ԏ' => 'ԏ', - 'Ԑ' => 'ԑ', - 'Ԓ' => 'ԓ', - 'Ԕ' => 'ԕ', - 'Ԗ' => 'ԗ', - 'Ԙ' => 'ԙ', - 'Ԛ' => 'ԛ', - 'Ԝ' => 'ԝ', - 'Ԟ' => 'ԟ', - 'Ԡ' => 'ԡ', - 'Ԣ' => 'ԣ', - 'Ԥ' => 'ԥ', - 'Ԧ' => 'ԧ', - 'Ԩ' => 'ԩ', - 'Ԫ' => 'ԫ', - 'Ԭ' => 'ԭ', - 'Ԯ' => 'ԯ', - 'Ա' => 'ա', - 'Բ' => 'բ', - 'Գ' => 'գ', - 'Դ' => 'դ', - 'Ե' => 'ե', - 'Զ' => 'զ', - 'Է' => 'է', - 'Ը' => 'ը', - 'Թ' => 'թ', - 'Ժ' => 'ժ', - 'Ի' => 'ի', - 'Լ' => 'լ', - 'Խ' => 'խ', - 'Ծ' => 'ծ', - 'Կ' => 'կ', - 'Հ' => 'հ', - 'Ձ' => 'ձ', - 'Ղ' => 'ղ', - 'Ճ' => 'ճ', - 'Մ' => 'մ', - 'Յ' => 'յ', - 'Ն' => 'ն', - 'Շ' => 'շ', - 'Ո' => 'ո', - 'Չ' => 'չ', - 'Պ' => 'պ', - 'Ջ' => 'ջ', - 'Ռ' => 'ռ', - 'Ս' => 'ս', - 'Վ' => 'վ', - 'Տ' => 'տ', - 'Ր' => 'ր', - 'Ց' => 'ց', - 'Ւ' => 'ւ', - 'Փ' => 'փ', - 'Ք' => 'ք', - 'Օ' => 'օ', - 'Ֆ' => 'ֆ', - 'Ⴀ' => 'ⴀ', - 'Ⴁ' => 'ⴁ', - 'Ⴂ' => 'ⴂ', - 'Ⴃ' => 'ⴃ', - 'Ⴄ' => 'ⴄ', - 'Ⴅ' => 'ⴅ', - 'Ⴆ' => 'ⴆ', - 'Ⴇ' => 'ⴇ', - 'Ⴈ' => 'ⴈ', - 'Ⴉ' => 'ⴉ', - 'Ⴊ' => 'ⴊ', - 'Ⴋ' => 'ⴋ', - 'Ⴌ' => 'ⴌ', - 'Ⴍ' => 'ⴍ', - 'Ⴎ' => 'ⴎ', - 'Ⴏ' => 'ⴏ', - 'Ⴐ' => 'ⴐ', - 'Ⴑ' => 'ⴑ', - 'Ⴒ' => 'ⴒ', - 'Ⴓ' => 'ⴓ', - 'Ⴔ' => 'ⴔ', - 'Ⴕ' => 'ⴕ', - 'Ⴖ' => 'ⴖ', - 'Ⴗ' => 'ⴗ', - 'Ⴘ' => 'ⴘ', - 'Ⴙ' => 'ⴙ', - 'Ⴚ' => 'ⴚ', - 'Ⴛ' => 'ⴛ', - 'Ⴜ' => 'ⴜ', - 'Ⴝ' => 'ⴝ', - 'Ⴞ' => 'ⴞ', - 'Ⴟ' => 'ⴟ', - 'Ⴠ' => 'ⴠ', - 'Ⴡ' => 'ⴡ', - 'Ⴢ' => 'ⴢ', - 'Ⴣ' => 'ⴣ', - 'Ⴤ' => 'ⴤ', - 'Ⴥ' => 'ⴥ', - 'Ⴧ' => 'ⴧ', - 'Ⴭ' => 'ⴭ', - 'Ꭰ' => 'ꭰ', - 'Ꭱ' => 'ꭱ', - 'Ꭲ' => 'ꭲ', - 'Ꭳ' => 'ꭳ', - 'Ꭴ' => 'ꭴ', - 'Ꭵ' => 'ꭵ', - 'Ꭶ' => 'ꭶ', - 'Ꭷ' => 'ꭷ', - 'Ꭸ' => 'ꭸ', - 'Ꭹ' => 'ꭹ', - 'Ꭺ' => 'ꭺ', - 'Ꭻ' => 'ꭻ', - 'Ꭼ' => 'ꭼ', - 'Ꭽ' => 'ꭽ', - 'Ꭾ' => 'ꭾ', - 'Ꭿ' => 'ꭿ', - 'Ꮀ' => 'ꮀ', - 'Ꮁ' => 'ꮁ', - 'Ꮂ' => 'ꮂ', - 'Ꮃ' => 'ꮃ', - 'Ꮄ' => 'ꮄ', - 'Ꮅ' => 'ꮅ', - 'Ꮆ' => 'ꮆ', - 'Ꮇ' => 'ꮇ', - 'Ꮈ' => 'ꮈ', - 'Ꮉ' => 'ꮉ', - 'Ꮊ' => 'ꮊ', - 'Ꮋ' => 'ꮋ', - 'Ꮌ' => 'ꮌ', - 'Ꮍ' => 'ꮍ', - 'Ꮎ' => 'ꮎ', - 'Ꮏ' => 'ꮏ', - 'Ꮐ' => 'ꮐ', - 'Ꮑ' => 'ꮑ', - 'Ꮒ' => 'ꮒ', - 'Ꮓ' => 'ꮓ', - 'Ꮔ' => 'ꮔ', - 'Ꮕ' => 'ꮕ', - 'Ꮖ' => 'ꮖ', - 'Ꮗ' => 'ꮗ', - 'Ꮘ' => 'ꮘ', - 'Ꮙ' => 'ꮙ', - 'Ꮚ' => 'ꮚ', - 'Ꮛ' => 'ꮛ', - 'Ꮜ' => 'ꮜ', - 'Ꮝ' => 'ꮝ', - 'Ꮞ' => 'ꮞ', - 'Ꮟ' => 'ꮟ', - 'Ꮠ' => 'ꮠ', - 'Ꮡ' => 'ꮡ', - 'Ꮢ' => 'ꮢ', - 'Ꮣ' => 'ꮣ', - 'Ꮤ' => 'ꮤ', - 'Ꮥ' => 'ꮥ', - 'Ꮦ' => 'ꮦ', - 'Ꮧ' => 'ꮧ', - 'Ꮨ' => 'ꮨ', - 'Ꮩ' => 'ꮩ', - 'Ꮪ' => 'ꮪ', - 'Ꮫ' => 'ꮫ', - 'Ꮬ' => 'ꮬ', - 'Ꮭ' => 'ꮭ', - 'Ꮮ' => 'ꮮ', - 'Ꮯ' => 'ꮯ', - 'Ꮰ' => 'ꮰ', - 'Ꮱ' => 'ꮱ', - 'Ꮲ' => 'ꮲ', - 'Ꮳ' => 'ꮳ', - 'Ꮴ' => 'ꮴ', - 'Ꮵ' => 'ꮵ', - 'Ꮶ' => 'ꮶ', - 'Ꮷ' => 'ꮷ', - 'Ꮸ' => 'ꮸ', - 'Ꮹ' => 'ꮹ', - 'Ꮺ' => 'ꮺ', - 'Ꮻ' => 'ꮻ', - 'Ꮼ' => 'ꮼ', - 'Ꮽ' => 'ꮽ', - 'Ꮾ' => 'ꮾ', - 'Ꮿ' => 'ꮿ', - 'Ᏸ' => 'ᏸ', - 'Ᏹ' => 'ᏹ', - 'Ᏺ' => 'ᏺ', - 'Ᏻ' => 'ᏻ', - 'Ᏼ' => 'ᏼ', - 'Ᏽ' => 'ᏽ', - 'Ა' => 'ა', - 'Ბ' => 'ბ', - 'Გ' => 'გ', - 'Დ' => 'დ', - 'Ე' => 'ე', - 'Ვ' => 'ვ', - 'Ზ' => 'ზ', - 'Თ' => 'თ', - 'Ი' => 'ი', - 'Კ' => 'კ', - 'Ლ' => 'ლ', - 'Მ' => 'მ', - 'Ნ' => 'ნ', - 'Ო' => 'ო', - 'Პ' => 'პ', - 'Ჟ' => 'ჟ', - 'Რ' => 'რ', - 'Ს' => 'ს', - 'Ტ' => 'ტ', - 'Უ' => 'უ', - 'Ფ' => 'ფ', - 'Ქ' => 'ქ', - 'Ღ' => 'ღ', - 'Ყ' => 'ყ', - 'Შ' => 'შ', - 'Ჩ' => 'ჩ', - 'Ც' => 'ც', - 'Ძ' => 'ძ', - 'Წ' => 'წ', - 'Ჭ' => 'ჭ', - 'Ხ' => 'ხ', - 'Ჯ' => 'ჯ', - 'Ჰ' => 'ჰ', - 'Ჱ' => 'ჱ', - 'Ჲ' => 'ჲ', - 'Ჳ' => 'ჳ', - 'Ჴ' => 'ჴ', - 'Ჵ' => 'ჵ', - 'Ჶ' => 'ჶ', - 'Ჷ' => 'ჷ', - 'Ჸ' => 'ჸ', - 'Ჹ' => 'ჹ', - 'Ჺ' => 'ჺ', - 'Ჽ' => 'ჽ', - 'Ჾ' => 'ჾ', - 'Ჿ' => 'ჿ', - 'Ḁ' => 'ḁ', - 'Ḃ' => 'ḃ', - 'Ḅ' => 'ḅ', - 'Ḇ' => 'ḇ', - 'Ḉ' => 'ḉ', - 'Ḋ' => 'ḋ', - 'Ḍ' => 'ḍ', - 'Ḏ' => 'ḏ', - 'Ḑ' => 'ḑ', - 'Ḓ' => 'ḓ', - 'Ḕ' => 'ḕ', - 'Ḗ' => 'ḗ', - 'Ḙ' => 'ḙ', - 'Ḛ' => 'ḛ', - 'Ḝ' => 'ḝ', - 'Ḟ' => 'ḟ', - 'Ḡ' => 'ḡ', - 'Ḣ' => 'ḣ', - 'Ḥ' => 'ḥ', - 'Ḧ' => 'ḧ', - 'Ḩ' => 'ḩ', - 'Ḫ' => 'ḫ', - 'Ḭ' => 'ḭ', - 'Ḯ' => 'ḯ', - 'Ḱ' => 'ḱ', - 'Ḳ' => 'ḳ', - 'Ḵ' => 'ḵ', - 'Ḷ' => 'ḷ', - 'Ḹ' => 'ḹ', - 'Ḻ' => 'ḻ', - 'Ḽ' => 'ḽ', - 'Ḿ' => 'ḿ', - 'Ṁ' => 'ṁ', - 'Ṃ' => 'ṃ', - 'Ṅ' => 'ṅ', - 'Ṇ' => 'ṇ', - 'Ṉ' => 'ṉ', - 'Ṋ' => 'ṋ', - 'Ṍ' => 'ṍ', - 'Ṏ' => 'ṏ', - 'Ṑ' => 'ṑ', - 'Ṓ' => 'ṓ', - 'Ṕ' => 'ṕ', - 'Ṗ' => 'ṗ', - 'Ṙ' => 'ṙ', - 'Ṛ' => 'ṛ', - 'Ṝ' => 'ṝ', - 'Ṟ' => 'ṟ', - 'Ṡ' => 'ṡ', - 'Ṣ' => 'ṣ', - 'Ṥ' => 'ṥ', - 'Ṧ' => 'ṧ', - 'Ṩ' => 'ṩ', - 'Ṫ' => 'ṫ', - 'Ṭ' => 'ṭ', - 'Ṯ' => 'ṯ', - 'Ṱ' => 'ṱ', - 'Ṳ' => 'ṳ', - 'Ṵ' => 'ṵ', - 'Ṷ' => 'ṷ', - 'Ṹ' => 'ṹ', - 'Ṻ' => 'ṻ', - 'Ṽ' => 'ṽ', - 'Ṿ' => 'ṿ', - 'Ẁ' => 'ẁ', - 'Ẃ' => 'ẃ', - 'Ẅ' => 'ẅ', - 'Ẇ' => 'ẇ', - 'Ẉ' => 'ẉ', - 'Ẋ' => 'ẋ', - 'Ẍ' => 'ẍ', - 'Ẏ' => 'ẏ', - 'Ẑ' => 'ẑ', - 'Ẓ' => 'ẓ', - 'Ẕ' => 'ẕ', - 'ẞ' => 'ß', - 'Ạ' => 'ạ', - 'Ả' => 'ả', - 'Ấ' => 'ấ', - 'Ầ' => 'ầ', - 'Ẩ' => 'ẩ', - 'Ẫ' => 'ẫ', - 'Ậ' => 'ậ', - 'Ắ' => 'ắ', - 'Ằ' => 'ằ', - 'Ẳ' => 'ẳ', - 'Ẵ' => 'ẵ', - 'Ặ' => 'ặ', - 'Ẹ' => 'ẹ', - 'Ẻ' => 'ẻ', - 'Ẽ' => 'ẽ', - 'Ế' => 'ế', - 'Ề' => 'ề', - 'Ể' => 'ể', - 'Ễ' => 'ễ', - 'Ệ' => 'ệ', - 'Ỉ' => 'ỉ', - 'Ị' => 'ị', - 'Ọ' => 'ọ', - 'Ỏ' => 'ỏ', - 'Ố' => 'ố', - 'Ồ' => 'ồ', - 'Ổ' => 'ổ', - 'Ỗ' => 'ỗ', - 'Ộ' => 'ộ', - 'Ớ' => 'ớ', - 'Ờ' => 'ờ', - 'Ở' => 'ở', - 'Ỡ' => 'ỡ', - 'Ợ' => 'ợ', - 'Ụ' => 'ụ', - 'Ủ' => 'ủ', - 'Ứ' => 'ứ', - 'Ừ' => 'ừ', - 'Ử' => 'ử', - 'Ữ' => 'ữ', - 'Ự' => 'ự', - 'Ỳ' => 'ỳ', - 'Ỵ' => 'ỵ', - 'Ỷ' => 'ỷ', - 'Ỹ' => 'ỹ', - 'Ỻ' => 'ỻ', - 'Ỽ' => 'ỽ', - 'Ỿ' => 'ỿ', - 'Ἀ' => 'ἀ', - 'Ἁ' => 'ἁ', - 'Ἂ' => 'ἂ', - 'Ἃ' => 'ἃ', - 'Ἄ' => 'ἄ', - 'Ἅ' => 'ἅ', - 'Ἆ' => 'ἆ', - 'Ἇ' => 'ἇ', - 'Ἐ' => 'ἐ', - 'Ἑ' => 'ἑ', - 'Ἒ' => 'ἒ', - 'Ἓ' => 'ἓ', - 'Ἔ' => 'ἔ', - 'Ἕ' => 'ἕ', - 'Ἠ' => 'ἠ', - 'Ἡ' => 'ἡ', - 'Ἢ' => 'ἢ', - 'Ἣ' => 'ἣ', - 'Ἤ' => 'ἤ', - 'Ἥ' => 'ἥ', - 'Ἦ' => 'ἦ', - 'Ἧ' => 'ἧ', - 'Ἰ' => 'ἰ', - 'Ἱ' => 'ἱ', - 'Ἲ' => 'ἲ', - 'Ἳ' => 'ἳ', - 'Ἴ' => 'ἴ', - 'Ἵ' => 'ἵ', - 'Ἶ' => 'ἶ', - 'Ἷ' => 'ἷ', - 'Ὀ' => 'ὀ', - 'Ὁ' => 'ὁ', - 'Ὂ' => 'ὂ', - 'Ὃ' => 'ὃ', - 'Ὄ' => 'ὄ', - 'Ὅ' => 'ὅ', - 'Ὑ' => 'ὑ', - 'Ὓ' => 'ὓ', - 'Ὕ' => 'ὕ', - 'Ὗ' => 'ὗ', - 'Ὠ' => 'ὠ', - 'Ὡ' => 'ὡ', - 'Ὢ' => 'ὢ', - 'Ὣ' => 'ὣ', - 'Ὤ' => 'ὤ', - 'Ὥ' => 'ὥ', - 'Ὦ' => 'ὦ', - 'Ὧ' => 'ὧ', - 'ᾈ' => 'ᾀ', - 'ᾉ' => 'ᾁ', - 'ᾊ' => 'ᾂ', - 'ᾋ' => 'ᾃ', - 'ᾌ' => 'ᾄ', - 'ᾍ' => 'ᾅ', - 'ᾎ' => 'ᾆ', - 'ᾏ' => 'ᾇ', - 'ᾘ' => 'ᾐ', - 'ᾙ' => 'ᾑ', - 'ᾚ' => 'ᾒ', - 'ᾛ' => 'ᾓ', - 'ᾜ' => 'ᾔ', - 'ᾝ' => 'ᾕ', - 'ᾞ' => 'ᾖ', - 'ᾟ' => 'ᾗ', - 'ᾨ' => 'ᾠ', - 'ᾩ' => 'ᾡ', - 'ᾪ' => 'ᾢ', - 'ᾫ' => 'ᾣ', - 'ᾬ' => 'ᾤ', - 'ᾭ' => 'ᾥ', - 'ᾮ' => 'ᾦ', - 'ᾯ' => 'ᾧ', - 'Ᾰ' => 'ᾰ', - 'Ᾱ' => 'ᾱ', - 'Ὰ' => 'ὰ', - 'Ά' => 'ά', - 'ᾼ' => 'ᾳ', - 'Ὲ' => 'ὲ', - 'Έ' => 'έ', - 'Ὴ' => 'ὴ', - 'Ή' => 'ή', - 'ῌ' => 'ῃ', - 'Ῐ' => 'ῐ', - 'Ῑ' => 'ῑ', - 'Ὶ' => 'ὶ', - 'Ί' => 'ί', - 'Ῠ' => 'ῠ', - 'Ῡ' => 'ῡ', - 'Ὺ' => 'ὺ', - 'Ύ' => 'ύ', - 'Ῥ' => 'ῥ', - 'Ὸ' => 'ὸ', - 'Ό' => 'ό', - 'Ὼ' => 'ὼ', - 'Ώ' => 'ώ', - 'ῼ' => 'ῳ', - 'Ω' => 'ω', - 'K' => 'k', - 'Å' => 'å', - 'Ⅎ' => 'ⅎ', - 'Ⅰ' => 'ⅰ', - 'Ⅱ' => 'ⅱ', - 'Ⅲ' => 'ⅲ', - 'Ⅳ' => 'ⅳ', - 'Ⅴ' => 'ⅴ', - 'Ⅵ' => 'ⅵ', - 'Ⅶ' => 'ⅶ', - 'Ⅷ' => 'ⅷ', - 'Ⅸ' => 'ⅸ', - 'Ⅹ' => 'ⅹ', - 'Ⅺ' => 'ⅺ', - 'Ⅻ' => 'ⅻ', - 'Ⅼ' => 'ⅼ', - 'Ⅽ' => 'ⅽ', - 'Ⅾ' => 'ⅾ', - 'Ⅿ' => 'ⅿ', - 'Ↄ' => 'ↄ', - 'Ⓐ' => 'ⓐ', - 'Ⓑ' => 'ⓑ', - 'Ⓒ' => 'ⓒ', - 'Ⓓ' => 'ⓓ', - 'Ⓔ' => 'ⓔ', - 'Ⓕ' => 'ⓕ', - 'Ⓖ' => 'ⓖ', - 'Ⓗ' => 'ⓗ', - 'Ⓘ' => 'ⓘ', - 'Ⓙ' => 'ⓙ', - 'Ⓚ' => 'ⓚ', - 'Ⓛ' => 'ⓛ', - 'Ⓜ' => 'ⓜ', - 'Ⓝ' => 'ⓝ', - 'Ⓞ' => 'ⓞ', - 'Ⓟ' => 'ⓟ', - 'Ⓠ' => 'ⓠ', - 'Ⓡ' => 'ⓡ', - 'Ⓢ' => 'ⓢ', - 'Ⓣ' => 'ⓣ', - 'Ⓤ' => 'ⓤ', - 'Ⓥ' => 'ⓥ', - 'Ⓦ' => 'ⓦ', - 'Ⓧ' => 'ⓧ', - 'Ⓨ' => 'ⓨ', - 'Ⓩ' => 'ⓩ', - 'Ⰰ' => 'ⰰ', - 'Ⰱ' => 'ⰱ', - 'Ⰲ' => 'ⰲ', - 'Ⰳ' => 'ⰳ', - 'Ⰴ' => 'ⰴ', - 'Ⰵ' => 'ⰵ', - 'Ⰶ' => 'ⰶ', - 'Ⰷ' => 'ⰷ', - 'Ⰸ' => 'ⰸ', - 'Ⰹ' => 'ⰹ', - 'Ⰺ' => 'ⰺ', - 'Ⰻ' => 'ⰻ', - 'Ⰼ' => 'ⰼ', - 'Ⰽ' => 'ⰽ', - 'Ⰾ' => 'ⰾ', - 'Ⰿ' => 'ⰿ', - 'Ⱀ' => 'ⱀ', - 'Ⱁ' => 'ⱁ', - 'Ⱂ' => 'ⱂ', - 'Ⱃ' => 'ⱃ', - 'Ⱄ' => 'ⱄ', - 'Ⱅ' => 'ⱅ', - 'Ⱆ' => 'ⱆ', - 'Ⱇ' => 'ⱇ', - 'Ⱈ' => 'ⱈ', - 'Ⱉ' => 'ⱉ', - 'Ⱊ' => 'ⱊ', - 'Ⱋ' => 'ⱋ', - 'Ⱌ' => 'ⱌ', - 'Ⱍ' => 'ⱍ', - 'Ⱎ' => 'ⱎ', - 'Ⱏ' => 'ⱏ', - 'Ⱐ' => 'ⱐ', - 'Ⱑ' => 'ⱑ', - 'Ⱒ' => 'ⱒ', - 'Ⱓ' => 'ⱓ', - 'Ⱔ' => 'ⱔ', - 'Ⱕ' => 'ⱕ', - 'Ⱖ' => 'ⱖ', - 'Ⱗ' => 'ⱗ', - 'Ⱘ' => 'ⱘ', - 'Ⱙ' => 'ⱙ', - 'Ⱚ' => 'ⱚ', - 'Ⱛ' => 'ⱛ', - 'Ⱜ' => 'ⱜ', - 'Ⱝ' => 'ⱝ', - 'Ⱞ' => 'ⱞ', - 'Ⱡ' => 'ⱡ', - 'Ɫ' => 'ɫ', - 'Ᵽ' => 'ᵽ', - 'Ɽ' => 'ɽ', - 'Ⱨ' => 'ⱨ', - 'Ⱪ' => 'ⱪ', - 'Ⱬ' => 'ⱬ', - 'Ɑ' => 'ɑ', - 'Ɱ' => 'ɱ', - 'Ɐ' => 'ɐ', - 'Ɒ' => 'ɒ', - 'Ⱳ' => 'ⱳ', - 'Ⱶ' => 'ⱶ', - 'Ȿ' => 'ȿ', - 'Ɀ' => 'ɀ', - 'Ⲁ' => 'ⲁ', - 'Ⲃ' => 'ⲃ', - 'Ⲅ' => 'ⲅ', - 'Ⲇ' => 'ⲇ', - 'Ⲉ' => 'ⲉ', - 'Ⲋ' => 'ⲋ', - 'Ⲍ' => 'ⲍ', - 'Ⲏ' => 'ⲏ', - 'Ⲑ' => 'ⲑ', - 'Ⲓ' => 'ⲓ', - 'Ⲕ' => 'ⲕ', - 'Ⲗ' => 'ⲗ', - 'Ⲙ' => 'ⲙ', - 'Ⲛ' => 'ⲛ', - 'Ⲝ' => 'ⲝ', - 'Ⲟ' => 'ⲟ', - 'Ⲡ' => 'ⲡ', - 'Ⲣ' => 'ⲣ', - 'Ⲥ' => 'ⲥ', - 'Ⲧ' => 'ⲧ', - 'Ⲩ' => 'ⲩ', - 'Ⲫ' => 'ⲫ', - 'Ⲭ' => 'ⲭ', - 'Ⲯ' => 'ⲯ', - 'Ⲱ' => 'ⲱ', - 'Ⲳ' => 'ⲳ', - 'Ⲵ' => 'ⲵ', - 'Ⲷ' => 'ⲷ', - 'Ⲹ' => 'ⲹ', - 'Ⲻ' => 'ⲻ', - 'Ⲽ' => 'ⲽ', - 'Ⲿ' => 'ⲿ', - 'Ⳁ' => 'ⳁ', - 'Ⳃ' => 'ⳃ', - 'Ⳅ' => 'ⳅ', - 'Ⳇ' => 'ⳇ', - 'Ⳉ' => 'ⳉ', - 'Ⳋ' => 'ⳋ', - 'Ⳍ' => 'ⳍ', - 'Ⳏ' => 'ⳏ', - 'Ⳑ' => 'ⳑ', - 'Ⳓ' => 'ⳓ', - 'Ⳕ' => 'ⳕ', - 'Ⳗ' => 'ⳗ', - 'Ⳙ' => 'ⳙ', - 'Ⳛ' => 'ⳛ', - 'Ⳝ' => 'ⳝ', - 'Ⳟ' => 'ⳟ', - 'Ⳡ' => 'ⳡ', - 'Ⳣ' => 'ⳣ', - 'Ⳬ' => 'ⳬ', - 'Ⳮ' => 'ⳮ', - 'Ⳳ' => 'ⳳ', - 'Ꙁ' => 'ꙁ', - 'Ꙃ' => 'ꙃ', - 'Ꙅ' => 'ꙅ', - 'Ꙇ' => 'ꙇ', - 'Ꙉ' => 'ꙉ', - 'Ꙋ' => 'ꙋ', - 'Ꙍ' => 'ꙍ', - 'Ꙏ' => 'ꙏ', - 'Ꙑ' => 'ꙑ', - 'Ꙓ' => 'ꙓ', - 'Ꙕ' => 'ꙕ', - 'Ꙗ' => 'ꙗ', - 'Ꙙ' => 'ꙙ', - 'Ꙛ' => 'ꙛ', - 'Ꙝ' => 'ꙝ', - 'Ꙟ' => 'ꙟ', - 'Ꙡ' => 'ꙡ', - 'Ꙣ' => 'ꙣ', - 'Ꙥ' => 'ꙥ', - 'Ꙧ' => 'ꙧ', - 'Ꙩ' => 'ꙩ', - 'Ꙫ' => 'ꙫ', - 'Ꙭ' => 'ꙭ', - 'Ꚁ' => 'ꚁ', - 'Ꚃ' => 'ꚃ', - 'Ꚅ' => 'ꚅ', - 'Ꚇ' => 'ꚇ', - 'Ꚉ' => 'ꚉ', - 'Ꚋ' => 'ꚋ', - 'Ꚍ' => 'ꚍ', - 'Ꚏ' => 'ꚏ', - 'Ꚑ' => 'ꚑ', - 'Ꚓ' => 'ꚓ', - 'Ꚕ' => 'ꚕ', - 'Ꚗ' => 'ꚗ', - 'Ꚙ' => 'ꚙ', - 'Ꚛ' => 'ꚛ', - 'Ꜣ' => 'ꜣ', - 'Ꜥ' => 'ꜥ', - 'Ꜧ' => 'ꜧ', - 'Ꜩ' => 'ꜩ', - 'Ꜫ' => 'ꜫ', - 'Ꜭ' => 'ꜭ', - 'Ꜯ' => 'ꜯ', - 'Ꜳ' => 'ꜳ', - 'Ꜵ' => 'ꜵ', - 'Ꜷ' => 'ꜷ', - 'Ꜹ' => 'ꜹ', - 'Ꜻ' => 'ꜻ', - 'Ꜽ' => 'ꜽ', - 'Ꜿ' => 'ꜿ', - 'Ꝁ' => 'ꝁ', - 'Ꝃ' => 'ꝃ', - 'Ꝅ' => 'ꝅ', - 'Ꝇ' => 'ꝇ', - 'Ꝉ' => 'ꝉ', - 'Ꝋ' => 'ꝋ', - 'Ꝍ' => 'ꝍ', - 'Ꝏ' => 'ꝏ', - 'Ꝑ' => 'ꝑ', - 'Ꝓ' => 'ꝓ', - 'Ꝕ' => 'ꝕ', - 'Ꝗ' => 'ꝗ', - 'Ꝙ' => 'ꝙ', - 'Ꝛ' => 'ꝛ', - 'Ꝝ' => 'ꝝ', - 'Ꝟ' => 'ꝟ', - 'Ꝡ' => 'ꝡ', - 'Ꝣ' => 'ꝣ', - 'Ꝥ' => 'ꝥ', - 'Ꝧ' => 'ꝧ', - 'Ꝩ' => 'ꝩ', - 'Ꝫ' => 'ꝫ', - 'Ꝭ' => 'ꝭ', - 'Ꝯ' => 'ꝯ', - 'Ꝺ' => 'ꝺ', - 'Ꝼ' => 'ꝼ', - 'Ᵹ' => 'ᵹ', - 'Ꝿ' => 'ꝿ', - 'Ꞁ' => 'ꞁ', - 'Ꞃ' => 'ꞃ', - 'Ꞅ' => 'ꞅ', - 'Ꞇ' => 'ꞇ', - 'Ꞌ' => 'ꞌ', - 'Ɥ' => 'ɥ', - 'Ꞑ' => 'ꞑ', - 'Ꞓ' => 'ꞓ', - 'Ꞗ' => 'ꞗ', - 'Ꞙ' => 'ꞙ', - 'Ꞛ' => 'ꞛ', - 'Ꞝ' => 'ꞝ', - 'Ꞟ' => 'ꞟ', - 'Ꞡ' => 'ꞡ', - 'Ꞣ' => 'ꞣ', - 'Ꞥ' => 'ꞥ', - 'Ꞧ' => 'ꞧ', - 'Ꞩ' => 'ꞩ', - 'Ɦ' => 'ɦ', - 'Ɜ' => 'ɜ', - 'Ɡ' => 'ɡ', - 'Ɬ' => 'ɬ', - 'Ɪ' => 'ɪ', - 'Ʞ' => 'ʞ', - 'Ʇ' => 'ʇ', - 'Ʝ' => 'ʝ', - 'Ꭓ' => 'ꭓ', - 'Ꞵ' => 'ꞵ', - 'Ꞷ' => 'ꞷ', - 'Ꞹ' => 'ꞹ', - 'Ꞻ' => 'ꞻ', - 'Ꞽ' => 'ꞽ', - 'Ꞿ' => 'ꞿ', - 'Ꟃ' => 'ꟃ', - 'Ꞔ' => 'ꞔ', - 'Ʂ' => 'ʂ', - 'Ᶎ' => 'ᶎ', - 'Ꟈ' => 'ꟈ', - 'Ꟊ' => 'ꟊ', - 'Ꟶ' => 'ꟶ', - 'A' => 'a', - 'B' => 'b', - 'C' => 'c', - 'D' => 'd', - 'E' => 'e', - 'F' => 'f', - 'G' => 'g', - 'H' => 'h', - 'I' => 'i', - 'J' => 'j', - 'K' => 'k', - 'L' => 'l', - 'M' => 'm', - 'N' => 'n', - 'O' => 'o', - 'P' => 'p', - 'Q' => 'q', - 'R' => 'r', - 'S' => 's', - 'T' => 't', - 'U' => 'u', - 'V' => 'v', - 'W' => 'w', - 'X' => 'x', - 'Y' => 'y', - 'Z' => 'z', - '𐐀' => '𐐨', - '𐐁' => '𐐩', - '𐐂' => '𐐪', - '𐐃' => '𐐫', - '𐐄' => '𐐬', - '𐐅' => '𐐭', - '𐐆' => '𐐮', - '𐐇' => '𐐯', - '𐐈' => '𐐰', - '𐐉' => '𐐱', - '𐐊' => '𐐲', - '𐐋' => '𐐳', - '𐐌' => '𐐴', - '𐐍' => '𐐵', - '𐐎' => '𐐶', - '𐐏' => '𐐷', - '𐐐' => '𐐸', - '𐐑' => '𐐹', - '𐐒' => '𐐺', - '𐐓' => '𐐻', - '𐐔' => '𐐼', - '𐐕' => '𐐽', - '𐐖' => '𐐾', - '𐐗' => '𐐿', - '𐐘' => '𐑀', - '𐐙' => '𐑁', - '𐐚' => '𐑂', - '𐐛' => '𐑃', - '𐐜' => '𐑄', - '𐐝' => '𐑅', - '𐐞' => '𐑆', - '𐐟' => '𐑇', - '𐐠' => '𐑈', - '𐐡' => '𐑉', - '𐐢' => '𐑊', - '𐐣' => '𐑋', - '𐐤' => '𐑌', - '𐐥' => '𐑍', - '𐐦' => '𐑎', - '𐐧' => '𐑏', - '𐒰' => '𐓘', - '𐒱' => '𐓙', - '𐒲' => '𐓚', - '𐒳' => '𐓛', - '𐒴' => '𐓜', - '𐒵' => '𐓝', - '𐒶' => '𐓞', - '𐒷' => '𐓟', - '𐒸' => '𐓠', - '𐒹' => '𐓡', - '𐒺' => '𐓢', - '𐒻' => '𐓣', - '𐒼' => '𐓤', - '𐒽' => '𐓥', - '𐒾' => '𐓦', - '𐒿' => '𐓧', - '𐓀' => '𐓨', - '𐓁' => '𐓩', - '𐓂' => '𐓪', - '𐓃' => '𐓫', - '𐓄' => '𐓬', - '𐓅' => '𐓭', - '𐓆' => '𐓮', - '𐓇' => '𐓯', - '𐓈' => '𐓰', - '𐓉' => '𐓱', - '𐓊' => '𐓲', - '𐓋' => '𐓳', - '𐓌' => '𐓴', - '𐓍' => '𐓵', - '𐓎' => '𐓶', - '𐓏' => '𐓷', - '𐓐' => '𐓸', - '𐓑' => '𐓹', - '𐓒' => '𐓺', - '𐓓' => '𐓻', - '𐲀' => '𐳀', - '𐲁' => '𐳁', - '𐲂' => '𐳂', - '𐲃' => '𐳃', - '𐲄' => '𐳄', - '𐲅' => '𐳅', - '𐲆' => '𐳆', - '𐲇' => '𐳇', - '𐲈' => '𐳈', - '𐲉' => '𐳉', - '𐲊' => '𐳊', - '𐲋' => '𐳋', - '𐲌' => '𐳌', - '𐲍' => '𐳍', - '𐲎' => '𐳎', - '𐲏' => '𐳏', - '𐲐' => '𐳐', - '𐲑' => '𐳑', - '𐲒' => '𐳒', - '𐲓' => '𐳓', - '𐲔' => '𐳔', - '𐲕' => '𐳕', - '𐲖' => '𐳖', - '𐲗' => '𐳗', - '𐲘' => '𐳘', - '𐲙' => '𐳙', - '𐲚' => '𐳚', - '𐲛' => '𐳛', - '𐲜' => '𐳜', - '𐲝' => '𐳝', - '𐲞' => '𐳞', - '𐲟' => '𐳟', - '𐲠' => '𐳠', - '𐲡' => '𐳡', - '𐲢' => '𐳢', - '𐲣' => '𐳣', - '𐲤' => '𐳤', - '𐲥' => '𐳥', - '𐲦' => '𐳦', - '𐲧' => '𐳧', - '𐲨' => '𐳨', - '𐲩' => '𐳩', - '𐲪' => '𐳪', - '𐲫' => '𐳫', - '𐲬' => '𐳬', - '𐲭' => '𐳭', - '𐲮' => '𐳮', - '𐲯' => '𐳯', - '𐲰' => '𐳰', - '𐲱' => '𐳱', - '𐲲' => '𐳲', - '𑢠' => '𑣀', - '𑢡' => '𑣁', - '𑢢' => '𑣂', - '𑢣' => '𑣃', - '𑢤' => '𑣄', - '𑢥' => '𑣅', - '𑢦' => '𑣆', - '𑢧' => '𑣇', - '𑢨' => '𑣈', - '𑢩' => '𑣉', - '𑢪' => '𑣊', - '𑢫' => '𑣋', - '𑢬' => '𑣌', - '𑢭' => '𑣍', - '𑢮' => '𑣎', - '𑢯' => '𑣏', - '𑢰' => '𑣐', - '𑢱' => '𑣑', - '𑢲' => '𑣒', - '𑢳' => '𑣓', - '𑢴' => '𑣔', - '𑢵' => '𑣕', - '𑢶' => '𑣖', - '𑢷' => '𑣗', - '𑢸' => '𑣘', - '𑢹' => '𑣙', - '𑢺' => '𑣚', - '𑢻' => '𑣛', - '𑢼' => '𑣜', - '𑢽' => '𑣝', - '𑢾' => '𑣞', - '𑢿' => '𑣟', - '𖹀' => '𖹠', - '𖹁' => '𖹡', - '𖹂' => '𖹢', - '𖹃' => '𖹣', - '𖹄' => '𖹤', - '𖹅' => '𖹥', - '𖹆' => '𖹦', - '𖹇' => '𖹧', - '𖹈' => '𖹨', - '𖹉' => '𖹩', - '𖹊' => '𖹪', - '𖹋' => '𖹫', - '𖹌' => '𖹬', - '𖹍' => '𖹭', - '𖹎' => '𖹮', - '𖹏' => '𖹯', - '𖹐' => '𖹰', - '𖹑' => '𖹱', - '𖹒' => '𖹲', - '𖹓' => '𖹳', - '𖹔' => '𖹴', - '𖹕' => '𖹵', - '𖹖' => '𖹶', - '𖹗' => '𖹷', - '𖹘' => '𖹸', - '𖹙' => '𖹹', - '𖹚' => '𖹺', - '𖹛' => '𖹻', - '𖹜' => '𖹼', - '𖹝' => '𖹽', - '𖹞' => '𖹾', - '𖹟' => '𖹿', - '𞤀' => '𞤢', - '𞤁' => '𞤣', - '𞤂' => '𞤤', - '𞤃' => '𞤥', - '𞤄' => '𞤦', - '𞤅' => '𞤧', - '𞤆' => '𞤨', - '𞤇' => '𞤩', - '𞤈' => '𞤪', - '𞤉' => '𞤫', - '𞤊' => '𞤬', - '𞤋' => '𞤭', - '𞤌' => '𞤮', - '𞤍' => '𞤯', - '𞤎' => '𞤰', - '𞤏' => '𞤱', - '𞤐' => '𞤲', - '𞤑' => '𞤳', - '𞤒' => '𞤴', - '𞤓' => '𞤵', - '𞤔' => '𞤶', - '𞤕' => '𞤷', - '𞤖' => '𞤸', - '𞤗' => '𞤹', - '𞤘' => '𞤺', - '𞤙' => '𞤻', - '𞤚' => '𞤼', - '𞤛' => '𞤽', - '𞤜' => '𞤾', - '𞤝' => '𞤿', - '𞤞' => '𞥀', - '𞤟' => '𞥁', - '𞤠' => '𞥂', - '𞤡' => '𞥃', -); diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php deleted file mode 100644 index 2a8f6e7..0000000 --- a/vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.php +++ /dev/null @@ -1,5 +0,0 @@ - 'A', - 'b' => 'B', - 'c' => 'C', - 'd' => 'D', - 'e' => 'E', - 'f' => 'F', - 'g' => 'G', - 'h' => 'H', - 'i' => 'I', - 'j' => 'J', - 'k' => 'K', - 'l' => 'L', - 'm' => 'M', - 'n' => 'N', - 'o' => 'O', - 'p' => 'P', - 'q' => 'Q', - 'r' => 'R', - 's' => 'S', - 't' => 'T', - 'u' => 'U', - 'v' => 'V', - 'w' => 'W', - 'x' => 'X', - 'y' => 'Y', - 'z' => 'Z', - 'µ' => 'Μ', - 'à' => 'À', - 'á' => 'Á', - 'â' => 'Â', - 'ã' => 'Ã', - 'ä' => 'Ä', - 'å' => 'Å', - 'æ' => 'Æ', - 'ç' => 'Ç', - 'è' => 'È', - 'é' => 'É', - 'ê' => 'Ê', - 'ë' => 'Ë', - 'ì' => 'Ì', - 'í' => 'Í', - 'î' => 'Î', - 'ï' => 'Ï', - 'ð' => 'Ð', - 'ñ' => 'Ñ', - 'ò' => 'Ò', - 'ó' => 'Ó', - 'ô' => 'Ô', - 'õ' => 'Õ', - 'ö' => 'Ö', - 'ø' => 'Ø', - 'ù' => 'Ù', - 'ú' => 'Ú', - 'û' => 'Û', - 'ü' => 'Ü', - 'ý' => 'Ý', - 'þ' => 'Þ', - 'ÿ' => 'Ÿ', - 'ā' => 'Ā', - 'ă' => 'Ă', - 'ą' => 'Ą', - 'ć' => 'Ć', - 'ĉ' => 'Ĉ', - 'ċ' => 'Ċ', - 'č' => 'Č', - 'ď' => 'Ď', - 'đ' => 'Đ', - 'ē' => 'Ē', - 'ĕ' => 'Ĕ', - 'ė' => 'Ė', - 'ę' => 'Ę', - 'ě' => 'Ě', - 'ĝ' => 'Ĝ', - 'ğ' => 'Ğ', - 'ġ' => 'Ġ', - 'ģ' => 'Ģ', - 'ĥ' => 'Ĥ', - 'ħ' => 'Ħ', - 'ĩ' => 'Ĩ', - 'ī' => 'Ī', - 'ĭ' => 'Ĭ', - 'į' => 'Į', - 'ı' => 'I', - 'ij' => 'IJ', - 'ĵ' => 'Ĵ', - 'ķ' => 'Ķ', - 'ĺ' => 'Ĺ', - 'ļ' => 'Ļ', - 'ľ' => 'Ľ', - 'ŀ' => 'Ŀ', - 'ł' => 'Ł', - 'ń' => 'Ń', - 'ņ' => 'Ņ', - 'ň' => 'Ň', - 'ŋ' => 'Ŋ', - 'ō' => 'Ō', - 'ŏ' => 'Ŏ', - 'ő' => 'Ő', - 'œ' => 'Œ', - 'ŕ' => 'Ŕ', - 'ŗ' => 'Ŗ', - 'ř' => 'Ř', - 'ś' => 'Ś', - 'ŝ' => 'Ŝ', - 'ş' => 'Ş', - 'š' => 'Š', - 'ţ' => 'Ţ', - 'ť' => 'Ť', - 'ŧ' => 'Ŧ', - 'ũ' => 'Ũ', - 'ū' => 'Ū', - 'ŭ' => 'Ŭ', - 'ů' => 'Ů', - 'ű' => 'Ű', - 'ų' => 'Ų', - 'ŵ' => 'Ŵ', - 'ŷ' => 'Ŷ', - 'ź' => 'Ź', - 'ż' => 'Ż', - 'ž' => 'Ž', - 'ſ' => 'S', - 'ƀ' => 'Ƀ', - 'ƃ' => 'Ƃ', - 'ƅ' => 'Ƅ', - 'ƈ' => 'Ƈ', - 'ƌ' => 'Ƌ', - 'ƒ' => 'Ƒ', - 'ƕ' => 'Ƕ', - 'ƙ' => 'Ƙ', - 'ƚ' => 'Ƚ', - 'ƞ' => 'Ƞ', - 'ơ' => 'Ơ', - 'ƣ' => 'Ƣ', - 'ƥ' => 'Ƥ', - 'ƨ' => 'Ƨ', - 'ƭ' => 'Ƭ', - 'ư' => 'Ư', - 'ƴ' => 'Ƴ', - 'ƶ' => 'Ƶ', - 'ƹ' => 'Ƹ', - 'ƽ' => 'Ƽ', - 'ƿ' => 'Ƿ', - 'Dž' => 'DŽ', - 'dž' => 'DŽ', - 'Lj' => 'LJ', - 'lj' => 'LJ', - 'Nj' => 'NJ', - 'nj' => 'NJ', - 'ǎ' => 'Ǎ', - 'ǐ' => 'Ǐ', - 'ǒ' => 'Ǒ', - 'ǔ' => 'Ǔ', - 'ǖ' => 'Ǖ', - 'ǘ' => 'Ǘ', - 'ǚ' => 'Ǚ', - 'ǜ' => 'Ǜ', - 'ǝ' => 'Ǝ', - 'ǟ' => 'Ǟ', - 'ǡ' => 'Ǡ', - 'ǣ' => 'Ǣ', - 'ǥ' => 'Ǥ', - 'ǧ' => 'Ǧ', - 'ǩ' => 'Ǩ', - 'ǫ' => 'Ǫ', - 'ǭ' => 'Ǭ', - 'ǯ' => 'Ǯ', - 'Dz' => 'DZ', - 'dz' => 'DZ', - 'ǵ' => 'Ǵ', - 'ǹ' => 'Ǹ', - 'ǻ' => 'Ǻ', - 'ǽ' => 'Ǽ', - 'ǿ' => 'Ǿ', - 'ȁ' => 'Ȁ', - 'ȃ' => 'Ȃ', - 'ȅ' => 'Ȅ', - 'ȇ' => 'Ȇ', - 'ȉ' => 'Ȉ', - 'ȋ' => 'Ȋ', - 'ȍ' => 'Ȍ', - 'ȏ' => 'Ȏ', - 'ȑ' => 'Ȑ', - 'ȓ' => 'Ȓ', - 'ȕ' => 'Ȕ', - 'ȗ' => 'Ȗ', - 'ș' => 'Ș', - 'ț' => 'Ț', - 'ȝ' => 'Ȝ', - 'ȟ' => 'Ȟ', - 'ȣ' => 'Ȣ', - 'ȥ' => 'Ȥ', - 'ȧ' => 'Ȧ', - 'ȩ' => 'Ȩ', - 'ȫ' => 'Ȫ', - 'ȭ' => 'Ȭ', - 'ȯ' => 'Ȯ', - 'ȱ' => 'Ȱ', - 'ȳ' => 'Ȳ', - 'ȼ' => 'Ȼ', - 'ȿ' => 'Ȿ', - 'ɀ' => 'Ɀ', - 'ɂ' => 'Ɂ', - 'ɇ' => 'Ɇ', - 'ɉ' => 'Ɉ', - 'ɋ' => 'Ɋ', - 'ɍ' => 'Ɍ', - 'ɏ' => 'Ɏ', - 'ɐ' => 'Ɐ', - 'ɑ' => 'Ɑ', - 'ɒ' => 'Ɒ', - 'ɓ' => 'Ɓ', - 'ɔ' => 'Ɔ', - 'ɖ' => 'Ɖ', - 'ɗ' => 'Ɗ', - 'ə' => 'Ə', - 'ɛ' => 'Ɛ', - 'ɜ' => 'Ɜ', - 'ɠ' => 'Ɠ', - 'ɡ' => 'Ɡ', - 'ɣ' => 'Ɣ', - 'ɥ' => 'Ɥ', - 'ɦ' => 'Ɦ', - 'ɨ' => 'Ɨ', - 'ɩ' => 'Ɩ', - 'ɪ' => 'Ɪ', - 'ɫ' => 'Ɫ', - 'ɬ' => 'Ɬ', - 'ɯ' => 'Ɯ', - 'ɱ' => 'Ɱ', - 'ɲ' => 'Ɲ', - 'ɵ' => 'Ɵ', - 'ɽ' => 'Ɽ', - 'ʀ' => 'Ʀ', - 'ʂ' => 'Ʂ', - 'ʃ' => 'Ʃ', - 'ʇ' => 'Ʇ', - 'ʈ' => 'Ʈ', - 'ʉ' => 'Ʉ', - 'ʊ' => 'Ʊ', - 'ʋ' => 'Ʋ', - 'ʌ' => 'Ʌ', - 'ʒ' => 'Ʒ', - 'ʝ' => 'Ʝ', - 'ʞ' => 'Ʞ', - 'ͅ' => 'Ι', - 'ͱ' => 'Ͱ', - 'ͳ' => 'Ͳ', - 'ͷ' => 'Ͷ', - 'ͻ' => 'Ͻ', - 'ͼ' => 'Ͼ', - 'ͽ' => 'Ͽ', - 'ά' => 'Ά', - 'έ' => 'Έ', - 'ή' => 'Ή', - 'ί' => 'Ί', - 'α' => 'Α', - 'β' => 'Β', - 'γ' => 'Γ', - 'δ' => 'Δ', - 'ε' => 'Ε', - 'ζ' => 'Ζ', - 'η' => 'Η', - 'θ' => 'Θ', - 'ι' => 'Ι', - 'κ' => 'Κ', - 'λ' => 'Λ', - 'μ' => 'Μ', - 'ν' => 'Ν', - 'ξ' => 'Ξ', - 'ο' => 'Ο', - 'π' => 'Π', - 'ρ' => 'Ρ', - 'ς' => 'Σ', - 'σ' => 'Σ', - 'τ' => 'Τ', - 'υ' => 'Υ', - 'φ' => 'Φ', - 'χ' => 'Χ', - 'ψ' => 'Ψ', - 'ω' => 'Ω', - 'ϊ' => 'Ϊ', - 'ϋ' => 'Ϋ', - 'ό' => 'Ό', - 'ύ' => 'Ύ', - 'ώ' => 'Ώ', - 'ϐ' => 'Β', - 'ϑ' => 'Θ', - 'ϕ' => 'Φ', - 'ϖ' => 'Π', - 'ϗ' => 'Ϗ', - 'ϙ' => 'Ϙ', - 'ϛ' => 'Ϛ', - 'ϝ' => 'Ϝ', - 'ϟ' => 'Ϟ', - 'ϡ' => 'Ϡ', - 'ϣ' => 'Ϣ', - 'ϥ' => 'Ϥ', - 'ϧ' => 'Ϧ', - 'ϩ' => 'Ϩ', - 'ϫ' => 'Ϫ', - 'ϭ' => 'Ϭ', - 'ϯ' => 'Ϯ', - 'ϰ' => 'Κ', - 'ϱ' => 'Ρ', - 'ϲ' => 'Ϲ', - 'ϳ' => 'Ϳ', - 'ϵ' => 'Ε', - 'ϸ' => 'Ϸ', - 'ϻ' => 'Ϻ', - 'а' => 'А', - 'б' => 'Б', - 'в' => 'В', - 'г' => 'Г', - 'д' => 'Д', - 'е' => 'Е', - 'ж' => 'Ж', - 'з' => 'З', - 'и' => 'И', - 'й' => 'Й', - 'к' => 'К', - 'л' => 'Л', - 'м' => 'М', - 'н' => 'Н', - 'о' => 'О', - 'п' => 'П', - 'р' => 'Р', - 'с' => 'С', - 'т' => 'Т', - 'у' => 'У', - 'ф' => 'Ф', - 'х' => 'Х', - 'ц' => 'Ц', - 'ч' => 'Ч', - 'ш' => 'Ш', - 'щ' => 'Щ', - 'ъ' => 'Ъ', - 'ы' => 'Ы', - 'ь' => 'Ь', - 'э' => 'Э', - 'ю' => 'Ю', - 'я' => 'Я', - 'ѐ' => 'Ѐ', - 'ё' => 'Ё', - 'ђ' => 'Ђ', - 'ѓ' => 'Ѓ', - 'є' => 'Є', - 'ѕ' => 'Ѕ', - 'і' => 'І', - 'ї' => 'Ї', - 'ј' => 'Ј', - 'љ' => 'Љ', - 'њ' => 'Њ', - 'ћ' => 'Ћ', - 'ќ' => 'Ќ', - 'ѝ' => 'Ѝ', - 'ў' => 'Ў', - 'џ' => 'Џ', - 'ѡ' => 'Ѡ', - 'ѣ' => 'Ѣ', - 'ѥ' => 'Ѥ', - 'ѧ' => 'Ѧ', - 'ѩ' => 'Ѩ', - 'ѫ' => 'Ѫ', - 'ѭ' => 'Ѭ', - 'ѯ' => 'Ѯ', - 'ѱ' => 'Ѱ', - 'ѳ' => 'Ѳ', - 'ѵ' => 'Ѵ', - 'ѷ' => 'Ѷ', - 'ѹ' => 'Ѹ', - 'ѻ' => 'Ѻ', - 'ѽ' => 'Ѽ', - 'ѿ' => 'Ѿ', - 'ҁ' => 'Ҁ', - 'ҋ' => 'Ҋ', - 'ҍ' => 'Ҍ', - 'ҏ' => 'Ҏ', - 'ґ' => 'Ґ', - 'ғ' => 'Ғ', - 'ҕ' => 'Ҕ', - 'җ' => 'Җ', - 'ҙ' => 'Ҙ', - 'қ' => 'Қ', - 'ҝ' => 'Ҝ', - 'ҟ' => 'Ҟ', - 'ҡ' => 'Ҡ', - 'ң' => 'Ң', - 'ҥ' => 'Ҥ', - 'ҧ' => 'Ҧ', - 'ҩ' => 'Ҩ', - 'ҫ' => 'Ҫ', - 'ҭ' => 'Ҭ', - 'ү' => 'Ү', - 'ұ' => 'Ұ', - 'ҳ' => 'Ҳ', - 'ҵ' => 'Ҵ', - 'ҷ' => 'Ҷ', - 'ҹ' => 'Ҹ', - 'һ' => 'Һ', - 'ҽ' => 'Ҽ', - 'ҿ' => 'Ҿ', - 'ӂ' => 'Ӂ', - 'ӄ' => 'Ӄ', - 'ӆ' => 'Ӆ', - 'ӈ' => 'Ӈ', - 'ӊ' => 'Ӊ', - 'ӌ' => 'Ӌ', - 'ӎ' => 'Ӎ', - 'ӏ' => 'Ӏ', - 'ӑ' => 'Ӑ', - 'ӓ' => 'Ӓ', - 'ӕ' => 'Ӕ', - 'ӗ' => 'Ӗ', - 'ә' => 'Ә', - 'ӛ' => 'Ӛ', - 'ӝ' => 'Ӝ', - 'ӟ' => 'Ӟ', - 'ӡ' => 'Ӡ', - 'ӣ' => 'Ӣ', - 'ӥ' => 'Ӥ', - 'ӧ' => 'Ӧ', - 'ө' => 'Ө', - 'ӫ' => 'Ӫ', - 'ӭ' => 'Ӭ', - 'ӯ' => 'Ӯ', - 'ӱ' => 'Ӱ', - 'ӳ' => 'Ӳ', - 'ӵ' => 'Ӵ', - 'ӷ' => 'Ӷ', - 'ӹ' => 'Ӹ', - 'ӻ' => 'Ӻ', - 'ӽ' => 'Ӽ', - 'ӿ' => 'Ӿ', - 'ԁ' => 'Ԁ', - 'ԃ' => 'Ԃ', - 'ԅ' => 'Ԅ', - 'ԇ' => 'Ԇ', - 'ԉ' => 'Ԉ', - 'ԋ' => 'Ԋ', - 'ԍ' => 'Ԍ', - 'ԏ' => 'Ԏ', - 'ԑ' => 'Ԑ', - 'ԓ' => 'Ԓ', - 'ԕ' => 'Ԕ', - 'ԗ' => 'Ԗ', - 'ԙ' => 'Ԙ', - 'ԛ' => 'Ԛ', - 'ԝ' => 'Ԝ', - 'ԟ' => 'Ԟ', - 'ԡ' => 'Ԡ', - 'ԣ' => 'Ԣ', - 'ԥ' => 'Ԥ', - 'ԧ' => 'Ԧ', - 'ԩ' => 'Ԩ', - 'ԫ' => 'Ԫ', - 'ԭ' => 'Ԭ', - 'ԯ' => 'Ԯ', - 'ա' => 'Ա', - 'բ' => 'Բ', - 'գ' => 'Գ', - 'դ' => 'Դ', - 'ե' => 'Ե', - 'զ' => 'Զ', - 'է' => 'Է', - 'ը' => 'Ը', - 'թ' => 'Թ', - 'ժ' => 'Ժ', - 'ի' => 'Ի', - 'լ' => 'Լ', - 'խ' => 'Խ', - 'ծ' => 'Ծ', - 'կ' => 'Կ', - 'հ' => 'Հ', - 'ձ' => 'Ձ', - 'ղ' => 'Ղ', - 'ճ' => 'Ճ', - 'մ' => 'Մ', - 'յ' => 'Յ', - 'ն' => 'Ն', - 'շ' => 'Շ', - 'ո' => 'Ո', - 'չ' => 'Չ', - 'պ' => 'Պ', - 'ջ' => 'Ջ', - 'ռ' => 'Ռ', - 'ս' => 'Ս', - 'վ' => 'Վ', - 'տ' => 'Տ', - 'ր' => 'Ր', - 'ց' => 'Ց', - 'ւ' => 'Ւ', - 'փ' => 'Փ', - 'ք' => 'Ք', - 'օ' => 'Օ', - 'ֆ' => 'Ֆ', - 'ა' => 'Ა', - 'ბ' => 'Ბ', - 'გ' => 'Გ', - 'დ' => 'Დ', - 'ე' => 'Ე', - 'ვ' => 'Ვ', - 'ზ' => 'Ზ', - 'თ' => 'Თ', - 'ი' => 'Ი', - 'კ' => 'Კ', - 'ლ' => 'Ლ', - 'მ' => 'Მ', - 'ნ' => 'Ნ', - 'ო' => 'Ო', - 'პ' => 'Პ', - 'ჟ' => 'Ჟ', - 'რ' => 'Რ', - 'ს' => 'Ს', - 'ტ' => 'Ტ', - 'უ' => 'Უ', - 'ფ' => 'Ფ', - 'ქ' => 'Ქ', - 'ღ' => 'Ღ', - 'ყ' => 'Ყ', - 'შ' => 'Შ', - 'ჩ' => 'Ჩ', - 'ც' => 'Ც', - 'ძ' => 'Ძ', - 'წ' => 'Წ', - 'ჭ' => 'Ჭ', - 'ხ' => 'Ხ', - 'ჯ' => 'Ჯ', - 'ჰ' => 'Ჰ', - 'ჱ' => 'Ჱ', - 'ჲ' => 'Ჲ', - 'ჳ' => 'Ჳ', - 'ჴ' => 'Ჴ', - 'ჵ' => 'Ჵ', - 'ჶ' => 'Ჶ', - 'ჷ' => 'Ჷ', - 'ჸ' => 'Ჸ', - 'ჹ' => 'Ჹ', - 'ჺ' => 'Ჺ', - 'ჽ' => 'Ჽ', - 'ჾ' => 'Ჾ', - 'ჿ' => 'Ჿ', - 'ᏸ' => 'Ᏸ', - 'ᏹ' => 'Ᏹ', - 'ᏺ' => 'Ᏺ', - 'ᏻ' => 'Ᏻ', - 'ᏼ' => 'Ᏼ', - 'ᏽ' => 'Ᏽ', - 'ᲀ' => 'В', - 'ᲁ' => 'Д', - 'ᲂ' => 'О', - 'ᲃ' => 'С', - 'ᲄ' => 'Т', - 'ᲅ' => 'Т', - 'ᲆ' => 'Ъ', - 'ᲇ' => 'Ѣ', - 'ᲈ' => 'Ꙋ', - 'ᵹ' => 'Ᵹ', - 'ᵽ' => 'Ᵽ', - 'ᶎ' => 'Ᶎ', - 'ḁ' => 'Ḁ', - 'ḃ' => 'Ḃ', - 'ḅ' => 'Ḅ', - 'ḇ' => 'Ḇ', - 'ḉ' => 'Ḉ', - 'ḋ' => 'Ḋ', - 'ḍ' => 'Ḍ', - 'ḏ' => 'Ḏ', - 'ḑ' => 'Ḑ', - 'ḓ' => 'Ḓ', - 'ḕ' => 'Ḕ', - 'ḗ' => 'Ḗ', - 'ḙ' => 'Ḙ', - 'ḛ' => 'Ḛ', - 'ḝ' => 'Ḝ', - 'ḟ' => 'Ḟ', - 'ḡ' => 'Ḡ', - 'ḣ' => 'Ḣ', - 'ḥ' => 'Ḥ', - 'ḧ' => 'Ḧ', - 'ḩ' => 'Ḩ', - 'ḫ' => 'Ḫ', - 'ḭ' => 'Ḭ', - 'ḯ' => 'Ḯ', - 'ḱ' => 'Ḱ', - 'ḳ' => 'Ḳ', - 'ḵ' => 'Ḵ', - 'ḷ' => 'Ḷ', - 'ḹ' => 'Ḹ', - 'ḻ' => 'Ḻ', - 'ḽ' => 'Ḽ', - 'ḿ' => 'Ḿ', - 'ṁ' => 'Ṁ', - 'ṃ' => 'Ṃ', - 'ṅ' => 'Ṅ', - 'ṇ' => 'Ṇ', - 'ṉ' => 'Ṉ', - 'ṋ' => 'Ṋ', - 'ṍ' => 'Ṍ', - 'ṏ' => 'Ṏ', - 'ṑ' => 'Ṑ', - 'ṓ' => 'Ṓ', - 'ṕ' => 'Ṕ', - 'ṗ' => 'Ṗ', - 'ṙ' => 'Ṙ', - 'ṛ' => 'Ṛ', - 'ṝ' => 'Ṝ', - 'ṟ' => 'Ṟ', - 'ṡ' => 'Ṡ', - 'ṣ' => 'Ṣ', - 'ṥ' => 'Ṥ', - 'ṧ' => 'Ṧ', - 'ṩ' => 'Ṩ', - 'ṫ' => 'Ṫ', - 'ṭ' => 'Ṭ', - 'ṯ' => 'Ṯ', - 'ṱ' => 'Ṱ', - 'ṳ' => 'Ṳ', - 'ṵ' => 'Ṵ', - 'ṷ' => 'Ṷ', - 'ṹ' => 'Ṹ', - 'ṻ' => 'Ṻ', - 'ṽ' => 'Ṽ', - 'ṿ' => 'Ṿ', - 'ẁ' => 'Ẁ', - 'ẃ' => 'Ẃ', - 'ẅ' => 'Ẅ', - 'ẇ' => 'Ẇ', - 'ẉ' => 'Ẉ', - 'ẋ' => 'Ẋ', - 'ẍ' => 'Ẍ', - 'ẏ' => 'Ẏ', - 'ẑ' => 'Ẑ', - 'ẓ' => 'Ẓ', - 'ẕ' => 'Ẕ', - 'ẛ' => 'Ṡ', - 'ạ' => 'Ạ', - 'ả' => 'Ả', - 'ấ' => 'Ấ', - 'ầ' => 'Ầ', - 'ẩ' => 'Ẩ', - 'ẫ' => 'Ẫ', - 'ậ' => 'Ậ', - 'ắ' => 'Ắ', - 'ằ' => 'Ằ', - 'ẳ' => 'Ẳ', - 'ẵ' => 'Ẵ', - 'ặ' => 'Ặ', - 'ẹ' => 'Ẹ', - 'ẻ' => 'Ẻ', - 'ẽ' => 'Ẽ', - 'ế' => 'Ế', - 'ề' => 'Ề', - 'ể' => 'Ể', - 'ễ' => 'Ễ', - 'ệ' => 'Ệ', - 'ỉ' => 'Ỉ', - 'ị' => 'Ị', - 'ọ' => 'Ọ', - 'ỏ' => 'Ỏ', - 'ố' => 'Ố', - 'ồ' => 'Ồ', - 'ổ' => 'Ổ', - 'ỗ' => 'Ỗ', - 'ộ' => 'Ộ', - 'ớ' => 'Ớ', - 'ờ' => 'Ờ', - 'ở' => 'Ở', - 'ỡ' => 'Ỡ', - 'ợ' => 'Ợ', - 'ụ' => 'Ụ', - 'ủ' => 'Ủ', - 'ứ' => 'Ứ', - 'ừ' => 'Ừ', - 'ử' => 'Ử', - 'ữ' => 'Ữ', - 'ự' => 'Ự', - 'ỳ' => 'Ỳ', - 'ỵ' => 'Ỵ', - 'ỷ' => 'Ỷ', - 'ỹ' => 'Ỹ', - 'ỻ' => 'Ỻ', - 'ỽ' => 'Ỽ', - 'ỿ' => 'Ỿ', - 'ἀ' => 'Ἀ', - 'ἁ' => 'Ἁ', - 'ἂ' => 'Ἂ', - 'ἃ' => 'Ἃ', - 'ἄ' => 'Ἄ', - 'ἅ' => 'Ἅ', - 'ἆ' => 'Ἆ', - 'ἇ' => 'Ἇ', - 'ἐ' => 'Ἐ', - 'ἑ' => 'Ἑ', - 'ἒ' => 'Ἒ', - 'ἓ' => 'Ἓ', - 'ἔ' => 'Ἔ', - 'ἕ' => 'Ἕ', - 'ἠ' => 'Ἠ', - 'ἡ' => 'Ἡ', - 'ἢ' => 'Ἢ', - 'ἣ' => 'Ἣ', - 'ἤ' => 'Ἤ', - 'ἥ' => 'Ἥ', - 'ἦ' => 'Ἦ', - 'ἧ' => 'Ἧ', - 'ἰ' => 'Ἰ', - 'ἱ' => 'Ἱ', - 'ἲ' => 'Ἲ', - 'ἳ' => 'Ἳ', - 'ἴ' => 'Ἴ', - 'ἵ' => 'Ἵ', - 'ἶ' => 'Ἶ', - 'ἷ' => 'Ἷ', - 'ὀ' => 'Ὀ', - 'ὁ' => 'Ὁ', - 'ὂ' => 'Ὂ', - 'ὃ' => 'Ὃ', - 'ὄ' => 'Ὄ', - 'ὅ' => 'Ὅ', - 'ὑ' => 'Ὑ', - 'ὓ' => 'Ὓ', - 'ὕ' => 'Ὕ', - 'ὗ' => 'Ὗ', - 'ὠ' => 'Ὠ', - 'ὡ' => 'Ὡ', - 'ὢ' => 'Ὢ', - 'ὣ' => 'Ὣ', - 'ὤ' => 'Ὤ', - 'ὥ' => 'Ὥ', - 'ὦ' => 'Ὦ', - 'ὧ' => 'Ὧ', - 'ὰ' => 'Ὰ', - 'ά' => 'Ά', - 'ὲ' => 'Ὲ', - 'έ' => 'Έ', - 'ὴ' => 'Ὴ', - 'ή' => 'Ή', - 'ὶ' => 'Ὶ', - 'ί' => 'Ί', - 'ὸ' => 'Ὸ', - 'ό' => 'Ό', - 'ὺ' => 'Ὺ', - 'ύ' => 'Ύ', - 'ὼ' => 'Ὼ', - 'ώ' => 'Ώ', - 'ᾀ' => 'ἈΙ', - 'ᾁ' => 'ἉΙ', - 'ᾂ' => 'ἊΙ', - 'ᾃ' => 'ἋΙ', - 'ᾄ' => 'ἌΙ', - 'ᾅ' => 'ἍΙ', - 'ᾆ' => 'ἎΙ', - 'ᾇ' => 'ἏΙ', - 'ᾐ' => 'ἨΙ', - 'ᾑ' => 'ἩΙ', - 'ᾒ' => 'ἪΙ', - 'ᾓ' => 'ἫΙ', - 'ᾔ' => 'ἬΙ', - 'ᾕ' => 'ἭΙ', - 'ᾖ' => 'ἮΙ', - 'ᾗ' => 'ἯΙ', - 'ᾠ' => 'ὨΙ', - 'ᾡ' => 'ὩΙ', - 'ᾢ' => 'ὪΙ', - 'ᾣ' => 'ὫΙ', - 'ᾤ' => 'ὬΙ', - 'ᾥ' => 'ὭΙ', - 'ᾦ' => 'ὮΙ', - 'ᾧ' => 'ὯΙ', - 'ᾰ' => 'Ᾰ', - 'ᾱ' => 'Ᾱ', - 'ᾳ' => 'ΑΙ', - 'ι' => 'Ι', - 'ῃ' => 'ΗΙ', - 'ῐ' => 'Ῐ', - 'ῑ' => 'Ῑ', - 'ῠ' => 'Ῠ', - 'ῡ' => 'Ῡ', - 'ῥ' => 'Ῥ', - 'ῳ' => 'ΩΙ', - 'ⅎ' => 'Ⅎ', - 'ⅰ' => 'Ⅰ', - 'ⅱ' => 'Ⅱ', - 'ⅲ' => 'Ⅲ', - 'ⅳ' => 'Ⅳ', - 'ⅴ' => 'Ⅴ', - 'ⅵ' => 'Ⅵ', - 'ⅶ' => 'Ⅶ', - 'ⅷ' => 'Ⅷ', - 'ⅸ' => 'Ⅸ', - 'ⅹ' => 'Ⅹ', - 'ⅺ' => 'Ⅺ', - 'ⅻ' => 'Ⅻ', - 'ⅼ' => 'Ⅼ', - 'ⅽ' => 'Ⅽ', - 'ⅾ' => 'Ⅾ', - 'ⅿ' => 'Ⅿ', - 'ↄ' => 'Ↄ', - 'ⓐ' => 'Ⓐ', - 'ⓑ' => 'Ⓑ', - 'ⓒ' => 'Ⓒ', - 'ⓓ' => 'Ⓓ', - 'ⓔ' => 'Ⓔ', - 'ⓕ' => 'Ⓕ', - 'ⓖ' => 'Ⓖ', - 'ⓗ' => 'Ⓗ', - 'ⓘ' => 'Ⓘ', - 'ⓙ' => 'Ⓙ', - 'ⓚ' => 'Ⓚ', - 'ⓛ' => 'Ⓛ', - 'ⓜ' => 'Ⓜ', - 'ⓝ' => 'Ⓝ', - 'ⓞ' => 'Ⓞ', - 'ⓟ' => 'Ⓟ', - 'ⓠ' => 'Ⓠ', - 'ⓡ' => 'Ⓡ', - 'ⓢ' => 'Ⓢ', - 'ⓣ' => 'Ⓣ', - 'ⓤ' => 'Ⓤ', - 'ⓥ' => 'Ⓥ', - 'ⓦ' => 'Ⓦ', - 'ⓧ' => 'Ⓧ', - 'ⓨ' => 'Ⓨ', - 'ⓩ' => 'Ⓩ', - 'ⰰ' => 'Ⰰ', - 'ⰱ' => 'Ⰱ', - 'ⰲ' => 'Ⰲ', - 'ⰳ' => 'Ⰳ', - 'ⰴ' => 'Ⰴ', - 'ⰵ' => 'Ⰵ', - 'ⰶ' => 'Ⰶ', - 'ⰷ' => 'Ⰷ', - 'ⰸ' => 'Ⰸ', - 'ⰹ' => 'Ⰹ', - 'ⰺ' => 'Ⰺ', - 'ⰻ' => 'Ⰻ', - 'ⰼ' => 'Ⰼ', - 'ⰽ' => 'Ⰽ', - 'ⰾ' => 'Ⰾ', - 'ⰿ' => 'Ⰿ', - 'ⱀ' => 'Ⱀ', - 'ⱁ' => 'Ⱁ', - 'ⱂ' => 'Ⱂ', - 'ⱃ' => 'Ⱃ', - 'ⱄ' => 'Ⱄ', - 'ⱅ' => 'Ⱅ', - 'ⱆ' => 'Ⱆ', - 'ⱇ' => 'Ⱇ', - 'ⱈ' => 'Ⱈ', - 'ⱉ' => 'Ⱉ', - 'ⱊ' => 'Ⱊ', - 'ⱋ' => 'Ⱋ', - 'ⱌ' => 'Ⱌ', - 'ⱍ' => 'Ⱍ', - 'ⱎ' => 'Ⱎ', - 'ⱏ' => 'Ⱏ', - 'ⱐ' => 'Ⱐ', - 'ⱑ' => 'Ⱑ', - 'ⱒ' => 'Ⱒ', - 'ⱓ' => 'Ⱓ', - 'ⱔ' => 'Ⱔ', - 'ⱕ' => 'Ⱕ', - 'ⱖ' => 'Ⱖ', - 'ⱗ' => 'Ⱗ', - 'ⱘ' => 'Ⱘ', - 'ⱙ' => 'Ⱙ', - 'ⱚ' => 'Ⱚ', - 'ⱛ' => 'Ⱛ', - 'ⱜ' => 'Ⱜ', - 'ⱝ' => 'Ⱝ', - 'ⱞ' => 'Ⱞ', - 'ⱡ' => 'Ⱡ', - 'ⱥ' => 'Ⱥ', - 'ⱦ' => 'Ⱦ', - 'ⱨ' => 'Ⱨ', - 'ⱪ' => 'Ⱪ', - 'ⱬ' => 'Ⱬ', - 'ⱳ' => 'Ⱳ', - 'ⱶ' => 'Ⱶ', - 'ⲁ' => 'Ⲁ', - 'ⲃ' => 'Ⲃ', - 'ⲅ' => 'Ⲅ', - 'ⲇ' => 'Ⲇ', - 'ⲉ' => 'Ⲉ', - 'ⲋ' => 'Ⲋ', - 'ⲍ' => 'Ⲍ', - 'ⲏ' => 'Ⲏ', - 'ⲑ' => 'Ⲑ', - 'ⲓ' => 'Ⲓ', - 'ⲕ' => 'Ⲕ', - 'ⲗ' => 'Ⲗ', - 'ⲙ' => 'Ⲙ', - 'ⲛ' => 'Ⲛ', - 'ⲝ' => 'Ⲝ', - 'ⲟ' => 'Ⲟ', - 'ⲡ' => 'Ⲡ', - 'ⲣ' => 'Ⲣ', - 'ⲥ' => 'Ⲥ', - 'ⲧ' => 'Ⲧ', - 'ⲩ' => 'Ⲩ', - 'ⲫ' => 'Ⲫ', - 'ⲭ' => 'Ⲭ', - 'ⲯ' => 'Ⲯ', - 'ⲱ' => 'Ⲱ', - 'ⲳ' => 'Ⲳ', - 'ⲵ' => 'Ⲵ', - 'ⲷ' => 'Ⲷ', - 'ⲹ' => 'Ⲹ', - 'ⲻ' => 'Ⲻ', - 'ⲽ' => 'Ⲽ', - 'ⲿ' => 'Ⲿ', - 'ⳁ' => 'Ⳁ', - 'ⳃ' => 'Ⳃ', - 'ⳅ' => 'Ⳅ', - 'ⳇ' => 'Ⳇ', - 'ⳉ' => 'Ⳉ', - 'ⳋ' => 'Ⳋ', - 'ⳍ' => 'Ⳍ', - 'ⳏ' => 'Ⳏ', - 'ⳑ' => 'Ⳑ', - 'ⳓ' => 'Ⳓ', - 'ⳕ' => 'Ⳕ', - 'ⳗ' => 'Ⳗ', - 'ⳙ' => 'Ⳙ', - 'ⳛ' => 'Ⳛ', - 'ⳝ' => 'Ⳝ', - 'ⳟ' => 'Ⳟ', - 'ⳡ' => 'Ⳡ', - 'ⳣ' => 'Ⳣ', - 'ⳬ' => 'Ⳬ', - 'ⳮ' => 'Ⳮ', - 'ⳳ' => 'Ⳳ', - 'ⴀ' => 'Ⴀ', - 'ⴁ' => 'Ⴁ', - 'ⴂ' => 'Ⴂ', - 'ⴃ' => 'Ⴃ', - 'ⴄ' => 'Ⴄ', - 'ⴅ' => 'Ⴅ', - 'ⴆ' => 'Ⴆ', - 'ⴇ' => 'Ⴇ', - 'ⴈ' => 'Ⴈ', - 'ⴉ' => 'Ⴉ', - 'ⴊ' => 'Ⴊ', - 'ⴋ' => 'Ⴋ', - 'ⴌ' => 'Ⴌ', - 'ⴍ' => 'Ⴍ', - 'ⴎ' => 'Ⴎ', - 'ⴏ' => 'Ⴏ', - 'ⴐ' => 'Ⴐ', - 'ⴑ' => 'Ⴑ', - 'ⴒ' => 'Ⴒ', - 'ⴓ' => 'Ⴓ', - 'ⴔ' => 'Ⴔ', - 'ⴕ' => 'Ⴕ', - 'ⴖ' => 'Ⴖ', - 'ⴗ' => 'Ⴗ', - 'ⴘ' => 'Ⴘ', - 'ⴙ' => 'Ⴙ', - 'ⴚ' => 'Ⴚ', - 'ⴛ' => 'Ⴛ', - 'ⴜ' => 'Ⴜ', - 'ⴝ' => 'Ⴝ', - 'ⴞ' => 'Ⴞ', - 'ⴟ' => 'Ⴟ', - 'ⴠ' => 'Ⴠ', - 'ⴡ' => 'Ⴡ', - 'ⴢ' => 'Ⴢ', - 'ⴣ' => 'Ⴣ', - 'ⴤ' => 'Ⴤ', - 'ⴥ' => 'Ⴥ', - 'ⴧ' => 'Ⴧ', - 'ⴭ' => 'Ⴭ', - 'ꙁ' => 'Ꙁ', - 'ꙃ' => 'Ꙃ', - 'ꙅ' => 'Ꙅ', - 'ꙇ' => 'Ꙇ', - 'ꙉ' => 'Ꙉ', - 'ꙋ' => 'Ꙋ', - 'ꙍ' => 'Ꙍ', - 'ꙏ' => 'Ꙏ', - 'ꙑ' => 'Ꙑ', - 'ꙓ' => 'Ꙓ', - 'ꙕ' => 'Ꙕ', - 'ꙗ' => 'Ꙗ', - 'ꙙ' => 'Ꙙ', - 'ꙛ' => 'Ꙛ', - 'ꙝ' => 'Ꙝ', - 'ꙟ' => 'Ꙟ', - 'ꙡ' => 'Ꙡ', - 'ꙣ' => 'Ꙣ', - 'ꙥ' => 'Ꙥ', - 'ꙧ' => 'Ꙧ', - 'ꙩ' => 'Ꙩ', - 'ꙫ' => 'Ꙫ', - 'ꙭ' => 'Ꙭ', - 'ꚁ' => 'Ꚁ', - 'ꚃ' => 'Ꚃ', - 'ꚅ' => 'Ꚅ', - 'ꚇ' => 'Ꚇ', - 'ꚉ' => 'Ꚉ', - 'ꚋ' => 'Ꚋ', - 'ꚍ' => 'Ꚍ', - 'ꚏ' => 'Ꚏ', - 'ꚑ' => 'Ꚑ', - 'ꚓ' => 'Ꚓ', - 'ꚕ' => 'Ꚕ', - 'ꚗ' => 'Ꚗ', - 'ꚙ' => 'Ꚙ', - 'ꚛ' => 'Ꚛ', - 'ꜣ' => 'Ꜣ', - 'ꜥ' => 'Ꜥ', - 'ꜧ' => 'Ꜧ', - 'ꜩ' => 'Ꜩ', - 'ꜫ' => 'Ꜫ', - 'ꜭ' => 'Ꜭ', - 'ꜯ' => 'Ꜯ', - 'ꜳ' => 'Ꜳ', - 'ꜵ' => 'Ꜵ', - 'ꜷ' => 'Ꜷ', - 'ꜹ' => 'Ꜹ', - 'ꜻ' => 'Ꜻ', - 'ꜽ' => 'Ꜽ', - 'ꜿ' => 'Ꜿ', - 'ꝁ' => 'Ꝁ', - 'ꝃ' => 'Ꝃ', - 'ꝅ' => 'Ꝅ', - 'ꝇ' => 'Ꝇ', - 'ꝉ' => 'Ꝉ', - 'ꝋ' => 'Ꝋ', - 'ꝍ' => 'Ꝍ', - 'ꝏ' => 'Ꝏ', - 'ꝑ' => 'Ꝑ', - 'ꝓ' => 'Ꝓ', - 'ꝕ' => 'Ꝕ', - 'ꝗ' => 'Ꝗ', - 'ꝙ' => 'Ꝙ', - 'ꝛ' => 'Ꝛ', - 'ꝝ' => 'Ꝝ', - 'ꝟ' => 'Ꝟ', - 'ꝡ' => 'Ꝡ', - 'ꝣ' => 'Ꝣ', - 'ꝥ' => 'Ꝥ', - 'ꝧ' => 'Ꝧ', - 'ꝩ' => 'Ꝩ', - 'ꝫ' => 'Ꝫ', - 'ꝭ' => 'Ꝭ', - 'ꝯ' => 'Ꝯ', - 'ꝺ' => 'Ꝺ', - 'ꝼ' => 'Ꝼ', - 'ꝿ' => 'Ꝿ', - 'ꞁ' => 'Ꞁ', - 'ꞃ' => 'Ꞃ', - 'ꞅ' => 'Ꞅ', - 'ꞇ' => 'Ꞇ', - 'ꞌ' => 'Ꞌ', - 'ꞑ' => 'Ꞑ', - 'ꞓ' => 'Ꞓ', - 'ꞔ' => 'Ꞔ', - 'ꞗ' => 'Ꞗ', - 'ꞙ' => 'Ꞙ', - 'ꞛ' => 'Ꞛ', - 'ꞝ' => 'Ꞝ', - 'ꞟ' => 'Ꞟ', - 'ꞡ' => 'Ꞡ', - 'ꞣ' => 'Ꞣ', - 'ꞥ' => 'Ꞥ', - 'ꞧ' => 'Ꞧ', - 'ꞩ' => 'Ꞩ', - 'ꞵ' => 'Ꞵ', - 'ꞷ' => 'Ꞷ', - 'ꞹ' => 'Ꞹ', - 'ꞻ' => 'Ꞻ', - 'ꞽ' => 'Ꞽ', - 'ꞿ' => 'Ꞿ', - 'ꟃ' => 'Ꟃ', - 'ꟈ' => 'Ꟈ', - 'ꟊ' => 'Ꟊ', - 'ꟶ' => 'Ꟶ', - 'ꭓ' => 'Ꭓ', - 'ꭰ' => 'Ꭰ', - 'ꭱ' => 'Ꭱ', - 'ꭲ' => 'Ꭲ', - 'ꭳ' => 'Ꭳ', - 'ꭴ' => 'Ꭴ', - 'ꭵ' => 'Ꭵ', - 'ꭶ' => 'Ꭶ', - 'ꭷ' => 'Ꭷ', - 'ꭸ' => 'Ꭸ', - 'ꭹ' => 'Ꭹ', - 'ꭺ' => 'Ꭺ', - 'ꭻ' => 'Ꭻ', - 'ꭼ' => 'Ꭼ', - 'ꭽ' => 'Ꭽ', - 'ꭾ' => 'Ꭾ', - 'ꭿ' => 'Ꭿ', - 'ꮀ' => 'Ꮀ', - 'ꮁ' => 'Ꮁ', - 'ꮂ' => 'Ꮂ', - 'ꮃ' => 'Ꮃ', - 'ꮄ' => 'Ꮄ', - 'ꮅ' => 'Ꮅ', - 'ꮆ' => 'Ꮆ', - 'ꮇ' => 'Ꮇ', - 'ꮈ' => 'Ꮈ', - 'ꮉ' => 'Ꮉ', - 'ꮊ' => 'Ꮊ', - 'ꮋ' => 'Ꮋ', - 'ꮌ' => 'Ꮌ', - 'ꮍ' => 'Ꮍ', - 'ꮎ' => 'Ꮎ', - 'ꮏ' => 'Ꮏ', - 'ꮐ' => 'Ꮐ', - 'ꮑ' => 'Ꮑ', - 'ꮒ' => 'Ꮒ', - 'ꮓ' => 'Ꮓ', - 'ꮔ' => 'Ꮔ', - 'ꮕ' => 'Ꮕ', - 'ꮖ' => 'Ꮖ', - 'ꮗ' => 'Ꮗ', - 'ꮘ' => 'Ꮘ', - 'ꮙ' => 'Ꮙ', - 'ꮚ' => 'Ꮚ', - 'ꮛ' => 'Ꮛ', - 'ꮜ' => 'Ꮜ', - 'ꮝ' => 'Ꮝ', - 'ꮞ' => 'Ꮞ', - 'ꮟ' => 'Ꮟ', - 'ꮠ' => 'Ꮠ', - 'ꮡ' => 'Ꮡ', - 'ꮢ' => 'Ꮢ', - 'ꮣ' => 'Ꮣ', - 'ꮤ' => 'Ꮤ', - 'ꮥ' => 'Ꮥ', - 'ꮦ' => 'Ꮦ', - 'ꮧ' => 'Ꮧ', - 'ꮨ' => 'Ꮨ', - 'ꮩ' => 'Ꮩ', - 'ꮪ' => 'Ꮪ', - 'ꮫ' => 'Ꮫ', - 'ꮬ' => 'Ꮬ', - 'ꮭ' => 'Ꮭ', - 'ꮮ' => 'Ꮮ', - 'ꮯ' => 'Ꮯ', - 'ꮰ' => 'Ꮰ', - 'ꮱ' => 'Ꮱ', - 'ꮲ' => 'Ꮲ', - 'ꮳ' => 'Ꮳ', - 'ꮴ' => 'Ꮴ', - 'ꮵ' => 'Ꮵ', - 'ꮶ' => 'Ꮶ', - 'ꮷ' => 'Ꮷ', - 'ꮸ' => 'Ꮸ', - 'ꮹ' => 'Ꮹ', - 'ꮺ' => 'Ꮺ', - 'ꮻ' => 'Ꮻ', - 'ꮼ' => 'Ꮼ', - 'ꮽ' => 'Ꮽ', - 'ꮾ' => 'Ꮾ', - 'ꮿ' => 'Ꮿ', - 'a' => 'A', - 'b' => 'B', - 'c' => 'C', - 'd' => 'D', - 'e' => 'E', - 'f' => 'F', - 'g' => 'G', - 'h' => 'H', - 'i' => 'I', - 'j' => 'J', - 'k' => 'K', - 'l' => 'L', - 'm' => 'M', - 'n' => 'N', - 'o' => 'O', - 'p' => 'P', - 'q' => 'Q', - 'r' => 'R', - 's' => 'S', - 't' => 'T', - 'u' => 'U', - 'v' => 'V', - 'w' => 'W', - 'x' => 'X', - 'y' => 'Y', - 'z' => 'Z', - '𐐨' => '𐐀', - '𐐩' => '𐐁', - '𐐪' => '𐐂', - '𐐫' => '𐐃', - '𐐬' => '𐐄', - '𐐭' => '𐐅', - '𐐮' => '𐐆', - '𐐯' => '𐐇', - '𐐰' => '𐐈', - '𐐱' => '𐐉', - '𐐲' => '𐐊', - '𐐳' => '𐐋', - '𐐴' => '𐐌', - '𐐵' => '𐐍', - '𐐶' => '𐐎', - '𐐷' => '𐐏', - '𐐸' => '𐐐', - '𐐹' => '𐐑', - '𐐺' => '𐐒', - '𐐻' => '𐐓', - '𐐼' => '𐐔', - '𐐽' => '𐐕', - '𐐾' => '𐐖', - '𐐿' => '𐐗', - '𐑀' => '𐐘', - '𐑁' => '𐐙', - '𐑂' => '𐐚', - '𐑃' => '𐐛', - '𐑄' => '𐐜', - '𐑅' => '𐐝', - '𐑆' => '𐐞', - '𐑇' => '𐐟', - '𐑈' => '𐐠', - '𐑉' => '𐐡', - '𐑊' => '𐐢', - '𐑋' => '𐐣', - '𐑌' => '𐐤', - '𐑍' => '𐐥', - '𐑎' => '𐐦', - '𐑏' => '𐐧', - '𐓘' => '𐒰', - '𐓙' => '𐒱', - '𐓚' => '𐒲', - '𐓛' => '𐒳', - '𐓜' => '𐒴', - '𐓝' => '𐒵', - '𐓞' => '𐒶', - '𐓟' => '𐒷', - '𐓠' => '𐒸', - '𐓡' => '𐒹', - '𐓢' => '𐒺', - '𐓣' => '𐒻', - '𐓤' => '𐒼', - '𐓥' => '𐒽', - '𐓦' => '𐒾', - '𐓧' => '𐒿', - '𐓨' => '𐓀', - '𐓩' => '𐓁', - '𐓪' => '𐓂', - '𐓫' => '𐓃', - '𐓬' => '𐓄', - '𐓭' => '𐓅', - '𐓮' => '𐓆', - '𐓯' => '𐓇', - '𐓰' => '𐓈', - '𐓱' => '𐓉', - '𐓲' => '𐓊', - '𐓳' => '𐓋', - '𐓴' => '𐓌', - '𐓵' => '𐓍', - '𐓶' => '𐓎', - '𐓷' => '𐓏', - '𐓸' => '𐓐', - '𐓹' => '𐓑', - '𐓺' => '𐓒', - '𐓻' => '𐓓', - '𐳀' => '𐲀', - '𐳁' => '𐲁', - '𐳂' => '𐲂', - '𐳃' => '𐲃', - '𐳄' => '𐲄', - '𐳅' => '𐲅', - '𐳆' => '𐲆', - '𐳇' => '𐲇', - '𐳈' => '𐲈', - '𐳉' => '𐲉', - '𐳊' => '𐲊', - '𐳋' => '𐲋', - '𐳌' => '𐲌', - '𐳍' => '𐲍', - '𐳎' => '𐲎', - '𐳏' => '𐲏', - '𐳐' => '𐲐', - '𐳑' => '𐲑', - '𐳒' => '𐲒', - '𐳓' => '𐲓', - '𐳔' => '𐲔', - '𐳕' => '𐲕', - '𐳖' => '𐲖', - '𐳗' => '𐲗', - '𐳘' => '𐲘', - '𐳙' => '𐲙', - '𐳚' => '𐲚', - '𐳛' => '𐲛', - '𐳜' => '𐲜', - '𐳝' => '𐲝', - '𐳞' => '𐲞', - '𐳟' => '𐲟', - '𐳠' => '𐲠', - '𐳡' => '𐲡', - '𐳢' => '𐲢', - '𐳣' => '𐲣', - '𐳤' => '𐲤', - '𐳥' => '𐲥', - '𐳦' => '𐲦', - '𐳧' => '𐲧', - '𐳨' => '𐲨', - '𐳩' => '𐲩', - '𐳪' => '𐲪', - '𐳫' => '𐲫', - '𐳬' => '𐲬', - '𐳭' => '𐲭', - '𐳮' => '𐲮', - '𐳯' => '𐲯', - '𐳰' => '𐲰', - '𐳱' => '𐲱', - '𐳲' => '𐲲', - '𑣀' => '𑢠', - '𑣁' => '𑢡', - '𑣂' => '𑢢', - '𑣃' => '𑢣', - '𑣄' => '𑢤', - '𑣅' => '𑢥', - '𑣆' => '𑢦', - '𑣇' => '𑢧', - '𑣈' => '𑢨', - '𑣉' => '𑢩', - '𑣊' => '𑢪', - '𑣋' => '𑢫', - '𑣌' => '𑢬', - '𑣍' => '𑢭', - '𑣎' => '𑢮', - '𑣏' => '𑢯', - '𑣐' => '𑢰', - '𑣑' => '𑢱', - '𑣒' => '𑢲', - '𑣓' => '𑢳', - '𑣔' => '𑢴', - '𑣕' => '𑢵', - '𑣖' => '𑢶', - '𑣗' => '𑢷', - '𑣘' => '𑢸', - '𑣙' => '𑢹', - '𑣚' => '𑢺', - '𑣛' => '𑢻', - '𑣜' => '𑢼', - '𑣝' => '𑢽', - '𑣞' => '𑢾', - '𑣟' => '𑢿', - '𖹠' => '𖹀', - '𖹡' => '𖹁', - '𖹢' => '𖹂', - '𖹣' => '𖹃', - '𖹤' => '𖹄', - '𖹥' => '𖹅', - '𖹦' => '𖹆', - '𖹧' => '𖹇', - '𖹨' => '𖹈', - '𖹩' => '𖹉', - '𖹪' => '𖹊', - '𖹫' => '𖹋', - '𖹬' => '𖹌', - '𖹭' => '𖹍', - '𖹮' => '𖹎', - '𖹯' => '𖹏', - '𖹰' => '𖹐', - '𖹱' => '𖹑', - '𖹲' => '𖹒', - '𖹳' => '𖹓', - '𖹴' => '𖹔', - '𖹵' => '𖹕', - '𖹶' => '𖹖', - '𖹷' => '𖹗', - '𖹸' => '𖹘', - '𖹹' => '𖹙', - '𖹺' => '𖹚', - '𖹻' => '𖹛', - '𖹼' => '𖹜', - '𖹽' => '𖹝', - '𖹾' => '𖹞', - '𖹿' => '𖹟', - '𞤢' => '𞤀', - '𞤣' => '𞤁', - '𞤤' => '𞤂', - '𞤥' => '𞤃', - '𞤦' => '𞤄', - '𞤧' => '𞤅', - '𞤨' => '𞤆', - '𞤩' => '𞤇', - '𞤪' => '𞤈', - '𞤫' => '𞤉', - '𞤬' => '𞤊', - '𞤭' => '𞤋', - '𞤮' => '𞤌', - '𞤯' => '𞤍', - '𞤰' => '𞤎', - '𞤱' => '𞤏', - '𞤲' => '𞤐', - '𞤳' => '𞤑', - '𞤴' => '𞤒', - '𞤵' => '𞤓', - '𞤶' => '𞤔', - '𞤷' => '𞤕', - '𞤸' => '𞤖', - '𞤹' => '𞤗', - '𞤺' => '𞤘', - '𞤻' => '𞤙', - '𞤼' => '𞤚', - '𞤽' => '𞤛', - '𞤾' => '𞤜', - '𞤿' => '𞤝', - '𞥀' => '𞤞', - '𞥁' => '𞤟', - '𞥂' => '𞤠', - '𞥃' => '𞤡', - 'ß' => 'SS', - 'ff' => 'FF', - 'fi' => 'FI', - 'fl' => 'FL', - 'ffi' => 'FFI', - 'ffl' => 'FFL', - 'ſt' => 'ST', - 'st' => 'ST', - 'և' => 'ԵՒ', - 'ﬓ' => 'ՄՆ', - 'ﬔ' => 'ՄԵ', - 'ﬕ' => 'ՄԻ', - 'ﬖ' => 'ՎՆ', - 'ﬗ' => 'ՄԽ', - 'ʼn' => 'ʼN', - 'ΐ' => 'Ϊ́', - 'ΰ' => 'Ϋ́', - 'ǰ' => 'J̌', - 'ẖ' => 'H̱', - 'ẗ' => 'T̈', - 'ẘ' => 'W̊', - 'ẙ' => 'Y̊', - 'ẚ' => 'Aʾ', - 'ὐ' => 'Υ̓', - 'ὒ' => 'Υ̓̀', - 'ὔ' => 'Υ̓́', - 'ὖ' => 'Υ̓͂', - 'ᾶ' => 'Α͂', - 'ῆ' => 'Η͂', - 'ῒ' => 'Ϊ̀', - 'ΐ' => 'Ϊ́', - 'ῖ' => 'Ι͂', - 'ῗ' => 'Ϊ͂', - 'ῢ' => 'Ϋ̀', - 'ΰ' => 'Ϋ́', - 'ῤ' => 'Ρ̓', - 'ῦ' => 'Υ͂', - 'ῧ' => 'Ϋ͂', - 'ῶ' => 'Ω͂', - 'ᾈ' => 'ἈΙ', - 'ᾉ' => 'ἉΙ', - 'ᾊ' => 'ἊΙ', - 'ᾋ' => 'ἋΙ', - 'ᾌ' => 'ἌΙ', - 'ᾍ' => 'ἍΙ', - 'ᾎ' => 'ἎΙ', - 'ᾏ' => 'ἏΙ', - 'ᾘ' => 'ἨΙ', - 'ᾙ' => 'ἩΙ', - 'ᾚ' => 'ἪΙ', - 'ᾛ' => 'ἫΙ', - 'ᾜ' => 'ἬΙ', - 'ᾝ' => 'ἭΙ', - 'ᾞ' => 'ἮΙ', - 'ᾟ' => 'ἯΙ', - 'ᾨ' => 'ὨΙ', - 'ᾩ' => 'ὩΙ', - 'ᾪ' => 'ὪΙ', - 'ᾫ' => 'ὫΙ', - 'ᾬ' => 'ὬΙ', - 'ᾭ' => 'ὭΙ', - 'ᾮ' => 'ὮΙ', - 'ᾯ' => 'ὯΙ', - 'ᾼ' => 'ΑΙ', - 'ῌ' => 'ΗΙ', - 'ῼ' => 'ΩΙ', - 'ᾲ' => 'ᾺΙ', - 'ᾴ' => 'ΆΙ', - 'ῂ' => 'ῊΙ', - 'ῄ' => 'ΉΙ', - 'ῲ' => 'ῺΙ', - 'ῴ' => 'ΏΙ', - 'ᾷ' => 'Α͂Ι', - 'ῇ' => 'Η͂Ι', - 'ῷ' => 'Ω͂Ι', -); diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php deleted file mode 100644 index 1fedd1f..0000000 --- a/vendor/symfony/polyfill-mbstring/bootstrap.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * 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); -} diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php deleted file mode 100644 index 82f5ac4..0000000 --- a/vendor/symfony/polyfill-mbstring/bootstrap80.php +++ /dev/null @@ -1,143 +0,0 @@ - - * - * 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); -} diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json deleted file mode 100644 index 4489553..0000000 --- a/vendor/symfony/polyfill-mbstring/composer.json +++ /dev/null @@ -1,41 +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" - }, - "provide": { - "ext-mbstring": "*" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Mbstring\\": "" }, - "files": [ "bootstrap.php" ] - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - } -} diff --git a/vendor/symfony/polyfill-php72/LICENSE b/vendor/symfony/polyfill-php72/LICENSE deleted file mode 100644 index 4cd8bdd..0000000 --- a/vendor/symfony/polyfill-php72/LICENSE +++ /dev/null @@ -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. diff --git a/vendor/symfony/polyfill-php72/Php72.php b/vendor/symfony/polyfill-php72/Php72.php deleted file mode 100644 index 7bf96c9..0000000 --- a/vendor/symfony/polyfill-php72/Php72.php +++ /dev/null @@ -1,217 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php72; - -/** - * @author Nicolas Grekas - * @author Dariusz Rumiński - * - * @internal - */ -final class Php72 -{ - private static $hashMask; - - public static function utf8_encode($s) - { - $s .= $s; - $len = \strlen($s); - - for ($i = $len >> 1, $j = 0; $i < $len; ++$i, ++$j) { - switch (true) { - case $s[$i] < "\x80": $s[$j] = $s[$i]; break; - case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break; - default: $s[$j] = "\xC3"; $s[++$j] = \chr(\ord($s[$i]) - 64); break; - } - } - - return substr($s, 0, $j); - } - - public static function utf8_decode($s) - { - $s = (string) $s; - $len = \strlen($s); - - for ($i = 0, $j = 0; $i < $len; ++$i, ++$j) { - switch ($s[$i] & "\xF0") { - case "\xC0": - case "\xD0": - $c = (\ord($s[$i] & "\x1F") << 6) | \ord($s[++$i] & "\x3F"); - $s[$j] = $c < 256 ? \chr($c) : '?'; - break; - - case "\xF0": - ++$i; - // no break - - case "\xE0": - $s[$j] = '?'; - $i += 2; - break; - - default: - $s[$j] = $s[$i]; - } - } - - return substr($s, 0, $j); - } - - public static function php_os_family() - { - if ('\\' === \DIRECTORY_SEPARATOR) { - return 'Windows'; - } - - $map = [ - 'Darwin' => 'Darwin', - 'DragonFly' => 'BSD', - 'FreeBSD' => 'BSD', - 'NetBSD' => 'BSD', - 'OpenBSD' => 'BSD', - 'Linux' => 'Linux', - 'SunOS' => 'Solaris', - ]; - - return $map[\PHP_OS] ?? 'Unknown'; - } - - public static function spl_object_id($object) - { - if (null === self::$hashMask) { - self::initHashMask(); - } - if (null === $hash = spl_object_hash($object)) { - return; - } - - // On 32-bit systems, PHP_INT_SIZE is 4, - return self::$hashMask ^ hexdec(substr($hash, 16 - (\PHP_INT_SIZE * 2 - 1), \PHP_INT_SIZE * 2 - 1)); - } - - public static function sapi_windows_vt100_support($stream, $enable = null) - { - if (!\is_resource($stream)) { - trigger_error('sapi_windows_vt100_support() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING); - - return false; - } - - $meta = stream_get_meta_data($stream); - - if ('STDIO' !== $meta['stream_type']) { - trigger_error('sapi_windows_vt100_support() was not able to analyze the specified stream', \E_USER_WARNING); - - return false; - } - - // We cannot actually disable vt100 support if it is set - if (false === $enable || !self::stream_isatty($stream)) { - return false; - } - - // The native function does not apply to stdin - $meta = array_map('strtolower', $meta); - $stdin = 'php://stdin' === $meta['uri'] || 'php://fd/0' === $meta['uri']; - - return !$stdin - && (false !== getenv('ANSICON') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM') - || 'Hyper' === getenv('TERM_PROGRAM')); - } - - public static function stream_isatty($stream) - { - if (!\is_resource($stream)) { - trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING); - - return false; - } - - if ('\\' === \DIRECTORY_SEPARATOR) { - $stat = @fstat($stream); - // Check if formatted mode is S_IFCHR - return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; - } - - return \function_exists('posix_isatty') && @posix_isatty($stream); - } - - private static function initHashMask() - { - $obj = (object) []; - self::$hashMask = -1; - - // check if we are nested in an output buffering handler to prevent a fatal error with ob_start() below - $obFuncs = ['ob_clean', 'ob_end_clean', 'ob_flush', 'ob_end_flush', 'ob_get_contents', 'ob_get_flush']; - foreach (debug_backtrace(\PHP_VERSION_ID >= 50400 ? \DEBUG_BACKTRACE_IGNORE_ARGS : false) as $frame) { - if (isset($frame['function'][0]) && !isset($frame['class']) && 'o' === $frame['function'][0] && \in_array($frame['function'], $obFuncs)) { - $frame['line'] = 0; - break; - } - } - if (!empty($frame['line'])) { - ob_start(); - debug_zval_dump($obj); - self::$hashMask = (int) substr(ob_get_clean(), 17); - } - - self::$hashMask ^= hexdec(substr(spl_object_hash($obj), 16 - (\PHP_INT_SIZE * 2 - 1), \PHP_INT_SIZE * 2 - 1)); - } - - 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 = $encoding ?? mb_internal_encoding()) { - $s = mb_convert_encoding($s, $encoding, 'UTF-8'); - } - - return $s; - } - - public static function mb_ord($s, $encoding = null) - { - if (null === $encoding) { - $s = mb_convert_encoding($s, 'UTF-8'); - } elseif ('UTF-8' !== $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; - } -} diff --git a/vendor/symfony/polyfill-php72/README.md b/vendor/symfony/polyfill-php72/README.md deleted file mode 100644 index ed19050..0000000 --- a/vendor/symfony/polyfill-php72/README.md +++ /dev/null @@ -1,35 +0,0 @@ -Symfony Polyfill / Php72 -======================== - -This component provides functions added to PHP 7.2 core: - -- [`spl_object_id`](https://php.net/spl_object_id) -- [`stream_isatty`](https://php.net/stream_isatty) - -And also functions added to PHP 7.2 mbstring: - -- [`mb_ord`](https://php.net/mb_ord) -- [`mb_chr`](https://php.net/mb_chr) -- [`mb_scrub`](https://php.net/mb_scrub) - -On Windows only: - -- [`sapi_windows_vt100_support`](https://php.net/sapi_windows_vt100_support) - -Moved to core since 7.2 (was in the optional XML extension earlier): - -- [`utf8_encode`](https://php.net/utf8_encode) -- [`utf8_decode`](https://php.net/utf8_decode) - -Also, it provides constants added to PHP 7.2: - -- [`PHP_FLOAT_*`](https://php.net/reserved.constants#constant.php-float-dig) -- [`PHP_OS_FAMILY`](https://php.net/reserved.constants#constant.php-os-family) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-php72/bootstrap.php b/vendor/symfony/polyfill-php72/bootstrap.php deleted file mode 100644 index b5c92d4..0000000 --- a/vendor/symfony/polyfill-php72/bootstrap.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php72 as p; - -if (\PHP_VERSION_ID >= 70200) { - return; -} - -if (!defined('PHP_FLOAT_DIG')) { - define('PHP_FLOAT_DIG', 15); -} -if (!defined('PHP_FLOAT_EPSILON')) { - define('PHP_FLOAT_EPSILON', 2.2204460492503E-16); -} -if (!defined('PHP_FLOAT_MIN')) { - define('PHP_FLOAT_MIN', 2.2250738585072E-308); -} -if (!defined('PHP_FLOAT_MAX')) { - define('PHP_FLOAT_MAX', 1.7976931348623157E+308); -} -if (!defined('PHP_OS_FAMILY')) { - define('PHP_OS_FAMILY', p\Php72::php_os_family()); -} - -if ('\\' === \DIRECTORY_SEPARATOR && !function_exists('sapi_windows_vt100_support')) { - function sapi_windows_vt100_support($stream, $enable = null) { return p\Php72::sapi_windows_vt100_support($stream, $enable); } -} -if (!function_exists('stream_isatty')) { - function stream_isatty($stream) { return p\Php72::stream_isatty($stream); } -} -if (!function_exists('utf8_encode')) { - function utf8_encode($string) { return p\Php72::utf8_encode($string); } -} -if (!function_exists('utf8_decode')) { - function utf8_decode($string) { return p\Php72::utf8_decode($string); } -} -if (!function_exists('spl_object_id')) { - function spl_object_id($object) { return p\Php72::spl_object_id($object); } -} -if (!function_exists('mb_ord')) { - function mb_ord($string, $encoding = null) { return p\Php72::mb_ord($string, $encoding); } -} -if (!function_exists('mb_chr')) { - function mb_chr($codepoint, $encoding = null) { return p\Php72::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); } -} diff --git a/vendor/symfony/polyfill-php80/LICENSE b/vendor/symfony/polyfill-php80/LICENSE deleted file mode 100644 index 5593b1d..0000000 --- a/vendor/symfony/polyfill-php80/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2020 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. diff --git a/vendor/symfony/polyfill-php80/Php80.php b/vendor/symfony/polyfill-php80/Php80.php deleted file mode 100644 index 362dd1a..0000000 --- a/vendor/symfony/polyfill-php80/Php80.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php80; - -/** - * @author Ion Bazan - * @author Nico Oelgart - * @author Nicolas Grekas - * - * @internal - */ -final class Php80 -{ - public static function fdiv(float $dividend, float $divisor): float - { - return @($dividend / $divisor); - } - - public static function get_debug_type($value): string - { - switch (true) { - case null === $value: return 'null'; - case \is_bool($value): return 'bool'; - case \is_string($value): return 'string'; - case \is_array($value): return 'array'; - case \is_int($value): return 'int'; - case \is_float($value): return 'float'; - case \is_object($value): break; - case $value instanceof \__PHP_Incomplete_Class: return '__PHP_Incomplete_Class'; - default: - if (null === $type = @get_resource_type($value)) { - return 'unknown'; - } - - if ('Unknown' === $type) { - $type = 'closed'; - } - - return "resource ($type)"; - } - - $class = \get_class($value); - - if (false === strpos($class, '@')) { - return $class; - } - - return (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous'; - } - - public static function get_resource_id($res): int - { - if (!\is_resource($res) && null === @get_resource_type($res)) { - throw new \TypeError(sprintf('Argument 1 passed to get_resource_id() must be of the type resource, %s given', get_debug_type($res))); - } - - return (int) $res; - } - - public static function preg_last_error_msg(): string - { - switch (preg_last_error()) { - case \PREG_INTERNAL_ERROR: - return 'Internal error'; - case \PREG_BAD_UTF8_ERROR: - return 'Malformed UTF-8 characters, possibly incorrectly encoded'; - case \PREG_BAD_UTF8_OFFSET_ERROR: - return 'The offset did not correspond to the beginning of a valid UTF-8 code point'; - case \PREG_BACKTRACK_LIMIT_ERROR: - return 'Backtrack limit exhausted'; - case \PREG_RECURSION_LIMIT_ERROR: - return 'Recursion limit exhausted'; - case \PREG_JIT_STACKLIMIT_ERROR: - return 'JIT stack limit exhausted'; - case \PREG_NO_ERROR: - return 'No error'; - default: - return 'Unknown error'; - } - } - - public static function str_contains(string $haystack, string $needle): bool - { - return '' === $needle || false !== strpos($haystack, $needle); - } - - public static function str_starts_with(string $haystack, string $needle): bool - { - return 0 === strncmp($haystack, $needle, \strlen($needle)); - } - - public static function str_ends_with(string $haystack, string $needle): bool - { - if ('' === $needle || $needle === $haystack) { - return true; - } - - if ('' === $haystack) { - return false; - } - - $needleLength = \strlen($needle); - - return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength); - } -} diff --git a/vendor/symfony/polyfill-php80/PhpToken.php b/vendor/symfony/polyfill-php80/PhpToken.php deleted file mode 100644 index fe6e691..0000000 --- a/vendor/symfony/polyfill-php80/PhpToken.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Polyfill\Php80; - -/** - * @author Fedonyuk Anton - * - * @internal - */ -class PhpToken implements \Stringable -{ - /** - * @var int - */ - public $id; - - /** - * @var string - */ - public $text; - - /** - * @var int - */ - public $line; - - /** - * @var int - */ - public $pos; - - public function __construct(int $id, string $text, int $line = -1, int $position = -1) - { - $this->id = $id; - $this->text = $text; - $this->line = $line; - $this->pos = $position; - } - - public function getTokenName(): ?string - { - if ('UNKNOWN' === $name = token_name($this->id)) { - $name = \strlen($this->text) > 1 || \ord($this->text) < 32 ? null : $this->text; - } - - return $name; - } - - /** - * @param int|string|array $kind - */ - public function is($kind): bool - { - foreach ((array) $kind as $value) { - if (\in_array($value, [$this->id, $this->text], true)) { - return true; - } - } - - return false; - } - - public function isIgnorable(): bool - { - return \in_array($this->id, [\T_WHITESPACE, \T_COMMENT, \T_DOC_COMMENT, \T_OPEN_TAG], true); - } - - public function __toString(): string - { - return (string) $this->text; - } - - /** - * @return static[] - */ - public static function tokenize(string $code, int $flags = 0): array - { - $line = 1; - $position = 0; - $tokens = token_get_all($code, $flags); - foreach ($tokens as $index => $token) { - if (\is_string($token)) { - $id = \ord($token); - $text = $token; - } else { - [$id, $text, $line] = $token; - } - $tokens[$index] = new static($id, $text, $line, $position); - $position += \strlen($text); - } - - return $tokens; - } -} diff --git a/vendor/symfony/polyfill-php80/README.md b/vendor/symfony/polyfill-php80/README.md deleted file mode 100644 index 3816c55..0000000 --- a/vendor/symfony/polyfill-php80/README.md +++ /dev/null @@ -1,25 +0,0 @@ -Symfony Polyfill / Php80 -======================== - -This component provides features added to PHP 8.0 core: - -- [`Stringable`](https://php.net/stringable) interface -- [`fdiv`](https://php.net/fdiv) -- [`ValueError`](https://php.net/valueerror) class -- [`UnhandledMatchError`](https://php.net/unhandledmatcherror) class -- `FILTER_VALIDATE_BOOL` constant -- [`get_debug_type`](https://php.net/get_debug_type) -- [`PhpToken`](https://php.net/phptoken) class -- [`preg_last_error_msg`](https://php.net/preg_last_error_msg) -- [`str_contains`](https://php.net/str_contains) -- [`str_starts_with`](https://php.net/str_starts_with) -- [`str_ends_with`](https://php.net/str_ends_with) -- [`get_resource_id`](https://php.net/get_resource_id) - -More information can be found in the -[main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md). - -License -======= - -This library is released under the [MIT license](LICENSE). diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php b/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php deleted file mode 100644 index 2b95542..0000000 --- a/vendor/symfony/polyfill-php80/Resources/stubs/Attribute.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -#[Attribute(Attribute::TARGET_CLASS)] -final class Attribute -{ - public const TARGET_CLASS = 1; - public const TARGET_FUNCTION = 2; - public const TARGET_METHOD = 4; - public const TARGET_PROPERTY = 8; - public const TARGET_CLASS_CONSTANT = 16; - public const TARGET_PARAMETER = 32; - public const TARGET_ALL = 63; - public const IS_REPEATABLE = 64; - - /** @var int */ - public $flags; - - public function __construct(int $flags = self::TARGET_ALL) - { - $this->flags = $flags; - } -} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php b/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php deleted file mode 100644 index bd1212f..0000000 --- a/vendor/symfony/polyfill-php80/Resources/stubs/PhpToken.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (\PHP_VERSION_ID < 80000 && extension_loaded('tokenizer')) { - class PhpToken extends Symfony\Polyfill\Php80\PhpToken - { - } -} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php b/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php deleted file mode 100644 index 7c62d75..0000000 --- a/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (\PHP_VERSION_ID < 80000) { - interface Stringable - { - /** - * @return string - */ - public function __toString(); - } -} diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php b/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php deleted file mode 100644 index 783dbc2..0000000 --- a/vendor/symfony/polyfill-php80/Resources/stubs/ValueError.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (\PHP_VERSION_ID < 80000) { - class ValueError extends Error - { - } -} diff --git a/vendor/symfony/polyfill-php80/bootstrap.php b/vendor/symfony/polyfill-php80/bootstrap.php deleted file mode 100644 index e5f7dbc..0000000 --- a/vendor/symfony/polyfill-php80/bootstrap.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Polyfill\Php80 as p; - -if (\PHP_VERSION_ID >= 80000) { - return; -} - -if (!defined('FILTER_VALIDATE_BOOL') && defined('FILTER_VALIDATE_BOOLEAN')) { - define('FILTER_VALIDATE_BOOL', \FILTER_VALIDATE_BOOLEAN); -} - -if (!function_exists('fdiv')) { - function fdiv(float $num1, float $num2): float { return p\Php80::fdiv($num1, $num2); } -} -if (!function_exists('preg_last_error_msg')) { - function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); } -} -if (!function_exists('str_contains')) { - function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); } -} -if (!function_exists('str_starts_with')) { - function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); } -} -if (!function_exists('str_ends_with')) { - function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); } -} -if (!function_exists('get_debug_type')) { - function get_debug_type($value): string { return p\Php80::get_debug_type($value); } -} -if (!function_exists('get_resource_id')) { - function get_resource_id($resource): int { return p\Php80::get_resource_id($resource); } -} diff --git a/vendor/symfony/polyfill-php80/composer.json b/vendor/symfony/polyfill-php80/composer.json deleted file mode 100644 index bd9a326..0000000 --- a/vendor/symfony/polyfill-php80/composer.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "symfony/polyfill-php80", - "type": "library", - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "keywords": ["polyfill", "shim", "compatibility", "portable"], - "homepage": "https://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "require": { - "php": ">=7.1" - }, - "autoload": { - "psr-4": { "Symfony\\Polyfill\\Php80\\": "" }, - "files": [ "bootstrap.php" ], - "classmap": [ "Resources/stubs" ] - }, - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - } -} diff --git a/vendor/symfony/var-dumper/CHANGELOG.md b/vendor/symfony/var-dumper/CHANGELOG.md deleted file mode 100644 index 94b1c17..0000000 --- a/vendor/symfony/var-dumper/CHANGELOG.md +++ /dev/null @@ -1,53 +0,0 @@ -CHANGELOG -========= - -4.4.0 ------ - - * added `VarDumperTestTrait::setUpVarDumper()` and `VarDumperTestTrait::tearDownVarDumper()` - to configure casters & flags to use in tests - * added `ImagineCaster` and infrastructure to dump images - * added the stamps of a message after it is dispatched in `TraceableMessageBus` and `MessengerDataCollector` collected data - * added `UuidCaster` - * made all casters final - * added support for the `NO_COLOR` env var (https://no-color.org/) - -4.3.0 ------ - - * added `DsCaster` to support dumping the contents of data structures from the Ds extension - -4.2.0 ------ - - * support selecting the format to use by setting the environment variable `VAR_DUMPER_FORMAT` to `html` or `cli` - -4.1.0 ------ - - * added a `ServerDumper` to send serialized Data clones to a server - * added a `ServerDumpCommand` and `DumpServer` to run a server collecting - and displaying dumps on a single place with multiple formats support - * added `CliDescriptor` and `HtmlDescriptor` descriptors for `server:dump` CLI and HTML formats support - -4.0.0 ------ - - * support for passing `\ReflectionClass` instances to the `Caster::castObject()` - method has been dropped, pass class names as strings instead - * the `Data::getRawData()` method has been removed - * the `VarDumperTestTrait::assertDumpEquals()` method expects a 3rd `$filter = 0` - argument and moves `$message = ''` argument at 4th position. - * the `VarDumperTestTrait::assertDumpMatchesFormat()` method expects a 3rd `$filter = 0` - argument and moves `$message = ''` argument at 4th position. - -3.4.0 ------ - - * added `AbstractCloner::setMinDepth()` function to ensure minimum tree depth - * deprecated `MongoCaster` - -2.7.0 ------ - - * deprecated `Cloner\Data::getLimitedClone()`. Use `withMaxDepth`, `withMaxItemsPerDepth` or `withRefHandles` instead. diff --git a/vendor/symfony/var-dumper/Caster/AmqpCaster.php b/vendor/symfony/var-dumper/Caster/AmqpCaster.php deleted file mode 100644 index 60045ff..0000000 --- a/vendor/symfony/var-dumper/Caster/AmqpCaster.php +++ /dev/null @@ -1,212 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts Amqp related classes to array representation. - * - * @author Grégoire Pineau - * - * @final since Symfony 4.4 - */ -class AmqpCaster -{ - private const FLAGS = [ - \AMQP_DURABLE => 'AMQP_DURABLE', - \AMQP_PASSIVE => 'AMQP_PASSIVE', - \AMQP_EXCLUSIVE => 'AMQP_EXCLUSIVE', - \AMQP_AUTODELETE => 'AMQP_AUTODELETE', - \AMQP_INTERNAL => 'AMQP_INTERNAL', - \AMQP_NOLOCAL => 'AMQP_NOLOCAL', - \AMQP_AUTOACK => 'AMQP_AUTOACK', - \AMQP_IFEMPTY => 'AMQP_IFEMPTY', - \AMQP_IFUNUSED => 'AMQP_IFUNUSED', - \AMQP_MANDATORY => 'AMQP_MANDATORY', - \AMQP_IMMEDIATE => 'AMQP_IMMEDIATE', - \AMQP_MULTIPLE => 'AMQP_MULTIPLE', - \AMQP_NOWAIT => 'AMQP_NOWAIT', - \AMQP_REQUEUE => 'AMQP_REQUEUE', - ]; - - private const EXCHANGE_TYPES = [ - \AMQP_EX_TYPE_DIRECT => 'AMQP_EX_TYPE_DIRECT', - \AMQP_EX_TYPE_FANOUT => 'AMQP_EX_TYPE_FANOUT', - \AMQP_EX_TYPE_TOPIC => 'AMQP_EX_TYPE_TOPIC', - \AMQP_EX_TYPE_HEADERS => 'AMQP_EX_TYPE_HEADERS', - ]; - - public static function castConnection(\AMQPConnection $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - $a += [ - $prefix.'is_connected' => $c->isConnected(), - ]; - - // Recent version of the extension already expose private properties - if (isset($a["\x00AMQPConnection\x00login"])) { - return $a; - } - - // BC layer in the amqp lib - if (method_exists($c, 'getReadTimeout')) { - $timeout = $c->getReadTimeout(); - } else { - $timeout = $c->getTimeout(); - } - - $a += [ - $prefix.'is_connected' => $c->isConnected(), - $prefix.'login' => $c->getLogin(), - $prefix.'password' => $c->getPassword(), - $prefix.'host' => $c->getHost(), - $prefix.'vhost' => $c->getVhost(), - $prefix.'port' => $c->getPort(), - $prefix.'read_timeout' => $timeout, - ]; - - return $a; - } - - public static function castChannel(\AMQPChannel $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - $a += [ - $prefix.'is_connected' => $c->isConnected(), - $prefix.'channel_id' => $c->getChannelId(), - ]; - - // Recent version of the extension already expose private properties - if (isset($a["\x00AMQPChannel\x00connection"])) { - return $a; - } - - $a += [ - $prefix.'connection' => $c->getConnection(), - $prefix.'prefetch_size' => $c->getPrefetchSize(), - $prefix.'prefetch_count' => $c->getPrefetchCount(), - ]; - - return $a; - } - - public static function castQueue(\AMQPQueue $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - $a += [ - $prefix.'flags' => self::extractFlags($c->getFlags()), - ]; - - // Recent version of the extension already expose private properties - if (isset($a["\x00AMQPQueue\x00name"])) { - return $a; - } - - $a += [ - $prefix.'connection' => $c->getConnection(), - $prefix.'channel' => $c->getChannel(), - $prefix.'name' => $c->getName(), - $prefix.'arguments' => $c->getArguments(), - ]; - - return $a; - } - - public static function castExchange(\AMQPExchange $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - $a += [ - $prefix.'flags' => self::extractFlags($c->getFlags()), - ]; - - $type = isset(self::EXCHANGE_TYPES[$c->getType()]) ? new ConstStub(self::EXCHANGE_TYPES[$c->getType()], $c->getType()) : $c->getType(); - - // Recent version of the extension already expose private properties - if (isset($a["\x00AMQPExchange\x00name"])) { - $a["\x00AMQPExchange\x00type"] = $type; - - return $a; - } - - $a += [ - $prefix.'connection' => $c->getConnection(), - $prefix.'channel' => $c->getChannel(), - $prefix.'name' => $c->getName(), - $prefix.'type' => $type, - $prefix.'arguments' => $c->getArguments(), - ]; - - return $a; - } - - public static function castEnvelope(\AMQPEnvelope $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $prefix = Caster::PREFIX_VIRTUAL; - - $deliveryMode = new ConstStub($c->getDeliveryMode().(2 === $c->getDeliveryMode() ? ' (persistent)' : ' (non-persistent)'), $c->getDeliveryMode()); - - // Recent version of the extension already expose private properties - if (isset($a["\x00AMQPEnvelope\x00body"])) { - $a["\0AMQPEnvelope\0delivery_mode"] = $deliveryMode; - - return $a; - } - - if (!($filter & Caster::EXCLUDE_VERBOSE)) { - $a += [$prefix.'body' => $c->getBody()]; - } - - $a += [ - $prefix.'delivery_tag' => $c->getDeliveryTag(), - $prefix.'is_redelivery' => $c->isRedelivery(), - $prefix.'exchange_name' => $c->getExchangeName(), - $prefix.'routing_key' => $c->getRoutingKey(), - $prefix.'content_type' => $c->getContentType(), - $prefix.'content_encoding' => $c->getContentEncoding(), - $prefix.'headers' => $c->getHeaders(), - $prefix.'delivery_mode' => $deliveryMode, - $prefix.'priority' => $c->getPriority(), - $prefix.'correlation_id' => $c->getCorrelationId(), - $prefix.'reply_to' => $c->getReplyTo(), - $prefix.'expiration' => $c->getExpiration(), - $prefix.'message_id' => $c->getMessageId(), - $prefix.'timestamp' => $c->getTimeStamp(), - $prefix.'type' => $c->getType(), - $prefix.'user_id' => $c->getUserId(), - $prefix.'app_id' => $c->getAppId(), - ]; - - return $a; - } - - private static function extractFlags(int $flags): ConstStub - { - $flagsArray = []; - - foreach (self::FLAGS as $value => $name) { - if ($flags & $value) { - $flagsArray[] = $name; - } - } - - if (!$flagsArray) { - $flagsArray = ['AMQP_NOPARAM']; - } - - return new ConstStub(implode('|', $flagsArray), $flags); - } -} diff --git a/vendor/symfony/var-dumper/Caster/ArgsStub.php b/vendor/symfony/var-dumper/Caster/ArgsStub.php deleted file mode 100644 index b3f7bbe..0000000 --- a/vendor/symfony/var-dumper/Caster/ArgsStub.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents a list of function arguments. - * - * @author Nicolas Grekas - */ -class ArgsStub extends EnumStub -{ - private static $parameters = []; - - public function __construct(array $args, string $function, ?string $class) - { - [$variadic, $params] = self::getParameters($function, $class); - - $values = []; - foreach ($args as $k => $v) { - $values[$k] = !\is_scalar($v) && !$v instanceof Stub ? new CutStub($v) : $v; - } - if (null === $params) { - parent::__construct($values, false); - - return; - } - if (\count($values) < \count($params)) { - $params = \array_slice($params, 0, \count($values)); - } elseif (\count($values) > \count($params)) { - $values[] = new EnumStub(array_splice($values, \count($params)), false); - $params[] = $variadic; - } - if (['...'] === $params) { - $this->dumpKeys = false; - $this->value = $values[0]->value; - } else { - $this->value = array_combine($params, $values); - } - } - - private static function getParameters(string $function, ?string $class): array - { - if (isset(self::$parameters[$k = $class.'::'.$function])) { - return self::$parameters[$k]; - } - - try { - $r = null !== $class ? new \ReflectionMethod($class, $function) : new \ReflectionFunction($function); - } catch (\ReflectionException $e) { - return [null, null]; - } - - $variadic = '...'; - $params = []; - foreach ($r->getParameters() as $v) { - $k = '$'.$v->name; - if ($v->isPassedByReference()) { - $k = '&'.$k; - } - if ($v->isVariadic()) { - $variadic .= $k; - } else { - $params[] = $k; - } - } - - return self::$parameters[$k] = [$variadic, $params]; - } -} diff --git a/vendor/symfony/var-dumper/Caster/Caster.php b/vendor/symfony/var-dumper/Caster/Caster.php deleted file mode 100644 index d35f323..0000000 --- a/vendor/symfony/var-dumper/Caster/Caster.php +++ /dev/null @@ -1,175 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Helper for filtering out properties in casters. - * - * @author Nicolas Grekas - * - * @final - */ -class Caster -{ - public const EXCLUDE_VERBOSE = 1; - public const EXCLUDE_VIRTUAL = 2; - public const EXCLUDE_DYNAMIC = 4; - public const EXCLUDE_PUBLIC = 8; - public const EXCLUDE_PROTECTED = 16; - public const EXCLUDE_PRIVATE = 32; - public const EXCLUDE_NULL = 64; - public const EXCLUDE_EMPTY = 128; - public const EXCLUDE_NOT_IMPORTANT = 256; - public const EXCLUDE_STRICT = 512; - - public const PREFIX_VIRTUAL = "\0~\0"; - public const PREFIX_DYNAMIC = "\0+\0"; - public const PREFIX_PROTECTED = "\0*\0"; - - /** - * Casts objects to arrays and adds the dynamic property prefix. - * - * @param object $obj The object to cast - * @param bool $hasDebugInfo Whether the __debugInfo method exists on $obj or not - * - * @return array The array-cast of the object, with prefixed dynamic properties - */ - public static function castObject($obj, string $class, bool $hasDebugInfo = false, string $debugClass = null): array - { - if ($hasDebugInfo) { - try { - $debugInfo = $obj->__debugInfo(); - } catch (\Exception $e) { - // ignore failing __debugInfo() - $hasDebugInfo = false; - } - } - - $a = $obj instanceof \Closure ? [] : (array) $obj; - - if ($obj instanceof \__PHP_Incomplete_Class) { - return $a; - } - - if ($a) { - static $publicProperties = []; - $debugClass = $debugClass ?? get_debug_type($obj); - - $i = 0; - $prefixedKeys = []; - foreach ($a as $k => $v) { - if (isset($k[0]) ? "\0" !== $k[0] : \PHP_VERSION_ID >= 70200) { - if (!isset($publicProperties[$class])) { - foreach ((new \ReflectionClass($class))->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) { - $publicProperties[$class][$prop->name] = true; - } - } - if (!isset($publicProperties[$class][$k])) { - $prefixedKeys[$i] = self::PREFIX_DYNAMIC.$k; - } - } elseif ($debugClass !== $class && 1 === strpos($k, $class)) { - $prefixedKeys[$i] = "\0".$debugClass.strrchr($k, "\0"); - } - ++$i; - } - if ($prefixedKeys) { - $keys = array_keys($a); - foreach ($prefixedKeys as $i => $k) { - $keys[$i] = $k; - } - $a = array_combine($keys, $a); - } - } - - if ($hasDebugInfo && \is_array($debugInfo)) { - foreach ($debugInfo as $k => $v) { - if (!isset($k[0]) || "\0" !== $k[0]) { - if (\array_key_exists(self::PREFIX_DYNAMIC.$k, $a)) { - continue; - } - $k = self::PREFIX_VIRTUAL.$k; - } - - unset($a[$k]); - $a[$k] = $v; - } - } - - return $a; - } - - /** - * Filters out the specified properties. - * - * By default, a single match in the $filter bit field filters properties out, following an "or" logic. - * When EXCLUDE_STRICT is set, an "and" logic is applied: all bits must match for a property to be removed. - * - * @param array $a The array containing the properties to filter - * @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out - * @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set - * @param int &$count Set to the number of removed properties - * - * @return array The filtered array - */ - public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array - { - $count = 0; - - foreach ($a as $k => $v) { - $type = self::EXCLUDE_STRICT & $filter; - - if (null === $v) { - $type |= self::EXCLUDE_NULL & $filter; - $type |= self::EXCLUDE_EMPTY & $filter; - } elseif (false === $v || '' === $v || '0' === $v || 0 === $v || 0.0 === $v || [] === $v) { - $type |= self::EXCLUDE_EMPTY & $filter; - } - if ((self::EXCLUDE_NOT_IMPORTANT & $filter) && !\in_array($k, $listedProperties, true)) { - $type |= self::EXCLUDE_NOT_IMPORTANT; - } - if ((self::EXCLUDE_VERBOSE & $filter) && \in_array($k, $listedProperties, true)) { - $type |= self::EXCLUDE_VERBOSE; - } - - if (!isset($k[1]) || "\0" !== $k[0]) { - $type |= self::EXCLUDE_PUBLIC & $filter; - } elseif ('~' === $k[1]) { - $type |= self::EXCLUDE_VIRTUAL & $filter; - } elseif ('+' === $k[1]) { - $type |= self::EXCLUDE_DYNAMIC & $filter; - } elseif ('*' === $k[1]) { - $type |= self::EXCLUDE_PROTECTED & $filter; - } else { - $type |= self::EXCLUDE_PRIVATE & $filter; - } - - if ((self::EXCLUDE_STRICT & $filter) ? $type === $filter : $type) { - unset($a[$k]); - ++$count; - } - } - - return $a; - } - - public static function castPhpIncompleteClass(\__PHP_Incomplete_Class $c, array $a, Stub $stub, bool $isNested): array - { - if (isset($a['__PHP_Incomplete_Class_Name'])) { - $stub->class .= '('.$a['__PHP_Incomplete_Class_Name'].')'; - unset($a['__PHP_Incomplete_Class_Name']); - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ClassStub.php b/vendor/symfony/var-dumper/Caster/ClassStub.php deleted file mode 100644 index 48f8483..0000000 --- a/vendor/symfony/var-dumper/Caster/ClassStub.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents a PHP class identifier. - * - * @author Nicolas Grekas - */ -class ClassStub extends ConstStub -{ - /** - * @param string $identifier A PHP identifier, e.g. a class, method, interface, etc. name - * @param callable $callable The callable targeted by the identifier when it is ambiguous or not a real PHP identifier - */ - public function __construct(string $identifier, $callable = null) - { - $this->value = $identifier; - - try { - if (null !== $callable) { - if ($callable instanceof \Closure) { - $r = new \ReflectionFunction($callable); - } elseif (\is_object($callable)) { - $r = [$callable, '__invoke']; - } elseif (\is_array($callable)) { - $r = $callable; - } elseif (false !== $i = strpos($callable, '::')) { - $r = [substr($callable, 0, $i), substr($callable, 2 + $i)]; - } else { - $r = new \ReflectionFunction($callable); - } - } elseif (0 < $i = strpos($identifier, '::') ?: strpos($identifier, '->')) { - $r = [substr($identifier, 0, $i), substr($identifier, 2 + $i)]; - } else { - $r = new \ReflectionClass($identifier); - } - - if (\is_array($r)) { - try { - $r = new \ReflectionMethod($r[0], $r[1]); - } catch (\ReflectionException $e) { - $r = new \ReflectionClass($r[0]); - } - } - - if (str_contains($identifier, "@anonymous\0")) { - $this->value = $identifier = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; - }, $identifier); - } - - if (null !== $callable && $r instanceof \ReflectionFunctionAbstract) { - $s = ReflectionCaster::castFunctionAbstract($r, [], new Stub(), true, Caster::EXCLUDE_VERBOSE); - $s = ReflectionCaster::getSignature($s); - - if (str_ends_with($identifier, '()')) { - $this->value = substr_replace($identifier, $s, -2); - } else { - $this->value .= $s; - } - } - } catch (\ReflectionException $e) { - return; - } finally { - if (0 < $i = strrpos($this->value, '\\')) { - $this->attr['ellipsis'] = \strlen($this->value) - $i; - $this->attr['ellipsis-type'] = 'class'; - $this->attr['ellipsis-tail'] = 1; - } - } - - if ($f = $r->getFileName()) { - $this->attr['file'] = $f; - $this->attr['line'] = $r->getStartLine(); - } - } - - public static function wrapCallable($callable) - { - if (\is_object($callable) || !\is_callable($callable)) { - return $callable; - } - - if (!\is_array($callable)) { - $callable = new static($callable, $callable); - } elseif (\is_string($callable[0])) { - $callable[0] = new static($callable[0], $callable); - } else { - $callable[1] = new static($callable[1], $callable); - } - - return $callable; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ConstStub.php b/vendor/symfony/var-dumper/Caster/ConstStub.php deleted file mode 100644 index 8b01797..0000000 --- a/vendor/symfony/var-dumper/Caster/ConstStub.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents a PHP constant and its value. - * - * @author Nicolas Grekas - */ -class ConstStub extends Stub -{ - public function __construct(string $name, $value = null) - { - $this->class = $name; - $this->value = 1 < \func_num_args() ? $value : $name; - } - - /** - * @return string - */ - public function __toString() - { - return (string) $this->value; - } -} diff --git a/vendor/symfony/var-dumper/Caster/CutArrayStub.php b/vendor/symfony/var-dumper/Caster/CutArrayStub.php deleted file mode 100644 index 0e4fb36..0000000 --- a/vendor/symfony/var-dumper/Caster/CutArrayStub.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -/** - * Represents a cut array. - * - * @author Nicolas Grekas - */ -class CutArrayStub extends CutStub -{ - public $preservedSubset; - - public function __construct(array $value, array $preservedKeys) - { - parent::__construct($value); - - $this->preservedSubset = array_intersect_key($value, array_flip($preservedKeys)); - $this->cut -= \count($this->preservedSubset); - } -} diff --git a/vendor/symfony/var-dumper/Caster/CutStub.php b/vendor/symfony/var-dumper/Caster/CutStub.php deleted file mode 100644 index 464c6db..0000000 --- a/vendor/symfony/var-dumper/Caster/CutStub.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents the main properties of a PHP variable, pre-casted by a caster. - * - * @author Nicolas Grekas - */ -class CutStub extends Stub -{ - public function __construct($value) - { - $this->value = $value; - - switch (\gettype($value)) { - case 'object': - $this->type = self::TYPE_OBJECT; - $this->class = \get_class($value); - - if ($value instanceof \Closure) { - ReflectionCaster::castClosure($value, [], $this, true, Caster::EXCLUDE_VERBOSE); - } - - $this->cut = -1; - break; - - case 'array': - $this->type = self::TYPE_ARRAY; - $this->class = self::ARRAY_ASSOC; - $this->cut = $this->value = \count($value); - break; - - case 'resource': - case 'unknown type': - case 'resource (closed)': - $this->type = self::TYPE_RESOURCE; - $this->handle = (int) $value; - if ('Unknown' === $this->class = @get_resource_type($value)) { - $this->class = 'Closed'; - } - $this->cut = -1; - break; - - case 'string': - $this->type = self::TYPE_STRING; - $this->class = preg_match('//u', $value) ? self::STRING_UTF8 : self::STRING_BINARY; - $this->cut = self::STRING_BINARY === $this->class ? \strlen($value) : mb_strlen($value, 'UTF-8'); - $this->value = ''; - break; - } - } -} diff --git a/vendor/symfony/var-dumper/Caster/DOMCaster.php b/vendor/symfony/var-dumper/Caster/DOMCaster.php deleted file mode 100644 index 5f2b9cd..0000000 --- a/vendor/symfony/var-dumper/Caster/DOMCaster.php +++ /dev/null @@ -1,304 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts DOM related classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class DOMCaster -{ - private const ERROR_CODES = [ - \DOM_PHP_ERR => 'DOM_PHP_ERR', - \DOM_INDEX_SIZE_ERR => 'DOM_INDEX_SIZE_ERR', - \DOMSTRING_SIZE_ERR => 'DOMSTRING_SIZE_ERR', - \DOM_HIERARCHY_REQUEST_ERR => 'DOM_HIERARCHY_REQUEST_ERR', - \DOM_WRONG_DOCUMENT_ERR => 'DOM_WRONG_DOCUMENT_ERR', - \DOM_INVALID_CHARACTER_ERR => 'DOM_INVALID_CHARACTER_ERR', - \DOM_NO_DATA_ALLOWED_ERR => 'DOM_NO_DATA_ALLOWED_ERR', - \DOM_NO_MODIFICATION_ALLOWED_ERR => 'DOM_NO_MODIFICATION_ALLOWED_ERR', - \DOM_NOT_FOUND_ERR => 'DOM_NOT_FOUND_ERR', - \DOM_NOT_SUPPORTED_ERR => 'DOM_NOT_SUPPORTED_ERR', - \DOM_INUSE_ATTRIBUTE_ERR => 'DOM_INUSE_ATTRIBUTE_ERR', - \DOM_INVALID_STATE_ERR => 'DOM_INVALID_STATE_ERR', - \DOM_SYNTAX_ERR => 'DOM_SYNTAX_ERR', - \DOM_INVALID_MODIFICATION_ERR => 'DOM_INVALID_MODIFICATION_ERR', - \DOM_NAMESPACE_ERR => 'DOM_NAMESPACE_ERR', - \DOM_INVALID_ACCESS_ERR => 'DOM_INVALID_ACCESS_ERR', - \DOM_VALIDATION_ERR => 'DOM_VALIDATION_ERR', - ]; - - private const NODE_TYPES = [ - \XML_ELEMENT_NODE => 'XML_ELEMENT_NODE', - \XML_ATTRIBUTE_NODE => 'XML_ATTRIBUTE_NODE', - \XML_TEXT_NODE => 'XML_TEXT_NODE', - \XML_CDATA_SECTION_NODE => 'XML_CDATA_SECTION_NODE', - \XML_ENTITY_REF_NODE => 'XML_ENTITY_REF_NODE', - \XML_ENTITY_NODE => 'XML_ENTITY_NODE', - \XML_PI_NODE => 'XML_PI_NODE', - \XML_COMMENT_NODE => 'XML_COMMENT_NODE', - \XML_DOCUMENT_NODE => 'XML_DOCUMENT_NODE', - \XML_DOCUMENT_TYPE_NODE => 'XML_DOCUMENT_TYPE_NODE', - \XML_DOCUMENT_FRAG_NODE => 'XML_DOCUMENT_FRAG_NODE', - \XML_NOTATION_NODE => 'XML_NOTATION_NODE', - \XML_HTML_DOCUMENT_NODE => 'XML_HTML_DOCUMENT_NODE', - \XML_DTD_NODE => 'XML_DTD_NODE', - \XML_ELEMENT_DECL_NODE => 'XML_ELEMENT_DECL_NODE', - \XML_ATTRIBUTE_DECL_NODE => 'XML_ATTRIBUTE_DECL_NODE', - \XML_ENTITY_DECL_NODE => 'XML_ENTITY_DECL_NODE', - \XML_NAMESPACE_DECL_NODE => 'XML_NAMESPACE_DECL_NODE', - ]; - - public static function castException(\DOMException $e, array $a, Stub $stub, $isNested) - { - $k = Caster::PREFIX_PROTECTED.'code'; - if (isset($a[$k], self::ERROR_CODES[$a[$k]])) { - $a[$k] = new ConstStub(self::ERROR_CODES[$a[$k]], $a[$k]); - } - - return $a; - } - - public static function castLength($dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'length' => $dom->length, - ]; - - return $a; - } - - public static function castImplementation($dom, array $a, Stub $stub, $isNested) - { - $a += [ - Caster::PREFIX_VIRTUAL.'Core' => '1.0', - Caster::PREFIX_VIRTUAL.'XML' => '2.0', - ]; - - return $a; - } - - public static function castNode(\DOMNode $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'nodeName' => $dom->nodeName, - 'nodeValue' => new CutStub($dom->nodeValue), - 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType), - 'parentNode' => new CutStub($dom->parentNode), - 'childNodes' => $dom->childNodes, - 'firstChild' => new CutStub($dom->firstChild), - 'lastChild' => new CutStub($dom->lastChild), - 'previousSibling' => new CutStub($dom->previousSibling), - 'nextSibling' => new CutStub($dom->nextSibling), - 'attributes' => $dom->attributes, - 'ownerDocument' => new CutStub($dom->ownerDocument), - 'namespaceURI' => $dom->namespaceURI, - 'prefix' => $dom->prefix, - 'localName' => $dom->localName, - 'baseURI' => $dom->baseURI ? new LinkStub($dom->baseURI) : $dom->baseURI, - 'textContent' => new CutStub($dom->textContent), - ]; - - return $a; - } - - public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'nodeName' => $dom->nodeName, - 'nodeValue' => new CutStub($dom->nodeValue), - 'nodeType' => new ConstStub(self::NODE_TYPES[$dom->nodeType], $dom->nodeType), - 'prefix' => $dom->prefix, - 'localName' => $dom->localName, - 'namespaceURI' => $dom->namespaceURI, - 'ownerDocument' => new CutStub($dom->ownerDocument), - 'parentNode' => new CutStub($dom->parentNode), - ]; - - return $a; - } - - public static function castDocument(\DOMDocument $dom, array $a, Stub $stub, $isNested, $filter = 0) - { - $a += [ - 'doctype' => $dom->doctype, - 'implementation' => $dom->implementation, - 'documentElement' => new CutStub($dom->documentElement), - 'actualEncoding' => $dom->actualEncoding, - 'encoding' => $dom->encoding, - 'xmlEncoding' => $dom->xmlEncoding, - 'standalone' => $dom->standalone, - 'xmlStandalone' => $dom->xmlStandalone, - 'version' => $dom->version, - 'xmlVersion' => $dom->xmlVersion, - 'strictErrorChecking' => $dom->strictErrorChecking, - 'documentURI' => $dom->documentURI ? new LinkStub($dom->documentURI) : $dom->documentURI, - 'config' => $dom->config, - 'formatOutput' => $dom->formatOutput, - 'validateOnParse' => $dom->validateOnParse, - 'resolveExternals' => $dom->resolveExternals, - 'preserveWhiteSpace' => $dom->preserveWhiteSpace, - 'recover' => $dom->recover, - 'substituteEntities' => $dom->substituteEntities, - ]; - - if (!($filter & Caster::EXCLUDE_VERBOSE)) { - $formatOutput = $dom->formatOutput; - $dom->formatOutput = true; - $a += [Caster::PREFIX_VIRTUAL.'xml' => $dom->saveXML()]; - $dom->formatOutput = $formatOutput; - } - - return $a; - } - - public static function castCharacterData(\DOMCharacterData $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'data' => $dom->data, - 'length' => $dom->length, - ]; - - return $a; - } - - public static function castAttr(\DOMAttr $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'name' => $dom->name, - 'specified' => $dom->specified, - 'value' => $dom->value, - 'ownerElement' => $dom->ownerElement, - 'schemaTypeInfo' => $dom->schemaTypeInfo, - ]; - - return $a; - } - - public static function castElement(\DOMElement $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'tagName' => $dom->tagName, - 'schemaTypeInfo' => $dom->schemaTypeInfo, - ]; - - return $a; - } - - public static function castText(\DOMText $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'wholeText' => $dom->wholeText, - ]; - - return $a; - } - - public static function castTypeinfo(\DOMTypeinfo $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'typeName' => $dom->typeName, - 'typeNamespace' => $dom->typeNamespace, - ]; - - return $a; - } - - public static function castDomError(\DOMDomError $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'severity' => $dom->severity, - 'message' => $dom->message, - 'type' => $dom->type, - 'relatedException' => $dom->relatedException, - 'related_data' => $dom->related_data, - 'location' => $dom->location, - ]; - - return $a; - } - - public static function castLocator(\DOMLocator $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'lineNumber' => $dom->lineNumber, - 'columnNumber' => $dom->columnNumber, - 'offset' => $dom->offset, - 'relatedNode' => $dom->relatedNode, - 'uri' => $dom->uri ? new LinkStub($dom->uri, $dom->lineNumber) : $dom->uri, - ]; - - return $a; - } - - public static function castDocumentType(\DOMDocumentType $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'name' => $dom->name, - 'entities' => $dom->entities, - 'notations' => $dom->notations, - 'publicId' => $dom->publicId, - 'systemId' => $dom->systemId, - 'internalSubset' => $dom->internalSubset, - ]; - - return $a; - } - - public static function castNotation(\DOMNotation $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'publicId' => $dom->publicId, - 'systemId' => $dom->systemId, - ]; - - return $a; - } - - public static function castEntity(\DOMEntity $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'publicId' => $dom->publicId, - 'systemId' => $dom->systemId, - 'notationName' => $dom->notationName, - 'actualEncoding' => $dom->actualEncoding, - 'encoding' => $dom->encoding, - 'version' => $dom->version, - ]; - - return $a; - } - - public static function castProcessingInstruction(\DOMProcessingInstruction $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'target' => $dom->target, - 'data' => $dom->data, - ]; - - return $a; - } - - public static function castXPath(\DOMXPath $dom, array $a, Stub $stub, $isNested) - { - $a += [ - 'document' => $dom->document, - ]; - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/DateCaster.php b/vendor/symfony/var-dumper/Caster/DateCaster.php deleted file mode 100644 index e0309bc..0000000 --- a/vendor/symfony/var-dumper/Caster/DateCaster.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts DateTimeInterface related classes to array representation. - * - * @author Dany Maillard - * - * @final since Symfony 4.4 - */ -class DateCaster -{ - private const PERIOD_LIMIT = 3; - - public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, $isNested, $filter) - { - $prefix = Caster::PREFIX_VIRTUAL; - $location = $d->getTimezone()->getLocation(); - $fromNow = (new \DateTime())->diff($d); - - $title = $d->format('l, F j, Y') - ."\n".self::formatInterval($fromNow).' from now' - .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '') - ; - - unset( - $a[Caster::PREFIX_DYNAMIC.'date'], - $a[Caster::PREFIX_DYNAMIC.'timezone'], - $a[Caster::PREFIX_DYNAMIC.'timezone_type'] - ); - $a[$prefix.'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title); - - $stub->class .= $d->format(' @U'); - - return $a; - } - - public static function castInterval(\DateInterval $interval, array $a, Stub $stub, $isNested, $filter) - { - $now = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); - $numberOfSeconds = $now->add($interval)->getTimestamp() - $now->getTimestamp(); - $title = number_format($numberOfSeconds, 0, '.', ' ').'s'; - - $i = [Caster::PREFIX_VIRTUAL.'interval' => new ConstStub(self::formatInterval($interval), $title)]; - - return $filter & Caster::EXCLUDE_VERBOSE ? $i : $i + $a; - } - - private static function formatInterval(\DateInterval $i): string - { - $format = '%R '; - - if (0 === $i->y && 0 === $i->m && ($i->h >= 24 || $i->i >= 60 || $i->s >= 60)) { - $d = new \DateTimeImmutable('@0', new \DateTimeZone('UTC')); - $i = $d->diff($d->add($i)); // recalculate carry over points - $format .= 0 < $i->days ? '%ad ' : ''; - } else { - $format .= ($i->y ? '%yy ' : '').($i->m ? '%mm ' : '').($i->d ? '%dd ' : ''); - } - - $format .= $i->h || $i->i || $i->s || $i->f ? '%H:%I:'.self::formatSeconds($i->s, substr($i->f, 2)) : ''; - $format = '%R ' === $format ? '0s' : $format; - - return $i->format(rtrim($format)); - } - - public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stub, $isNested, $filter) - { - $location = $timeZone->getLocation(); - $formatted = (new \DateTime('now', $timeZone))->format($location ? 'e (P)' : 'P'); - $title = $location && \extension_loaded('intl') ? \Locale::getDisplayRegion('-'.$location['country_code']) : ''; - - $z = [Caster::PREFIX_VIRTUAL.'timezone' => new ConstStub($formatted, $title)]; - - return $filter & Caster::EXCLUDE_VERBOSE ? $z : $z + $a; - } - - public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter) - { - $dates = []; - if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/74639 - foreach (clone $p as $i => $d) { - if (self::PERIOD_LIMIT === $i) { - $now = new \DateTimeImmutable('now', new \DateTimeZone('UTC')); - $dates[] = sprintf('%s more', ($end = $p->getEndDate()) - ? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u'))) - : $p->recurrences - $i - ); - break; - } - $dates[] = sprintf('%s) %s', $i + 1, self::formatDateTime($d)); - } - } - - $period = sprintf( - 'every %s, from %s%s %s', - self::formatInterval($p->getDateInterval()), - $p->include_start_date ? '[' : ']', - self::formatDateTime($p->getStartDate()), - ($end = $p->getEndDate()) ? 'to '.self::formatDateTime($end).(\PHP_VERSION_ID >= 80200 && $p->include_end_date ? ']' : '[') : 'recurring '.$p->recurrences.' time/s' - ); - - $p = [Caster::PREFIX_VIRTUAL.'period' => new ConstStub($period, implode("\n", $dates))]; - - return $filter & Caster::EXCLUDE_VERBOSE ? $p : $p + $a; - } - - private static function formatDateTime(\DateTimeInterface $d, string $extra = ''): string - { - return $d->format('Y-m-d H:i:'.self::formatSeconds($d->format('s'), $d->format('u')).$extra); - } - - private static function formatSeconds(string $s, string $us): string - { - return sprintf('%02d.%s', $s, 0 === ($len = \strlen($t = rtrim($us, '0'))) ? '0' : ($len <= 3 ? str_pad($t, 3, '0') : $us)); - } -} diff --git a/vendor/symfony/var-dumper/Caster/DoctrineCaster.php b/vendor/symfony/var-dumper/Caster/DoctrineCaster.php deleted file mode 100644 index 7409508..0000000 --- a/vendor/symfony/var-dumper/Caster/DoctrineCaster.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Doctrine\Common\Proxy\Proxy as CommonProxy; -use Doctrine\ORM\PersistentCollection; -use Doctrine\ORM\Proxy\Proxy as OrmProxy; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts Doctrine related classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class DoctrineCaster -{ - public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, $isNested) - { - foreach (['__cloner__', '__initializer__'] as $k) { - if (\array_key_exists($k, $a)) { - unset($a[$k]); - ++$stub->cut; - } - } - - return $a; - } - - public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNested) - { - foreach (['_entityPersister', '_identifier'] as $k) { - if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) { - unset($a[$k]); - ++$stub->cut; - } - } - - return $a; - } - - public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, $isNested) - { - foreach (['snapshot', 'association', 'typeClass'] as $k) { - if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) { - $a[$k] = new CutStub($a[$k]); - } - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/DsCaster.php b/vendor/symfony/var-dumper/Caster/DsCaster.php deleted file mode 100644 index 11423c9..0000000 --- a/vendor/symfony/var-dumper/Caster/DsCaster.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Ds\Collection; -use Ds\Map; -use Ds\Pair; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts Ds extension classes to array representation. - * - * @author Jáchym Toušek - * - * @final since Symfony 4.4 - */ -class DsCaster -{ - public static function castCollection(Collection $c, array $a, Stub $stub, bool $isNested): array - { - $a[Caster::PREFIX_VIRTUAL.'count'] = $c->count(); - $a[Caster::PREFIX_VIRTUAL.'capacity'] = $c->capacity(); - - if (!$c instanceof Map) { - $a += $c->toArray(); - } - - return $a; - } - - public static function castMap(Map $c, array $a, Stub $stub, bool $isNested): array - { - foreach ($c as $k => $v) { - $a[] = new DsPairStub($k, $v); - } - - return $a; - } - - public static function castPair(Pair $c, array $a, Stub $stub, bool $isNested): array - { - foreach ($c->toArray() as $k => $v) { - $a[Caster::PREFIX_VIRTUAL.$k] = $v; - } - - return $a; - } - - public static function castPairStub(DsPairStub $c, array $a, Stub $stub, bool $isNested): array - { - if ($isNested) { - $stub->class = Pair::class; - $stub->value = null; - $stub->handle = 0; - - $a = $c->value; - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/DsPairStub.php b/vendor/symfony/var-dumper/Caster/DsPairStub.php deleted file mode 100644 index a1dcc15..0000000 --- a/vendor/symfony/var-dumper/Caster/DsPairStub.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Nicolas Grekas - */ -class DsPairStub extends Stub -{ - public function __construct($key, $value) - { - $this->value = [ - Caster::PREFIX_VIRTUAL.'key' => $key, - Caster::PREFIX_VIRTUAL.'value' => $value, - ]; - } -} diff --git a/vendor/symfony/var-dumper/Caster/EnumStub.php b/vendor/symfony/var-dumper/Caster/EnumStub.php deleted file mode 100644 index 7a4e98a..0000000 --- a/vendor/symfony/var-dumper/Caster/EnumStub.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents an enumeration of values. - * - * @author Nicolas Grekas - */ -class EnumStub extends Stub -{ - public $dumpKeys = true; - - public function __construct(array $values, bool $dumpKeys = true) - { - $this->value = $values; - $this->dumpKeys = $dumpKeys; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ExceptionCaster.php b/vendor/symfony/var-dumper/Caster/ExceptionCaster.php deleted file mode 100644 index f2c0f96..0000000 --- a/vendor/symfony/var-dumper/Caster/ExceptionCaster.php +++ /dev/null @@ -1,388 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext; -use Symfony\Component\VarDumper\Cloner\Stub; -use Symfony\Component\VarDumper\Exception\ThrowingCasterException; - -/** - * Casts common Exception classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class ExceptionCaster -{ - public static $srcContext = 1; - public static $traceArgs = true; - public static $errorTypes = [ - \E_DEPRECATED => 'E_DEPRECATED', - \E_USER_DEPRECATED => 'E_USER_DEPRECATED', - \E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', - \E_ERROR => 'E_ERROR', - \E_WARNING => 'E_WARNING', - \E_PARSE => 'E_PARSE', - \E_NOTICE => 'E_NOTICE', - \E_CORE_ERROR => 'E_CORE_ERROR', - \E_CORE_WARNING => 'E_CORE_WARNING', - \E_COMPILE_ERROR => 'E_COMPILE_ERROR', - \E_COMPILE_WARNING => 'E_COMPILE_WARNING', - \E_USER_ERROR => 'E_USER_ERROR', - \E_USER_WARNING => 'E_USER_WARNING', - \E_USER_NOTICE => 'E_USER_NOTICE', - \E_STRICT => 'E_STRICT', - ]; - - private static $framesCache = []; - - public static function castError(\Error $e, array $a, Stub $stub, $isNested, $filter = 0) - { - return self::filterExceptionArray($stub->class, $a, "\0Error\0", $filter); - } - - public static function castException(\Exception $e, array $a, Stub $stub, $isNested, $filter = 0) - { - return self::filterExceptionArray($stub->class, $a, "\0Exception\0", $filter); - } - - public static function castErrorException(\ErrorException $e, array $a, Stub $stub, $isNested) - { - if (isset($a[$s = Caster::PREFIX_PROTECTED.'severity'], self::$errorTypes[$a[$s]])) { - $a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]); - } - - return $a; - } - - public static function castThrowingCasterException(ThrowingCasterException $e, array $a, Stub $stub, $isNested) - { - $trace = Caster::PREFIX_VIRTUAL.'trace'; - $prefix = Caster::PREFIX_PROTECTED; - $xPrefix = "\0Exception\0"; - - if (isset($a[$xPrefix.'previous'], $a[$trace]) && $a[$xPrefix.'previous'] instanceof \Exception) { - $b = (array) $a[$xPrefix.'previous']; - $class = get_debug_type($a[$xPrefix.'previous']); - self::traceUnshift($b[$xPrefix.'trace'], $class, $b[$prefix.'file'], $b[$prefix.'line']); - $a[$trace] = new TraceStub($b[$xPrefix.'trace'], false, 0, -\count($a[$trace]->value)); - } - - unset($a[$xPrefix.'previous'], $a[$prefix.'code'], $a[$prefix.'file'], $a[$prefix.'line']); - - return $a; - } - - public static function castSilencedErrorContext(SilencedErrorContext $e, array $a, Stub $stub, $isNested) - { - $sPrefix = "\0".SilencedErrorContext::class."\0"; - - if (!isset($a[$s = $sPrefix.'severity'])) { - return $a; - } - - if (isset(self::$errorTypes[$a[$s]])) { - $a[$s] = new ConstStub(self::$errorTypes[$a[$s]], $a[$s]); - } - - $trace = [[ - 'file' => $a[$sPrefix.'file'], - 'line' => $a[$sPrefix.'line'], - ]]; - - if (isset($a[$sPrefix.'trace'])) { - $trace = array_merge($trace, $a[$sPrefix.'trace']); - } - - unset($a[$sPrefix.'file'], $a[$sPrefix.'line'], $a[$sPrefix.'trace']); - $a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs); - - return $a; - } - - public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $isNested) - { - if (!$isNested) { - return $a; - } - $stub->class = ''; - $stub->handle = 0; - $frames = $trace->value; - $prefix = Caster::PREFIX_VIRTUAL; - - $a = []; - $j = \count($frames); - if (0 > $i = $trace->sliceOffset) { - $i = max(0, $j + $i); - } - if (!isset($trace->value[$i])) { - return []; - } - $lastCall = isset($frames[$i]['function']) ? (isset($frames[$i]['class']) ? $frames[0]['class'].$frames[$i]['type'] : '').$frames[$i]['function'].'()' : ''; - $frames[] = ['function' => '']; - $collapse = false; - - for ($j += $trace->numberingOffset - $i++; isset($frames[$i]); ++$i, --$j) { - $f = $frames[$i]; - $call = isset($f['function']) ? (isset($f['class']) ? $f['class'].$f['type'] : '').$f['function'] : '???'; - - $frame = new FrameStub( - [ - 'object' => $f['object'] ?? null, - 'class' => $f['class'] ?? null, - 'type' => $f['type'] ?? null, - 'function' => $f['function'] ?? null, - ] + $frames[$i - 1], - false, - true - ); - $f = self::castFrameStub($frame, [], $frame, true); - if (isset($f[$prefix.'src'])) { - foreach ($f[$prefix.'src']->value as $label => $frame) { - if (str_starts_with($label, "\0~collapse=0")) { - if ($collapse) { - $label = substr_replace($label, '1', 11, 1); - } else { - $collapse = true; - } - } - $label = substr_replace($label, "title=Stack level $j.&", 2, 0); - } - $f = $frames[$i - 1]; - if ($trace->keepArgs && !empty($f['args']) && $frame instanceof EnumStub) { - $frame->value['arguments'] = new ArgsStub($f['args'], $f['function'] ?? null, $f['class'] ?? null); - } - } elseif ('???' !== $lastCall) { - $label = new ClassStub($lastCall); - if (isset($label->attr['ellipsis'])) { - $label->attr['ellipsis'] += 2; - $label = substr_replace($prefix, "ellipsis-type=class&ellipsis={$label->attr['ellipsis']}&ellipsis-tail=1&title=Stack level $j.", 2, 0).$label->value.'()'; - } else { - $label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$label->value.'()'; - } - } else { - $label = substr_replace($prefix, "title=Stack level $j.", 2, 0).$lastCall; - } - $a[substr_replace($label, sprintf('separator=%s&', $frame instanceof EnumStub ? ' ' : ':'), 2, 0)] = $frame; - - $lastCall = $call; - } - if (null !== $trace->sliceLength) { - $a = \array_slice($a, 0, $trace->sliceLength, true); - } - - return $a; - } - - public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $isNested) - { - if (!$isNested) { - return $a; - } - $f = $frame->value; - $prefix = Caster::PREFIX_VIRTUAL; - - if (isset($f['file'], $f['line'])) { - $cacheKey = $f; - unset($cacheKey['object'], $cacheKey['args']); - $cacheKey[] = self::$srcContext; - $cacheKey = implode('-', $cacheKey); - - if (isset(self::$framesCache[$cacheKey])) { - $a[$prefix.'src'] = self::$framesCache[$cacheKey]; - } else { - if (preg_match('/\((\d+)\)(?:\([\da-f]{32}\))? : (?:eval\(\)\'d code|runtime-created function)$/', $f['file'], $match)) { - $f['file'] = substr($f['file'], 0, -\strlen($match[0])); - $f['line'] = (int) $match[1]; - } - $src = $f['line']; - $srcKey = $f['file']; - $ellipsis = new LinkStub($srcKey, 0); - $srcAttr = 'collapse='.(int) $ellipsis->inVendor; - $ellipsisTail = $ellipsis->attr['ellipsis-tail'] ?? 0; - $ellipsis = $ellipsis->attr['ellipsis'] ?? 0; - - if (file_exists($f['file']) && 0 <= self::$srcContext) { - if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) { - $template = null; - if (isset($f['object'])) { - $template = $f['object']; - } elseif ((new \ReflectionClass($f['class']))->isInstantiable()) { - $template = unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class'])); - } - if (null !== $template) { - $ellipsis = 0; - $templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : ''); - $templateInfo = $template->getDebugInfo(); - if (isset($templateInfo[$f['line']])) { - if (!method_exists($template, 'getSourceContext') || !file_exists($templatePath = $template->getSourceContext()->getPath())) { - $templatePath = null; - } - if ($templateSrc) { - $src = self::extractSource($templateSrc, $templateInfo[$f['line']], self::$srcContext, 'twig', $templatePath, $f); - $srcKey = ($templatePath ?: $template->getTemplateName()).':'.$templateInfo[$f['line']]; - } - } - } - } - if ($srcKey == $f['file']) { - $src = self::extractSource(file_get_contents($f['file']), $f['line'], self::$srcContext, 'php', $f['file'], $f); - $srcKey .= ':'.$f['line']; - if ($ellipsis) { - $ellipsis += 1 + \strlen($f['line']); - } - } - $srcAttr .= sprintf('&separator= &file=%s&line=%d', rawurlencode($f['file']), $f['line']); - } else { - $srcAttr .= '&separator=:'; - } - $srcAttr .= $ellipsis ? '&ellipsis-type=path&ellipsis='.$ellipsis.'&ellipsis-tail='.$ellipsisTail : ''; - self::$framesCache[$cacheKey] = $a[$prefix.'src'] = new EnumStub(["\0~$srcAttr\0$srcKey" => $src]); - } - } - - unset($a[$prefix.'args'], $a[$prefix.'line'], $a[$prefix.'file']); - if ($frame->inTraceStub) { - unset($a[$prefix.'class'], $a[$prefix.'type'], $a[$prefix.'function']); - } - foreach ($a as $k => $v) { - if (!$v) { - unset($a[$k]); - } - } - if ($frame->keepArgs && !empty($f['args'])) { - $a[$prefix.'arguments'] = new ArgsStub($f['args'], $f['function'], $f['class']); - } - - return $a; - } - - private static function filterExceptionArray(string $xClass, array $a, string $xPrefix, int $filter): array - { - if (isset($a[$xPrefix.'trace'])) { - $trace = $a[$xPrefix.'trace']; - unset($a[$xPrefix.'trace']); // Ensures the trace is always last - } else { - $trace = []; - } - - if (!($filter & Caster::EXCLUDE_VERBOSE) && $trace) { - if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) { - self::traceUnshift($trace, $xClass, $a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']); - } - $a[Caster::PREFIX_VIRTUAL.'trace'] = new TraceStub($trace, self::$traceArgs); - } - if (empty($a[$xPrefix.'previous'])) { - unset($a[$xPrefix.'previous']); - } - unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']); - - if (isset($a[Caster::PREFIX_PROTECTED.'message']) && str_contains($a[Caster::PREFIX_PROTECTED.'message'], "@anonymous\0")) { - $a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { - return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; - }, $a[Caster::PREFIX_PROTECTED.'message']); - } - - if (isset($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line'])) { - $a[Caster::PREFIX_PROTECTED.'file'] = new LinkStub($a[Caster::PREFIX_PROTECTED.'file'], $a[Caster::PREFIX_PROTECTED.'line']); - } - - return $a; - } - - private static function traceUnshift(array &$trace, ?string $class, string $file, int $line): void - { - if (isset($trace[0]['file'], $trace[0]['line']) && $trace[0]['file'] === $file && $trace[0]['line'] === $line) { - return; - } - array_unshift($trace, [ - 'function' => $class ? 'new '.$class : null, - 'file' => $file, - 'line' => $line, - ]); - } - - private static function extractSource(string $srcLines, int $line, int $srcContext, string $lang, ?string $file, array $frame): EnumStub - { - $srcLines = explode("\n", $srcLines); - $src = []; - - for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) { - $src[] = ($srcLines[$i] ?? '')."\n"; - } - - if ($frame['function'] ?? false) { - $stub = new CutStub(new \stdClass()); - $stub->class = (isset($frame['class']) ? $frame['class'].$frame['type'] : '').$frame['function']; - $stub->type = Stub::TYPE_OBJECT; - $stub->attr['cut_hash'] = true; - $stub->attr['file'] = $frame['file']; - $stub->attr['line'] = $frame['line']; - - try { - $caller = isset($frame['class']) ? new \ReflectionMethod($frame['class'], $frame['function']) : new \ReflectionFunction($frame['function']); - $stub->class .= ReflectionCaster::getSignature(ReflectionCaster::castFunctionAbstract($caller, [], $stub, true, Caster::EXCLUDE_VERBOSE)); - - if ($f = $caller->getFileName()) { - $stub->attr['file'] = $f; - $stub->attr['line'] = $caller->getStartLine(); - } - } catch (\ReflectionException $e) { - // ignore fake class/function - } - - $srcLines = ["\0~separator=\0" => $stub]; - } else { - $stub = null; - $srcLines = []; - } - - $ltrim = 0; - do { - $pad = null; - for ($i = $srcContext << 1; $i >= 0; --$i) { - if (isset($src[$i][$ltrim]) && "\r" !== ($c = $src[$i][$ltrim]) && "\n" !== $c) { - if (null === $pad) { - $pad = $c; - } - if ((' ' !== $c && "\t" !== $c) || $pad !== $c) { - break; - } - } - } - ++$ltrim; - } while (0 > $i && null !== $pad); - - --$ltrim; - - foreach ($src as $i => $c) { - if ($ltrim) { - $c = isset($c[$ltrim]) && "\r" !== $c[$ltrim] ? substr($c, $ltrim) : ltrim($c, " \t"); - } - $c = substr($c, 0, -1); - if ($i !== $srcContext) { - $c = new ConstStub('default', $c); - } else { - $c = new ConstStub($c, $stub ? 'in '.$stub->class : ''); - if (null !== $file) { - $c->attr['file'] = $file; - $c->attr['line'] = $line; - } - } - $c->attr['lang'] = $lang; - $srcLines[sprintf("\0~separator=› &%d\0", $i + $line - $srcContext)] = $c; - } - - return new EnumStub($srcLines); - } -} diff --git a/vendor/symfony/var-dumper/Caster/FrameStub.php b/vendor/symfony/var-dumper/Caster/FrameStub.php deleted file mode 100644 index 8786755..0000000 --- a/vendor/symfony/var-dumper/Caster/FrameStub.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -/** - * Represents a single backtrace frame as returned by debug_backtrace() or Exception->getTrace(). - * - * @author Nicolas Grekas - */ -class FrameStub extends EnumStub -{ - public $keepArgs; - public $inTraceStub; - - public function __construct(array $frame, bool $keepArgs = true, bool $inTraceStub = false) - { - $this->value = $frame; - $this->keepArgs = $keepArgs; - $this->inTraceStub = $inTraceStub; - } -} diff --git a/vendor/symfony/var-dumper/Caster/GmpCaster.php b/vendor/symfony/var-dumper/Caster/GmpCaster.php deleted file mode 100644 index 2b20e15..0000000 --- a/vendor/symfony/var-dumper/Caster/GmpCaster.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts GMP objects to array representation. - * - * @author Hamza Amrouche - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class GmpCaster -{ - public static function castGmp(\GMP $gmp, array $a, Stub $stub, $isNested, $filter): array - { - $a[Caster::PREFIX_VIRTUAL.'value'] = new ConstStub(gmp_strval($gmp), gmp_strval($gmp)); - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ImagineCaster.php b/vendor/symfony/var-dumper/Caster/ImagineCaster.php deleted file mode 100644 index d1289da..0000000 --- a/vendor/symfony/var-dumper/Caster/ImagineCaster.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Imagine\Image\ImageInterface; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Grégoire Pineau - */ -final class ImagineCaster -{ - public static function castImage(ImageInterface $c, array $a, Stub $stub, bool $isNested): array - { - $imgData = $c->get('png'); - if (\strlen($imgData) > 1 * 1000 * 1000) { - $a += [ - Caster::PREFIX_VIRTUAL.'image' => new ConstStub($c->getSize()), - ]; - } else { - $a += [ - Caster::PREFIX_VIRTUAL.'image' => new ImgStub($imgData, 'image/png', $c->getSize()), - ]; - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ImgStub.php b/vendor/symfony/var-dumper/Caster/ImgStub.php deleted file mode 100644 index 05789fe..0000000 --- a/vendor/symfony/var-dumper/Caster/ImgStub.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -/** - * @author Grégoire Pineau - */ -class ImgStub extends ConstStub -{ - public function __construct(string $data, string $contentType, string $size) - { - $this->value = ''; - $this->attr['img-data'] = $data; - $this->attr['img-size'] = $size; - $this->attr['content-type'] = $contentType; - } -} diff --git a/vendor/symfony/var-dumper/Caster/IntlCaster.php b/vendor/symfony/var-dumper/Caster/IntlCaster.php deleted file mode 100644 index 581324d..0000000 --- a/vendor/symfony/var-dumper/Caster/IntlCaster.php +++ /dev/null @@ -1,172 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Nicolas Grekas - * @author Jan Schädlich - * - * @final since Symfony 4.4 - */ -class IntlCaster -{ - public static function castMessageFormatter(\MessageFormatter $c, array $a, Stub $stub, $isNested) - { - $a += [ - Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), - Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), - ]; - - return self::castError($c, $a); - } - - public static function castNumberFormatter(\NumberFormatter $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $a += [ - Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), - Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), - ]; - - if ($filter & Caster::EXCLUDE_VERBOSE) { - $stub->cut += 3; - - return self::castError($c, $a); - } - - $a += [ - Caster::PREFIX_VIRTUAL.'attributes' => new EnumStub( - [ - 'PARSE_INT_ONLY' => $c->getAttribute(\NumberFormatter::PARSE_INT_ONLY), - 'GROUPING_USED' => $c->getAttribute(\NumberFormatter::GROUPING_USED), - 'DECIMAL_ALWAYS_SHOWN' => $c->getAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN), - 'MAX_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_INTEGER_DIGITS), - 'MIN_INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_INTEGER_DIGITS), - 'INTEGER_DIGITS' => $c->getAttribute(\NumberFormatter::INTEGER_DIGITS), - 'MAX_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_FRACTION_DIGITS), - 'MIN_FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_FRACTION_DIGITS), - 'FRACTION_DIGITS' => $c->getAttribute(\NumberFormatter::FRACTION_DIGITS), - 'MULTIPLIER' => $c->getAttribute(\NumberFormatter::MULTIPLIER), - 'GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::GROUPING_SIZE), - 'ROUNDING_MODE' => $c->getAttribute(\NumberFormatter::ROUNDING_MODE), - 'ROUNDING_INCREMENT' => $c->getAttribute(\NumberFormatter::ROUNDING_INCREMENT), - 'FORMAT_WIDTH' => $c->getAttribute(\NumberFormatter::FORMAT_WIDTH), - 'PADDING_POSITION' => $c->getAttribute(\NumberFormatter::PADDING_POSITION), - 'SECONDARY_GROUPING_SIZE' => $c->getAttribute(\NumberFormatter::SECONDARY_GROUPING_SIZE), - 'SIGNIFICANT_DIGITS_USED' => $c->getAttribute(\NumberFormatter::SIGNIFICANT_DIGITS_USED), - 'MIN_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MIN_SIGNIFICANT_DIGITS), - 'MAX_SIGNIFICANT_DIGITS' => $c->getAttribute(\NumberFormatter::MAX_SIGNIFICANT_DIGITS), - 'LENIENT_PARSE' => $c->getAttribute(\NumberFormatter::LENIENT_PARSE), - ] - ), - Caster::PREFIX_VIRTUAL.'text_attributes' => new EnumStub( - [ - 'POSITIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_PREFIX), - 'POSITIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::POSITIVE_SUFFIX), - 'NEGATIVE_PREFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_PREFIX), - 'NEGATIVE_SUFFIX' => $c->getTextAttribute(\NumberFormatter::NEGATIVE_SUFFIX), - 'PADDING_CHARACTER' => $c->getTextAttribute(\NumberFormatter::PADDING_CHARACTER), - 'CURRENCY_CODE' => $c->getTextAttribute(\NumberFormatter::CURRENCY_CODE), - 'DEFAULT_RULESET' => $c->getTextAttribute(\NumberFormatter::DEFAULT_RULESET), - 'PUBLIC_RULESETS' => $c->getTextAttribute(\NumberFormatter::PUBLIC_RULESETS), - ] - ), - Caster::PREFIX_VIRTUAL.'symbols' => new EnumStub( - [ - 'DECIMAL_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL), - 'GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL), - 'PATTERN_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::PATTERN_SEPARATOR_SYMBOL), - 'PERCENT_SYMBOL' => $c->getSymbol(\NumberFormatter::PERCENT_SYMBOL), - 'ZERO_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::ZERO_DIGIT_SYMBOL), - 'DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::DIGIT_SYMBOL), - 'MINUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::MINUS_SIGN_SYMBOL), - 'PLUS_SIGN_SYMBOL' => $c->getSymbol(\NumberFormatter::PLUS_SIGN_SYMBOL), - 'CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::CURRENCY_SYMBOL), - 'INTL_CURRENCY_SYMBOL' => $c->getSymbol(\NumberFormatter::INTL_CURRENCY_SYMBOL), - 'MONETARY_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_SEPARATOR_SYMBOL), - 'EXPONENTIAL_SYMBOL' => $c->getSymbol(\NumberFormatter::EXPONENTIAL_SYMBOL), - 'PERMILL_SYMBOL' => $c->getSymbol(\NumberFormatter::PERMILL_SYMBOL), - 'PAD_ESCAPE_SYMBOL' => $c->getSymbol(\NumberFormatter::PAD_ESCAPE_SYMBOL), - 'INFINITY_SYMBOL' => $c->getSymbol(\NumberFormatter::INFINITY_SYMBOL), - 'NAN_SYMBOL' => $c->getSymbol(\NumberFormatter::NAN_SYMBOL), - 'SIGNIFICANT_DIGIT_SYMBOL' => $c->getSymbol(\NumberFormatter::SIGNIFICANT_DIGIT_SYMBOL), - 'MONETARY_GROUPING_SEPARATOR_SYMBOL' => $c->getSymbol(\NumberFormatter::MONETARY_GROUPING_SEPARATOR_SYMBOL), - ] - ), - ]; - - return self::castError($c, $a); - } - - public static function castIntlTimeZone(\IntlTimeZone $c, array $a, Stub $stub, $isNested) - { - $a += [ - Caster::PREFIX_VIRTUAL.'display_name' => $c->getDisplayName(), - Caster::PREFIX_VIRTUAL.'id' => $c->getID(), - Caster::PREFIX_VIRTUAL.'raw_offset' => $c->getRawOffset(), - ]; - - if ($c->useDaylightTime()) { - $a += [ - Caster::PREFIX_VIRTUAL.'dst_savings' => $c->getDSTSavings(), - ]; - } - - return self::castError($c, $a); - } - - public static function castIntlCalendar(\IntlCalendar $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $a += [ - Caster::PREFIX_VIRTUAL.'type' => $c->getType(), - Caster::PREFIX_VIRTUAL.'first_day_of_week' => $c->getFirstDayOfWeek(), - Caster::PREFIX_VIRTUAL.'minimal_days_in_first_week' => $c->getMinimalDaysInFirstWeek(), - Caster::PREFIX_VIRTUAL.'repeated_wall_time_option' => $c->getRepeatedWallTimeOption(), - Caster::PREFIX_VIRTUAL.'skipped_wall_time_option' => $c->getSkippedWallTimeOption(), - Caster::PREFIX_VIRTUAL.'time' => $c->getTime(), - Caster::PREFIX_VIRTUAL.'in_daylight_time' => $c->inDaylightTime(), - Caster::PREFIX_VIRTUAL.'is_lenient' => $c->isLenient(), - Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(), - ]; - - return self::castError($c, $a); - } - - public static function castIntlDateFormatter(\IntlDateFormatter $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $a += [ - Caster::PREFIX_VIRTUAL.'locale' => $c->getLocale(), - Caster::PREFIX_VIRTUAL.'pattern' => $c->getPattern(), - Caster::PREFIX_VIRTUAL.'calendar' => $c->getCalendar(), - Caster::PREFIX_VIRTUAL.'time_zone_id' => $c->getTimeZoneId(), - Caster::PREFIX_VIRTUAL.'time_type' => $c->getTimeType(), - Caster::PREFIX_VIRTUAL.'date_type' => $c->getDateType(), - Caster::PREFIX_VIRTUAL.'calendar_object' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getCalendarObject()) : $c->getCalendarObject(), - Caster::PREFIX_VIRTUAL.'time_zone' => ($filter & Caster::EXCLUDE_VERBOSE) ? new CutStub($c->getTimeZone()) : $c->getTimeZone(), - ]; - - return self::castError($c, $a); - } - - private static function castError($c, array $a): array - { - if ($errorCode = $c->getErrorCode()) { - $a += [ - Caster::PREFIX_VIRTUAL.'error_code' => $errorCode, - Caster::PREFIX_VIRTUAL.'error_message' => $c->getErrorMessage(), - ]; - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/LinkStub.php b/vendor/symfony/var-dumper/Caster/LinkStub.php deleted file mode 100644 index c619d9d..0000000 --- a/vendor/symfony/var-dumper/Caster/LinkStub.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -/** - * Represents a file or a URL. - * - * @author Nicolas Grekas - */ -class LinkStub extends ConstStub -{ - public $inVendor = false; - - private static $vendorRoots; - private static $composerRoots; - - public function __construct(string $label, int $line = 0, string $href = null) - { - $this->value = $label; - - if (null === $href) { - $href = $label; - } - if (!\is_string($href)) { - return; - } - if (str_starts_with($href, 'file://')) { - if ($href === $label) { - $label = substr($label, 7); - } - $href = substr($href, 7); - } elseif (str_contains($href, '://')) { - $this->attr['href'] = $href; - - return; - } - if (!file_exists($href)) { - return; - } - if ($line) { - $this->attr['line'] = $line; - } - if ($label !== $this->attr['file'] = realpath($href) ?: $href) { - return; - } - if ($composerRoot = $this->getComposerRoot($href, $this->inVendor)) { - $this->attr['ellipsis'] = \strlen($href) - \strlen($composerRoot) + 1; - $this->attr['ellipsis-type'] = 'path'; - $this->attr['ellipsis-tail'] = 1 + ($this->inVendor ? 2 + \strlen(implode('', \array_slice(explode(\DIRECTORY_SEPARATOR, substr($href, 1 - $this->attr['ellipsis'])), 0, 2))) : 0); - } elseif (3 < \count($ellipsis = explode(\DIRECTORY_SEPARATOR, $href))) { - $this->attr['ellipsis'] = 2 + \strlen(implode('', \array_slice($ellipsis, -2))); - $this->attr['ellipsis-type'] = 'path'; - $this->attr['ellipsis-tail'] = 1; - } - } - - private function getComposerRoot(string $file, bool &$inVendor) - { - if (null === self::$vendorRoots) { - self::$vendorRoots = []; - - foreach (get_declared_classes() as $class) { - if ('C' === $class[0] && str_starts_with($class, 'ComposerAutoloaderInit')) { - $r = new \ReflectionClass($class); - $v = \dirname($r->getFileName(), 2); - if (file_exists($v.'/composer/installed.json')) { - self::$vendorRoots[] = $v.\DIRECTORY_SEPARATOR; - } - } - } - } - $inVendor = false; - - if (isset(self::$composerRoots[$dir = \dirname($file)])) { - return self::$composerRoots[$dir]; - } - - foreach (self::$vendorRoots as $root) { - if ($inVendor = str_starts_with($file, $root)) { - return $root; - } - } - - $parent = $dir; - while (!@file_exists($parent.'/composer.json')) { - if (!@file_exists($parent)) { - // open_basedir restriction in effect - break; - } - if ($parent === \dirname($parent)) { - return self::$composerRoots[$dir] = false; - } - - $parent = \dirname($parent); - } - - return self::$composerRoots[$dir] = $parent.\DIRECTORY_SEPARATOR; - } -} diff --git a/vendor/symfony/var-dumper/Caster/MemcachedCaster.php b/vendor/symfony/var-dumper/Caster/MemcachedCaster.php deleted file mode 100644 index 696cef1..0000000 --- a/vendor/symfony/var-dumper/Caster/MemcachedCaster.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Jan Schädlich - * - * @final since Symfony 4.4 - */ -class MemcachedCaster -{ - private static $optionConstants; - private static $defaultOptions; - - public static function castMemcached(\Memcached $c, array $a, Stub $stub, $isNested) - { - $a += [ - Caster::PREFIX_VIRTUAL.'servers' => $c->getServerList(), - Caster::PREFIX_VIRTUAL.'options' => new EnumStub( - self::getNonDefaultOptions($c) - ), - ]; - - return $a; - } - - private static function getNonDefaultOptions(\Memcached $c): array - { - self::$defaultOptions = self::$defaultOptions ?? self::discoverDefaultOptions(); - self::$optionConstants = self::$optionConstants ?? self::getOptionConstants(); - - $nonDefaultOptions = []; - foreach (self::$optionConstants as $constantKey => $value) { - if (self::$defaultOptions[$constantKey] !== $option = $c->getOption($value)) { - $nonDefaultOptions[$constantKey] = $option; - } - } - - return $nonDefaultOptions; - } - - private static function discoverDefaultOptions(): array - { - $defaultMemcached = new \Memcached(); - $defaultMemcached->addServer('127.0.0.1', 11211); - - $defaultOptions = []; - self::$optionConstants = self::$optionConstants ?? self::getOptionConstants(); - - foreach (self::$optionConstants as $constantKey => $value) { - $defaultOptions[$constantKey] = $defaultMemcached->getOption($value); - } - - return $defaultOptions; - } - - private static function getOptionConstants(): array - { - $reflectedMemcached = new \ReflectionClass(\Memcached::class); - - $optionConstants = []; - foreach ($reflectedMemcached->getConstants() as $constantKey => $value) { - if (str_starts_with($constantKey, 'OPT_')) { - $optionConstants[$constantKey] = $value; - } - } - - return $optionConstants; - } -} diff --git a/vendor/symfony/var-dumper/Caster/MysqliCaster.php b/vendor/symfony/var-dumper/Caster/MysqliCaster.php deleted file mode 100644 index bfe6f08..0000000 --- a/vendor/symfony/var-dumper/Caster/MysqliCaster.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Nicolas Grekas - * - * @internal - */ -final class MysqliCaster -{ - public static function castMysqliDriver(\mysqli_driver $c, array $a, Stub $stub, bool $isNested): array - { - foreach ($a as $k => $v) { - if (isset($c->$k)) { - $a[$k] = $c->$k; - } - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/PdoCaster.php b/vendor/symfony/var-dumper/Caster/PdoCaster.php deleted file mode 100644 index 47b0a62..0000000 --- a/vendor/symfony/var-dumper/Caster/PdoCaster.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts PDO related classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class PdoCaster -{ - private const PDO_ATTRIBUTES = [ - 'CASE' => [ - \PDO::CASE_LOWER => 'LOWER', - \PDO::CASE_NATURAL => 'NATURAL', - \PDO::CASE_UPPER => 'UPPER', - ], - 'ERRMODE' => [ - \PDO::ERRMODE_SILENT => 'SILENT', - \PDO::ERRMODE_WARNING => 'WARNING', - \PDO::ERRMODE_EXCEPTION => 'EXCEPTION', - ], - 'TIMEOUT', - 'PREFETCH', - 'AUTOCOMMIT', - 'PERSISTENT', - 'DRIVER_NAME', - 'SERVER_INFO', - 'ORACLE_NULLS' => [ - \PDO::NULL_NATURAL => 'NATURAL', - \PDO::NULL_EMPTY_STRING => 'EMPTY_STRING', - \PDO::NULL_TO_STRING => 'TO_STRING', - ], - 'CLIENT_VERSION', - 'SERVER_VERSION', - 'STATEMENT_CLASS', - 'EMULATE_PREPARES', - 'CONNECTION_STATUS', - 'STRINGIFY_FETCHES', - 'DEFAULT_FETCH_MODE' => [ - \PDO::FETCH_ASSOC => 'ASSOC', - \PDO::FETCH_BOTH => 'BOTH', - \PDO::FETCH_LAZY => 'LAZY', - \PDO::FETCH_NUM => 'NUM', - \PDO::FETCH_OBJ => 'OBJ', - ], - ]; - - public static function castPdo(\PDO $c, array $a, Stub $stub, $isNested) - { - $attr = []; - $errmode = $c->getAttribute(\PDO::ATTR_ERRMODE); - $c->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - - foreach (self::PDO_ATTRIBUTES as $k => $v) { - if (!isset($k[0])) { - $k = $v; - $v = []; - } - - try { - $attr[$k] = 'ERRMODE' === $k ? $errmode : $c->getAttribute(\constant('PDO::ATTR_'.$k)); - if ($v && isset($v[$attr[$k]])) { - $attr[$k] = new ConstStub($v[$attr[$k]], $attr[$k]); - } - } catch (\Exception $e) { - } - } - if (isset($attr[$k = 'STATEMENT_CLASS'][1])) { - if ($attr[$k][1]) { - $attr[$k][1] = new ArgsStub($attr[$k][1], '__construct', $attr[$k][0]); - } - $attr[$k][0] = new ClassStub($attr[$k][0]); - } - - $prefix = Caster::PREFIX_VIRTUAL; - $a += [ - $prefix.'inTransaction' => method_exists($c, 'inTransaction'), - $prefix.'errorInfo' => $c->errorInfo(), - $prefix.'attributes' => new EnumStub($attr), - ]; - - if ($a[$prefix.'inTransaction']) { - $a[$prefix.'inTransaction'] = $c->inTransaction(); - } else { - unset($a[$prefix.'inTransaction']); - } - - if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) { - unset($a[$prefix.'errorInfo']); - } - - $c->setAttribute(\PDO::ATTR_ERRMODE, $errmode); - - return $a; - } - - public static function castPdoStatement(\PDOStatement $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - $a[$prefix.'errorInfo'] = $c->errorInfo(); - - if (!isset($a[$prefix.'errorInfo'][1], $a[$prefix.'errorInfo'][2])) { - unset($a[$prefix.'errorInfo']); - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/PgSqlCaster.php b/vendor/symfony/var-dumper/Caster/PgSqlCaster.php deleted file mode 100644 index 3097c51..0000000 --- a/vendor/symfony/var-dumper/Caster/PgSqlCaster.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts pqsql resources to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class PgSqlCaster -{ - private const PARAM_CODES = [ - 'server_encoding', - 'client_encoding', - 'is_superuser', - 'session_authorization', - 'DateStyle', - 'TimeZone', - 'IntervalStyle', - 'integer_datetimes', - 'application_name', - 'standard_conforming_strings', - ]; - - private const TRANSACTION_STATUS = [ - \PGSQL_TRANSACTION_IDLE => 'PGSQL_TRANSACTION_IDLE', - \PGSQL_TRANSACTION_ACTIVE => 'PGSQL_TRANSACTION_ACTIVE', - \PGSQL_TRANSACTION_INTRANS => 'PGSQL_TRANSACTION_INTRANS', - \PGSQL_TRANSACTION_INERROR => 'PGSQL_TRANSACTION_INERROR', - \PGSQL_TRANSACTION_UNKNOWN => 'PGSQL_TRANSACTION_UNKNOWN', - ]; - - private const RESULT_STATUS = [ - \PGSQL_EMPTY_QUERY => 'PGSQL_EMPTY_QUERY', - \PGSQL_COMMAND_OK => 'PGSQL_COMMAND_OK', - \PGSQL_TUPLES_OK => 'PGSQL_TUPLES_OK', - \PGSQL_COPY_OUT => 'PGSQL_COPY_OUT', - \PGSQL_COPY_IN => 'PGSQL_COPY_IN', - \PGSQL_BAD_RESPONSE => 'PGSQL_BAD_RESPONSE', - \PGSQL_NONFATAL_ERROR => 'PGSQL_NONFATAL_ERROR', - \PGSQL_FATAL_ERROR => 'PGSQL_FATAL_ERROR', - ]; - - private const DIAG_CODES = [ - 'severity' => \PGSQL_DIAG_SEVERITY, - 'sqlstate' => \PGSQL_DIAG_SQLSTATE, - 'message' => \PGSQL_DIAG_MESSAGE_PRIMARY, - 'detail' => \PGSQL_DIAG_MESSAGE_DETAIL, - 'hint' => \PGSQL_DIAG_MESSAGE_HINT, - 'statement position' => \PGSQL_DIAG_STATEMENT_POSITION, - 'internal position' => \PGSQL_DIAG_INTERNAL_POSITION, - 'internal query' => \PGSQL_DIAG_INTERNAL_QUERY, - 'context' => \PGSQL_DIAG_CONTEXT, - 'file' => \PGSQL_DIAG_SOURCE_FILE, - 'line' => \PGSQL_DIAG_SOURCE_LINE, - 'function' => \PGSQL_DIAG_SOURCE_FUNCTION, - ]; - - public static function castLargeObject($lo, array $a, Stub $stub, $isNested) - { - $a['seek position'] = pg_lo_tell($lo); - - return $a; - } - - public static function castLink($link, array $a, Stub $stub, $isNested) - { - $a['status'] = pg_connection_status($link); - $a['status'] = new ConstStub(\PGSQL_CONNECTION_OK === $a['status'] ? 'PGSQL_CONNECTION_OK' : 'PGSQL_CONNECTION_BAD', $a['status']); - $a['busy'] = pg_connection_busy($link); - - $a['transaction'] = pg_transaction_status($link); - if (isset(self::TRANSACTION_STATUS[$a['transaction']])) { - $a['transaction'] = new ConstStub(self::TRANSACTION_STATUS[$a['transaction']], $a['transaction']); - } - - $a['pid'] = pg_get_pid($link); - $a['last error'] = pg_last_error($link); - $a['last notice'] = pg_last_notice($link); - $a['host'] = pg_host($link); - $a['port'] = pg_port($link); - $a['dbname'] = pg_dbname($link); - $a['options'] = pg_options($link); - $a['version'] = pg_version($link); - - foreach (self::PARAM_CODES as $v) { - if (false !== $s = pg_parameter_status($link, $v)) { - $a['param'][$v] = $s; - } - } - - $a['param']['client_encoding'] = pg_client_encoding($link); - $a['param'] = new EnumStub($a['param']); - - return $a; - } - - public static function castResult($result, array $a, Stub $stub, $isNested) - { - $a['num rows'] = pg_num_rows($result); - $a['status'] = pg_result_status($result); - if (isset(self::RESULT_STATUS[$a['status']])) { - $a['status'] = new ConstStub(self::RESULT_STATUS[$a['status']], $a['status']); - } - $a['command-completion tag'] = pg_result_status($result, \PGSQL_STATUS_STRING); - - if (-1 === $a['num rows']) { - foreach (self::DIAG_CODES as $k => $v) { - $a['error'][$k] = pg_result_error_field($result, $v); - } - } - - $a['affected rows'] = pg_affected_rows($result); - $a['last OID'] = pg_last_oid($result); - - $fields = pg_num_fields($result); - - for ($i = 0; $i < $fields; ++$i) { - $field = [ - 'name' => pg_field_name($result, $i), - 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), - 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), - 'nullable' => (bool) pg_field_is_null($result, $i), - 'storage' => pg_field_size($result, $i).' bytes', - 'display' => pg_field_prtlen($result, $i).' chars', - ]; - if (' (OID: )' === $field['table']) { - $field['table'] = null; - } - if ('-1 bytes' === $field['storage']) { - $field['storage'] = 'variable size'; - } elseif ('1 bytes' === $field['storage']) { - $field['storage'] = '1 byte'; - } - if ('1 chars' === $field['display']) { - $field['display'] = '1 char'; - } - $a['fields'][] = new EnumStub($field); - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php b/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php deleted file mode 100644 index ec02f81..0000000 --- a/vendor/symfony/var-dumper/Caster/ProxyManagerCaster.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use ProxyManager\Proxy\ProxyInterface; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class ProxyManagerCaster -{ - public static function castProxy(ProxyInterface $c, array $a, Stub $stub, $isNested) - { - if ($parent = get_parent_class($c)) { - $stub->class .= ' - '.$parent; - } - $stub->class .= '@proxy'; - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/RedisCaster.php b/vendor/symfony/var-dumper/Caster/RedisCaster.php deleted file mode 100644 index bd877cb..0000000 --- a/vendor/symfony/var-dumper/Caster/RedisCaster.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts Redis class from ext-redis to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class RedisCaster -{ - private const SERIALIZERS = [ - \Redis::SERIALIZER_NONE => 'NONE', - \Redis::SERIALIZER_PHP => 'PHP', - 2 => 'IGBINARY', // Optional Redis::SERIALIZER_IGBINARY - ]; - - private const MODES = [ - \Redis::ATOMIC => 'ATOMIC', - \Redis::MULTI => 'MULTI', - \Redis::PIPELINE => 'PIPELINE', - ]; - - private const COMPRESSION_MODES = [ - 0 => 'NONE', // Redis::COMPRESSION_NONE - 1 => 'LZF', // Redis::COMPRESSION_LZF - ]; - - private const FAILOVER_OPTIONS = [ - \RedisCluster::FAILOVER_NONE => 'NONE', - \RedisCluster::FAILOVER_ERROR => 'ERROR', - \RedisCluster::FAILOVER_DISTRIBUTE => 'DISTRIBUTE', - \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES => 'DISTRIBUTE_SLAVES', - ]; - - public static function castRedis(\Redis $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - if (!$connected = $c->isConnected()) { - return $a + [ - $prefix.'isConnected' => $connected, - ]; - } - - $mode = $c->getMode(); - - return $a + [ - $prefix.'isConnected' => $connected, - $prefix.'host' => $c->getHost(), - $prefix.'port' => $c->getPort(), - $prefix.'auth' => $c->getAuth(), - $prefix.'mode' => isset(self::MODES[$mode]) ? new ConstStub(self::MODES[$mode], $mode) : $mode, - $prefix.'dbNum' => $c->getDbNum(), - $prefix.'timeout' => $c->getTimeout(), - $prefix.'lastError' => $c->getLastError(), - $prefix.'persistentId' => $c->getPersistentID(), - $prefix.'options' => self::getRedisOptions($c), - ]; - } - - public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - return $a + [ - $prefix.'hosts' => $c->_hosts(), - $prefix.'function' => ClassStub::wrapCallable($c->_function()), - $prefix.'lastError' => $c->getLastError(), - $prefix.'options' => self::getRedisOptions($c), - ]; - } - - public static function castRedisCluster(\RedisCluster $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - $failover = $c->getOption(\RedisCluster::OPT_SLAVE_FAILOVER); - - $a += [ - $prefix.'_masters' => $c->_masters(), - $prefix.'_redir' => $c->_redir(), - $prefix.'mode' => new ConstStub($c->getMode() ? 'MULTI' : 'ATOMIC', $c->getMode()), - $prefix.'lastError' => $c->getLastError(), - $prefix.'options' => self::getRedisOptions($c, [ - 'SLAVE_FAILOVER' => isset(self::FAILOVER_OPTIONS[$failover]) ? new ConstStub(self::FAILOVER_OPTIONS[$failover], $failover) : $failover, - ]), - ]; - - return $a; - } - - /** - * @param \Redis|\RedisArray|\RedisCluster $redis - */ - private static function getRedisOptions($redis, array $options = []): EnumStub - { - $serializer = $redis->getOption(\Redis::OPT_SERIALIZER); - if (\is_array($serializer)) { - foreach ($serializer as &$v) { - if (isset(self::SERIALIZERS[$v])) { - $v = new ConstStub(self::SERIALIZERS[$v], $v); - } - } - } elseif (isset(self::SERIALIZERS[$serializer])) { - $serializer = new ConstStub(self::SERIALIZERS[$serializer], $serializer); - } - - $compression = \defined('Redis::OPT_COMPRESSION') ? $redis->getOption(\Redis::OPT_COMPRESSION) : 0; - if (\is_array($compression)) { - foreach ($compression as &$v) { - if (isset(self::COMPRESSION_MODES[$v])) { - $v = new ConstStub(self::COMPRESSION_MODES[$v], $v); - } - } - } elseif (isset(self::COMPRESSION_MODES[$compression])) { - $compression = new ConstStub(self::COMPRESSION_MODES[$compression], $compression); - } - - $retry = \defined('Redis::OPT_SCAN') ? $redis->getOption(\Redis::OPT_SCAN) : 0; - if (\is_array($retry)) { - foreach ($retry as &$v) { - $v = new ConstStub($v ? 'RETRY' : 'NORETRY', $v); - } - } else { - $retry = new ConstStub($retry ? 'RETRY' : 'NORETRY', $retry); - } - - $options += [ - 'TCP_KEEPALIVE' => \defined('Redis::OPT_TCP_KEEPALIVE') ? $redis->getOption(\Redis::OPT_TCP_KEEPALIVE) : 0, - 'READ_TIMEOUT' => $redis->getOption(\Redis::OPT_READ_TIMEOUT), - 'COMPRESSION' => $compression, - 'SERIALIZER' => $serializer, - 'PREFIX' => $redis->getOption(\Redis::OPT_PREFIX), - 'SCAN' => $retry, - ]; - - return new EnumStub($options); - } -} diff --git a/vendor/symfony/var-dumper/Caster/ReflectionCaster.php b/vendor/symfony/var-dumper/Caster/ReflectionCaster.php deleted file mode 100644 index 2a74b25..0000000 --- a/vendor/symfony/var-dumper/Caster/ReflectionCaster.php +++ /dev/null @@ -1,405 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts Reflector related classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class ReflectionCaster -{ - public const UNSET_CLOSURE_FILE_INFO = ['Closure' => __CLASS__.'::unsetClosureFileInfo']; - - private const EXTRA_MAP = [ - 'docComment' => 'getDocComment', - 'extension' => 'getExtensionName', - 'isDisabled' => 'isDisabled', - 'isDeprecated' => 'isDeprecated', - 'isInternal' => 'isInternal', - 'isUserDefined' => 'isUserDefined', - 'isGenerator' => 'isGenerator', - 'isVariadic' => 'isVariadic', - ]; - - public static function castClosure(\Closure $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $prefix = Caster::PREFIX_VIRTUAL; - $c = new \ReflectionFunction($c); - - $a = static::castFunctionAbstract($c, $a, $stub, $isNested, $filter); - - if (!str_contains($c->name, '{closure}')) { - $stub->class = isset($a[$prefix.'class']) ? $a[$prefix.'class']->value.'::'.$c->name : $c->name; - unset($a[$prefix.'class']); - } - unset($a[$prefix.'extra']); - - $stub->class .= self::getSignature($a); - - if ($f = $c->getFileName()) { - $stub->attr['file'] = $f; - $stub->attr['line'] = $c->getStartLine(); - } - - unset($a[$prefix.'parameters']); - - if ($filter & Caster::EXCLUDE_VERBOSE) { - $stub->cut += ($c->getFileName() ? 2 : 0) + \count($a); - - return []; - } - - if ($f) { - $a[$prefix.'file'] = new LinkStub($f, $c->getStartLine()); - $a[$prefix.'line'] = $c->getStartLine().' to '.$c->getEndLine(); - } - - return $a; - } - - public static function unsetClosureFileInfo(\Closure $c, array $a) - { - unset($a[Caster::PREFIX_VIRTUAL.'file'], $a[Caster::PREFIX_VIRTUAL.'line']); - - return $a; - } - - public static function castGenerator(\Generator $c, array $a, Stub $stub, $isNested) - { - // Cannot create ReflectionGenerator based on a terminated Generator - try { - $reflectionGenerator = new \ReflectionGenerator($c); - } catch (\Exception $e) { - $a[Caster::PREFIX_VIRTUAL.'closed'] = true; - - return $a; - } - - return self::castReflectionGenerator($reflectionGenerator, $a, $stub, $isNested); - } - - public static function castType(\ReflectionType $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - if ($c instanceof \ReflectionNamedType || \PHP_VERSION_ID < 80000) { - $a += [ - $prefix.'name' => $c instanceof \ReflectionNamedType ? $c->getName() : (string) $c, - $prefix.'allowsNull' => $c->allowsNull(), - $prefix.'isBuiltin' => $c->isBuiltin(), - ]; - } elseif ($c instanceof \ReflectionUnionType || $c instanceof \ReflectionIntersectionType) { - $a[$prefix.'allowsNull'] = $c->allowsNull(); - self::addMap($a, $c, [ - 'types' => 'getTypes', - ]); - } else { - $a[$prefix.'allowsNull'] = $c->allowsNull(); - } - - return $a; - } - - public static function castReflectionGenerator(\ReflectionGenerator $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - if ($c->getThis()) { - $a[$prefix.'this'] = new CutStub($c->getThis()); - } - $function = $c->getFunction(); - $frame = [ - 'class' => $function->class ?? null, - 'type' => isset($function->class) ? ($function->isStatic() ? '::' : '->') : null, - 'function' => $function->name, - 'file' => $c->getExecutingFile(), - 'line' => $c->getExecutingLine(), - ]; - if ($trace = $c->getTrace(\DEBUG_BACKTRACE_IGNORE_ARGS)) { - $function = new \ReflectionGenerator($c->getExecutingGenerator()); - array_unshift($trace, [ - 'function' => 'yield', - 'file' => $function->getExecutingFile(), - 'line' => $function->getExecutingLine() - (int) (\PHP_VERSION_ID < 80100), - ]); - $trace[] = $frame; - $a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1); - } else { - $function = new FrameStub($frame, false, true); - $function = ExceptionCaster::castFrameStub($function, [], $function, true); - $a[$prefix.'executing'] = $function[$prefix.'src']; - } - - $a[Caster::PREFIX_VIRTUAL.'closed'] = false; - - return $a; - } - - public static function castClass(\ReflectionClass $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $prefix = Caster::PREFIX_VIRTUAL; - - if ($n = \Reflection::getModifierNames($c->getModifiers())) { - $a[$prefix.'modifiers'] = implode(' ', $n); - } - - self::addMap($a, $c, [ - 'extends' => 'getParentClass', - 'implements' => 'getInterfaceNames', - 'constants' => 'getConstants', - ]); - - foreach ($c->getProperties() as $n) { - $a[$prefix.'properties'][$n->name] = $n; - } - - foreach ($c->getMethods() as $n) { - $a[$prefix.'methods'][$n->name] = $n; - } - - if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) { - self::addExtra($a, $c); - } - - return $a; - } - - public static function castFunctionAbstract(\ReflectionFunctionAbstract $c, array $a, Stub $stub, $isNested, $filter = 0) - { - $prefix = Caster::PREFIX_VIRTUAL; - - self::addMap($a, $c, [ - 'returnsReference' => 'returnsReference', - 'returnType' => 'getReturnType', - 'class' => 'getClosureScopeClass', - 'this' => 'getClosureThis', - ]); - - if (isset($a[$prefix.'returnType'])) { - $v = $a[$prefix.'returnType']; - $v = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v; - $a[$prefix.'returnType'] = new ClassStub($a[$prefix.'returnType'] instanceof \ReflectionNamedType && $a[$prefix.'returnType']->allowsNull() && 'mixed' !== $v ? '?'.$v : $v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']); - } - if (isset($a[$prefix.'class'])) { - $a[$prefix.'class'] = new ClassStub($a[$prefix.'class']); - } - if (isset($a[$prefix.'this'])) { - $a[$prefix.'this'] = new CutStub($a[$prefix.'this']); - } - - foreach ($c->getParameters() as $v) { - $k = '$'.$v->name; - if ($v->isVariadic()) { - $k = '...'.$k; - } - if ($v->isPassedByReference()) { - $k = '&'.$k; - } - $a[$prefix.'parameters'][$k] = $v; - } - if (isset($a[$prefix.'parameters'])) { - $a[$prefix.'parameters'] = new EnumStub($a[$prefix.'parameters']); - } - - if (!($filter & Caster::EXCLUDE_VERBOSE) && $v = $c->getStaticVariables()) { - foreach ($v as $k => &$v) { - if (\is_object($v)) { - $a[$prefix.'use']['$'.$k] = new CutStub($v); - } else { - $a[$prefix.'use']['$'.$k] = &$v; - } - } - unset($v); - $a[$prefix.'use'] = new EnumStub($a[$prefix.'use']); - } - - if (!($filter & Caster::EXCLUDE_VERBOSE) && !$isNested) { - self::addExtra($a, $c); - } - - return $a; - } - - public static function castMethod(\ReflectionMethod $c, array $a, Stub $stub, $isNested) - { - $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); - - return $a; - } - - public static function castParameter(\ReflectionParameter $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - - self::addMap($a, $c, [ - 'position' => 'getPosition', - 'isVariadic' => 'isVariadic', - 'byReference' => 'isPassedByReference', - 'allowsNull' => 'allowsNull', - ]); - - if ($v = $c->getType()) { - $a[$prefix.'typeHint'] = $v instanceof \ReflectionNamedType ? $v->getName() : (string) $v; - } - - if (isset($a[$prefix.'typeHint'])) { - $v = $a[$prefix.'typeHint']; - $a[$prefix.'typeHint'] = new ClassStub($v, [class_exists($v, false) || interface_exists($v, false) || trait_exists($v, false) ? $v : '', '']); - } else { - unset($a[$prefix.'allowsNull']); - } - - if ($c->isOptional()) { - try { - $a[$prefix.'default'] = $v = $c->getDefaultValue(); - if ($c->isDefaultValueConstant()) { - $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); - } - if (null === $v) { - unset($a[$prefix.'allowsNull']); - } - } catch (\ReflectionException $e) { - } - } - - return $a; - } - - public static function castProperty(\ReflectionProperty $c, array $a, Stub $stub, $isNested) - { - $a[Caster::PREFIX_VIRTUAL.'modifiers'] = implode(' ', \Reflection::getModifierNames($c->getModifiers())); - self::addExtra($a, $c); - - return $a; - } - - public static function castReference(\ReflectionReference $c, array $a, Stub $stub, $isNested) - { - $a[Caster::PREFIX_VIRTUAL.'id'] = $c->getId(); - - return $a; - } - - public static function castExtension(\ReflectionExtension $c, array $a, Stub $stub, $isNested) - { - self::addMap($a, $c, [ - 'version' => 'getVersion', - 'dependencies' => 'getDependencies', - 'iniEntries' => 'getIniEntries', - 'isPersistent' => 'isPersistent', - 'isTemporary' => 'isTemporary', - 'constants' => 'getConstants', - 'functions' => 'getFunctions', - 'classes' => 'getClasses', - ]); - - return $a; - } - - public static function castZendExtension(\ReflectionZendExtension $c, array $a, Stub $stub, $isNested) - { - self::addMap($a, $c, [ - 'version' => 'getVersion', - 'author' => 'getAuthor', - 'copyright' => 'getCopyright', - 'url' => 'getURL', - ]); - - return $a; - } - - public static function getSignature(array $a) - { - $prefix = Caster::PREFIX_VIRTUAL; - $signature = ''; - - if (isset($a[$prefix.'parameters'])) { - foreach ($a[$prefix.'parameters']->value as $k => $param) { - $signature .= ', '; - if ($type = $param->getType()) { - if (!$type instanceof \ReflectionNamedType) { - $signature .= $type.' '; - } else { - if (!$param->isOptional() && $param->allowsNull() && 'mixed' !== $type->getName()) { - $signature .= '?'; - } - $signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' '; - } - } - $signature .= $k; - - if (!$param->isDefaultValueAvailable()) { - continue; - } - $v = $param->getDefaultValue(); - $signature .= ' = '; - - if ($param->isDefaultValueConstant()) { - $signature .= substr(strrchr('\\'.$param->getDefaultValueConstantName(), '\\'), 1); - } elseif (null === $v) { - $signature .= 'null'; - } elseif (\is_array($v)) { - $signature .= $v ? '[…'.\count($v).']' : '[]'; - } elseif (\is_string($v)) { - $signature .= 10 > \strlen($v) && !str_contains($v, '\\') ? "'{$v}'" : "'…".\strlen($v)."'"; - } elseif (\is_bool($v)) { - $signature .= $v ? 'true' : 'false'; - } elseif (\is_object($v)) { - $signature .= 'new '.substr(strrchr('\\'.get_debug_type($v), '\\'), 1); - } else { - $signature .= $v; - } - } - } - $signature = (empty($a[$prefix.'returnsReference']) ? '' : '&').'('.substr($signature, 2).')'; - - if (isset($a[$prefix.'returnType'])) { - $signature .= ': '.substr(strrchr('\\'.$a[$prefix.'returnType'], '\\'), 1); - } - - return $signature; - } - - private static function addExtra(array &$a, \Reflector $c) - { - $x = isset($a[Caster::PREFIX_VIRTUAL.'extra']) ? $a[Caster::PREFIX_VIRTUAL.'extra']->value : []; - - if (method_exists($c, 'getFileName') && $m = $c->getFileName()) { - $x['file'] = new LinkStub($m, $c->getStartLine()); - $x['line'] = $c->getStartLine().' to '.$c->getEndLine(); - } - - self::addMap($x, $c, self::EXTRA_MAP, ''); - - if ($x) { - $a[Caster::PREFIX_VIRTUAL.'extra'] = new EnumStub($x); - } - } - - private static function addMap(array &$a, $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL) - { - foreach ($map as $k => $m) { - if (\PHP_VERSION_ID >= 80000 && 'isDisabled' === $k) { - continue; - } - - if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) { - $a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m; - } - } - } -} diff --git a/vendor/symfony/var-dumper/Caster/ResourceCaster.php b/vendor/symfony/var-dumper/Caster/ResourceCaster.php deleted file mode 100644 index a3278a8..0000000 --- a/vendor/symfony/var-dumper/Caster/ResourceCaster.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts common resource types to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class ResourceCaster -{ - /** - * @param \CurlHandle|resource $h - * - * @return array - */ - public static function castCurl($h, array $a, Stub $stub, $isNested) - { - return curl_getinfo($h); - } - - public static function castDba($dba, array $a, Stub $stub, $isNested) - { - $list = dba_list(); - $a['file'] = $list[(int) $dba]; - - return $a; - } - - public static function castProcess($process, array $a, Stub $stub, $isNested) - { - return proc_get_status($process); - } - - public static function castStream($stream, array $a, Stub $stub, $isNested) - { - $a = stream_get_meta_data($stream) + static::castStreamContext($stream, $a, $stub, $isNested); - if ($a['uri'] ?? false) { - $a['uri'] = new LinkStub($a['uri']); - } - - return $a; - } - - public static function castStreamContext($stream, array $a, Stub $stub, $isNested) - { - return @stream_context_get_params($stream) ?: $a; - } - - public static function castGd($gd, array $a, Stub $stub, $isNested) - { - $a['size'] = imagesx($gd).'x'.imagesy($gd); - $a['trueColor'] = imageistruecolor($gd); - - return $a; - } - - public static function castMysqlLink($h, array $a, Stub $stub, $isNested) - { - $a['host'] = mysql_get_host_info($h); - $a['protocol'] = mysql_get_proto_info($h); - $a['server'] = mysql_get_server_info($h); - - return $a; - } - - public static function castOpensslX509($h, array $a, Stub $stub, $isNested) - { - $stub->cut = -1; - $info = openssl_x509_parse($h, false); - - $pin = openssl_pkey_get_public($h); - $pin = openssl_pkey_get_details($pin)['key']; - $pin = \array_slice(explode("\n", $pin), 1, -2); - $pin = base64_decode(implode('', $pin)); - $pin = base64_encode(hash('sha256', $pin, true)); - - $a += [ - 'subject' => new EnumStub(array_intersect_key($info['subject'], ['organizationName' => true, 'commonName' => true])), - 'issuer' => new EnumStub(array_intersect_key($info['issuer'], ['organizationName' => true, 'commonName' => true])), - 'expiry' => new ConstStub(date(\DateTime::ISO8601, $info['validTo_time_t']), $info['validTo_time_t']), - 'fingerprint' => new EnumStub([ - 'md5' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'md5')), 2, ':', true)), - 'sha1' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha1')), 2, ':', true)), - 'sha256' => new ConstStub(wordwrap(strtoupper(openssl_x509_fingerprint($h, 'sha256')), 2, ':', true)), - 'pin-sha256' => new ConstStub($pin), - ]), - ]; - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/SplCaster.php b/vendor/symfony/var-dumper/Caster/SplCaster.php deleted file mode 100644 index be9d66b..0000000 --- a/vendor/symfony/var-dumper/Caster/SplCaster.php +++ /dev/null @@ -1,245 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts SPL related classes to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class SplCaster -{ - private const SPL_FILE_OBJECT_FLAGS = [ - \SplFileObject::DROP_NEW_LINE => 'DROP_NEW_LINE', - \SplFileObject::READ_AHEAD => 'READ_AHEAD', - \SplFileObject::SKIP_EMPTY => 'SKIP_EMPTY', - \SplFileObject::READ_CSV => 'READ_CSV', - ]; - - public static function castArrayObject(\ArrayObject $c, array $a, Stub $stub, $isNested) - { - return self::castSplArray($c, $a, $stub, $isNested); - } - - public static function castArrayIterator(\ArrayIterator $c, array $a, Stub $stub, $isNested) - { - return self::castSplArray($c, $a, $stub, $isNested); - } - - public static function castHeap(\Iterator $c, array $a, Stub $stub, $isNested) - { - $a += [ - Caster::PREFIX_VIRTUAL.'heap' => iterator_to_array(clone $c), - ]; - - return $a; - } - - public static function castDoublyLinkedList(\SplDoublyLinkedList $c, array $a, Stub $stub, $isNested) - { - $prefix = Caster::PREFIX_VIRTUAL; - $mode = $c->getIteratorMode(); - $c->setIteratorMode(\SplDoublyLinkedList::IT_MODE_KEEP | $mode & ~\SplDoublyLinkedList::IT_MODE_DELETE); - - $a += [ - $prefix.'mode' => new ConstStub((($mode & \SplDoublyLinkedList::IT_MODE_LIFO) ? 'IT_MODE_LIFO' : 'IT_MODE_FIFO').' | '.(($mode & \SplDoublyLinkedList::IT_MODE_DELETE) ? 'IT_MODE_DELETE' : 'IT_MODE_KEEP'), $mode), - $prefix.'dllist' => iterator_to_array($c), - ]; - $c->setIteratorMode($mode); - - return $a; - } - - public static function castFileInfo(\SplFileInfo $c, array $a, Stub $stub, $isNested) - { - static $map = [ - 'path' => 'getPath', - 'filename' => 'getFilename', - 'basename' => 'getBasename', - 'pathname' => 'getPathname', - 'extension' => 'getExtension', - 'realPath' => 'getRealPath', - 'aTime' => 'getATime', - 'mTime' => 'getMTime', - 'cTime' => 'getCTime', - 'inode' => 'getInode', - 'size' => 'getSize', - 'perms' => 'getPerms', - 'owner' => 'getOwner', - 'group' => 'getGroup', - 'type' => 'getType', - 'writable' => 'isWritable', - 'readable' => 'isReadable', - 'executable' => 'isExecutable', - 'file' => 'isFile', - 'dir' => 'isDir', - 'link' => 'isLink', - 'linkTarget' => 'getLinkTarget', - ]; - - $prefix = Caster::PREFIX_VIRTUAL; - unset($a["\0SplFileInfo\0fileName"]); - unset($a["\0SplFileInfo\0pathName"]); - - if (\PHP_VERSION_ID < 80000) { - if (false === $c->getPathname()) { - $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; - - return $a; - } - } else { - try { - $c->isReadable(); - } catch (\RuntimeException $e) { - if ('Object not initialized' !== $e->getMessage()) { - throw $e; - } - - $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; - - return $a; - } catch (\Error $e) { - if ('Object not initialized' !== $e->getMessage()) { - throw $e; - } - - $a[$prefix.'⚠'] = 'The parent constructor was not called: the object is in an invalid state'; - - return $a; - } - } - - foreach ($map as $key => $accessor) { - try { - $a[$prefix.$key] = $c->$accessor(); - } catch (\Exception $e) { - } - } - - if ($a[$prefix.'realPath'] ?? false) { - $a[$prefix.'realPath'] = new LinkStub($a[$prefix.'realPath']); - } - - if (isset($a[$prefix.'perms'])) { - $a[$prefix.'perms'] = new ConstStub(sprintf('0%o', $a[$prefix.'perms']), $a[$prefix.'perms']); - } - - static $mapDate = ['aTime', 'mTime', 'cTime']; - foreach ($mapDate as $key) { - if (isset($a[$prefix.$key])) { - $a[$prefix.$key] = new ConstStub(date('Y-m-d H:i:s', $a[$prefix.$key]), $a[$prefix.$key]); - } - } - - return $a; - } - - public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, $isNested) - { - static $map = [ - 'csvControl' => 'getCsvControl', - 'flags' => 'getFlags', - 'maxLineLen' => 'getMaxLineLen', - 'fstat' => 'fstat', - 'eof' => 'eof', - 'key' => 'key', - ]; - - $prefix = Caster::PREFIX_VIRTUAL; - - foreach ($map as $key => $accessor) { - try { - $a[$prefix.$key] = $c->$accessor(); - } catch (\Exception $e) { - } - } - - if (isset($a[$prefix.'flags'])) { - $flagsArray = []; - foreach (self::SPL_FILE_OBJECT_FLAGS as $value => $name) { - if ($a[$prefix.'flags'] & $value) { - $flagsArray[] = $name; - } - } - $a[$prefix.'flags'] = new ConstStub(implode('|', $flagsArray), $a[$prefix.'flags']); - } - - if (isset($a[$prefix.'fstat'])) { - $a[$prefix.'fstat'] = new CutArrayStub($a[$prefix.'fstat'], ['dev', 'ino', 'nlink', 'rdev', 'blksize', 'blocks']); - } - - return $a; - } - - public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, $isNested) - { - $storage = []; - unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967 - unset($a["\0SplObjectStorage\0storage"]); - - $clone = clone $c; - foreach ($clone as $obj) { - $storage[] = [ - 'object' => $obj, - 'info' => $clone->getInfo(), - ]; - } - - $a += [ - Caster::PREFIX_VIRTUAL.'storage' => $storage, - ]; - - return $a; - } - - public static function castOuterIterator(\OuterIterator $c, array $a, Stub $stub, $isNested) - { - $a[Caster::PREFIX_VIRTUAL.'innerIterator'] = $c->getInnerIterator(); - - return $a; - } - - public static function castWeakReference(\WeakReference $c, array $a, Stub $stub, $isNested) - { - $a[Caster::PREFIX_VIRTUAL.'object'] = $c->get(); - - return $a; - } - - private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array - { - $prefix = Caster::PREFIX_VIRTUAL; - $flags = $c->getFlags(); - - if (!($flags & \ArrayObject::STD_PROP_LIST)) { - $c->setFlags(\ArrayObject::STD_PROP_LIST); - $a = Caster::castObject($c, \get_class($c), method_exists($c, '__debugInfo'), $stub->class); - $c->setFlags($flags); - } - if (\PHP_VERSION_ID < 70400) { - $a[$prefix.'storage'] = $c->getArrayCopy(); - } - $a += [ - $prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST), - $prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS), - ]; - if ($c instanceof \ArrayObject) { - $a[$prefix.'iteratorClass'] = new ClassStub($c->getIteratorClass()); - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/StubCaster.php b/vendor/symfony/var-dumper/Caster/StubCaster.php deleted file mode 100644 index b6332fb..0000000 --- a/vendor/symfony/var-dumper/Caster/StubCaster.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts a caster's Stub. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class StubCaster -{ - public static function castStub(Stub $c, array $a, Stub $stub, $isNested) - { - if ($isNested) { - $stub->type = $c->type; - $stub->class = $c->class; - $stub->value = $c->value; - $stub->handle = $c->handle; - $stub->cut = $c->cut; - $stub->attr = $c->attr; - - if (Stub::TYPE_REF === $c->type && !$c->class && \is_string($c->value) && !preg_match('//u', $c->value)) { - $stub->type = Stub::TYPE_STRING; - $stub->class = Stub::STRING_BINARY; - } - - $a = []; - } - - return $a; - } - - public static function castCutArray(CutArrayStub $c, array $a, Stub $stub, $isNested) - { - return $isNested ? $c->preservedSubset : $a; - } - - public static function cutInternals($obj, array $a, Stub $stub, $isNested) - { - if ($isNested) { - $stub->cut += \count($a); - - return []; - } - - return $a; - } - - public static function castEnum(EnumStub $c, array $a, Stub $stub, $isNested) - { - if ($isNested) { - $stub->class = $c->dumpKeys ? '' : null; - $stub->handle = 0; - $stub->value = null; - $stub->cut = $c->cut; - $stub->attr = $c->attr; - - $a = []; - - if ($c->value) { - foreach (array_keys($c->value) as $k) { - $keys[] = !isset($k[0]) || "\0" !== $k[0] ? Caster::PREFIX_VIRTUAL.$k : $k; - } - // Preserve references with array_combine() - $a = array_combine($keys, $c->value); - } - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/SymfonyCaster.php b/vendor/symfony/var-dumper/Caster/SymfonyCaster.php deleted file mode 100644 index 06f213e..0000000 --- a/vendor/symfony/var-dumper/Caster/SymfonyCaster.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @final since Symfony 4.4 - */ -class SymfonyCaster -{ - private const REQUEST_GETTERS = [ - 'pathInfo' => 'getPathInfo', - 'requestUri' => 'getRequestUri', - 'baseUrl' => 'getBaseUrl', - 'basePath' => 'getBasePath', - 'method' => 'getMethod', - 'format' => 'getRequestFormat', - ]; - - public static function castRequest(Request $request, array $a, Stub $stub, $isNested) - { - $clone = null; - - foreach (self::REQUEST_GETTERS as $prop => $getter) { - $key = Caster::PREFIX_PROTECTED.$prop; - if (\array_key_exists($key, $a) && null === $a[$key]) { - if (null === $clone) { - $clone = clone $request; - } - $a[Caster::PREFIX_VIRTUAL.$prop] = $clone->{$getter}(); - } - } - - return $a; - } - - public static function castHttpClient($client, array $a, Stub $stub, $isNested) - { - $multiKey = sprintf("\0%s\0multi", \get_class($client)); - if (isset($a[$multiKey])) { - $a[$multiKey] = new CutStub($a[$multiKey]); - } - - return $a; - } - - public static function castHttpClientResponse($response, array $a, Stub $stub, $isNested) - { - $stub->cut += \count($a); - $a = []; - - foreach ($response->getInfo() as $k => $v) { - $a[Caster::PREFIX_VIRTUAL.$k] = $v; - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/TraceStub.php b/vendor/symfony/var-dumper/Caster/TraceStub.php deleted file mode 100644 index 5eea1c8..0000000 --- a/vendor/symfony/var-dumper/Caster/TraceStub.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Represents a backtrace as returned by debug_backtrace() or Exception->getTrace(). - * - * @author Nicolas Grekas - */ -class TraceStub extends Stub -{ - public $keepArgs; - public $sliceOffset; - public $sliceLength; - public $numberingOffset; - - public function __construct(array $trace, bool $keepArgs = true, int $sliceOffset = 0, int $sliceLength = null, int $numberingOffset = 0) - { - $this->value = $trace; - $this->keepArgs = $keepArgs; - $this->sliceOffset = $sliceOffset; - $this->sliceLength = $sliceLength; - $this->numberingOffset = $numberingOffset; - } -} diff --git a/vendor/symfony/var-dumper/Caster/UuidCaster.php b/vendor/symfony/var-dumper/Caster/UuidCaster.php deleted file mode 100644 index b102774..0000000 --- a/vendor/symfony/var-dumper/Caster/UuidCaster.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Ramsey\Uuid\UuidInterface; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * @author Grégoire Pineau - */ -final class UuidCaster -{ - public static function castRamseyUuid(UuidInterface $c, array $a, Stub $stub, bool $isNested): array - { - $a += [ - Caster::PREFIX_VIRTUAL.'uuid' => (string) $c, - ]; - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php b/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php deleted file mode 100644 index 9f5a375..0000000 --- a/vendor/symfony/var-dumper/Caster/XmlReaderCaster.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts XmlReader class to array representation. - * - * @author Baptiste Clavié - * - * @final since Symfony 4.4 - */ -class XmlReaderCaster -{ - private const NODE_TYPES = [ - \XMLReader::NONE => 'NONE', - \XMLReader::ELEMENT => 'ELEMENT', - \XMLReader::ATTRIBUTE => 'ATTRIBUTE', - \XMLReader::TEXT => 'TEXT', - \XMLReader::CDATA => 'CDATA', - \XMLReader::ENTITY_REF => 'ENTITY_REF', - \XMLReader::ENTITY => 'ENTITY', - \XMLReader::PI => 'PI (Processing Instruction)', - \XMLReader::COMMENT => 'COMMENT', - \XMLReader::DOC => 'DOC', - \XMLReader::DOC_TYPE => 'DOC_TYPE', - \XMLReader::DOC_FRAGMENT => 'DOC_FRAGMENT', - \XMLReader::NOTATION => 'NOTATION', - \XMLReader::WHITESPACE => 'WHITESPACE', - \XMLReader::SIGNIFICANT_WHITESPACE => 'SIGNIFICANT_WHITESPACE', - \XMLReader::END_ELEMENT => 'END_ELEMENT', - \XMLReader::END_ENTITY => 'END_ENTITY', - \XMLReader::XML_DECLARATION => 'XML_DECLARATION', - ]; - - public static function castXmlReader(\XMLReader $reader, array $a, Stub $stub, $isNested) - { - try { - $properties = [ - 'LOADDTD' => @$reader->getParserProperty(\XMLReader::LOADDTD), - 'DEFAULTATTRS' => @$reader->getParserProperty(\XMLReader::DEFAULTATTRS), - 'VALIDATE' => @$reader->getParserProperty(\XMLReader::VALIDATE), - 'SUBST_ENTITIES' => @$reader->getParserProperty(\XMLReader::SUBST_ENTITIES), - ]; - } catch (\Error $e) { - $properties = [ - 'LOADDTD' => false, - 'DEFAULTATTRS' => false, - 'VALIDATE' => false, - 'SUBST_ENTITIES' => false, - ]; - } - - $props = Caster::PREFIX_VIRTUAL.'parserProperties'; - $info = [ - 'localName' => $reader->localName, - 'prefix' => $reader->prefix, - 'nodeType' => new ConstStub(self::NODE_TYPES[$reader->nodeType], $reader->nodeType), - 'depth' => $reader->depth, - 'isDefault' => $reader->isDefault, - 'isEmptyElement' => \XMLReader::NONE === $reader->nodeType ? null : $reader->isEmptyElement, - 'xmlLang' => $reader->xmlLang, - 'attributeCount' => $reader->attributeCount, - 'value' => $reader->value, - 'namespaceURI' => $reader->namespaceURI, - 'baseURI' => $reader->baseURI ? new LinkStub($reader->baseURI) : $reader->baseURI, - $props => $properties, - ]; - - if ($info[$props] = Caster::filter($info[$props], Caster::EXCLUDE_EMPTY, [], $count)) { - $info[$props] = new EnumStub($info[$props]); - $info[$props]->cut = $count; - } - - $info = Caster::filter($info, Caster::EXCLUDE_EMPTY, [], $count); - // +2 because hasValue and hasAttributes are always filtered - $stub->cut += $count + 2; - - return $a + $info; - } -} diff --git a/vendor/symfony/var-dumper/Caster/XmlResourceCaster.php b/vendor/symfony/var-dumper/Caster/XmlResourceCaster.php deleted file mode 100644 index 455fc06..0000000 --- a/vendor/symfony/var-dumper/Caster/XmlResourceCaster.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Caster; - -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * Casts XML resources to array representation. - * - * @author Nicolas Grekas - * - * @final since Symfony 4.4 - */ -class XmlResourceCaster -{ - private const XML_ERRORS = [ - \XML_ERROR_NONE => 'XML_ERROR_NONE', - \XML_ERROR_NO_MEMORY => 'XML_ERROR_NO_MEMORY', - \XML_ERROR_SYNTAX => 'XML_ERROR_SYNTAX', - \XML_ERROR_NO_ELEMENTS => 'XML_ERROR_NO_ELEMENTS', - \XML_ERROR_INVALID_TOKEN => 'XML_ERROR_INVALID_TOKEN', - \XML_ERROR_UNCLOSED_TOKEN => 'XML_ERROR_UNCLOSED_TOKEN', - \XML_ERROR_PARTIAL_CHAR => 'XML_ERROR_PARTIAL_CHAR', - \XML_ERROR_TAG_MISMATCH => 'XML_ERROR_TAG_MISMATCH', - \XML_ERROR_DUPLICATE_ATTRIBUTE => 'XML_ERROR_DUPLICATE_ATTRIBUTE', - \XML_ERROR_JUNK_AFTER_DOC_ELEMENT => 'XML_ERROR_JUNK_AFTER_DOC_ELEMENT', - \XML_ERROR_PARAM_ENTITY_REF => 'XML_ERROR_PARAM_ENTITY_REF', - \XML_ERROR_UNDEFINED_ENTITY => 'XML_ERROR_UNDEFINED_ENTITY', - \XML_ERROR_RECURSIVE_ENTITY_REF => 'XML_ERROR_RECURSIVE_ENTITY_REF', - \XML_ERROR_ASYNC_ENTITY => 'XML_ERROR_ASYNC_ENTITY', - \XML_ERROR_BAD_CHAR_REF => 'XML_ERROR_BAD_CHAR_REF', - \XML_ERROR_BINARY_ENTITY_REF => 'XML_ERROR_BINARY_ENTITY_REF', - \XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF => 'XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF', - \XML_ERROR_MISPLACED_XML_PI => 'XML_ERROR_MISPLACED_XML_PI', - \XML_ERROR_UNKNOWN_ENCODING => 'XML_ERROR_UNKNOWN_ENCODING', - \XML_ERROR_INCORRECT_ENCODING => 'XML_ERROR_INCORRECT_ENCODING', - \XML_ERROR_UNCLOSED_CDATA_SECTION => 'XML_ERROR_UNCLOSED_CDATA_SECTION', - \XML_ERROR_EXTERNAL_ENTITY_HANDLING => 'XML_ERROR_EXTERNAL_ENTITY_HANDLING', - ]; - - public static function castXml($h, array $a, Stub $stub, $isNested) - { - $a['current_byte_index'] = xml_get_current_byte_index($h); - $a['current_column_number'] = xml_get_current_column_number($h); - $a['current_line_number'] = xml_get_current_line_number($h); - $a['error_code'] = xml_get_error_code($h); - - if (isset(self::XML_ERRORS[$a['error_code']])) { - $a['error_code'] = new ConstStub(self::XML_ERRORS[$a['error_code']], $a['error_code']); - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Cloner/AbstractCloner.php b/vendor/symfony/var-dumper/Cloner/AbstractCloner.php deleted file mode 100644 index d2e5039..0000000 --- a/vendor/symfony/var-dumper/Cloner/AbstractCloner.php +++ /dev/null @@ -1,377 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -use Symfony\Component\VarDumper\Caster\Caster; -use Symfony\Component\VarDumper\Exception\ThrowingCasterException; - -/** - * AbstractCloner implements a generic caster mechanism for objects and resources. - * - * @author Nicolas Grekas - */ -abstract class AbstractCloner implements ClonerInterface -{ - public static $defaultCasters = [ - '__PHP_Incomplete_Class' => ['Symfony\Component\VarDumper\Caster\Caster', 'castPhpIncompleteClass'], - - 'Symfony\Component\VarDumper\Caster\CutStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'], - 'Symfony\Component\VarDumper\Caster\CutArrayStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castCutArray'], - 'Symfony\Component\VarDumper\Caster\ConstStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castStub'], - 'Symfony\Component\VarDumper\Caster\EnumStub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'castEnum'], - - 'Closure' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClosure'], - 'Generator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castGenerator'], - 'ReflectionType' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castType'], - 'ReflectionGenerator' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReflectionGenerator'], - 'ReflectionClass' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castClass'], - 'ReflectionFunctionAbstract' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castFunctionAbstract'], - 'ReflectionMethod' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castMethod'], - 'ReflectionParameter' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castParameter'], - 'ReflectionProperty' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castProperty'], - 'ReflectionReference' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castReference'], - 'ReflectionExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castExtension'], - 'ReflectionZendExtension' => ['Symfony\Component\VarDumper\Caster\ReflectionCaster', 'castZendExtension'], - - 'Doctrine\Common\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Doctrine\Common\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castCommonProxy'], - 'Doctrine\ORM\Proxy\Proxy' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castOrmProxy'], - 'Doctrine\ORM\PersistentCollection' => ['Symfony\Component\VarDumper\Caster\DoctrineCaster', 'castPersistentCollection'], - 'Doctrine\Persistence\ObjectManager' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - - 'DOMException' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castException'], - 'DOMStringList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], - 'DOMNameList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], - 'DOMImplementation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castImplementation'], - 'DOMImplementationList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], - 'DOMNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNode'], - 'DOMNameSpaceNode' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNameSpaceNode'], - 'DOMDocument' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocument'], - 'DOMNodeList' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], - 'DOMNamedNodeMap' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLength'], - 'DOMCharacterData' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castCharacterData'], - 'DOMAttr' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castAttr'], - 'DOMElement' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castElement'], - 'DOMText' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castText'], - 'DOMTypeinfo' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castTypeinfo'], - 'DOMDomError' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDomError'], - 'DOMLocator' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castLocator'], - 'DOMDocumentType' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castDocumentType'], - 'DOMNotation' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castNotation'], - 'DOMEntity' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castEntity'], - 'DOMProcessingInstruction' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castProcessingInstruction'], - 'DOMXPath' => ['Symfony\Component\VarDumper\Caster\DOMCaster', 'castXPath'], - - 'XMLReader' => ['Symfony\Component\VarDumper\Caster\XmlReaderCaster', 'castXmlReader'], - - 'ErrorException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castErrorException'], - 'Exception' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castException'], - 'Error' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castError'], - 'Symfony\Component\DependencyInjection\ContainerInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Symfony\Component\EventDispatcher\EventDispatcherInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Symfony\Component\HttpClient\CurlHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], - 'Symfony\Component\HttpClient\NativeHttpClient' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClient'], - 'Symfony\Component\HttpClient\Response\CurlResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], - 'Symfony\Component\HttpClient\Response\NativeResponse' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castHttpClientResponse'], - 'Symfony\Component\HttpFoundation\Request' => ['Symfony\Component\VarDumper\Caster\SymfonyCaster', 'castRequest'], - 'Symfony\Component\VarDumper\Exception\ThrowingCasterException' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castThrowingCasterException'], - 'Symfony\Component\VarDumper\Caster\TraceStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castTraceStub'], - 'Symfony\Component\VarDumper\Caster\FrameStub' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castFrameStub'], - 'Symfony\Component\VarDumper\Cloner\AbstractCloner' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Symfony\Component\ErrorHandler\Exception\SilencedErrorContext' => ['Symfony\Component\VarDumper\Caster\ExceptionCaster', 'castSilencedErrorContext'], - - 'Imagine\Image\ImageInterface' => ['Symfony\Component\VarDumper\Caster\ImagineCaster', 'castImage'], - - 'Ramsey\Uuid\UuidInterface' => ['Symfony\Component\VarDumper\Caster\UuidCaster', 'castRamseyUuid'], - - 'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'], - 'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'PHPUnit\Framework\MockObject\MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'PHPUnit\Framework\MockObject\Stub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Prophecy\Prophecy\ProphecySubjectInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - 'Mockery\MockInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'], - - 'PDO' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdo'], - 'PDOStatement' => ['Symfony\Component\VarDumper\Caster\PdoCaster', 'castPdoStatement'], - - 'AMQPConnection' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castConnection'], - 'AMQPChannel' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castChannel'], - 'AMQPQueue' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castQueue'], - 'AMQPExchange' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castExchange'], - 'AMQPEnvelope' => ['Symfony\Component\VarDumper\Caster\AmqpCaster', 'castEnvelope'], - - 'ArrayObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayObject'], - 'ArrayIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castArrayIterator'], - 'SplDoublyLinkedList' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castDoublyLinkedList'], - 'SplFileInfo' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileInfo'], - 'SplFileObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileObject'], - 'SplHeap' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'], - 'SplObjectStorage' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castObjectStorage'], - 'SplPriorityQueue' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'], - 'OuterIterator' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castOuterIterator'], - 'WeakReference' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castWeakReference'], - - 'Redis' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedis'], - 'RedisArray' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisArray'], - 'RedisCluster' => ['Symfony\Component\VarDumper\Caster\RedisCaster', 'castRedisCluster'], - - 'DateTimeInterface' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castDateTime'], - 'DateInterval' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castInterval'], - 'DateTimeZone' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castTimeZone'], - 'DatePeriod' => ['Symfony\Component\VarDumper\Caster\DateCaster', 'castPeriod'], - - 'GMP' => ['Symfony\Component\VarDumper\Caster\GmpCaster', 'castGmp'], - - 'MessageFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castMessageFormatter'], - 'NumberFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castNumberFormatter'], - 'IntlTimeZone' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlTimeZone'], - 'IntlCalendar' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlCalendar'], - 'IntlDateFormatter' => ['Symfony\Component\VarDumper\Caster\IntlCaster', 'castIntlDateFormatter'], - - 'Memcached' => ['Symfony\Component\VarDumper\Caster\MemcachedCaster', 'castMemcached'], - - 'Ds\Collection' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castCollection'], - 'Ds\Map' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castMap'], - 'Ds\Pair' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPair'], - 'Symfony\Component\VarDumper\Caster\DsPairStub' => ['Symfony\Component\VarDumper\Caster\DsCaster', 'castPairStub'], - - 'mysqli_driver' => ['Symfony\Component\VarDumper\Caster\MysqliCaster', 'castMysqliDriver'], - - 'CurlHandle' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'], - ':curl' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castCurl'], - - ':dba' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'], - ':dba persistent' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castDba'], - - 'GdImage' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'], - ':gd' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castGd'], - - ':mysql link' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castMysqlLink'], - ':pgsql large object' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLargeObject'], - ':pgsql link' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'], - ':pgsql link persistent' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castLink'], - ':pgsql result' => ['Symfony\Component\VarDumper\Caster\PgSqlCaster', 'castResult'], - ':process' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castProcess'], - ':stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'], - - 'OpenSSLCertificate' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'], - ':OpenSSL X.509' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castOpensslX509'], - - ':persistent stream' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStream'], - ':stream-context' => ['Symfony\Component\VarDumper\Caster\ResourceCaster', 'castStreamContext'], - - 'XmlParser' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'], - ':xml' => ['Symfony\Component\VarDumper\Caster\XmlResourceCaster', 'castXml'], - ]; - - protected $maxItems = 2500; - protected $maxString = -1; - protected $minDepth = 1; - - private $casters = []; - private $prevErrorHandler; - private $classInfo = []; - private $filter = 0; - - /** - * @param callable[]|null $casters A map of casters - * - * @see addCasters - */ - public function __construct(array $casters = null) - { - if (null === $casters) { - $casters = static::$defaultCasters; - } - $this->addCasters($casters); - } - - /** - * Adds casters for resources and objects. - * - * Maps resources or objects types to a callback. - * Types are in the key, with a callable caster for value. - * Resource types are to be prefixed with a `:`, - * see e.g. static::$defaultCasters. - * - * @param callable[] $casters A map of casters - */ - public function addCasters(array $casters) - { - foreach ($casters as $type => $callback) { - $this->casters[$type][] = $callback; - } - } - - /** - * Sets the maximum number of items to clone past the minimum depth in nested structures. - * - * @param int $maxItems - */ - public function setMaxItems($maxItems) - { - $this->maxItems = (int) $maxItems; - } - - /** - * Sets the maximum cloned length for strings. - * - * @param int $maxString - */ - public function setMaxString($maxString) - { - $this->maxString = (int) $maxString; - } - - /** - * Sets the minimum tree depth where we are guaranteed to clone all the items. After this - * depth is reached, only setMaxItems items will be cloned. - * - * @param int $minDepth - */ - public function setMinDepth($minDepth) - { - $this->minDepth = (int) $minDepth; - } - - /** - * Clones a PHP variable. - * - * @param mixed $var Any PHP variable - * @param int $filter A bit field of Caster::EXCLUDE_* constants - * - * @return Data The cloned variable represented by a Data object - */ - public function cloneVar($var, $filter = 0) - { - $this->prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) { - if (\E_RECOVERABLE_ERROR === $type || \E_USER_ERROR === $type) { - // Cloner never dies - throw new \ErrorException($msg, 0, $type, $file, $line); - } - - if ($this->prevErrorHandler) { - return ($this->prevErrorHandler)($type, $msg, $file, $line, $context); - } - - return false; - }); - $this->filter = $filter; - - if ($gc = gc_enabled()) { - gc_disable(); - } - try { - return new Data($this->doClone($var)); - } finally { - if ($gc) { - gc_enable(); - } - restore_error_handler(); - $this->prevErrorHandler = null; - } - } - - /** - * Effectively clones the PHP variable. - * - * @param mixed $var Any PHP variable - * - * @return array The cloned variable represented in an array - */ - abstract protected function doClone($var); - - /** - * Casts an object to an array representation. - * - * @param bool $isNested True if the object is nested in the dumped structure - * - * @return array The object casted as array - */ - protected function castObject(Stub $stub, $isNested) - { - $obj = $stub->value; - $class = $stub->class; - - if (\PHP_VERSION_ID < 80000 ? "\0" === ($class[15] ?? null) : str_contains($class, "@anonymous\0")) { - $stub->class = get_debug_type($obj); - } - if (isset($this->classInfo[$class])) { - [$i, $parents, $hasDebugInfo, $fileInfo] = $this->classInfo[$class]; - } else { - $i = 2; - $parents = [$class]; - $hasDebugInfo = method_exists($class, '__debugInfo'); - - foreach (class_parents($class) as $p) { - $parents[] = $p; - ++$i; - } - foreach (class_implements($class) as $p) { - $parents[] = $p; - ++$i; - } - $parents[] = '*'; - - $r = new \ReflectionClass($class); - $fileInfo = $r->isInternal() || $r->isSubclassOf(Stub::class) ? [] : [ - 'file' => $r->getFileName(), - 'line' => $r->getStartLine(), - ]; - - $this->classInfo[$class] = [$i, $parents, $hasDebugInfo, $fileInfo]; - } - - $stub->attr += $fileInfo; - $a = Caster::castObject($obj, $class, $hasDebugInfo, $stub->class); - - try { - while ($i--) { - if (!empty($this->casters[$p = $parents[$i]])) { - foreach ($this->casters[$p] as $callback) { - $a = $callback($obj, $a, $stub, $isNested, $this->filter); - } - } - } - } catch (\Exception $e) { - $a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a; - } - - return $a; - } - - /** - * Casts a resource to an array representation. - * - * @param bool $isNested True if the object is nested in the dumped structure - * - * @return array The resource casted as array - */ - protected function castResource(Stub $stub, $isNested) - { - $a = []; - $res = $stub->value; - $type = $stub->class; - - try { - if (!empty($this->casters[':'.$type])) { - foreach ($this->casters[':'.$type] as $callback) { - $a = $callback($res, $a, $stub, $isNested, $this->filter); - } - } - } catch (\Exception $e) { - $a = [(Stub::TYPE_OBJECT === $stub->type ? Caster::PREFIX_VIRTUAL : '').'⚠' => new ThrowingCasterException($e)] + $a; - } - - return $a; - } -} diff --git a/vendor/symfony/var-dumper/Cloner/ClonerInterface.php b/vendor/symfony/var-dumper/Cloner/ClonerInterface.php deleted file mode 100644 index 7ed287a..0000000 --- a/vendor/symfony/var-dumper/Cloner/ClonerInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -/** - * @author Nicolas Grekas - */ -interface ClonerInterface -{ - /** - * Clones a PHP variable. - * - * @param mixed $var Any PHP variable - * - * @return Data The cloned variable represented by a Data object - */ - public function cloneVar($var); -} diff --git a/vendor/symfony/var-dumper/Cloner/Cursor.php b/vendor/symfony/var-dumper/Cloner/Cursor.php deleted file mode 100644 index 1fd796d..0000000 --- a/vendor/symfony/var-dumper/Cloner/Cursor.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -/** - * Represents the current state of a dumper while dumping. - * - * @author Nicolas Grekas - */ -class Cursor -{ - public const HASH_INDEXED = Stub::ARRAY_INDEXED; - public const HASH_ASSOC = Stub::ARRAY_ASSOC; - public const HASH_OBJECT = Stub::TYPE_OBJECT; - public const HASH_RESOURCE = Stub::TYPE_RESOURCE; - - public $depth = 0; - public $refIndex = 0; - public $softRefTo = 0; - public $softRefCount = 0; - public $softRefHandle = 0; - public $hardRefTo = 0; - public $hardRefCount = 0; - public $hardRefHandle = 0; - public $hashType; - public $hashKey; - public $hashKeyIsBinary; - public $hashIndex = 0; - public $hashLength = 0; - public $hashCut = 0; - public $stop = false; - public $attr = []; - public $skipChildren = false; -} diff --git a/vendor/symfony/var-dumper/Cloner/Data.php b/vendor/symfony/var-dumper/Cloner/Data.php deleted file mode 100644 index 8f621b1..0000000 --- a/vendor/symfony/var-dumper/Cloner/Data.php +++ /dev/null @@ -1,470 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -use Symfony\Component\VarDumper\Caster\Caster; -use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider; - -/** - * @author Nicolas Grekas - */ -class Data implements \ArrayAccess, \Countable, \IteratorAggregate -{ - private $data; - private $position = 0; - private $key = 0; - private $maxDepth = 20; - private $maxItemsPerDepth = -1; - private $useRefHandles = -1; - private $context = []; - - /** - * @param array $data An array as returned by ClonerInterface::cloneVar() - */ - public function __construct(array $data) - { - $this->data = $data; - } - - /** - * @return string|null The type of the value - */ - public function getType() - { - $item = $this->data[$this->position][$this->key]; - - if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { - $item = $item->value; - } - if (!$item instanceof Stub) { - return \gettype($item); - } - if (Stub::TYPE_STRING === $item->type) { - return 'string'; - } - if (Stub::TYPE_ARRAY === $item->type) { - return 'array'; - } - if (Stub::TYPE_OBJECT === $item->type) { - return $item->class; - } - if (Stub::TYPE_RESOURCE === $item->type) { - return $item->class.' resource'; - } - - return null; - } - - /** - * @param array|bool $recursive Whether values should be resolved recursively or not - * - * @return string|int|float|bool|array|Data[]|null A native representation of the original value - */ - public function getValue($recursive = false) - { - $item = $this->data[$this->position][$this->key]; - - if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { - $item = $item->value; - } - if (!($item = $this->getStub($item)) instanceof Stub) { - return $item; - } - if (Stub::TYPE_STRING === $item->type) { - return $item->value; - } - - $children = $item->position ? $this->data[$item->position] : []; - - foreach ($children as $k => $v) { - if ($recursive && !($v = $this->getStub($v)) instanceof Stub) { - continue; - } - $children[$k] = clone $this; - $children[$k]->key = $k; - $children[$k]->position = $item->position; - - if ($recursive) { - if (Stub::TYPE_REF === $v->type && ($v = $this->getStub($v->value)) instanceof Stub) { - $recursive = (array) $recursive; - if (isset($recursive[$v->position])) { - continue; - } - $recursive[$v->position] = true; - } - $children[$k] = $children[$k]->getValue($recursive); - } - } - - return $children; - } - - /** - * @return int - */ - #[\ReturnTypeWillChange] - public function count() - { - return \count($this->getValue()); - } - - /** - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() - { - if (!\is_array($value = $this->getValue())) { - throw new \LogicException(sprintf('"%s" object holds non-iterable type "%s".', self::class, \gettype($value))); - } - - yield from $value; - } - - public function __get($key) - { - if (null !== $data = $this->seek($key)) { - $item = $this->getStub($data->data[$data->position][$data->key]); - - return $item instanceof Stub || [] === $item ? $data : $item; - } - - return null; - } - - /** - * @return bool - */ - public function __isset($key) - { - return null !== $this->seek($key); - } - - /** - * @return bool - */ - #[\ReturnTypeWillChange] - public function offsetExists($key) - { - return $this->__isset($key); - } - - /** - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet($key) - { - return $this->__get($key); - } - - /** - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetSet($key, $value) - { - throw new \BadMethodCallException(self::class.' objects are immutable.'); - } - - /** - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetUnset($key) - { - throw new \BadMethodCallException(self::class.' objects are immutable.'); - } - - /** - * @return string - */ - public function __toString() - { - $value = $this->getValue(); - - if (!\is_array($value)) { - return (string) $value; - } - - return sprintf('%s (count=%d)', $this->getType(), \count($value)); - } - - /** - * Returns a depth limited clone of $this. - * - * @param int $maxDepth The max dumped depth level - * - * @return static - */ - public function withMaxDepth($maxDepth) - { - $data = clone $this; - $data->maxDepth = (int) $maxDepth; - - return $data; - } - - /** - * Limits the number of elements per depth level. - * - * @param int $maxItemsPerDepth The max number of items dumped per depth level - * - * @return static - */ - public function withMaxItemsPerDepth($maxItemsPerDepth) - { - $data = clone $this; - $data->maxItemsPerDepth = (int) $maxItemsPerDepth; - - return $data; - } - - /** - * Enables/disables objects' identifiers tracking. - * - * @param bool $useRefHandles False to hide global ref. handles - * - * @return static - */ - public function withRefHandles($useRefHandles) - { - $data = clone $this; - $data->useRefHandles = $useRefHandles ? -1 : 0; - - return $data; - } - - /** - * @return static - */ - public function withContext(array $context) - { - $data = clone $this; - $data->context = $context; - - return $data; - } - - /** - * Seeks to a specific key in nested data structures. - * - * @param string|int $key The key to seek to - * - * @return static|null Null if the key is not set - */ - public function seek($key) - { - $item = $this->data[$this->position][$this->key]; - - if ($item instanceof Stub && Stub::TYPE_REF === $item->type && !$item->position) { - $item = $item->value; - } - if (!($item = $this->getStub($item)) instanceof Stub || !$item->position) { - return null; - } - $keys = [$key]; - - switch ($item->type) { - case Stub::TYPE_OBJECT: - $keys[] = Caster::PREFIX_DYNAMIC.$key; - $keys[] = Caster::PREFIX_PROTECTED.$key; - $keys[] = Caster::PREFIX_VIRTUAL.$key; - $keys[] = "\0$item->class\0$key"; - // no break - case Stub::TYPE_ARRAY: - case Stub::TYPE_RESOURCE: - break; - default: - return null; - } - - $data = null; - $children = $this->data[$item->position]; - - foreach ($keys as $key) { - if (isset($children[$key]) || \array_key_exists($key, $children)) { - $data = clone $this; - $data->key = $key; - $data->position = $item->position; - break; - } - } - - return $data; - } - - /** - * Dumps data with a DumperInterface dumper. - */ - public function dump(DumperInterface $dumper) - { - $refs = [0]; - $cursor = new Cursor(); - - if ($cursor->attr = $this->context[SourceContextProvider::class] ?? []) { - $cursor->attr['if_links'] = true; - $cursor->hashType = -1; - $dumper->dumpScalar($cursor, 'default', '^'); - $cursor->attr = ['if_links' => true]; - $dumper->dumpScalar($cursor, 'default', ' '); - $cursor->hashType = 0; - } - - $this->dumpItem($dumper, $cursor, $refs, $this->data[$this->position][$this->key]); - } - - /** - * Depth-first dumping of items. - * - * @param mixed $item A Stub object or the original value being dumped - */ - private function dumpItem(DumperInterface $dumper, Cursor $cursor, array &$refs, $item) - { - $cursor->refIndex = 0; - $cursor->softRefTo = $cursor->softRefHandle = $cursor->softRefCount = 0; - $cursor->hardRefTo = $cursor->hardRefHandle = $cursor->hardRefCount = 0; - $firstSeen = true; - - if (!$item instanceof Stub) { - $cursor->attr = []; - $type = \gettype($item); - if ($item && 'array' === $type) { - $item = $this->getStub($item); - } - } elseif (Stub::TYPE_REF === $item->type) { - if ($item->handle) { - if (!isset($refs[$r = $item->handle - (\PHP_INT_MAX >> 1)])) { - $cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0]; - } else { - $firstSeen = false; - } - $cursor->hardRefTo = $refs[$r]; - $cursor->hardRefHandle = $this->useRefHandles & $item->handle; - $cursor->hardRefCount = 0 < $item->handle ? $item->refCount : 0; - } - $cursor->attr = $item->attr; - $type = $item->class ?: \gettype($item->value); - $item = $this->getStub($item->value); - } - if ($item instanceof Stub) { - if ($item->refCount) { - if (!isset($refs[$r = $item->handle])) { - $cursor->refIndex = $refs[$r] = $cursor->refIndex ?: ++$refs[0]; - } else { - $firstSeen = false; - } - $cursor->softRefTo = $refs[$r]; - } - $cursor->softRefHandle = $this->useRefHandles & $item->handle; - $cursor->softRefCount = $item->refCount; - $cursor->attr = $item->attr; - $cut = $item->cut; - - if ($item->position && $firstSeen) { - $children = $this->data[$item->position]; - - if ($cursor->stop) { - if ($cut >= 0) { - $cut += \count($children); - } - $children = []; - } - } else { - $children = []; - } - switch ($item->type) { - case Stub::TYPE_STRING: - $dumper->dumpString($cursor, $item->value, Stub::STRING_BINARY === $item->class, $cut); - break; - - case Stub::TYPE_ARRAY: - $item = clone $item; - $item->type = $item->class; - $item->class = $item->value; - // no break - case Stub::TYPE_OBJECT: - case Stub::TYPE_RESOURCE: - $withChildren = $children && $cursor->depth !== $this->maxDepth && $this->maxItemsPerDepth; - $dumper->enterHash($cursor, $item->type, $item->class, $withChildren); - if ($withChildren) { - if ($cursor->skipChildren) { - $withChildren = false; - $cut = -1; - } else { - $cut = $this->dumpChildren($dumper, $cursor, $refs, $children, $cut, $item->type, null !== $item->class); - } - } elseif ($children && 0 <= $cut) { - $cut += \count($children); - } - $cursor->skipChildren = false; - $dumper->leaveHash($cursor, $item->type, $item->class, $withChildren, $cut); - break; - - default: - throw new \RuntimeException(sprintf('Unexpected Stub type: "%s".', $item->type)); - } - } elseif ('array' === $type) { - $dumper->enterHash($cursor, Cursor::HASH_INDEXED, 0, false); - $dumper->leaveHash($cursor, Cursor::HASH_INDEXED, 0, false, 0); - } elseif ('string' === $type) { - $dumper->dumpString($cursor, $item, false, 0); - } else { - $dumper->dumpScalar($cursor, $type, $item); - } - } - - /** - * Dumps children of hash structures. - * - * @return int The final number of removed items - */ - private function dumpChildren(DumperInterface $dumper, Cursor $parentCursor, array &$refs, array $children, int $hashCut, int $hashType, bool $dumpKeys): int - { - $cursor = clone $parentCursor; - ++$cursor->depth; - $cursor->hashType = $hashType; - $cursor->hashIndex = 0; - $cursor->hashLength = \count($children); - $cursor->hashCut = $hashCut; - foreach ($children as $key => $child) { - $cursor->hashKeyIsBinary = isset($key[0]) && !preg_match('//u', $key); - $cursor->hashKey = $dumpKeys ? $key : null; - $this->dumpItem($dumper, $cursor, $refs, $child); - if (++$cursor->hashIndex === $this->maxItemsPerDepth || $cursor->stop) { - $parentCursor->stop = true; - - return $hashCut >= 0 ? $hashCut + $cursor->hashLength - $cursor->hashIndex : $hashCut; - } - } - - return $hashCut; - } - - private function getStub($item) - { - if (!$item || !\is_array($item)) { - return $item; - } - - $stub = new Stub(); - $stub->type = Stub::TYPE_ARRAY; - foreach ($item as $stub->class => $stub->position) { - } - if (isset($item[0])) { - $stub->cut = $item[0]; - } - $stub->value = $stub->cut + ($stub->position ? \count($this->data[$stub->position]) : 0); - - return $stub; - } -} diff --git a/vendor/symfony/var-dumper/Cloner/DumperInterface.php b/vendor/symfony/var-dumper/Cloner/DumperInterface.php deleted file mode 100644 index ec8ef27..0000000 --- a/vendor/symfony/var-dumper/Cloner/DumperInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -/** - * DumperInterface used by Data objects. - * - * @author Nicolas Grekas - */ -interface DumperInterface -{ - /** - * Dumps a scalar value. - * - * @param string $type The PHP type of the value being dumped - * @param string|int|float|bool $value The scalar value being dumped - */ - public function dumpScalar(Cursor $cursor, $type, $value); - - /** - * Dumps a string. - * - * @param string $str The string being dumped - * @param bool $bin Whether $str is UTF-8 or binary encoded - * @param int $cut The number of characters $str has been cut by - */ - public function dumpString(Cursor $cursor, $str, $bin, $cut); - - /** - * Dumps while entering an hash. - * - * @param int $type A Cursor::HASH_* const for the type of hash - * @param string|int $class The object class, resource type or array count - * @param bool $hasChild When the dump of the hash has child item - */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild); - - /** - * Dumps while leaving an hash. - * - * @param int $type A Cursor::HASH_* const for the type of hash - * @param string|int $class The object class, resource type or array count - * @param bool $hasChild When the dump of the hash has child item - * @param int $cut The number of items the hash has been cut by - */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut); -} diff --git a/vendor/symfony/var-dumper/Cloner/Stub.php b/vendor/symfony/var-dumper/Cloner/Stub.php deleted file mode 100644 index 073c56e..0000000 --- a/vendor/symfony/var-dumper/Cloner/Stub.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -/** - * Represents the main properties of a PHP variable. - * - * @author Nicolas Grekas - */ -class Stub -{ - public const TYPE_REF = 1; - public const TYPE_STRING = 2; - public const TYPE_ARRAY = 3; - public const TYPE_OBJECT = 4; - public const TYPE_RESOURCE = 5; - - public const STRING_BINARY = 1; - public const STRING_UTF8 = 2; - - public const ARRAY_ASSOC = 1; - public const ARRAY_INDEXED = 2; - - public $type = self::TYPE_REF; - public $class = ''; - public $value; - public $cut = 0; - public $handle = 0; - public $refCount = 0; - public $position = 0; - public $attr = []; - - private static $defaultProperties = []; - - /** - * @internal - */ - public function __sleep(): array - { - $properties = []; - - if (!isset(self::$defaultProperties[$c = static::class])) { - self::$defaultProperties[$c] = get_class_vars($c); - - foreach ((new \ReflectionClass($c))->getStaticProperties() as $k => $v) { - unset(self::$defaultProperties[$c][$k]); - } - } - - foreach (self::$defaultProperties[$c] as $k => $v) { - if ($this->$k !== $v) { - $properties[] = $k; - } - } - - return $properties; - } -} diff --git a/vendor/symfony/var-dumper/Cloner/VarCloner.php b/vendor/symfony/var-dumper/Cloner/VarCloner.php deleted file mode 100644 index cd6e7dc..0000000 --- a/vendor/symfony/var-dumper/Cloner/VarCloner.php +++ /dev/null @@ -1,324 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Cloner; - -/** - * @author Nicolas Grekas - */ -class VarCloner extends AbstractCloner -{ - private static $gid; - private static $arrayCache = []; - - /** - * {@inheritdoc} - */ - protected function doClone($var) - { - $len = 1; // Length of $queue - $pos = 0; // Number of cloned items past the minimum depth - $refsCounter = 0; // Hard references counter - $queue = [[$var]]; // This breadth-first queue is the return value - $indexedArrays = []; // Map of queue indexes that hold numerically indexed arrays - $hardRefs = []; // Map of original zval ids to stub objects - $objRefs = []; // Map of original object handles to their stub object counterpart - $objects = []; // Keep a ref to objects to ensure their handle cannot be reused while cloning - $resRefs = []; // Map of original resource handles to their stub object counterpart - $values = []; // Map of stub objects' ids to original values - $maxItems = $this->maxItems; - $maxString = $this->maxString; - $minDepth = $this->minDepth; - $currentDepth = 0; // Current tree depth - $currentDepthFinalIndex = 0; // Final $queue index for current tree depth - $minimumDepthReached = 0 === $minDepth; // Becomes true when minimum tree depth has been reached - $cookie = (object) []; // Unique object used to detect hard references - $a = null; // Array cast for nested structures - $stub = null; // Stub capturing the main properties of an original item value - // or null if the original value is used directly - - if (!$gid = self::$gid) { - $gid = self::$gid = md5(random_bytes(6)); // Unique string used to detect the special $GLOBALS variable - } - $arrayStub = new Stub(); - $arrayStub->type = Stub::TYPE_ARRAY; - $fromObjCast = false; - - for ($i = 0; $i < $len; ++$i) { - // Detect when we move on to the next tree depth - if ($i > $currentDepthFinalIndex) { - ++$currentDepth; - $currentDepthFinalIndex = $len - 1; - if ($currentDepth >= $minDepth) { - $minimumDepthReached = true; - } - } - - $refs = $vals = $queue[$i]; - if (\PHP_VERSION_ID < 70200 && empty($indexedArrays[$i])) { - // see https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts - foreach ($vals as $k => $v) { - if (\is_int($k)) { - continue; - } - foreach ([$k => true] as $gk => $gv) { - } - if ($gk !== $k) { - $fromObjCast = true; - $refs = $vals = array_values($queue[$i]); - break; - } - } - } - foreach ($vals as $k => $v) { - // $v is the original value or a stub object in case of hard references - - if (\PHP_VERSION_ID >= 70400) { - $zvalRef = ($r = \ReflectionReference::fromArrayElement($vals, $k)) ? $r->getId() : null; - } else { - $refs[$k] = $cookie; - $zvalRef = $vals[$k] === $cookie; - } - - if ($zvalRef) { - $vals[$k] = &$stub; // Break hard references to make $queue completely - unset($stub); // independent from the original structure - if (\PHP_VERSION_ID >= 70400 ? null !== $vals[$k] = $hardRefs[$zvalRef] ?? null : $v instanceof Stub && isset($hardRefs[spl_object_id($v)])) { - if (\PHP_VERSION_ID >= 70400) { - $v = $vals[$k]; - } else { - $refs[$k] = $vals[$k] = $v; - } - if ($v->value instanceof Stub && (Stub::TYPE_OBJECT === $v->value->type || Stub::TYPE_RESOURCE === $v->value->type)) { - ++$v->value->refCount; - } - ++$v->refCount; - continue; - } - $vals[$k] = new Stub(); - $vals[$k]->value = $v; - $vals[$k]->handle = ++$refsCounter; - - if (\PHP_VERSION_ID >= 70400) { - $hardRefs[$zvalRef] = $vals[$k]; - } else { - $refs[$k] = $vals[$k]; - $h = spl_object_id($refs[$k]); - $hardRefs[$h] = &$refs[$k]; - $values[$h] = $v; - } - } - // Create $stub when the original value $v can not be used directly - // If $v is a nested structure, put that structure in array $a - switch (true) { - case null === $v: - case \is_bool($v): - case \is_int($v): - case \is_float($v): - continue 2; - case \is_string($v): - if ('' === $v) { - continue 2; - } - if (!preg_match('//u', $v)) { - $stub = new Stub(); - $stub->type = Stub::TYPE_STRING; - $stub->class = Stub::STRING_BINARY; - if (0 <= $maxString && 0 < $cut = \strlen($v) - $maxString) { - $stub->cut = $cut; - $stub->value = substr($v, 0, -$cut); - } else { - $stub->value = $v; - } - } elseif (0 <= $maxString && isset($v[1 + ($maxString >> 2)]) && 0 < $cut = mb_strlen($v, 'UTF-8') - $maxString) { - $stub = new Stub(); - $stub->type = Stub::TYPE_STRING; - $stub->class = Stub::STRING_UTF8; - $stub->cut = $cut; - $stub->value = mb_substr($v, 0, $maxString, 'UTF-8'); - } else { - continue 2; - } - $a = null; - break; - - case \is_array($v): - if (!$v) { - continue 2; - } - $stub = $arrayStub; - $stub->class = Stub::ARRAY_INDEXED; - - $j = -1; - foreach ($v as $gk => $gv) { - if ($gk !== ++$j) { - $stub->class = Stub::ARRAY_ASSOC; - break; - } - } - $a = $v; - - if (Stub::ARRAY_ASSOC === $stub->class) { - // Copies of $GLOBALS have very strange behavior, - // let's detect them with some black magic - if (\PHP_VERSION_ID < 80100 && ($a[$gid] = true) && isset($v[$gid])) { - unset($v[$gid]); - $a = []; - foreach ($v as $gk => &$gv) { - if ($v === $gv && (\PHP_VERSION_ID < 70400 || !isset($hardRefs[\ReflectionReference::fromArrayElement($v, $gk)->getId()]))) { - unset($v); - $v = new Stub(); - $v->value = [$v->cut = \count($gv), Stub::TYPE_ARRAY => 0]; - $v->handle = -1; - if (\PHP_VERSION_ID >= 70400) { - $gv = &$a[$gk]; - $hardRefs[\ReflectionReference::fromArrayElement($a, $gk)->getId()] = &$gv; - } else { - $gv = &$hardRefs[spl_object_id($v)]; - } - $gv = $v; - } - - $a[$gk] = &$gv; - } - unset($gv); - } else { - $a = $v; - } - } elseif (\PHP_VERSION_ID < 70200) { - $indexedArrays[$len] = true; - } - break; - - case \is_object($v): - case $v instanceof \__PHP_Incomplete_Class: - if (empty($objRefs[$h = spl_object_id($v)])) { - $stub = new Stub(); - $stub->type = Stub::TYPE_OBJECT; - $stub->class = \get_class($v); - $stub->value = $v; - $stub->handle = $h; - $a = $this->castObject($stub, 0 < $i); - if ($v !== $stub->value) { - if (Stub::TYPE_OBJECT !== $stub->type || null === $stub->value) { - break; - } - $stub->handle = $h = spl_object_id($stub->value); - } - $stub->value = null; - if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) { - $stub->cut = \count($a); - $a = null; - } - } - if (empty($objRefs[$h])) { - $objRefs[$h] = $stub; - $objects[] = $v; - } else { - $stub = $objRefs[$h]; - ++$stub->refCount; - $a = null; - } - break; - - default: // resource - if (empty($resRefs[$h = (int) $v])) { - $stub = new Stub(); - $stub->type = Stub::TYPE_RESOURCE; - if ('Unknown' === $stub->class = @get_resource_type($v)) { - $stub->class = 'Closed'; - } - $stub->value = $v; - $stub->handle = $h; - $a = $this->castResource($stub, 0 < $i); - $stub->value = null; - if (0 <= $maxItems && $maxItems <= $pos && $minimumDepthReached) { - $stub->cut = \count($a); - $a = null; - } - } - if (empty($resRefs[$h])) { - $resRefs[$h] = $stub; - } else { - $stub = $resRefs[$h]; - ++$stub->refCount; - $a = null; - } - break; - } - - if ($a) { - if (!$minimumDepthReached || 0 > $maxItems) { - $queue[$len] = $a; - $stub->position = $len++; - } elseif ($pos < $maxItems) { - if ($maxItems < $pos += \count($a)) { - $a = \array_slice($a, 0, $maxItems - $pos, true); - if ($stub->cut >= 0) { - $stub->cut += $pos - $maxItems; - } - } - $queue[$len] = $a; - $stub->position = $len++; - } elseif ($stub->cut >= 0) { - $stub->cut += \count($a); - $stub->position = 0; - } - } - - if ($arrayStub === $stub) { - if ($arrayStub->cut) { - $stub = [$arrayStub->cut, $arrayStub->class => $arrayStub->position]; - $arrayStub->cut = 0; - } elseif (isset(self::$arrayCache[$arrayStub->class][$arrayStub->position])) { - $stub = self::$arrayCache[$arrayStub->class][$arrayStub->position]; - } else { - self::$arrayCache[$arrayStub->class][$arrayStub->position] = $stub = [$arrayStub->class => $arrayStub->position]; - } - } - - if (!$zvalRef) { - $vals[$k] = $stub; - } elseif (\PHP_VERSION_ID >= 70400) { - $hardRefs[$zvalRef]->value = $stub; - } else { - $refs[$k]->value = $stub; - } - } - - if ($fromObjCast) { - $fromObjCast = false; - $refs = $vals; - $vals = []; - $j = -1; - foreach ($queue[$i] as $k => $v) { - foreach ([$k => true] as $gk => $gv) { - } - if ($gk !== $k) { - $vals = (object) $vals; - $vals->{$k} = $refs[++$j]; - $vals = (array) $vals; - } else { - $vals[$k] = $refs[++$j]; - } - } - } - - $queue[$i] = $vals; - } - - foreach ($values as $h => $v) { - $hardRefs[$h] = $v; - } - - return $queue; - } -} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php b/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php deleted file mode 100644 index 7d9ec0e..0000000 --- a/vendor/symfony/var-dumper/Command/Descriptor/CliDescriptor.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Command\Descriptor; - -use Symfony\Component\Console\Formatter\OutputFormatterStyle; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\CliDumper; - -/** - * Describe collected data clones for cli output. - * - * @author Maxime Steinhausser - * - * @final - */ -class CliDescriptor implements DumpDescriptorInterface -{ - private $dumper; - private $lastIdentifier; - private $supportsHref; - - public function __construct(CliDumper $dumper) - { - $this->dumper = $dumper; - $this->supportsHref = method_exists(OutputFormatterStyle::class, 'setHref'); - } - - public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void - { - $io = $output instanceof SymfonyStyle ? $output : new SymfonyStyle(new ArrayInput([]), $output); - $this->dumper->setColors($output->isDecorated()); - - $rows = [['date', date('r', (int) $context['timestamp'])]]; - $lastIdentifier = $this->lastIdentifier; - $this->lastIdentifier = $clientId; - - $section = "Received from client #$clientId"; - if (isset($context['request'])) { - $request = $context['request']; - $this->lastIdentifier = $request['identifier']; - $section = sprintf('%s %s', $request['method'], $request['uri']); - if ($controller = $request['controller']) { - $rows[] = ['controller', rtrim($this->dumper->dump($controller, true), "\n")]; - } - } elseif (isset($context['cli'])) { - $this->lastIdentifier = $context['cli']['identifier']; - $section = '$ '.$context['cli']['command_line']; - } - - if ($this->lastIdentifier !== $lastIdentifier) { - $io->section($section); - } - - if (isset($context['source'])) { - $source = $context['source']; - $sourceInfo = sprintf('%s on line %d', $source['name'], $source['line']); - $fileLink = $source['file_link'] ?? null; - if ($this->supportsHref && $fileLink) { - $sourceInfo = sprintf('%s', $fileLink, $sourceInfo); - } - $rows[] = ['source', $sourceInfo]; - $file = $source['file_relative'] ?? $source['file']; - $rows[] = ['file', $file]; - } - - $io->table([], $rows); - - if (!$this->supportsHref && isset($fileLink)) { - $io->writeln(['Open source in your IDE/browser:', $fileLink]); - $io->newLine(); - } - - $this->dumper->dump($data); - $io->newLine(); - } -} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php b/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php deleted file mode 100644 index 267d27b..0000000 --- a/vendor/symfony/var-dumper/Command/Descriptor/DumpDescriptorInterface.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Command\Descriptor; - -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\VarDumper\Cloner\Data; - -/** - * @author Maxime Steinhausser - */ -interface DumpDescriptorInterface -{ - public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void; -} diff --git a/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php b/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php deleted file mode 100644 index 636b618..0000000 --- a/vendor/symfony/var-dumper/Command/Descriptor/HtmlDescriptor.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Command\Descriptor; - -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; - -/** - * Describe collected data clones for html output. - * - * @author Maxime Steinhausser - * - * @final - */ -class HtmlDescriptor implements DumpDescriptorInterface -{ - private $dumper; - private $initialized = false; - - public function __construct(HtmlDumper $dumper) - { - $this->dumper = $dumper; - } - - public function describe(OutputInterface $output, Data $data, array $context, int $clientId): void - { - if (!$this->initialized) { - $styles = file_get_contents(__DIR__.'/../../Resources/css/htmlDescriptor.css'); - $scripts = file_get_contents(__DIR__.'/../../Resources/js/htmlDescriptor.js'); - $output->writeln(""); - $this->initialized = true; - } - - $title = '-'; - if (isset($context['request'])) { - $request = $context['request']; - $controller = "{$this->dumper->dump($request['controller'], true, ['maxDepth' => 0])}"; - $title = sprintf('%s %s', $request['method'], $uri = $request['uri'], $uri); - $dedupIdentifier = $request['identifier']; - } elseif (isset($context['cli'])) { - $title = '$ '.$context['cli']['command_line']; - $dedupIdentifier = $context['cli']['identifier']; - } else { - $dedupIdentifier = uniqid('', true); - } - - $sourceDescription = ''; - if (isset($context['source'])) { - $source = $context['source']; - $projectDir = $source['project_dir'] ?? null; - $sourceDescription = sprintf('%s on line %d', $source['name'], $source['line']); - if (isset($source['file_link'])) { - $sourceDescription = sprintf('%s', $source['file_link'], $sourceDescription); - } - } - - $isoDate = $this->extractDate($context, 'c'); - $tags = array_filter([ - 'controller' => $controller ?? null, - 'project dir' => $projectDir ?? null, - ]); - - $output->writeln(<< -
-
-

$title

- -
- {$this->renderTags($tags)} -
-
-

- $sourceDescription -

- {$this->dumper->dump($data, true)} -
- -HTML - ); - } - - private function extractDate(array $context, string $format = 'r'): string - { - return date($format, (int) $context['timestamp']); - } - - private function renderTags(array $tags): string - { - if (!$tags) { - return ''; - } - - $renderedTags = ''; - foreach ($tags as $key => $value) { - $renderedTags .= sprintf('
  • %s%s
  • ', $key, $value); - } - - return << -
      - $renderedTags -
    -
    -HTML; - } -} diff --git a/vendor/symfony/var-dumper/Command/ServerDumpCommand.php b/vendor/symfony/var-dumper/Command/ServerDumpCommand.php deleted file mode 100644 index b66301b..0000000 --- a/vendor/symfony/var-dumper/Command/ServerDumpCommand.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Command; - -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Exception\InvalidArgumentException; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Command\Descriptor\CliDescriptor; -use Symfony\Component\VarDumper\Command\Descriptor\DumpDescriptorInterface; -use Symfony\Component\VarDumper\Command\Descriptor\HtmlDescriptor; -use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; -use Symfony\Component\VarDumper\Server\DumpServer; - -/** - * Starts a dump server to collect and output dumps on a single place with multiple formats support. - * - * @author Maxime Steinhausser - * - * @final - */ -class ServerDumpCommand extends Command -{ - protected static $defaultName = 'server:dump'; - - private $server; - - /** @var DumpDescriptorInterface[] */ - private $descriptors; - - public function __construct(DumpServer $server, array $descriptors = []) - { - $this->server = $server; - $this->descriptors = $descriptors + [ - 'cli' => new CliDescriptor(new CliDumper()), - 'html' => new HtmlDescriptor(new HtmlDumper()), - ]; - - parent::__construct(); - } - - protected function configure() - { - $availableFormats = implode(', ', array_keys($this->descriptors)); - - $this - ->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format (%s)', $availableFormats), 'cli') - ->setDescription('Start a dump server that collects and displays dumps in a single place') - ->setHelp(<<<'EOF' -%command.name% starts a dump server that collects and displays -dumps in a single place for debugging you application: - - php %command.full_name% - -You can consult dumped data in HTML format in your browser by providing the --format=html option -and redirecting the output to a file: - - php %command.full_name% --format="html" > dump.html - -EOF - ) - ; - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = new SymfonyStyle($input, $output); - $format = $input->getOption('format'); - - if (!$descriptor = $this->descriptors[$format] ?? null) { - throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $format)); - } - - $errorIo = $io->getErrorStyle(); - $errorIo->title('Symfony Var Dumper Server'); - - $this->server->start(); - - $errorIo->success(sprintf('Server listening on %s', $this->server->getHost())); - $errorIo->comment('Quit the server with CONTROL-C.'); - - $this->server->listen(function (Data $data, array $context, int $clientId) use ($descriptor, $io) { - $descriptor->describe($io, $data, $context, $clientId); - }); - - return 0; - } -} diff --git a/vendor/symfony/var-dumper/Dumper/AbstractDumper.php b/vendor/symfony/var-dumper/Dumper/AbstractDumper.php deleted file mode 100644 index 4185329..0000000 --- a/vendor/symfony/var-dumper/Dumper/AbstractDumper.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\DumperInterface; - -/** - * Abstract mechanism for dumping a Data object. - * - * @author Nicolas Grekas - */ -abstract class AbstractDumper implements DataDumperInterface, DumperInterface -{ - public const DUMP_LIGHT_ARRAY = 1; - public const DUMP_STRING_LENGTH = 2; - public const DUMP_COMMA_SEPARATOR = 4; - public const DUMP_TRAILING_COMMA = 8; - - public static $defaultOutput = 'php://output'; - - protected $line = ''; - protected $lineDumper; - protected $outputStream; - protected $decimalPoint; // This is locale dependent - protected $indentPad = ' '; - protected $flags; - - private $charset = ''; - - /** - * @param callable|resource|string|null $output A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput - * @param string|null $charset The default character encoding to use for non-UTF8 strings - * @param int $flags A bit field of static::DUMP_* constants to fine tune dumps representation - */ - public function __construct($output = null, string $charset = null, int $flags = 0) - { - $this->flags = $flags; - $this->setCharset($charset ?: \ini_get('php.output_encoding') ?: \ini_get('default_charset') ?: 'UTF-8'); - $this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point']; - $this->setOutput($output ?: static::$defaultOutput); - if (!$output && \is_string(static::$defaultOutput)) { - static::$defaultOutput = $this->outputStream; - } - } - - /** - * Sets the output destination of the dumps. - * - * @param callable|resource|string $output A line dumper callable, an opened stream or an output path - * - * @return callable|resource|string The previous output destination - */ - public function setOutput($output) - { - $prev = $this->outputStream ?? $this->lineDumper; - - if (\is_callable($output)) { - $this->outputStream = null; - $this->lineDumper = $output; - } else { - if (\is_string($output)) { - $output = fopen($output, 'w'); - } - $this->outputStream = $output; - $this->lineDumper = [$this, 'echoLine']; - } - - return $prev; - } - - /** - * Sets the default character encoding to use for non-UTF8 strings. - * - * @param string $charset The default character encoding to use for non-UTF8 strings - * - * @return string The previous charset - */ - public function setCharset($charset) - { - $prev = $this->charset; - - $charset = strtoupper($charset); - $charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset; - - $this->charset = $charset; - - return $prev; - } - - /** - * Sets the indentation pad string. - * - * @param string $pad A string that will be prepended to dumped lines, repeated by nesting level - * - * @return string The previous indent pad - */ - public function setIndentPad($pad) - { - $prev = $this->indentPad; - $this->indentPad = $pad; - - return $prev; - } - - /** - * Dumps a Data object. - * - * @param callable|resource|string|true|null $output A line dumper callable, an opened stream, an output path or true to return the dump - * - * @return string|null The dump as string when $output is true - */ - public function dump(Data $data, $output = null) - { - $this->decimalPoint = \PHP_VERSION_ID >= 80000 ? '.' : localeconv()['decimal_point']; - - if ($locale = $this->flags & (self::DUMP_COMMA_SEPARATOR | self::DUMP_TRAILING_COMMA) ? setlocale(\LC_NUMERIC, 0) : null) { - setlocale(\LC_NUMERIC, 'C'); - } - - if ($returnDump = true === $output) { - $output = fopen('php://memory', 'r+'); - } - if ($output) { - $prevOutput = $this->setOutput($output); - } - try { - $data->dump($this); - $this->dumpLine(-1); - - if ($returnDump) { - $result = stream_get_contents($output, -1, 0); - fclose($output); - - return $result; - } - } finally { - if ($output) { - $this->setOutput($prevOutput); - } - if ($locale) { - setlocale(\LC_NUMERIC, $locale); - } - } - - return null; - } - - /** - * Dumps the current line. - * - * @param int $depth The recursive depth in the dumped structure for the line being dumped, - * or -1 to signal the end-of-dump to the line dumper callable - */ - protected function dumpLine($depth) - { - ($this->lineDumper)($this->line, $depth, $this->indentPad); - $this->line = ''; - } - - /** - * Generic line dumper callback. - * - * @param string $line The line to write - * @param int $depth The recursive depth in the dumped structure - * @param string $indentPad The line indent pad - */ - protected function echoLine($line, $depth, $indentPad) - { - if (-1 !== $depth) { - fwrite($this->outputStream, str_repeat($indentPad, $depth).$line."\n"); - } - } - - /** - * Converts a non-UTF-8 string to UTF-8. - * - * @param string|null $s The non-UTF-8 string to convert - * - * @return string|null The string converted to UTF-8 - */ - protected function utf8Encode($s) - { - if (null === $s || preg_match('//u', $s)) { - return $s; - } - - if (!\function_exists('iconv')) { - throw new \RuntimeException('Unable to convert a non-UTF-8 string to UTF-8: required function iconv() does not exist. You should install ext-iconv or symfony/polyfill-iconv.'); - } - - if (false !== $c = @iconv($this->charset, 'UTF-8', $s)) { - return $c; - } - if ('CP1252' !== $this->charset && false !== $c = @iconv('CP1252', 'UTF-8', $s)) { - return $c; - } - - return iconv('CP850', 'UTF-8', $s); - } -} diff --git a/vendor/symfony/var-dumper/Dumper/CliDumper.php b/vendor/symfony/var-dumper/Dumper/CliDumper.php deleted file mode 100644 index e3861cd..0000000 --- a/vendor/symfony/var-dumper/Dumper/CliDumper.php +++ /dev/null @@ -1,655 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Cursor; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * CliDumper dumps variables for command line output. - * - * @author Nicolas Grekas - */ -class CliDumper extends AbstractDumper -{ - public static $defaultColors; - public static $defaultOutput = 'php://stdout'; - - protected $colors; - protected $maxStringWidth = 0; - protected $styles = [ - // See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics - 'default' => '0;38;5;208', - 'num' => '1;38;5;38', - 'const' => '1;38;5;208', - 'str' => '1;38;5;113', - 'note' => '38;5;38', - 'ref' => '38;5;247', - 'public' => '', - 'protected' => '', - 'private' => '', - 'meta' => '38;5;170', - 'key' => '38;5;113', - 'index' => '38;5;38', - ]; - - protected static $controlCharsRx = '/[\x00-\x1F\x7F]+/'; - protected static $controlCharsMap = [ - "\t" => '\t', - "\n" => '\n', - "\v" => '\v', - "\f" => '\f', - "\r" => '\r', - "\033" => '\e', - ]; - - protected $collapseNextHash = false; - protected $expandNextHash = false; - - private $displayOptions = [ - 'fileLinkFormat' => null, - ]; - - private $handlesHrefGracefully; - - /** - * {@inheritdoc} - */ - public function __construct($output = null, string $charset = null, int $flags = 0) - { - parent::__construct($output, $charset, $flags); - - if ('\\' === \DIRECTORY_SEPARATOR && !$this->isWindowsTrueColor()) { - // Use only the base 16 xterm colors when using ANSICON or standard Windows 10 CLI - $this->setStyles([ - 'default' => '31', - 'num' => '1;34', - 'const' => '1;31', - 'str' => '1;32', - 'note' => '34', - 'ref' => '1;30', - 'meta' => '35', - 'key' => '32', - 'index' => '34', - ]); - } - - $this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: 'file://%f#L%l'; - } - - /** - * Enables/disables colored output. - * - * @param bool $colors - */ - public function setColors($colors) - { - $this->colors = (bool) $colors; - } - - /** - * Sets the maximum number of characters per line for dumped strings. - * - * @param int $maxStringWidth - */ - public function setMaxStringWidth($maxStringWidth) - { - $this->maxStringWidth = (int) $maxStringWidth; - } - - /** - * Configures styles. - * - * @param array $styles A map of style names to style definitions - */ - public function setStyles(array $styles) - { - $this->styles = $styles + $this->styles; - } - - /** - * Configures display options. - * - * @param array $displayOptions A map of display options to customize the behavior - */ - public function setDisplayOptions(array $displayOptions) - { - $this->displayOptions = $displayOptions + $this->displayOptions; - } - - /** - * {@inheritdoc} - */ - public function dumpScalar(Cursor $cursor, $type, $value) - { - $this->dumpKey($cursor); - - $style = 'const'; - $attr = $cursor->attr; - - switch ($type) { - case 'default': - $style = 'default'; - break; - - case 'integer': - $style = 'num'; - break; - - case 'double': - $style = 'num'; - - switch (true) { - case \INF === $value: $value = 'INF'; break; - case -\INF === $value: $value = '-INF'; break; - case is_nan($value): $value = 'NAN'; break; - default: - $value = (string) $value; - if (!str_contains($value, $this->decimalPoint)) { - $value .= $this->decimalPoint.'0'; - } - break; - } - break; - - case 'NULL': - $value = 'null'; - break; - - case 'boolean': - $value = $value ? 'true' : 'false'; - break; - - default: - $attr += ['value' => $this->utf8Encode($value)]; - $value = $this->utf8Encode($type); - break; - } - - $this->line .= $this->style($style, $value, $attr); - - $this->endValue($cursor); - } - - /** - * {@inheritdoc} - */ - public function dumpString(Cursor $cursor, $str, $bin, $cut) - { - $this->dumpKey($cursor); - $attr = $cursor->attr; - - if ($bin) { - $str = $this->utf8Encode($str); - } - if ('' === $str) { - $this->line .= '""'; - $this->endValue($cursor); - } else { - $attr += [ - 'length' => 0 <= $cut ? mb_strlen($str, 'UTF-8') + $cut : 0, - 'binary' => $bin, - ]; - $str = explode("\n", $str); - if (isset($str[1]) && !isset($str[2]) && !isset($str[1][0])) { - unset($str[1]); - $str[0] .= "\n"; - } - $m = \count($str) - 1; - $i = $lineCut = 0; - - if (self::DUMP_STRING_LENGTH & $this->flags) { - $this->line .= '('.$attr['length'].') '; - } - if ($bin) { - $this->line .= 'b'; - } - - if ($m) { - $this->line .= '"""'; - $this->dumpLine($cursor->depth); - } else { - $this->line .= '"'; - } - - foreach ($str as $str) { - if ($i < $m) { - $str .= "\n"; - } - if (0 < $this->maxStringWidth && $this->maxStringWidth < $len = mb_strlen($str, 'UTF-8')) { - $str = mb_substr($str, 0, $this->maxStringWidth, 'UTF-8'); - $lineCut = $len - $this->maxStringWidth; - } - if ($m && 0 < $cursor->depth) { - $this->line .= $this->indentPad; - } - if ('' !== $str) { - $this->line .= $this->style('str', $str, $attr); - } - if ($i++ == $m) { - if ($m) { - if ('' !== $str) { - $this->dumpLine($cursor->depth); - if (0 < $cursor->depth) { - $this->line .= $this->indentPad; - } - } - $this->line .= '"""'; - } else { - $this->line .= '"'; - } - if ($cut < 0) { - $this->line .= '…'; - $lineCut = 0; - } elseif ($cut) { - $lineCut += $cut; - } - } - if ($lineCut) { - $this->line .= '…'.$lineCut; - $lineCut = 0; - } - - if ($i > $m) { - $this->endValue($cursor); - } else { - $this->dumpLine($cursor->depth); - } - } - } - } - - /** - * {@inheritdoc} - */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild) - { - if (null === $this->colors) { - $this->colors = $this->supportsColors(); - } - - $this->dumpKey($cursor); - $attr = $cursor->attr; - - if ($this->collapseNextHash) { - $cursor->skipChildren = true; - $this->collapseNextHash = $hasChild = false; - } - - $class = $this->utf8Encode($class); - if (Cursor::HASH_OBJECT === $type) { - $prefix = $class && 'stdClass' !== $class ? $this->style('note', $class, $attr).(empty($attr['cut_hash']) ? ' {' : '') : '{'; - } elseif (Cursor::HASH_RESOURCE === $type) { - $prefix = $this->style('note', $class.' resource', $attr).($hasChild ? ' {' : ' '); - } else { - $prefix = $class && !(self::DUMP_LIGHT_ARRAY & $this->flags) ? $this->style('note', 'array:'.$class).' [' : '['; - } - - if (($cursor->softRefCount || 0 < $cursor->softRefHandle) && empty($attr['cut_hash'])) { - $prefix .= $this->style('ref', (Cursor::HASH_RESOURCE === $type ? '@' : '#').(0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->softRefTo), ['count' => $cursor->softRefCount]); - } elseif ($cursor->hardRefTo && !$cursor->refIndex && $class) { - $prefix .= $this->style('ref', '&'.$cursor->hardRefTo, ['count' => $cursor->hardRefCount]); - } elseif (!$hasChild && Cursor::HASH_RESOURCE === $type) { - $prefix = substr($prefix, 0, -1); - } - - $this->line .= $prefix; - - if ($hasChild) { - $this->dumpLine($cursor->depth); - } - } - - /** - * {@inheritdoc} - */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut) - { - if (empty($cursor->attr['cut_hash'])) { - $this->dumpEllipsis($cursor, $hasChild, $cut); - $this->line .= Cursor::HASH_OBJECT === $type ? '}' : (Cursor::HASH_RESOURCE !== $type ? ']' : ($hasChild ? '}' : '')); - } - - $this->endValue($cursor); - } - - /** - * Dumps an ellipsis for cut children. - * - * @param bool $hasChild When the dump of the hash has child item - * @param int $cut The number of items the hash has been cut by - */ - protected function dumpEllipsis(Cursor $cursor, $hasChild, $cut) - { - if ($cut) { - $this->line .= ' …'; - if (0 < $cut) { - $this->line .= $cut; - } - if ($hasChild) { - $this->dumpLine($cursor->depth + 1); - } - } - } - - /** - * Dumps a key in a hash structure. - */ - protected function dumpKey(Cursor $cursor) - { - if (null !== $key = $cursor->hashKey) { - if ($cursor->hashKeyIsBinary) { - $key = $this->utf8Encode($key); - } - $attr = ['binary' => $cursor->hashKeyIsBinary]; - $bin = $cursor->hashKeyIsBinary ? 'b' : ''; - $style = 'key'; - switch ($cursor->hashType) { - default: - case Cursor::HASH_INDEXED: - if (self::DUMP_LIGHT_ARRAY & $this->flags) { - break; - } - $style = 'index'; - // no break - case Cursor::HASH_ASSOC: - if (\is_int($key)) { - $this->line .= $this->style($style, $key).' => '; - } else { - $this->line .= $bin.'"'.$this->style($style, $key).'" => '; - } - break; - - case Cursor::HASH_RESOURCE: - $key = "\0~\0".$key; - // no break - case Cursor::HASH_OBJECT: - if (!isset($key[0]) || "\0" !== $key[0]) { - $this->line .= '+'.$bin.$this->style('public', $key).': '; - } elseif (0 < strpos($key, "\0", 1)) { - $key = explode("\0", substr($key, 1), 2); - - switch ($key[0][0]) { - case '+': // User inserted keys - $attr['dynamic'] = true; - $this->line .= '+'.$bin.'"'.$this->style('public', $key[1], $attr).'": '; - break 2; - case '~': - $style = 'meta'; - if (isset($key[0][1])) { - parse_str(substr($key[0], 1), $attr); - $attr += ['binary' => $cursor->hashKeyIsBinary]; - } - break; - case '*': - $style = 'protected'; - $bin = '#'.$bin; - break; - default: - $attr['class'] = $key[0]; - $style = 'private'; - $bin = '-'.$bin; - break; - } - - if (isset($attr['collapse'])) { - if ($attr['collapse']) { - $this->collapseNextHash = true; - } else { - $this->expandNextHash = true; - } - } - - $this->line .= $bin.$this->style($style, $key[1], $attr).($attr['separator'] ?? ': '); - } else { - // This case should not happen - $this->line .= '-'.$bin.'"'.$this->style('private', $key, ['class' => '']).'": '; - } - break; - } - - if ($cursor->hardRefTo) { - $this->line .= $this->style('ref', '&'.($cursor->hardRefCount ? $cursor->hardRefTo : ''), ['count' => $cursor->hardRefCount]).' '; - } - } - } - - /** - * Decorates a value with some style. - * - * @param string $style The type of style being applied - * @param string $value The value being styled - * @param array $attr Optional context information - * - * @return string The value with style decoration - */ - protected function style($style, $value, $attr = []) - { - if (null === $this->colors) { - $this->colors = $this->supportsColors(); - } - - if (null === $this->handlesHrefGracefully) { - $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') - && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100); - } - - if (isset($attr['ellipsis'], $attr['ellipsis-type'])) { - $prefix = substr($value, 0, -$attr['ellipsis']); - if ('cli' === \PHP_SAPI && 'path' === $attr['ellipsis-type'] && isset($_SERVER[$pwd = '\\' === \DIRECTORY_SEPARATOR ? 'CD' : 'PWD']) && str_starts_with($prefix, $_SERVER[$pwd])) { - $prefix = '.'.substr($prefix, \strlen($_SERVER[$pwd])); - } - if (!empty($attr['ellipsis-tail'])) { - $prefix .= substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']); - $value = substr($value, -$attr['ellipsis'] + $attr['ellipsis-tail']); - } else { - $value = substr($value, -$attr['ellipsis']); - } - - $value = $this->style('default', $prefix).$this->style($style, $value); - - goto href; - } - - $map = static::$controlCharsMap; - $startCchr = $this->colors ? "\033[m\033[{$this->styles['default']}m" : ''; - $endCchr = $this->colors ? "\033[m\033[{$this->styles[$style]}m" : ''; - $value = preg_replace_callback(static::$controlCharsRx, function ($c) use ($map, $startCchr, $endCchr) { - $s = $startCchr; - $c = $c[$i = 0]; - do { - $s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i])); - } while (isset($c[++$i])); - - return $s.$endCchr; - }, $value, -1, $cchrCount); - - if ($this->colors) { - if ($cchrCount && "\033" === $value[0]) { - $value = substr($value, \strlen($startCchr)); - } else { - $value = "\033[{$this->styles[$style]}m".$value; - } - if ($cchrCount && str_ends_with($value, $endCchr)) { - $value = substr($value, 0, -\strlen($endCchr)); - } else { - $value .= "\033[{$this->styles['default']}m"; - } - } - - href: - if ($this->colors && $this->handlesHrefGracefully) { - if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) { - if ('note' === $style) { - $value .= "\033]8;;{$href}\033\\^\033]8;;\033\\"; - } else { - $attr['href'] = $href; - } - } - if (isset($attr['href'])) { - $value = "\033]8;;{$attr['href']}\033\\{$value}\033]8;;\033\\"; - } - } elseif ($attr['if_links'] ?? false) { - return ''; - } - - return $value; - } - - /** - * @return bool Tells if the current output stream supports ANSI colors or not - */ - protected function supportsColors() - { - if ($this->outputStream !== static::$defaultOutput) { - return $this->hasColorSupport($this->outputStream); - } - if (null !== static::$defaultColors) { - return static::$defaultColors; - } - if (isset($_SERVER['argv'][1])) { - $colors = $_SERVER['argv']; - $i = \count($colors); - while (--$i > 0) { - if (isset($colors[$i][5])) { - switch ($colors[$i]) { - case '--ansi': - case '--color': - case '--color=yes': - case '--color=force': - case '--color=always': - return static::$defaultColors = true; - - case '--no-ansi': - case '--color=no': - case '--color=none': - case '--color=never': - return static::$defaultColors = false; - } - } - } - } - - $h = stream_get_meta_data($this->outputStream) + ['wrapper_type' => null]; - $h = 'Output' === $h['stream_type'] && 'PHP' === $h['wrapper_type'] ? fopen('php://stdout', 'w') : $this->outputStream; - - return static::$defaultColors = $this->hasColorSupport($h); - } - - /** - * {@inheritdoc} - */ - protected function dumpLine($depth, $endOfValue = false) - { - if ($this->colors) { - $this->line = sprintf("\033[%sm%s\033[m", $this->styles['default'], $this->line); - } - parent::dumpLine($depth); - } - - protected function endValue(Cursor $cursor) - { - if (-1 === $cursor->hashType) { - return; - } - - if (Stub::ARRAY_INDEXED === $cursor->hashType || Stub::ARRAY_ASSOC === $cursor->hashType) { - if (self::DUMP_TRAILING_COMMA & $this->flags && 0 < $cursor->depth) { - $this->line .= ','; - } elseif (self::DUMP_COMMA_SEPARATOR & $this->flags && 1 < $cursor->hashLength - $cursor->hashIndex) { - $this->line .= ','; - } - } - - $this->dumpLine($cursor->depth, true); - } - - /** - * Returns true if the stream supports colorization. - * - * Reference: Composer\XdebugHandler\Process::supportsColor - * https://github.com/composer/xdebug-handler - * - * @param mixed $stream A CLI output stream - */ - private function hasColorSupport($stream): bool - { - if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) { - return false; - } - - // Follow https://no-color.org/ - if (isset($_SERVER['NO_COLOR']) || false !== getenv('NO_COLOR')) { - return false; - } - - if ('Hyper' === getenv('TERM_PROGRAM')) { - return true; - } - - if (\DIRECTORY_SEPARATOR === '\\') { - return (\function_exists('sapi_windows_vt100_support') - && @sapi_windows_vt100_support($stream)) - || false !== getenv('ANSICON') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM'); - } - - if (\function_exists('stream_isatty')) { - return @stream_isatty($stream); - } - - if (\function_exists('posix_isatty')) { - return @posix_isatty($stream); - } - - $stat = @fstat($stream); - // Check if formatted mode is S_IFCHR - return $stat ? 0020000 === ($stat['mode'] & 0170000) : false; - } - - /** - * Returns true if the Windows terminal supports true color. - * - * Note that this does not check an output stream, but relies on environment - * variables from known implementations, or a PHP and Windows version that - * supports true color. - */ - private function isWindowsTrueColor(): bool - { - $result = 183 <= getenv('ANSICON_VER') - || 'ON' === getenv('ConEmuANSI') - || 'xterm' === getenv('TERM') - || 'Hyper' === getenv('TERM_PROGRAM'); - - if (!$result && \PHP_VERSION_ID >= 70200) { - $version = sprintf( - '%s.%s.%s', - PHP_WINDOWS_VERSION_MAJOR, - PHP_WINDOWS_VERSION_MINOR, - PHP_WINDOWS_VERSION_BUILD - ); - $result = $version >= '10.0.15063'; - } - - return $result; - } - - private function getSourceLink(string $file, int $line) - { - if ($fmt = $this->displayOptions['fileLinkFormat']) { - return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : ($fmt->format($file, $line) ?: 'file://'.$file.'#L'.$line); - } - - return false; - } -} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php deleted file mode 100644 index 38f8789..0000000 --- a/vendor/symfony/var-dumper/Dumper/ContextProvider/CliContextProvider.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper\ContextProvider; - -/** - * Tries to provide context on CLI. - * - * @author Maxime Steinhausser - */ -final class CliContextProvider implements ContextProviderInterface -{ - public function getContext(): ?array - { - if ('cli' !== \PHP_SAPI) { - return null; - } - - return [ - 'command_line' => $commandLine = implode(' ', $_SERVER['argv'] ?? []), - 'identifier' => hash('crc32b', $commandLine.$_SERVER['REQUEST_TIME_FLOAT']), - ]; - } -} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php deleted file mode 100644 index 38ef3b0..0000000 --- a/vendor/symfony/var-dumper/Dumper/ContextProvider/ContextProviderInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper\ContextProvider; - -/** - * Interface to provide contextual data about dump data clones sent to a server. - * - * @author Maxime Steinhausser - */ -interface ContextProviderInterface -{ - /** - * @return array|null Context data or null if unable to provide any context - */ - public function getContext(): ?array; -} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php deleted file mode 100644 index 3684a47..0000000 --- a/vendor/symfony/var-dumper/Dumper/ContextProvider/RequestContextProvider.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper\ContextProvider; - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\VarDumper\Caster\ReflectionCaster; -use Symfony\Component\VarDumper\Cloner\VarCloner; - -/** - * Tries to provide context from a request. - * - * @author Maxime Steinhausser - */ -final class RequestContextProvider implements ContextProviderInterface -{ - private $requestStack; - private $cloner; - - public function __construct(RequestStack $requestStack) - { - $this->requestStack = $requestStack; - $this->cloner = new VarCloner(); - $this->cloner->setMaxItems(0); - $this->cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO); - } - - public function getContext(): ?array - { - if (null === $request = $this->requestStack->getCurrentRequest()) { - return null; - } - - $controller = $request->attributes->get('_controller'); - - return [ - 'uri' => $request->getUri(), - 'method' => $request->getMethod(), - 'controller' => $controller ? $this->cloner->cloneVar($controller) : $controller, - 'identifier' => spl_object_hash($request), - ]; - } -} diff --git a/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php b/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php deleted file mode 100644 index 2e2c818..0000000 --- a/vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper\ContextProvider; - -use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; -use Symfony\Component\VarDumper\VarDumper; -use Twig\Template; - -/** - * Tries to provide context from sources (class name, file, line, code excerpt, ...). - * - * @author Nicolas Grekas - * @author Maxime Steinhausser - */ -final class SourceContextProvider implements ContextProviderInterface -{ - private $limit; - private $charset; - private $projectDir; - private $fileLinkFormatter; - - public function __construct(string $charset = null, string $projectDir = null, FileLinkFormatter $fileLinkFormatter = null, int $limit = 9) - { - $this->charset = $charset; - $this->projectDir = $projectDir; - $this->fileLinkFormatter = $fileLinkFormatter; - $this->limit = $limit; - } - - public function getContext(): ?array - { - $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, $this->limit); - - $file = $trace[1]['file']; - $line = $trace[1]['line']; - $name = false; - $fileExcerpt = false; - - for ($i = 2; $i < $this->limit; ++$i) { - if (isset($trace[$i]['class'], $trace[$i]['function']) - && 'dump' === $trace[$i]['function'] - && VarDumper::class === $trace[$i]['class'] - ) { - $file = $trace[$i]['file'] ?? $file; - $line = $trace[$i]['line'] ?? $line; - - while (++$i < $this->limit) { - if (isset($trace[$i]['function'], $trace[$i]['file']) && empty($trace[$i]['class']) && !str_starts_with($trace[$i]['function'], 'call_user_func')) { - $file = $trace[$i]['file']; - $line = $trace[$i]['line']; - - break; - } elseif (isset($trace[$i]['object']) && $trace[$i]['object'] instanceof Template) { - $template = $trace[$i]['object']; - $name = $template->getTemplateName(); - $src = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : false); - $info = $template->getDebugInfo(); - if (isset($info[$trace[$i - 1]['line']])) { - $line = $info[$trace[$i - 1]['line']]; - $file = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getPath() : null; - - if ($src) { - $src = explode("\n", $src); - $fileExcerpt = []; - - for ($i = max($line - 3, 1), $max = min($line + 3, \count($src)); $i <= $max; ++$i) { - $fileExcerpt[] = ''.$this->htmlEncode($src[$i - 1]).''; - } - - $fileExcerpt = '
      '.implode("\n", $fileExcerpt).'
    '; - } - } - break; - } - } - break; - } - } - - if (false === $name) { - $name = str_replace('\\', '/', $file); - $name = substr($name, strrpos($name, '/') + 1); - } - - $context = ['name' => $name, 'file' => $file, 'line' => $line]; - $context['file_excerpt'] = $fileExcerpt; - - if (null !== $this->projectDir) { - $context['project_dir'] = $this->projectDir; - if (str_starts_with($file, $this->projectDir)) { - $context['file_relative'] = ltrim(substr($file, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR); - } - } - - if ($this->fileLinkFormatter && $fileLink = $this->fileLinkFormatter->format($context['file'], $context['line'])) { - $context['file_link'] = $fileLink; - } - - return $context; - } - - private function htmlEncode(string $s): string - { - $html = ''; - - $dumper = new HtmlDumper(function ($line) use (&$html) { $html .= $line; }, $this->charset); - $dumper->setDumpHeader(''); - $dumper->setDumpBoundaries('', ''); - - $cloner = new VarCloner(); - $dumper->dump($cloner->cloneVar($s)); - - return substr(strip_tags($html), 1, -1); - } -} diff --git a/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php b/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php deleted file mode 100644 index 7638417..0000000 --- a/vendor/symfony/var-dumper/Dumper/ContextualizedDumper.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; - -/** - * @author Kévin Thérage - */ -class ContextualizedDumper implements DataDumperInterface -{ - private $wrappedDumper; - private $contextProviders; - - /** - * @param ContextProviderInterface[] $contextProviders - */ - public function __construct(DataDumperInterface $wrappedDumper, array $contextProviders) - { - $this->wrappedDumper = $wrappedDumper; - $this->contextProviders = $contextProviders; - } - - public function dump(Data $data) - { - $context = []; - foreach ($this->contextProviders as $contextProvider) { - $context[\get_class($contextProvider)] = $contextProvider->getContext(); - } - - $this->wrappedDumper->dump($data->withContext($context)); - } -} diff --git a/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php b/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php deleted file mode 100644 index b173bcc..0000000 --- a/vendor/symfony/var-dumper/Dumper/DataDumperInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Data; - -/** - * DataDumperInterface for dumping Data objects. - * - * @author Nicolas Grekas - */ -interface DataDumperInterface -{ - public function dump(Data $data); -} diff --git a/vendor/symfony/var-dumper/Dumper/HtmlDumper.php b/vendor/symfony/var-dumper/Dumper/HtmlDumper.php deleted file mode 100644 index 9b57f90..0000000 --- a/vendor/symfony/var-dumper/Dumper/HtmlDumper.php +++ /dev/null @@ -1,1004 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Cursor; -use Symfony\Component\VarDumper\Cloner\Data; - -/** - * HtmlDumper dumps variables as HTML. - * - * @author Nicolas Grekas - */ -class HtmlDumper extends CliDumper -{ - public static $defaultOutput = 'php://output'; - - protected static $themes = [ - 'dark' => [ - 'default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', - 'num' => 'font-weight:bold; color:#1299DA', - 'const' => 'font-weight:bold', - 'str' => 'font-weight:bold; color:#56DB3A', - 'note' => 'color:#1299DA', - 'ref' => 'color:#A0A0A0', - 'public' => 'color:#FFFFFF', - 'protected' => 'color:#FFFFFF', - 'private' => 'color:#FFFFFF', - 'meta' => 'color:#B729D9', - 'key' => 'color:#56DB3A', - 'index' => 'color:#1299DA', - 'ellipsis' => 'color:#FF8400', - 'ns' => 'user-select:none;', - ], - 'light' => [ - 'default' => 'background:none; color:#CC7832; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', - 'num' => 'font-weight:bold; color:#1299DA', - 'const' => 'font-weight:bold', - 'str' => 'font-weight:bold; color:#629755;', - 'note' => 'color:#6897BB', - 'ref' => 'color:#6E6E6E', - 'public' => 'color:#262626', - 'protected' => 'color:#262626', - 'private' => 'color:#262626', - 'meta' => 'color:#B729D9', - 'key' => 'color:#789339', - 'index' => 'color:#1299DA', - 'ellipsis' => 'color:#CC7832', - 'ns' => 'user-select:none;', - ], - ]; - - protected $dumpHeader; - protected $dumpPrefix = '
    ';
    -    protected $dumpSuffix = '
    '; - protected $dumpId = 'sf-dump'; - protected $colors = true; - protected $headerIsDumped = false; - protected $lastDepth = -1; - protected $styles; - - private $displayOptions = [ - 'maxDepth' => 1, - 'maxStringLength' => 160, - 'fileLinkFormat' => null, - ]; - private $extraDisplayOptions = []; - - /** - * {@inheritdoc} - */ - public function __construct($output = null, string $charset = null, int $flags = 0) - { - AbstractDumper::__construct($output, $charset, $flags); - $this->dumpId = 'sf-dump-'.mt_rand(); - $this->displayOptions['fileLinkFormat'] = \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->styles = static::$themes['dark'] ?? self::$themes['dark']; - } - - /** - * {@inheritdoc} - */ - public function setStyles(array $styles) - { - $this->headerIsDumped = false; - $this->styles = $styles + $this->styles; - } - - public function setTheme(string $themeName) - { - if (!isset(static::$themes[$themeName])) { - throw new \InvalidArgumentException(sprintf('Theme "%s" does not exist in class "%s".', $themeName, static::class)); - } - - $this->setStyles(static::$themes[$themeName]); - } - - /** - * Configures display options. - * - * @param array $displayOptions A map of display options to customize the behavior - */ - public function setDisplayOptions(array $displayOptions) - { - $this->headerIsDumped = false; - $this->displayOptions = $displayOptions + $this->displayOptions; - } - - /** - * Sets an HTML header that will be dumped once in the output stream. - * - * @param string $header An HTML string - */ - public function setDumpHeader($header) - { - $this->dumpHeader = $header; - } - - /** - * Sets an HTML prefix and suffix that will encapse every single dump. - * - * @param string $prefix The prepended HTML string - * @param string $suffix The appended HTML string - */ - public function setDumpBoundaries($prefix, $suffix) - { - $this->dumpPrefix = $prefix; - $this->dumpSuffix = $suffix; - } - - /** - * {@inheritdoc} - */ - public function dump(Data $data, $output = null, array $extraDisplayOptions = []) - { - $this->extraDisplayOptions = $extraDisplayOptions; - $result = parent::dump($data, $output); - $this->dumpId = 'sf-dump-'.mt_rand(); - - return $result; - } - - /** - * Dumps the HTML header. - */ - protected function getDumpHeader() - { - $this->headerIsDumped = $this->outputStream ?? $this->lineDumper; - - if (null !== $this->dumpHeader) { - return $this->dumpHeader; - } - - $line = str_replace('{$options}', json_encode($this->displayOptions, \JSON_FORCE_OBJECT), <<<'EOHTML' -'.$this->dumpHeader; - } - - /** - * {@inheritdoc} - */ - public function dumpString(Cursor $cursor, $str, $bin, $cut) - { - if ('' === $str && isset($cursor->attr['img-data'], $cursor->attr['content-type'])) { - $this->dumpKey($cursor); - $this->line .= $this->style('default', $cursor->attr['img-size'] ?? '', []).' '; - $this->endValue($cursor); - $this->line .= $this->indentPad; - $this->line .= sprintf('', $cursor->attr['content-type'], base64_encode($cursor->attr['img-data'])); - $this->endValue($cursor); - } else { - parent::dumpString($cursor, $str, $bin, $cut); - } - } - - /** - * {@inheritdoc} - */ - public function enterHash(Cursor $cursor, $type, $class, $hasChild) - { - if (Cursor::HASH_OBJECT === $type) { - $cursor->attr['depth'] = $cursor->depth; - } - parent::enterHash($cursor, $type, $class, false); - - if ($cursor->skipChildren) { - $cursor->skipChildren = false; - $eol = ' class=sf-dump-compact>'; - } elseif ($this->expandNextHash) { - $this->expandNextHash = false; - $eol = ' class=sf-dump-expanded>'; - } else { - $eol = '>'; - } - - if ($hasChild) { - $this->line .= 'refIndex) { - $r = Cursor::HASH_OBJECT !== $type ? 1 - (Cursor::HASH_RESOURCE !== $type) : 2; - $r .= $r && 0 < $cursor->softRefHandle ? $cursor->softRefHandle : $cursor->refIndex; - - $this->line .= sprintf(' id=%s-ref%s', $this->dumpId, $r); - } - $this->line .= $eol; - $this->dumpLine($cursor->depth); - } - } - - /** - * {@inheritdoc} - */ - public function leaveHash(Cursor $cursor, $type, $class, $hasChild, $cut) - { - $this->dumpEllipsis($cursor, $hasChild, $cut); - if ($hasChild) { - $this->line .= ''; - } - parent::leaveHash($cursor, $type, $class, $hasChild, 0); - } - - /** - * {@inheritdoc} - */ - protected function style($style, $value, $attr = []) - { - if ('' === $value) { - return ''; - } - - $v = esc($value); - - if ('ref' === $style) { - if (empty($attr['count'])) { - return sprintf('%s', $v); - } - $r = ('#' !== $v[0] ? 1 - ('@' !== $v[0]) : 2).substr($value, 1); - - return sprintf('%s', $this->dumpId, $r, 1 + $attr['count'], $v); - } - - if ('const' === $style && isset($attr['value'])) { - $style .= sprintf(' title="%s"', esc(\is_scalar($attr['value']) ? $attr['value'] : json_encode($attr['value']))); - } elseif ('public' === $style) { - $style .= sprintf(' title="%s"', empty($attr['dynamic']) ? 'Public property' : 'Runtime added dynamic property'); - } elseif ('str' === $style && 1 < $attr['length']) { - $style .= sprintf(' title="%d%s characters"', $attr['length'], $attr['binary'] ? ' binary or non-UTF-8' : ''); - } elseif ('note' === $style && 0 < ($attr['depth'] ?? 0) && false !== $c = strrpos($value, '\\')) { - $style .= ' title=""'; - $attr += [ - 'ellipsis' => \strlen($value) - $c, - 'ellipsis-type' => 'note', - 'ellipsis-tail' => 1, - ]; - } elseif ('protected' === $style) { - $style .= ' title="Protected property"'; - } elseif ('meta' === $style && isset($attr['title'])) { - $style .= sprintf(' title="%s"', esc($this->utf8Encode($attr['title']))); - } elseif ('private' === $style) { - $style .= sprintf(' title="Private property defined in class: `%s`"', esc($this->utf8Encode($attr['class']))); - } - $map = static::$controlCharsMap; - - if (isset($attr['ellipsis'])) { - $class = 'sf-dump-ellipsis'; - if (isset($attr['ellipsis-type'])) { - $class = sprintf('"%s sf-dump-ellipsis-%s"', $class, $attr['ellipsis-type']); - } - $label = esc(substr($value, -$attr['ellipsis'])); - $style = str_replace(' title="', " title=\"$v\n", $style); - $v = sprintf('%s', $class, substr($v, 0, -\strlen($label))); - - if (!empty($attr['ellipsis-tail'])) { - $tail = \strlen(esc(substr($value, -$attr['ellipsis'], $attr['ellipsis-tail']))); - $v .= sprintf('%s%s', $class, substr($label, 0, $tail), substr($label, $tail)); - } else { - $v .= $label; - } - } - - $v = "".preg_replace_callback(static::$controlCharsRx, function ($c) use ($map) { - $s = $b = ''; - }, $v).''; - - if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) { - $attr['href'] = $href; - } - if (isset($attr['href'])) { - $target = isset($attr['file']) ? '' : ' target="_blank"'; - $v = sprintf('%s', esc($this->utf8Encode($attr['href'])), $target, $v); - } - if (isset($attr['lang'])) { - $v = sprintf('%s', esc($attr['lang']), $v); - } - - return $v; - } - - /** - * {@inheritdoc} - */ - protected function dumpLine($depth, $endOfValue = false) - { - if (-1 === $this->lastDepth) { - $this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line; - } - if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) { - $this->line = $this->getDumpHeader().$this->line; - } - - if (-1 === $depth) { - $args = ['"'.$this->dumpId.'"']; - if ($this->extraDisplayOptions) { - $args[] = json_encode($this->extraDisplayOptions, \JSON_FORCE_OBJECT); - } - // Replace is for BC - $this->line .= sprintf(str_replace('"%s"', '%s', $this->dumpSuffix), implode(', ', $args)); - } - $this->lastDepth = $depth; - - $this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8'); - - if (-1 === $depth) { - AbstractDumper::dumpLine(0); - } - AbstractDumper::dumpLine($depth); - } - - private function getSourceLink(string $file, int $line) - { - $options = $this->extraDisplayOptions + $this->displayOptions; - - if ($fmt = $options['fileLinkFormat']) { - return \is_string($fmt) ? strtr($fmt, ['%f' => $file, '%l' => $line]) : $fmt->format($file, $line); - } - - return false; - } -} - -function esc(string $str) -{ - return htmlspecialchars($str, \ENT_QUOTES, 'UTF-8'); -} diff --git a/vendor/symfony/var-dumper/Dumper/ServerDumper.php b/vendor/symfony/var-dumper/Dumper/ServerDumper.php deleted file mode 100644 index 94795bf..0000000 --- a/vendor/symfony/var-dumper/Dumper/ServerDumper.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Dumper; - -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; -use Symfony\Component\VarDumper\Server\Connection; - -/** - * ServerDumper forwards serialized Data clones to a server. - * - * @author Maxime Steinhausser - */ -class ServerDumper implements DataDumperInterface -{ - private $connection; - private $wrappedDumper; - - /** - * @param string $host The server host - * @param DataDumperInterface|null $wrappedDumper A wrapped instance used whenever we failed contacting the server - * @param ContextProviderInterface[] $contextProviders Context providers indexed by context name - */ - public function __construct(string $host, DataDumperInterface $wrappedDumper = null, array $contextProviders = []) - { - $this->connection = new Connection($host, $contextProviders); - $this->wrappedDumper = $wrappedDumper; - } - - public function getContextProviders(): array - { - return $this->connection->getContextProviders(); - } - - /** - * {@inheritdoc} - */ - public function dump(Data $data) - { - if (!$this->connection->write($data) && $this->wrappedDumper) { - $this->wrappedDumper->dump($data); - } - } -} diff --git a/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php b/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php deleted file mode 100644 index 122f0d3..0000000 --- a/vendor/symfony/var-dumper/Exception/ThrowingCasterException.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Exception; - -/** - * @author Nicolas Grekas - */ -class ThrowingCasterException extends \Exception -{ - /** - * @param \Throwable $prev The exception thrown from the caster - */ - public function __construct(\Throwable $prev) - { - parent::__construct('Unexpected '.\get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev); - } -} diff --git a/vendor/symfony/var-dumper/LICENSE b/vendor/symfony/var-dumper/LICENSE deleted file mode 100644 index a843ec1..0000000 --- a/vendor/symfony/var-dumper/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014-2022 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. diff --git a/vendor/symfony/var-dumper/README.md b/vendor/symfony/var-dumper/README.md deleted file mode 100644 index a0da8c9..0000000 --- a/vendor/symfony/var-dumper/README.md +++ /dev/null @@ -1,15 +0,0 @@ -VarDumper Component -=================== - -The VarDumper component provides mechanisms for walking through any arbitrary -PHP variable. It provides a better `dump()` function that you can use instead -of `var_dump()`. - -Resources ---------- - - * [Documentation](https://symfony.com/doc/current/components/var_dumper/introduction.html) - * [Contributing](https://symfony.com/doc/current/contributing/index.html) - * [Report issues](https://github.com/symfony/symfony/issues) and - [send Pull Requests](https://github.com/symfony/symfony/pulls) - in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/vendor/symfony/var-dumper/Resources/bin/var-dump-server b/vendor/symfony/var-dumper/Resources/bin/var-dump-server deleted file mode 100644 index f398fce..0000000 --- a/vendor/symfony/var-dumper/Resources/bin/var-dump-server +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if ('cli' !== PHP_SAPI) { - throw new Exception('This script must be run from the command line.'); -} - -/** - * Starts a dump server to collect and output dumps on a single place with multiple formats support. - * - * @author Maxime Steinhausser - */ - -use Psr\Log\LoggerInterface; -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Logger\ConsoleLogger; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\VarDumper\Command\ServerDumpCommand; -use Symfony\Component\VarDumper\Server\DumpServer; - -function includeIfExists(string $file): bool -{ - return file_exists($file) && include $file; -} - -if ( - !includeIfExists(__DIR__ . '/../../../../autoload.php') && - !includeIfExists(__DIR__ . '/../../vendor/autoload.php') && - !includeIfExists(__DIR__ . '/../../../../../../vendor/autoload.php') -) { - fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL); - exit(1); -} - -if (!class_exists(Application::class)) { - fwrite(STDERR, 'You need the "symfony/console" component in order to run the VarDumper server.'.PHP_EOL); - exit(1); -} - -$input = new ArgvInput(); -$output = new ConsoleOutput(); -$defaultHost = '127.0.0.1:9912'; -$host = $input->getParameterOption(['--host'], $_SERVER['VAR_DUMPER_SERVER'] ?? $defaultHost, true); -$logger = interface_exists(LoggerInterface::class) ? new ConsoleLogger($output->getErrorOutput()) : null; - -$app = new Application(); - -$app->getDefinition()->addOption( - new InputOption('--host', null, InputOption::VALUE_REQUIRED, 'The address the server should listen to', $defaultHost) -); - -$app->add($command = new ServerDumpCommand(new DumpServer($host, $logger))) - ->getApplication() - ->setDefaultCommand($command->getName(), true) - ->run($input, $output) -; diff --git a/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css b/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css deleted file mode 100644 index 8f706d6..0000000 --- a/vendor/symfony/var-dumper/Resources/css/htmlDescriptor.css +++ /dev/null @@ -1,130 +0,0 @@ -body { - display: flex; - flex-direction: column-reverse; - justify-content: flex-end; - max-width: 1140px; - margin: auto; - padding: 15px; - word-wrap: break-word; - background-color: #F9F9F9; - color: #222; - font-family: Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 1.4; -} -p { - margin: 0; -} -a { - color: #218BC3; - text-decoration: none; -} -a:hover { - text-decoration: underline; -} -.text-small { - font-size: 12px !important; -} -article { - margin: 5px; - margin-bottom: 10px; -} -article > header > .row { - display: flex; - flex-direction: row; - align-items: baseline; - margin-bottom: 10px; -} -article > header > .row > .col { - flex: 1; - display: flex; - align-items: baseline; -} -article > header > .row > h2 { - font-size: 14px; - color: #222; - font-weight: normal; - font-family: "Lucida Console", monospace, sans-serif; - word-break: break-all; - margin: 20px 5px 0 0; - user-select: all; -} -article > header > .row > h2 > code { - white-space: nowrap; - user-select: none; - color: #cc2255; - background-color: #f7f7f9; - border: 1px solid #e1e1e8; - border-radius: 3px; - margin-right: 5px; - padding: 0 3px; -} -article > header > .row > time.col { - flex: 0; - text-align: right; - white-space: nowrap; - color: #999; - font-style: italic; -} -article > header ul.tags { - list-style: none; - padding: 0; - margin: 0; - font-size: 12px; -} -article > header ul.tags > li { - user-select: all; - margin-bottom: 2px; -} -article > header ul.tags > li > span.badge { - display: inline-block; - padding: .25em .4em; - margin-right: 5px; - border-radius: 4px; - background-color: #6c757d3b; - color: #524d4d; - font-size: 12px; - text-align: center; - font-weight: 700; - line-height: 1; - white-space: nowrap; - vertical-align: baseline; - user-select: none; -} -article > section.body { - border: 1px solid #d8d8d8; - background: #FFF; - padding: 10px; - border-radius: 3px; -} -pre.sf-dump { - border-radius: 3px; - margin-bottom: 0; -} -.hidden { - display: none !important; -} -.dumped-tag > .sf-dump { - display: inline-block; - margin: 0; - padding: 1px 5px; - line-height: 1.4; - vertical-align: top; - background-color: transparent; - user-select: auto; -} -.dumped-tag > pre.sf-dump, -.dumped-tag > .sf-dump-default { - color: #CC7832; - background: none; -} -.dumped-tag > .sf-dump .sf-dump-str { color: #629755; } -.dumped-tag > .sf-dump .sf-dump-private, -.dumped-tag > .sf-dump .sf-dump-protected, -.dumped-tag > .sf-dump .sf-dump-public { color: #262626; } -.dumped-tag > .sf-dump .sf-dump-note { color: #6897BB; } -.dumped-tag > .sf-dump .sf-dump-key { color: #789339; } -.dumped-tag > .sf-dump .sf-dump-ref { color: #6E6E6E; } -.dumped-tag > .sf-dump .sf-dump-ellipsis { color: #CC7832; max-width: 100em; } -.dumped-tag > .sf-dump .sf-dump-ellipsis-path { max-width: 5em; } -.dumped-tag > .sf-dump .sf-dump-ns { user-select: none; } diff --git a/vendor/symfony/var-dumper/Resources/functions/dump.php b/vendor/symfony/var-dumper/Resources/functions/dump.php deleted file mode 100644 index a485d57..0000000 --- a/vendor/symfony/var-dumper/Resources/functions/dump.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Symfony\Component\VarDumper\VarDumper; - -if (!function_exists('dump')) { - /** - * @author Nicolas Grekas - */ - function dump($var, ...$moreVars) - { - VarDumper::dump($var); - - foreach ($moreVars as $v) { - VarDumper::dump($v); - } - - if (1 < func_num_args()) { - return func_get_args(); - } - - return $var; - } -} - -if (!function_exists('dd')) { - function dd(...$vars) - { - foreach ($vars as $v) { - VarDumper::dump($v); - } - - exit(1); - } -} diff --git a/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js b/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js deleted file mode 100644 index 63101e5..0000000 --- a/vendor/symfony/var-dumper/Resources/js/htmlDescriptor.js +++ /dev/null @@ -1,10 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - let prev = null; - Array.from(document.getElementsByTagName('article')).reverse().forEach(function (article) { - const dedupId = article.dataset.dedupId; - if (dedupId === prev) { - article.getElementsByTagName('header')[0].classList.add('hidden'); - } - prev = dedupId; - }); -}); diff --git a/vendor/symfony/var-dumper/Server/Connection.php b/vendor/symfony/var-dumper/Server/Connection.php deleted file mode 100644 index 55d9214..0000000 --- a/vendor/symfony/var-dumper/Server/Connection.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Server; - -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface; - -/** - * Forwards serialized Data clones to a server. - * - * @author Maxime Steinhausser - */ -class Connection -{ - private $host; - private $contextProviders; - private $socket; - - /** - * @param string $host The server host - * @param ContextProviderInterface[] $contextProviders Context providers indexed by context name - */ - public function __construct(string $host, array $contextProviders = []) - { - if (!str_contains($host, '://')) { - $host = 'tcp://'.$host; - } - - $this->host = $host; - $this->contextProviders = $contextProviders; - } - - public function getContextProviders(): array - { - return $this->contextProviders; - } - - public function write(Data $data): bool - { - $socketIsFresh = !$this->socket; - if (!$this->socket = $this->socket ?: $this->createSocket()) { - return false; - } - - $context = ['timestamp' => microtime(true)]; - foreach ($this->contextProviders as $name => $provider) { - $context[$name] = $provider->getContext(); - } - $context = array_filter($context); - $encodedPayload = base64_encode(serialize([$data, $context]))."\n"; - - set_error_handler([self::class, 'nullErrorHandler']); - try { - if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { - return true; - } - if (!$socketIsFresh) { - stream_socket_shutdown($this->socket, \STREAM_SHUT_RDWR); - fclose($this->socket); - $this->socket = $this->createSocket(); - } - if (-1 !== stream_socket_sendto($this->socket, $encodedPayload)) { - return true; - } - } finally { - restore_error_handler(); - } - - return false; - } - - private static function nullErrorHandler(int $t, string $m) - { - // no-op - } - - private function createSocket() - { - set_error_handler([self::class, 'nullErrorHandler']); - try { - return stream_socket_client($this->host, $errno, $errstr, 3, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT); - } finally { - restore_error_handler(); - } - } -} diff --git a/vendor/symfony/var-dumper/Server/DumpServer.php b/vendor/symfony/var-dumper/Server/DumpServer.php deleted file mode 100644 index 1c2c348..0000000 --- a/vendor/symfony/var-dumper/Server/DumpServer.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Server; - -use Psr\Log\LoggerInterface; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\Stub; - -/** - * A server collecting Data clones sent by a ServerDumper. - * - * @author Maxime Steinhausser - * - * @final - */ -class DumpServer -{ - private $host; - private $socket; - private $logger; - - public function __construct(string $host, LoggerInterface $logger = null) - { - if (!str_contains($host, '://')) { - $host = 'tcp://'.$host; - } - - $this->host = $host; - $this->logger = $logger; - } - - public function start(): void - { - if (!$this->socket = stream_socket_server($this->host, $errno, $errstr)) { - throw new \RuntimeException(sprintf('Server start failed on "%s": ', $this->host).$errstr.' '.$errno); - } - } - - public function listen(callable $callback): void - { - if (null === $this->socket) { - $this->start(); - } - - foreach ($this->getMessages() as $clientId => $message) { - $payload = @unserialize(base64_decode($message), ['allowed_classes' => [Data::class, Stub::class]]); - - // Impossible to decode the message, give up. - if (false === $payload) { - if ($this->logger) { - $this->logger->warning('Unable to decode a message from {clientId} client.', ['clientId' => $clientId]); - } - - continue; - } - - if (!\is_array($payload) || \count($payload) < 2 || !$payload[0] instanceof Data || !\is_array($payload[1])) { - if ($this->logger) { - $this->logger->warning('Invalid payload from {clientId} client. Expected an array of two elements (Data $data, array $context)', ['clientId' => $clientId]); - } - - continue; - } - - [$data, $context] = $payload; - - $callback($data, $context, $clientId); - } - } - - public function getHost(): string - { - return $this->host; - } - - private function getMessages(): iterable - { - $sockets = [(int) $this->socket => $this->socket]; - $write = []; - - while (true) { - $read = $sockets; - stream_select($read, $write, $write, null); - - foreach ($read as $stream) { - if ($this->socket === $stream) { - $stream = stream_socket_accept($this->socket); - $sockets[(int) $stream] = $stream; - } elseif (feof($stream)) { - unset($sockets[(int) $stream]); - fclose($stream); - } else { - yield (int) $stream => fgets($stream); - } - } - } - } -} diff --git a/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php b/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php deleted file mode 100644 index 3d3d18e..0000000 --- a/vendor/symfony/var-dumper/Test/VarDumperTestTrait.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper\Test; - -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; - -/** - * @author Nicolas Grekas - */ -trait VarDumperTestTrait -{ - /** - * @internal - */ - private $varDumperConfig = [ - 'casters' => [], - 'flags' => null, - ]; - - protected function setUpVarDumper(array $casters, int $flags = null): void - { - $this->varDumperConfig['casters'] = $casters; - $this->varDumperConfig['flags'] = $flags; - } - - /** - * @after - */ - protected function tearDownVarDumper(): void - { - $this->varDumperConfig['casters'] = []; - $this->varDumperConfig['flags'] = null; - } - - public function assertDumpEquals($expected, $data, $filter = 0, $message = '') - { - $this->assertSame($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); - } - - public function assertDumpMatchesFormat($expected, $data, $filter = 0, $message = '') - { - $this->assertStringMatchesFormat($this->prepareExpectation($expected, $filter), $this->getDump($data, null, $filter), $message); - } - - /** - * @return string|null - */ - protected function getDump($data, $key = null, $filter = 0) - { - if (null === $flags = $this->varDumperConfig['flags']) { - $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0; - $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0; - $flags |= getenv('DUMP_COMMA_SEPARATOR') ? CliDumper::DUMP_COMMA_SEPARATOR : 0; - } - - $cloner = new VarCloner(); - $cloner->addCasters($this->varDumperConfig['casters']); - $cloner->setMaxItems(-1); - $dumper = new CliDumper(null, null, $flags); - $dumper->setColors(false); - $data = $cloner->cloneVar($data, $filter)->withRefHandles(false); - if (null !== $key && null === $data = $data->seek($key)) { - return null; - } - - return rtrim($dumper->dump($data, true)); - } - - private function prepareExpectation($expected, int $filter): string - { - if (!\is_string($expected)) { - $expected = $this->getDump($expected, null, $filter); - } - - return rtrim($expected); - } -} diff --git a/vendor/symfony/var-dumper/VarDumper.php b/vendor/symfony/var-dumper/VarDumper.php deleted file mode 100644 index febc1e0..0000000 --- a/vendor/symfony/var-dumper/VarDumper.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\VarDumper; - -use Symfony\Component\VarDumper\Caster\ReflectionCaster; -use Symfony\Component\VarDumper\Cloner\VarCloner; -use Symfony\Component\VarDumper\Dumper\CliDumper; -use Symfony\Component\VarDumper\Dumper\ContextProvider\SourceContextProvider; -use Symfony\Component\VarDumper\Dumper\ContextualizedDumper; -use Symfony\Component\VarDumper\Dumper\HtmlDumper; - -// Load the global dump() function -require_once __DIR__.'/Resources/functions/dump.php'; - -/** - * @author Nicolas Grekas - */ -class VarDumper -{ - private static $handler; - - public static function dump($var) - { - if (null === self::$handler) { - $cloner = new VarCloner(); - $cloner->addCasters(ReflectionCaster::UNSET_CLOSURE_FILE_INFO); - - if (isset($_SERVER['VAR_DUMPER_FORMAT'])) { - $dumper = 'html' === $_SERVER['VAR_DUMPER_FORMAT'] ? new HtmlDumper() : new CliDumper(); - } else { - $dumper = \in_array(\PHP_SAPI, ['cli', 'phpdbg']) ? new CliDumper() : new HtmlDumper(); - } - - $dumper = new ContextualizedDumper($dumper, [new SourceContextProvider()]); - - self::$handler = function ($var) use ($cloner, $dumper) { - $dumper->dump($cloner->cloneVar($var)); - }; - } - - return (self::$handler)($var); - } - - public static function setHandler(callable $callable = null) - { - $prevHandler = self::$handler; - - // Prevent replacing the handler with expected format as soon as the env var was set: - if (isset($_SERVER['VAR_DUMPER_FORMAT'])) { - return $prevHandler; - } - - self::$handler = $callable; - - return $prevHandler; - } -} diff --git a/vendor/symfony/var-dumper/composer.json b/vendor/symfony/var-dumper/composer.json deleted file mode 100644 index d4e64cc..0000000 --- a/vendor/symfony/var-dumper/composer.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "symfony/var-dumper", - "type": "library", - "description": "Provides mechanisms for walking through any arbitrary PHP variable", - "keywords": ["dump", "debug"], - "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.3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php72": "~1.5", - "symfony/polyfill-php80": "^1.16" - }, - "require-dev": { - "ext-iconv": "*", - "symfony/console": "^3.4|^4.0|^5.0", - "symfony/process": "^4.4|^5.0", - "twig/twig": "^1.43|^2.13|^3.0.4" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", - "symfony/console": "<3.4" - }, - "suggest": { - "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).", - "ext-intl": "To show region name in time zone dump", - "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script" - }, - "autoload": { - "files": [ "Resources/functions/dump.php" ], - "psr-4": { "Symfony\\Component\\VarDumper\\": "" }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "bin": [ - "Resources/bin/var-dump-server" - ], - "minimum-stability": "dev" -} diff --git a/vendor/symfony/var-exporter/CHANGELOG.md b/vendor/symfony/var-exporter/CHANGELOG.md index 3406c30..1b21a0b 100644 --- a/vendor/symfony/var-exporter/CHANGELOG.md +++ b/vendor/symfony/var-exporter/CHANGELOG.md @@ -1,6 +1,14 @@ CHANGELOG ========= +6.2 +--- + + * Add support for lazy ghost objects and virtual proxies + * Add `Hydrator::hydrate()` + * Preserve PHP references also when using `Hydrator::hydrate()` or `Instantiator::instantiate()` + * Add support for hydrating from native (array) casts + 5.1.0 ----- diff --git a/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php b/vendor/symfony/var-exporter/Exception/LogicException.php similarity index 65% rename from vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php rename to vendor/symfony/var-exporter/Exception/LogicException.php index 01c6c6c..619d055 100644 --- a/vendor/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php +++ b/vendor/symfony/var-exporter/Exception/LogicException.php @@ -9,8 +9,8 @@ * file that was distributed with this source code. */ -if (\PHP_VERSION_ID < 80000) { - class UnhandledMatchError extends Error - { - } +namespace Symfony\Component\VarExporter\Exception; + +class LogicException extends \LogicException implements ExceptionInterface +{ } diff --git a/vendor/symfony/var-exporter/Hydrator.php b/vendor/symfony/var-exporter/Hydrator.php new file mode 100644 index 0000000..5f456fb --- /dev/null +++ b/vendor/symfony/var-exporter/Hydrator.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter; + +use Symfony\Component\VarExporter\Internal\Hydrator as InternalHydrator; + +/** + * Utility class to hydrate the properties of an object. + * + * @author Nicolas Grekas + */ +final class Hydrator +{ + /** + * Sets the properties of an object, including private and protected ones. + * + * For example: + * + * // Sets the public or protected $object->propertyName property + * Hydrator::hydrate($object, ['propertyName' => $propertyValue]); + * + * // Sets a private property defined on its parent Bar class: + * Hydrator::hydrate($object, ["\0Bar\0privateBarProperty" => $propertyValue]); + * + * // Alternative way to set the private $object->privateBarProperty property + * Hydrator::hydrate($object, [], [ + * Bar::class => ['privateBarProperty' => $propertyValue], + * ]); + * + * Instances of ArrayObject, ArrayIterator and SplObjectStorage can be hydrated + * by using the special "\0" property name to define their internal value: + * + * // Hydrates an SplObjectStorage where $info1 is attached to $obj1, etc. + * Hydrator::hydrate($object, ["\0" => [$obj1, $info1, $obj2, $info2...]]); + * + * // Hydrates an ArrayObject populated with $inputArray + * Hydrator::hydrate($object, ["\0" => [$inputArray]]); + * + * @template T of object + * + * @param T $instance The object to hydrate + * @param array $properties The properties to set on the instance + * @param array> $scopedProperties The properties to set on the instance, + * keyed by their declaring class + * + * @return T + */ + public static function hydrate(object $instance, array $properties = [], array $scopedProperties = []): object + { + if ($properties) { + $class = $instance::class; + $propertyScopes = InternalHydrator::$propertyScopes[$class] ??= InternalHydrator::getPropertyScopes($class); + + foreach ($properties as $name => &$value) { + [$scope, $name, $readonlyScope] = $propertyScopes[$name] ?? [$class, $name, $class]; + $scopedProperties[$readonlyScope ?? $scope][$name] = &$value; + } + unset($value); + } + + foreach ($scopedProperties as $scope => $properties) { + if ($properties) { + (InternalHydrator::$simpleHydrators[$scope] ??= InternalHydrator::getSimpleHydrator($scope))($properties, $instance); + } + } + + return $instance; + } +} diff --git a/vendor/symfony/var-exporter/Instantiator.php b/vendor/symfony/var-exporter/Instantiator.php index 368c769..10200c0 100644 --- a/vendor/symfony/var-exporter/Instantiator.php +++ b/vendor/symfony/var-exporter/Instantiator.php @@ -13,7 +13,6 @@ namespace Symfony\Component\VarExporter; use Symfony\Component\VarExporter\Exception\ExceptionInterface; use Symfony\Component\VarExporter\Exception\NotInstantiableTypeException; -use Symfony\Component\VarExporter\Internal\Hydrator; use Symfony\Component\VarExporter\Internal\Registry; /** @@ -26,67 +25,35 @@ final class Instantiator /** * Creates an object and sets its properties without calling its constructor nor any other methods. * - * For example: + * @see Hydrator::hydrate() for examples * - * // creates an empty instance of Foo - * Instantiator::instantiate(Foo::class); + * @template T of object * - * // creates a Foo instance and sets one of its properties - * Instantiator::instantiate(Foo::class, ['propertyName' => $propertyValue]); + * @param class-string $class The class of the instance to create + * @param array $properties The properties to set on the instance + * @param array> $scopedProperties The properties to set on the instance, + * keyed by their declaring class * - * // creates a Foo instance and sets a private property defined on its parent Bar class - * Instantiator::instantiate(Foo::class, [], [ - * Bar::class => ['privateBarProperty' => $propertyValue], - * ]); - * - * Instances of ArrayObject, ArrayIterator and SplObjectStorage can be created - * by using the special "\0" property name to define their internal value: - * - * // creates an SplObjectStorage where $info1 is attached to $obj1, etc. - * Instantiator::instantiate(SplObjectStorage::class, ["\0" => [$obj1, $info1, $obj2, $info2...]]); - * - * // creates an ArrayObject populated with $inputArray - * Instantiator::instantiate(ArrayObject::class, ["\0" => [$inputArray]]); - * - * @param string $class The class of the instance to create - * @param array $properties The properties to set on the instance - * @param array $privateProperties The private properties to set on the instance, - * keyed by their declaring class + * @return T * * @throws ExceptionInterface When the instance cannot be created */ - public static function instantiate(string $class, array $properties = [], array $privateProperties = []): object + public static function instantiate(string $class, array $properties = [], array $scopedProperties = []): object { - $reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class); + $reflector = Registry::$reflectors[$class] ??= Registry::getClassReflector($class); if (Registry::$cloneable[$class]) { - $wrappedInstance = [clone Registry::$prototypes[$class]]; + $instance = clone Registry::$prototypes[$class]; } elseif (Registry::$instantiableWithoutConstructor[$class]) { - $wrappedInstance = [$reflector->newInstanceWithoutConstructor()]; + $instance = $reflector->newInstanceWithoutConstructor(); } elseif (null === Registry::$prototypes[$class]) { throw new NotInstantiableTypeException($class); - } elseif ($reflector->implementsInterface('Serializable') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize'))) { - $wrappedInstance = [unserialize('C:'.\strlen($class).':"'.$class.'":0:{}')]; + } elseif ($reflector->implementsInterface('Serializable') && !method_exists($class, '__unserialize')) { + $instance = unserialize('C:'.\strlen($class).':"'.$class.'":0:{}'); } else { - $wrappedInstance = [unserialize('O:'.\strlen($class).':"'.$class.'":0:{}')]; + $instance = unserialize('O:'.\strlen($class).':"'.$class.'":0:{}'); } - if ($properties) { - $privateProperties[$class] = isset($privateProperties[$class]) ? $properties + $privateProperties[$class] : $properties; - } - - foreach ($privateProperties as $class => $properties) { - if (!$properties) { - continue; - } - foreach ($properties as $name => $value) { - // because they're also used for "unserialization", hydrators - // deal with array of instances, so we need to wrap values - $properties[$name] = [$value]; - } - (Hydrator::$hydrators[$class] ?? Hydrator::getHydrator($class))($properties, $wrappedInstance); - } - - return $wrappedInstance[0]; + return $properties || $scopedProperties ? Hydrator::hydrate($instance, $properties, $scopedProperties) : $instance; } } diff --git a/vendor/symfony/var-exporter/Internal/Exporter.php b/vendor/symfony/var-exporter/Internal/Exporter.php index 6ee3ee7..e7ee44b 100644 --- a/vendor/symfony/var-exporter/Internal/Exporter.php +++ b/vendor/symfony/var-exporter/Internal/Exporter.php @@ -31,9 +31,11 @@ class Exporter * @param int &$objectsCount * @param bool &$valuesAreStatic * + * @return array + * * @throws NotInstantiableTypeException When a value cannot be serialized */ - public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic): array + public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount, &$valuesAreStatic) { $refs = $values; foreach ($values as $k => $value) { @@ -71,22 +73,31 @@ class Exporter goto handle_value; } - $class = \get_class($value); - $reflector = Registry::$reflectors[$class] ?? Registry::getClassReflector($class); + $class = $value::class; + $reflector = Registry::$reflectors[$class] ??= Registry::getClassReflector($class); + $properties = []; if ($reflector->hasMethod('__serialize')) { if (!$reflector->getMethod('__serialize')->isPublic()) { throw new \Error(sprintf('Call to %s method "%s::__serialize()".', $reflector->getMethod('__serialize')->isProtected() ? 'protected' : 'private', $class)); } - if (!\is_array($properties = $value->__serialize())) { + if (!\is_array($serializeProperties = $value->__serialize())) { throw new \TypeError($class.'::__serialize() must return an array'); } + if ($reflector->hasMethod('__unserialize')) { + $properties = $serializeProperties; + } else { + foreach ($serializeProperties as $n => $v) { + $c = \PHP_VERSION_ID >= 80100 && $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass'; + $properties[$c][$n] = $v; + } + } + goto prepare_value; } - $properties = []; $sleep = null; $proto = Registry::$prototypes[$class]; @@ -133,7 +144,7 @@ class Exporter $i = 0; $n = (string) $name; if ('' === $n || "\0" !== $n[0]) { - $c = \PHP_VERSION_ID >= 80100 && $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass'; + $c = $reflector->hasProperty($n) && ($p = $reflector->getProperty($n))->isReadOnly() ? $p->class : 'stdClass'; } elseif ('*' === $n[1]) { $n = substr($n, 3); $c = $reflector->getProperty($n)->class; @@ -189,7 +200,7 @@ class Exporter return $values; } - public static function export($value, string $indent = '') + public static function export($value, $indent = '') { switch (true) { case \is_int($value) || \is_float($value): return var_export($value, true); @@ -228,7 +239,7 @@ class Exporter return substr($m[1], 0, -2); } - if ('n".\'' === substr($m[1], -4)) { + if (str_ends_with($m[1], 'n".\'')) { return substr_replace($m[1], "\n".$subIndent.".'".$m[2], -2); } @@ -366,7 +377,7 @@ class Exporter self::export($value->wakeups, $subIndent), ]; - return '\\'.\get_class($value)."::hydrate(\n".$subIndent.implode(",\n".$subIndent, $code)."\n".$indent.')'; + return '\\'.$value::class."::hydrate(\n".$subIndent.implode(",\n".$subIndent, $code)."\n".$indent.')'; } /** @@ -376,7 +387,7 @@ class Exporter private static function getArrayObjectProperties($value, $proto): array { $reflector = $value instanceof \ArrayIterator ? 'ArrayIterator' : 'ArrayObject'; - $reflector = Registry::$reflectors[$reflector] ?? Registry::getClassReflector($reflector); + $reflector = Registry::$reflectors[$reflector] ??= Registry::getClassReflector($reflector); $properties = [ $arrayValue = (array) $value, diff --git a/vendor/symfony/var-exporter/Internal/Hydrator.php b/vendor/symfony/var-exporter/Internal/Hydrator.php index 5ed6bdc..f665f6e 100644 --- a/vendor/symfony/var-exporter/Internal/Hydrator.php +++ b/vendor/symfony/var-exporter/Internal/Hydrator.php @@ -21,6 +21,8 @@ use Symfony\Component\VarExporter\Exception\ClassNotFoundException; class Hydrator { public static $hydrators = []; + public static $simpleHydrators = []; + public static $propertyScopes = []; public $registry; public $values; @@ -40,7 +42,7 @@ class Hydrator public static function hydrate($objects, $values, $properties, $value, $wakeups) { foreach ($properties as $class => $vars) { - (self::$hydrators[$class] ?? self::getHydrator($class))($vars, $objects); + (self::$hydrators[$class] ??= self::getHydrator($class))($vars, $objects); } foreach ($wakeups as $k => $v) { if (\is_array($v)) { @@ -55,26 +57,28 @@ class Hydrator public static function getHydrator($class) { + $baseHydrator = self::$hydrators['stdClass'] ??= static function ($properties, $objects) { + foreach ($properties as $name => $values) { + foreach ($values as $i => $v) { + $objects[$i]->$name = $v; + } + } + }; + switch ($class) { case 'stdClass': - return self::$hydrators[$class] = static function ($properties, $objects) { - foreach ($properties as $name => $values) { - foreach ($values as $i => $v) { - $objects[$i]->$name = $v; - } - } - }; + return $baseHydrator; case 'ErrorException': - return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, new class() extends \ErrorException { + return $baseHydrator->bindTo(null, new class() extends \ErrorException { }); case 'TypeError': - return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, new class() extends \Error { + return $baseHydrator->bindTo(null, new class() extends \Error { }); case 'SplObjectStorage': - return self::$hydrators[$class] = static function ($properties, $objects) { + return static function ($properties, $objects) { foreach ($properties as $name => $values) { if ("\0" === $name) { foreach ($values as $i => $v) { @@ -99,9 +103,9 @@ class Hydrator switch ($class) { case 'ArrayIterator': case 'ArrayObject': - $constructor = \Closure::fromCallable([$classReflector->getConstructor(), 'invokeArgs']); + $constructor = $classReflector->getConstructor()->invokeArgs(...); - return self::$hydrators[$class] = static function ($properties, $objects) use ($constructor) { + return static function ($properties, $objects) use ($constructor) { foreach ($properties as $name => $values) { if ("\0" !== $name) { foreach ($values as $i => $v) { @@ -116,26 +120,25 @@ class Hydrator } if (!$classReflector->isInternal()) { - return self::$hydrators[$class] = (self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'))->bindTo(null, $class); + return $baseHydrator->bindTo(null, $class); } if ($classReflector->name !== $class) { - return self::$hydrators[$classReflector->name] ?? self::getHydrator($classReflector->name); + return self::$hydrators[$classReflector->name] ??= self::getHydrator($classReflector->name); } $propertySetters = []; foreach ($classReflector->getProperties() as $propertyReflector) { if (!$propertyReflector->isStatic()) { - $propertyReflector->setAccessible(true); - $propertySetters[$propertyReflector->name] = \Closure::fromCallable([$propertyReflector, 'setValue']); + $propertySetters[$propertyReflector->name] = $propertyReflector->setValue(...); } } if (!$propertySetters) { - return self::$hydrators[$class] = self::$hydrators['stdClass'] ?? self::getHydrator('stdClass'); + return $baseHydrator; } - return self::$hydrators[$class] = static function ($properties, $objects) use ($propertySetters) { + return static function ($properties, $objects) use ($propertySetters) { foreach ($properties as $name => $values) { if ($setValue = $propertySetters[$name] ?? null) { foreach ($values as $i => $v) { @@ -149,4 +152,148 @@ class Hydrator } }; } + + public static function getSimpleHydrator($class) + { + $baseHydrator = self::$simpleHydrators['stdClass'] ??= (function ($properties, $object) { + $readonly = (array) $this; + + foreach ($properties as $name => &$value) { + $object->$name = $value; + + if (!($readonly[$name] ?? false)) { + $object->$name = &$value; + } + } + })->bindTo(new \stdClass()); + + switch ($class) { + case 'stdClass': + return $baseHydrator; + + case 'ErrorException': + return $baseHydrator->bindTo(new \stdClass(), new class() extends \ErrorException { + }); + + case 'TypeError': + return $baseHydrator->bindTo(new \stdClass(), new class() extends \Error { + }); + + case 'SplObjectStorage': + return static function ($properties, $object) { + foreach ($properties as $name => &$value) { + if ("\0" !== $name) { + $object->$name = $value; + $object->$name = &$value; + continue; + } + for ($i = 0; $i < \count($value); ++$i) { + $object->attach($value[$i], $value[++$i]); + } + } + }; + } + + if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) { + throw new ClassNotFoundException($class); + } + $classReflector = new \ReflectionClass($class); + + switch ($class) { + case 'ArrayIterator': + case 'ArrayObject': + $constructor = $classReflector->getConstructor()->invokeArgs(...); + + return static function ($properties, $object) use ($constructor) { + foreach ($properties as $name => &$value) { + if ("\0" === $name) { + $constructor($object, $value); + } else { + $object->$name = $value; + $object->$name = &$value; + } + } + }; + } + + if (!$classReflector->isInternal()) { + $readonly = new \stdClass(); + foreach ($classReflector->getProperties(\ReflectionProperty::IS_READONLY) as $propertyReflector) { + if ($class === $propertyReflector->class) { + $readonly->{$propertyReflector->name} = true; + } + } + + return $baseHydrator->bindTo($readonly, $class); + } + + if ($classReflector->name !== $class) { + return self::$simpleHydrators[$classReflector->name] ??= self::getSimpleHydrator($classReflector->name); + } + + $propertySetters = []; + foreach ($classReflector->getProperties() as $propertyReflector) { + if (!$propertyReflector->isStatic()) { + $propertySetters[$propertyReflector->name] = $propertyReflector->setValue(...); + } + } + + if (!$propertySetters) { + return $baseHydrator; + } + + return static function ($properties, $object) use ($propertySetters) { + foreach ($properties as $name => &$value) { + if ($setValue = $propertySetters[$name] ?? null) { + $setValue($object, $value); + } else { + $object->$name = $value; + $object->$name = &$value; + } + } + }; + } + + /** + * @return array + */ + public static function getPropertyScopes($class) + { + $propertyScopes = []; + $r = new \ReflectionClass($class); + + foreach ($r->getProperties() as $property) { + $flags = $property->getModifiers(); + + if (\ReflectionProperty::IS_STATIC & $flags) { + continue; + } + $name = $property->name; + + if (\ReflectionProperty::IS_PRIVATE & $flags) { + $propertyScopes["\0$class\0$name"] = $propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $class : null]; + continue; + } + $propertyScopes[$name] = [$class, $name, $flags & \ReflectionProperty::IS_READONLY ? $property->class : null]; + + if (\ReflectionProperty::IS_PROTECTED & $flags) { + $propertyScopes["\0*\0$name"] = $propertyScopes[$name]; + } + } + + while ($r = $r->getParentClass()) { + $class = $r->name; + + foreach ($r->getProperties(\ReflectionProperty::IS_PRIVATE) as $property) { + if (!$property->isStatic()) { + $name = $property->name; + $readonlyScope = $property->isReadOnly() ? $class : null; + $propertyScopes["\0$class\0$name"] = [$class, $name, $readonlyScope]; + $propertyScopes[$name] ??= [$class, $name, $readonlyScope]; + } + } + } + + return $propertyScopes; + } } diff --git a/vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php b/vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php new file mode 100644 index 0000000..d9d9925 --- /dev/null +++ b/vendor/symfony/var-exporter/Internal/LazyObjectRegistry.php @@ -0,0 +1,146 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter\Internal; + +/** + * Stores the state of lazy objects and caches related reflection information. + * + * As a micro-optimization, this class uses no type declarations. + * + * @internal + */ +class LazyObjectRegistry +{ + /** + * @var array + */ + public static $classReflectors = []; + + /** + * @var array> + */ + public static $defaultProperties = []; + + /** + * @var array> + */ + public static $classResetters = []; + + /** + * @var array + */ + public static $classAccessors = []; + + /** + * @var array + */ + public static $parentMethods = []; + + public static ?\Closure $noInitializerState = null; + + public static function getClassResetters($class) + { + $classProperties = []; + + if ((self::$classReflectors[$class] ??= new \ReflectionClass($class))->isInternal()) { + $propertyScopes = []; + } else { + $propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class); + } + + foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) { + $propertyScopes[$k = "\0$scope\0$name"] ?? $propertyScopes[$k = "\0*\0$name"] ?? $k = $name; + + if ($k === $key && "\0$class\0lazyObjectState" !== $k) { + $classProperties[$readonlyScope ?? $scope][$name] = $key; + } + } + + $resetters = []; + foreach ($classProperties as $scope => $properties) { + $resetters[] = \Closure::bind(static function ($instance, $skippedProperties, $onlyProperties = null) use ($properties) { + foreach ($properties as $name => $key) { + if (!\array_key_exists($key, $skippedProperties) && (null === $onlyProperties || \array_key_exists($key, $onlyProperties))) { + unset($instance->$name); + } + } + }, null, $scope); + } + + $resetters[] = static function ($instance, $skippedProperties, $onlyProperties = null) { + foreach ((array) $instance as $name => $value) { + if ("\0" !== ($name[0] ?? '') && !\array_key_exists($name, $skippedProperties) && (null === $onlyProperties || \array_key_exists($name, $onlyProperties))) { + unset($instance->$name); + } + } + }; + + return $resetters; + } + + public static function getClassAccessors($class) + { + return \Closure::bind(static fn () => [ + 'get' => static function &($instance, $name, $readonly) { + if (!$readonly) { + return $instance->$name; + } + $value = $instance->$name; + + return $value; + }, + 'set' => static function ($instance, $name, $value) { + $instance->$name = $value; + }, + 'isset' => static fn ($instance, $name) => isset($instance->$name), + 'unset' => static function ($instance, $name) { + unset($instance->$name); + }, + ], null, \Closure::class === $class ? null : $class)(); + } + + public static function getParentMethods($class) + { + $parent = get_parent_class($class); + $methods = []; + + foreach (['set', 'isset', 'unset', 'clone', 'serialize', 'unserialize', 'sleep', 'wakeup', 'destruct', 'get'] as $method) { + if (!$parent || !method_exists($parent, '__'.$method)) { + $methods[$method] = false; + } else { + $m = new \ReflectionMethod($parent, '__'.$method); + $methods[$method] = !$m->isAbstract() && !$m->isPrivate(); + } + } + + $methods['get'] = $methods['get'] ? ($m->returnsReference() ? 2 : 1) : 0; + + return $methods; + } + + public static function getScope($propertyScopes, $class, $property, $readonlyScope = null) + { + if (null === $readonlyScope && !isset($propertyScopes[$k = "\0$class\0$property"]) && !isset($propertyScopes[$k = "\0*\0$property"])) { + return null; + } + $frame = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]; + + if (\ReflectionProperty::class === $scope = $frame['class'] ?? \Closure::class) { + $scope = $frame['object']->class; + } + if (null === $readonlyScope && '*' === $k[1] && ($class === $scope || (is_subclass_of($class, $scope) && !isset($propertyScopes["\0$scope\0$property"])))) { + return null; + } + + return $scope; + } +} diff --git a/vendor/symfony/var-exporter/Internal/LazyObjectState.php b/vendor/symfony/var-exporter/Internal/LazyObjectState.php new file mode 100644 index 0000000..2f649dd --- /dev/null +++ b/vendor/symfony/var-exporter/Internal/LazyObjectState.php @@ -0,0 +1,130 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter\Internal; + +use Symfony\Component\VarExporter\Hydrator as PublicHydrator; + +/** + * Keeps the state of lazy objects. + * + * As a micro-optimization, this class uses no type declarations. + * + * @internal + */ +class LazyObjectState +{ + public const STATUS_UNINITIALIZED_FULL = 1; + public const STATUS_UNINITIALIZED_PARTIAL = 2; + public const STATUS_INITIALIZED_FULL = 3; + public const STATUS_INITIALIZED_PARTIAL = 4; + + /** + * @var array + */ + public readonly array $skippedProperties; + + /** + * @var self::STATUS_* + */ + public int $status = 0; + + public object $realInstance; + + public function __construct(public readonly \Closure|array $initializer, $skippedProperties = []) + { + $this->skippedProperties = $skippedProperties; + $this->status = \is_array($initializer) ? self::STATUS_UNINITIALIZED_PARTIAL : self::STATUS_UNINITIALIZED_FULL; + } + + public function initialize($instance, $propertyName, $propertyScope) + { + if (self::STATUS_INITIALIZED_FULL === $this->status) { + return self::STATUS_INITIALIZED_FULL; + } + + if (\is_array($this->initializer)) { + $class = $instance::class; + $propertyScope ??= $class; + $propertyScopes = Hydrator::$propertyScopes[$class]; + $propertyScopes[$k = "\0$propertyScope\0$propertyName"] ?? $propertyScopes[$k = "\0*\0$propertyName"] ?? $k = $propertyName; + + if ($initializer = $this->initializer[$k] ?? null) { + $value = $initializer(...[$instance, $propertyName, $propertyScope, LazyObjectRegistry::$defaultProperties[$class][$k] ?? null]); + $accessor = LazyObjectRegistry::$classAccessors[$propertyScope] ??= LazyObjectRegistry::getClassAccessors($propertyScope); + $accessor['set']($instance, $propertyName, $value); + + return $this->status = self::STATUS_INITIALIZED_PARTIAL; + } + + $status = self::STATUS_UNINITIALIZED_PARTIAL; + + if ($initializer = $this->initializer["\0"] ?? null) { + if (!\is_array($values = $initializer($instance, LazyObjectRegistry::$defaultProperties[$class]))) { + throw new \TypeError(sprintf('The lazy-initializer defined for instance of "%s" must return an array, got "%s".', $class, get_debug_type($values))); + } + $properties = (array) $instance; + foreach ($values as $key => $value) { + if ($k === $key) { + $status = self::STATUS_INITIALIZED_PARTIAL; + } + if (!\array_key_exists($key, $properties) && [$scope, $name, $readonlyScope] = $propertyScopes[$key] ?? null) { + $scope = $readonlyScope ?? ('*' !== $scope ? $scope : $class); + $accessor = LazyObjectRegistry::$classAccessors[$scope] ??= LazyObjectRegistry::getClassAccessors($scope); + $accessor['set']($instance, $name, $value); + } + } + } + + return $status; + } + + $this->status = self::STATUS_INITIALIZED_FULL; + + try { + if ($defaultProperties = array_diff_key(LazyObjectRegistry::$defaultProperties[$instance::class], $this->skippedProperties)) { + PublicHydrator::hydrate($instance, $defaultProperties); + } + + ($this->initializer)($instance); + } catch (\Throwable $e) { + $this->status = self::STATUS_UNINITIALIZED_FULL; + $this->reset($instance); + + throw $e; + } + + return self::STATUS_INITIALIZED_FULL; + } + + public function reset($instance): void + { + $class = $instance::class; + $propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class); + $skippedProperties = $this->skippedProperties; + $properties = (array) $instance; + $onlyProperties = \is_array($this->initializer) ? $this->initializer : null; + + foreach ($propertyScopes as $key => [$scope, $name, $readonlyScope]) { + $propertyScopes[$k = "\0$scope\0$name"] ?? $propertyScopes[$k = "\0*\0$name"] ?? $k = $name; + + if ($k === $key && (null !== $readonlyScope || !\array_key_exists($k, $properties))) { + $skippedProperties[$k] = true; + } + } + + foreach (LazyObjectRegistry::$classResetters[$class] as $reset) { + $reset($instance, $skippedProperties, $onlyProperties); + } + + $this->status = self::STATUS_INITIALIZED_FULL === $this->status ? self::STATUS_UNINITIALIZED_FULL : self::STATUS_UNINITIALIZED_PARTIAL; + } +} diff --git a/vendor/symfony/var-exporter/Internal/LazyObjectTrait.php b/vendor/symfony/var-exporter/Internal/LazyObjectTrait.php new file mode 100644 index 0000000..cccdf6c --- /dev/null +++ b/vendor/symfony/var-exporter/Internal/LazyObjectTrait.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter\Internal; + +if (\PHP_VERSION_ID >= 80300) { + /** + * @internal + */ + trait LazyObjectTrait + { + private readonly LazyObjectState $lazyObjectState; + } +} else { + /** + * @internal + */ + trait LazyObjectTrait + { + private LazyObjectState $lazyObjectState; + } +} diff --git a/vendor/symfony/var-exporter/Internal/Registry.php b/vendor/symfony/var-exporter/Internal/Registry.php index 24b77b9..09d2de2 100644 --- a/vendor/symfony/var-exporter/Internal/Registry.php +++ b/vendor/symfony/var-exporter/Internal/Registry.php @@ -58,9 +58,9 @@ class Registry public static function f($class) { - $reflector = self::$reflectors[$class] ?? self::getClassReflector($class, true, false); + $reflector = self::$reflectors[$class] ??= self::getClassReflector($class, true, false); - return self::$factories[$class] = \Closure::fromCallable([$reflector, 'newInstanceWithoutConstructor']); + return self::$factories[$class] = [$reflector, 'newInstanceWithoutConstructor'](...); } public static function getClassReflector($class, $instantiableWithoutConstructor = false, $cloneable = null) @@ -75,17 +75,17 @@ class Registry } elseif (!$isClass || $reflector->isAbstract()) { throw new NotInstantiableTypeException($class); } elseif ($reflector->name !== $class) { - $reflector = self::$reflectors[$name = $reflector->name] ?? self::getClassReflector($name, false, $cloneable); + $reflector = self::$reflectors[$name = $reflector->name] ??= self::getClassReflector($name, false, $cloneable); self::$cloneable[$class] = self::$cloneable[$name]; self::$instantiableWithoutConstructor[$class] = self::$instantiableWithoutConstructor[$name]; self::$prototypes[$class] = self::$prototypes[$name]; - return self::$reflectors[$class] = $reflector; + return $reflector; } else { try { $proto = $reflector->newInstanceWithoutConstructor(); $instantiableWithoutConstructor = true; - } catch (\ReflectionException $e) { + } catch (\ReflectionException) { $proto = $reflector->implementsInterface('Serializable') && !method_exists($class, '__unserialize') ? 'C:' : 'O:'; if ('C:' === $proto && !$reflector->getMethod('unserialize')->isInternal()) { $proto = null; @@ -103,7 +103,7 @@ class Registry } } } - if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__serialize'))) { + if (null !== $proto && !$proto instanceof \Throwable && !$proto instanceof \Serializable && !method_exists($class, '__sleep') && !method_exists($class, '__serialize')) { try { serialize($proto); } catch (\Exception $e) { @@ -113,7 +113,7 @@ class Registry } if (null === $cloneable) { - if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !method_exists($proto, '__wakeup') && (\PHP_VERSION_ID < 70400 || !method_exists($class, '__unserialize')))) { + if (($proto instanceof \Reflector || $proto instanceof \ReflectionGenerator || $proto instanceof \ReflectionType || $proto instanceof \IteratorIterator || $proto instanceof \RecursiveIteratorIterator) && (!$proto instanceof \Serializable && !method_exists($proto, '__wakeup') && !method_exists($class, '__unserialize'))) { throw new NotInstantiableTypeException($class); } @@ -132,15 +132,13 @@ class Registry new \ReflectionProperty(\Error::class, 'trace'), new \ReflectionProperty(\Exception::class, 'trace'), ]; - $setTrace[0]->setAccessible(true); - $setTrace[1]->setAccessible(true); - $setTrace[0] = \Closure::fromCallable([$setTrace[0], 'setValue']); - $setTrace[1] = \Closure::fromCallable([$setTrace[1], 'setValue']); + $setTrace[0] = $setTrace[0]->setValue(...); + $setTrace[1] = $setTrace[1]->setValue(...); } $setTrace[$proto instanceof \Exception]($proto, []); } - return self::$reflectors[$class] = $reflector; + return $reflector; } } diff --git a/vendor/symfony/var-exporter/LazyGhostTrait.php b/vendor/symfony/var-exporter/LazyGhostTrait.php new file mode 100644 index 0000000..13e33f5 --- /dev/null +++ b/vendor/symfony/var-exporter/LazyGhostTrait.php @@ -0,0 +1,391 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter; + +use Symfony\Component\VarExporter\Internal\Hydrator; +use Symfony\Component\VarExporter\Internal\LazyObjectRegistry as Registry; +use Symfony\Component\VarExporter\Internal\LazyObjectState; +use Symfony\Component\VarExporter\Internal\LazyObjectTrait; + +trait LazyGhostTrait +{ + use LazyObjectTrait; + + /** + * Creates a lazy-loading ghost instance. + * + * When the initializer is a closure, it should initialize all properties at + * once and is given the instance to initialize as argument. + * + * When the initializer is an array of closures, it should be indexed by + * properties and closures should accept 4 arguments: the instance to + * initialize, the property to initialize, its write-scope, and its default + * value. Each closure should return the value of the corresponding property. + * The special "\0" key can be used to define a closure that returns all + * properties at once when full-initialization is needed; it takes the + * instance and its default properties as arguments. + * + * Properties should be indexed by their array-cast name, see + * https://php.net/manual/language.types.array#language.types.array.casting + * + * @param (\Closure(static):void + * |array + * |array{"\0": \Closure(static, array):array}) $initializer + * @param array|null $skippedProperties An array indexed by the properties to skip, aka the ones + * that the initializer doesn't set when its a closure + * @param static|null $instance + */ + public static function createLazyGhost(\Closure|array $initializer, array $skippedProperties = null, object $instance = null): static + { + $onlyProperties = null === $skippedProperties && \is_array($initializer) ? $initializer : null; + + if (self::class !== $class = $instance ? $instance::class : static::class) { + $skippedProperties["\0".self::class."\0lazyObjectState"] = true; + } elseif (\defined($class.'::LAZY_OBJECT_PROPERTY_SCOPES')) { + Hydrator::$propertyScopes[$class] ??= $class::LAZY_OBJECT_PROPERTY_SCOPES; + } + + $instance ??= (Registry::$classReflectors[$class] ??= new \ReflectionClass($class))->newInstanceWithoutConstructor(); + Registry::$defaultProperties[$class] ??= (array) $instance; + $instance->lazyObjectState = new LazyObjectState($initializer, $skippedProperties ??= []); + + foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) { + $reset($instance, $skippedProperties, $onlyProperties); + } + + return $instance; + } + + /** + * Returns whether the object is initialized. + * + * @param $partial Whether partially initialized objects should be considered as initialized + */ + public function isLazyObjectInitialized(bool $partial = false): bool + { + if (!$state = $this->lazyObjectState ?? null) { + return true; + } + + if (!\is_array($state->initializer)) { + return LazyObjectState::STATUS_INITIALIZED_FULL === $state->status; + } + + $class = $this::class; + $properties = (array) $this; + + if ($partial) { + return (bool) array_intersect_key($state->initializer, $properties); + } + + $propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class); + foreach ($state->initializer as $key => $initializer) { + if (!\array_key_exists($key, $properties) && isset($propertyScopes[$key])) { + return false; + } + } + + return true; + } + + /** + * Forces initialization of a lazy object and returns it. + */ + public function initializeLazyObject(): static + { + if (!$state = $this->lazyObjectState ?? null) { + return $this; + } + + if (!\is_array($state->initializer)) { + if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) { + $state->initialize($this, '', null); + } + + return $this; + } + + $values = isset($state->initializer["\0"]) ? null : []; + + $class = $this::class; + $properties = (array) $this; + $propertyScopes = Hydrator::$propertyScopes[$class] ??= Hydrator::getPropertyScopes($class); + foreach ($state->initializer as $key => $initializer) { + if (\array_key_exists($key, $properties) || ![$scope, $name, $readonlyScope] = $propertyScopes[$key] ?? null) { + continue; + } + $scope = $readonlyScope ?? ('*' !== $scope ? $scope : $class); + + if (null === $values) { + if (!\is_array($values = ($state->initializer["\0"])($this, Registry::$defaultProperties[$class]))) { + throw new \TypeError(sprintf('The lazy-initializer defined for instance of "%s" must return an array, got "%s".', $class, get_debug_type($values))); + } + + if (\array_key_exists($key, $properties = (array) $this)) { + continue; + } + } + + if (\array_key_exists($key, $values)) { + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + $accessor['set']($this, $name, $properties[$key] = $values[$key]); + } else { + $state->initialize($this, $name, $scope); + $properties = (array) $this; + } + } + + return $this; + } + + /** + * @return bool Returns false when the object cannot be reset, ie when it's not a lazy object + */ + public function resetLazyObject(): bool + { + if (!$state = $this->lazyObjectState ?? null) { + return false; + } + + if (LazyObjectState::STATUS_UNINITIALIZED_FULL !== $state->status) { + $state->reset($this); + } + + return true; + } + + public function &__get($name): mixed + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name); + $state = $this->lazyObjectState ?? null; + + if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"])) + && LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $state->initialize($this, $name, $readonlyScope ?? $scope) + ) { + goto get_in_scope; + } + } + + if ($parent = (Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['get']) { + if (2 === $parent) { + return parent::__get($name); + } + $value = parent::__get($name); + + return $value; + } + + if (null === $class) { + $frame = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; + trigger_error(sprintf('Undefined property: %s::$%s in %s on line %s', $this::class, $name, $frame['file'], $frame['line']), \E_USER_NOTICE); + } + + get_in_scope: + + try { + if (null === $scope) { + if (null === $readonlyScope) { + return $this->$name; + } + $value = $this->$name; + + return $value; + } + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + + return $accessor['get']($this, $name, null !== $readonlyScope); + } catch (\Error $e) { + if (\Error::class !== $e::class || !str_starts_with($e->getMessage(), 'Cannot access uninitialized non-nullable property')) { + throw $e; + } + + try { + if (null === $scope) { + $this->$name = []; + + return $this->$name; + } + + $accessor['set']($this, $name, []); + + return $accessor['get']($this, $name, null !== $readonlyScope); + } catch (\Error) { + throw $e; + } + } + } + + public function __set($name, $value): void + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope); + $state = $this->lazyObjectState ?? null; + + if ($state && ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"]))) { + if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) { + $state->initialize($this, $name, $readonlyScope ?? $scope); + } + goto set_in_scope; + } + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['set']) { + parent::__set($name, $value); + + return; + } + + set_in_scope: + + if (null === $scope) { + $this->$name = $value; + } else { + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + $accessor['set']($this, $name, $value); + } + } + + public function __isset($name): bool + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name); + $state = $this->lazyObjectState ?? null; + + if ($state && (null === $scope || isset($propertyScopes["\0$scope\0$name"])) + && LazyObjectState::STATUS_UNINITIALIZED_PARTIAL !== $state->initialize($this, $name, $readonlyScope ?? $scope) + ) { + goto isset_in_scope; + } + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['isset']) { + return parent::__isset($name); + } + + isset_in_scope: + + if (null === $scope) { + return isset($this->$name); + } + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + + return $accessor['isset']($this, $name); + } + + public function __unset($name): void + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope); + $state = $this->lazyObjectState ?? null; + + if ($state && ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"]))) { + if (LazyObjectState::STATUS_UNINITIALIZED_FULL === $state->status) { + $state->initialize($this, $name, $readonlyScope ?? $scope); + } + goto unset_in_scope; + } + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['unset']) { + parent::__unset($name); + + return; + } + + unset_in_scope: + + if (null === $scope) { + unset($this->$name); + } else { + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + $accessor['unset']($this, $name); + } + } + + public function __clone(): void + { + if ($state = $this->lazyObjectState ?? null) { + $this->lazyObjectState = clone $state; + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) { + parent::__clone(); + } + } + + public function __serialize(): array + { + $class = self::class; + + if ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) { + $properties = parent::__serialize(); + } else { + $this->initializeLazyObject(); + $properties = (array) $this; + } + unset($properties["\0$class\0lazyObjectState"]); + + if (Registry::$parentMethods[$class]['serialize'] || !Registry::$parentMethods[$class]['sleep']) { + return $properties; + } + + $scope = get_parent_class($class); + $data = []; + + foreach (parent::__sleep() as $name) { + $value = $properties[$k = $name] ?? $properties[$k = "\0*\0$name"] ?? $properties[$k = "\0$scope\0$name"] ?? $k = null; + + if (null === $k) { + trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $name), \E_USER_NOTICE); + } else { + $data[$k] = $value; + } + } + + return $data; + } + + public function __destruct() + { + $state = $this->lazyObjectState ?? null; + + if ($state && \in_array($state->status, [LazyObjectState::STATUS_UNINITIALIZED_FULL, LazyObjectState::STATUS_UNINITIALIZED_PARTIAL], true)) { + return; + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['destruct']) { + parent::__destruct(); + } + } + + private function setLazyObjectAsInitialized(bool $initialized): void + { + $state = $this->lazyObjectState ?? null; + + if ($state && !\is_array($state->initializer)) { + $state->status = $initialized ? LazyObjectState::STATUS_INITIALIZED_FULL : LazyObjectState::STATUS_UNINITIALIZED_FULL; + } + } +} diff --git a/vendor/symfony/var-exporter/LazyObjectInterface.php b/vendor/symfony/var-exporter/LazyObjectInterface.php new file mode 100644 index 0000000..3670884 --- /dev/null +++ b/vendor/symfony/var-exporter/LazyObjectInterface.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter; + +interface LazyObjectInterface +{ + /** + * Returns whether the object is initialized. + * + * @param $partial Whether partially initialized objects should be considered as initialized + */ + public function isLazyObjectInitialized(bool $partial = false): bool; + + /** + * Forces initialization of a lazy object and returns it. + */ + public function initializeLazyObject(): object; + + /** + * @return bool Returns false when the object cannot be reset, ie when it's not a lazy object + */ + public function resetLazyObject(): bool; +} diff --git a/vendor/symfony/var-exporter/LazyProxyTrait.php b/vendor/symfony/var-exporter/LazyProxyTrait.php new file mode 100644 index 0000000..153c382 --- /dev/null +++ b/vendor/symfony/var-exporter/LazyProxyTrait.php @@ -0,0 +1,347 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter; + +use Symfony\Component\VarExporter\Hydrator as PublicHydrator; +use Symfony\Component\VarExporter\Internal\Hydrator; +use Symfony\Component\VarExporter\Internal\LazyObjectRegistry as Registry; +use Symfony\Component\VarExporter\Internal\LazyObjectState; +use Symfony\Component\VarExporter\Internal\LazyObjectTrait; + +trait LazyProxyTrait +{ + use LazyObjectTrait; + + /** + * Creates a lazy-loading virtual proxy. + * + * @param \Closure():object $initializer Returns the proxied object + * @param static|null $instance + */ + public static function createLazyProxy(\Closure $initializer, object $instance = null): static + { + if (self::class !== $class = $instance ? $instance::class : static::class) { + $skippedProperties = ["\0".self::class."\0lazyObjectState" => true]; + } elseif (\defined($class.'::LAZY_OBJECT_PROPERTY_SCOPES')) { + Hydrator::$propertyScopes[$class] ??= $class::LAZY_OBJECT_PROPERTY_SCOPES; + } + + $instance ??= (Registry::$classReflectors[$class] ??= new \ReflectionClass($class))->newInstanceWithoutConstructor(); + $instance->lazyObjectState = new LazyObjectState($initializer); + + foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) { + $reset($instance, $skippedProperties ??= []); + } + + return $instance; + } + + /** + * Returns whether the object is initialized. + * + * @param $partial Whether partially initialized objects should be considered as initialized + */ + public function isLazyObjectInitialized(bool $partial = false): bool + { + return !isset($this->lazyObjectState) || isset($this->lazyObjectState->realInstance) || Registry::$noInitializerState === $this->lazyObjectState->initializer; + } + + /** + * Forces initialization of a lazy object and returns it. + */ + public function initializeLazyObject(): parent + { + if ($state = $this->lazyObjectState ?? null) { + return $state->realInstance ??= ($state->initializer)(); + } + + return $this; + } + + /** + * @return bool Returns false when the object cannot be reset, ie when it's not a lazy object + */ + public function resetLazyObject(): bool + { + if (!isset($this->lazyObjectState) || Registry::$noInitializerState === $this->lazyObjectState->initializer) { + return false; + } + + unset($this->lazyObjectState->realInstance); + + return true; + } + + public function &__get($name): mixed + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + $instance = $this; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name); + + if (null === $scope || isset($propertyScopes["\0$scope\0$name"])) { + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } + $parent = 2; + goto get_in_scope; + } + } + $parent = (Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['get']; + + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } else { + if (2 === $parent) { + return parent::__get($name); + } + $value = parent::__get($name); + + return $value; + } + + if (!$parent && null === $class && !\array_key_exists($name, (array) $instance)) { + $frame = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]; + trigger_error(sprintf('Undefined property: %s::$%s in %s on line %s', $instance::class, $name, $frame['file'], $frame['line']), \E_USER_NOTICE); + } + + get_in_scope: + + try { + if (null === $scope) { + if (null === $readonlyScope && 1 !== $parent) { + return $instance->$name; + } + $value = $instance->$name; + + return $value; + } + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + + return $accessor['get']($instance, $name, null !== $readonlyScope || 1 === $parent); + } catch (\Error $e) { + if (\Error::class !== $e::class || !str_starts_with($e->getMessage(), 'Cannot access uninitialized non-nullable property')) { + throw $e; + } + + try { + if (null === $scope) { + $instance->$name = []; + + return $instance->$name; + } + + $accessor['set']($instance, $name, []); + + return $accessor['get']($instance, $name, null !== $readonlyScope || 1 === $parent); + } catch (\Error) { + throw $e; + } + } + } + + public function __set($name, $value): void + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + $instance = $this; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope); + + if ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"])) { + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } + goto set_in_scope; + } + } + + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['set']) { + parent::__set($name, $value); + + return; + } + + set_in_scope: + + if (null === $scope) { + $instance->$name = $value; + } else { + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + $accessor['set']($instance, $name, $value); + } + } + + public function __isset($name): bool + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + $instance = $this; + + if ([$class] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name); + + if (null === $scope || isset($propertyScopes["\0$scope\0$name"])) { + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } + goto isset_in_scope; + } + } + + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['isset']) { + return parent::__isset($name); + } + + isset_in_scope: + + if (null === $scope) { + return isset($instance->$name); + } + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + + return $accessor['isset']($instance, $name); + } + + public function __unset($name): void + { + $propertyScopes = Hydrator::$propertyScopes[$this::class] ??= Hydrator::getPropertyScopes($this::class); + $scope = null; + $instance = $this; + + if ([$class, , $readonlyScope] = $propertyScopes[$name] ?? null) { + $scope = Registry::getScope($propertyScopes, $class, $name, $readonlyScope); + + if ($readonlyScope === $scope || isset($propertyScopes["\0$scope\0$name"])) { + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } + goto unset_in_scope; + } + } + + if ($state = $this->lazyObjectState ?? null) { + $instance = $state->realInstance ??= ($state->initializer)(); + } elseif ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['unset']) { + parent::__unset($name); + + return; + } + + unset_in_scope: + + if (null === $scope) { + unset($instance->$name); + } else { + $accessor = Registry::$classAccessors[$scope] ??= Registry::getClassAccessors($scope); + $accessor['unset']($instance, $name); + } + } + + public function __clone(): void + { + if (!isset($this->lazyObjectState)) { + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['clone']) { + parent::__clone(); + } + + return; + } + + $this->lazyObjectState = clone $this->lazyObjectState; + + if (isset($this->lazyObjectState->realInstance)) { + $this->lazyObjectState->realInstance = clone $this->lazyObjectState->realInstance; + } + } + + public function __serialize(): array + { + $class = self::class; + $state = $this->lazyObjectState ?? null; + + if (!$state && (Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['serialize']) { + $properties = parent::__serialize(); + } else { + $properties = (array) $this; + + if ($state) { + unset($properties["\0$class\0lazyObjectState"]); + $properties["\0$class\0lazyObjectReal"] = $state->realInstance ??= ($state->initializer)(); + } + } + + if ($state || Registry::$parentMethods[$class]['serialize'] || !Registry::$parentMethods[$class]['sleep']) { + return $properties; + } + + $scope = get_parent_class($class); + $data = []; + + foreach (parent::__sleep() as $name) { + $value = $properties[$k = $name] ?? $properties[$k = "\0*\0$name"] ?? $properties[$k = "\0$scope\0$name"] ?? $k = null; + + if (null === $k) { + trigger_error(sprintf('serialize(): "%s" returned as member variable from __sleep() but does not exist', $name), \E_USER_NOTICE); + } else { + $data[$k] = $value; + } + } + + return $data; + } + + public function __unserialize(array $data): void + { + $class = self::class; + + if ($instance = $data["\0$class\0lazyObjectReal"] ?? null) { + unset($data["\0$class\0lazyObjectReal"]); + + foreach (Registry::$classResetters[$class] ??= Registry::getClassResetters($class) as $reset) { + $reset($this, $data); + } + + if ($data) { + PublicHydrator::hydrate($this, $data); + } + $this->lazyObjectState = new LazyObjectState(Registry::$noInitializerState ??= static fn () => throw new \LogicException('Lazy proxy has no initializer.')); + $this->lazyObjectState->realInstance = $instance; + } elseif ((Registry::$parentMethods[$class] ??= Registry::getParentMethods($class))['unserialize']) { + parent::__unserialize($data); + } else { + PublicHydrator::hydrate($this, $data); + + if (Registry::$parentMethods[$class]['wakeup']) { + parent::__wakeup(); + } + } + } + + public function __destruct() + { + if (isset($this->lazyObjectState)) { + return; + } + + if ((Registry::$parentMethods[self::class] ??= Registry::getParentMethods(self::class))['destruct']) { + parent::__destruct(); + } + } +} diff --git a/vendor/symfony/var-exporter/ProxyHelper.php b/vendor/symfony/var-exporter/ProxyHelper.php new file mode 100644 index 0000000..2e150cb --- /dev/null +++ b/vendor/symfony/var-exporter/ProxyHelper.php @@ -0,0 +1,365 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarExporter; + +use Symfony\Component\VarExporter\Exception\LogicException; +use Symfony\Component\VarExporter\Internal\Hydrator; +use Symfony\Component\VarExporter\Internal\LazyObjectRegistry; + +/** + * @author Nicolas Grekas + */ +final class ProxyHelper +{ + /** + * Helps generate lazy-loading ghost objects. + * + * @throws LogicException When the class is incompatible with ghost objects + */ + public static function generateLazyGhost(\ReflectionClass $class): string + { + if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class->isReadOnly()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is readonly.', $class->name)); + } + if ($class->isFinal()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is final.', $class->name)); + } + if ($class->isInterface() || $class->isAbstract()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: "%s" is not a concrete class.', $class->name)); + } + if (\stdClass::class !== $class->name && $class->isInternal()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" is internal.', $class->name)); + } + if ($class->hasMethod('__get') && 'mixed' !== (self::exportType($class->getMethod('__get')) ?? 'mixed')) { + throw new LogicException(sprintf('Cannot generate lazy ghost: return type of method "%s::__get()" should be "mixed".', $class->name)); + } + + static $traitMethods; + $traitMethods ??= (new \ReflectionClass(LazyGhostTrait::class))->getMethods(); + + foreach ($traitMethods as $method) { + if ($class->hasMethod($method->name) && $class->getMethod($method->name)->isFinal()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: method "%s::%s()" is final.', $class->name, $method->name)); + } + } + + $parent = $class; + while ($parent = $parent->getParentClass()) { + if (\stdClass::class !== $parent->name && $parent->isInternal()) { + throw new LogicException(sprintf('Cannot generate lazy ghost: class "%s" extends "%s" which is internal.', $class->name, $parent->name)); + } + } + $propertyScopes = self::exportPropertyScopes($class->name); + + return <<name} implements \Symfony\Component\VarExporter\LazyObjectInterface + { + use \Symfony\Component\VarExporter\LazyGhostTrait; + + private const LAZY_OBJECT_PROPERTY_SCOPES = {$propertyScopes}; + } + + // Help opcache.preload discover always-needed symbols + class_exists(\Symfony\Component\VarExporter\Internal\Hydrator::class); + class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectRegistry::class); + class_exists(\Symfony\Component\VarExporter\Internal\LazyObjectState::class); + + EOPHP; + } + + /** + * Helps generate lazy-loading virtual proxies. + * + * @param \ReflectionClass[] $interfaces + * + * @throws LogicException When the class is incompatible with virtual proxies + */ + public static function generateLazyProxy(?\ReflectionClass $class, array $interfaces = []): string + { + if (!class_exists($class?->name ?? \stdClass::class, false)) { + throw new LogicException(sprintf('Cannot generate lazy proxy: "%s" is not a class.', $class->name)); + } + if ($class?->isFinal()) { + throw new LogicException(sprintf('Cannot generate lazy proxy: class "%s" is final.', $class->name)); + } + if (\PHP_VERSION_ID >= 80200 && \PHP_VERSION_ID < 80300 && $class?->isReadOnly()) { + throw new LogicException(sprintf('Cannot generate lazy proxy: class "%s" is readonly.', $class->name)); + } + + $methodReflectors = [$class?->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) ?? []]; + foreach ($interfaces as $interface) { + if (!$interface->isInterface()) { + throw new LogicException(sprintf('Cannot generate lazy proxy: "%s" is not an interface.', $interface->name)); + } + $methodReflectors[] = $interface->getMethods(); + } + $methodReflectors = array_merge(...$methodReflectors); + + $extendsInternalClass = false; + if ($parent = $class) { + do { + $extendsInternalClass = \stdClass::class !== $parent->name && $parent->isInternal(); + } while (!$extendsInternalClass && $parent = $parent->getParentClass()); + } + $methodsHaveToBeProxied = $extendsInternalClass; + $methods = []; + + foreach ($methodReflectors as $method) { + if ('__get' !== strtolower($method->name) || 'mixed' === ($type = self::exportType($method) ?? 'mixed')) { + continue; + } + $methodsHaveToBeProxied = true; + $trait = new \ReflectionMethod(LazyProxyTrait::class, '__get'); + $body = \array_slice(file($trait->getFileName()), $trait->getStartLine() - 1, $trait->getEndLine() - $trait->getStartLine()); + $body[0] = str_replace('): mixed', '): '.$type, $body[0]); + $methods['__get'] = strtr(implode('', $body).' }', [ + 'Hydrator' => '\\'.Hydrator::class, + 'Registry' => '\\'.LazyObjectRegistry::class, + ]); + break; + } + + foreach ($methodReflectors as $method) { + if (($method->isStatic() && !$method->isAbstract()) || isset($methods[$lcName = strtolower($method->name)])) { + continue; + } + if ($method->isFinal()) { + if ($extendsInternalClass || $methodsHaveToBeProxied || method_exists(LazyProxyTrait::class, $method->name)) { + throw new LogicException(sprintf('Cannot generate lazy proxy: method "%s::%s()" is final.', $class->name, $method->name)); + } + continue; + } + if (method_exists(LazyProxyTrait::class, $method->name) || ($method->isProtected() && !$method->isAbstract())) { + continue; + } + + $signature = self::exportSignature($method, true, $args); + $parentCall = $method->isAbstract() ? "throw new \BadMethodCallException('Cannot forward abstract method \"{$method->class}::{$method->name}()\".')" : "parent::{$method->name}({$args})"; + + if ($method->isStatic()) { + $body = " $parentCall;"; + } elseif (str_ends_with($signature, '): never') || str_ends_with($signature, '): void')) { + $body = <<lazyObjectState)) { + (\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args}); + } else { + {$parentCall}; + } + EOPHP; + } else { + if (!$methodsHaveToBeProxied && !$method->isAbstract()) { + // Skip proxying methods that might return $this + foreach (preg_split('/[()|&]++/', self::exportType($method) ?? 'static') as $type) { + if (\in_array($type = ltrim($type, '?'), ['static', 'object'], true)) { + continue 2; + } + foreach ([$class, ...$interfaces] as $r) { + if ($r && is_a($r->name, $type, true)) { + continue 3; + } + } + } + } + + $body = <<lazyObjectState)) { + return (\$this->lazyObjectState->realInstance ??= (\$this->lazyObjectState->initializer)())->{$method->name}({$args}); + } + + return {$parentCall}; + EOPHP; + } + $methods[$lcName] = " {$signature}\n {\n{$body}\n }"; + } + + $types = $interfaces = array_unique(array_column($interfaces, 'name')); + $interfaces[] = LazyObjectInterface::class; + $interfaces = implode(', \\', $interfaces); + $parent = $class ? ' extends \\'.$class->name : ''; + array_unshift($types, $class ? 'parent' : ''); + $type = ltrim(implode('&\\', $types), '&'); + + if (!$class) { + $trait = new \ReflectionMethod(LazyProxyTrait::class, 'initializeLazyObject'); + $body = \array_slice(file($trait->getFileName()), $trait->getStartLine() - 1, $trait->getEndLine() - $trait->getStartLine()); + $body[0] = str_replace('): parent', '): '.$type, $body[0]); + $methods = ['initializeLazyObject' => implode('', $body).' }'] + $methods; + } + $body = $methods ? "\n".implode("\n\n", $methods)."\n" : ''; + $propertyScopes = $class ? self::exportPropertyScopes($class->name) : '[]'; + + return <<getParameters() as $param) { + $parameters[] = ($param->getAttributes(\SensitiveParameter::class) ? '#[\SensitiveParameter] ' : '') + .($withParameterTypes && $param->hasType() ? self::exportType($param).' ' : '') + .($param->isPassedByReference() ? '&' : '') + .($param->isVariadic() ? '...' : '').'$'.$param->name + .($param->isOptional() && !$param->isVariadic() ? ' = '.self::exportDefault($param) : ''); + $hasByRef = $hasByRef || $param->isPassedByReference(); + $args .= ($param->isVariadic() ? '...$' : '$').$param->name.', '; + } + + if (!$param || !$hasByRef) { + $args = '...\func_get_args()'; + } elseif ($param->isVariadic()) { + $args = substr($args, 0, -2); + } else { + $args .= sprintf('...\array_slice(\func_get_args(), %d)', \count($parameters)); + } + + $signature = 'function '.($function->returnsReference() ? '&' : '') + .($function->isClosure() ? '' : $function->name).'('.implode(', ', $parameters).')'; + + if ($function instanceof \ReflectionMethod) { + $signature = ($function->isPublic() ? 'public ' : ($function->isProtected() ? 'protected ' : 'private ')) + .($function->isStatic() ? 'static ' : '').$signature; + } + if ($function->hasReturnType()) { + $signature .= ': '.self::exportType($function); + } + + static $getPrototype; + $getPrototype ??= (new \ReflectionMethod(\ReflectionMethod::class, 'getPrototype'))->invoke(...); + + while ($function) { + if ($function->hasTentativeReturnType()) { + return '#[\ReturnTypeWillChange] '.$signature; + } + + try { + $function = $function instanceof \ReflectionMethod && $function->isAbstract() ? false : $getPrototype($function); + } catch (\ReflectionException) { + break; + } + } + + return $signature; + } + + public static function exportType(\ReflectionFunctionAbstract|\ReflectionProperty|\ReflectionParameter $owner, bool $noBuiltin = false, \ReflectionType $type = null): ?string + { + if (!$type ??= $owner instanceof \ReflectionFunctionAbstract ? $owner->getReturnType() : $owner->getType()) { + return null; + } + $class = null; + $types = []; + if ($type instanceof \ReflectionUnionType) { + $reflectionTypes = $type->getTypes(); + $glue = '|'; + } elseif ($type instanceof \ReflectionIntersectionType) { + $reflectionTypes = $type->getTypes(); + $glue = '&'; + } else { + $reflectionTypes = [$type]; + $glue = null; + } + + foreach ($reflectionTypes as $type) { + if ($type instanceof \ReflectionIntersectionType) { + if ('' !== $name = '('.self::exportType($owner, $noBuiltin, $type).')') { + $types[] = $name; + } + continue; + } + $name = $type->getName(); + + if ($noBuiltin && $type->isBuiltin()) { + continue; + } + if (\in_array($name, ['parent', 'self'], true) && $class ??= $owner->getDeclaringClass()) { + $name = 'parent' === $name ? ($class->getParentClass() ?: null)?->name ?? 'parent' : $class->name; + } + + $types[] = ($noBuiltin || $type->isBuiltin() || 'static' === $name ? '' : '\\').$name; + } + + if (!$types) { + return ''; + } + if (null === $glue) { + return (!$noBuiltin && $type->allowsNull() && 'mixed' !== $name ? '?' : '').$types[0]; + } + sort($types); + + return implode($glue, $types); + } + + private static function exportPropertyScopes(string $parent): string + { + $propertyScopes = Hydrator::$propertyScopes[$parent] ??= Hydrator::getPropertyScopes($parent); + uksort($propertyScopes, 'strnatcmp'); + $propertyScopes = VarExporter::export($propertyScopes); + $propertyScopes = str_replace(VarExporter::export($parent), 'parent::class', $propertyScopes); + $propertyScopes = preg_replace("/(?|(,)\n( ) |\n |,\n (\]))/", '$1$2', $propertyScopes); + $propertyScopes = str_replace("\n", "\n ", $propertyScopes); + + return $propertyScopes; + } + + private static function exportDefault(\ReflectionParameter $param): string + { + $default = rtrim(substr(explode('$'.$param->name.' = ', (string) $param, 2)[1] ?? '', 0, -2)); + + if (\in_array($default, ['', 'NULL'], true)) { + return 'null'; + } + if (str_ends_with($default, "...'") && preg_match("/^'(?:[^'\\\\]*+(?:\\\\.)*+)*+'$/", $default)) { + return VarExporter::export($param->getDefaultValue()); + } + + $regexp = "/(\"(?:[^\"\\\\]*+(?:\\\\.)*+)*+\"|'(?:[^'\\\\]*+(?:\\\\.)*+)*+')/"; + $parts = preg_split($regexp, $default, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + + $regexp = '/([\[\( ]|^)([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z0-9_\x7f-\xff]++)*+)(?!: )/'; + $callback = (false !== strpbrk($default, "\\:('") && $class = $param->getDeclaringClass()) + ? fn ($m) => $m[1].match ($m[2]) { + 'new', 'false', 'true', 'null' => $m[2], + 'NULL' => 'null', + 'self' => '\\'.$class->name, + 'namespace\\parent', + 'parent' => ($parent = $class->getParentClass()) ? '\\'.$parent->name : 'parent', + default => '\\'.$m[2], + } + : fn ($m) => $m[1].match ($m[2]) { + 'new', 'false', 'true', 'null', 'self', 'parent' => $m[2], + 'NULL' => 'null', + default => '\\'.$m[2], + }; + + return implode('', array_map(fn ($part) => match ($part[0]) { + '"' => $part, // for internal classes only + "'" => false !== strpbrk($part, "\\\0\r\n") ? '"'.substr(str_replace(['$', "\0", "\r", "\n"], ['\$', '\0', '\r', '\n'], $part), 1, -1).'"' : $part, + default => preg_replace_callback($regexp, $callback, $part), + }, $parts)); + } +} diff --git a/vendor/symfony/var-exporter/README.md b/vendor/symfony/var-exporter/README.md index a34e4c2..7c7a58e 100644 --- a/vendor/symfony/var-exporter/README.md +++ b/vendor/symfony/var-exporter/README.md @@ -1,15 +1,22 @@ VarExporter Component ===================== -The VarExporter component allows exporting any serializable PHP data structure to -plain PHP code. While doing so, it preserves all the semantics associated with -the serialization mechanism of PHP (`__wakeup`, `__sleep`, `Serializable`, -`__serialize`, `__unserialize`). +The VarExporter component provides various tools to deal with the internal state +of objects: -It also provides an instantiator that allows creating and populating objects -without calling their constructor nor any other methods. +- `VarExporter::export()` allows exporting any serializable PHP data structure to + plain PHP code. While doing so, it preserves all the semantics associated with + the serialization mechanism of PHP (`__wakeup`, `__sleep`, `Serializable`, + `__serialize`, `__unserialize`.) +- `Instantiator::instantiate()` creates an object and sets its properties without + calling its constructor nor any other methods. +- `Hydrator::hydrate()` can set the properties of an existing object. +- `Lazy*Trait` can make a class behave as a lazy-loading ghost or virtual proxy. -The reason to use this component *vs* `serialize()` or +VarExporter::export() +--------------------- + +The reason to use `VarExporter::export()` *vs* `serialize()` or [igbinary](https://github.com/igbinary/igbinary) is performance: thanks to OPcache, the resulting code is significantly faster and more memory efficient than using `unserialize()` or `igbinary_unserialize()`. @@ -20,14 +27,118 @@ It also provides a few improvements over `var_export()`/`serialize()`: * the output is PSR-2 compatible; * the output can be re-indented without messing up with `\r` or `\n` in the data - * missing classes throw a `ClassNotFoundException` instead of being unserialized to - `PHP_Incomplete_Class` objects; + * missing classes throw a `ClassNotFoundException` instead of being unserialized + to `PHP_Incomplete_Class` objects; * references involving `SplObjectStorage`, `ArrayObject` or `ArrayIterator` instances are preserved; * `Reflection*`, `IteratorIterator` and `RecursiveIteratorIterator` classes throw an exception when being serialized (their unserialized version is broken anyway, see https://bugs.php.net/76737). +Instantiator and Hydrator +------------------------- + +`Instantiator::instantiate($class)` creates an object of the given class without +calling its constructor nor any other methods. + +`Hydrator::hydrate()` sets the properties of an existing object, including +private and protected ones. For example: + +```php +// Sets the public or protected $object->propertyName property +Hydrator::hydrate($object, ['propertyName' => $propertyValue]); + +// Sets a private property defined on its parent Bar class: +Hydrator::hydrate($object, ["\0Bar\0privateBarProperty" => $propertyValue]); + +// Alternative way to set the private $object->privateBarProperty property +Hydrator::hydrate($object, [], [ + Bar::class => ['privateBarProperty' => $propertyValue], +]); +``` + +`Lazy*Trait` +------------ + +The component provides two lazy-loading patterns: ghost objects and virtual +proxies (see https://martinfowler.com/eaaCatalog/lazyLoad.html for reference.) + +Ghost objects work only with concrete and non-internal classes. In the generic +case, they are not compatible with using factories in their initializer. + +Virtual proxies work with concrete, abstract or internal classes. They provide an +API that looks like the actual objects and forward calls to them. They can cause +identity problems because proxies might not be seen as equivalents to the actual +objects they proxy. + +Because of this identity problem, ghost objects should be preferred when +possible. Exceptions thrown by the `ProxyHelper` class can help decide when it +can be used or not. + +Ghost objects and virtual proxies both provide implementations for the +`LazyObjectInterface` which allows resetting them to their initial state or to +forcibly initialize them when needed. Note that resetting a ghost object skips +its read-only properties. You should use a virtual proxy to reset read-only +properties. + +### `LazyGhostTrait` + +By using `LazyGhostTrait` either directly in your classes or by using +`ProxyHelper::generateLazyGhost()`, you can make their instances lazy-loadable. +This works by creating these instances empty and by computing their state only +when accessing a property. + +```php +class FooLazyGhost extends Foo +{ + use LazyGhostTrait; +} + +$foo = FooLazyGhost::createLazyGhost(initializer: function (Foo $instance): void { + // [...] Use whatever heavy logic you need here + // to compute the $dependencies of the $instance + $instance->__construct(...$dependencies); + // [...] Call setters, etc. if needed +}); + +// $foo is now a lazy-loading ghost object. The initializer will +// be called only when and if a *property* is accessed. +``` + +You can also partially initialize the objects on a property-by-property basis by +adding two arguments to the initializer: + +```php +$initializer = function (Foo $instance, string $propertyName, ?string $propertyScope): mixed { + if (Foo::class === $propertyScope && 'bar' === $propertyName) { + return 123; + } + // [...] Add more logic for the other properties +}; +``` + +### `LazyProxyTrait` + +Alternatively, `LazyProxyTrait` can be used to create virtual proxies: + +```php +$proxyCode = ProxyHelper::generateLazyProxy(new ReflectionClass(Foo::class)); +// $proxyCode contains the reference to LazyProxyTrait +// and should be dumped into a file in production envs +eval('class FooLazyProxy'.$proxyCode); + +$foo = FooLazyProxy::createLazyProxy(initializer: function (): Foo { + // [...] Use whatever heavy logic you need here + // to compute the $dependencies of the $instance + $instance = new Foo(...$dependencies); + // [...] Call setters, etc. if needed + + return $instance; +}); +// $foo is now a lazy-loading virtual proxy object. The initializer will +// be called only when and if a *method* is called. +``` + Resources --------- diff --git a/vendor/symfony/var-exporter/VarExporter.php b/vendor/symfony/var-exporter/VarExporter.php index 8581337..c12eb4f 100644 --- a/vendor/symfony/var-exporter/VarExporter.php +++ b/vendor/symfony/var-exporter/VarExporter.php @@ -32,13 +32,12 @@ final class VarExporter /** * Exports a serializable PHP value to PHP code. * - * @param mixed $value The value to export * @param bool &$isStaticValue Set to true after execution if the provided value is static, false otherwise * @param array &$foundClasses Classes found in the value are added to this list as both keys and values * * @throws ExceptionInterface When the provided value cannot be serialized */ - public static function export($value, bool &$isStaticValue = null, array &$foundClasses = []): string + public static function export(mixed $value, bool &$isStaticValue = null, array &$foundClasses = []): string { $isStaticValue = true; diff --git a/vendor/symfony/var-exporter/composer.json b/vendor/symfony/var-exporter/composer.json index 29d4901..83140ee 100644 --- a/vendor/symfony/var-exporter/composer.json +++ b/vendor/symfony/var-exporter/composer.json @@ -2,7 +2,7 @@ "name": "symfony/var-exporter", "type": "library", "description": "Allows exporting any serializable PHP data structure to plain PHP code", - "keywords": ["export", "serialize", "instantiate", "hydrate", "construct", "clone"], + "keywords": ["export", "serialize", "instantiate", "hydrate", "construct", "clone", "lazy-loading", "proxy"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ @@ -16,11 +16,10 @@ } ], "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" }, "require-dev": { - "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + "symfony/var-dumper": "^5.4|^6.0" }, "autoload": { "psr-4": { "Symfony\\Component\\VarExporter\\": "" }, diff --git a/vendor/taoser/think-addons/README.md b/vendor/taoser/think-addons/README.md index 5ca893c..e529117 100644 --- a/vendor/taoser/think-addons/README.md +++ b/vendor/taoser/think-addons/README.md @@ -1,5 +1,5 @@ # think-addons -The ThinkPHP 6 Addons Package +The ThinkPHP 8 Addons Package ## 安装 > composer require taoser/think-addons @@ -80,7 +80,7 @@ class Plugin extends Addons // 需继承think\Addons类 public $info = [ 'name' => 'test', // 插件标识 'title' => '插件测试', // 插件名称 - 'description' => 'thinkph6插件测试', // 插件简介 + 'description' => 'thinkph8插件测试', // 插件简介 'status' => 0, // 状态 'author' => 'byron sampson', 'version' => '0.1' diff --git a/vendor/taoser/think-addons/composer.json b/vendor/taoser/think-addons/composer.json index 81d0f06..f25f210 100644 --- a/vendor/taoser/think-addons/composer.json +++ b/vendor/taoser/think-addons/composer.json @@ -1,6 +1,6 @@ { "name": "taoser/think-addons", - "description": "The ThinkPHP6 Addons Package", + "description": "The ThinkPHP8 Addons Package", "license": "mit", "authors": [ { @@ -9,11 +9,11 @@ } ], "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0", - "topthink/think-view": "^1.0", + "php": ">=8.0.0", + "topthink/framework": "^8.0", + "topthink/think-view": "^2.0", "topthink/think-helper": "^3.0.0", - "symfony/var-exporter": "^5.4" + "symfony/var-exporter": "^6.0" }, "autoload": { "psr-4": { diff --git a/vendor/taoser/think-auth/README.md b/vendor/taoser/think-auth/README.md index c4701b6..cb46f4a 100644 --- a/vendor/taoser/think-auth/README.md +++ b/vendor/taoser/think-auth/README.md @@ -1,11 +1,11 @@ # thinkphp-auth -ThinkPHP6权限Auth扩展 +ThinkPHP8权限Auth扩展 ## 安装 ~~~php -//thinkphp6.0 +//thinkphp8.0 composer require taoser/think-auth ~~~ diff --git a/vendor/taoser/think-auth/composer.json b/vendor/taoser/think-auth/composer.json index 4df28de..9bf945b 100644 --- a/vendor/taoser/think-auth/composer.json +++ b/vendor/taoser/think-auth/composer.json @@ -1,7 +1,7 @@ { "name": "taoser/think-auth", "description": "The Auth package forThinkphp6,ThinkPHP6的Auth权限扩展", - "keywords": ["think-auth", "thinkphp6"], + "keywords": ["think-auth", "thinkphp8"], "homepage": "https://github.com/taoser/think-auth", "license": "Apache-2.0", "type": "think-extend", @@ -12,8 +12,8 @@ } ], "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" + "php": ">=8.0.0", + "topthink/framework": "^8.0" }, "autoload": { "psr-4": { diff --git a/vendor/taoser/think-setarr/README.md b/vendor/taoser/think-setarr/README.md index 99f5cfb..ecb7fb0 100644 --- a/vendor/taoser/think-setarr/README.md +++ b/vendor/taoser/think-setarr/README.md @@ -218,4 +218,10 @@ $conf = SetArr::name('app')->delete($del); ``` +### 清理空数组 + +``` +Set::name('app')->clearNullArr(); +``` + 详细参考 [作者](http://wiki.aieok.com) \ No newline at end of file diff --git a/vendor/taoser/think-setarr/src/SetArr.php b/vendor/taoser/think-setarr/src/SetArr.php index 383562f..8c672cc 100644 --- a/vendor/taoser/think-setarr/src/SetArr.php +++ b/vendor/taoser/think-setarr/src/SetArr.php @@ -2,10 +2,10 @@ /* * @Author: TaoLer * @Date: 2022-04-14 16:05:35 - * @LastEditTime: 2022-05-09 11:31:00 + * @LastEditTime: 2022-04-17 07:04:31 * @LastEditors: TaoLer - * @Description: 搜索引擎SEO优化设置 - * @FilePath: \TaoLer\vendor\taoser\think-setarr\src\SetArr.php + * @Description: Config配置文件设置 + * @FilePath: \undefinede:\github\think-setarr\src\SetArr.php * Copyright (c) 2020~2022 https://www.aieok.com All rights reserved. */ namespace taoser; @@ -219,7 +219,6 @@ class SetArr //$kpats = '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/'; // 添加一维数组,数组中有元素匹配到最后一个数组,没有数组,匹配到数组开头[ $kpats = self::getArrSonCount(config(self::$configName.'.'.$k)) ? '/\''.$k.'\'\s*=>\s*\[[^\[|\]]*,\r?\n/' : '/\''.$k.'\'\s*=>\s*\[\r?\n/'; - preg_match($kpats,self::$str,$arrk); if(!is_int($kk)) { @@ -785,18 +784,24 @@ class SetArr } } - /* 匹配空数组 - * 'key' => [ - * ], - */ - $nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m'; - //preg_match($nullArray,self::$str,$arr); - //self::$str = preg_replace($nullArray, '', self::$str); + // 是否清理空数组? } //写入配置 return file_put_contents(self::$configFile, self::$str) ? true : false; } + + /* 匹配空数组 + * 'key' => [ + * ], + */ + public static function clearNullArr() + { + $nullArray = '/[^\n]*\'\w+\'\s*=>\s*\[\s*\]{1}\S*\,?\r?\n/m'; + //preg_match($nullArray,self::$str,$arr); + self::$str = preg_replace($nullArray, '', self::$str); + return file_put_contents(self::$configFile, self::$str) ? true : false; + } /** * 获取数组中子元素为数组的个数 diff --git a/vendor/tightenco/collect/.github/workflows/run-tests.yml b/vendor/tightenco/collect/.github/workflows/run-tests.yml deleted file mode 100644 index 2a0d42f..0000000 --- a/vendor/tightenco/collect/.github/workflows/run-tests.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Run tests - -on: - push: - branches: [laravel-9-ongoing, laravel-8-ongoing] - pull_request: - -jobs: - tests: - strategy: - matrix: - os: [Ubuntu, macOS] - php: [7.3, 7.4, 8.0, 8.1] - - include: - - os: Ubuntu - os-version: ubuntu-latest - - - os: macOS - os-version: macos-latest - - name: ${{ matrix.os }} - PHP ${{ matrix.php }} - - runs-on: ${{ matrix.os-version }} - - steps: - - name: Checkout code - uses: actions/checkout@v1 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: posix, dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: none - - - name: Install dependencies - run: composer update --prefer-stable --prefer-dist --no-interaction - - - name: Run tests - run: bash upgrade.sh diff --git a/vendor/tightenco/collect/branch-commit-push.sh b/vendor/tightenco/collect/branch-commit-push.sh deleted file mode 100644 index 124e583..0000000 --- a/vendor/tightenco/collect/branch-commit-push.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - - -GREEN='\033[0;32m' -RED='\033[0;31m' -WHITE='\033[0;37m' -RESET='\033[0m' - -function validateVersion() -{ - echo "" - passedVersion=$1 - echo -e "${WHITE}-- Validating tag '$passedVersion'...${RESET}" - - # Todo: validate the version here using a regex; if fail, just exit - # ... expect 8.75.0, with no v in front of it - - if [[ $passedVersion == '' ]]; then - echo -e "\n-- Invalid tag. Tags should be structured without v; e.g. 8.57.0" - exit - fi - - echo -e "${WHITE}-- Tag valid.${RESET}" - echo "" -} - -# Exit script if any command fails (e.g. phpunit) -set -e - - -# Require confirmation it's set up corrctly -echo -echo -e "${WHITE}-- This script is meant to be run after running upgrade.sh, BEFORE committing to Git.${RESET}" - -while true; do - echo -e "${GREEN}-- Is that the current state of your local project?${RESET}" - read -p "-- (y/n) " yn - case $yn in - [Yy]* ) break;; - [Nn]* ) exit;; - * ) echo "Please answer y or n.";; - esac -done - -# Get the version and exit if not valid -validateVersion $1 - -# Create official v prefaced version -version="v$1" - -# Run tests (and bail if they fail) -phpunit -echo -e "\n${WHITE}-- Tests succeeded.${RESET}" - -# Branch -echo -e "\n${WHITE}-- Creating a Git branch '$version-changes'...${RESET}\n" -git checkout -b $version-changes - -# Add and commit, with "v8.57.0 changes" as the commit name -git add -A -git commit -m "$version changes" - -echo -echo -e "${WHITE}-- Git committed.${RESET}" - -# Push -git push -u origin $version-changes diff --git a/vendor/tightenco/collect/composer.json b/vendor/tightenco/collect/composer.json deleted file mode 100644 index 88ebb77..0000000 --- a/vendor/tightenco/collect/composer.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "tightenco/collect", - "description": "Collect - Illuminate Collections as a separate package.", - "keywords": ["laravel", "collection"], - "license": "MIT", - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylorotwell@gmail.com" - } - ], - "require": { - "php": "^7.3|^8.0", - "symfony/var-dumper": "^3.4 || ^4.0 || ^5.0 || ^6.0" - }, - "require-dev": { - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^8.3", - "nesbot/carbon": "^2.23.0" - }, - "autoload": { - "files": [ - "src/Collect/Support/helpers.php", - "src/Collect/Support/alias.php" - ], - "psr-4": { - "Tightenco\\Collect\\": "src/Collect" - } - }, - "autoload-dev": { - "files": [ - "tests/files/Support/Carbon.php", - "tests/files/Support/HtmlString.php", - "tests/files/Support/HigherOrderTapProxy.php", - "tests/files/Support/Str.php", - "tests/files/Support/Traits/Conditionable.php", - "tests/files/Support/Stringable.php", - "tests/files/Support/ItemNotFoundException.php", - "tests/files/Support/MultipleItemsFoundException.php", - "tests/Support/Concerns/CountsEnumerations.php" - ] - }, - "scripts": { - "test": [ - "@composer install", - "phpunit" - ] - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/vendor/tightenco/collect/framework-.zip b/vendor/tightenco/collect/framework-.zip deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/tightenco/collect/src/Collect/Contracts/Support/Arrayable.php b/vendor/tightenco/collect/src/Collect/Contracts/Support/Arrayable.php deleted file mode 100644 index a205804..0000000 --- a/vendor/tightenco/collect/src/Collect/Contracts/Support/Arrayable.php +++ /dev/null @@ -1,13 +0,0 @@ -all(); - } elseif (! is_array($values)) { - continue; - } - - $results[] = $values; - } - - return array_merge([], ...$results); - } - - /** - * Cross join the given arrays, returning all possible permutations. - * - * @param iterable ...$arrays - * @return array - */ - public static function crossJoin(...$arrays) - { - $results = [[]]; - - foreach ($arrays as $index => $array) { - $append = []; - - foreach ($results as $product) { - foreach ($array as $item) { - $product[$index] = $item; - - $append[] = $product; - } - } - - $results = $append; - } - - return $results; - } - - /** - * Divide an array into two arrays. One with keys and the other with values. - * - * @param array $array - * @return array - */ - public static function divide($array) - { - return [array_keys($array), array_values($array)]; - } - - /** - * Flatten a multi-dimensional associative array with dots. - * - * @param iterable $array - * @param string $prepend - * @return array - */ - public static function dot($array, $prepend = '') - { - $results = []; - - foreach ($array as $key => $value) { - if (is_array($value) && ! empty($value)) { - $results = array_merge($results, static::dot($value, $prepend.$key.'.')); - } else { - $results[$prepend.$key] = $value; - } - } - - return $results; - } - - /** - * Convert a flatten "dot" notation array into an expanded array. - * - * @param iterable $array - * @return array - */ - public static function undot($array) - { - $results = []; - - foreach ($array as $key => $value) { - static::set($results, $key, $value); - } - - return $results; - } - - /** - * Get all of the given array except for a specified array of keys. - * - * @param array $array - * @param array|string $keys - * @return array - */ - public static function except($array, $keys) - { - static::forget($array, $keys); - - return $array; - } - - /** - * Determine if the given key exists in the provided array. - * - * @param \ArrayAccess|array $array - * @param string|int $key - * @return bool - */ - public static function exists($array, $key) - { - if ($array instanceof Enumerable) { - return $array->has($key); - } - - if ($array instanceof ArrayAccess) { - return $array->offsetExists($key); - } - - return array_key_exists($key, $array); - } - - /** - * Return the first element in an array passing a given truth test. - * - * @param iterable $array - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public static function first($array, callable $callback = null, $default = null) - { - if (is_null($callback)) { - if (empty($array)) { - return value($default); - } - - foreach ($array as $item) { - return $item; - } - } - - foreach ($array as $key => $value) { - if ($callback($value, $key)) { - return $value; - } - } - - return value($default); - } - - /** - * Return the last element in an array passing a given truth test. - * - * @param array $array - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public static function last($array, callable $callback = null, $default = null) - { - if (is_null($callback)) { - return empty($array) ? value($default) : end($array); - } - - return static::first(array_reverse($array, true), $callback, $default); - } - - /** - * Flatten a multi-dimensional array into a single level. - * - * @param iterable $array - * @param int $depth - * @return array - */ - public static function flatten($array, $depth = INF) - { - $result = []; - - foreach ($array as $item) { - $item = $item instanceof Collection ? $item->all() : $item; - - if (! is_array($item)) { - $result[] = $item; - } else { - $values = $depth === 1 - ? array_values($item) - : static::flatten($item, $depth - 1); - - foreach ($values as $value) { - $result[] = $value; - } - } - } - - return $result; - } - - /** - * Remove one or many array items from a given array using "dot" notation. - * - * @param array $array - * @param array|string $keys - * @return void - */ - public static function forget(&$array, $keys) - { - $original = &$array; - - $keys = (array) $keys; - - if (count($keys) === 0) { - return; - } - - foreach ($keys as $key) { - // if the exact key exists in the top-level, remove it - if (static::exists($array, $key)) { - unset($array[$key]); - - continue; - } - - $parts = explode('.', $key); - - // clean up before each pass - $array = &$original; - - while (count($parts) > 1) { - $part = array_shift($parts); - - if (isset($array[$part]) && is_array($array[$part])) { - $array = &$array[$part]; - } else { - continue 2; - } - } - - unset($array[array_shift($parts)]); - } - } - - /** - * Get an item from an array using "dot" notation. - * - * @param \ArrayAccess|array $array - * @param string|int|null $key - * @param mixed $default - * @return mixed - */ - public static function get($array, $key, $default = null) - { - if (! static::accessible($array)) { - return value($default); - } - - if (is_null($key)) { - return $array; - } - - if (static::exists($array, $key)) { - return $array[$key]; - } - - if (strpos($key, '.') === false) { - return $array[$key] ?? value($default); - } - - foreach (explode('.', $key) as $segment) { - if (static::accessible($array) && static::exists($array, $segment)) { - $array = $array[$segment]; - } else { - return value($default); - } - } - - return $array; - } - - /** - * Check if an item or items exist in an array using "dot" notation. - * - * @param \ArrayAccess|array $array - * @param string|array $keys - * @return bool - */ - public static function has($array, $keys) - { - $keys = (array) $keys; - - if (! $array || $keys === []) { - return false; - } - - foreach ($keys as $key) { - $subKeyArray = $array; - - if (static::exists($array, $key)) { - continue; - } - - foreach (explode('.', $key) as $segment) { - if (static::accessible($subKeyArray) && static::exists($subKeyArray, $segment)) { - $subKeyArray = $subKeyArray[$segment]; - } else { - return false; - } - } - } - - return true; - } - - /** - * Determine if any of the keys exist in an array using "dot" notation. - * - * @param \ArrayAccess|array $array - * @param string|array $keys - * @return bool - */ - public static function hasAny($array, $keys) - { - if (is_null($keys)) { - return false; - } - - $keys = (array) $keys; - - if (! $array) { - return false; - } - - if ($keys === []) { - return false; - } - - foreach ($keys as $key) { - if (static::has($array, $key)) { - return true; - } - } - - return false; - } - - /** - * Determines if an array is associative. - * - * An array is "associative" if it doesn't have sequential numerical keys beginning with zero. - * - * @param array $array - * @return bool - */ - public static function isAssoc(array $array) - { - $keys = array_keys($array); - - return array_keys($keys) !== $keys; - } - - /** - * Determines if an array is a list. - * - * An array is a "list" if all array keys are sequential integers starting from 0 with no gaps in between. - * - * @param array $array - * @return bool - */ - public static function isList($array) - { - return ! self::isAssoc($array); - } - - /** - * Get a subset of the items from the given array. - * - * @param array $array - * @param array|string $keys - * @return array - */ - public static function only($array, $keys) - { - return array_intersect_key($array, array_flip((array) $keys)); - } - - /** - * Pluck an array of values from an array. - * - * @param iterable $array - * @param string|array|int|null $value - * @param string|array|null $key - * @return array - */ - public static function pluck($array, $value, $key = null) - { - $results = []; - - [$value, $key] = static::explodePluckParameters($value, $key); - - foreach ($array as $item) { - $itemValue = data_get($item, $value); - - // If the key is "null", we will just append the value to the array and keep - // looping. Otherwise we will key the array using the value of the key we - // received from the developer. Then we'll return the final array form. - if (is_null($key)) { - $results[] = $itemValue; - } else { - $itemKey = data_get($item, $key); - - if (is_object($itemKey) && method_exists($itemKey, '__toString')) { - $itemKey = (string) $itemKey; - } - - $results[$itemKey] = $itemValue; - } - } - - return $results; - } - - /** - * Explode the "value" and "key" arguments passed to "pluck". - * - * @param string|array $value - * @param string|array|null $key - * @return array - */ - protected static function explodePluckParameters($value, $key) - { - $value = is_string($value) ? explode('.', $value) : $value; - - $key = is_null($key) || is_array($key) ? $key : explode('.', $key); - - return [$value, $key]; - } - - /** - * Push an item onto the beginning of an array. - * - * @param array $array - * @param mixed $value - * @param mixed $key - * @return array - */ - public static function prepend($array, $value, $key = null) - { - if (func_num_args() == 2) { - array_unshift($array, $value); - } else { - $array = [$key => $value] + $array; - } - - return $array; - } - - /** - * Get a value from the array, and remove it. - * - * @param array $array - * @param string|int $key - * @param mixed $default - * @return mixed - */ - public static function pull(&$array, $key, $default = null) - { - $value = static::get($array, $key, $default); - - static::forget($array, $key); - - return $value; - } - - /** - * Convert the array into a query string. - * - * @param array $array - * @return string - */ - public static function query($array) - { - return http_build_query($array, '', '&', PHP_QUERY_RFC3986); - } - - /** - * Get one or a specified number of random values from an array. - * - * @param array $array - * @param int|null $number - * @param bool|false $preserveKeys - * @return mixed - * - * @throws \InvalidArgumentException - */ - public static function random($array, $number = null, $preserveKeys = false) - { - $requested = is_null($number) ? 1 : $number; - - $count = count($array); - - if ($requested > $count) { - throw new InvalidArgumentException( - "You requested {$requested} items, but there are only {$count} items available." - ); - } - - if (is_null($number)) { - return $array[array_rand($array)]; - } - - if ((int) $number === 0) { - return []; - } - - $keys = array_rand($array, $number); - - $results = []; - - if ($preserveKeys) { - foreach ((array) $keys as $key) { - $results[$key] = $array[$key]; - } - } else { - foreach ((array) $keys as $key) { - $results[] = $array[$key]; - } - } - - return $results; - } - - /** - * Set an array item to a given value using "dot" notation. - * - * If no key is given to the method, the entire array will be replaced. - * - * @param array $array - * @param string|null $key - * @param mixed $value - * @return array - */ - public static function set(&$array, $key, $value) - { - if (is_null($key)) { - return $array = $value; - } - - $keys = explode('.', $key); - - foreach ($keys as $i => $key) { - if (count($keys) === 1) { - break; - } - - unset($keys[$i]); - - // If the key doesn't exist at this depth, we will just create an empty array - // to hold the next value, allowing us to create the arrays to hold final - // values at the correct depth. Then we'll keep digging into the array. - if (! isset($array[$key]) || ! is_array($array[$key])) { - $array[$key] = []; - } - - $array = &$array[$key]; - } - - $array[array_shift($keys)] = $value; - - return $array; - } - - /** - * Shuffle the given array and return the result. - * - * @param array $array - * @param int|null $seed - * @return array - */ - public static function shuffle($array, $seed = null) - { - if (is_null($seed)) { - shuffle($array); - } else { - mt_srand($seed); - shuffle($array); - mt_srand(); - } - - return $array; - } - - /** - * Sort the array using the given callback or "dot" notation. - * - * @param array $array - * @param callable|array|string|null $callback - * @return array - */ - public static function sort($array, $callback = null) - { - return Collection::make($array)->sortBy($callback)->all(); - } - - /** - * Recursively sort an array by keys and values. - * - * @param array $array - * @param int $options - * @param bool $descending - * @return array - */ - public static function sortRecursive($array, $options = SORT_REGULAR, $descending = false) - { - foreach ($array as &$value) { - if (is_array($value)) { - $value = static::sortRecursive($value, $options, $descending); - } - } - - if (static::isAssoc($array)) { - $descending - ? krsort($array, $options) - : ksort($array, $options); - } else { - $descending - ? rsort($array, $options) - : sort($array, $options); - } - - return $array; - } - - /** - * Conditionally compile classes from an array into a CSS class list. - * - * @param array $array - * @return string - */ - public static function toCssClasses($array) - { - $classList = static::wrap($array); - - $classes = []; - - foreach ($classList as $class => $constraint) { - if (is_numeric($class)) { - $classes[] = $constraint; - } elseif ($constraint) { - $classes[] = $class; - } - } - - return implode(' ', $classes); - } - - /** - * Filter the array using the given callback. - * - * @param array $array - * @param callable $callback - * @return array - */ - public static function where($array, callable $callback) - { - return array_filter($array, $callback, ARRAY_FILTER_USE_BOTH); - } - - /** - * Filter items where the value is not null. - * - * @param array $array - * @return array - */ - public static function whereNotNull($array) - { - return static::where($array, function ($value) { - return ! is_null($value); - }); - } - - /** - * If the given value is not an array and not null, wrap it in one. - * - * @param mixed $value - * @return array - */ - public static function wrap($value) - { - if (is_null($value)) { - return []; - } - - return is_array($value) ? $value : [$value]; - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/Collection.php b/vendor/tightenco/collect/src/Collect/Support/Collection.php deleted file mode 100644 index 0dc7323..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/Collection.php +++ /dev/null @@ -1,1672 +0,0 @@ -items = $this->getArrayableItems($items); - } - - /** - * Create a collection with the given range. - * - * @param int $from - * @param int $to - * @return static - */ - public static function range($from, $to) - { - return new static(range($from, $to)); - } - - /** - * Get all of the items in the collection. - * - * @return array - */ - public function all() - { - return $this->items; - } - - /** - * Get a lazy collection for the items in this collection. - * - * @return \Tightenco\Collect\Support\LazyCollection - */ - public function lazy() - { - return new LazyCollection($this->items); - } - - /** - * Get the average value of a given key. - * - * @param callable|string|null $callback - * @return mixed - */ - public function avg($callback = null) - { - $callback = $this->valueRetriever($callback); - - $items = $this->map(function ($value) use ($callback) { - return $callback($value); - })->filter(function ($value) { - return ! is_null($value); - }); - - if ($count = $items->count()) { - return $items->sum() / $count; - } - } - - /** - * Get the median of a given key. - * - * @param string|array|null $key - * @return mixed - */ - public function median($key = null) - { - $values = (isset($key) ? $this->pluck($key) : $this) - ->filter(function ($item) { - return ! is_null($item); - })->sort()->values(); - - $count = $values->count(); - - if ($count === 0) { - return; - } - - $middle = (int) ($count / 2); - - if ($count % 2) { - return $values->get($middle); - } - - return (new static([ - $values->get($middle - 1), $values->get($middle), - ]))->average(); - } - - /** - * Get the mode of a given key. - * - * @param string|array|null $key - * @return array|null - */ - public function mode($key = null) - { - if ($this->count() === 0) { - return; - } - - $collection = isset($key) ? $this->pluck($key) : $this; - - $counts = new static; - - $collection->each(function ($value) use ($counts) { - $counts[$value] = isset($counts[$value]) ? $counts[$value] + 1 : 1; - }); - - $sorted = $counts->sort(); - - $highestValue = $sorted->last(); - - return $sorted->filter(function ($value) use ($highestValue) { - return $value == $highestValue; - })->sort()->keys()->all(); - } - - /** - * Collapse the collection of items into a single array. - * - * @return static - */ - public function collapse() - { - return new static(Arr::collapse($this->items)); - } - - /** - * Determine if an item exists in the collection. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function contains($key, $operator = null, $value = null) - { - if (func_num_args() === 1) { - if ($this->useAsCallable($key)) { - $placeholder = new stdClass; - - return $this->first($key, $placeholder) !== $placeholder; - } - - return in_array($key, $this->items); - } - - return $this->contains($this->operatorForWhere(...func_get_args())); - } - - /** - * Determine if an item is not contained in the collection. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function doesntContain($key, $operator = null, $value = null) - { - return ! $this->contains(...func_get_args()); - } - - /** - * Cross join with the given lists, returning all possible permutations. - * - * @param mixed ...$lists - * @return static - */ - public function crossJoin(...$lists) - { - return new static(Arr::crossJoin( - $this->items, ...array_map([$this, 'getArrayableItems'], $lists) - )); - } - - /** - * Get the items in the collection that are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diff($items) - { - return new static(array_diff($this->items, $this->getArrayableItems($items))); - } - - /** - * Get the items in the collection that are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffUsing($items, callable $callback) - { - return new static(array_udiff($this->items, $this->getArrayableItems($items), $callback)); - } - - /** - * Get the items in the collection whose keys and values are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diffAssoc($items) - { - return new static(array_diff_assoc($this->items, $this->getArrayableItems($items))); - } - - /** - * Get the items in the collection whose keys and values are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffAssocUsing($items, callable $callback) - { - return new static(array_diff_uassoc($this->items, $this->getArrayableItems($items), $callback)); - } - - /** - * Get the items in the collection whose keys are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diffKeys($items) - { - return new static(array_diff_key($this->items, $this->getArrayableItems($items))); - } - - /** - * Get the items in the collection whose keys are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffKeysUsing($items, callable $callback) - { - return new static(array_diff_ukey($this->items, $this->getArrayableItems($items), $callback)); - } - - /** - * Retrieve duplicate items from the collection. - * - * @param callable|string|null $callback - * @param bool $strict - * @return static - */ - public function duplicates($callback = null, $strict = false) - { - $items = $this->map($this->valueRetriever($callback)); - - $uniqueItems = $items->unique(null, $strict); - - $compare = $this->duplicateComparator($strict); - - $duplicates = new static; - - foreach ($items as $key => $value) { - if ($uniqueItems->isNotEmpty() && $compare($value, $uniqueItems->first())) { - $uniqueItems->shift(); - } else { - $duplicates[$key] = $value; - } - } - - return $duplicates; - } - - /** - * Retrieve duplicate items from the collection using strict comparison. - * - * @param callable|string|null $callback - * @return static - */ - public function duplicatesStrict($callback = null) - { - return $this->duplicates($callback, true); - } - - /** - * Get the comparison function to detect duplicates. - * - * @param bool $strict - * @return \Closure - */ - protected function duplicateComparator($strict) - { - if ($strict) { - return function ($a, $b) { - return $a === $b; - }; - } - - return function ($a, $b) { - return $a == $b; - }; - } - - /** - * Get all items except for those with the specified keys. - * - * @param \Tightenco\Collect\Support\Collection|mixed $keys - * @return static - */ - public function except($keys) - { - if ($keys instanceof Enumerable) { - $keys = $keys->all(); - } elseif (! is_array($keys)) { - $keys = func_get_args(); - } - - return new static(Arr::except($this->items, $keys)); - } - - /** - * Run a filter over each of the items. - * - * @param callable|null $callback - * @return static - */ - public function filter(callable $callback = null) - { - if ($callback) { - return new static(Arr::where($this->items, $callback)); - } - - return new static(array_filter($this->items)); - } - - /** - * Get the first item from the collection passing the given truth test. - * - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public function first(callable $callback = null, $default = null) - { - return Arr::first($this->items, $callback, $default); - } - - /** - * Get a flattened array of the items in the collection. - * - * @param int $depth - * @return static - */ - public function flatten($depth = INF) - { - return new static(Arr::flatten($this->items, $depth)); - } - - /** - * Flip the items in the collection. - * - * @return static - */ - public function flip() - { - return new static(array_flip($this->items)); - } - - /** - * Remove an item from the collection by key. - * - * @param string|int|array $keys - * @return $this - */ - public function forget($keys) - { - foreach ((array) $keys as $key) { - $this->offsetUnset($key); - } - - return $this; - } - - /** - * Get an item from the collection by key. - * - * @param mixed $key - * @param mixed $default - * @return mixed - */ - public function get($key, $default = null) - { - if (array_key_exists($key, $this->items)) { - return $this->items[$key]; - } - - return value($default); - } - - /** - * Get an item from the collection by key or add it to collection if it does not exist. - * - * @param mixed $key - * @param mixed $value - * @return mixed - */ - public function getOrPut($key, $value) - { - if (array_key_exists($key, $this->items)) { - return $this->items[$key]; - } - - $this->offsetSet($key, $value = value($value)); - - return $value; - } - - /** - * Group an associative array by a field or using a callback. - * - * @param array|callable|string $groupBy - * @param bool $preserveKeys - * @return static - */ - public function groupBy($groupBy, $preserveKeys = false) - { - if (! $this->useAsCallable($groupBy) && is_array($groupBy)) { - $nextGroups = $groupBy; - - $groupBy = array_shift($nextGroups); - } - - $groupBy = $this->valueRetriever($groupBy); - - $results = []; - - foreach ($this->items as $key => $value) { - $groupKeys = $groupBy($value, $key); - - if (! is_array($groupKeys)) { - $groupKeys = [$groupKeys]; - } - - foreach ($groupKeys as $groupKey) { - $groupKey = is_bool($groupKey) ? (int) $groupKey : $groupKey; - - if (! array_key_exists($groupKey, $results)) { - $results[$groupKey] = new static; - } - - $results[$groupKey]->offsetSet($preserveKeys ? $key : null, $value); - } - } - - $result = new static($results); - - if (! empty($nextGroups)) { - return $result->map->groupBy($nextGroups, $preserveKeys); - } - - return $result; - } - - /** - * Key an associative array by a field or using a callback. - * - * @param callable|string $keyBy - * @return static - */ - public function keyBy($keyBy) - { - $keyBy = $this->valueRetriever($keyBy); - - $results = []; - - foreach ($this->items as $key => $item) { - $resolvedKey = $keyBy($item, $key); - - if (is_object($resolvedKey)) { - $resolvedKey = (string) $resolvedKey; - } - - $results[$resolvedKey] = $item; - } - - return new static($results); - } - - /** - * Determine if an item exists in the collection by key. - * - * @param mixed $key - * @return bool - */ - public function has($key) - { - $keys = is_array($key) ? $key : func_get_args(); - - foreach ($keys as $value) { - if (! array_key_exists($value, $this->items)) { - return false; - } - } - - return true; - } - - /** - * Determine if any of the keys exist in the collection. - * - * @param mixed $key - * @return bool - */ - public function hasAny($key) - { - if ($this->isEmpty()) { - return false; - } - - $keys = is_array($key) ? $key : func_get_args(); - - foreach ($keys as $value) { - if ($this->has($value)) { - return true; - } - } - - return false; - } - - /** - * Concatenate values of a given key as a string. - * - * @param string $value - * @param string|null $glue - * @return string - */ - public function implode($value, $glue = null) - { - $first = $this->first(); - - if (is_array($first) || (is_object($first) && ! $first instanceof \Illuminate\Support\Stringable)) { - return implode($glue ?? '', $this->pluck($value)->all()); - } - - return implode($value ?? '', $this->items); - } - - /** - * Intersect the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function intersect($items) - { - return new static(array_intersect($this->items, $this->getArrayableItems($items))); - } - - /** - * Intersect the collection with the given items by key. - * - * @param mixed $items - * @return static - */ - public function intersectByKeys($items) - { - return new static(array_intersect_key( - $this->items, $this->getArrayableItems($items) - )); - } - - /** - * Determine if the collection is empty or not. - * - * @return bool - */ - public function isEmpty() - { - return empty($this->items); - } - - /** - * Determine if the collection contains a single item. - * - * @return bool - */ - public function containsOneItem() - { - return $this->count() === 1; - } - - /** - * Join all items from the collection using a string. The final items can use a separate glue string. - * - * @param string $glue - * @param string $finalGlue - * @return string - */ - public function join($glue, $finalGlue = '') - { - if ($finalGlue === '') { - return $this->implode($glue); - } - - $count = $this->count(); - - if ($count === 0) { - return ''; - } - - if ($count === 1) { - return $this->last(); - } - - $collection = new static($this->items); - - $finalItem = $collection->pop(); - - return $collection->implode($glue).$finalGlue.$finalItem; - } - - /** - * Get the keys of the collection items. - * - * @return static - */ - public function keys() - { - return new static(array_keys($this->items)); - } - - /** - * Get the last item from the collection. - * - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public function last(callable $callback = null, $default = null) - { - return Arr::last($this->items, $callback, $default); - } - - /** - * Get the values of a given key. - * - * @param string|array|int|null $value - * @param string|null $key - * @return static - */ - public function pluck($value, $key = null) - { - return new static(Arr::pluck($this->items, $value, $key)); - } - - /** - * Run a map over each of the items. - * - * @param callable $callback - * @return static - */ - public function map(callable $callback) - { - $keys = array_keys($this->items); - - $items = array_map($callback, $this->items, $keys); - - return new static(array_combine($keys, $items)); - } - - /** - * Run a dictionary map over the items. - * - * The callback should return an associative array with a single key/value pair. - * - * @param callable $callback - * @return static - */ - public function mapToDictionary(callable $callback) - { - $dictionary = []; - - foreach ($this->items as $key => $item) { - $pair = $callback($item, $key); - - $key = key($pair); - - $value = reset($pair); - - if (! isset($dictionary[$key])) { - $dictionary[$key] = []; - } - - $dictionary[$key][] = $value; - } - - return new static($dictionary); - } - - /** - * Run an associative map over each of the items. - * - * The callback should return an associative array with a single key/value pair. - * - * @param callable $callback - * @return static - */ - public function mapWithKeys(callable $callback) - { - $result = []; - - foreach ($this->items as $key => $value) { - $assoc = $callback($value, $key); - - foreach ($assoc as $mapKey => $mapValue) { - $result[$mapKey] = $mapValue; - } - } - - return new static($result); - } - - /** - * Merge the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function merge($items) - { - return new static(array_merge($this->items, $this->getArrayableItems($items))); - } - - /** - * Recursively merge the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function mergeRecursive($items) - { - return new static(array_merge_recursive($this->items, $this->getArrayableItems($items))); - } - - /** - * Create a collection by using this collection for keys and another for its values. - * - * @param mixed $values - * @return static - */ - public function combine($values) - { - return new static(array_combine($this->all(), $this->getArrayableItems($values))); - } - - /** - * Union the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function union($items) - { - return new static($this->items + $this->getArrayableItems($items)); - } - - /** - * Create a new collection consisting of every n-th element. - * - * @param int $step - * @param int $offset - * @return static - */ - public function nth($step, $offset = 0) - { - $new = []; - - $position = 0; - - foreach ($this->slice($offset)->items as $item) { - if ($position % $step === 0) { - $new[] = $item; - } - - $position++; - } - - return new static($new); - } - - /** - * Get the items with the specified keys. - * - * @param mixed $keys - * @return static - */ - public function only($keys) - { - if (is_null($keys)) { - return new static($this->items); - } - - if ($keys instanceof Enumerable) { - $keys = $keys->all(); - } - - $keys = is_array($keys) ? $keys : func_get_args(); - - return new static(Arr::only($this->items, $keys)); - } - - /** - * Get and remove the last N items from the collection. - * - * @param int $count - * @return mixed - */ - public function pop($count = 1) - { - if ($count === 1) { - return array_pop($this->items); - } - - if ($this->isEmpty()) { - return new static; - } - - $results = []; - - $collectionCount = $this->count(); - - foreach (range(1, min($count, $collectionCount)) as $item) { - array_push($results, array_pop($this->items)); - } - - return new static($results); - } - - /** - * Push an item onto the beginning of the collection. - * - * @param mixed $value - * @param mixed $key - * @return $this - */ - public function prepend($value, $key = null) - { - $this->items = Arr::prepend($this->items, ...func_get_args()); - - return $this; - } - - /** - * Push one or more items onto the end of the collection. - * - * @param mixed $values - * @return $this - */ - public function push(...$values) - { - foreach ($values as $value) { - $this->items[] = $value; - } - - return $this; - } - - /** - * Push all of the given items onto the collection. - * - * @param iterable $source - * @return static - */ - public function concat($source) - { - $result = new static($this); - - foreach ($source as $item) { - $result->push($item); - } - - return $result; - } - - /** - * Get and remove an item from the collection. - * - * @param mixed $key - * @param mixed $default - * @return mixed - */ - public function pull($key, $default = null) - { - return Arr::pull($this->items, $key, $default); - } - - /** - * Put an item in the collection by key. - * - * @param mixed $key - * @param mixed $value - * @return $this - */ - public function put($key, $value) - { - $this->offsetSet($key, $value); - - return $this; - } - - /** - * Get one or a specified number of items randomly from the collection. - * - * @param int|null $number - * @return static|mixed - * - * @throws \InvalidArgumentException - */ - public function random($number = null) - { - if (is_null($number)) { - return Arr::random($this->items); - } - - return new static(Arr::random($this->items, $number)); - } - - /** - * Replace the collection items with the given items. - * - * @param mixed $items - * @return static - */ - public function replace($items) - { - return new static(array_replace($this->items, $this->getArrayableItems($items))); - } - - /** - * Recursively replace the collection items with the given items. - * - * @param mixed $items - * @return static - */ - public function replaceRecursive($items) - { - return new static(array_replace_recursive($this->items, $this->getArrayableItems($items))); - } - - /** - * Reverse items order. - * - * @return static - */ - public function reverse() - { - return new static(array_reverse($this->items, true)); - } - - /** - * Search the collection for a given value and return the corresponding key if successful. - * - * @param mixed $value - * @param bool $strict - * @return mixed - */ - public function search($value, $strict = false) - { - if (! $this->useAsCallable($value)) { - return array_search($value, $this->items, $strict); - } - - foreach ($this->items as $key => $item) { - if ($value($item, $key)) { - return $key; - } - } - - return false; - } - - /** - * Get and remove the first N items from the collection. - * - * @param int $count - * @return mixed - */ - public function shift($count = 1) - { - if ($count === 1) { - return array_shift($this->items); - } - - if ($this->isEmpty()) { - return new static; - } - - $results = []; - - $collectionCount = $this->count(); - - foreach (range(1, min($count, $collectionCount)) as $item) { - array_push($results, array_shift($this->items)); - } - - return new static($results); - } - - /** - * Shuffle the items in the collection. - * - * @param int|null $seed - * @return static - */ - public function shuffle($seed = null) - { - return new static(Arr::shuffle($this->items, $seed)); - } - - /** - * Create chunks representing a "sliding window" view of the items in the collection. - * - * @param int $size - * @param int $step - * @return static - */ - public function sliding($size = 2, $step = 1) - { - $chunks = floor(($this->count() - $size) / $step) + 1; - - return static::times($chunks, function ($number) use ($size, $step) { - return $this->slice(($number - 1) * $step, $size); - }); - } - - /** - * Skip the first {$count} items. - * - * @param int $count - * @return static - */ - public function skip($count) - { - return $this->slice($count); - } - - /** - * Skip items in the collection until the given condition is met. - * - * @param mixed $value - * @return static - */ - public function skipUntil($value) - { - return new static($this->lazy()->skipUntil($value)->all()); - } - - /** - * Skip items in the collection while the given condition is met. - * - * @param mixed $value - * @return static - */ - public function skipWhile($value) - { - return new static($this->lazy()->skipWhile($value)->all()); - } - - /** - * Slice the underlying collection array. - * - * @param int $offset - * @param int|null $length - * @return static - */ - public function slice($offset, $length = null) - { - return new static(array_slice($this->items, $offset, $length, true)); - } - - /** - * Split a collection into a certain number of groups. - * - * @param int $numberOfGroups - * @return static - */ - public function split($numberOfGroups) - { - if ($this->isEmpty()) { - return new static; - } - - $groups = new static; - - $groupSize = floor($this->count() / $numberOfGroups); - - $remain = $this->count() % $numberOfGroups; - - $start = 0; - - for ($i = 0; $i < $numberOfGroups; $i++) { - $size = $groupSize; - - if ($i < $remain) { - $size++; - } - - if ($size) { - $groups->push(new static(array_slice($this->items, $start, $size))); - - $start += $size; - } - } - - return $groups; - } - - /** - * Split a collection into a certain number of groups, and fill the first groups completely. - * - * @param int $numberOfGroups - * @return static - */ - public function splitIn($numberOfGroups) - { - return $this->chunk(ceil($this->count() / $numberOfGroups)); - } - - /** - * Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return mixed - * - * @throws \Tightenco\Collect\Support\ItemNotFoundException - * @throws \Tightenco\Collect\Support\MultipleItemsFoundException - */ - public function sole($key = null, $operator = null, $value = null) - { - $filter = func_num_args() > 1 - ? $this->operatorForWhere(...func_get_args()) - : $key; - - $items = $this->when($filter)->filter($filter); - - if ($items->isEmpty()) { - throw new ItemNotFoundException; - } - - if ($items->count() > 1) { - throw new MultipleItemsFoundException; - } - - return $items->first(); - } - - /** - * Get the first item in the collection but throw an exception if no matching items exist. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return mixed - * - * @throws \Tightenco\Collect\Support\ItemNotFoundException - */ - public function firstOrFail($key = null, $operator = null, $value = null) - { - $filter = func_num_args() > 1 - ? $this->operatorForWhere(...func_get_args()) - : $key; - - $placeholder = new stdClass(); - - $item = $this->first($filter, $placeholder); - - if ($item === $placeholder) { - throw new ItemNotFoundException; - } - - return $item; - } - - /** - * Chunk the collection into chunks of the given size. - * - * @param int $size - * @return static - */ - public function chunk($size) - { - if ($size <= 0) { - return new static; - } - - $chunks = []; - - foreach (array_chunk($this->items, $size, true) as $chunk) { - $chunks[] = new static($chunk); - } - - return new static($chunks); - } - - /** - * Chunk the collection into chunks with a callback. - * - * @param callable $callback - * @return static - */ - public function chunkWhile(callable $callback) - { - return new static( - $this->lazy()->chunkWhile($callback)->mapInto(static::class) - ); - } - - /** - * Sort through each item with a callback. - * - * @param callable|int|null $callback - * @return static - */ - public function sort($callback = null) - { - $items = $this->items; - - $callback && is_callable($callback) - ? uasort($items, $callback) - : asort($items, $callback ?? SORT_REGULAR); - - return new static($items); - } - - /** - * Sort items in descending order. - * - * @param int $options - * @return static - */ - public function sortDesc($options = SORT_REGULAR) - { - $items = $this->items; - - arsort($items, $options); - - return new static($items); - } - - /** - * Sort the collection using the given callback. - * - * @param callable|array|string $callback - * @param int $options - * @param bool $descending - * @return static - */ - public function sortBy($callback, $options = SORT_REGULAR, $descending = false) - { - if (is_array($callback) && ! is_callable($callback)) { - return $this->sortByMany($callback); - } - - $results = []; - - $callback = $this->valueRetriever($callback); - - // First we will loop through the items and get the comparator from a callback - // function which we were given. Then, we will sort the returned values and - // grab all the corresponding values for the sorted keys from this array. - foreach ($this->items as $key => $value) { - $results[$key] = $callback($value, $key); - } - - $descending ? arsort($results, $options) - : asort($results, $options); - - // Once we have sorted all of the keys in the array, we will loop through them - // and grab the corresponding model so we can set the underlying items list - // to the sorted version. Then we'll just return the collection instance. - foreach (array_keys($results) as $key) { - $results[$key] = $this->items[$key]; - } - - return new static($results); - } - - /** - * Sort the collection using multiple comparisons. - * - * @param array $comparisons - * @return static - */ - protected function sortByMany(array $comparisons = []) - { - $items = $this->items; - - usort($items, function ($a, $b) use ($comparisons) { - foreach ($comparisons as $comparison) { - $comparison = Arr::wrap($comparison); - - $prop = $comparison[0]; - - $ascending = Arr::get($comparison, 1, true) === true || - Arr::get($comparison, 1, true) === 'asc'; - - $result = 0; - - if (! is_string($prop) && is_callable($prop)) { - $result = $prop($a, $b); - } else { - $values = [data_get($a, $prop), data_get($b, $prop)]; - - if (! $ascending) { - $values = array_reverse($values); - } - - $result = $values[0] <=> $values[1]; - } - - if ($result === 0) { - continue; - } - - return $result; - } - }); - - return new static($items); - } - - /** - * Sort the collection in descending order using the given callback. - * - * @param callable|string $callback - * @param int $options - * @return static - */ - public function sortByDesc($callback, $options = SORT_REGULAR) - { - return $this->sortBy($callback, $options, true); - } - - /** - * Sort the collection keys. - * - * @param int $options - * @param bool $descending - * @return static - */ - public function sortKeys($options = SORT_REGULAR, $descending = false) - { - $items = $this->items; - - $descending ? krsort($items, $options) : ksort($items, $options); - - return new static($items); - } - - /** - * Sort the collection keys in descending order. - * - * @param int $options - * @return static - */ - public function sortKeysDesc($options = SORT_REGULAR) - { - return $this->sortKeys($options, true); - } - - /** - * Sort the collection keys using a callback. - * - * @param callable $callback - * @return static - */ - public function sortKeysUsing(callable $callback) - { - $items = $this->items; - - uksort($items, $callback); - - return new static($items); - } - - /** - * Splice a portion of the underlying collection array. - * - * @param int $offset - * @param int|null $length - * @param mixed $replacement - * @return static - */ - public function splice($offset, $length = null, $replacement = []) - { - if (func_num_args() === 1) { - return new static(array_splice($this->items, $offset)); - } - - return new static(array_splice($this->items, $offset, $length, $this->getArrayableItems($replacement))); - } - - /** - * Take the first or last {$limit} items. - * - * @param int $limit - * @return static - */ - public function take($limit) - { - if ($limit < 0) { - return $this->slice($limit, abs($limit)); - } - - return $this->slice(0, $limit); - } - - /** - * Take items in the collection until the given condition is met. - * - * @param mixed $value - * @return static - */ - public function takeUntil($value) - { - return new static($this->lazy()->takeUntil($value)->all()); - } - - /** - * Take items in the collection while the given condition is met. - * - * @param mixed $value - * @return static - */ - public function takeWhile($value) - { - return new static($this->lazy()->takeWhile($value)->all()); - } - - /** - * Transform each item in the collection using a callback. - * - * @param callable $callback - * @return $this - */ - public function transform(callable $callback) - { - $this->items = $this->map($callback)->all(); - - return $this; - } - - /** - * Convert a flatten "dot" notation array into an expanded array. - * - * @return static - */ - public function undot() - { - return new static(Arr::undot($this->all())); - } - - /** - * Return only unique items from the collection array. - * - * @param string|callable|null $key - * @param bool $strict - * @return static - */ - public function unique($key = null, $strict = false) - { - if (is_null($key) && $strict === false) { - return new static(array_unique($this->items, SORT_REGULAR)); - } - - $callback = $this->valueRetriever($key); - - $exists = []; - - return $this->reject(function ($item, $key) use ($callback, $strict, &$exists) { - if (in_array($id = $callback($item, $key), $exists, $strict)) { - return true; - } - - $exists[] = $id; - }); - } - - /** - * Reset the keys on the underlying array. - * - * @return static - */ - public function values() - { - return new static(array_values($this->items)); - } - - /** - * Zip the collection together with one or more arrays. - * - * e.g. new Collection([1, 2, 3])->zip([4, 5, 6]); - * => [[1, 4], [2, 5], [3, 6]] - * - * @param mixed ...$items - * @return static - */ - public function zip($items) - { - $arrayableItems = array_map(function ($items) { - return $this->getArrayableItems($items); - }, func_get_args()); - - $params = array_merge([function () { - return new static(func_get_args()); - }, $this->items], $arrayableItems); - - return new static(array_map(...$params)); - } - - /** - * Pad collection to the specified length with a value. - * - * @param int $size - * @param mixed $value - * @return static - */ - public function pad($size, $value) - { - return new static(array_pad($this->items, $size, $value)); - } - - /** - * Get an iterator for the items. - * - * @return \ArrayIterator - */ - #[\ReturnTypeWillChange] - public function getIterator() - { - return new ArrayIterator($this->items); - } - - /** - * Count the number of items in the collection. - * - * @return int - */ - #[\ReturnTypeWillChange] - public function count() - { - return count($this->items); - } - - /** - * Count the number of items in the collection by a field or using a callback. - * - * @param callable|string $countBy - * @return static - */ - public function countBy($countBy = null) - { - return new static($this->lazy()->countBy($countBy)->all()); - } - - /** - * Add an item to the collection. - * - * @param mixed $item - * @return $this - */ - public function add($item) - { - $this->items[] = $item; - - return $this; - } - - /** - * Get a base Support collection instance from this collection. - * - * @return \Tightenco\Collect\Support\Collection - */ - public function toBase() - { - return new self($this); - } - - /** - * Determine if an item exists at an offset. - * - * @param mixed $key - * @return bool - */ - #[\ReturnTypeWillChange] - public function offsetExists($key) - { - return isset($this->items[$key]); - } - - /** - * Get an item at a given offset. - * - * @param mixed $key - * @return mixed - */ - #[\ReturnTypeWillChange] - public function offsetGet($key) - { - return $this->items[$key]; - } - - /** - * Set the item at a given offset. - * - * @param mixed $key - * @param mixed $value - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetSet($key, $value) - { - if (is_null($key)) { - $this->items[] = $value; - } else { - $this->items[$key] = $value; - } - } - - /** - * Unset the item at a given offset. - * - * @param mixed $key - * @return void - */ - #[\ReturnTypeWillChange] - public function offsetUnset($key) - { - unset($this->items[$key]); - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/Enumerable.php b/vendor/tightenco/collect/src/Collect/Support/Enumerable.php deleted file mode 100644 index 60af386..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/Enumerable.php +++ /dev/null @@ -1,1027 +0,0 @@ -zip([4, 5, 6]); - * => [[1, 4], [2, 5], [3, 6]] - * - * @param mixed ...$items - * @return static - */ - public function zip($items); - - /** - * Collect the values into a collection. - * - * @return \Tightenco\Collect\Support\Collection - */ - public function collect(); - - /** - * Convert the collection to its string representation. - * - * @return string - */ - public function __toString(); - - /** - * Add a method to the list of proxied methods. - * - * @param string $method - * @return void - */ - public static function proxy($method); - - /** - * Dynamically access collection proxies. - * - * @param string $key - * @return mixed - * - * @throws \Exception - */ - public function __get($key); -} diff --git a/vendor/tightenco/collect/src/Collect/Support/HigherOrderCollectionProxy.php b/vendor/tightenco/collect/src/Collect/Support/HigherOrderCollectionProxy.php deleted file mode 100644 index 01ac43f..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/HigherOrderCollectionProxy.php +++ /dev/null @@ -1,63 +0,0 @@ -method = $method; - $this->collection = $collection; - } - - /** - * Proxy accessing an attribute onto the collection items. - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - return $this->collection->{$this->method}(function ($value) use ($key) { - return is_array($value) ? $value[$key] : $value->{$key}; - }); - } - - /** - * Proxy a method call onto the collection items. - * - * @param string $method - * @param array $parameters - * @return mixed - */ - public function __call($method, $parameters) - { - return $this->collection->{$this->method}(function ($value) use ($method, $parameters) { - return $value->{$method}(...$parameters); - }); - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/HigherOrderWhenProxy.php b/vendor/tightenco/collect/src/Collect/Support/HigherOrderWhenProxy.php deleted file mode 100644 index ea48c7c..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/HigherOrderWhenProxy.php +++ /dev/null @@ -1,63 +0,0 @@ -condition = $condition; - $this->collection = $collection; - } - - /** - * Proxy accessing an attribute onto the collection. - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - return $this->condition - ? $this->collection->{$key} - : $this->collection; - } - - /** - * Proxy a method call onto the collection. - * - * @param string $method - * @param array $parameters - * @return mixed - */ - public function __call($method, $parameters) - { - return $this->condition - ? $this->collection->{$method}(...$parameters) - : $this->collection; - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/LazyCollection.php b/vendor/tightenco/collect/src/Collect/Support/LazyCollection.php deleted file mode 100644 index a54787d..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/LazyCollection.php +++ /dev/null @@ -1,1585 +0,0 @@ -source = $source; - } elseif (is_null($source)) { - $this->source = static::empty(); - } else { - $this->source = $this->getArrayableItems($source); - } - } - - /** - * Create a collection with the given range. - * - * @param int $from - * @param int $to - * @return static - */ - public static function range($from, $to) - { - return new static(function () use ($from, $to) { - if ($from <= $to) { - for (; $from <= $to; $from++) { - yield $from; - } - } else { - for (; $from >= $to; $from--) { - yield $from; - } - } - }); - } - - /** - * Get all items in the enumerable. - * - * @return array - */ - public function all() - { - if (is_array($this->source)) { - return $this->source; - } - - return iterator_to_array($this->getIterator()); - } - - /** - * Eager load all items into a new lazy collection backed by an array. - * - * @return static - */ - public function eager() - { - return new static($this->all()); - } - - /** - * Cache values as they're enumerated. - * - * @return static - */ - public function remember() - { - $iterator = $this->getIterator(); - - $iteratorIndex = 0; - - $cache = []; - - return new static(function () use ($iterator, &$iteratorIndex, &$cache) { - for ($index = 0; true; $index++) { - if (array_key_exists($index, $cache)) { - yield $cache[$index][0] => $cache[$index][1]; - - continue; - } - - if ($iteratorIndex < $index) { - $iterator->next(); - - $iteratorIndex++; - } - - if (! $iterator->valid()) { - break; - } - - $cache[$index] = [$iterator->key(), $iterator->current()]; - - yield $cache[$index][0] => $cache[$index][1]; - } - }); - } - - /** - * Get the average value of a given key. - * - * @param callable|string|null $callback - * @return mixed - */ - public function avg($callback = null) - { - return $this->collect()->avg($callback); - } - - /** - * Get the median of a given key. - * - * @param string|array|null $key - * @return mixed - */ - public function median($key = null) - { - return $this->collect()->median($key); - } - - /** - * Get the mode of a given key. - * - * @param string|array|null $key - * @return array|null - */ - public function mode($key = null) - { - return $this->collect()->mode($key); - } - - /** - * Collapse the collection of items into a single array. - * - * @return static - */ - public function collapse() - { - return new static(function () { - foreach ($this as $values) { - if (is_array($values) || $values instanceof Enumerable) { - foreach ($values as $value) { - yield $value; - } - } - } - }); - } - - /** - * Determine if an item exists in the enumerable. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function contains($key, $operator = null, $value = null) - { - if (func_num_args() === 1 && $this->useAsCallable($key)) { - $placeholder = new stdClass; - - return $this->first($key, $placeholder) !== $placeholder; - } - - if (func_num_args() === 1) { - $needle = $key; - - foreach ($this as $value) { - if ($value == $needle) { - return true; - } - } - - return false; - } - - return $this->contains($this->operatorForWhere(...func_get_args())); - } - - /** - * Determine if an item is not contained in the enumerable. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function doesntContain($key, $operator = null, $value = null) - { - return ! $this->contains(...func_get_args()); - } - - /** - * Cross join the given iterables, returning all possible permutations. - * - * @param array ...$arrays - * @return static - */ - public function crossJoin(...$arrays) - { - return $this->passthru('crossJoin', func_get_args()); - } - - /** - * Count the number of items in the collection by a field or using a callback. - * - * @param callable|string $countBy - * @return static - */ - public function countBy($countBy = null) - { - $countBy = is_null($countBy) - ? $this->identity() - : $this->valueRetriever($countBy); - - return new static(function () use ($countBy) { - $counts = []; - - foreach ($this as $key => $value) { - $group = $countBy($value, $key); - - if (empty($counts[$group])) { - $counts[$group] = 0; - } - - $counts[$group]++; - } - - yield from $counts; - }); - } - - /** - * Get the items that are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diff($items) - { - return $this->passthru('diff', func_get_args()); - } - - /** - * Get the items that are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffUsing($items, callable $callback) - { - return $this->passthru('diffUsing', func_get_args()); - } - - /** - * Get the items whose keys and values are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diffAssoc($items) - { - return $this->passthru('diffAssoc', func_get_args()); - } - - /** - * Get the items whose keys and values are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffAssocUsing($items, callable $callback) - { - return $this->passthru('diffAssocUsing', func_get_args()); - } - - /** - * Get the items whose keys are not present in the given items. - * - * @param mixed $items - * @return static - */ - public function diffKeys($items) - { - return $this->passthru('diffKeys', func_get_args()); - } - - /** - * Get the items whose keys are not present in the given items, using the callback. - * - * @param mixed $items - * @param callable $callback - * @return static - */ - public function diffKeysUsing($items, callable $callback) - { - return $this->passthru('diffKeysUsing', func_get_args()); - } - - /** - * Retrieve duplicate items. - * - * @param callable|string|null $callback - * @param bool $strict - * @return static - */ - public function duplicates($callback = null, $strict = false) - { - return $this->passthru('duplicates', func_get_args()); - } - - /** - * Retrieve duplicate items using strict comparison. - * - * @param callable|string|null $callback - * @return static - */ - public function duplicatesStrict($callback = null) - { - return $this->passthru('duplicatesStrict', func_get_args()); - } - - /** - * Get all items except for those with the specified keys. - * - * @param mixed $keys - * @return static - */ - public function except($keys) - { - return $this->passthru('except', func_get_args()); - } - - /** - * Run a filter over each of the items. - * - * @param callable|null $callback - * @return static - */ - public function filter(callable $callback = null) - { - if (is_null($callback)) { - $callback = function ($value) { - return (bool) $value; - }; - } - - return new static(function () use ($callback) { - foreach ($this as $key => $value) { - if ($callback($value, $key)) { - yield $key => $value; - } - } - }); - } - - /** - * Get the first item from the enumerable passing the given truth test. - * - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public function first(callable $callback = null, $default = null) - { - $iterator = $this->getIterator(); - - if (is_null($callback)) { - if (! $iterator->valid()) { - return value($default); - } - - return $iterator->current(); - } - - foreach ($iterator as $key => $value) { - if ($callback($value, $key)) { - return $value; - } - } - - return value($default); - } - - /** - * Get a flattened list of the items in the collection. - * - * @param int $depth - * @return static - */ - public function flatten($depth = INF) - { - $instance = new static(function () use ($depth) { - foreach ($this as $item) { - if (! is_array($item) && ! $item instanceof Enumerable) { - yield $item; - } elseif ($depth === 1) { - yield from $item; - } else { - yield from (new static($item))->flatten($depth - 1); - } - } - }); - - return $instance->values(); - } - - /** - * Flip the items in the collection. - * - * @return static - */ - public function flip() - { - return new static(function () { - foreach ($this as $key => $value) { - yield $value => $key; - } - }); - } - - /** - * Get an item by key. - * - * @param mixed $key - * @param mixed $default - * @return mixed - */ - public function get($key, $default = null) - { - if (is_null($key)) { - return; - } - - foreach ($this as $outerKey => $outerValue) { - if ($outerKey == $key) { - return $outerValue; - } - } - - return value($default); - } - - /** - * Group an associative array by a field or using a callback. - * - * @param array|callable|string $groupBy - * @param bool $preserveKeys - * @return static - */ - public function groupBy($groupBy, $preserveKeys = false) - { - return $this->passthru('groupBy', func_get_args()); - } - - /** - * Key an associative array by a field or using a callback. - * - * @param callable|string $keyBy - * @return static - */ - public function keyBy($keyBy) - { - return new static(function () use ($keyBy) { - $keyBy = $this->valueRetriever($keyBy); - - foreach ($this as $key => $item) { - $resolvedKey = $keyBy($item, $key); - - if (is_object($resolvedKey)) { - $resolvedKey = (string) $resolvedKey; - } - - yield $resolvedKey => $item; - } - }); - } - - /** - * Determine if an item exists in the collection by key. - * - * @param mixed $key - * @return bool - */ - public function has($key) - { - $keys = array_flip(is_array($key) ? $key : func_get_args()); - $count = count($keys); - - foreach ($this as $key => $value) { - if (array_key_exists($key, $keys) && --$count == 0) { - return true; - } - } - - return false; - } - - /** - * Determine if any of the keys exist in the collection. - * - * @param mixed $key - * @return bool - */ - public function hasAny($key) - { - $keys = array_flip(is_array($key) ? $key : func_get_args()); - - foreach ($this as $key => $value) { - if (array_key_exists($key, $keys)) { - return true; - } - } - - return false; - } - - /** - * Concatenate values of a given key as a string. - * - * @param string $value - * @param string|null $glue - * @return string - */ - public function implode($value, $glue = null) - { - return $this->collect()->implode(...func_get_args()); - } - - /** - * Intersect the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function intersect($items) - { - return $this->passthru('intersect', func_get_args()); - } - - /** - * Intersect the collection with the given items by key. - * - * @param mixed $items - * @return static - */ - public function intersectByKeys($items) - { - return $this->passthru('intersectByKeys', func_get_args()); - } - - /** - * Determine if the items are empty or not. - * - * @return bool - */ - public function isEmpty() - { - return ! $this->getIterator()->valid(); - } - - /** - * Determine if the collection contains a single item. - * - * @return bool - */ - public function containsOneItem() - { - return $this->take(2)->count() === 1; - } - - /** - * Join all items from the collection using a string. The final items can use a separate glue string. - * - * @param string $glue - * @param string $finalGlue - * @return string - */ - public function join($glue, $finalGlue = '') - { - return $this->collect()->join(...func_get_args()); - } - - /** - * Get the keys of the collection items. - * - * @return static - */ - public function keys() - { - return new static(function () { - foreach ($this as $key => $value) { - yield $key; - } - }); - } - - /** - * Get the last item from the collection. - * - * @param callable|null $callback - * @param mixed $default - * @return mixed - */ - public function last(callable $callback = null, $default = null) - { - $needle = $placeholder = new stdClass; - - foreach ($this as $key => $value) { - if (is_null($callback) || $callback($value, $key)) { - $needle = $value; - } - } - - return $needle === $placeholder ? value($default) : $needle; - } - - /** - * Get the values of a given key. - * - * @param string|array $value - * @param string|null $key - * @return static - */ - public function pluck($value, $key = null) - { - return new static(function () use ($value, $key) { - [$value, $key] = $this->explodePluckParameters($value, $key); - - foreach ($this as $item) { - $itemValue = data_get($item, $value); - - if (is_null($key)) { - yield $itemValue; - } else { - $itemKey = data_get($item, $key); - - if (is_object($itemKey) && method_exists($itemKey, '__toString')) { - $itemKey = (string) $itemKey; - } - - yield $itemKey => $itemValue; - } - } - }); - } - - /** - * Run a map over each of the items. - * - * @param callable $callback - * @return static - */ - public function map(callable $callback) - { - return new static(function () use ($callback) { - foreach ($this as $key => $value) { - yield $key => $callback($value, $key); - } - }); - } - - /** - * Run a dictionary map over the items. - * - * The callback should return an associative array with a single key/value pair. - * - * @param callable $callback - * @return static - */ - public function mapToDictionary(callable $callback) - { - return $this->passthru('mapToDictionary', func_get_args()); - } - - /** - * Run an associative map over each of the items. - * - * The callback should return an associative array with a single key/value pair. - * - * @param callable $callback - * @return static - */ - public function mapWithKeys(callable $callback) - { - return new static(function () use ($callback) { - foreach ($this as $key => $value) { - yield from $callback($value, $key); - } - }); - } - - /** - * Merge the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function merge($items) - { - return $this->passthru('merge', func_get_args()); - } - - /** - * Recursively merge the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function mergeRecursive($items) - { - return $this->passthru('mergeRecursive', func_get_args()); - } - - /** - * Create a collection by using this collection for keys and another for its values. - * - * @param mixed $values - * @return static - */ - public function combine($values) - { - return new static(function () use ($values) { - $values = $this->makeIterator($values); - - $errorMessage = 'Both parameters should have an equal number of elements'; - - foreach ($this as $key) { - if (! $values->valid()) { - trigger_error($errorMessage, E_USER_WARNING); - - break; - } - - yield $key => $values->current(); - - $values->next(); - } - - if ($values->valid()) { - trigger_error($errorMessage, E_USER_WARNING); - } - }); - } - - /** - * Union the collection with the given items. - * - * @param mixed $items - * @return static - */ - public function union($items) - { - return $this->passthru('union', func_get_args()); - } - - /** - * Create a new collection consisting of every n-th element. - * - * @param int $step - * @param int $offset - * @return static - */ - public function nth($step, $offset = 0) - { - return new static(function () use ($step, $offset) { - $position = 0; - - foreach ($this->slice($offset) as $item) { - if ($position % $step === 0) { - yield $item; - } - - $position++; - } - }); - } - - /** - * Get the items with the specified keys. - * - * @param mixed $keys - * @return static - */ - public function only($keys) - { - if ($keys instanceof Enumerable) { - $keys = $keys->all(); - } elseif (! is_null($keys)) { - $keys = is_array($keys) ? $keys : func_get_args(); - } - - return new static(function () use ($keys) { - if (is_null($keys)) { - yield from $this; - } else { - $keys = array_flip($keys); - - foreach ($this as $key => $value) { - if (array_key_exists($key, $keys)) { - yield $key => $value; - - unset($keys[$key]); - - if (empty($keys)) { - break; - } - } - } - } - }); - } - - /** - * Push all of the given items onto the collection. - * - * @param iterable $source - * @return static - */ - public function concat($source) - { - return (new static(function () use ($source) { - yield from $this; - yield from $source; - }))->values(); - } - - /** - * Get one or a specified number of items randomly from the collection. - * - * @param int|null $number - * @return static|mixed - * - * @throws \InvalidArgumentException - */ - public function random($number = null) - { - $result = $this->collect()->random(...func_get_args()); - - return is_null($number) ? $result : new static($result); - } - - /** - * Replace the collection items with the given items. - * - * @param mixed $items - * @return static - */ - public function replace($items) - { - return new static(function () use ($items) { - $items = $this->getArrayableItems($items); - - foreach ($this as $key => $value) { - if (array_key_exists($key, $items)) { - yield $key => $items[$key]; - - unset($items[$key]); - } else { - yield $key => $value; - } - } - - foreach ($items as $key => $value) { - yield $key => $value; - } - }); - } - - /** - * Recursively replace the collection items with the given items. - * - * @param mixed $items - * @return static - */ - public function replaceRecursive($items) - { - return $this->passthru('replaceRecursive', func_get_args()); - } - - /** - * Reverse items order. - * - * @return static - */ - public function reverse() - { - return $this->passthru('reverse', func_get_args()); - } - - /** - * Search the collection for a given value and return the corresponding key if successful. - * - * @param mixed $value - * @param bool $strict - * @return mixed - */ - public function search($value, $strict = false) - { - $predicate = $this->useAsCallable($value) - ? $value - : function ($item) use ($value, $strict) { - return $strict ? $item === $value : $item == $value; - }; - - foreach ($this as $key => $item) { - if ($predicate($item, $key)) { - return $key; - } - } - - return false; - } - - /** - * Shuffle the items in the collection. - * - * @param int|null $seed - * @return static - */ - public function shuffle($seed = null) - { - return $this->passthru('shuffle', func_get_args()); - } - - /** - * Create chunks representing a "sliding window" view of the items in the collection. - * - * @param int $size - * @param int $step - * @return static - */ - public function sliding($size = 2, $step = 1) - { - return new static(function () use ($size, $step) { - $iterator = $this->getIterator(); - - $chunk = []; - - while ($iterator->valid()) { - $chunk[$iterator->key()] = $iterator->current(); - - if (count($chunk) == $size) { - yield tap(new static($chunk), function () use (&$chunk, $step) { - $chunk = array_slice($chunk, $step, null, true); - }); - - // If the $step between chunks is bigger than each chunk's $size - // we will skip the extra items (which should never be in any - // chunk) before we continue to the next chunk in the loop. - if ($step > $size) { - $skip = $step - $size; - - for ($i = 0; $i < $skip && $iterator->valid(); $i++) { - $iterator->next(); - } - } - } - - $iterator->next(); - } - }); - } - - /** - * Skip the first {$count} items. - * - * @param int $count - * @return static - */ - public function skip($count) - { - return new static(function () use ($count) { - $iterator = $this->getIterator(); - - while ($iterator->valid() && $count--) { - $iterator->next(); - } - - while ($iterator->valid()) { - yield $iterator->key() => $iterator->current(); - - $iterator->next(); - } - }); - } - - /** - * Skip items in the collection until the given condition is met. - * - * @param mixed $value - * @return static - */ - public function skipUntil($value) - { - $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - - return $this->skipWhile($this->negate($callback)); - } - - /** - * Skip items in the collection while the given condition is met. - * - * @param mixed $value - * @return static - */ - public function skipWhile($value) - { - $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - - return new static(function () use ($callback) { - $iterator = $this->getIterator(); - - while ($iterator->valid() && $callback($iterator->current(), $iterator->key())) { - $iterator->next(); - } - - while ($iterator->valid()) { - yield $iterator->key() => $iterator->current(); - - $iterator->next(); - } - }); - } - - /** - * Get a slice of items from the enumerable. - * - * @param int $offset - * @param int|null $length - * @return static - */ - public function slice($offset, $length = null) - { - if ($offset < 0 || $length < 0) { - return $this->passthru('slice', func_get_args()); - } - - $instance = $this->skip($offset); - - return is_null($length) ? $instance : $instance->take($length); - } - - /** - * Split a collection into a certain number of groups. - * - * @param int $numberOfGroups - * @return static - */ - public function split($numberOfGroups) - { - return $this->passthru('split', func_get_args()); - } - - /** - * Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return mixed - * - * @throws \Tightenco\Collect\Support\ItemNotFoundException - * @throws \Tightenco\Collect\Support\MultipleItemsFoundException - */ - public function sole($key = null, $operator = null, $value = null) - { - $filter = func_num_args() > 1 - ? $this->operatorForWhere(...func_get_args()) - : $key; - - return $this - ->when($filter) - ->filter($filter) - ->take(2) - ->collect() - ->sole(); - } - - /** - * Get the first item in the collection but throw an exception if no matching items exist. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return mixed - * - * @throws \Tightenco\Collect\Support\ItemNotFoundException - */ - public function firstOrFail($key = null, $operator = null, $value = null) - { - $filter = func_num_args() > 1 - ? $this->operatorForWhere(...func_get_args()) - : $key; - - return $this - ->when($filter) - ->filter($filter) - ->take(1) - ->collect() - ->firstOrFail(); - } - - /** - * Chunk the collection into chunks of the given size. - * - * @param int $size - * @return static - */ - public function chunk($size) - { - if ($size <= 0) { - return static::empty(); - } - - return new static(function () use ($size) { - $iterator = $this->getIterator(); - - while ($iterator->valid()) { - $chunk = []; - - while (true) { - $chunk[$iterator->key()] = $iterator->current(); - - if (count($chunk) < $size) { - $iterator->next(); - - if (! $iterator->valid()) { - break; - } - } else { - break; - } - } - - yield new static($chunk); - - $iterator->next(); - } - }); - } - - /** - * Split a collection into a certain number of groups, and fill the first groups completely. - * - * @param int $numberOfGroups - * @return static - */ - public function splitIn($numberOfGroups) - { - return $this->chunk(ceil($this->count() / $numberOfGroups)); - } - - /** - * Chunk the collection into chunks with a callback. - * - * @param callable $callback - * @return static - */ - public function chunkWhile(callable $callback) - { - return new static(function () use ($callback) { - $iterator = $this->getIterator(); - - $chunk = new Collection; - - if ($iterator->valid()) { - $chunk[$iterator->key()] = $iterator->current(); - - $iterator->next(); - } - - while ($iterator->valid()) { - if (! $callback($iterator->current(), $iterator->key(), $chunk)) { - yield new static($chunk); - - $chunk = new Collection; - } - - $chunk[$iterator->key()] = $iterator->current(); - - $iterator->next(); - } - - if ($chunk->isNotEmpty()) { - yield new static($chunk); - } - }); - } - - /** - * Sort through each item with a callback. - * - * @param callable|null|int $callback - * @return static - */ - public function sort($callback = null) - { - return $this->passthru('sort', func_get_args()); - } - - /** - * Sort items in descending order. - * - * @param int $options - * @return static - */ - public function sortDesc($options = SORT_REGULAR) - { - return $this->passthru('sortDesc', func_get_args()); - } - - /** - * Sort the collection using the given callback. - * - * @param callable|string $callback - * @param int $options - * @param bool $descending - * @return static - */ - public function sortBy($callback, $options = SORT_REGULAR, $descending = false) - { - return $this->passthru('sortBy', func_get_args()); - } - - /** - * Sort the collection in descending order using the given callback. - * - * @param callable|string $callback - * @param int $options - * @return static - */ - public function sortByDesc($callback, $options = SORT_REGULAR) - { - return $this->passthru('sortByDesc', func_get_args()); - } - - /** - * Sort the collection keys. - * - * @param int $options - * @param bool $descending - * @return static - */ - public function sortKeys($options = SORT_REGULAR, $descending = false) - { - return $this->passthru('sortKeys', func_get_args()); - } - - /** - * Sort the collection keys in descending order. - * - * @param int $options - * @return static - */ - public function sortKeysDesc($options = SORT_REGULAR) - { - return $this->passthru('sortKeysDesc', func_get_args()); - } - - /** - * Sort the collection keys using a callback. - * - * @param callable $callback - * @return static - */ - public function sortKeysUsing(callable $callback) - { - return $this->passthru('sortKeysUsing', func_get_args()); - } - - /** - * Take the first or last {$limit} items. - * - * @param int $limit - * @return static - */ - public function take($limit) - { - if ($limit < 0) { - return $this->passthru('take', func_get_args()); - } - - return new static(function () use ($limit) { - $iterator = $this->getIterator(); - - while ($limit--) { - if (! $iterator->valid()) { - break; - } - - yield $iterator->key() => $iterator->current(); - - if ($limit) { - $iterator->next(); - } - } - }); - } - - /** - * Take items in the collection until the given condition is met. - * - * @param mixed $value - * @return static - */ - public function takeUntil($value) - { - $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - - return new static(function () use ($callback) { - foreach ($this as $key => $item) { - if ($callback($item, $key)) { - break; - } - - yield $key => $item; - } - }); - } - - /** - * Take items in the collection until a given point in time. - * - * @param \DateTimeInterface $timeout - * @return static - */ - public function takeUntilTimeout(DateTimeInterface $timeout) - { - $timeout = $timeout->getTimestamp(); - - return $this->takeWhile(function () use ($timeout) { - return $this->now() < $timeout; - }); - } - - /** - * Take items in the collection while the given condition is met. - * - * @param mixed $value - * @return static - */ - public function takeWhile($value) - { - $callback = $this->useAsCallable($value) ? $value : $this->equality($value); - - return $this->takeUntil(function ($item, $key) use ($callback) { - return ! $callback($item, $key); - }); - } - - /** - * Pass each item in the collection to the given callback, lazily. - * - * @param callable $callback - * @return static - */ - public function tapEach(callable $callback) - { - return new static(function () use ($callback) { - foreach ($this as $key => $value) { - $callback($value, $key); - - yield $key => $value; - } - }); - } - - /** - * Convert a flatten "dot" notation array into an expanded array. - * - * @return static - */ - public function undot() - { - return $this->passthru('undot', []); - } - - /** - * Return only unique items from the collection array. - * - * @param string|callable|null $key - * @param bool $strict - * @return static - */ - public function unique($key = null, $strict = false) - { - $callback = $this->valueRetriever($key); - - return new static(function () use ($callback, $strict) { - $exists = []; - - foreach ($this as $key => $item) { - if (! in_array($id = $callback($item, $key), $exists, $strict)) { - yield $key => $item; - - $exists[] = $id; - } - } - }); - } - - /** - * Reset the keys on the underlying array. - * - * @return static - */ - public function values() - { - return new static(function () { - foreach ($this as $item) { - yield $item; - } - }); - } - - /** - * Zip the collection together with one or more arrays. - * - * e.g. new LazyCollection([1, 2, 3])->zip([4, 5, 6]); - * => [[1, 4], [2, 5], [3, 6]] - * - * @param mixed ...$items - * @return static - */ - public function zip($items) - { - $iterables = func_get_args(); - - return new static(function () use ($iterables) { - $iterators = Collection::make($iterables)->map(function ($iterable) { - return $this->makeIterator($iterable); - })->prepend($this->getIterator()); - - while ($iterators->contains->valid()) { - yield new static($iterators->map->current()); - - $iterators->each->next(); - } - }); - } - - /** - * Pad collection to the specified length with a value. - * - * @param int $size - * @param mixed $value - * @return static - */ - public function pad($size, $value) - { - if ($size < 0) { - return $this->passthru('pad', func_get_args()); - } - - return new static(function () use ($size, $value) { - $yielded = 0; - - foreach ($this as $index => $item) { - yield $index => $item; - - $yielded++; - } - - while ($yielded++ < $size) { - yield $value; - } - }); - } - - /** - * Get the values iterator. - * - * @return \Traversable - */ - #[\ReturnTypeWillChange] - public function getIterator() - { - return $this->makeIterator($this->source); - } - - /** - * Count the number of items in the collection. - * - * @return int - */ - #[\ReturnTypeWillChange] - public function count() - { - if (is_array($this->source)) { - return count($this->source); - } - - return iterator_count($this->getIterator()); - } - - /** - * Make an iterator from the given source. - * - * @param mixed $source - * @return \Traversable - */ - protected function makeIterator($source) - { - if ($source instanceof IteratorAggregate) { - return $source->getIterator(); - } - - if (is_array($source)) { - return new ArrayIterator($source); - } - - return $source(); - } - - /** - * Explode the "value" and "key" arguments passed to "pluck". - * - * @param string|array $value - * @param string|array|null $key - * @return array - */ - protected function explodePluckParameters($value, $key) - { - $value = is_string($value) ? explode('.', $value) : $value; - - $key = is_null($key) || is_array($key) ? $key : explode('.', $key); - - return [$value, $key]; - } - - /** - * Pass this lazy collection through a method on the collection class. - * - * @param string $method - * @param array $params - * @return static - */ - protected function passthru($method, array $params) - { - return new static(function () use ($method, $params) { - yield from $this->collect()->$method(...$params); - }); - } - - /** - * Get the current time. - * - * @return int - */ - protected function now() - { - return time(); - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/Traits/EnumeratesValues.php b/vendor/tightenco/collect/src/Collect/Support/Traits/EnumeratesValues.php deleted file mode 100644 index 2f1187f..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/Traits/EnumeratesValues.php +++ /dev/null @@ -1,1116 +0,0 @@ -all() : $value; - } - - /** - * Create a new instance with no items. - * - * @return static - */ - public static function empty() - { - return new static([]); - } - - /** - * Create a new collection by invoking the callback a given amount of times. - * - * @param int $number - * @param callable|null $callback - * @return static - */ - public static function times($number, callable $callback = null) - { - if ($number < 1) { - return new static; - } - - return static::range(1, $number) - ->when($callback) - ->map($callback); - } - - /** - * Alias for the "avg" method. - * - * @param callable|string|null $callback - * @return mixed - */ - public function average($callback = null) - { - return $this->avg($callback); - } - - /** - * Alias for the "contains" method. - * - * @param mixed $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function some($key, $operator = null, $value = null) - { - return $this->contains(...func_get_args()); - } - - /** - * Determine if an item exists, using strict comparison. - * - * @param mixed $key - * @param mixed $value - * @return bool - */ - public function containsStrict($key, $value = null) - { - if (func_num_args() === 2) { - return $this->contains(function ($item) use ($key, $value) { - return data_get($item, $key) === $value; - }); - } - - if ($this->useAsCallable($key)) { - return ! is_null($this->first($key)); - } - - foreach ($this as $item) { - if ($item === $key) { - return true; - } - } - - return false; - } - - /** - * Dump the items and end the script. - * - * @param mixed ...$args - * @return void - */ - public function dd(...$args) - { - $this->dump(...$args); - - exit(1); - } - - /** - * Dump the items. - * - * @return $this - */ - public function dump() - { - (new Collection(func_get_args())) - ->push($this->all()) - ->each(function ($item) { - VarDumper::dump($item); - }); - - return $this; - } - - /** - * Execute a callback over each item. - * - * @param callable $callback - * @return $this - */ - public function each(callable $callback) - { - foreach ($this as $key => $item) { - if ($callback($item, $key) === false) { - break; - } - } - - return $this; - } - - /** - * Execute a callback over each nested chunk of items. - * - * @param callable $callback - * @return static - */ - public function eachSpread(callable $callback) - { - return $this->each(function ($chunk, $key) use ($callback) { - $chunk[] = $key; - - return $callback(...$chunk); - }); - } - - /** - * Determine if all items pass the given truth test. - * - * @param string|callable $key - * @param mixed $operator - * @param mixed $value - * @return bool - */ - public function every($key, $operator = null, $value = null) - { - if (func_num_args() === 1) { - $callback = $this->valueRetriever($key); - - foreach ($this as $k => $v) { - if (! $callback($v, $k)) { - return false; - } - } - - return true; - } - - return $this->every($this->operatorForWhere(...func_get_args())); - } - - /** - * Get the first item by the given key value pair. - * - * @param string $key - * @param mixed $operator - * @param mixed $value - * @return mixed - */ - public function firstWhere($key, $operator = null, $value = null) - { - return $this->first($this->operatorForWhere(...func_get_args())); - } - - /** - * Determine if the collection is not empty. - * - * @return bool - */ - public function isNotEmpty() - { - return ! $this->isEmpty(); - } - - /** - * Run a map over each nested chunk of items. - * - * @param callable $callback - * @return static - */ - public function mapSpread(callable $callback) - { - return $this->map(function ($chunk, $key) use ($callback) { - $chunk[] = $key; - - return $callback(...$chunk); - }); - } - - /** - * Run a grouping map over the items. - * - * The callback should return an associative array with a single key/value pair. - * - * @param callable $callback - * @return static - */ - public function mapToGroups(callable $callback) - { - $groups = $this->mapToDictionary($callback); - - return $groups->map([$this, 'make']); - } - - /** - * Map a collection and flatten the result by a single level. - * - * @param callable $callback - * @return static - */ - public function flatMap(callable $callback) - { - return $this->map($callback)->collapse(); - } - - /** - * Map the values into a new class. - * - * @param string $class - * @return static - */ - public function mapInto($class) - { - return $this->map(function ($value, $key) use ($class) { - return new $class($value, $key); - }); - } - - /** - * Get the min value of a given key. - * - * @param callable|string|null $callback - * @return mixed - */ - public function min($callback = null) - { - $callback = $this->valueRetriever($callback); - - return $this->map(function ($value) use ($callback) { - return $callback($value); - })->filter(function ($value) { - return ! is_null($value); - })->reduce(function ($result, $value) { - return is_null($result) || $value < $result ? $value : $result; - }); - } - - /** - * Get the max value of a given key. - * - * @param callable|string|null $callback - * @return mixed - */ - public function max($callback = null) - { - $callback = $this->valueRetriever($callback); - - return $this->filter(function ($value) { - return ! is_null($value); - })->reduce(function ($result, $item) use ($callback) { - $value = $callback($item); - - return is_null($result) || $value > $result ? $value : $result; - }); - } - - /** - * "Paginate" the collection by slicing it into a smaller collection. - * - * @param int $page - * @param int $perPage - * @return static - */ - public function forPage($page, $perPage) - { - $offset = max(0, ($page - 1) * $perPage); - - return $this->slice($offset, $perPage); - } - - /** - * Partition the collection into two arrays using the given callback or key. - * - * @param callable|string $key - * @param mixed $operator - * @param mixed $value - * @return static - */ - public function partition($key, $operator = null, $value = null) - { - $passed = []; - $failed = []; - - $callback = func_num_args() === 1 - ? $this->valueRetriever($key) - : $this->operatorForWhere(...func_get_args()); - - foreach ($this as $key => $item) { - if ($callback($item, $key)) { - $passed[$key] = $item; - } else { - $failed[$key] = $item; - } - } - - return new static([new static($passed), new static($failed)]); - } - - /** - * Get the sum of the given values. - * - * @param callable|string|null $callback - * @return mixed - */ - public function sum($callback = null) - { - $callback = is_null($callback) - ? $this->identity() - : $this->valueRetriever($callback); - - return $this->reduce(function ($result, $item) use ($callback) { - return $result + $callback($item); - }, 0); - } - - /** - * Apply the callback if the value is truthy. - * - * @param bool|mixed $value - * @param callable|null $callback - * @param callable|null $default - * @return static|mixed - */ - public function when($value, callable $callback = null, callable $default = null) - { - if (! $callback) { - return new HigherOrderWhenProxy($this, $value); - } - - if ($value) { - return $callback($this, $value); - } elseif ($default) { - return $default($this, $value); - } - - return $this; - } - - /** - * Apply the callback if the collection is empty. - * - * @param callable $callback - * @param callable|null $default - * @return static|mixed - */ - public function whenEmpty(callable $callback, callable $default = null) - { - return $this->when($this->isEmpty(), $callback, $default); - } - - /** - * Apply the callback if the collection is not empty. - * - * @param callable $callback - * @param callable|null $default - * @return static|mixed - */ - public function whenNotEmpty(callable $callback, callable $default = null) - { - return $this->when($this->isNotEmpty(), $callback, $default); - } - - /** - * Apply the callback if the value is falsy. - * - * @param bool $value - * @param callable $callback - * @param callable|null $default - * @return static|mixed - */ - public function unless($value, callable $callback, callable $default = null) - { - return $this->when(! $value, $callback, $default); - } - - /** - * Apply the callback unless the collection is empty. - * - * @param callable $callback - * @param callable|null $default - * @return static|mixed - */ - public function unlessEmpty(callable $callback, callable $default = null) - { - return $this->whenNotEmpty($callback, $default); - } - - /** - * Apply the callback unless the collection is not empty. - * - * @param callable $callback - * @param callable|null $default - * @return static|mixed - */ - public function unlessNotEmpty(callable $callback, callable $default = null) - { - return $this->whenEmpty($callback, $default); - } - - /** - * Filter items by the given key value pair. - * - * @param string $key - * @param mixed $operator - * @param mixed $value - * @return static - */ - public function where($key, $operator = null, $value = null) - { - return $this->filter($this->operatorForWhere(...func_get_args())); - } - - /** - * Filter items where the value for the given key is null. - * - * @param string|null $key - * @return static - */ - public function whereNull($key = null) - { - return $this->whereStrict($key, null); - } - - /** - * Filter items where the value for the given key is not null. - * - * @param string|null $key - * @return static - */ - public function whereNotNull($key = null) - { - return $this->where($key, '!==', null); - } - - /** - * Filter items by the given key value pair using strict comparison. - * - * @param string $key - * @param mixed $value - * @return static - */ - public function whereStrict($key, $value) - { - return $this->where($key, '===', $value); - } - - /** - * Filter items by the given key value pair. - * - * @param string $key - * @param mixed $values - * @param bool $strict - * @return static - */ - public function whereIn($key, $values, $strict = false) - { - $values = $this->getArrayableItems($values); - - return $this->filter(function ($item) use ($key, $values, $strict) { - return in_array(data_get($item, $key), $values, $strict); - }); - } - - /** - * Filter items by the given key value pair using strict comparison. - * - * @param string $key - * @param mixed $values - * @return static - */ - public function whereInStrict($key, $values) - { - return $this->whereIn($key, $values, true); - } - - /** - * Filter items such that the value of the given key is between the given values. - * - * @param string $key - * @param array $values - * @return static - */ - public function whereBetween($key, $values) - { - return $this->where($key, '>=', reset($values))->where($key, '<=', end($values)); - } - - /** - * Filter items such that the value of the given key is not between the given values. - * - * @param string $key - * @param array $values - * @return static - */ - public function whereNotBetween($key, $values) - { - return $this->filter(function ($item) use ($key, $values) { - return data_get($item, $key) < reset($values) || data_get($item, $key) > end($values); - }); - } - - /** - * Filter items by the given key value pair. - * - * @param string $key - * @param mixed $values - * @param bool $strict - * @return static - */ - public function whereNotIn($key, $values, $strict = false) - { - $values = $this->getArrayableItems($values); - - return $this->reject(function ($item) use ($key, $values, $strict) { - return in_array(data_get($item, $key), $values, $strict); - }); - } - - /** - * Filter items by the given key value pair using strict comparison. - * - * @param string $key - * @param mixed $values - * @return static - */ - public function whereNotInStrict($key, $values) - { - return $this->whereNotIn($key, $values, true); - } - - /** - * Filter the items, removing any items that don't match the given type(s). - * - * @param string|string[] $type - * @return static - */ - public function whereInstanceOf($type) - { - return $this->filter(function ($value) use ($type) { - if (is_array($type)) { - foreach ($type as $classType) { - if ($value instanceof $classType) { - return true; - } - } - - return false; - } - - return $value instanceof $type; - }); - } - - /** - * Pass the collection to the given callback and return the result. - * - * @param callable $callback - * @return mixed - */ - public function pipe(callable $callback) - { - return $callback($this); - } - - /** - * Pass the collection into a new class. - * - * @param string $class - * @return mixed - */ - public function pipeInto($class) - { - return new $class($this); - } - - /** - * Pass the collection through a series of callable pipes and return the result. - * - * @param array $pipes - * @return mixed - */ - public function pipeThrough($pipes) - { - return static::make($pipes)->reduce( - function ($carry, $pipe) { - return $pipe($carry); - }, - $this, - ); - } - - /** - * Pass the collection to the given callback and then return it. - * - * @param callable $callback - * @return $this - */ - public function tap(callable $callback) - { - $callback(clone $this); - - return $this; - } - - /** - * Reduce the collection to a single value. - * - * @param callable $callback - * @param mixed $initial - * @return mixed - */ - public function reduce(callable $callback, $initial = null) - { - $result = $initial; - - foreach ($this as $key => $value) { - $result = $callback($result, $value, $key); - } - - return $result; - } - - /** - * Reduce the collection to multiple aggregate values. - * - * @param callable $callback - * @param mixed ...$initial - * @return array - * - * @deprecated Use "reduceSpread" instead - * - * @throws \UnexpectedValueException - */ - public function reduceMany(callable $callback, ...$initial) - { - return $this->reduceSpread($callback, ...$initial); - } - - /** - * Reduce the collection to multiple aggregate values. - * - * @param callable $callback - * @param mixed ...$initial - * @return array - * - * @throws \UnexpectedValueException - */ - public function reduceSpread(callable $callback, ...$initial) - { - $result = $initial; - - foreach ($this as $key => $value) { - $result = call_user_func_array($callback, array_merge($result, [$value, $key])); - - if (! is_array($result)) { - throw new UnexpectedValueException(sprintf( - "%s::reduceMany expects reducer to return an array, but got a '%s' instead.", - class_basename(static::class), gettype($result) - )); - } - } - - return $result; - } - - /** - * Reduce an associative collection to a single value. - * - * @param callable $callback - * @param mixed $initial - * @return mixed - */ - public function reduceWithKeys(callable $callback, $initial = null) - { - return $this->reduce($callback, $initial); - } - - /** - * Create a collection of all elements that do not pass a given truth test. - * - * @param callable|mixed $callback - * @return static - */ - public function reject($callback = true) - { - $useAsCallable = $this->useAsCallable($callback); - - return $this->filter(function ($value, $key) use ($callback, $useAsCallable) { - return $useAsCallable - ? ! $callback($value, $key) - : $value != $callback; - }); - } - - /** - * Return only unique items from the collection array using strict comparison. - * - * @param string|callable|null $key - * @return static - */ - public function uniqueStrict($key = null) - { - return $this->unique($key, true); - } - - /** - * Collect the values into a collection. - * - * @return \Tightenco\Collect\Support\Collection - */ - public function collect() - { - return new Collection($this->all()); - } - - /** - * Get the collection of items as a plain array. - * - * @return array - */ - public function toArray() - { - return $this->map(function ($value) { - return $value instanceof Arrayable ? $value->toArray() : $value; - })->all(); - } - - /** - * Convert the object into something JSON serializable. - * - * @return array - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - return array_map(function ($value) { - if ($value instanceof JsonSerializable) { - return $value->jsonSerialize(); - } elseif ($value instanceof Jsonable) { - return json_decode($value->toJson(), true); - } elseif ($value instanceof Arrayable) { - return $value->toArray(); - } - - return $value; - }, $this->all()); - } - - /** - * Get the collection of items as JSON. - * - * @param int $options - * @return string - */ - public function toJson($options = 0) - { - return json_encode($this->jsonSerialize(), $options); - } - - /** - * Get a CachingIterator instance. - * - * @param int $flags - * @return \CachingIterator - */ - public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING) - { - return new CachingIterator($this->getIterator(), $flags); - } - - /** - * Convert the collection to its string representation. - * - * @return string - */ - public function __toString() - { - return $this->escapeWhenCastingToString - ? e($this->toJson()) - : $this->toJson(); - } - - /** - * Indicate that the model's string representation should be escaped when __toString is invoked. - * - * @param bool $escape - * @return $this - */ - public function escapeWhenCastingToString($escape = true) - { - $this->escapeWhenCastingToString = $escape; - - return $this; - } - - /** - * Add a method to the list of proxied methods. - * - * @param string $method - * @return void - */ - public static function proxy($method) - { - static::$proxies[] = $method; - } - - /** - * Dynamically access collection proxies. - * - * @param string $key - * @return mixed - * - * @throws \Exception - */ - public function __get($key) - { - if (! in_array($key, static::$proxies)) { - throw new Exception("Property [{$key}] does not exist on this collection instance."); - } - - return new HigherOrderCollectionProxy($this, $key); - } - - /** - * Results array of items from Collection or Arrayable. - * - * @param mixed $items - * @return array - */ - protected function getArrayableItems($items) - { - if (is_array($items)) { - return $items; - } elseif ($items instanceof Enumerable) { - return $items->all(); - } elseif ($items instanceof Arrayable) { - return $items->toArray(); - } elseif ($items instanceof Jsonable) { - return json_decode($items->toJson(), true); - } elseif ($items instanceof JsonSerializable) { - return (array) $items->jsonSerialize(); - } elseif ($items instanceof Traversable) { - return iterator_to_array($items); - } elseif ($items instanceof UnitEnum) { - return [$items]; - } - - return (array) $items; - } - - /** - * Get an operator checker callback. - * - * @param string $key - * @param string|null $operator - * @param mixed $value - * @return \Closure - */ - protected function operatorForWhere($key, $operator = null, $value = null) - { - if (func_num_args() === 1) { - $value = true; - - $operator = '='; - } - - if (func_num_args() === 2) { - $value = $operator; - - $operator = '='; - } - - return function ($item) use ($key, $operator, $value) { - $retrieved = data_get($item, $key); - - $strings = array_filter([$retrieved, $value], function ($value) { - return is_string($value) || (is_object($value) && method_exists($value, '__toString')); - }); - - if (count($strings) < 2 && count(array_filter([$retrieved, $value], 'is_object')) == 1) { - return in_array($operator, ['!=', '<>', '!==']); - } - - switch ($operator) { - default: - case '=': - case '==': return $retrieved == $value; - case '!=': - case '<>': return $retrieved != $value; - case '<': return $retrieved < $value; - case '>': return $retrieved > $value; - case '<=': return $retrieved <= $value; - case '>=': return $retrieved >= $value; - case '===': return $retrieved === $value; - case '!==': return $retrieved !== $value; - } - }; - } - - /** - * Determine if the given value is callable, but not a string. - * - * @param mixed $value - * @return bool - */ - protected function useAsCallable($value) - { - return ! is_string($value) && is_callable($value); - } - - /** - * Get a value retrieving callback. - * - * @param callable|string|null $value - * @return callable - */ - protected function valueRetriever($value) - { - if ($this->useAsCallable($value)) { - return $value; - } - - return function ($item) use ($value) { - return data_get($item, $value); - }; - } - - /** - * Make a function to check an item's equality. - * - * @param mixed $value - * @return \Closure - */ - protected function equality($value) - { - return function ($item) use ($value) { - return $item === $value; - }; - } - - /** - * Make a function using another function, by negating its result. - * - * @param \Closure $callback - * @return \Closure - */ - protected function negate(Closure $callback) - { - return function (...$params) use ($callback) { - return ! $callback(...$params); - }; - } - - /** - * Make a function that returns what's passed to it. - * - * @return \Closure - */ - protected function identity() - { - return function ($value) { - return $value; - }; - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/Traits/Macroable.php b/vendor/tightenco/collect/src/Collect/Support/Traits/Macroable.php deleted file mode 100644 index 7e9fbd5..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/Traits/Macroable.php +++ /dev/null @@ -1,126 +0,0 @@ -getMethods( - ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED - ); - - foreach ($methods as $method) { - if ($replace || ! static::hasMacro($method->name)) { - $method->setAccessible(true); - static::macro($method->name, $method->invoke($mixin)); - } - } - } - - /** - * Checks if macro is registered. - * - * @param string $name - * @return bool - */ - public static function hasMacro($name) - { - return isset(static::$macros[$name]); - } - - /** - * Flush the existing macros. - * - * @return void - */ - public static function flushMacros() - { - static::$macros = []; - } - - /** - * Dynamically handle calls to the class. - * - * @param string $method - * @param array $parameters - * @return mixed - * - * @throws \BadMethodCallException - */ - public static function __callStatic($method, $parameters) - { - if (! static::hasMacro($method)) { - throw new BadMethodCallException(sprintf( - 'Method %s::%s does not exist.', static::class, $method - )); - } - - $macro = static::$macros[$method]; - - if ($macro instanceof Closure) { - $macro = $macro->bindTo(null, static::class); - } - - return $macro(...$parameters); - } - - /** - * Dynamically handle calls to the class. - * - * @param string $method - * @param array $parameters - * @return mixed - * - * @throws \BadMethodCallException - */ - public function __call($method, $parameters) - { - if (! static::hasMacro($method)) { - throw new BadMethodCallException(sprintf( - 'Method %s::%s does not exist.', static::class, $method - )); - } - - $macro = static::$macros[$method]; - - if ($macro instanceof Closure) { - $macro = $macro->bindTo($this, static::class); - } - - return $macro(...$parameters); - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/Traits/Tappable.php b/vendor/tightenco/collect/src/Collect/Support/Traits/Tappable.php deleted file mode 100644 index 9d75d26..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/Traits/Tappable.php +++ /dev/null @@ -1,17 +0,0 @@ - Illuminate\Contracts\Support\Arrayable::class, - Tightenco\Collect\Contracts\Support\Jsonable::class => Illuminate\Contracts\Support\Jsonable::class, - Tightenco\Collect\Contracts\Support\Htmlable::class => Illuminate\Contracts\Support\Htmlable::class, - Tightenco\Collect\Contracts\Support\CanBeEscapedWhenCastToString::class => Illuminate\Contracts\Support\CanBeEscapedWhenCastToString::class, - Tightenco\Collect\Support\Arr::class => Illuminate\Support\Arr::class, - Tightenco\Collect\Support\Collection::class => Illuminate\Support\Collection::class, - Tightenco\Collect\Support\Enumerable::class => Illuminate\Support\Enumerable::class, - Tightenco\Collect\Support\HigherOrderCollectionProxy::class => Illuminate\Support\HigherOrderCollectionProxy::class, - Tightenco\Collect\Support\HigherOrderWhenProxy::class => Illuminate\Support\HigherOrderWhenProxy::class, - Tightenco\Collect\Support\LazyCollection::class => Illuminate\Support\LazyCollection::class, - Tightenco\Collect\Support\Traits\EnumeratesValues::class => Illuminate\Support\Traits\EnumeratesValues::class, -]; - -# echo "\n\n-- Aliasing....\n---------------------------------------------\n\n"; - -foreach ($aliases as $tighten => $illuminate) { - if (! class_exists($illuminate) && ! interface_exists($illuminate) && ! trait_exists($illuminate)) { - # echo "Aliasing {$tighten} to {$illuminate}.\n"; - class_alias($tighten, $illuminate); - } -} diff --git a/vendor/tightenco/collect/src/Collect/Support/helpers.php b/vendor/tightenco/collect/src/Collect/Support/helpers.php deleted file mode 100644 index 886a141..0000000 --- a/vendor/tightenco/collect/src/Collect/Support/helpers.php +++ /dev/null @@ -1,122 +0,0 @@ - $segment) { - unset($key[$i]); - - if (is_null($segment)) { - return $target; - } - - if ($segment === '*') { - if ($target instanceof Collection) { - $target = $target->all(); - } elseif (! is_array($target)) { - return value($default); - } - - $result = []; - - foreach ($target as $item) { - $result[] = data_get($item, $key); - } - - return in_array('*', $key) ? Arr::collapse($result) : $result; - } - - if (Arr::accessible($target) && Arr::exists($target, $segment)) { - $target = $target[$segment]; - } elseif (is_object($target) && isset($target->{$segment})) { - $target = $target->{$segment}; - } else { - return value($default); - } - } - - return $target; - } - } - - if (! function_exists('tap')) { - /** - * Call the given Closure with the given value then return the value. - * - * @param mixed $value - * @param callable|null $callback - * @return mixed - */ - function tap($value, $callback = null) - { - if (is_null($callback)) { - return new HigherOrderTapProxy($value); - } - - $callback($value); - - return $value; - } - } - - if (! function_exists('class_basename')) { - /** - * Get the class "basename" of the given object / class. - * - * @param string|object $class - * @return string - */ - function class_basename($class) - { - $class = is_object($class) ? get_class($class) : $class; - - return basename(str_replace('\\', '/', $class)); - } - } -} diff --git a/vendor/topthink/framework/.github/workflows/build.yml b/vendor/topthink/framework/.github/workflows/build.yml new file mode 100644 index 0000000..f2f5537 --- /dev/null +++ b/vendor/topthink/framework/.github/workflows/build.yml @@ -0,0 +1,48 @@ +name: build + +on: + push: + branches: + - "8.0" + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + tests: + runs-on: ubuntu-22.04 + + strategy: + fail-fast: true + matrix: + php: [8.0, 8.1, 8.2] + + name: PHP ${{ matrix.php }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 10 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer:v2 + coverage: xdebug + + - name: Install dependencies + uses: nick-fields/retry@v2 + with: + timeout_minutes: 5 + max_attempts: 5 + command: composer update --prefer-dist --no-interaction --prefer-stable --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml + + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--format=php-clover build/logs/clover.xml --revision=${{ github.event.pull_request.head.sha || github.sha }}" diff --git a/vendor/topthink/framework/.gitignore b/vendor/topthink/framework/.gitignore index b2fd3b9..1accf15 100644 --- a/vendor/topthink/framework/.gitignore +++ b/vendor/topthink/framework/.gitignore @@ -7,4 +7,5 @@ Thumbs.db /.vscode /.settings /.buildpath -/.project \ No newline at end of file +/.project +.phpunit.result.cache diff --git a/vendor/topthink/framework/.travis.yml b/vendor/topthink/framework/.travis.yml deleted file mode 100644 index abaa271..0000000 --- a/vendor/topthink/framework/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -dist: xenial -language: php - -matrix: - fast_finish: true - include: - - php: 7.2 - - php: 7.3 - - php: 8.0 - -cache: - directories: - - $HOME/.composer/cache - -services: - - memcached - - redis-server - - mysql - -before_install: - - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - - echo 'xdebug.mode = coverage' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - printf "\n" | pecl install -f redis - - travis_retry composer self-update - - mysql -e 'CREATE DATABASE test;' - -install: - - travis_retry composer update --prefer-dist --no-interaction --prefer-stable --no-suggest - -script: - - vendor/bin/phpunit --coverage-clover build/logs/coverage.xml - -after_script: - - travis_retry wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.xml diff --git a/vendor/topthink/framework/LICENSE.txt b/vendor/topthink/framework/LICENSE.txt index 4e910bb..3dcd79f 100644 --- a/vendor/topthink/framework/LICENSE.txt +++ b/vendor/topthink/framework/LICENSE.txt @@ -1,6 +1,6 @@ ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 -版权所有Copyright © 2006-2019 by ThinkPHP (http://thinkphp.cn) +版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。 ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 diff --git a/vendor/topthink/framework/README.md b/vendor/topthink/framework/README.md index dd38e34..906d042 100644 --- a/vendor/topthink/framework/README.md +++ b/vendor/topthink/framework/README.md @@ -1,39 +1,44 @@ -![](https://box.kancloud.cn/5a0aaa69a5ff42657b5c4715f3d49221) +![](https://www.thinkphp.cn/uploads/images/20230630/300c856765af4d8ae758c503185f8739.png) -ThinkPHP 6.1 +ThinkPHP 8.0 =============== -[![Build Status](https://travis-ci.org/top-think/framework.svg?branch=6.0)](https://travis-ci.org/top-think/framework) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/top-think/framework/badges/quality-score.png?b=6.0)](https://scrutinizer-ci.com/g/top-think/framework/?branch=6.0) -[![Code Coverage](https://scrutinizer-ci.com/g/top-think/framework/badges/coverage.png?b=6.0)](https://scrutinizer-ci.com/g/top-think/framework/?branch=6.0) +[![build](https://github.com/top-think/framework/actions/workflows/build.yml/badge.svg?branch=8.0)](https://github.com/top-think/framework/actions) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/top-think/framework/badges/quality-score.png?b=8.0)](https://scrutinizer-ci.com/g/top-think/framework/?branch=8.0) +[![Code Coverage](https://scrutinizer-ci.com/g/top-think/framework/badges/coverage.png?b=8.0)](https://scrutinizer-ci.com/g/top-think/framework/?branch=8.0) [![Total Downloads](https://poser.pugx.org/topthink/framework/downloads)](https://packagist.org/packages/topthink/framework) [![Latest Stable Version](https://poser.pugx.org/topthink/framework/v/stable)](https://packagist.org/packages/topthink/framework) -[![PHP Version](https://img.shields.io/badge/php-%3E%3D7.1-8892BF.svg)](http://www.php.net/) +[![PHP Version](https://img.shields.io/badge/php-%3E%3D8.0-8892BF.svg)](http://www.php.net/) [![License](https://poser.pugx.org/topthink/framework/license)](https://packagist.org/packages/topthink/framework) +## 主要特性 -[官方服务](https://www.topthink.com) | [`ThinkAPI`——官方统一API](https://doc.topthink.com/think-api) - -## 主要新特性 - -* 采用`PHP7`强类型(严格模式) -* 支持更多的`PSR`规范 -* 原生多应用支持 -* 系统服务注入支持 -* ORM作为独立组件使用 -* 全新的事件系统 -* 模板引擎分离出核心 -* 内部功能中间件化 -* SESSION机制改进 -* 日志多通道支持 -* 规范扩展接口 -* 更强大的控制台 -* 对Swoole以及协程支持改进 -* 对IDE更加友好 -* 统一和精简大量用法 +* 基于PHP`8.0+`重构 +* 升级`PSR`依赖 +* 依赖`think-orm`3.0版本 +* `6.0`/`6.1`无缝升级 -> ThinkPHP6.1的运行环境要求PHP7.2.5+,最高兼容PHP8.2 +> ThinkPHP8.0的运行环境要求PHP8.0.0+ + +现在开始,你可以使用官方提供的[ThinkChat](https://chat.topthink.com/),让你在学习ThinkPHP的旅途中享受私人AI助理服务! + +[![](https://www.topthink.com/uploads/assistant/20230630/4d1a3f0ad2958b49bb8189b7ef824cb0.png)](https://chat.topthink.com/) + +ThinkPHP生态服务由[顶想云](https://www.topthink.com)(TOPThink Cloud)提供,为生态提供专业的开发者服务和价值之选。 + +## 文档 + +[完全开发手册](https://doc.thinkphp.cn) + + +## 赞助商 + +全新的[赞助计划](https://www.thinkphp.cn/sponsor)可以让你通过我们的网站、手册、欢迎页及GIT仓库获得巨大曝光,同时提升企业的品牌声誉,也更好保障ThinkPHP的可持续发展。 + +[![](https://www.thinkphp.cn/sponsor/special.svg)](https://www.thinkphp.cn/sponsor/special) + +[![](https://www.thinkphp.cn/sponsor.svg)](https://www.thinkphp.cn/sponsor) ## 安装 @@ -59,13 +64,9 @@ http://localhost:8000 composer update topthink/framework ~~~ -## 文档 - -[完全开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content) - ## 命名规范 -`ThinkPHP6`遵循PSR-2命名规范和PSR-4自动加载规范。 +`ThinkPHP`遵循PSR-2命名规范和PSR-4自动加载规范。 ## 参与开发 @@ -77,7 +78,7 @@ ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 本项目包含的第三方源码和二进制文件之版权信息另行标注。 -版权所有Copyright © 2006-2021 by ThinkPHP (http://thinkphp.cn) All rights reserved。 +版权所有Copyright © 2006-2023 by ThinkPHP (http://thinkphp.cn) All rights reserved。 ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 diff --git a/vendor/topthink/framework/composer.json b/vendor/topthink/framework/composer.json index 2d9685e..53c7d80 100644 --- a/vendor/topthink/framework/composer.json +++ b/vendor/topthink/framework/composer.json @@ -19,20 +19,20 @@ } ], "require": { - "php": ">=7.2.5", + "php": ">=8.0.0", "ext-json": "*", "ext-mbstring": "*", - "psr/log": "~1.0", - "psr/container": "~1.0", - "psr/simple-cache": "^1.0", + "psr/log": "^3.0", + "psr/container": "^2.0", + "psr/simple-cache": "^3.0", "psr/http-message": "^1.0", - "topthink/think-orm": "^2.0|^3.0", - "topthink/think-helper": "^3.1.1" + "topthink/think-orm": "^3.0", + "topthink/think-helper": "^3.1" }, "require-dev": { "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.2", - "phpunit/phpunit": "^7.0", + "phpunit/phpunit": "^9.5", "guzzlehttp/psr7": "^2.1.0" }, "autoload": { diff --git a/vendor/topthink/framework/phpunit.xml.dist b/vendor/topthink/framework/phpunit.xml.dist index e20a133..4966885 100644 --- a/vendor/topthink/framework/phpunit.xml.dist +++ b/vendor/topthink/framework/phpunit.xml.dist @@ -1,5 +1,6 @@ - + + + ./src/think + + ./tests - - - ./src/think - - diff --git a/vendor/topthink/framework/src/helper.php b/vendor/topthink/framework/src/helper.php index caba0ae..a8f9ff9 100644 --- a/vendor/topthink/framework/src/helper.php +++ b/vendor/topthink/framework/src/helper.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); //------------------------ // ThinkPHP 助手函数 @@ -100,7 +100,7 @@ if (!function_exists('cache')) { if ('' === $value) { // 获取缓存 - return 0 === strpos($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name); + return str_starts_with($name, '?') ? Cache::has(substr($name, 1)) : Cache::get($name); } elseif (is_null($value)) { // 删除缓存 return Cache::delete($name); @@ -134,7 +134,7 @@ if (!function_exists('config')) { return Config::set($name, $value); } - return 0 === strpos($name, '?') ? Config::has(substr($name, 1)) : Config::get($name, $value); + return str_starts_with($name, '?') ? Config::has(substr($name, 1)) : Config::get($name, $value); } } @@ -153,7 +153,7 @@ if (!function_exists('cookie')) { Cookie::delete($name, $option ?: []); } elseif ('' === $value) { // 获取 - return 0 === strpos($name, '?') ? Cookie::has(substr($name, 1)) : Cookie::get($name); + return str_starts_with($name, '?') ? Cookie::has(substr($name, 1)) : Cookie::get($name); } else { // 设置 return Cookie::set($name, $value, $option); @@ -253,7 +253,7 @@ if (!function_exists('input')) { */ function input(string $key = '', $default = null, $filter = '') { - if (0 === strpos($key, '?')) { + if (str_starts_with($key, '?')) { $key = substr($key, 1); $has = true; } @@ -275,8 +275,8 @@ if (!function_exists('input')) { } return isset($has) ? - request()->has($key, $method) : - request()->$method($key, $default, $filter); + request()->has($key, $method) : + request()->$method($key, $default, $filter); } } @@ -422,7 +422,7 @@ if (!function_exists('session')) { Session::delete($name); } elseif ('' === $value) { // 判断或获取 - return 0 === strpos($name, '?') ? Session::has(substr($name, 1)) : Session::get($name); + return str_starts_with($name, '?') ? Session::has(substr($name, 1)) : Session::get($name); } else { // 设置 Session::set($name, $value); @@ -522,12 +522,12 @@ if (!function_exists('validate')) { $v->rule($validate); } } else { - if (strpos($validate, '.')) { + if (str_contains($validate, '.')) { // 支持场景 [$validate, $scene] = explode('.', $validate); } - $class = false !== strpos($validate, '\\') ? $validate : app()->parseClass('validate', $validate); + $class = str_contains($validate, '\\') ? $validate : app()->parseClass('validate', $validate); $v = new $class(); diff --git a/vendor/topthink/framework/src/lang/zh-cn.php b/vendor/topthink/framework/src/lang/zh-cn.php index a546330..9bfb60b 100644 --- a/vendor/topthink/framework/src/lang/zh-cn.php +++ b/vendor/topthink/framework/src/lang/zh-cn.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -100,6 +100,10 @@ return [ ':attribute must be numeric' => ':attribute必须是数字', ':attribute must be integer' => ':attribute必须是整数', ':attribute must be float' => ':attribute必须是浮点数', + ':attribute must be string' => ':attribute必须是字符串', + ':attribute must start with :rule' => ':attribute必须以 :rule 开头', + ':attribute must end with :rule' => ':attribute必须以 :rule 结尾', + ':attribute must contain :rule' => ':attribute必须包含 :rule', ':attribute must be bool' => ':attribute必须是布尔值', ':attribute not a valid email address' => ':attribute格式不符', ':attribute not a valid mobile' => ':attribute格式不符', diff --git a/vendor/topthink/framework/src/think/App.php b/vendor/topthink/framework/src/think/App.php index 5aa4a87..f4cd3ee 100644 --- a/vendor/topthink/framework/src/think/App.php +++ b/vendor/topthink/framework/src/think/App.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -38,7 +38,7 @@ use think\initializer\RegisterService; */ class App extends Container { - const VERSION = '6.1.3'; + const VERSION = '8.0.0'; /** * 应用调试模式 @@ -188,7 +188,7 @@ class App extends Container * @param bool $force 强制重新注册 * @return Service|null */ - public function register($service, bool $force = false) + public function register(Service|string $service, bool $force = false) { $registered = $this->getService($service); @@ -217,7 +217,7 @@ class App extends Container * @param Service $service 服务 * @return mixed */ - public function bootService($service) + public function bootService(Service $service) { if (method_exists($service, 'boot')) { return $this->invoke([$service, 'boot']); @@ -229,9 +229,9 @@ class App extends Container * @param string|Service $service * @return Service|null */ - public function getService($service) + public function getService(Service|string $service): ?Service { - $name = is_string($service) ? $service : get_class($service); + $name = is_string($service) ? $service : $service::class; return array_values(array_filter($this->services, function ($value) use ($name) { return $value instanceof $name; }, ARRAY_FILTER_USE_BOTH))[0] ?? null; @@ -477,7 +477,7 @@ class App extends Container * 加载语言包 * @return void */ - public function loadLangPack() + public function loadLangPack(): void { // 加载默认语言包 $langSet = $this->lang->defaultLangSet(); @@ -616,5 +616,4 @@ class App extends Container { return dirname($this->thinkPath, 4) . DIRECTORY_SEPARATOR; } - } diff --git a/vendor/topthink/framework/src/think/Cache.php b/vendor/topthink/framework/src/think/Cache.php index f802b55..822fbe0 100644 --- a/vendor/topthink/framework/src/think/Cache.php +++ b/vendor/topthink/framework/src/think/Cache.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types = 1); namespace think; +use DateInterval; use Psr\SimpleCache\CacheInterface; use think\cache\Driver; use think\cache\TagSet; @@ -32,7 +33,7 @@ class Cache extends Manager implements CacheInterface * 默认驱动 * @return string|null */ - public function getDefaultDriver() + public function getDefaultDriver(): ?string { return $this->getConfig('default'); } @@ -57,7 +58,7 @@ class Cache extends Manager implements CacheInterface * 获取驱动配置 * @param string $store * @param string $name - * @param null $default + * @param mixed $default * @return array */ public function getStoreConfig(string $store, string $name = null, $default = null) @@ -82,7 +83,7 @@ class Cache extends Manager implements CacheInterface /** * 连接或者切换缓存 * @access public - * @param string $name 连接配置名 + * @param string|null $name 连接配置名 * @return Driver */ public function store(string $name = null) @@ -107,7 +108,7 @@ class Cache extends Manager implements CacheInterface * @param mixed $default 默认值 * @return mixed */ - public function get($key, $default = null) + public function get(string $key, mixed $default = null): mixed { return $this->store()->get($key, $default); } @@ -120,7 +121,7 @@ class Cache extends Manager implements CacheInterface * @param int|\DateTime $ttl 有效时间 0为永久 * @return bool */ - public function set($key, $value, $ttl = null): bool + public function set(string $key, mixed $value, int|DateInterval $ttl = null): bool { return $this->store()->set($key, $value, $ttl); } @@ -131,7 +132,7 @@ class Cache extends Manager implements CacheInterface * @param string $key 缓存变量名 * @return bool */ - public function delete($key): bool + public function delete(string $key): bool { return $this->store()->delete($key); } @@ -144,7 +145,7 @@ class Cache extends Manager implements CacheInterface * @return iterable * @throws InvalidArgumentException */ - public function getMultiple($keys, $default = null): iterable + public function getMultiple(iterable $keys, mixed $default = null): iterable { return $this->store()->getMultiple($keys, $default); } @@ -156,7 +157,7 @@ class Cache extends Manager implements CacheInterface * @param null|int|\DateInterval $ttl 有效时间 0为永久 * @return bool */ - public function setMultiple($values, $ttl = null): bool + public function setMultiple(iterable $values, int|DateInterval $ttl = null): bool { return $this->store()->setMultiple($values, $ttl); } @@ -168,7 +169,7 @@ class Cache extends Manager implements CacheInterface * @return bool * @throws InvalidArgumentException */ - public function deleteMultiple($keys): bool + public function deleteMultiple(iterable $keys): bool { return $this->store()->deleteMultiple($keys); } @@ -179,7 +180,7 @@ class Cache extends Manager implements CacheInterface * @param string $key 缓存变量名 * @return bool */ - public function has($key): bool + public function has(string $key): bool { return $this->store()->has($key); } @@ -190,7 +191,7 @@ class Cache extends Manager implements CacheInterface * @param string|array $name 标签名 * @return TagSet */ - public function tag($name): TagSet + public function tag(string|array $name): TagSet { return $this->store()->tag($name); } diff --git a/vendor/topthink/framework/src/think/Config.php b/vendor/topthink/framework/src/think/Config.php index 9162e82..b0288c7 100644 --- a/vendor/topthink/framework/src/think/Config.php +++ b/vendor/topthink/framework/src/think/Config.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -24,26 +24,12 @@ class Config */ protected $config = []; - /** - * 配置文件目录 - * @var string - */ - protected $path; - - /** - * 配置文件后缀 - * @var string - */ - protected $ext; - /** * 构造方法 * @access public */ - public function __construct(string $path = null, string $ext = '.php') + public function __construct(protected string $path = '', protected string $ext = '.php') { - $this->path = $path ?: ''; - $this->ext = $ext; } public static function __make(App $app) @@ -87,23 +73,13 @@ class Config { $type = pathinfo($file, PATHINFO_EXTENSION); $config = []; - switch ($type) { - case 'php': - $config = include $file; - break; - case 'yml': - case 'yaml': - if (function_exists('yaml_parse_file')) { - $config = yaml_parse_file($file); - } - break; - case 'ini': - $config = parse_ini_file($file, true, INI_SCANNER_TYPED) ?: []; - break; - case 'json': - $config = json_decode(file_get_contents($file), true); - break; - } + $config = match ($type) { + 'php' => include $file, + 'yml','yaml' => function_exists('yaml_parse_file') ? yaml_parse_file($file) : [], + 'ini' => parse_ini_file($file, true, INI_SCANNER_TYPED) ?: [], + 'json' => json_decode(file_get_contents($file), true), + default => [], + }; return is_array($config) ? $this->set($config, strtolower($name)) : []; } @@ -116,7 +92,7 @@ class Config */ public function has(string $name): bool { - if (false === strpos($name, '.') && !isset($this->config[strtolower($name)])) { + if (!str_contains($name, '.') && !isset($this->config[strtolower($name)])) { return false; } @@ -150,7 +126,7 @@ class Config return $this->config; } - if (false === strpos($name, '.')) { + if (!str_contains($name, '.')) { return $this->pull($name); } @@ -179,19 +155,19 @@ class Config */ public function set(array $config, string $name = null): array { - if (!empty($name)) { - if (isset($this->config[$name])) { - $result = array_merge($this->config[$name], $config); - } else { - $result = $config; - } - - $this->config[$name] = $result; - } else { - $result = $this->config = array_merge($this->config, array_change_key_case($config)); + if (empty($name)) { + $this->config = array_merge($this->config, array_change_key_case($config)); + return $this->config; } + if (isset($this->config[$name])) { + $result = array_merge($this->config[$name], $config); + } else { + $result = $config; + } + + $this->config[$name] = $result; + return $result; } - } diff --git a/vendor/topthink/framework/src/think/Console.php b/vendor/topthink/framework/src/think/Console.php index 27f12ba..91af08b 100644 --- a/vendor/topthink/framework/src/think/Console.php +++ b/vendor/topthink/framework/src/think/Console.php @@ -46,9 +46,6 @@ use think\console\output\driver\Buffer; */ class Console { - - protected $app; - /** @var Command[] */ protected $commands = []; @@ -87,10 +84,8 @@ class Console */ protected static $startCallbacks = []; - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; - $this->initialize(); $this->definition = $this->getDefaultInputDefinition(); @@ -104,7 +99,7 @@ class Console /** * 初始化 */ - protected function initialize() + protected function initialize():void { if (!$this->app->initialized()) { $this->app->initialize(); @@ -115,7 +110,7 @@ class Console /** * 构造request */ - protected function makeRequest() + protected function makeRequest():void { $url = $this->app->config->get('app.url', 'http://localhost'); @@ -401,7 +396,7 @@ class Console * @param string $name 指令名 留空则自动获取 * @return Command|void */ - public function addCommand($command, string $name = '') + public function addCommand(string|Command $command, string $name = '') { if ($name) { $this->commands[$name] = $command; @@ -422,7 +417,7 @@ class Console $command->setApp($this->app); if (null === $command->getDefinition()) { - throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command))); + throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', $command::class)); } $this->commands[$command->getName()] = $command; @@ -717,7 +712,7 @@ class Console * @param array|\Traversable $collection * @return array */ - private function findAlternatives(string $name, $collection): array + private function findAlternatives(string $name, array|\Traversable $collection): array { $threshold = 1e3; $alternatives = []; @@ -738,7 +733,7 @@ class Console } $lev = levenshtein($subname, $parts[$i]); - if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) { + if ($lev <= strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) { $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; } elseif ($exists) { $alternatives[$collectionName] += $threshold; @@ -748,7 +743,7 @@ class Console foreach ($collection as $item) { $lev = levenshtein($name, $item); - if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { + if ($lev <= strlen($name) / 3 || str_contains($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } diff --git a/vendor/topthink/framework/src/think/Container.php b/vendor/topthink/framework/src/think/Container.php index f286c73..e6a365e 100644 --- a/vendor/topthink/framework/src/think/Container.php +++ b/vendor/topthink/framework/src/think/Container.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -21,6 +21,7 @@ use IteratorAggregate; use Psr\Container\ContainerInterface; use ReflectionClass; use ReflectionException; +use ReflectionNamedType; use ReflectionFunction; use ReflectionFunctionAbstract; use ReflectionMethod; @@ -94,7 +95,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param Closure|null $callback * @return void */ - public function resolving($abstract, Closure $callback = null): void + public function resolving(string|Closure $abstract, Closure $callback = null): void { if ($abstract instanceof Closure) { $this->invokeCallback['*'][] = $abstract; @@ -125,7 +126,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param string|class-string $abstract 类名或者标识 * @return T|object */ - public function get($abstract) + public function get(string $abstract) { if ($this->has($abstract)) { return $this->make($abstract); @@ -141,7 +142,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param mixed $concrete 要绑定的类、闭包或者实例 * @return $this */ - public function bind($abstract, $concrete = null) + public function bind(string|array $abstract, $concrete = null) { if (is_array($abstract)) { foreach ($abstract as $key => $val) { @@ -212,7 +213,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param string $name 类名或者标识 * @return bool */ - public function has($name): bool + public function has(string $name): bool { return $this->bound($name); } @@ -265,7 +266,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param string $name 类名或者标识 * @return void */ - public function delete($name) + public function delete(string $name) { $name = $this->getAlias($name); @@ -281,7 +282,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C * @param array $vars 参数 * @return mixed */ - public function invokeFunction($function, array $vars = []) + public function invokeFunction(string|Closure $function, array $vars = []) { try { $reflect = new ReflectionFunction($function); @@ -316,7 +317,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C try { $reflect = new ReflectionMethod($class, $method); } catch (ReflectionException $e) { - $class = is_object($class) ? get_class($class) : $class; + $class = is_object($class) ? $class::class : $class; throw new FuncNotFoundException('method not exists: ' . $class . '::' . $method . '()', "{$class}::{$method}", $e); } @@ -356,7 +357,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C { if ($callable instanceof Closure) { return $this->invokeFunction($callable, $vars); - } elseif (is_string($callable) && false === strpos($callable, '::')) { + } elseif (is_string($callable) && !str_contains($callable, '::')) { return $this->invokeFunction($callable, $vars); } else { return $this->invokeMethod($callable, $vars, $accessible); @@ -447,7 +448,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C if ($param->isVariadic()) { return array_merge($args, array_values($vars)); - } elseif ($reflectionType && $reflectionType instanceof \ReflectionNamedType && $reflectionType->isBuiltin() === false) { + } elseif ($reflectionType && $reflectionType instanceof ReflectionNamedType && $reflectionType->isBuiltin() === false) { $args[] = $this->getObjectParam($reflectionType->getName(), $vars); } elseif (1 == $type && !empty($vars)) { $args[] = array_shift($vars); @@ -476,7 +477,7 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C */ public static function factory(string $name, string $namespace = '', ...$args) { - $class = false !== strpos($name, '\\') ? $name : $namespace . ucwords($name); + $class = str_contains($name, '\\') ? $name : $namespace . ucwords($name); return Container::getInstance()->invokeClass($class, $args); } @@ -523,26 +524,22 @@ class Container implements ContainerInterface, ArrayAccess, IteratorAggregate, C $this->delete($name); } - #[\ReturnTypeWillChange] - public function offsetExists($key): bool + public function offsetExists(mixed $key): bool { return $this->exists($key); } - #[\ReturnTypeWillChange] - public function offsetGet($key) + public function offsetGet(mixed $key): mixed { return $this->make($key); } - #[\ReturnTypeWillChange] - public function offsetSet($key, $value) + public function offsetSet(mixed $key, mixed $value): void { $this->bind($key, $value); } - #[\ReturnTypeWillChange] - public function offsetUnset($key) + public function offsetUnset(mixed $key): void { $this->delete($key); } diff --git a/vendor/topthink/framework/src/think/Cookie.php b/vendor/topthink/framework/src/think/Cookie.php index 04774a6..41eeac3 100644 --- a/vendor/topthink/framework/src/think/Cookie.php +++ b/vendor/topthink/framework/src/think/Cookie.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -45,19 +45,12 @@ class Cookie */ protected $cookie = []; - /** - * 当前Request对象 - * @var Request - */ - protected $request; - /** * 构造方法 * @access public */ - public function __construct(Request $request, array $config = []) + public function __construct(protected Request $request, array $config = []) { - $this->request = $request; $this->config = array_merge($this->config, array_change_key_case($config)); } @@ -215,18 +208,13 @@ class Cookie */ protected function saveCookie(string $name, string $value, int $expire, string $path, string $domain, bool $secure, bool $httponly, string $samesite): void { - if (version_compare(PHP_VERSION, '7.3.0', '>=')) { - setcookie($name, $value, [ - 'expires' => $expire, - 'path' => $path, - 'domain' => $domain, - 'secure' => $secure, - 'httponly' => $httponly, - 'samesite' => $samesite, - ]); - } else { - setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); - } + setcookie($name, $value, [ + 'expires' => $expire, + 'path' => $path, + 'domain' => $domain, + 'secure' => $secure, + 'httponly' => $httponly, + 'samesite' => $samesite, + ]); } - } diff --git a/vendor/topthink/framework/src/think/Db.php b/vendor/topthink/framework/src/think/Db.php index 0048874..809e04f 100644 --- a/vendor/topthink/framework/src/think/Db.php +++ b/vendor/topthink/framework/src/think/Db.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -46,7 +46,7 @@ class Db extends DbManager * @access public * @return void */ - protected function modelMaker() + protected function modelMaker(): void { } diff --git a/vendor/topthink/framework/src/think/Env.php b/vendor/topthink/framework/src/think/Env.php index 9e1b7f4..f1772ea 100644 --- a/vendor/topthink/framework/src/think/Env.php +++ b/vendor/topthink/framework/src/think/Env.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -89,10 +89,8 @@ class Env implements ArrayAccess return $default; } - if ('false' === $result) { - $result = false; - } elseif ('true' === $result) { - $result = true; + if (isset($this->convert[$result])) { + $result = $this->convert[$result]; } if (!isset($this->data[$name])) { @@ -175,26 +173,22 @@ class Env implements ArrayAccess } // ArrayAccess - #[\ReturnTypeWillChange] - public function offsetSet($name, $value): void + public function offsetSet(mixed $name, mixed $value): void { $this->set($name, $value); } - #[\ReturnTypeWillChange] - public function offsetExists($name): bool + public function offsetExists(mixed $name): bool { return $this->__isset($name); } - #[\ReturnTypeWillChange] - public function offsetUnset($name): void + public function offsetUnset(mixed $name): void { throw new Exception('not support: unset'); } - #[\ReturnTypeWillChange] - public function offsetGet($name) + public function offsetGet(mixed $name): mixed { return $this->get($name); } diff --git a/vendor/topthink/framework/src/think/Event.php b/vendor/topthink/framework/src/think/Event.php index 3c70aad..c806cf7 100644 --- a/vendor/topthink/framework/src/think/Event.php +++ b/vendor/topthink/framework/src/think/Event.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -187,7 +187,7 @@ class Event foreach ($methods as $method) { $name = $method->getName(); - if (0 === strpos($name, 'on')) { + if (str_starts_with($name, 'on')) { $this->listen($prefix . substr($name, 2), [$observer, $name]); } } @@ -207,7 +207,7 @@ class Event { if (is_object($event)) { $params = $event; - $event = get_class($event); + $event = $event::class; } if (isset($this->bind[$event])) { @@ -217,7 +217,7 @@ class Event $result = []; $listeners = $this->listener[$event] ?? []; - if (strpos($event, '.')) { + if (str_contains($event, '.')) { [$prefix, $event] = explode('.', $event, 2); if (isset($this->listener[$prefix . '.*'])) { $listeners = array_merge($listeners, $this->listener[$prefix . '.*']); @@ -259,7 +259,7 @@ class Event { if (!is_string($event)) { $call = $event; - } elseif (strpos($event, '::')) { + } elseif (str_contains($event, '::')) { $call = $event; } else { $obj = $this->app->make($event); @@ -268,5 +268,4 @@ class Event return $this->app->invoke($call, [$params]); } - } diff --git a/vendor/topthink/framework/src/think/Exception.php b/vendor/topthink/framework/src/think/Exception.php index 5cf7954..4eb6d5c 100644 --- a/vendor/topthink/framework/src/think/Exception.php +++ b/vendor/topthink/framework/src/think/Exception.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: 麦当苗儿 // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -52,9 +52,8 @@ class Exception extends \Exception * @access public * @return array 由setData设置的Debug数据 */ - final public function getData() + final public function getData(): array { return $this->data; } - } diff --git a/vendor/topthink/framework/src/think/Facade.php b/vendor/topthink/framework/src/think/Facade.php index 9a0e333..51378da 100644 --- a/vendor/topthink/framework/src/think/Facade.php +++ b/vendor/topthink/framework/src/think/Facade.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -53,7 +53,8 @@ class Facade * @return string */ protected static function getFacadeClass() - {} + { + } /** * 带参数实例化当前Facade类 diff --git a/vendor/topthink/framework/src/think/File.php b/vendor/topthink/framework/src/think/File.php index 59230b5..bc67971 100644 --- a/vendor/topthink/framework/src/think/File.php +++ b/vendor/topthink/framework/src/think/File.php @@ -2,17 +2,18 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; use SplFileInfo; +use Closure; use think\exception\FileException; /** @@ -174,27 +175,20 @@ class File extends SplFileInfo /** * 自动生成文件名 * @access public - * @param string|\Closure $rule + * @param string|Closure|null $rule * @return string */ - public function hashName($rule = ''): string + public function hashName(string|Closure|null $rule = null): string { if (!$this->hashName) { - if ($rule instanceof \Closure) { + if ($rule instanceof Closure) { $this->hashName = call_user_func_array($rule, [$this]); } else { - switch (true) { - case in_array($rule, hash_algos()): - $hash = $this->hash($rule); - $this->hashName = substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2); - break; - case is_callable($rule): - $this->hashName = call_user_func($rule); - break; - default: - $this->hashName = date('Ymd') . DIRECTORY_SEPARATOR . md5(microtime(true) . $this->getPathname()); - break; - } + $this->hashName = match (true) { + in_array($rule, hash_algos()) && $hash = $this->hash($rule) => substr($hash, 0, 2) . DIRECTORY_SEPARATOR . substr($hash, 2), + is_callable($rule) => call_user_func($rule), + default => date('Ymd') . DIRECTORY_SEPARATOR . md5(microtime(true) . $this->getPathname()), + }; } } diff --git a/vendor/topthink/framework/src/think/Filesystem.php b/vendor/topthink/framework/src/think/Filesystem.php deleted file mode 100644 index 0aee929..0000000 --- a/vendor/topthink/framework/src/think/Filesystem.php +++ /dev/null @@ -1,89 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think; - -use InvalidArgumentException; -use think\filesystem\Driver; -use think\filesystem\driver\Local; -use think\helper\Arr; - -/** - * Class Filesystem - * @package think - * @mixin Driver - * @mixin Local - */ -class Filesystem extends Manager -{ - protected $namespace = '\\think\\filesystem\\driver\\'; - - /** - * @param null|string $name - * @return Driver - */ - public function disk(string $name = null): Driver - { - return $this->driver($name); - } - - protected function resolveType(string $name) - { - return $this->getDiskConfig($name, 'type', 'local'); - } - - protected function resolveConfig(string $name) - { - return $this->getDiskConfig($name); - } - - /** - * 获取缓存配置 - * @access public - * @param null|string $name 名称 - * @param mixed $default 默认值 - * @return mixed - */ - public function getConfig(string $name = null, $default = null) - { - if (!is_null($name)) { - return $this->app->config->get('filesystem.' . $name, $default); - } - - return $this->app->config->get('filesystem'); - } - - /** - * 获取磁盘配置 - * @param string $disk - * @param null $name - * @param null $default - * @return array - */ - public function getDiskConfig($disk, $name = null, $default = null) - { - if ($config = $this->getConfig("disks.{$disk}")) { - return Arr::get($config, $name, $default); - } - - throw new InvalidArgumentException("Disk [$disk] not found."); - } - - /** - * 默认驱动 - * @return string|null - */ - public function getDefaultDriver() - { - return $this->getConfig('default'); - } -} diff --git a/vendor/topthink/framework/src/think/Http.php b/vendor/topthink/framework/src/think/Http.php index 4e49c88..157078c 100644 --- a/vendor/topthink/framework/src/think/Http.php +++ b/vendor/topthink/framework/src/think/Http.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -24,12 +24,6 @@ use Throwable; */ class Http { - - /** - * @var App - */ - protected $app; - /** * 应用名称 * @var string @@ -54,10 +48,8 @@ class Http */ protected $isBind = false; - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; - $this->routePath = $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR; } @@ -91,7 +83,7 @@ class Http */ public function path(string $path) { - if (substr($path, -1) != DIRECTORY_SEPARATOR) { + if (str_ends_with($path, DIRECTORY_SEPARATOR)) { $path .= DIRECTORY_SEPARATOR; } @@ -284,5 +276,4 @@ class Http // 写入日志 $this->app->log->save(); } - } diff --git a/vendor/topthink/framework/src/think/Lang.php b/vendor/topthink/framework/src/think/Lang.php index b891084..d62c986 100644 --- a/vendor/topthink/framework/src/think/Lang.php +++ b/vendor/topthink/framework/src/think/Lang.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -186,33 +186,15 @@ class Lang */ protected function parse(string $file): array { - $type = pathinfo($file, PATHINFO_EXTENSION); + $type = pathinfo($file, PATHINFO_EXTENSION); + $result = match ($type) { + 'php' => include $file, + 'yml','yaml'=> function_exists('yaml_parse_file') ? yaml_parse_file($file) : [], + 'json' => json_decode(file_get_contents($file), true), + default => [], + }; - switch ($type) { - case 'php': - $result = include $file; - break; - case 'yml': - case 'yaml': - if (function_exists('yaml_parse_file')) { - $result = yaml_parse_file($file); - } - break; - case 'json': - $data = file_get_contents($file); - - if (false !== $data) { - $data = json_decode($data, true); - - if (json_last_error() === JSON_ERROR_NONE) { - $result = $data; - } - } - - break; - } - - return isset($result) && is_array($result) ? $result : []; + return is_array($result) ? $result : []; } /** @@ -226,7 +208,7 @@ class Lang { $range = $range ?: $this->range; - if ($this->config['allow_group'] && strpos($name, '.')) { + if ($this->config['allow_group'] && str_contains($name, '.')) { [$name1, $name2] = explode('.', $name, 2); return isset($this->lang[$range][strtolower($name1)][$name2]); } @@ -255,7 +237,7 @@ class Lang return $this->lang[$range] ?? []; } - if ($this->config['allow_group'] && strpos($name, '.')) { + if ($this->config['allow_group'] && str_contains($name, '.')) { [$name1, $name2] = explode('.', $name, 2); $value = $this->lang[$range][strtolower($name1)][$name2] ?? $name; @@ -286,5 +268,4 @@ class Lang return $value; } - } diff --git a/vendor/topthink/framework/src/think/Log.php b/vendor/topthink/framework/src/think/Log.php index c31210c..d8dec64 100644 --- a/vendor/topthink/framework/src/think/Log.php +++ b/vendor/topthink/framework/src/think/Log.php @@ -2,18 +2,20 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; use InvalidArgumentException; use Psr\Log\LoggerInterface; +use Psr\Log\LoggerTrait; +use Stringable; use think\event\LogWrite; use think\helper\Arr; use think\log\Channel; @@ -26,15 +28,16 @@ use think\log\ChannelSet; */ class Log extends Manager implements LoggerInterface { + use LoggerTrait; const EMERGENCY = 'emergency'; - const ALERT = 'alert'; - const CRITICAL = 'critical'; - const ERROR = 'error'; - const WARNING = 'warning'; - const NOTICE = 'notice'; - const INFO = 'info'; - const DEBUG = 'debug'; - const SQL = 'sql'; + const ALERT = 'alert'; + const CRITICAL = 'critical'; + const ERROR = 'error'; + const WARNING = 'warning'; + const NOTICE = 'notice'; + const INFO = 'info'; + const DEBUG = 'debug'; + const SQL = 'sql'; protected $namespace = '\\think\\log\\driver\\'; @@ -42,7 +45,7 @@ class Log extends Manager implements LoggerInterface * 默认驱动 * @return string|null */ - public function getDefaultDriver() + public function getDefaultDriver(): ?string { return $this->getConfig('default'); } @@ -66,11 +69,11 @@ class Log extends Manager implements LoggerInterface /** * 获取渠道配置 * @param string $channel - * @param null $name - * @param null $default + * @param string $name + * @param mixed $default * @return array */ - public function getChannelConfig($channel, $name = null, $default = null) + public function getChannelConfig(string $channel, string $name = null, $default = null) { if ($config = $this->getConfig("channels.{$channel}")) { return Arr::get($config, $name, $default); @@ -84,7 +87,7 @@ class Log extends Manager implements LoggerInterface * @param string|array $name 渠道名 * @return Channel|ChannelSet */ - public function channel($name = null) + public function channel(string|array $name = null) { if (is_array($name)) { return new ChannelSet($this, $name); @@ -102,7 +105,7 @@ class Log extends Manager implements LoggerInterface { $driver = parent::createDriver($name); - $lazy = !$this->getChannelConfig($name, "realtime_write", false) && !$this->app->runningInConsole(); + $lazy = !$this->getChannelConfig($name, "realtime_write", false) && !$this->app->runningInConsole(); $allow = array_merge($this->getConfig("level", []), $this->getChannelConfig($name, "level", [])); return new Channel($name, $driver, $allow, $lazy, $this->app->event); @@ -119,7 +122,7 @@ class Log extends Manager implements LoggerInterface * @param string|array $channel 日志通道名 * @return $this */ - public function clear($channel = '*') + public function clear(string|array $channel = '*') { if ('*' == $channel) { $channel = array_keys($this->drivers); @@ -136,7 +139,7 @@ class Log extends Manager implements LoggerInterface * @param string|array $channel 日志通道名 * @return $this */ - public function close($channel = '*') + public function close(string|array $channel = '*') { if ('*' == $channel) { $channel = array_keys($this->drivers); @@ -217,120 +220,24 @@ class Log extends Manager implements LoggerInterface /** * 记录日志信息 * @access public - * @param string $level 日志级别 - * @param mixed $message 日志信息 + * @param mixed $level 日志级别 + * @param string|Stringable $message 日志信息 * @param array $context 替换内容 * @return void */ - public function log($level, $message, array $context = []): void + public function log($level, string|Stringable $message, array $context = []): void { $this->record($message, $level, $context); } - /** - * 记录emergency信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function emergency($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录警报信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function alert($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录紧急情况 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function critical($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录错误信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function error($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录warning信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function warning($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录notice信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function notice($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录一般信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function info($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * 记录调试信息 - * @access public - * @param mixed $message 日志信息 - * @param array $context 替换内容 - * @return void - */ - public function debug($message, array $context = []): void - { - $this->log(__FUNCTION__, $message, $context); - } - /** * 记录sql信息 * @access public - * @param mixed $message 日志信息 + * @param string|Stringable $message 日志信息 * @param array $context 替换内容 * @return void */ - public function sql($message, array $context = []): void + public function sql(string|Stringable $message, array $context = []): void { $this->log(__FUNCTION__, $message, $context); } diff --git a/vendor/topthink/framework/src/think/Manager.php b/vendor/topthink/framework/src/think/Manager.php index ca3f6a5..93d3aed 100644 --- a/vendor/topthink/framework/src/think/Manager.php +++ b/vendor/topthink/framework/src/think/Manager.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -17,9 +17,6 @@ use think\helper\Str; abstract class Manager { - /** @var App */ - protected $app; - /** * 驱动 * @var array @@ -32,9 +29,8 @@ abstract class Manager */ protected $namespace = null; - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; } /** @@ -93,8 +89,8 @@ abstract class Manager */ protected function resolveClass(string $type): string { - if ($this->namespace || false !== strpos($type, '\\')) { - $class = false !== strpos($type, '\\') ? $type : $this->namespace . Str::studly($type); + if ($this->namespace || str_contains($type, '\\')) { + $class = str_contains($type, '\\') ? $type : $this->namespace . Str::studly($type); if (class_exists($class)) { return $class; diff --git a/vendor/topthink/framework/src/think/Middleware.php b/vendor/topthink/framework/src/think/Middleware.php index a3db0f2..6c12976 100644 --- a/vendor/topthink/framework/src/think/Middleware.php +++ b/vendor/topthink/framework/src/think/Middleware.php @@ -2,18 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: Slince // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; use Closure; -use InvalidArgumentException; use LogicException; use think\exception\Handle; use Throwable; @@ -30,15 +29,8 @@ class Middleware */ protected $queue = []; - /** - * 应用对象 - * @var App - */ - protected $app; - - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; } /** @@ -62,7 +54,7 @@ class Middleware * @param string $type 中间件类型 * @return void */ - public function add($middleware, string $type = 'global'): void + public function add(array|string|Closure $middleware, string $type = 'global'): void { $middleware = $this->buildMiddleware($middleware, $type); @@ -78,7 +70,7 @@ class Middleware * @param mixed $middleware * @return void */ - public function route($middleware): void + public function route(array|string|Closure $middleware): void { $this->add($middleware, 'route'); } @@ -89,7 +81,7 @@ class Middleware * @param mixed $middleware * @return void */ - public function controller($middleware): void + public function controller(array|string|Closure $middleware): void { $this->add($middleware, 'controller'); } @@ -100,7 +92,7 @@ class Middleware * @param mixed $middleware * @param string $type 中间件类型 */ - public function unshift($middleware, string $type = 'global') + public function unshift(array|string|Closure $middleware, string $type = 'global') { $middleware = $this->buildMiddleware($middleware, $type); @@ -188,11 +180,11 @@ class Middleware /** * 解析中间件 * @access protected - * @param mixed $middleware + * @param array|string|Closure $middleware * @param string $type 中间件类型 * @return array */ - protected function buildMiddleware($middleware, string $type): array + protected function buildMiddleware(array|string|Closure $middleware, string $type): array { if (is_array($middleware)) { [$middleware, $params] = $middleware; @@ -202,10 +194,6 @@ class Middleware return [$middleware, $params ?? []]; } - if (!is_string($middleware)) { - throw new InvalidArgumentException('The middleware is invalid'); - } - //中间件别名检查 $alias = $this->app->config->get('middleware.alias', []); @@ -253,5 +241,4 @@ class Middleware } return -1; } - } diff --git a/vendor/topthink/framework/src/think/Pipeline.php b/vendor/topthink/framework/src/think/Pipeline.php index 77151f3..d20f413 100644 --- a/vendor/topthink/framework/src/think/Pipeline.php +++ b/vendor/topthink/framework/src/think/Pipeline.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -103,5 +103,4 @@ class Pipeline } throw $e; } - } diff --git a/vendor/topthink/framework/src/think/Request.php b/vendor/topthink/framework/src/think/Request.php index 99f4f80..5d9f154 100644 --- a/vendor/topthink/framework/src/think/Request.php +++ b/vendor/topthink/framework/src/think/Request.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -315,7 +315,7 @@ class Request implements ArrayAccess $header = []; $server = $_SERVER; foreach ($server as $key => $val) { - if (0 === strpos($key, 'HTTP_')) { + if (str_starts_with($key, 'HTTP_')) { $key = str_replace('_', '-', strtolower(substr($key, 5))); $header[$key] = $val; } @@ -500,7 +500,7 @@ class Request implements ArrayAccess { if (!$this->baseUrl) { $str = $this->url(); - $this->baseUrl = strpos($str, '?') ? strstr($str, '?', true) : $str; + $this->baseUrl = str_contains($str, '?') ? strstr($str, '?', true) : $str; } return $complete ? $this->domain() . $this->baseUrl : $this->baseUrl; @@ -526,7 +526,7 @@ class Request implements ArrayAccess $url = $this->server('ORIG_SCRIPT_NAME'); } elseif (($pos = strpos($this->server('PHP_SELF'), '/' . $script_name)) !== false) { $url = substr($this->server('SCRIPT_NAME'), 0, $pos) . '/' . $script_name; - } elseif ($this->server('DOCUMENT_ROOT') && strpos($this->server('SCRIPT_FILENAME'), $this->server('DOCUMENT_ROOT')) === 0) { + } elseif ($this->server('DOCUMENT_ROOT') && str_starts_with($this->server('SCRIPT_FILENAME'), $this->server('DOCUMENT_ROOT'))) { $url = str_replace('\\', '/', str_replace($this->server('DOCUMENT_ROOT'), '', $this->server('SCRIPT_FILENAME'))); } } @@ -558,7 +558,7 @@ class Request implements ArrayAccess { if (!$this->root) { $file = $this->baseFile(); - if ($file && 0 !== strpos($this->url(), $file)) { + if ($file && !str_starts_with($this->url(), $file)) { $file = str_replace('\\', '/', dirname($file)); } $this->root = rtrim($file, '/'); @@ -575,7 +575,7 @@ class Request implements ArrayAccess public function rootUrl(): string { $base = $this->root(); - $root = strpos($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base; + $root = str_contains($base, '.') ? ltrim(dirname($base), DIRECTORY_SEPARATOR) : $base; if ('' != $root) { $root = '/' . ltrim($root, '/'); @@ -611,16 +611,16 @@ class Request implements ArrayAccess unset($this->get[$this->varPathinfo]); } elseif ($this->server('PATH_INFO')) { $pathinfo = $this->server('PATH_INFO'); - } elseif (false !== strpos(PHP_SAPI, 'cli')) { - $pathinfo = strpos($this->server('REQUEST_URI'), '?') ? strstr($this->server('REQUEST_URI'), '?', true) : $this->server('REQUEST_URI'); + } elseif (str_contains(PHP_SAPI, 'cli')) { + $pathinfo = str_contains($this->server('REQUEST_URI'), '?') ? strstr($this->server('REQUEST_URI'), '?', true) : $this->server('REQUEST_URI'); } // 分析PATHINFO信息 if (!isset($pathinfo)) { foreach ($this->pathinfoFetch as $type) { if ($this->server($type)) { - $pathinfo = (0 === strpos($this->server($type), $this->server('SCRIPT_NAME'))) ? - substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type); + $pathinfo = str_starts_with($this->server($type), $this->server('SCRIPT_NAME')) ? + substr($this->server($type), strlen($this->server('SCRIPT_NAME'))) : $this->server($type); break; } } @@ -828,7 +828,7 @@ class Request implements ArrayAccess */ public function isCgi(): bool { - return strpos(PHP_SAPI, 'cgi') === 0; + return str_starts_with(PHP_SAPI, 'cgi'); } /** @@ -845,18 +845,11 @@ class Request implements ArrayAccess $method = $this->method(true); // 自动获取请求变量 - switch ($method) { - case 'POST': - $vars = $this->post(false); - break; - case 'PUT': - case 'DELETE': - case 'PATCH': - $vars = $this->put(false); - break; - default: - $vars = []; - } + $vars = match ($method) { + 'POST' => $this->post(false), + 'PUT','DELETE','PATCH' => $this->put(false), + default => [], + }; // 当前请求参数和URL地址中的参数合并 $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false)); @@ -878,7 +871,7 @@ class Request implements ArrayAccess * @param string|array $filter 过滤方法 * @return mixed */ - public function all($name = '', $filter = '') + public function all(string|array $name = '', string|array $filter = '') { $data = array_merge($this->param(), $this->file() ?: []); @@ -929,12 +922,12 @@ class Request implements ArrayAccess /** * 获取路由参数 * @access public - * @param string|array $name 变量名 + * @param string|array|bool $name 变量名 * @param mixed $default 默认值 * @param string|array $filter 过滤方法 * @return mixed */ - public function route($name = '', $default = null, $filter = '') + public function route(string|array|bool $name = '', $default = null, string|array $filter = '') { if (is_array($name)) { return $this->only($name, $this->route, $filter); @@ -946,12 +939,12 @@ class Request implements ArrayAccess /** * 获取GET参数 * @access public - * @param string|array $name 变量名 + * @param string|array|bool $name 变量名 * @param mixed $default 默认值 * @param string|array $filter 过滤方法 * @return mixed */ - public function get($name = '', $default = null, $filter = '') + public function get(string|array|bool $name = '', $default = null, string|array $filter = '') { if (is_array($name)) { return $this->only($name, $this->get, $filter); @@ -963,11 +956,11 @@ class Request implements ArrayAccess /** * 获取中间件传递的参数 * @access public - * @param mixed $name 变量名 + * @param string $name 变量名 * @param mixed $default 默认值 * @return mixed */ - public function middleware($name, $default = null) + public function middleware(string $name, $default = null) { return $this->middleware[$name] ?? $default; } @@ -975,12 +968,12 @@ class Request implements ArrayAccess /** * 获取POST参数 * @access public - * @param string|array $name 变量名 + * @param bool|string|array $name 变量名 * @param mixed $default 默认值 * @param string|array $filter 过滤方法 * @return mixed */ - public function post($name = '', $default = null, $filter = '') + public function post(string|array|bool $name = '', $default = null, string|array $filter = '') { if (is_array($name)) { return $this->only($name, $this->post, $filter); @@ -992,12 +985,12 @@ class Request implements ArrayAccess /** * 获取PUT参数 * @access public - * @param string|array $name 变量名 + * @param string|array|bool $name 变量名 * @param mixed $default 默认值 * @param string|array $filter 过滤方法 * @return mixed */ - public function put($name = '', $default = null, $filter = '') + public function put(string|array|bool $name = '', $default = null, string|array $filter = '') { if (is_array($name)) { return $this->only($name, $this->put, $filter); @@ -1006,13 +999,13 @@ class Request implements ArrayAccess return $this->input($this->put, $name, $default, $filter); } - protected function getInputData($content): array + protected function getInputData(string $content): array { $contentType = $this->contentType(); if ('application/x-www-form-urlencoded' == $contentType) { parse_str($content, $data); return $data; - } elseif (false !== strpos($contentType, 'json')) { + } elseif (str_contains($contentType, 'json')) { return (array) json_decode($content, true); } @@ -1027,7 +1020,7 @@ class Request implements ArrayAccess * @param string|array $filter 过滤方法 * @return mixed */ - public function delete($name = '', $default = null, $filter = '') + public function delete(string|array|bool $name = '', $default = null, string|array $filter = '') { return $this->put($name, $default, $filter); } @@ -1040,7 +1033,7 @@ class Request implements ArrayAccess * @param string|array $filter 过滤方法 * @return mixed */ - public function patch($name = '', $default = null, $filter = '') + public function patch(string|array|bool $name = '', $default = null, string|array $filter = '') { return $this->put($name, $default, $filter); } @@ -1053,7 +1046,7 @@ class Request implements ArrayAccess * @param string|array $filter 过滤方法 * @return mixed */ - public function request($name = '', $default = null, $filter = '') + public function request(string|array|bool $name = '', $default = null, string|array $filter = '') { if (is_array($name)) { return $this->only($name, $this->request, $filter); @@ -1073,11 +1066,8 @@ class Request implements ArrayAccess { if (empty($name)) { return $this->env->get(); - } else { - $name = strtoupper($name); } - - return $this->env->get($name, $default); + return $this->env->get(strtoupper($name), $default); } /** @@ -1134,11 +1124,8 @@ class Request implements ArrayAccess { if (empty($name)) { return $this->server; - } else { - $name = strtoupper($name); } - - return $this->server[$name] ?? $default; + return $this->server[strtoupper($name)] ?? $default; } /** @@ -1151,7 +1138,7 @@ class Request implements ArrayAccess { $files = $this->file; if (!empty($files)) { - if (strpos($name, '.')) { + if (str_contains($name, '.')) { [$name, $sub] = explode('.', $name); } @@ -1246,7 +1233,6 @@ class Request implements ArrayAccess } $name = str_replace('_', '-', strtolower($name)); - return $this->header[$name] ?? $default; } @@ -1259,7 +1245,7 @@ class Request implements ArrayAccess * @param string|array $filter 过滤函数 * @return mixed */ - public function input(array $data = [], $name = '', $default = null, $filter = '') + public function input(array $data = [], string|bool $name = '', $default = null, string|array $filter = '') { if (false === $name) { // 获取原始数据 @@ -1269,7 +1255,7 @@ class Request implements ArrayAccess $name = (string) $name; if ('' != $name) { // 解析name - if (strpos($name, '/')) { + if (str_contains($name, '/')) { [$name, $type] = explode('/', $name); } @@ -1317,31 +1303,15 @@ class Request implements ArrayAccess */ protected function typeCast(&$data, string $type) { - switch (strtolower($type)) { - // 数组 - case 'a': - $data = (array) $data; - break; - // 数字 - case 'd': - $data = (int) $data; - break; - // 浮点 - case 'f': - $data = (float) $data; - break; - // 布尔 - case 'b': - $data = (boolean) $data; - break; - // 字符串 - case 's': - if (is_scalar($data)) { - $data = (string) $data; - } else { - throw new \InvalidArgumentException('variable type error:' . gettype($data)); - } - break; + $type = strtolower($type); + if (in_array($type, ['a', 'b', 'd', 'f', 's'])) { + $data = match ($type) { + 'a' => (array) $data, // 数组 + 'b' => (bool) $data, // 布尔 + 'd' => (int) $data, // 数字 + 'f' => (float) $data, // 浮点 + 's' => is_scalar($data) ? (string) $data : throw new \InvalidArgumentException('variable type error:' . gettype($data)), //字符串 + }; } } @@ -1389,7 +1359,7 @@ class Request implements ArrayAccess $filter = []; } else { $filter = $filter ?: $this->filter; - if (is_string($filter) && false === strpos($filter, '/')) { + if (is_string($filter) && !str_contains($filter, '/')) { $filter = explode(',', $filter); } else { $filter = (array) $filter; @@ -1422,7 +1392,7 @@ class Request implements ArrayAccess $value = call_user_func($filter, $value); } elseif (is_scalar($value)) { - if (is_string($filter) && false !== strpos($filter, '/')) { + if (is_string($filter) && str_contains($filter, '/')) { // 正则过滤 if (!preg_match($filter, $value)) { // 匹配不成功返回默认值 @@ -1558,7 +1528,7 @@ class Request implements ArrayAccess { $acceptType = $this->type(); - return false !== strpos($acceptType, 'json'); + return str_contains($acceptType, 'json'); } /** @@ -1676,17 +1646,11 @@ class Request implements ArrayAccess */ public function isValidIP(string $ip, string $type = ''): bool { - switch (strtolower($type)) { - case 'ipv4': - $flag = FILTER_FLAG_IPV4; - break; - case 'ipv6': - $flag = FILTER_FLAG_IPV6; - break; - default: - $flag = 0; - break; - } + $flag = match (strtolower($type)) { + 'ipv4' => FILTER_FLAG_IPV4, + 'ipv6' => FILTER_FLAG_IPV6, + default => 0, + }; return boolval(filter_var($ip, FILTER_VALIDATE_IP, $flag)); } @@ -1726,7 +1690,7 @@ class Request implements ArrayAccess { if ($this->server('HTTP_VIA') && stristr($this->server('HTTP_VIA'), "wap")) { return true; - } elseif ($this->server('HTTP_ACCEPT') && strpos(strtoupper($this->server('HTTP_ACCEPT')), "VND.WAP.WML")) { + } elseif ($this->server('HTTP_ACCEPT') && str_contains(strtoupper($this->server('HTTP_ACCEPT')), "VND.WAP.WML")) { return true; } elseif ($this->server('HTTP_X_WAP_PROFILE') || $this->server('HTTP_PROFILE')) { return true; @@ -1784,7 +1748,7 @@ class Request implements ArrayAccess $host = strval($this->server('HTTP_X_FORWARDED_HOST') ?: $this->server('HTTP_HOST')); } - return true === $strict && strpos($host, ':') ? strstr($host, ':', true) : $host; + return true === $strict && str_contains($host, ':') ? strstr($host, ':', true) : $host; } /** @@ -1827,7 +1791,7 @@ class Request implements ArrayAccess $contentType = $this->header('Content-Type'); if ($contentType) { - if (strpos($contentType, ';')) { + if (str_contains($contentType, ';')) { [$type] = explode(';', $contentType); } else { $type = $contentType; @@ -2155,24 +2119,21 @@ class Request implements ArrayAccess } // ArrayAccess - #[\ReturnTypeWillChange] - public function offsetExists($name): bool + public function offsetExists(mixed $name): bool { return $this->has($name); } - #[\ReturnTypeWillChange] - public function offsetGet($name) + public function offsetGet(mixed $name): mixed { return $this->param($name); } - #[\ReturnTypeWillChange] - public function offsetSet($name, $value) - {} - - #[\ReturnTypeWillChange] - public function offsetUnset($name) - {} + public function offsetSet(mixed $name, mixed $value): void + { + } + public function offsetUnset(mixed $name): void + { + } } diff --git a/vendor/topthink/framework/src/think/Response.php b/vendor/topthink/framework/src/think/Response.php index 49f26dc..62bce6c 100644 --- a/vendor/topthink/framework/src/think/Response.php +++ b/vendor/topthink/framework/src/think/Response.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -102,7 +102,7 @@ abstract class Response */ public static function create($data = '', string $type = 'html', int $code = 200): Response { - $class = false !== strpos($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); + $class = str_contains($type, '\\') ? $type : '\\think\\response\\' . ucfirst(strtolower($type)); return Container::getInstance()->invokeClass($class, [$data, $code]); } @@ -260,10 +260,11 @@ abstract class Response */ public function content($content) { - if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ - $content, - '__toString', - ]) + if ( + null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) ) { throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); } @@ -387,10 +388,11 @@ abstract class Response if (null == $this->content) { $content = $this->output($this->data); - if (null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ - $content, - '__toString', - ]) + if ( + null !== $content && !is_string($content) && !is_numeric($content) && !is_callable([ + $content, + '__toString', + ]) ) { throw new \InvalidArgumentException(sprintf('variable type error: %s', gettype($content))); } diff --git a/vendor/topthink/framework/src/think/Route.php b/vendor/topthink/framework/src/think/Route.php index 60eba4a..b891256 100644 --- a/vendor/topthink/framework/src/think/Route.php +++ b/vendor/topthink/framework/src/think/Route.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -57,6 +57,8 @@ class Route 'url_lazy_route' => false, // 是否强制使用路由 'url_route_must' => false, + // 是否区分大小写 + 'url_case_sensitive' => false, // 合并路由规则 'route_rule_merge' => false, // 路由是否完全匹配 @@ -85,12 +87,6 @@ class Route 'url_common_param' => true, ]; - /** - * 当前应用 - * @var App - */ - protected $app; - /** * 请求对象 * @var Request @@ -138,12 +134,6 @@ class Route */ protected $lazy = false; - /** - * 路由是否测试模式 - * @var bool - */ - protected $isTest = false; - /** * (分组)路由规则是否合并解析 * @var bool @@ -156,9 +146,8 @@ class Route */ protected $removeSlash = false; - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; $this->ruleName = new RuleName(); $this->setDefaultDomain(); @@ -187,7 +176,7 @@ class Route // 注册全局MISS路由 $this->miss(function () { return Response::create('', 'html', 204)->header(['Allow' => 'GET, POST, PUT, DELETE']); - }, 'options')->allowCrossDomain(); + }, 'options'); } public function config(string $name = null) @@ -211,27 +200,6 @@ class Route return $this; } - /** - * 设置路由为测试模式 - * @access public - * @param bool $test 路由是否测试模式 - * @return void - */ - public function setTestMode(bool $test): void - { - $this->isTest = $test; - } - - /** - * 检查路由是否为测试模式 - * @access public - * @return bool - */ - public function isTest(): bool - { - return $this->isTest; - } - /** * 设置路由域名及分组(包括资源路由)是否合并解析 * @access public @@ -317,7 +285,7 @@ class Route * @param mixed $rule 路由规则 * @return Domain */ - public function domain($name, $rule = null): Domain + public function domain(string|array $name, $rule = null): Domain { // 支持多个域名使用相同路由规则 $domainName = is_array($name) ? array_shift($name) : $name; @@ -399,14 +367,14 @@ class Route { if (is_null($domain)) { $domain = $this->host; - } elseif (false === strpos($domain, '.') && $this->request) { + } elseif (!str_contains($domain, '.') && $this->request) { $domain .= '.' . $this->request->rootDomain(); } if ($this->request) { $subDomain = $this->request->subDomain(); - if (strpos($subDomain, '.')) { + if (str_contains($subDomain, '.')) { $name = '*' . strstr($subDomain, '.'); } } @@ -518,12 +486,6 @@ class Route */ public function rule(string $rule, $route = null, string $method = '*'): RuleItem { - if ($route instanceof Response) { - // 兼容之前的路由到响应对象,感觉不需要,使用场景很少,闭包就能实现 - $route = function () use ($route) { - return $route; - }; - } return $this->group->addRule($rule, $route, $method); } @@ -547,11 +509,11 @@ class Route /** * 注册路由分组 * @access public - * @param string|\Closure $name 分组名称或者参数 + * @param string|Closure $name 分组名称或者参数 * @param mixed $route 分组路由 * @return RuleGroup */ - public function group($name, $route = null): RuleGroup + public function group(string|Closure $name, $route = null): RuleGroup { if ($name instanceof Closure) { $route = $name; @@ -726,7 +688,7 @@ class Route * @param array|bool $resource 资源 * @return $this */ - public function rest($name, $resource = []) + public function rest(string|array $name, array|bool $resource = []) { if (is_array($name)) { $this->rest = $resource ? $name : array_merge($this->rest, $name); @@ -759,7 +721,7 @@ class Route * @param string $method 请求类型 * @return RuleItem */ - public function miss($route, string $method = '*'): RuleItem + public function miss(string|Closure $route, string $method = '*'): RuleItem { return $this->group->miss($route, $method); } @@ -770,7 +732,7 @@ class Route * @param Closure|bool $withRoute * @return Response */ - public function dispatch(Request $request, $withRoute = true) + public function dispatch(Request $request, Closure|bool $withRoute = true) { $this->request = $request; $this->host = $this->request->host(true); diff --git a/vendor/topthink/framework/src/think/Service.php b/vendor/topthink/framework/src/think/Service.php index d9e8960..9d0559f 100644 --- a/vendor/topthink/framework/src/think/Service.php +++ b/vendor/topthink/framework/src/think/Service.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -22,11 +22,8 @@ use think\event\RouteLoaded; */ abstract class Service { - protected $app; - - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; } /** @@ -34,7 +31,7 @@ abstract class Service * @access protected * @param string $path 路由路径 */ - protected function loadRoutesFrom($path) + protected function loadRoutesFrom(string $path) { $this->registerRoutes(function () use ($path) { include $path; diff --git a/vendor/topthink/framework/src/think/Session.php b/vendor/topthink/framework/src/think/Session.php index 6c84faf..7faccb7 100644 --- a/vendor/topthink/framework/src/think/Session.php +++ b/vendor/topthink/framework/src/think/Session.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; diff --git a/vendor/topthink/framework/src/think/Validate.php b/vendor/topthink/framework/src/think/Validate.php index 0788406..ba66215 100644 --- a/vendor/topthink/framework/src/think/Validate.php +++ b/vendor/topthink/framework/src/think/Validate.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -65,6 +65,7 @@ class Validate 'number' => ':attribute must be numeric', 'integer' => ':attribute must be integer', 'float' => ':attribute must be float', + 'string' => ':attribute must be string', 'boolean' => ':attribute must be bool', 'email' => ':attribute not a valid email address', 'mobile' => ':attribute not a valid mobile', @@ -110,6 +111,9 @@ class Validate 'fileSize' => 'filesize not match', 'fileExt' => 'extensions to upload is not allowed', 'fileMime' => 'mimetype to upload is not allowed', + 'startWith' => ':attribute must start with :rule', + 'endWith' => ':attribute must end with :rule', + 'contain' => ':attribute must contain :rule', ]; /** @@ -126,10 +130,10 @@ class Validate 'alpha' => '/^[A-Za-z]+$/', 'alphaNum' => '/^[A-Za-z0-9]+$/', 'alphaDash' => '/^[A-Za-z0-9\-\_]+$/', - 'chs' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}]+$/u', - 'chsAlpha' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z]+$/u', - 'chsAlphaNum' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9]+$/u', - 'chsDash' => '/^[\x{4e00}-\x{9fa5}\x{9fa6}-\x{9fef}\x{3400}-\x{4db5}\x{20000}-\x{2ebe0}a-zA-Z0-9\_\-]+$/u', + 'chs' => '/^[\p{Han}]+$/u', + 'chsAlpha' => '/^[\p{Han}a-zA-Z]+$/u', + 'chsAlphaNum' => '/^[\p{Han}a-zA-Z0-9]+$/u', + 'chsDash' => '/^[\p{Han}a-zA-Z0-9\_\-]+$/u', 'mobile' => '/^1[3-9]\d{9}$/', 'idCard' => '/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/', 'zip' => '/\d{6}/', @@ -283,7 +287,7 @@ class Validate * @param mixed $rule 验证规则或者字段描述信息 * @return $this */ - public function rule($name, $rule = '') + public function rule(string|array $name, $rule = '') { if (is_array($name)) { $this->rule = $name + $this->rule; @@ -323,7 +327,7 @@ class Validate * @param string $msg 验证提示信息 * @return void */ - public function setTypeMsg($type, string $msg = null): void + public function setTypeMsg(string|array $type, string $msg = null): void { if (is_array($type)) { $this->typeMsg = array_merge($this->typeMsg, $type); @@ -416,7 +420,7 @@ class Validate * @param mixed $rule 验证规则 true 移除所有规则 * @return $this */ - public function remove($field, $rule = null) + public function remove(string|array $field, $rule = null) { if (is_array($field)) { foreach ($field as $key => $rule) { @@ -444,7 +448,7 @@ class Validate * @param mixed $rule 验证规则 * @return $this */ - public function append($field, $rule = null) + public function append(string|array $field, $rule = null) { if (is_array($field)) { foreach ($field as $key => $rule) { @@ -490,7 +494,7 @@ class Validate foreach ($rules as $key => $rule) { // field => 'rule1|rule2...' field => ['rule1','rule2',...] - if (strpos($key, '|')) { + if (str_contains($key, '|')) { // 字段|描述 用于指定属性名称 [$key, $title] = explode('|', $key); } else { @@ -631,7 +635,7 @@ class Validate if (isset($this->type[$type])) { $result = call_user_func_array($this->type[$type], [$value, $rule, $data, $field, $title]); - } elseif ('must' == $info || 0 === strpos($info, 'require') || (!is_null($value) && '' !== $value)) { + } elseif ('must' == $info || str_starts_with($info, 'require') || (!is_null($value) && '' !== $value)) { $result = call_user_func_array([$this, $type], [$value, $rule, $data, $field, $title]); } else { $result = true; @@ -642,7 +646,7 @@ class Validate // 验证失败 返回错误信息 if (!empty($msg[$i])) { $message = $msg[$i]; - if (is_string($message) && strpos($message, '{%') === 0) { + if (is_string($message) && str_starts_with($message, '{%')) { $message = $this->lang->get(substr($message, 2, -1)); } } else { @@ -652,10 +656,10 @@ class Validate return $message; } elseif (true !== $result) { // 返回自定义错误信息 - if (is_string($result) && false !== strpos($result, ':')) { + if (is_string($result) && str_contains($result, ':')) { $result = str_replace(':attribute', $title, $result); - if (strpos($result, ':rule') && is_scalar($rule)) { + if (str_contains($result, ':rule') && is_scalar($rule)) { $result = str_replace(':rule', (string) $rule, $result); } } @@ -686,7 +690,7 @@ class Validate return [$key, $rule, $key]; } - if (strpos($rule, ':')) { + if (str_contains($rule, ':')) { [$type, $rule] = explode(':', $rule, 2); if (isset($this->alias[$type])) { // 判断别名 @@ -717,7 +721,7 @@ class Validate public function confirm($value, $rule, array $data = [], string $field = ''): bool { if ('' == $rule) { - if (strpos($field, '_confirm')) { + if (str_contains($field, '_confirm')) { $rule = strstr($field, '_confirm', true); } else { $rule = $field . '_confirm'; @@ -826,65 +830,39 @@ class Validate */ public function is($value, string $rule, array $data = []): bool { - switch (Str::camel($rule)) { - case 'require': - // 必须 - $result = !empty($value) || '0' == $value; - break; - case 'accepted': - // 接受 - $result = in_array($value, ['1', 'on', 'yes']); - break; - case 'date': - // 是否是一个有效日期 - $result = false !== strtotime($value); - break; - case 'activeUrl': - // 是否为有效的网址 - $result = checkdnsrr($value); - break; - case 'boolean': - case 'bool': - // 是否为布尔值 - $result = in_array($value, [true, false, 0, 1, '0', '1'], true); - break; - case 'number': - $result = ctype_digit((string) $value); - break; - case 'alphaNum': - $result = ctype_alnum($value); - break; - case 'array': - // 是否为数组 - $result = is_array($value); - break; - case 'file': - $result = $value instanceof File; - break; - case 'image': - $result = $value instanceof File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6]); - break; - case 'token': - $result = $this->token($value, '__token__', $data); - break; - default: - if (isset($this->type[$rule])) { - // 注册的验证规则 - $result = call_user_func_array($this->type[$rule], [$value]); - } elseif (function_exists('ctype_' . $rule)) { - // ctype验证规则 - $ctypeFun = 'ctype_' . $rule; - $result = $ctypeFun($value); - } elseif (isset($this->filter[$rule])) { - // Filter_var验证规则 - $result = $this->filter($value, $this->filter[$rule]); - } else { - // 正则验证 - $result = $this->regex($value, $rule); - } - } + $call = function ($value, $rule) { + if (isset($this->type[$rule])) { + // 注册的验证规则 + $result = call_user_func_array($this->type[$rule], [$value]); + } elseif (function_exists('ctype_' . $rule)) { + // ctype验证规则 + $ctypeFun = 'ctype_' . $rule; + $result = $ctypeFun($value); + } elseif (isset($this->filter[$rule])) { + // Filter_var验证规则 + $result = $this->filter($value, $this->filter[$rule]); + } else { + // 正则验证 + $result = $this->regex($value, $rule); + } + return $result; + }; - return $result; + return match (Str::camel($rule)) { + 'require' => !empty($value) || '0' == $value, // 必须 + 'accepted' => in_array($value, ['1', 'on', 'yes']), // 接受 + 'date' => false !== strtotime($value), // 是否是一个有效日期 + 'activeUrl' => checkdnsrr($value), // 是否为有效的网址 + 'boolean','bool' => in_array($value, [true, false, 0, 1, '0', '1'], true), // 是否为布尔值 + 'number' => ctype_digit((string) $value), + 'alphaNum' => ctype_alnum($value), + 'array' => is_array($value), // 是否为数组 + 'string' => is_string($value), + 'file' => $value instanceof File, + 'image' => $value instanceof File && in_array($this->getImageType($value->getRealPath()), [1, 2, 3, 6]), + 'token' => $this->token($value, '__token__', $data), + default => $call($value, $rule), + }; } // 判断图像类型 @@ -948,6 +926,42 @@ class Validate return $this->filter($value, [FILTER_VALIDATE_IP, 'ipv6' == $rule ? FILTER_FLAG_IPV6 : FILTER_FLAG_IPV4]); } + /** + * 检测是否以某个字符串开头 + * @access public + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function startWith($value, string $rule): bool + { + return is_string($value) && str_starts_with($value, $rule); + } + + /** + * 检测是否以某个字符串结尾 + * @access public + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function endWith($value, string $rule): bool + { + return is_string($value) && str_ends_with($value, $rule); + } + + /** + * 检测是否以包含某个字符串 + * @access public + * @param mixed $value 字段值 + * @param string $rule 验证规则 + * @return bool + */ + public function contain($value, string $rule): bool + { + return is_string($value) && str_contains($value, $rule); + } + /** * 检测上传文件后缀 * @access public @@ -1127,7 +1141,7 @@ class Validate $rule = explode(',', $rule); } - if (false !== strpos($rule[0], '\\')) { + if (str_contains($rule[0], '\\')) { // 指定模型类 $db = new $rule[0]; } else { @@ -1137,7 +1151,7 @@ class Validate $key = $rule[1] ?? $field; $map = []; - if (strpos($key, '^')) { + if (str_contains($key, '^')) { // 支持多个字段验证 $fields = explode('^', $key); foreach ($fields as $key) { @@ -1177,7 +1191,7 @@ class Validate */ public function filter($value, $rule): bool { - if (is_string($rule) && strpos($rule, ',')) { + if (is_string($rule) && str_contains($rule, ',')) { [$rule, $param] = explode(',', $rule); } elseif (is_array($rule)) { $param = $rule[1] ?? 0; @@ -1340,7 +1354,7 @@ class Validate $length = mb_strlen((string) $value); } - if (is_string($rule) && strpos($rule, ',')) { + if (is_string($rule) && str_contains($rule, ',')) { // 长度区间 [$min, $max] = explode(',', $rule); return $length >= $min && $length <= $max; @@ -1509,7 +1523,7 @@ class Validate $rule = $this->defaultRegex[$rule]; } - if (is_string($rule) && 0 !== strpos($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { + if (is_string($rule) && !str_starts_with($rule, '/') && !preg_match('/\/[imsU]{0,4}$/', $rule)) { // 不是正则表达式则两端补上/ $rule = '/^' . $rule . '$/'; } @@ -1537,7 +1551,7 @@ class Validate { if (is_numeric($key)) { $value = $key; - } elseif (is_string($key) && strpos($key, '.')) { + } elseif (is_string($key) && str_contains($key, '.')) { // 支持多维数组验证 foreach (explode('.', $key) as $key) { if (!isset($data[$key])) { @@ -1572,7 +1586,7 @@ class Validate $msg = $this->message[$attribute]; } elseif (isset($this->typeMsg[$type])) { $msg = $this->typeMsg[$type]; - } elseif (0 === strpos($type, 'require')) { + } elseif (str_starts_with($type, 'require')) { $msg = $this->typeMsg['require']; } else { $msg = $title . $this->lang->get('not conform to the rules'); @@ -1595,7 +1609,7 @@ class Validate */ protected function parseErrorMsg(string $msg, $rule, string $title) { - if (0 === strpos($msg, '{%')) { + if (str_starts_with($msg, '{%')) { $msg = $this->lang->get(substr($msg, 2, -1)); } elseif ($this->lang->has($msg)) { $msg = $this->lang->get($msg); @@ -1610,9 +1624,9 @@ class Validate $rule = implode(',', $rule); } - if (is_scalar($rule) && false !== strpos($msg, ':')) { + if (is_scalar($rule) && str_contains($msg, ':')) { // 变量替换 - if (is_string($rule) && strpos($rule, ',')) { + if (is_string($rule) && str_contains($rule, ',')) { $array = array_pad(explode(',', $rule), 3, ''); } else { $array = array_pad([], 3, ''); @@ -1624,7 +1638,7 @@ class Validate $msg ); - if (strpos($msg, ':rule')) { + if (str_contains($msg, ':rule')) { $msg = str_replace(':rule', (string) $rule, $msg); } } diff --git a/vendor/topthink/framework/src/think/View.php b/vendor/topthink/framework/src/think/View.php index 2e71088..73579f4 100644 --- a/vendor/topthink/framework/src/think/View.php +++ b/vendor/topthink/framework/src/think/View.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -53,7 +53,7 @@ class View extends Manager * @param mixed $value 变量值 * @return $this */ - public function assign($name, $value = null) + public function assign(string|array $name, $value = null) { if (is_array($name)) { $this->data = array_merge($this->data, $name); @@ -115,11 +115,7 @@ class View extends Manager { // 页面缓存 ob_start(); - if (PHP_VERSION > 8.0) { - ob_implicit_flush(false); - } else { - ob_implicit_flush(0); - } + ob_implicit_flush(false); // 渲染输出 try { @@ -187,5 +183,4 @@ class View extends Manager { return $this->app->config->get('view.type', 'php'); } - } diff --git a/vendor/topthink/framework/src/think/cache/Driver.php b/vendor/topthink/framework/src/think/cache/Driver.php index 7dc0d30..48e22ce 100644 --- a/vendor/topthink/framework/src/think/cache/Driver.php +++ b/vendor/topthink/framework/src/think/cache/Driver.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache; @@ -64,7 +64,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @param integer|DateTimeInterface|DateInterval $expire 有效期 * @return int */ - protected function getExpireTime($expire): int + protected function getExpireTime(int|DateTimeInterface|DateInterval $expire): int { if ($expire instanceof DateTimeInterface) { $expire = $expire->getTimestamp() - time(); @@ -74,7 +74,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface ->format('U') - time(); } - return (int) $expire; + return $expire; } /** @@ -147,10 +147,10 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param int $expire 有效时间 0为永久 + * @param int|DateInterval $expire 有效时间 0为永久 * @return mixed */ - public function remember(string $name, $value, $expire = null) + public function remember(string $name, $value, int|DateInterval $expire = null) { if ($this->has($name)) { if (($hit = $this->get($name)) !== null) { @@ -193,7 +193,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @param string|array $name 标签名 * @return TagSet */ - public function tag($name): TagSet + public function tag(string|array $name): TagSet { $name = (array) $name; $key = implode('-', $name); @@ -251,7 +251,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @param string $data 缓存数据 * @return mixed */ - protected function unserialize($data) + protected function unserialize(string $data) { if (is_numeric($data)) { return $data; @@ -301,7 +301,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @return iterable * @throws InvalidArgumentException */ - public function getMultiple($keys, $default = null): iterable + public function getMultiple(iterable $keys, mixed $default = null): iterable { $result = []; @@ -319,7 +319,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @param null|int|\DateInterval $ttl 有效时间 0为永久 * @return bool */ - public function setMultiple($values, $ttl = null): bool + public function setMultiple(iterable $values, int|DateInterval $ttl = null): bool { foreach ($values as $key => $val) { $result = $this->set($key, $val, $ttl); @@ -339,7 +339,7 @@ abstract class Driver implements CacheInterface, CacheHandlerInterface * @return bool * @throws InvalidArgumentException */ - public function deleteMultiple($keys): bool + public function deleteMultiple(iterable $keys): bool { foreach ($keys as $key) { $result = $this->delete($key); diff --git a/vendor/topthink/framework/src/think/cache/TagSet.php b/vendor/topthink/framework/src/think/cache/TagSet.php index 5ba2076..7582c32 100644 --- a/vendor/topthink/framework/src/think/cache/TagSet.php +++ b/vendor/topthink/framework/src/think/cache/TagSet.php @@ -2,43 +2,31 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache; +use DateInterval; + /** * 标签集合 */ class TagSet { - /** - * 标签的缓存Key - * @var array - */ - protected $tag; - - /** - * 缓存句柄 - * @var Driver - */ - protected $handler; - /** * 架构函数 * @access public * @param array $tag 缓存标签 * @param Driver $cache 缓存对象 */ - public function __construct(array $tag, Driver $cache) + public function __construct(protected array $tag, protected Driver $handler) { - $this->tag = $tag; - $this->handler = $cache; } /** @@ -46,10 +34,10 @@ class TagSet * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|\DateTime $expire 有效时间(秒) + * @param integer|DateInterval $expire 有效时间(秒) * @return bool */ - public function set(string $name, $value, $expire = null): bool + public function set(string $name, $value, int|DateInterval $expire = null): bool { $this->handler->set($name, $value, $expire); @@ -78,10 +66,10 @@ class TagSet * 写入缓存 * @access public * @param iterable $values 缓存数据 - * @param null|int|\DateInterval $ttl 有效时间 0为永久 + * @param null|int|DateInterval $ttl 有效时间 0为永久 * @return bool */ - public function setMultiple($values, $ttl = null): bool + public function setMultiple(iterable $values, int|DateInterval $ttl = null): bool { foreach ($values as $key => $val) { $result = $this->set($key, $val, $ttl); diff --git a/vendor/topthink/framework/src/think/cache/driver/File.php b/vendor/topthink/framework/src/think/cache/driver/File.php index b36b069..f3a1780 100644 --- a/vendor/topthink/framework/src/think/cache/driver/File.php +++ b/vendor/topthink/framework/src/think/cache/driver/File.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types = 1); namespace think\cache\driver; +use DateInterval; use FilesystemIterator; use think\App; use think\cache\Driver; @@ -51,7 +52,7 @@ class File extends Driver $this->options['path'] = $app->getRuntimePath() . 'cache'; } - if (substr($this->options['path'], -1) != DIRECTORY_SEPARATOR) { + if (!str_ends_with($this->options['path'], DIRECTORY_SEPARATOR)) { $this->options['path'] .= DIRECTORY_SEPARATOR; } } @@ -108,7 +109,7 @@ class File extends Driver $content = gzuncompress($content); } - return is_string($content) ? ['content' => $content, 'expire' => $expire] : null; + return is_string($content) ? ['content' => (string) $content, 'expire' => $expire] : null; } } @@ -118,7 +119,7 @@ class File extends Driver * @param string $name 缓存变量名 * @return bool */ - public function has($name): bool + public function has(string $name): bool { return $this->getRaw($name) !== null; } @@ -130,7 +131,7 @@ class File extends Driver * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null) + public function get(string $name, mixed $default = null): mixed { $this->readTimes++; @@ -142,12 +143,12 @@ class File extends Driver /** * 写入缓存 * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param int|\DateTime $expire 有效时间 0为永久 + * @param string $name 缓存变量名 + * @param mixed $value 存储数据 + * @param int|\DateInterval|null $expire 有效时间 0为永久 * @return bool */ - public function set($name, $value, $expire = null): bool + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool { $this->writeTimes++; @@ -175,8 +176,14 @@ class File extends Driver $data = gzcompress($data, 3); } - $data = "\n" . $data; - $result = file_put_contents($filename, $data); + $data = "\n" . $data; + + if (str_contains($filename, '://') && !str_starts_with($filename, 'file://')) { + //虚拟文件不加锁 + $result = file_put_contents($filename, $data); + } else { + $result = file_put_contents($filename, $data, LOCK_EX); + } if ($result) { clearstatcache(); @@ -224,7 +231,7 @@ class File extends Driver * @param string $name 缓存变量名 * @return bool */ - public function delete($name): bool + public function delete(string $name): bool { $this->writeTimes++; @@ -300,5 +307,4 @@ class File extends Driver return true; } - } diff --git a/vendor/topthink/framework/src/think/cache/driver/Memcache.php b/vendor/topthink/framework/src/think/cache/driver/Memcache.php index 2fbbb9c..7f41914 100644 --- a/vendor/topthink/framework/src/think/cache/driver/Memcache.php +++ b/vendor/topthink/framework/src/think/cache/driver/Memcache.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache\driver; +use DateInterval; use think\cache\Driver; /** @@ -64,8 +65,8 @@ class Memcache extends Driver foreach ($hosts as $i => $host) { $port = $ports[$i] ?? $ports[0]; $this->options['timeout'] > 0 ? - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : - $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1, (int) $this->options['timeout']) : + $this->handler->addServer($host, (int) $port, $this->options['persistent'], 1); } } @@ -75,7 +76,7 @@ class Memcache extends Driver * @param string $name 缓存变量名 * @return bool */ - public function has($name): bool + public function has(string $name): bool { $key = $this->getCacheKey($name); @@ -89,7 +90,7 @@ class Memcache extends Driver * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null) + public function get(string $name, mixed $default = null): mixed { $this->readTimes++; @@ -106,7 +107,7 @@ class Memcache extends Driver * @param int|\DateTime $expire 有效时间(秒) * @return bool */ - public function set($name, $value, $expire = null): bool + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool { $this->writeTimes++; @@ -170,15 +171,15 @@ class Memcache extends Driver * @param bool|false $ttl * @return bool */ - public function delete($name, $ttl = false): bool + public function delete(string $name, $ttl = false): bool { $this->writeTimes++; $key = $this->getCacheKey($name); return false === $ttl ? - $this->handler->delete($key) : - $this->handler->delete($key, $ttl); + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); } /** @@ -205,5 +206,4 @@ class Memcache extends Driver $this->handler->delete($key); } } - } diff --git a/vendor/topthink/framework/src/think/cache/driver/Memcached.php b/vendor/topthink/framework/src/think/cache/driver/Memcached.php index 71edb05..4c4aa89 100644 --- a/vendor/topthink/framework/src/think/cache/driver/Memcached.php +++ b/vendor/topthink/framework/src/think/cache/driver/Memcached.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache\driver; +use DateInterval; use think\cache\Driver; /** @@ -89,7 +90,7 @@ class Memcached extends Driver * @param string $name 缓存变量名 * @return bool */ - public function has($name): bool + public function has(string $name): bool { $key = $this->getCacheKey($name); @@ -103,7 +104,7 @@ class Memcached extends Driver * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null) + public function get(string $name, mixed $default = null): mixed { $this->readTimes++; @@ -117,10 +118,10 @@ class Memcached extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|\DateTime $expire 有效时间(秒) + * @param integer|DateInterval $expire 有效时间(秒) * @return bool */ - public function set($name, $value, $expire = null): bool + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool { $this->writeTimes++; @@ -184,15 +185,15 @@ class Memcached extends Driver * @param bool|false $ttl * @return bool */ - public function delete($name, $ttl = false): bool + public function delete(string $name, $ttl = false): bool { $this->writeTimes++; $key = $this->getCacheKey($name); return false === $ttl ? - $this->handler->delete($key) : - $this->handler->delete($key, $ttl); + $this->handler->delete($key) : + $this->handler->delete($key, $ttl); } /** @@ -217,5 +218,4 @@ class Memcached extends Driver { $this->handler->deleteMulti($keys); } - } diff --git a/vendor/topthink/framework/src/think/cache/driver/Redis.php b/vendor/topthink/framework/src/think/cache/driver/Redis.php index 791b27b..22317b3 100644 --- a/vendor/topthink/framework/src/think/cache/driver/Redis.php +++ b/vendor/topthink/framework/src/think/cache/driver/Redis.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache\driver; +use DateInterval; use think\cache\Driver; /** @@ -97,7 +98,7 @@ class Redis extends Driver * @param string $name 缓存变量名 * @return bool */ - public function has($name): bool + public function has(string $name): bool { return $this->handler->exists($this->getCacheKey($name)) ? true : false; } @@ -109,7 +110,7 @@ class Redis extends Driver * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null) + public function get(string $name, mixed $default = null): mixed { $this->readTimes++; $key = $this->getCacheKey($name); @@ -127,10 +128,10 @@ class Redis extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|\DateTime $expire 有效时间(秒) + * @param integer|DateInterval $expire 有效时间(秒) * @return bool */ - public function set($name, $value, $expire = null): bool + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool { $this->writeTimes++; @@ -187,7 +188,7 @@ class Redis extends Driver * @param string $name 缓存变量名 * @return bool */ - public function delete($name): bool + public function delete(string $name): bool { $this->writeTimes++; @@ -245,5 +246,4 @@ class Redis extends Driver $key = $this->getCacheKey($name); return $this->handler->sMembers($key); } - } diff --git a/vendor/topthink/framework/src/think/cache/driver/Wincache.php b/vendor/topthink/framework/src/think/cache/driver/Wincache.php index 8b3e8b8..7358371 100644 --- a/vendor/topthink/framework/src/think/cache/driver/Wincache.php +++ b/vendor/topthink/framework/src/think/cache/driver/Wincache.php @@ -2,16 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\cache\driver; +use DateInterval; use think\cache\Driver; /** @@ -69,7 +70,7 @@ class Wincache extends Driver * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null) + public function get(string $name, mixed $default = null): mixed { $this->readTimes++; @@ -83,10 +84,10 @@ class Wincache extends Driver * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|\DateTime $expire 有效时间(秒) + * @param integer|DateInterval $expire 有效时间(秒) * @return bool */ - public function set($name, $value, $expire = null): bool + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool { $this->writeTimes++; @@ -143,7 +144,7 @@ class Wincache extends Driver * @param string $name 缓存变量名 * @return bool */ - public function delete($name): bool + public function delete(string $name): bool { $this->writeTimes++; @@ -171,5 +172,4 @@ class Wincache extends Driver { wincache_ucache_delete($keys); } - } diff --git a/vendor/topthink/framework/src/think/console/Command.php b/vendor/topthink/framework/src/think/console/Command.php index bd3fb20..473869d 100644 --- a/vendor/topthink/framework/src/think/console/Command.php +++ b/vendor/topthink/framework/src/think/console/Command.php @@ -459,7 +459,7 @@ abstract class Command */ public function addUsage(string $usage) { - if (0 !== strpos($usage, $this->name)) { + if (!str_starts_with($usage, $this->name)) { $usage = sprintf('%s %s', $this->name, $usage); } diff --git a/vendor/topthink/framework/src/think/console/Input.php b/vendor/topthink/framework/src/think/console/Input.php index 9ae9077..71769e3 100644 --- a/vendor/topthink/framework/src/think/console/Input.php +++ b/vendor/topthink/framework/src/think/console/Input.php @@ -82,7 +82,7 @@ class Input $this->parseArgument($token); } elseif ($parseOptions && '--' == $token) { $parseOptions = false; - } elseif ($parseOptions && 0 === strpos($token, '--')) { + } elseif ($parseOptions && str_starts_with($token, '--')) { $this->parseLongOption($token); } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { $this->parseShortOption($token); @@ -267,7 +267,7 @@ class Input foreach ($this->tokens as $token) { foreach ($values as $value) { - if ($token === $value || 0 === strpos($token, $value . '=')) { + if ($token === $value || str_starts_with($token, $value . '=')) { return true; } } @@ -291,7 +291,7 @@ class Input $token = array_shift($tokens); foreach ($values as $value) { - if ($token === $value || 0 === strpos($token, $value . '=')) { + if ($token === $value || str_starts_with($token, $value . '=')) { if (false !== $pos = strpos($token, '=')) { return substr($token, $pos + 1); } @@ -378,7 +378,7 @@ class Input * @param string|int $name 参数名或位置 * @return bool */ - public function hasArgument($name): bool + public function hasArgument(string|int $name): bool { return $this->definition->hasArgument($name); } diff --git a/vendor/topthink/framework/src/think/console/command/Make.php b/vendor/topthink/framework/src/think/console/command/Make.php index a74e9e8..ac2453d 100644 --- a/vendor/topthink/framework/src/think/console/command/Make.php +++ b/vendor/topthink/framework/src/think/console/command/Make.php @@ -74,17 +74,17 @@ abstract class Make extends Command protected function getClassName(string $name): string { - if (strpos($name, '\\') !== false) { + if (str_contains($name, '\\')) { return $name; } - if (strpos($name, '@')) { + if (str_contains($name, '@')) { [$app, $name] = explode('@', $name); } else { $app = ''; } - if (strpos($name, '/') !== false) { + if (str_contains($name, '/')) { $name = str_replace('/', '\\', $name); } diff --git a/vendor/topthink/framework/src/think/console/command/RouteList.php b/vendor/topthink/framework/src/think/console/command/RouteList.php index cfc7293..546cf4d 100644 --- a/vendor/topthink/framework/src/think/console/command/RouteList.php +++ b/vendor/topthink/framework/src/think/console/command/RouteList.php @@ -68,7 +68,7 @@ class RouteList extends Command $files = is_dir($path) ? scandir($path) : []; foreach ($files as $file) { - if (strpos($file, '.php')) { + if (str_contains($file, '.php')) { include $path . $file; } } diff --git a/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php b/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php index e90f433..5de73f8 100644 --- a/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php +++ b/vendor/topthink/framework/src/think/console/command/ServiceDiscover.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\console\command; diff --git a/vendor/topthink/framework/src/think/console/command/VendorPublish.php b/vendor/topthink/framework/src/think/console/command/VendorPublish.php index 3998765..e1f3ce1 100644 --- a/vendor/topthink/framework/src/think/console/command/VendorPublish.php +++ b/vendor/topthink/framework/src/think/console/command/VendorPublish.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\console\command; diff --git a/vendor/topthink/framework/src/think/console/command/make/Command.php b/vendor/topthink/framework/src/think/console/command/make/Command.php index 9549a02..7fca7f0 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Command.php +++ b/vendor/topthink/framework/src/think/console/command/make/Command.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -51,5 +51,4 @@ class Command extends Make { return parent::getNamespace($app) . '\\command'; } - } diff --git a/vendor/topthink/framework/src/think/console/command/make/Controller.php b/vendor/topthink/framework/src/think/console/command/make/Controller.php index 4a8d226..c4a23ac 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Controller.php +++ b/vendor/topthink/framework/src/think/console/command/make/Controller.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -52,5 +52,4 @@ class Controller extends Make { return parent::getNamespace($app) . '\\controller'; } - } diff --git a/vendor/topthink/framework/src/think/console/command/make/Event.php b/vendor/topthink/framework/src/think/console/command/make/Event.php index 6b16689..fa8052f 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Event.php +++ b/vendor/topthink/framework/src/think/console/command/make/Event.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Listener.php b/vendor/topthink/framework/src/think/console/command/make/Listener.php index 5c92673..48265ac 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Listener.php +++ b/vendor/topthink/framework/src/think/console/command/make/Listener.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Middleware.php b/vendor/topthink/framework/src/think/console/command/make/Middleware.php index 3b68b4a..bd410b7 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Middleware.php +++ b/vendor/topthink/framework/src/think/console/command/make/Middleware.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Model.php b/vendor/topthink/framework/src/think/console/command/make/Model.php index cb7a23c..4ae6889 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Model.php +++ b/vendor/topthink/framework/src/think/console/command/make/Model.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Service.php b/vendor/topthink/framework/src/think/console/command/make/Service.php index c4bbaa0..e95d14a 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Service.php +++ b/vendor/topthink/framework/src/think/console/command/make/Service.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Subscribe.php b/vendor/topthink/framework/src/think/console/command/make/Subscribe.php index a1dc2a8..a702fb8 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Subscribe.php +++ b/vendor/topthink/framework/src/think/console/command/make/Subscribe.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK IT ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/console/command/make/Validate.php b/vendor/topthink/framework/src/think/console/command/make/Validate.php index 8d36431..09e5062 100644 --- a/vendor/topthink/framework/src/think/console/command/make/Validate.php +++ b/vendor/topthink/framework/src/think/console/command/make/Validate.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -35,5 +35,4 @@ class Validate extends Make { return parent::getNamespace($app) . '\\validate'; } - } diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Route.php b/vendor/topthink/framework/src/think/console/command/optimize/Route.php index 56f7f5a..30ef76a 100644 --- a/vendor/topthink/framework/src/think/console/command/optimize/Route.php +++ b/vendor/topthink/framework/src/think/console/command/optimize/Route.php @@ -51,7 +51,7 @@ class Route extends Command $files = is_dir($path) ? scandir($path) : []; foreach ($files as $file) { - if (strpos($file, '.php')) { + if (str_contains($file, '.php')) { include $path . $file; } } diff --git a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php index 6ce3e64..3ee3f42 100644 --- a/vendor/topthink/framework/src/think/console/command/optimize/Schema.php +++ b/vendor/topthink/framework/src/think/console/command/optimize/Schema.php @@ -40,7 +40,7 @@ class Schema extends Command return; } $table = $input->getOption('table'); - if (false === strpos($table, '.')) { + if (!str_contains($table, '.')) { $dbName = $connection->getConfig('database'); } else { [$dbName, $table] = explode('.', $table); @@ -64,10 +64,15 @@ class Schema extends Command $list = is_dir($path) ? scandir($path) : []; foreach ($list as $file) { - if (0 === strpos($file, '.')) { + if (str_starts_with($file, '.')) { continue; } $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); + + if (!class_exists($class)) { + continue; + } + $this->buildModelSchema($class); } } diff --git a/vendor/topthink/framework/src/think/console/input/Option.php b/vendor/topthink/framework/src/think/console/input/Option.php index d7e6514..8554087 100644 --- a/vendor/topthink/framework/src/think/console/input/Option.php +++ b/vendor/topthink/framework/src/think/console/input/Option.php @@ -67,7 +67,7 @@ class Option */ public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) { - if (0 === strpos($name, '--')) { + if (str_starts_with($name, '--')) { $name = substr($name, 2); } diff --git a/vendor/topthink/framework/src/think/console/output/Ask.php b/vendor/topthink/framework/src/think/console/output/Ask.php index 0058d05..01bc219 100644 --- a/vendor/topthink/framework/src/think/console/output/Ask.php +++ b/vendor/topthink/framework/src/think/console/output/Ask.php @@ -169,7 +169,7 @@ class Ask $ofs = 0; foreach ($autocomplete as $value) { - if (0 === strpos($value, $ret) && $i !== strlen($value)) { + if (str_starts_with($value, $ret) && $i !== strlen($value)) { $matches[$numMatches++] = $value; } } diff --git a/vendor/topthink/framework/src/think/console/output/Descriptor.php b/vendor/topthink/framework/src/think/console/output/Descriptor.php index 84d487c..2985ddb 100644 --- a/vendor/topthink/framework/src/think/console/output/Descriptor.php +++ b/vendor/topthink/framework/src/think/console/output/Descriptor.php @@ -51,7 +51,7 @@ class Descriptor $this->describeConsole($object, $options); break; default: - throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', $object::class)); } } @@ -86,7 +86,7 @@ class Descriptor $spacingWidth = $totalWidth - strlen($argument->getName()) + 2; $this->writeText(sprintf(" %s%s%s%s", $argument->getName(), str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces - preg_replace('/\s*\R\s*/', PHP_EOL . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options); + preg_replace('/\s*[\r\n]\s*/', PHP_EOL . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options); } /** @@ -121,7 +121,7 @@ class Descriptor $spacingWidth = $totalWidth - strlen($synopsis) + 2; $this->writeText(sprintf(" %s%s%s%s%s", $synopsis, str_repeat(' ', $spacingWidth), // + 17 = 2 spaces + + + 2 spaces - preg_replace('/\s*\R\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : ''), $options); + preg_replace('/\s*[\r\n]\s*/', "\n" . str_repeat(' ', $totalWidth + 17), $option->getDescription()), $default, $option->isArray() ? ' (multiple values allowed)' : ''), $options); } /** diff --git a/vendor/topthink/framework/src/think/console/output/driver/Console.php b/vendor/topthink/framework/src/think/console/output/driver/Console.php index 3061f55..5c0a9ef 100644 --- a/vendor/topthink/framework/src/think/console/output/driver/Console.php +++ b/vendor/topthink/framework/src/think/console/output/driver/Console.php @@ -75,7 +75,7 @@ class Console $this->formatter->setDecorated($decorated); do { - $title = sprintf(' [%s] ', get_class($e)); + $title = sprintf(' [%s] ', $e::class); $len = $this->stringWidth($title); diff --git a/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php b/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php index da5e696..992b0dd 100644 --- a/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php +++ b/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php @@ -2,16 +2,18 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\contract; +use DateInterval; + /** * 缓存驱动接口 */ @@ -23,7 +25,7 @@ interface CacheHandlerInterface * @param string $name 缓存变量名 * @return bool */ - public function has($name); + public function has(string $name): bool; /** * 读取缓存 @@ -32,17 +34,17 @@ interface CacheHandlerInterface * @param mixed $default 默认值 * @return mixed */ - public function get($name, $default = null); + public function get(string $name, mixed $default = null): mixed; /** * 写入缓存 * @access public * @param string $name 缓存变量名 * @param mixed $value 存储数据 - * @param integer|\DateTime $expire 有效时间(秒) + * @param integer|DateInterval $expire 有效时间(秒) * @return bool */ - public function set($name, $value, $expire = null); + public function set(string $name, mixed $value, int|DateInterval $expire = null): bool; /** * 自增缓存(针对数值缓存) @@ -68,14 +70,14 @@ interface CacheHandlerInterface * @param string $name 缓存变量名 * @return bool */ - public function delete($name); + public function delete(string $name): bool; /** * 清除缓存 * @access public * @return bool */ - public function clear(); + public function clear(): bool; /** * 删除缓存标签 @@ -84,5 +86,4 @@ interface CacheHandlerInterface * @return void */ public function clearTag(array $keys); - } diff --git a/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php b/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php index 1f6f994..545b21d 100644 --- a/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php +++ b/vendor/topthink/framework/src/think/contract/ModelRelationInterface.php @@ -2,19 +2,18 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\contract; use Closure; -use think\Collection; -use think\db\Query; +use think\db\BaseQuery as Query; use think\Model; /** @@ -27,9 +26,9 @@ interface ModelRelationInterface * @access public * @param array $subRelation 子关联 * @param Closure $closure 闭包查询条件 - * @return Collection + * @return mixed */ - public function getRelation(array $subRelation = [], Closure $closure = null): Collection; + public function getRelation(array $subRelation = [], Closure $closure = null); /** * 预载入关联查询 @@ -85,7 +84,7 @@ interface ModelRelationInterface * @param string $joinType JOIN类型 * @return Query */ - public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER'): Query; + public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', Query $query = null): Query; /** * 根据关联条件查询当前模型 diff --git a/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php b/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php index 0b2e414..99782e1 100644 --- a/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php +++ b/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\contract; diff --git a/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php b/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php index 9be93d2..c361364 100644 --- a/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php +++ b/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\contract; diff --git a/vendor/topthink/framework/src/think/event/AppInit.php b/vendor/topthink/framework/src/think/event/AppInit.php index dda820b..fa27ea6 100644 --- a/vendor/topthink/framework/src/think/event/AppInit.php +++ b/vendor/topthink/framework/src/think/event/AppInit.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\event; @@ -16,4 +16,5 @@ namespace think\event; * AppInit事件类 */ class AppInit -{} +{ +} diff --git a/vendor/topthink/framework/src/think/event/HttpEnd.php b/vendor/topthink/framework/src/think/event/HttpEnd.php index c40da57..de0b4c3 100644 --- a/vendor/topthink/framework/src/think/event/HttpEnd.php +++ b/vendor/topthink/framework/src/think/event/HttpEnd.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\event; @@ -16,4 +16,5 @@ namespace think\event; * HttpEnd事件类 */ class HttpEnd -{} +{ +} diff --git a/vendor/topthink/framework/src/think/event/HttpRun.php b/vendor/topthink/framework/src/think/event/HttpRun.php index ce67e93..4a6d3ff 100644 --- a/vendor/topthink/framework/src/think/event/HttpRun.php +++ b/vendor/topthink/framework/src/think/event/HttpRun.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\event; @@ -16,4 +16,5 @@ namespace think\event; * HttpRun事件类 */ class HttpRun -{} +{ +} diff --git a/vendor/topthink/framework/src/think/event/LogRecord.php b/vendor/topthink/framework/src/think/event/LogRecord.php index 237468d..3fd6767 100644 --- a/vendor/topthink/framework/src/think/event/LogRecord.php +++ b/vendor/topthink/framework/src/think/event/LogRecord.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/event/LogWrite.php b/vendor/topthink/framework/src/think/event/LogWrite.php index a787301..f339fba 100644 --- a/vendor/topthink/framework/src/think/event/LogWrite.php +++ b/vendor/topthink/framework/src/think/event/LogWrite.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\event; @@ -17,15 +17,7 @@ namespace think\event; */ class LogWrite { - /** @var string */ - public $channel; - - /** @var array */ - public $log; - - public function __construct($channel, $log) + public function __construct(public string $channel, public array $log) { - $this->channel = $channel; - $this->log = $log; } } diff --git a/vendor/topthink/framework/src/think/event/RouteLoaded.php b/vendor/topthink/framework/src/think/event/RouteLoaded.php index ace7992..6b1b527 100644 --- a/vendor/topthink/framework/src/think/event/RouteLoaded.php +++ b/vendor/topthink/framework/src/think/event/RouteLoaded.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\event; @@ -17,5 +17,4 @@ namespace think\event; */ class RouteLoaded { - } diff --git a/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php b/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php index c4cda77..93ec89f 100644 --- a/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php +++ b/vendor/topthink/framework/src/think/exception/ClassNotFoundException.php @@ -17,12 +17,9 @@ use Throwable; class ClassNotFoundException extends RuntimeException implements NotFoundExceptionInterface { - protected $class; - - public function __construct(string $message, string $class = '', Throwable $previous = null) + public function __construct(string $message, protected string $class = '', Throwable $previous = null) { $this->message = $message; - $this->class = $class; parent::__construct($message, 0, $previous); } diff --git a/vendor/topthink/framework/src/think/exception/ErrorException.php b/vendor/topthink/framework/src/think/exception/ErrorException.php index d1a2378..e8ae7ec 100644 --- a/vendor/topthink/framework/src/think/exception/ErrorException.php +++ b/vendor/topthink/framework/src/think/exception/ErrorException.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: 麦当苗儿 // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\exception; diff --git a/vendor/topthink/framework/src/think/exception/FileException.php b/vendor/topthink/framework/src/think/exception/FileException.php index 228a189..505f7ba 100644 --- a/vendor/topthink/framework/src/think/exception/FileException.php +++ b/vendor/topthink/framework/src/think/exception/FileException.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\exception; diff --git a/vendor/topthink/framework/src/think/exception/FuncNotFoundException.php b/vendor/topthink/framework/src/think/exception/FuncNotFoundException.php index ee2bcad..0f65376 100644 --- a/vendor/topthink/framework/src/think/exception/FuncNotFoundException.php +++ b/vendor/topthink/framework/src/think/exception/FuncNotFoundException.php @@ -8,12 +8,9 @@ use Throwable; class FuncNotFoundException extends RuntimeException implements NotFoundExceptionInterface { - protected $func; - - public function __construct(string $message, string $func = '', Throwable $previous = null) + public function __construct(string $message, protected string $func = '', Throwable $previous = null) { $this->message = $message; - $this->func = $func; parent::__construct($message, 0, $previous); } diff --git a/vendor/topthink/framework/src/think/exception/Handle.php b/vendor/topthink/framework/src/think/exception/Handle.php index 1f783bc..7d64e13 100644 --- a/vendor/topthink/framework/src/think/exception/Handle.php +++ b/vendor/topthink/framework/src/think/exception/Handle.php @@ -26,9 +26,6 @@ use Throwable; */ class Handle { - /** @var App */ - protected $app; - protected $ignoreReport = [ HttpException::class, HttpResponseException::class, @@ -39,9 +36,8 @@ class Handle protected $isJson = false; - public function __construct(App $app) + public function __construct(protected App $app) { - $this->app = $app; } /** @@ -100,7 +96,7 @@ class Handle * @param Throwable $e * @return Response */ - public function render($request, Throwable $e): Response + public function render(Request $request, Throwable $e): Response { $this->isJson = $request->isJson(); if ($e instanceof HttpResponseException) { @@ -156,7 +152,7 @@ class Handle $nextException = $exception; do { $traces[] = [ - 'name' => get_class($nextException), + 'name' => $nextException::class, 'file' => $nextException->getFile(), 'line' => $nextException->getLine(), 'code' => $this->getCode($nextException), @@ -261,10 +257,10 @@ class Handle $lang = $this->app->lang; - if (strpos($message, ':')) { + if (str_contains($message, ':')) { $name = strstr($message, ':', true); $message = $lang->has($name) ? $lang->get($name) . strstr($message, ':') : $message; - } elseif (strpos($message, ',')) { + } elseif (str_contains($message, ',')) { $name = strstr($message, ',', true); $message = $lang->has($name) ? $lang->get($name) . ':' . substr(strstr($message, ','), 1) : $message; } elseif ($lang->has($message)) { diff --git a/vendor/topthink/framework/src/think/exception/HttpException.php b/vendor/topthink/framework/src/think/exception/HttpException.php index 45302e5..7ccc670 100644 --- a/vendor/topthink/framework/src/think/exception/HttpException.php +++ b/vendor/topthink/framework/src/think/exception/HttpException.php @@ -19,14 +19,8 @@ use Exception; */ class HttpException extends \RuntimeException { - private $statusCode; - private $headers; - - public function __construct(int $statusCode, string $message = '', Exception $previous = null, array $headers = [], $code = 0) + public function __construct(private int $statusCode, string $message = '', Exception $previous = null, private array $headers = [], $code = 0) { - $this->statusCode = $statusCode; - $this->headers = $headers; - parent::__construct($message, $code, $previous); } diff --git a/vendor/topthink/framework/src/think/exception/HttpResponseException.php b/vendor/topthink/framework/src/think/exception/HttpResponseException.php index 607813d..fc22fb4 100644 --- a/vendor/topthink/framework/src/think/exception/HttpResponseException.php +++ b/vendor/topthink/framework/src/think/exception/HttpResponseException.php @@ -19,14 +19,8 @@ use think\Response; */ class HttpResponseException extends \RuntimeException { - /** - * @var Response - */ - protected $response; - - public function __construct(Response $response) + public function __construct(protected Response $response) { - $this->response = $response; } public function getResponse() diff --git a/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php b/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php index 8ccd6f6..d7603c9 100644 --- a/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php +++ b/vendor/topthink/framework/src/think/exception/InvalidArgumentException.php @@ -11,12 +11,11 @@ declare (strict_types = 1); namespace think\exception; -use Psr\Cache\InvalidArgumentException as Psr6CacheInvalidArgumentInterface; use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInvalidArgumentInterface; /** * 非法数据异常 */ -class InvalidArgumentException extends \InvalidArgumentException implements Psr6CacheInvalidArgumentInterface, SimpleCacheInvalidArgumentInterface +class InvalidArgumentException extends \InvalidArgumentException implements SimpleCacheInvalidArgumentInterface { } diff --git a/vendor/topthink/framework/src/think/facade/App.php b/vendor/topthink/framework/src/think/facade/App.php index e9f8105..b30d4ac 100644 --- a/vendor/topthink/framework/src/think/facade/App.php +++ b/vendor/topthink/framework/src/think/facade/App.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Cache.php b/vendor/topthink/framework/src/think/facade/Cache.php index aac105d..14350ec 100644 --- a/vendor/topthink/framework/src/think/facade/Cache.php +++ b/vendor/topthink/framework/src/think/facade/Cache.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Config.php b/vendor/topthink/framework/src/think/facade/Config.php index 4ce73dd..e392af6 100644 --- a/vendor/topthink/framework/src/think/facade/Config.php +++ b/vendor/topthink/framework/src/think/facade/Config.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Console.php b/vendor/topthink/framework/src/think/facade/Console.php index 30dd935..ca2bb43 100644 --- a/vendor/topthink/framework/src/think/facade/Console.php +++ b/vendor/topthink/framework/src/think/facade/Console.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Cookie.php b/vendor/topthink/framework/src/think/facade/Cookie.php index 960f4a3..1d29c27 100644 --- a/vendor/topthink/framework/src/think/facade/Cookie.php +++ b/vendor/topthink/framework/src/think/facade/Cookie.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Env.php b/vendor/topthink/framework/src/think/facade/Env.php index bed2538..44f4a2a 100644 --- a/vendor/topthink/framework/src/think/facade/Env.php +++ b/vendor/topthink/framework/src/think/facade/Env.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Event.php b/vendor/topthink/framework/src/think/facade/Event.php index c09d816..6429669 100644 --- a/vendor/topthink/framework/src/think/facade/Event.php +++ b/vendor/topthink/framework/src/think/facade/Event.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Filesystem.php b/vendor/topthink/framework/src/think/facade/Filesystem.php deleted file mode 100644 index 53706a8..0000000 --- a/vendor/topthink/framework/src/think/facade/Filesystem.php +++ /dev/null @@ -1,33 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\facade; - -use think\Facade; -use think\filesystem\Driver; - -/** - * Class Filesystem - * @package think\facade - * @mixin \think\Filesystem - * @method static Driver disk(string $name = null) ,null|string - * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置 - * @method static array getDiskConfig(string $disk, null $name = null, null $default = null) 获取磁盘配置 - * @method static string|null getDefaultDriver() 默认驱动 - */ -class Filesystem extends Facade -{ - protected static function getFacadeClass() - { - return 'filesystem'; - } -} diff --git a/vendor/topthink/framework/src/think/facade/Lang.php b/vendor/topthink/framework/src/think/facade/Lang.php index b460fe2..ff22bfd 100644 --- a/vendor/topthink/framework/src/think/facade/Lang.php +++ b/vendor/topthink/framework/src/think/facade/Lang.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Log.php b/vendor/topthink/framework/src/think/facade/Log.php index 7c43d37..cf07882 100644 --- a/vendor/topthink/framework/src/think/facade/Log.php +++ b/vendor/topthink/framework/src/think/facade/Log.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Middleware.php b/vendor/topthink/framework/src/think/facade/Middleware.php index 4203f82..426501c 100644 --- a/vendor/topthink/framework/src/think/facade/Middleware.php +++ b/vendor/topthink/framework/src/think/facade/Middleware.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Request.php b/vendor/topthink/framework/src/think/facade/Request.php index 6531f46..f665444 100644 --- a/vendor/topthink/framework/src/think/facade/Request.php +++ b/vendor/topthink/framework/src/think/facade/Request.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; @@ -115,10 +115,10 @@ use think\route\Rule; * @method static mixed __set(string $name, mixed $value) 设置中间传递数据 * @method static mixed __get(string $name) 获取中间传递数据的值 * @method static boolean __isset(string $name) 检测中间传递数据的值 - * @method static bool offsetExists($name) - * @method static mixed offsetGet($name) - * @method static mixed offsetSet($name, $value) - * @method static mixed offsetUnset($name) + * @method static bool offsetExists(mixed $name) + * @method static mixed offsetGet(mixed $name) + * @method static mixed offsetSet(mixed $name, $value) + * @method static mixed offsetUnset(mixed $name) */ class Request extends Facade { diff --git a/vendor/topthink/framework/src/think/facade/Route.php b/vendor/topthink/framework/src/think/facade/Route.php index 1b9a872..550359e 100644 --- a/vendor/topthink/framework/src/think/facade/Route.php +++ b/vendor/topthink/framework/src/think/facade/Route.php @@ -2,18 +2,17 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; use think\Facade; -use think\Response; use think\route\Dispatch; use think\route\Domain; use think\route\Rule; @@ -21,7 +20,6 @@ use think\route\RuleGroup; use think\route\RuleItem; use think\route\RuleName; use think\route\Url as UrlBuild; -use think\route\ResourceRegister as Resource; /** * @see \think\Route @@ -29,8 +27,6 @@ use think\route\ResourceRegister as Resource; * @mixin \think\Route * @method static mixed config(string $name = null) * @method static \think\Route lazy(bool $lazy = true) 设置路由域名及分组(包括资源路由)是否延迟解析 - * @method static void setTestMode(bool $test) 设置路由为测试模式 - * @method static bool isTest() 检查路由是否为测试模式 * @method static \think\Route mergeRuleRegex(bool $merge = true) 设置路由域名及分组(包括资源路由)是否合并解析 * @method static void setGroup(RuleGroup $group) 设置当前分组 * @method static RuleGroup getGroup(string $name = null) 获取指定标识的路由分组 不指定则获取当前分组 @@ -66,7 +62,7 @@ use think\route\ResourceRegister as Resource; * @method static \think\Route rest(string|array $name, array|bool $resource = []) rest方法定义和修改 * @method static array|null getRest(string $name = null) 获取rest方法定义的参数 * @method static RuleItem miss(string|\Closure $route, string $method = '*') 注册未匹配路由规则后的处理 - * @method static Response dispatch(\think\Request $request, \Closure|bool $withRoute = true) 路由调度 + * @method static Response dispatch(\think\Request $request, Closure|bool $withRoute = true) 路由调度 * @method static Dispatch|false check() 检测URL路由 * @method static Dispatch url(string $url) 默认URL解析 * @method static UrlBuild buildUrl(string $url = '', array $vars = []) URL生成 支持路由反射 diff --git a/vendor/topthink/framework/src/think/facade/Session.php b/vendor/topthink/framework/src/think/facade/Session.php index 68bf993..1e5e12a 100644 --- a/vendor/topthink/framework/src/think/facade/Session.php +++ b/vendor/topthink/framework/src/think/facade/Session.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/Validate.php b/vendor/topthink/framework/src/think/facade/Validate.php index 6db6d34..195fb56 100644 --- a/vendor/topthink/framework/src/think/facade/Validate.php +++ b/vendor/topthink/framework/src/think/facade/Validate.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/facade/View.php b/vendor/topthink/framework/src/think/facade/View.php index acde3b5..c3e2d54 100644 --- a/vendor/topthink/framework/src/think/facade/View.php +++ b/vendor/topthink/framework/src/think/facade/View.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\facade; diff --git a/vendor/topthink/framework/src/think/file/UploadedFile.php b/vendor/topthink/framework/src/think/file/UploadedFile.php index 7dff766..2909966 100644 --- a/vendor/topthink/framework/src/think/file/UploadedFile.php +++ b/vendor/topthink/framework/src/think/file/UploadedFile.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\file; @@ -81,28 +81,14 @@ class UploadedFile extends File */ protected function getErrorMessage(): string { - switch ($this->error) { - case 1: - case 2: - $message = 'upload File size exceeds the maximum value'; - break; - case 3: - $message = 'only the portion of file is uploaded'; - break; - case 4: - $message = 'no file to uploaded'; - break; - case 6: - $message = 'upload temp dir not found'; - break; - case 7: - $message = 'file write error'; - break; - default: - $message = 'unknown upload error'; - } - - return $message; + return match ($this->error) { + 1,2 => 'upload File size exceeds the maximum value', + 3 => 'only the portion of file is uploaded', + 4 => 'no file to uploaded', + 6 => 'upload temp dir not found', + 7 => 'file write error', + default => 'unknown upload error', + }; } /** diff --git a/vendor/topthink/framework/src/think/filesystem/CacheStore.php b/vendor/topthink/framework/src/think/filesystem/CacheStore.php deleted file mode 100644 index 0a62399..0000000 --- a/vendor/topthink/framework/src/think/filesystem/CacheStore.php +++ /dev/null @@ -1,54 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\Cached\Storage\AbstractCache; -use Psr\SimpleCache\CacheInterface; - -class CacheStore extends AbstractCache -{ - protected $store; - - protected $key; - - protected $expire; - - public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null) - { - $this->key = $key; - $this->store = $store; - $this->expire = $expire; - } - - /** - * Store the cache. - */ - public function save() - { - $contents = $this->getForStorage(); - - $this->store->set($this->key, $contents, $this->expire); - } - - /** - * Load the cache. - */ - public function load() - { - $contents = $this->store->get($this->key); - - if (!is_null($contents)) { - $this->setFromStorage($contents); - } - } -} diff --git a/vendor/topthink/framework/src/think/filesystem/Driver.php b/vendor/topthink/framework/src/think/filesystem/Driver.php deleted file mode 100644 index 0e61cf4..0000000 --- a/vendor/topthink/framework/src/think/filesystem/Driver.php +++ /dev/null @@ -1,144 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\AbstractAdapter; -use League\Flysystem\Cached\CachedAdapter; -use League\Flysystem\Cached\Storage\Memory as MemoryStore; -use League\Flysystem\Filesystem; -use RuntimeException; -use think\Cache; -use think\File; - -/** - * Class Driver - * @package think\filesystem - * @mixin Filesystem - */ -abstract class Driver -{ - - /** @var Cache */ - protected $cache; - - /** @var Filesystem */ - protected $filesystem; - - /** - * 配置参数 - * @var array - */ - protected $config = []; - - public function __construct(Cache $cache, array $config) - { - $this->cache = $cache; - $this->config = array_merge($this->config, $config); - - $adapter = $this->createAdapter(); - $this->filesystem = $this->createFilesystem($adapter); - } - - protected function createCacheStore($config) - { - if (true === $config) { - return new MemoryStore; - } - - return new CacheStore( - $this->cache->store($config['store']), - $config['prefix'] ?? 'flysystem', - $config['expire'] ?? null - ); - } - - abstract protected function createAdapter(): AdapterInterface; - - protected function createFilesystem(AdapterInterface $adapter): Filesystem - { - if (!empty($this->config['cache'])) { - $adapter = new CachedAdapter($adapter, $this->createCacheStore($this->config['cache'])); - } - - $config = array_intersect_key($this->config, array_flip(['visibility', 'disable_asserts', 'url'])); - - return new Filesystem($adapter, count($config) > 0 ? $config : null); - } - - /** - * 获取文件完整路径 - * @param string $path - * @return string - */ - public function path(string $path): string - { - $adapter = $this->filesystem->getAdapter(); - - if ($adapter instanceof AbstractAdapter) { - return $adapter->applyPathPrefix($path); - } - - return $path; - } - - protected function concatPathToUrl($url, $path) - { - return rtrim($url, '/') . '/' . ltrim($path, '/'); - } - - public function url(string $path): string - { - throw new RuntimeException('This driver does not support retrieving URLs.'); - } - - /** - * 保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param null|string|\Closure $rule 文件名规则 - * @param array $options 参数 - * @return bool|string - */ - public function putFile(string $path, File $file, $rule = null, array $options = []) - { - return $this->putFileAs($path, $file, $file->hashName($rule), $options); - } - - /** - * 指定文件名保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param string $name 文件名 - * @param array $options 参数 - * @return bool|string - */ - public function putFileAs(string $path, File $file, string $name, array $options = []) - { - $stream = fopen($file->getRealPath(), 'r'); - $path = trim($path . '/' . $name, '/'); - - $result = $this->putStream($path, $stream, $options); - - if (is_resource($stream)) { - fclose($stream); - } - - return $result ? $path : false; - } - - public function __call($method, $parameters) - { - return $this->filesystem->$method(...$parameters); - } -} diff --git a/vendor/topthink/framework/src/think/filesystem/driver/Local.php b/vendor/topthink/framework/src/think/filesystem/driver/Local.php deleted file mode 100644 index 5749335..0000000 --- a/vendor/topthink/framework/src/think/filesystem/driver/Local.php +++ /dev/null @@ -1,59 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem\driver; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\Local as LocalAdapter; -use think\filesystem\Driver; - -class Local extends Driver -{ - /** - * 配置参数 - * @var array - */ - protected $config = [ - 'root' => '', - ]; - - protected function createAdapter(): AdapterInterface - { - $permissions = $this->config['permissions'] ?? []; - - $links = ($this->config['links'] ?? null) === 'skip' - ? LocalAdapter::SKIP_LINKS - : LocalAdapter::DISALLOW_LINKS; - - return new LocalAdapter( - $this->config['root'], - LOCK_EX, - $links, - $permissions - ); - } - - /** - * 获取文件访问地址 - * @param string $path 文件路径 - * @return string - */ - public function url(string $path): string - { - $path = str_replace('\\', '/', $path); - - if (isset($this->config['url'])) { - return $this->concatPathToUrl($this->config['url'], $path); - } - return parent::url($path); - } -} diff --git a/vendor/topthink/framework/src/think/initializer/BootService.php b/vendor/topthink/framework/src/think/initializer/BootService.php index bab6d39..0545f3c 100644 --- a/vendor/topthink/framework/src/think/initializer/BootService.php +++ b/vendor/topthink/framework/src/think/initializer/BootService.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\initializer; diff --git a/vendor/topthink/framework/src/think/initializer/Error.php b/vendor/topthink/framework/src/think/initializer/Error.php index 201d947..4e8d02e 100644 --- a/vendor/topthink/framework/src/think/initializer/Error.php +++ b/vendor/topthink/framework/src/think/initializer/Error.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: 麦当苗儿 // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\initializer; @@ -55,7 +55,9 @@ class Error if ($this->app->runningInConsole()) { $handler->renderForConsole(new ConsoleOutput, $e); } else { - $handler->render($this->app->request, $e)->send(); + $response = $handler->render($this->app->request, $e); + $response->send(); + $this->app->http->end($response); } } diff --git a/vendor/topthink/framework/src/think/initializer/RegisterService.php b/vendor/topthink/framework/src/think/initializer/RegisterService.php index b682a0b..77c62b8 100644 --- a/vendor/topthink/framework/src/think/initializer/RegisterService.php +++ b/vendor/topthink/framework/src/think/initializer/RegisterService.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\initializer; diff --git a/vendor/topthink/framework/src/think/log/Channel.php b/vendor/topthink/framework/src/think/log/Channel.php index 1de96f1..ee7c33e 100644 --- a/vendor/topthink/framework/src/think/log/Channel.php +++ b/vendor/topthink/framework/src/think/log/Channel.php @@ -2,17 +2,19 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\log; use Psr\Log\LoggerInterface; +use Psr\Log\LoggerTrait; +use Stringable; use think\contract\LogHandlerInterface; use think\Event; use think\event\LogRecord; @@ -20,11 +22,14 @@ use think\event\LogWrite; class Channel implements LoggerInterface { - protected $name; - protected $logger; + use LoggerTrait; + + /** + * 事件 + * @var Event + */ protected $event; - protected $lazy = true; /** * 日志信息 * @var array @@ -37,25 +42,14 @@ class Channel implements LoggerInterface */ protected $close = false; - /** - * 允许写入类型 - * @var array - */ - protected $allow = []; - - public function __construct(string $name, LogHandlerInterface $logger, array $allow, bool $lazy = true, Event $event = null) + public function __construct(protected string $name, protected LogHandlerInterface $logger, protected array $allow = [], protected bool $lazy = true, Event $event = null) { - $this->name = $name; - $this->logger = $logger; - $this->allow = $allow; - $this->lazy = $lazy; - $this->event = $event; } /** * 关闭通道 */ - public function close() + public function close(): void { $this->clear(); $this->close = true; @@ -64,7 +58,7 @@ class Channel implements LoggerInterface /** * 清空日志 */ - public function clear() + public function clear(): void { $this->log = []; } @@ -84,6 +78,10 @@ class Channel implements LoggerInterface return $this; } + if ($msg instanceof Stringable) { + $msg = $msg->__toString(); + } + if (is_string($msg) && !empty($context)) { $replace = []; foreach ($context as $key => $val) { @@ -150,131 +148,16 @@ class Channel implements LoggerInterface return false; } - /** - * System is unusable. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function emergency($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function alert($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function critical($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function error($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function warning($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function notice($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function info($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return void - */ - public function debug($message, array $context = []) - { - $this->log(__FUNCTION__, $message, $context); - } - /** * Logs with an arbitrary level. * * @param mixed $level - * @param string $message + * @param string|Stringable $message * @param array $context * * @return void */ - public function log($level, $message, array $context = []) + public function log($level, string|Stringable $message, array $context = []): void { $this->record($message, $level, $context); } diff --git a/vendor/topthink/framework/src/think/log/ChannelSet.php b/vendor/topthink/framework/src/think/log/ChannelSet.php index 6dcb0bd..0a227af 100644 --- a/vendor/topthink/framework/src/think/log/ChannelSet.php +++ b/vendor/topthink/framework/src/think/log/ChannelSet.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\log; @@ -21,13 +21,8 @@ use think\Log; */ class ChannelSet { - protected $log; - protected $channels; - - public function __construct(Log $log, array $channels) + public function __construct(protected Log $log, protected array $channels) { - $this->log = $log; - $this->channels = $channels; } public function __call($method, $arguments) diff --git a/vendor/topthink/framework/src/think/log/driver/Socket.php b/vendor/topthink/framework/src/think/log/driver/Socket.php index 2cfb943..427dab6 100644 --- a/vendor/topthink/framework/src/think/log/driver/Socket.php +++ b/vendor/topthink/framework/src/think/log/driver/Socket.php @@ -22,8 +22,6 @@ use think\contract\LogHandlerInterface; */ class Socket implements LogHandlerInterface { - protected $app; - protected $config = [ // socket服务器地址 'host' => 'localhost', @@ -66,10 +64,8 @@ class Socket implements LogHandlerInterface * @param App $app * @param array $config 缓存参数 */ - public function __construct(App $app, array $config = []) + public function __construct(protected App $app, array $config = []) { - $this->app = $app; - if (!empty($config)) { $this->config = array_merge($this->config, $config); } diff --git a/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php b/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php index b7ab842..7f258ed 100644 --- a/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php +++ b/vendor/topthink/framework/src/think/middleware/AllowCrossDomain.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\middleware; @@ -44,14 +44,14 @@ class AllowCrossDomain * @param array $header * @return Response */ - public function handle($request, Closure $next, ? array $header = []) + public function handle(Request $request, Closure $next, array $header = []): Response { $header = !empty($header) ? array_merge($this->header, $header) : $this->header; if (!isset($header['Access-Control-Allow-Origin'])) { $origin = $request->header('origin'); - if ($origin && ('' == $this->cookieDomain || strpos($origin, $this->cookieDomain))) { + if ($origin && ('' == $this->cookieDomain || str_contains($origin, $this->cookieDomain))) { $header['Access-Control-Allow-Origin'] = $origin; } else { $header['Access-Control-Allow-Origin'] = '*'; diff --git a/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php b/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php index b114351..c3e7e57 100644 --- a/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php +++ b/vendor/topthink/framework/src/think/middleware/CheckRequestCache.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\middleware; @@ -58,7 +58,7 @@ class CheckRequestCache * @param mixed $cache * @return Response */ - public function handle($request, Closure $next, $cache = null) + public function handle(Request $request, Closure $next, $cache = null): Response { if ($request->isGet() && false !== $cache) { if (false === $this->config['request_cache_key']) { @@ -70,11 +70,11 @@ class CheckRequestCache if ($cache) { if (is_array($cache)) { - [$key, $expire, $tag] = array_pad($cache, 3, null); + [$key, $expire, $tag] = array_pad($cache, 3, ''); } else { $key = md5($request->url(true)); $expire = $cache; - $tag = null; + $tag = ''; } $key = $this->parseCacheKey($request, $key); @@ -136,7 +136,7 @@ class CheckRequestCache */ protected function parseCacheKey($request, $key) { - if ($key instanceof \Closure) { + if ($key instanceof Closure) { $key = call_user_func($key, $request); } @@ -148,24 +148,24 @@ class CheckRequestCache if (true === $key) { // 自动缓存功能 $key = '__URL__'; - } elseif (strpos($key, '|')) { + } elseif (str_contains($key, '|')) { [$key, $fun] = explode('|', $key); } // 特殊规则替换 - if (false !== strpos($key, '__')) { + if (str_contains($key, '__')) { $key = str_replace(['__CONTROLLER__', '__ACTION__', '__URL__'], [$request->controller(), $request->action(), md5($request->url(true))], $key); } - if (false !== strpos($key, ':')) { + if (str_contains($key, ':')) { $param = $request->param(); foreach ($param as $item => $val) { - if (is_string($val) && false !== strpos($key, ':' . $item)) { + if (is_string($val) && str_contains($key, ':' . $item)) { $key = str_replace(':' . $item, (string) $val, $key); } } - } elseif (strpos($key, ']')) { + } elseif (str_contains($key, ']')) { if ('[' . $request->ext() . ']' == $key) { // 缓存某个后缀的请求 $key = md5($request->url()); diff --git a/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php b/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php index efbb77b..542d396 100644 --- a/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php +++ b/vendor/topthink/framework/src/think/middleware/FormTokenCheck.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\middleware; @@ -31,7 +31,7 @@ class FormTokenCheck * @param string $token 表单令牌Token名称 * @return Response */ - public function handle(Request $request, Closure $next, string $token = null) + public function handle(Request $request, Closure $next, string $token = null): Response { $check = $request->checkToken($token ?: '__token__'); @@ -41,5 +41,4 @@ class FormTokenCheck return $next($request); } - } diff --git a/vendor/topthink/framework/src/think/middleware/LoadLangPack.php b/vendor/topthink/framework/src/think/middleware/LoadLangPack.php index af0324b..82e6a98 100644 --- a/vendor/topthink/framework/src/think/middleware/LoadLangPack.php +++ b/vendor/topthink/framework/src/think/middleware/LoadLangPack.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\middleware; @@ -25,14 +25,10 @@ use think\Response; */ class LoadLangPack { - protected $app; - protected $lang; protected $config; - public function __construct(App $app, Lang $lang, Config $config) + public function __construct(protected App $app, protected Lang $lang, Config $config) { - $this->app = $app; - $this->lang = $lang; $this->config = $lang->getConfig(); } @@ -43,7 +39,7 @@ class LoadLangPack * @param Closure $next * @return Response */ - public function handle($request, Closure $next) + public function handle(Request $request, Closure $next): Response { // 自动侦测当前语言 $langset = $this->detect($request); @@ -108,11 +104,10 @@ class LoadLangPack * @param string $langSet 语言 * @return void */ - protected function saveToCookie(Cookie $cookie, string $langSet) + protected function saveToCookie(Cookie $cookie, string $langSet): void { if ($this->config['use_cookie']) { $cookie->set($this->config['cookie_var'], $langSet); } } - } diff --git a/vendor/topthink/framework/src/think/middleware/SessionInit.php b/vendor/topthink/framework/src/think/middleware/SessionInit.php index 55cea3b..3f2c454 100644 --- a/vendor/topthink/framework/src/think/middleware/SessionInit.php +++ b/vendor/topthink/framework/src/think/middleware/SessionInit.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\middleware; @@ -23,17 +23,8 @@ use think\Session; */ class SessionInit { - - /** @var App */ - protected $app; - - /** @var Session */ - protected $session; - - public function __construct(App $app, Session $session) + public function __construct(protected App $app, protected Session $session) { - $this->app = $app; - $this->session = $session; } /** @@ -43,7 +34,7 @@ class SessionInit * @param Closure $next * @return Response */ - public function handle($request, Closure $next) + public function handle(Request $request, Closure $next): Response { // Session初始化 $varSessionId = $this->app->config->get('session.var_session_id'); @@ -73,7 +64,7 @@ class SessionInit return $response; } - public function end(Response $response) + public function end(Response $response): void { $this->session->save(); } diff --git a/vendor/topthink/framework/src/think/response/File.php b/vendor/topthink/framework/src/think/response/File.php index 1e45f2f..22a442c 100644 --- a/vendor/topthink/framework/src/think/response/File.php +++ b/vendor/topthink/framework/src/think/response/File.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -151,7 +151,7 @@ class File extends Response { $this->name = $filename; - if ($extension && false === strpos($filename, '.')) { + if ($extension && !str_contains($filename, '.')) { $this->name .= '.' . pathinfo($this->data, PATHINFO_EXTENSION); } diff --git a/vendor/topthink/framework/src/think/response/Html.php b/vendor/topthink/framework/src/think/response/Html.php index c158f78..11170f2 100644 --- a/vendor/topthink/framework/src/think/response/Html.php +++ b/vendor/topthink/framework/src/think/response/Html.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; diff --git a/vendor/topthink/framework/src/think/response/Json.php b/vendor/topthink/framework/src/think/response/Json.php index a84501f..0196c30 100644 --- a/vendor/topthink/framework/src/think/response/Json.php +++ b/vendor/topthink/framework/src/think/response/Json.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -58,5 +58,4 @@ class Json extends Response throw $e; } } - } diff --git a/vendor/topthink/framework/src/think/response/Jsonp.php b/vendor/topthink/framework/src/think/response/Jsonp.php index 81d3a06..3a9b3fe 100644 --- a/vendor/topthink/framework/src/think/response/Jsonp.php +++ b/vendor/topthink/framework/src/think/response/Jsonp.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -70,5 +70,4 @@ class Jsonp extends Response throw $e; } } - } diff --git a/vendor/topthink/framework/src/think/response/Redirect.php b/vendor/topthink/framework/src/think/response/Redirect.php index c6d71ae..b984307 100644 --- a/vendor/topthink/framework/src/think/response/Redirect.php +++ b/vendor/topthink/framework/src/think/response/Redirect.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -45,7 +45,7 @@ class Redirect extends Response /** * 处理数据 * @access protected - * @param mixed $data 要处理的数据 + * @param mixed $data 要处理的数据 * @return string */ protected function output($data): string @@ -56,8 +56,8 @@ class Redirect extends Response /** * 重定向传值(通过Session) * @access protected - * @param string|array $name 变量名或者数组 - * @param mixed $value 值 + * @param string|array $name 变量名或者数组 + * @param mixed $value 值 * @return $this */ public function with($name, $value = null) diff --git a/vendor/topthink/framework/src/think/response/View.php b/vendor/topthink/framework/src/think/response/View.php index 2c116c7..65f41e9 100644 --- a/vendor/topthink/framework/src/think/response/View.php +++ b/vendor/topthink/framework/src/think/response/View.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -88,8 +88,8 @@ class View extends Response // 渲染模板输出 $this->view->filter($this->filter); return $this->isContent ? - $this->view->display($data, $this->vars) : - $this->view->fetch($data, $this->vars); + $this->view->display($data, $this->vars) : + $this->view->fetch($data, $this->vars); } /** @@ -114,7 +114,7 @@ class View extends Response * @param mixed $value 变量值 * @return $this */ - public function assign($name, $value = null) + public function assign(string|array $name, $value = null) { if (is_array($name)) { $this->vars = array_merge($this->vars, $name); @@ -147,5 +147,4 @@ class View extends Response { return $this->view->exists($name); } - } diff --git a/vendor/topthink/framework/src/think/response/Xml.php b/vendor/topthink/framework/src/think/response/Xml.php index bddbb48..55e24fb 100644 --- a/vendor/topthink/framework/src/think/response/Xml.php +++ b/vendor/topthink/framework/src/think/response/Xml.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\response; @@ -53,7 +53,7 @@ class Xml extends Response protected function output($data): string { if (is_string($data)) { - if (0 !== strpos($data, 'options['encoding']; $xml = ""; $data = $xml . $data; diff --git a/vendor/topthink/framework/src/think/route/Dispatch.php b/vendor/topthink/framework/src/think/route/Dispatch.php index e0baad9..1449e6e 100644 --- a/vendor/topthink/framework/src/think/route/Dispatch.php +++ b/vendor/topthink/framework/src/think/route/Dispatch.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -26,40 +26,12 @@ abstract class Dispatch { /** * 应用对象 - * @var \think\App + * @var App */ protected $app; - /** - * 请求对象 - * @var Request - */ - protected $request; - - /** - * 路由规则 - * @var Rule - */ - protected $rule; - - /** - * 调度信息 - * @var mixed - */ - protected $dispatch; - - /** - * 路由变量 - * @var array - */ - protected $param; - - public function __construct(Request $request, Rule $rule, $dispatch, array $param = []) + public function __construct(protected Request $request, protected Rule $rule, protected $dispatch, protected array $param = []) { - $this->request = $request; - $this->rule = $rule; - $this->dispatch = $dispatch; - $this->param = $param; } public function init(App $app) @@ -73,7 +45,7 @@ abstract class Dispatch /** * 执行路由调度 * @access public - * @return mixed + * @return Response */ public function run(): Response { @@ -182,7 +154,7 @@ abstract class Dispatch if (!empty($result)) { // 注入容器 - $this->app->instance(get_class($result), $result); + $this->app->instance($result::class, $result); } } } @@ -204,7 +176,7 @@ abstract class Dispatch $v->rule($validate); } else { // 调用验证器 - $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); + $class = str_contains($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate); $v = new $class(); diff --git a/vendor/topthink/framework/src/think/route/Domain.php b/vendor/topthink/framework/src/think/route/Domain.php index 4cf03cf..0092637 100644 --- a/vendor/topthink/framework/src/think/route/Domain.php +++ b/vendor/topthink/framework/src/think/route/Domain.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -29,7 +29,7 @@ class Domain extends RuleGroup * @param Route $router 路由对象 * @param string $name 路由域名 * @param mixed $rule 域名路由 - * @param bool $lazy 延迟解析 + * @param bool $lazy 延迟解析 */ public function __construct(Route $router, string $name = null, $rule = null, bool $lazy = false) { @@ -37,7 +37,7 @@ class Domain extends RuleGroup $this->domain = $name; $this->rule = $rule; - if (!$lazy) { + if (!$lazy && !is_null($rule)) { $this->parseGroupRule($rule); } } @@ -114,7 +114,7 @@ class Domain extends RuleGroup protected function parseBindAppendParam(string &$bind): void { - if (false !== strpos($bind, '?')) { + if (str_contains($bind, '?')) { [$bind, $query] = explode('?', $bind); parse_str($query, $vars); $this->append($vars); @@ -132,7 +132,7 @@ class Domain extends RuleGroup protected function bindToClass(Request $request, string $url, string $class): CallbackDispatch { $array = explode('|', $url, 2); - $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); + $action = !empty($array[0]) ? $array[0] : $this->config('default_action'); $param = []; if (!empty($array[1])) { @@ -153,8 +153,8 @@ class Domain extends RuleGroup protected function bindToNamespace(Request $request, string $url, string $namespace): CallbackDispatch { $array = explode('|', $url, 3); - $class = !empty($array[0]) ? $array[0] : $this->router->config('default_controller'); - $method = !empty($array[1]) ? $array[1] : $this->router->config('default_action'); + $class = !empty($array[0]) ? $array[0] : $this->config('default_controller'); + $method = !empty($array[1]) ? $array[1] : $this->config('default_action'); $param = []; if (!empty($array[2])) { @@ -175,7 +175,7 @@ class Domain extends RuleGroup protected function bindToController(Request $request, string $url, string $controller): ControllerDispatch { $array = explode('|', $url, 2); - $action = !empty($array[0]) ? $array[0] : $this->router->config('default_action'); + $action = !empty($array[0]) ? $array[0] : $this->config('default_action'); $param = []; if (!empty($array[1])) { @@ -184,5 +184,4 @@ class Domain extends RuleGroup return new ControllerDispatch($request, $this, $controller . '/' . $action, $param); } - } diff --git a/vendor/topthink/framework/src/think/route/Resource.php b/vendor/topthink/framework/src/think/route/Resource.php index 33cd824..a049486 100644 --- a/vendor/topthink/framework/src/think/route/Resource.php +++ b/vendor/topthink/framework/src/think/route/Resource.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -46,11 +46,11 @@ class Resource extends RuleGroup /** * 架构函数 * @access public - * @param Route $router 路由对象 - * @param RuleGroup|null $parent 上级对象 - * @param string $name 资源名称 - * @param string $route 路由地址 - * @param array $rest 资源定义 + * @param Route $router 路由对象 + * @param RuleGroup $parent 上级对象 + * @param string $name 资源名称 + * @param string $route 路由地址 + * @param array $rest 资源定义 */ public function __construct(Route $router, RuleGroup $parent = null, string $name = '', string $route = '', array $rest = []) { @@ -59,7 +59,7 @@ class Resource extends RuleGroup $this->parent = $parent; $this->rule = $name; $this->route = $route; - $this->name = strpos($name, '.') ? strstr($name, '.', true) : $name; + $this->name = str_contains($name, '.') ? strstr($name, '.', true) : $name; $this->setFullName(); @@ -75,7 +75,7 @@ class Resource extends RuleGroup } /** - * 解析资源路由规则 + * 生成资源路由规则 * @access public * @param mixed $rule 路由规则 * @return void @@ -86,7 +86,7 @@ class Resource extends RuleGroup $origin = $this->router->getGroup(); $this->router->setGroup($this); - if (strpos($rule, '.')) { + if (str_contains($rule, '.')) { // 注册嵌套资源路由 $array = explode('.', $rule); $last = array_pop($array); @@ -104,13 +104,14 @@ class Resource extends RuleGroup // 注册资源路由 foreach ($this->rest as $key => $val) { if ((isset($option['only']) && !in_array($key, $option['only'])) - || (isset($option['except']) && in_array($key, $option['except']))) { + || (isset($option['except']) && in_array($key, $option['except'])) + ) { continue; } - if (isset($last) && strpos($val[1], '') && isset($option['var'][$last])) { + if (isset($last) && str_contains($val[1], '') && isset($option['var'][$last])) { $val[1] = str_replace('', '<' . $option['var'][$last] . '>', $val[1]); - } elseif (strpos($val[1], '') && isset($option['var'][$rule])) { + } elseif (str_contains($val[1], '') && isset($option['var'][$rule])) { $val[1] = str_replace('', '<' . $option['var'][$rule] . '>', $val[1]); } @@ -120,7 +121,6 @@ class Resource extends RuleGroup if (isset($this->$name[$key])) { call_user_func_array([$ruleItem, $name], (array) $this->$name[$key]); } - } } @@ -168,7 +168,7 @@ class Resource extends RuleGroup * @param array|string $validate 验证信息 * @return $this */ - public function withValidate($name, $validate = []) + public function withValidate(array|string $name, array|string $validate = []) { if (is_array($name)) { $this->validate = array_merge($this->validate, $name); @@ -186,7 +186,7 @@ class Resource extends RuleGroup * @param array|string $model 模型绑定 * @return $this */ - public function withModel($name, $model = []) + public function withModel(array|string $name, array|string $model = []) { if (is_array($name)) { $this->model = array_merge($this->model, $name); @@ -204,7 +204,7 @@ class Resource extends RuleGroup * @param array|string $middleware 中间件定义 * @return $this */ - public function withMiddleware($name, $middleware = []) + public function withMiddleware(array|string $name, array|string $middleware = []) { if (is_array($name)) { $this->middleware = array_merge($this->middleware, $name); @@ -222,7 +222,7 @@ class Resource extends RuleGroup * @param array|bool $resource 资源 * @return $this */ - public function rest($name, $resource = []) + public function rest(array|string $name, array|bool $resource = []) { if (is_array($name)) { $this->rest = $resource ? $name : array_merge($this->rest, $name); @@ -232,5 +232,4 @@ class Resource extends RuleGroup return $this; } - } diff --git a/vendor/topthink/framework/src/think/route/Rule.php b/vendor/topthink/framework/src/think/route/Rule.php index e909e78..883a517 100644 --- a/vendor/topthink/framework/src/think/route/Rule.php +++ b/vendor/topthink/framework/src/think/route/Rule.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -336,6 +336,17 @@ abstract class Rule return $this->setOption('domain', $domain); } + /** + * 是否区分大小写 + * @access public + * @param bool $case 是否区分 + * @return $this + */ + public function caseUrl(bool $case) + { + return $this->setOption('case_sensitive', $case); + } + /** * 设置参数过滤检查 * @access public @@ -357,7 +368,7 @@ abstract class Rule * @param bool $exception 是否抛出异常 * @return $this */ - public function model($var, $model = null, bool $exception = true) + public function model(array|string|Closure $var, string|Closure $model = null, bool $exception = true) { if ($var instanceof Closure) { $this->option['model'][] = $var; @@ -408,7 +419,7 @@ abstract class Rule * @param mixed $params 参数 * @return $this */ - public function middleware($middleware, ...$params) + public function middleware(string|array|Closure $middleware, ...$params) { if (empty($params) && is_array($middleware)) { $this->option['middleware'] = $middleware; @@ -449,7 +460,7 @@ abstract class Rule * @param array|string $cache 缓存 * @return $this */ - public function cache($cache) + public function cache(array|string $cache) { return $this->middleware(CheckRequestCache::class, $cache); } @@ -597,7 +608,7 @@ abstract class Rule // 替换路由地址中的变量 $extraParams = true; $search = $replace = []; - $depr = $this->router->config('pathinfo_depr'); + $depr = $this->config('pathinfo_depr'); foreach ($matches as $key => $value) { $search[] = '<' . $key . '>'; $replace[] = $value; @@ -605,7 +616,7 @@ abstract class Rule $search[] = ':' . $key; $replace[] = $value; - if (strpos($value, $depr)) { + if (str_contains($value, $depr)) { $extraParams = false; } } @@ -642,7 +653,7 @@ abstract class Rule } elseif ($route instanceof Closure) { // 执行闭包 $result = new CallbackDispatch($request, $this, $route, $this->vars); - } elseif (false !== strpos($route, '@') || false !== strpos($route, '::') || false !== strpos($route, '\\')) { + } elseif (str_contains($route, '@') || str_contains($route, '::') || str_contains($route, '\\')) { // 路由到类的方法 $route = str_replace('::', '@', $route); $result = $this->dispatchMethod($request, $route); @@ -666,7 +677,7 @@ abstract class Rule $path = $this->parseUrlPath($route); $route = str_replace('/', '@', implode('/', $path)); - $method = strpos($route, '@') ? explode('@', $route) : $route; + $method = str_contains($route, '@') ? explode('@', $route) : $route; return new CallbackDispatch($request, $this, $method, $this->vars); } @@ -735,14 +746,15 @@ abstract class Rule // HTTPS检查 if ((isset($option['https']) && $option['https'] && !$request->isSsl()) - || (isset($option['https']) && !$option['https'] && $request->isSsl())) { + || (isset($option['https']) && !$option['https'] && $request->isSsl()) + ) { return false; } // 请求参数检查 if (isset($option['filter'])) { foreach ($option['filter'] as $name => $value) { - if ($request->param($name, '', null) != $value) { + if ($request->param($name, '') != $value) { return false; } } @@ -779,7 +791,7 @@ abstract class Rule $url = str_replace('|', '/', $url); $url = trim($url, '/'); - if (strpos($url, '/')) { + if (str_contains($url, '/')) { // [控制器/操作] $path = explode('/', $url); } else { @@ -814,7 +826,7 @@ abstract class Rule if ('/' != $rule) { if (!empty($option['remove_slash'])) { $rule = rtrim($rule, '/'); - } elseif (substr($rule, -1) == '/') { + } elseif (str_ends_with($rule, '/')) { $rule = rtrim($rule, '/'); $hasSlash = true; } @@ -855,20 +867,20 @@ abstract class Rule return ''; } - if (strpos($name, '?')) { + if (str_contains($name, '?')) { $name = substr($name, 1, -2); $optional = '?'; - } elseif (strpos($name, '>')) { + } elseif (str_contains($name, '>')) { $name = substr($name, 1, -1); } if (isset($pattern[$name])) { $nameRule = $pattern[$name]; - if (0 === strpos($nameRule, '/') && '/' == substr($nameRule, -1)) { + if (str_starts_with($nameRule, '/') && str_ends_with($nameRule, '/')) { $nameRule = substr($nameRule, 1, -1); } } else { - $nameRule = $this->router->config('default_route_pattern'); + $nameRule = $this->config('default_route_pattern'); } return '(' . $prefix . '(?<' . $name . $suffix . '>' . $nameRule . '))' . $optional; diff --git a/vendor/topthink/framework/src/think/route/RuleGroup.php b/vendor/topthink/framework/src/think/route/RuleGroup.php index f689dba..b678d32 100644 --- a/vendor/topthink/framework/src/think/route/RuleGroup.php +++ b/vendor/topthink/framework/src/think/route/RuleGroup.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -29,12 +29,6 @@ class RuleGroup extends Rule */ protected $rules = []; - /** - * 是否已经解析 - * @var bool - */ - protected $hasParsed; - /** * MISS路由 * @var RuleItem @@ -53,14 +47,20 @@ class RuleGroup extends Rule */ protected $alias; + /** + * 是否已经解析 + * @var bool + */ + protected $hasParsed; + /** * 架构函数 * @access public - * @param Route $router 路由对象 - * @param RuleGroup|null $parent 上级对象 - * @param string $name 分组名称 - * @param mixed $rule 分组路由 - * @param bool $lazy 延迟解析 + * @param Route $router 路由对象 + * @param RuleGroup $parent 上级对象 + * @param string $name 分组名称 + * @param mixed $rule 分组路由 + * @param bool $lazy 延迟解析 */ public function __construct(Route $router, RuleGroup $parent = null, string $name = '', $rule = null, bool $lazy = false) { @@ -88,7 +88,7 @@ class RuleGroup extends Rule */ protected function setFullName(): void { - if (false !== strpos($this->name, ':')) { + if (str_contains($this->name, ':')) { $this->name = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/'], ['<\1?>', '<\1>'], $this->name); } @@ -229,10 +229,6 @@ class RuleGroup extends Rule */ public function parseGroupRule($rule): void { - if (is_null($rule)) { - return; - } - if (is_string($rule) && is_subclass_of($rule, Dispatch::class)) { $this->dispatcher($rule); return; @@ -262,13 +258,12 @@ class RuleGroup extends Rule */ protected function checkMergeRuleRegex(Request $request, array &$rules, string $url, bool $completeMatch) { - $depr = $this->router->config('pathinfo_depr'); + $depr = $this->config('pathinfo_depr'); $url = $depr . str_replace('|', $depr, $url); $regex = []; $items = []; - foreach ($rules as $key => $val) { - $item = $val[1]; + foreach ($rules as $key => $item) { if ($item instanceof RuleItem) { $rule = $depr . str_replace('/', $depr, $item->getRule()); if ($depr == $rule && $depr != $url) { @@ -278,7 +273,7 @@ class RuleGroup extends Rule $complete = $item->getOption('complete_match', $completeMatch); - if (false === strpos($rule, '<')) { + if (!str_contains($rule, '<')) { if (0 === strcasecmp($rule, $url) || (!$complete && 0 === strncasecmp($rule, $url, strlen($rule)))) { return $item->checkRule($request, $url, []); } @@ -329,7 +324,7 @@ class RuleGroup extends Rule if (!isset($pos)) { foreach ($regex as $key => $item) { - if (0 === strpos(str_replace(['\/', '\-', '\\' . $depr], ['/', '-', $depr], $item), $match[0])) { + if (str_starts_with(str_replace(['\/', '\-', '\\' . $depr], ['/', '-', $depr], $item), $match[0])) { $pos = $key; break; } @@ -354,7 +349,25 @@ class RuleGroup extends Rule } /** - * 获取分组的MISS路由 + * 注册MISS路由 + * @access public + * @param string|Closure $route 路由地址 + * @param string $method 请求类型 + * @return RuleItem + */ + public function miss(string|Closure $route, string $method = '*'): RuleItem + { + // 创建路由规则实例 + $method = strtolower($method); + $ruleItem = new RuleItem($this->router, $this, null, '', $route, $method); + + $this->miss[$method] = $ruleItem->setMiss(); + + return $ruleItem; + } + + /** + * 添加分组下的MISS路由 * @access public * @param string $method 请求类型 * @return RuleItem|null @@ -371,23 +384,6 @@ class RuleGroup extends Rule return $miss; } - /** - * 注册MISS路由 - * @access public - * @param string|Closure $route 路由地址 - * @param string $method 请求类型 - * @return RuleItem - */ - public function miss($route, string $method = '*') : RuleItem - { - // 创建路由规则实例 - $ruleItem = new RuleItem($this->router, $this, null, '', $route, strtolower($method)); - - $this->miss[$method] = $ruleItem->setMiss(); - - return $ruleItem; - } - /** * 添加分组下的路由规则 * @access public @@ -428,7 +424,6 @@ class RuleGroup extends Rule public function addRuleItem(Rule $rule) { $this->rules[] = $rule; - return $this; } @@ -493,7 +488,7 @@ class RuleGroup extends Rule return array_filter($this->rules, function ($item) use ($method) { $ruleMethod = $item->getMethod(); - return '*' == $ruleMethod || false !== strpos($ruleMethod, $method); + return '*' == $ruleMethod || str_contains($ruleMethod, $method); }); } diff --git a/vendor/topthink/framework/src/think/route/RuleItem.php b/vendor/topthink/framework/src/think/route/RuleItem.php index cdde273..68e9c5c 100644 --- a/vendor/topthink/framework/src/think/route/RuleItem.php +++ b/vendor/topthink/framework/src/think/route/RuleItem.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -38,7 +38,7 @@ class RuleItem extends Rule * @access public * @param Route $router 路由实例 * @param RuleGroup $parent 上级对象 - * @param string|null $name 路由标识 + * @param string $name 路由标识 * @param string $rule 路由规则 * @param string|\Closure $route 路由地址 * @param string $method 请求类型 @@ -82,7 +82,7 @@ class RuleItem extends Rule * @access public * @return string|null */ - public function getSuffix() + public function getSuffix(): ?string { if (isset($this->option['ext'])) { $suffix = $this->option['ext']; @@ -103,7 +103,7 @@ class RuleItem extends Rule */ public function setRule(string $rule): void { - if ('$' == substr($rule, -1, 1)) { + if (str_ends_with($rule, '$')) { // 是否完整匹配 $rule = substr($rule, 0, -1); @@ -116,7 +116,7 @@ class RuleItem extends Rule $rule = $prefix . ($rule ? '/' . ltrim($rule, '/') : ''); } - if (false !== strpos($rule, ':')) { + if (str_contains($rule, ':')) { $this->rule = preg_replace(['/\[\:(\w+)\]/', '/\:(\w+)/'], ['<\1?>', '<\1>'], $rule); } else { $this->rule = $rule; @@ -162,7 +162,7 @@ class RuleItem extends Rule * @param bool $completeMatch 路由是否完全匹配 * @return Dispatch|false */ - public function checkRule(Request $request, string $url, $match = null, bool $completeMatch = false) + public function checkRule(Request $request, string $url, array $match = null, bool $completeMatch = false) { // 检查参数有效性 if (!$this->checkOption($this->option, $request)) { @@ -237,10 +237,15 @@ class RuleItem extends Rule $completeMatch = $option['complete_match']; } - $depr = $this->router->config('pathinfo_depr'); + $depr = $this->config('pathinfo_depr'); + if (isset($option['case_sensitive'])) { + $case = $option['case_sensitive']; + } else { + $case = $this->config('url_case_sensitive'); + } // 检查完整规则定义 - if (isset($pattern['__url__']) && !preg_match(0 === strpos($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . ($completeMatch ? '$' : '') . '/', str_replace('|', $depr, $url))) { + if (isset($pattern['__url__']) && !preg_match(str_starts_with($pattern['__url__'], '/') ? $pattern['__url__'] : '/^' . $pattern['__url__'] . ($completeMatch ? '$' : '') . '/', str_replace('|', $depr, $url))) { return false; } @@ -252,8 +257,10 @@ class RuleItem extends Rule return false; } - if (false === strpos($rule, '<')) { - if (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule . $depr, $url . $depr, strlen($rule . $depr)))) { + if (!str_contains($rule, '<')) { + if ($case && (0 === strcmp($rule, $url) || (!$completeMatch && 0 === strncmp($rule . $depr, $url . $depr, strlen($rule . $depr))))) { + return $var; + } elseif (!$case && (0 === strcasecmp($rule, $url) || (!$completeMatch && 0 === strncasecmp($rule . $depr, $url . $depr, strlen($rule . $depr))))) { return $var; } return false; @@ -271,7 +278,7 @@ class RuleItem extends Rule $regex = $this->buildRuleRegex($rule, $matches[0], $pattern, $option, $completeMatch); try { - if (!preg_match('~^' . $regex . '~u', $url, $match)) { + if (!preg_match('~^' . $regex . '~u' . ($case ? '' : 'i'), $url, $match)) { return false; } } catch (\Exception $e) { diff --git a/vendor/topthink/framework/src/think/route/RuleName.php b/vendor/topthink/framework/src/think/route/RuleName.php index dd93a0d..faea0d8 100644 --- a/vendor/topthink/framework/src/think/route/RuleName.php +++ b/vendor/topthink/framework/src/think/route/RuleName.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -101,7 +101,7 @@ class RuleName * @param string $name 路由分组标识 * @return RuleGroup|null */ - public function getGroup(string $name) + public function getGroup(string $name): ?RuleGroup { return $this->group[strtolower($name)] ?? null; } @@ -113,9 +113,8 @@ class RuleName */ public function clear(): void { - $this->item = []; - $this->rule = []; - $this->group = []; + $this->item = []; + $this->rule = []; } /** diff --git a/vendor/topthink/framework/src/think/route/Url.php b/vendor/topthink/framework/src/think/route/Url.php index 9e60fca..60786dc 100644 --- a/vendor/topthink/framework/src/think/route/Url.php +++ b/vendor/topthink/framework/src/think/route/Url.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route; @@ -20,30 +20,6 @@ use think\Route; */ class Url { - /** - * 应用对象 - * @var App - */ - protected $app; - - /** - * 路由对象 - * @var Route - */ - protected $route; - - /** - * URL变量 - * @var array - */ - protected $vars = []; - - /** - * 路由URL - * @var string - */ - protected $url; - /** * URL 根地址 * @var string @@ -71,15 +47,13 @@ class Url /** * 架构函数 * @access public + * @param Route $route URL地址 + * @param App $app App对象 * @param string $url URL地址 * @param array $vars 参数 */ - public function __construct(Route $route, App $app, string $url = '', array $vars = []) + public function __construct(protected Route $route, protected App $app, protected string $url = '', protected array $vars = []) { - $this->route = $route; - $this->app = $app; - $this->url = $url; - $this->vars = $vars; } /** @@ -100,7 +74,7 @@ class Url * @param string|bool $suffix URL后缀 * @return $this */ - public function suffix($suffix) + public function suffix(string|bool $suffix) { $this->suffix = $suffix; return $this; @@ -112,7 +86,7 @@ class Url * @param string|bool $domain URL域名 * @return $this */ - public function domain($domain) + public function domain(string|bool $domain) { $this->domain = $domain; return $this; @@ -149,7 +123,7 @@ class Url * @param string|true $domain 域名 * @return string */ - protected function parseDomain(string &$url, $domain): string + protected function parseDomain(string &$url, string|bool $domain): string { if (!$domain) { return ''; @@ -166,10 +140,10 @@ class Url if (!empty($domains)) { $routeDomain = array_keys($domains); foreach ($routeDomain as $domainPrefix) { - if (0 === strpos($domainPrefix, '*.') && strpos($domain, ltrim($domainPrefix, '*.')) !== false) { + if (str_starts_with($domainPrefix, '*.') && str_contains($domain, ltrim($domainPrefix, '*.')) !== false) { foreach ($domains as $key => $rule) { $rule = is_array($rule) ? $rule[0] : $rule; - if (is_string($rule) && false === strpos($key, '*') && 0 === strpos($url, $rule)) { + if (is_string($rule) && !str_contains($key, '*') && str_starts_with($url, $rule)) { $url = ltrim($url, $rule); $domain = $key; @@ -178,7 +152,7 @@ class Url $domain .= $rootDomain; } break; - } elseif (false !== strpos($key, '*')) { + } elseif (str_contains($key, '*')) { if (!empty($rootDomain)) { $domain .= $rootDomain; } @@ -189,11 +163,11 @@ class Url } } } - } elseif (false === strpos($domain, '.') && 0 !== strpos($domain, $rootDomain)) { + } elseif (!str_contains($domain, '.') && !str_starts_with($domain, $rootDomain)) { $domain .= '.' . $rootDomain; } - if (false !== strpos($domain, '://')) { + if (str_contains($domain, '://')) { $scheme = ''; } else { $scheme = $this->https || $request->isSsl() ? 'https://' : 'http://'; @@ -208,7 +182,7 @@ class Url * @param string|bool $suffix 后缀 * @return string */ - protected function parseSuffix($suffix): string + protected function parseSuffix(string|bool $suffix): string { if ($suffix) { $suffix = true === $suffix ? $this->route->config('url_html_suffix') : $suffix; @@ -218,7 +192,7 @@ class Url } } - return (empty($suffix) || 0 === strpos($suffix, '.')) ? (string) $suffix : '.' . $suffix; + return (empty($suffix) || str_starts_with($suffix, '.')) ? (string) $suffix : '.' . $suffix; } /** @@ -228,17 +202,17 @@ class Url * @param string|bool $domain Domain * @return string */ - protected function parseUrl(string $url, &$domain): string + protected function parseUrl(string $url, string | bool &$domain): string { $request = $this->app->request; - if (0 === strpos($url, '/')) { + if (str_starts_with($url, '/')) { // 直接作为路由地址解析 $url = substr($url, 1); - } elseif (false !== strpos($url, '\\')) { + } elseif (str_contains($url, '\\')) { // 解析到类 $url = ltrim(str_replace('\\', '/', $url), '/'); - } elseif (0 === strpos($url, '@')) { + } elseif (str_starts_with($url, '@')) { // 解析到控制器 $url = substr($url, 1); } elseif ('' === $url) { @@ -271,7 +245,7 @@ class Url foreach ($matches[0] as $name) { $optional = false; - if (strpos($name, '?')) { + if (str_contains($name, '?')) { $name = substr($name, 1, -2); $optional = true; } else { @@ -290,13 +264,13 @@ class Url * @access protected * @param array $rule 路由规则 * @param array $vars 路由变量 - * @param mixed $allowDomain 允许域名 + * @param string|bool $allowDomain 允许域名 * @return array */ - protected function getRuleUrl(array $rule, array &$vars = [], $allowDomain = ''): array + protected function getRuleUrl(array $rule, array &$vars = [], string|bool $allowDomain = ''): array { $request = $this->app->request; - if (is_string($allowDomain) && false === strpos($allowDomain, '.')) { + if (is_string($allowDomain) && !str_contains($allowDomain, '.')) { $allowDomain .= '.' . $request->rootDomain(); } $port = $request->port(); @@ -367,13 +341,13 @@ class Url $request = $this->app->request; $vars = $this->vars; - if (0 === strpos($url, '[') && $pos = strpos($url, ']')) { + if (str_starts_with($url, '[') && $pos = strpos($url, ']')) { // [name] 表示使用路由命名标识生成URL $name = substr($url, 1, $pos - 1); $url = 'name' . substr($url, $pos + 1); } - if (false === strpos($url, '://') && 0 !== strpos($url, '/')) { + if (!str_contains($url, '://') && !str_starts_with($url, '/')) { $info = parse_url($url); $url = !empty($info['path']) ? $info['path'] : ''; @@ -381,16 +355,16 @@ class Url // 解析锚点 $anchor = $info['fragment']; - if (false !== strpos($anchor, '?')) { + if (str_contains($anchor, '?')) { // 解析参数 [$anchor, $info['query']] = explode('?', $anchor, 2); } - if (false !== strpos($anchor, '@')) { + if (str_contains($anchor, '@')) { // 解析域名 [$anchor, $domain] = explode('@', $anchor, 2); } - } elseif (strpos($url, '@') && false === strpos($url, '\\')) { + } elseif (str_contains($url, '@') && !str_contains($url, '\\')) { // 解析域名 [$url, $domain] = explode('@', $url, 2); } @@ -428,13 +402,13 @@ class Url // 检测URL绑定 $bind = $this->route->getDomainBind($domain && is_string($domain) ? $domain : null); - if ($bind && 0 === strpos($url, $bind)) { + if ($bind && str_starts_with($url, $bind)) { $url = substr($url, strlen($bind) + 1); } else { $binds = $this->route->getBind(); foreach ($binds as $key => $val) { - if (is_string($val) && 0 === strpos($url, $val) && substr_count($val, '/') > 1) { + if (is_string($val) && str_starts_with($url, $val) && substr_count($val, '/') > 1) { $url = substr($url, strlen($val) + 1); $domain = $key; break; @@ -457,14 +431,14 @@ class Url $url = str_replace('/', $depr, $url); $file = $request->baseFile(); - if ($file && 0 !== strpos($request->url(), $file)) { + if ($file && !str_starts_with($request->url(), $file)) { $file = str_replace('\\', '/', dirname($file)); } $url = rtrim($file, '/') . '/' . $url; // URL后缀 - if ('/' == substr($url, -1) || '' == $url) { + if (str_ends_with($url, '/') || '' == $url) { $suffix = ''; } else { $suffix = $this->parseSuffix($suffix); diff --git a/vendor/topthink/framework/src/think/route/dispatch/Callback.php b/vendor/topthink/framework/src/think/route/dispatch/Callback.php index 2044ef8..26614cc 100644 --- a/vendor/topthink/framework/src/think/route/dispatch/Callback.php +++ b/vendor/topthink/framework/src/think/route/dispatch/Callback.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route\dispatch; @@ -26,5 +26,4 @@ class Callback extends Dispatch return $this->app->invoke($this->dispatch, $vars); } - } diff --git a/vendor/topthink/framework/src/think/route/dispatch/Controller.php b/vendor/topthink/framework/src/think/route/dispatch/Controller.php index f18512c..c36e521 100644 --- a/vendor/topthink/framework/src/think/route/dispatch/Controller.php +++ b/vendor/topthink/framework/src/think/route/dispatch/Controller.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route\dispatch; @@ -51,7 +51,7 @@ class Controller extends Dispatch // 获取控制器名 $controller = strip_tags($result[0] ?: $this->rule->config('default_controller')); - if (strpos($controller, '.')) { + if (str_contains($controller, '.')) { $pos = strrpos($controller, '.'); $this->controller = substr($controller, 0, $pos) . '.' . Str::studly(substr($controller, $pos + 1)); } else { @@ -104,7 +104,7 @@ class Controller extends Dispatch } } else { // 操作不存在 - throw new HttpException(404, 'method not exists:' . get_class($instance) . '->' . $action . '()'); + throw new HttpException(404, 'method not exists:' . $instance::class . '->' . $action . '()'); } $data = $this->app->invokeReflectMethod($instance, $reflect, $vars); @@ -155,7 +155,7 @@ class Controller extends Dispatch continue; } - if (is_string($middleware) && strpos($middleware, ':')) { + if (is_string($middleware) && str_contains($middleware, ':')) { $middleware = explode(':', $middleware); if (count($middleware) > 1) { $middleware = [$middleware[0], array_slice($middleware, 1)]; diff --git a/vendor/topthink/framework/src/think/route/dispatch/Url.php b/vendor/topthink/framework/src/think/route/dispatch/Url.php index 147f5cb..15a8a54 100644 --- a/vendor/topthink/framework/src/think/route/dispatch/Url.php +++ b/vendor/topthink/framework/src/think/route/dispatch/Url.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\route\dispatch; @@ -47,7 +47,7 @@ class Url extends Controller if ($bind && preg_match('/^[a-z]/is', $bind)) { $bind = str_replace('/', $depr, $bind); // 如果有域名绑定 - $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr); + $url = $bind . (!str_ends_with($bind, '.') ? $depr : '') . ltrim($url, $depr); } $path = $this->rule->parseUrlPath($url); @@ -114,5 +114,4 @@ class Url extends Controller return false; } - } diff --git a/vendor/topthink/framework/src/think/service/ModelService.php b/vendor/topthink/framework/src/think/service/ModelService.php index b517c4e..bffdcab 100644 --- a/vendor/topthink/framework/src/think/service/ModelService.php +++ b/vendor/topthink/framework/src/think/service/ModelService.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\service; @@ -47,7 +47,6 @@ class ModelService extends Service [$createTime, $updateTime] = explode(',', $timeField); $model->setTimeField($createTime, $updateTime); } - }); } } diff --git a/vendor/topthink/framework/src/think/service/PaginatorService.php b/vendor/topthink/framework/src/think/service/PaginatorService.php index a01977d..50fa1ed 100644 --- a/vendor/topthink/framework/src/think/service/PaginatorService.php +++ b/vendor/topthink/framework/src/think/service/PaginatorService.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\service; diff --git a/vendor/topthink/framework/src/think/service/ValidateService.php b/vendor/topthink/framework/src/think/service/ValidateService.php index 94d7638..45306c9 100644 --- a/vendor/topthink/framework/src/think/service/ValidateService.php +++ b/vendor/topthink/framework/src/think/service/ValidateService.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: yunwuxin <448901948@qq.com> // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\service; diff --git a/vendor/topthink/framework/src/think/session/Store.php b/vendor/topthink/framework/src/think/session/Store.php index 49e1ba9..50e402b 100644 --- a/vendor/topthink/framework/src/think/session/Store.php +++ b/vendor/topthink/framework/src/think/session/Store.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -16,7 +16,6 @@ use think\helper\Arr; class Store { - /** * Session数据 * @var array @@ -29,31 +28,17 @@ class Store */ protected $init = null; - /** - * 记录Session name - * @var string - */ - protected $name = 'PHPSESSID'; - /** * 记录Session Id * @var string */ protected $id; - /** - * @var SessionHandlerInterface - */ - protected $handler; - /** @var array */ protected $serialize = []; - public function __construct($name, SessionHandlerInterface $handler, array $serialize = null) + public function __construct(protected string $name, protected SessionHandlerInterface $handler, array $serialize = null) { - $this->name = $name; - $this->handler = $handler; - if (!empty($serialize)) { $this->serialize = $serialize; } @@ -116,7 +101,7 @@ class Store * @param string $id session_id * @return void */ - public function setId($id = null): void + public function setId(string $id = null): void { $this->id = is_string($id) && strlen($id) === 32 && ctype_alnum($id) ? $id : md5(microtime(true) . session_create_id()); } @@ -336,5 +321,4 @@ class Store return (array) $unserialize($data); } - } diff --git a/vendor/topthink/framework/src/think/session/driver/Cache.php b/vendor/topthink/framework/src/think/session/driver/Cache.php index 4fabc79..910b8bf 100644 --- a/vendor/topthink/framework/src/think/session/driver/Cache.php +++ b/vendor/topthink/framework/src/think/session/driver/Cache.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/framework/src/think/session/driver/File.php b/vendor/topthink/framework/src/think/session/driver/File.php index 788f323..ac2268f 100644 --- a/vendor/topthink/framework/src/think/session/driver/File.php +++ b/vendor/topthink/framework/src/think/session/driver/File.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\session\driver; @@ -56,7 +56,7 @@ class File implements SessionHandlerInterface { try { !is_dir($this->config['path']) && mkdir($this->config['path'], 0755, true); - } catch (\Exception $e) { + } catch (Exception $e) { // 写入失败 } @@ -129,7 +129,7 @@ class File implements SessionHandlerInterface if ($auto && !is_dir($dir)) { try { mkdir($dir, 0755, true); - } catch (\Exception $e) { + } catch (Exception $e) { // 创建失败 } } @@ -230,7 +230,7 @@ class File implements SessionHandlerInterface { try { return $this->unlink($this->getFileName($sessID)); - } catch (\Exception $e) { + } catch (Exception $e) { return false; } } @@ -245,5 +245,4 @@ class File implements SessionHandlerInterface { return is_file($file) && unlink($file); } - } diff --git a/vendor/topthink/framework/src/think/validate/ValidateRule.php b/vendor/topthink/framework/src/think/validate/ValidateRule.php index 18e5ea3..a2ed959 100644 --- a/vendor/topthink/framework/src/think/validate/ValidateRule.php +++ b/vendor/topthink/framework/src/think/validate/ValidateRule.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\validate; diff --git a/vendor/topthink/framework/src/think/view/driver/Php.php b/vendor/topthink/framework/src/think/view/driver/Php.php index 9e6e54a..7f7c0f6 100644 --- a/vendor/topthink/framework/src/think/view/driver/Php.php +++ b/vendor/topthink/framework/src/think/view/driver/Php.php @@ -2,13 +2,13 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2021 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- // | Author: liu21st // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\view\driver; @@ -114,7 +114,7 @@ class Php implements TemplateHandlerInterface $request = $this->app->request; // 获取视图根目录 - if (strpos($template, '@')) { + if (str_contains($template, '@')) { // 跨应用调用 [$app, $template] = explode('@', $template); } @@ -134,10 +134,10 @@ class Php implements TemplateHandlerInterface $depr = $this->config['view_depr']; - if (0 !== strpos($template, '/')) { + if (!str_starts_with($template, '/')) { $template = str_replace(['/', ':'], $depr, $template); $controller = $request->controller(); - if (strpos($controller, '.')) { + if (str_contains($controller, '.')) { $pos = strrpos($controller, '.'); $controller = substr($controller, 0, $pos) . '.' . Str::snake(substr($controller, $pos + 1)); } else { @@ -156,7 +156,7 @@ class Php implements TemplateHandlerInterface } $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; - } elseif (false === strpos($template, $depr)) { + } elseif (!str_contains($template, $depr)) { $template = str_replace('.', DIRECTORY_SEPARATOR, $controller) . $depr . $template; } } diff --git a/vendor/topthink/framework/tests/AppTest.php b/vendor/topthink/framework/tests/AppTest.php index 6b86015..1295652 100644 --- a/vendor/topthink/framework/tests/AppTest.php +++ b/vendor/topthink/framework/tests/AppTest.php @@ -39,7 +39,7 @@ class AppTest extends TestCase /** @var App */ protected $app; - protected function setUp() + protected function setUp(): void { $this->app = new App(); } @@ -51,10 +51,6 @@ class AppTest extends TestCase public function testService() { - $this->app->register(stdClass::class); - - $this->assertInstanceOf(stdClass::class, $this->app->getService(stdClass::class)); - $service = m::mock(SomeService::class); $service->shouldReceive('register')->once(); diff --git a/vendor/topthink/framework/tests/CacheTest.php b/vendor/topthink/framework/tests/CacheTest.php index 5b5a13c..82bae1e 100644 --- a/vendor/topthink/framework/tests/CacheTest.php +++ b/vendor/topthink/framework/tests/CacheTest.php @@ -28,7 +28,7 @@ class CacheTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->app = m::mock(App::class)->makePartial(); @@ -70,7 +70,8 @@ class CacheTest extends TestCase $this->config->shouldReceive('get')->with("cache.default", null)->andReturn('file'); - $this->config->shouldReceive('get')->with("cache.stores.file", null)->andReturn(['type' => 'file', 'path' => $root->url()]); + $this->config->shouldReceive('get')->with("cache.stores.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); $this->cache->set('foo', 5); $this->cache->inc('foo'); @@ -97,12 +98,16 @@ class CacheTest extends TestCase //tags $this->cache->tag('foo')->set('bar', 'foobar'); $this->assertEquals('foobar', $this->cache->get('bar')); + $this->cache->tag('foo')->remember('baz', 'foobar'); + $this->assertEquals('foobar', $this->cache->get('baz')); $this->cache->tag('foo')->clear(); $this->assertFalse($this->cache->has('bar')); //multiple $this->cache->setMultiple(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']]); + $this->cache->tag('foo')->setMultiple(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']]); $this->assertEquals(['foo' => ['foobar', 'bar'], 'foobar' => ['foo', 'bar']], $this->cache->getMultiple(['foo', 'foobar'])); + $this->assertIsInt($this->cache->getWriteTimes()); $this->assertTrue($this->cache->deleteMultiple(['foo', 'foobar'])); } diff --git a/vendor/topthink/framework/tests/ContainerTest.php b/vendor/topthink/framework/tests/ContainerTest.php index e27deb0..909c322 100644 --- a/vendor/topthink/framework/tests/ContainerTest.php +++ b/vendor/topthink/framework/tests/ContainerTest.php @@ -186,7 +186,7 @@ class ContainerTest extends TestCase $taylor = $container->make(Taylor::class); $this->assertInstanceOf(Taylor::class, $taylor); - $this->assertAttributeSame('Taylor', 'name', $taylor); + $this->assertSame('Taylor', $taylor->name); } public function testGetAndSetInstance() diff --git a/vendor/topthink/framework/tests/EventTest.php b/vendor/topthink/framework/tests/EventTest.php index ded5a36..797c4d6 100644 --- a/vendor/topthink/framework/tests/EventTest.php +++ b/vendor/topthink/framework/tests/EventTest.php @@ -26,7 +26,7 @@ class EventTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->app = m::mock(App::class)->makePartial(); diff --git a/vendor/topthink/framework/tests/FilesystemTest.php b/vendor/topthink/framework/tests/FilesystemTest.php deleted file mode 100644 index df5ffe2..0000000 --- a/vendor/topthink/framework/tests/FilesystemTest.php +++ /dev/null @@ -1,131 +0,0 @@ -app = m::mock(App::class)->makePartial(); - Container::setInstance($this->app); - $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); - $this->config = m::mock(Config::class); - $this->config->shouldReceive('get')->with('filesystem.default', null)->andReturn('local'); - $this->app->shouldReceive('get')->with('config')->andReturn($this->config); - $this->filesystem = new Filesystem($this->app); - - $this->root = vfsStream::setup('rootDir'); - } - - protected function tearDown(): void - { - m::close(); - } - - public function testDisk() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.foo', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk('foo')); - } - - public function testCache() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - 'cache' => true, - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->config->shouldReceive('get')->with('filesystem.disks.cache', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $this->root->url(), - 'cache' => [ - 'store' => 'flysystem', - ], - ]); - - $cache = m::mock(Cache::class); - - $cacheDriver = m::mock(File::class); - - $cache->shouldReceive('store')->once()->with('flysystem')->andReturn($cacheDriver); - - $this->app->shouldReceive('make')->with(Cache::class)->andReturn($cache); - - $cacheDriver->shouldReceive('get')->with('flysystem')->once()->andReturn(null); - - $cacheDriver->shouldReceive('set')->withAnyArgs(); - - $this->filesystem->disk('cache')->put('test.txt', 'aa'); - } - - public function testPutFile() - { - $root = vfsStream::setup('rootDir', null, [ - 'foo.jpg' => 'hello', - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $root->url(), - 'cache' => true, - ]); - - $file = m::mock(\think\File::class); - - $file->shouldReceive('hashName')->with(null)->once()->andReturn('foo.jpg'); - - $file->shouldReceive('getRealPath')->once()->andReturn($root->getChild('foo.jpg')->url()); - - $this->filesystem->putFile('test', $file); - } -} - -class NullDriver extends Driver -{ - protected function createAdapter(): AdapterInterface - { - return new NullAdapter(); - } -} diff --git a/vendor/topthink/framework/tests/HttpTest.php b/vendor/topthink/framework/tests/HttpTest.php index c3e0abd..dd91b9b 100644 --- a/vendor/topthink/framework/tests/HttpTest.php +++ b/vendor/topthink/framework/tests/HttpTest.php @@ -31,7 +31,7 @@ class HttpTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->app = m::mock(App::class)->makePartial(); diff --git a/vendor/topthink/framework/tests/LogTest.php b/vendor/topthink/framework/tests/LogTest.php index 981110f..218b815 100644 --- a/vendor/topthink/framework/tests/LogTest.php +++ b/vendor/topthink/framework/tests/LogTest.php @@ -22,7 +22,7 @@ class LogTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->prepareApp(); @@ -64,7 +64,8 @@ class LogTest extends TestCase $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); - $this->config->shouldReceive('get')->with("log.channels.file", null)->andReturn(['type' => 'file', 'path' => $root->url()]); + $this->config->shouldReceive('get')->with("log.channels.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); $this->log->info('foo'); @@ -118,7 +119,8 @@ class LogTest extends TestCase $this->config->shouldReceive('get')->with("log.default", null)->andReturn('file'); - $this->config->shouldReceive('get')->with("log.channels.file", null)->andReturn(['type' => 'file', 'path' => $root->url()]); + $this->config->shouldReceive('get')->with("log.channels.file", null) + ->andReturn(['type' => 'file', 'path' => $root->url()]); $this->log->info('foo'); diff --git a/vendor/topthink/framework/tests/MiddlewareTest.php b/vendor/topthink/framework/tests/MiddlewareTest.php index aa53059..e57aecf 100644 --- a/vendor/topthink/framework/tests/MiddlewareTest.php +++ b/vendor/topthink/framework/tests/MiddlewareTest.php @@ -24,7 +24,7 @@ class MiddlewareTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->prepareApp(); @@ -47,7 +47,8 @@ class MiddlewareTest extends TestCase $this->assertEquals(2, count($this->middleware->all())); $this->assertEquals([['BazMiddleware', 'handle'], 'baz'], $this->middleware->all()[0]); - $this->config->shouldReceive('get')->with('middleware.alias', [])->andReturn(['foo' => ['FooMiddleware', 'FarMiddleware']]); + $this->config->shouldReceive('get')->with('middleware.alias', []) + ->andReturn(['foo' => ['FooMiddleware', 'FarMiddleware']]); $this->middleware->add('foo'); $this->assertEquals(3, count($this->middleware->all())); @@ -84,7 +85,8 @@ class MiddlewareTest extends TestCase $this->app->shouldReceive('make')->with(Handle::class)->andReturn($handle); - $this->config->shouldReceive('get')->once()->with('middleware.priority', [])->andReturn(['FooMiddleware', 'BarMiddleware']); + $this->config->shouldReceive('get')->once()->with('middleware.priority', []) + ->andReturn(['FooMiddleware', 'BarMiddleware']); $this->middleware->import([function ($request, $next) { return $next($request); diff --git a/vendor/topthink/framework/tests/RouteTest.php b/vendor/topthink/framework/tests/RouteTest.php index 6a7f8ee..e6013cc 100644 --- a/vendor/topthink/framework/tests/RouteTest.php +++ b/vendor/topthink/framework/tests/RouteTest.php @@ -6,6 +6,7 @@ use Closure; use Mockery as m; use Mockery\MockInterface; use PHPUnit\Framework\TestCase; +use think\exception\RouteNotFoundException; use think\helper\Str; use think\Request; use think\response\Redirect; @@ -24,14 +25,16 @@ class RouteTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->prepareApp(); + + $this->config->shouldReceive('get')->with('route')->andReturn(['url_route_must' => true]); $this->route = new Route($this->app); } /** - * @param $path + * @param $path * @param string $method * @param string $host * @return m\Mock|Request @@ -73,53 +76,53 @@ class RouteTest extends TestCase $this->assertEquals('get-foo', $response->getContent()); } - public function testOptionsRequest() - { - $this->route->get('foo', function () { - return 'get-foo'; - }); - - $this->route->put('foo', function () { - return 'put-foo'; - }); - - $this->route->group(function () { - $this->route->post('foo', function () { - return 'post-foo'; - }); - }); - $this->route->group('abc', function () { - $this->route->post('foo/:id', function () { - return 'post-abc-foo'; - }); - }); - - $this->route->post('foo/:id', function () { - return 'post-abc-foo'; - }); - - $this->route->resource('bar', 'SomeClass'); - - $request = $this->makeRequest('foo', 'options'); - $response = $this->route->dispatch($request); - $this->assertEquals(204, $response->getCode()); - $this->assertEquals('GET, PUT, POST', $response->getHeader('Allow')); - - $request = $this->makeRequest('bar', 'options'); - $response = $this->route->dispatch($request); - $this->assertEquals(204, $response->getCode()); - $this->assertEquals('GET, POST', $response->getHeader('Allow')); - - $request = $this->makeRequest('bar/1', 'options'); - $response = $this->route->dispatch($request); - $this->assertEquals(204, $response->getCode()); - $this->assertEquals('GET, PUT, DELETE', $response->getHeader('Allow')); - - $request = $this->makeRequest('xxxx', 'options'); - $response = $this->route->dispatch($request); - $this->assertEquals(204, $response->getCode()); - $this->assertEquals('GET, POST, PUT, DELETE', $response->getHeader('Allow')); - } + // public function testOptionsRequest() + // { + // $this->route->get('foo', function () { + // return 'get-foo'; + // }); + // + // $this->route->put('foo', function () { + // return 'put-foo'; + // }); + // + // $this->route->group(function () { + // $this->route->post('foo', function () { + // return 'post-foo'; + // }); + // }); + // $this->route->group('abc', function () { + // $this->route->post('foo/:id', function () { + // return 'post-abc-foo'; + // }); + // }); + // + // $this->route->post('foo/:id', function () { + // return 'post-abc-foo'; + // }); + // + // $this->route->resource('bar', 'SomeClass'); + // + // $request = $this->makeRequest('foo', 'options'); + // $response = $this->route->dispatch($request); + // $this->assertEquals(204, $response->getCode()); + // $this->assertEquals('GET, PUT, POST', $response->getHeader('Allow')); + // + // $request = $this->makeRequest('bar', 'options'); + // $response = $this->route->dispatch($request); + // $this->assertEquals(204, $response->getCode()); + // $this->assertEquals('GET, POST', $response->getHeader('Allow')); + // + // $request = $this->makeRequest('bar/1', 'options'); + // $response = $this->route->dispatch($request); + // $this->assertEquals(204, $response->getCode()); + // $this->assertEquals('GET, PUT, DELETE', $response->getHeader('Allow')); + // + // $request = $this->makeRequest('xxxx', 'options'); + // $response = $this->route->dispatch($request); + // $this->assertEquals(204, $response->getCode()); + // $this->assertEquals('GET, POST, PUT, DELETE', $response->getHeader('Allow')); + // } public function testAllowCrossDomain() { @@ -133,12 +136,9 @@ class RouteTest extends TestCase $this->assertEquals('bar', $response->getHeader('some')); $this->assertArrayHasKey('Access-Control-Allow-Credentials', $response->getHeader()); - $request = $this->makeRequest('foo2', 'options'); - $response = $this->route->dispatch($request); - - $this->assertEquals(204, $response->getCode()); - $this->assertArrayHasKey('Access-Control-Allow-Credentials', $response->getHeader()); - $this->assertEquals('GET, POST, PUT, DELETE', $response->getHeader('Allow')); + //$this->expectException(RouteNotFoundException::class); + $request = $this->makeRequest('foo2', 'options'); + $this->route->dispatch($request); } public function testControllerDispatch() @@ -210,20 +210,6 @@ class RouteTest extends TestCase $this->assertEquals('bar', $response->getContent()); } - public function testUrlDispatch() - { - $controller = m::mock(FooClass::class); - $controller->shouldReceive('index')->andReturn('bar'); - - $this->app->shouldReceive('parseClass')->once()->with('controller', 'Foo') - ->andReturn($controller->mockery_getName()); - $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); - - $request = $this->makeRequest('foo'); - $response = $this->route->dispatch($request); - $this->assertEquals('bar', $response->getContent()); - } - public function testRedirectDispatch() { $this->route->redirect('foo', 'http://localhost', 302); @@ -249,20 +235,6 @@ class RouteTest extends TestCase $this->assertEquals('index/hello', $response->getData()); } - public function testResponseDispatch() - { - $this->route->get('hello/:name', response() - ->data('Hello,ThinkPHP') - ->code(200) - ->contentType('text/plain')); - - $request = $this->makeRequest('hello/some'); - $response = $this->route->dispatch($request); - - $this->assertEquals('Hello,ThinkPHP', $response->getContent()); - $this->assertEquals(200, $response->getCode()); - } - public function testDomainBindResponse() { $this->route->domain('test', function () { diff --git a/vendor/topthink/framework/tests/SessionTest.php b/vendor/topthink/framework/tests/SessionTest.php index b3b48a7..f9b4827 100644 --- a/vendor/topthink/framework/tests/SessionTest.php +++ b/vendor/topthink/framework/tests/SessionTest.php @@ -34,7 +34,7 @@ class SessionTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->app = m::mock(App::class)->makePartial(); Container::setInstance($this->app); diff --git a/vendor/topthink/framework/tests/UrlRouteTest.php b/vendor/topthink/framework/tests/UrlRouteTest.php new file mode 100644 index 0000000..28c502f --- /dev/null +++ b/vendor/topthink/framework/tests/UrlRouteTest.php @@ -0,0 +1,60 @@ +prepareApp(); + + $this->route = new Route($this->app); + } + + public function testUrlDispatch() + { + $controller = m::mock(FooClass::class); + $controller->shouldReceive('index')->andReturn('bar'); + + $this->app->shouldReceive('parseClass')->once()->with('controller', 'Foo') + ->andReturn($controller->mockery_getName()); + $this->app->shouldReceive('make')->with($controller->mockery_getName(), [], true)->andReturn($controller); + + $request = $this->makeRequest('foo'); + $response = $this->route->dispatch($request); + $this->assertEquals('bar', $response->getContent()); + } + + /** + * @param $path + * @param string $method + * @param string $host + * @return m\Mock|Request + */ + protected function makeRequest($path, $method = 'GET', $host = 'localhost') + { + $request = m::mock(Request::class)->makePartial(); + $request->shouldReceive('host')->andReturn($host); + $request->shouldReceive('pathinfo')->andReturn($path); + $request->shouldReceive('url')->andReturn('/' . $path); + $request->shouldReceive('method')->andReturn(strtoupper($method)); + return $request; + } + +} diff --git a/vendor/topthink/framework/tests/ViewTest.php b/vendor/topthink/framework/tests/ViewTest.php index e413510..95ea119 100644 --- a/vendor/topthink/framework/tests/ViewTest.php +++ b/vendor/topthink/framework/tests/ViewTest.php @@ -27,7 +27,7 @@ class ViewTest extends TestCase m::close(); } - protected function setUp() + protected function setUp(): void { $this->app = m::mock(App::class)->makePartial(); Container::setInstance($this->app); diff --git a/vendor/topthink/think-captcha/assets/zhttfs/1.ttf b/vendor/topthink/think-captcha/assets/zhttfs/1.ttf deleted file mode 100644 index 1c14f7f..0000000 Binary files a/vendor/topthink/think-captcha/assets/zhttfs/1.ttf and /dev/null differ diff --git a/vendor/topthink/think-filesystem/.gitignore b/vendor/topthink/think-filesystem/.gitignore deleted file mode 100644 index 25ad74d..0000000 --- a/vendor/topthink/think-filesystem/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -composer.lock -/.idea -/vendor diff --git a/vendor/topthink/think-filesystem/README.md b/vendor/topthink/think-filesystem/README.md deleted file mode 100644 index 90977dd..0000000 --- a/vendor/topthink/think-filesystem/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# think-filesystem for ThinkPHP6.1 - -## 安装 - -> composer require topthink/think-filesystem diff --git a/vendor/topthink/think-filesystem/composer.json b/vendor/topthink/think-filesystem/composer.json deleted file mode 100644 index 040f4a3..0000000 --- a/vendor/topthink/think-filesystem/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "topthink/think-filesystem", - "description": "The ThinkPHP6.1 Filesystem Package", - "type": "library", - "license": "Apache-2.0", - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "autoload": { - "psr-4": { - "think\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "think\\tests\\": "tests/" - } - }, - "require": { - "php": ">=7.2.5", - "topthink/framework": "^6.1", - "league/flysystem": "^1.1.4", - "league/flysystem-cached-adapter": "^1.0" - }, - "require-dev": { - "mikey179/vfsstream": "^1.6", - "mockery/mockery": "^1.2", - "phpunit/phpunit": "^8.0" - }, - "minimum-stability": "dev", - "prefer-stable": true -} diff --git a/vendor/topthink/think-filesystem/phpunit.xml.dist b/vendor/topthink/think-filesystem/phpunit.xml.dist deleted file mode 100644 index e20a133..0000000 --- a/vendor/topthink/think-filesystem/phpunit.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - ./tests - - - - - ./src/think - - - diff --git a/vendor/topthink/think-filesystem/src/Filesystem.php b/vendor/topthink/think-filesystem/src/Filesystem.php deleted file mode 100644 index 0aee929..0000000 --- a/vendor/topthink/think-filesystem/src/Filesystem.php +++ /dev/null @@ -1,89 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think; - -use InvalidArgumentException; -use think\filesystem\Driver; -use think\filesystem\driver\Local; -use think\helper\Arr; - -/** - * Class Filesystem - * @package think - * @mixin Driver - * @mixin Local - */ -class Filesystem extends Manager -{ - protected $namespace = '\\think\\filesystem\\driver\\'; - - /** - * @param null|string $name - * @return Driver - */ - public function disk(string $name = null): Driver - { - return $this->driver($name); - } - - protected function resolveType(string $name) - { - return $this->getDiskConfig($name, 'type', 'local'); - } - - protected function resolveConfig(string $name) - { - return $this->getDiskConfig($name); - } - - /** - * 获取缓存配置 - * @access public - * @param null|string $name 名称 - * @param mixed $default 默认值 - * @return mixed - */ - public function getConfig(string $name = null, $default = null) - { - if (!is_null($name)) { - return $this->app->config->get('filesystem.' . $name, $default); - } - - return $this->app->config->get('filesystem'); - } - - /** - * 获取磁盘配置 - * @param string $disk - * @param null $name - * @param null $default - * @return array - */ - public function getDiskConfig($disk, $name = null, $default = null) - { - if ($config = $this->getConfig("disks.{$disk}")) { - return Arr::get($config, $name, $default); - } - - throw new InvalidArgumentException("Disk [$disk] not found."); - } - - /** - * 默认驱动 - * @return string|null - */ - public function getDefaultDriver() - { - return $this->getConfig('default'); - } -} diff --git a/vendor/topthink/think-filesystem/src/facade/Filesystem.php b/vendor/topthink/think-filesystem/src/facade/Filesystem.php deleted file mode 100644 index 0e32c2c..0000000 --- a/vendor/topthink/think-filesystem/src/facade/Filesystem.php +++ /dev/null @@ -1,33 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\facade; - -use think\Facade; -use think\filesystem\Driver; - -/** - * Class Filesystem - * @package think\facade - * @mixin \think\Filesystem - * @method static Driver disk(string $name = null) , null|string - * @method static mixed getConfig(null|string $name = null, mixed $default = null) 获取缓存配置 - * @method static array getDiskConfig(string $disk, null $name = null, null $default = null) 获取磁盘配置 - * @method static string|null getDefaultDriver() 默认驱动 - */ -class Filesystem extends Facade -{ - protected static function getFacadeClass() - { - return \think\Filesystem::class; - } -} diff --git a/vendor/topthink/think-filesystem/src/filesystem/CacheStore.php b/vendor/topthink/think-filesystem/src/filesystem/CacheStore.php deleted file mode 100644 index 0a62399..0000000 --- a/vendor/topthink/think-filesystem/src/filesystem/CacheStore.php +++ /dev/null @@ -1,54 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\Cached\Storage\AbstractCache; -use Psr\SimpleCache\CacheInterface; - -class CacheStore extends AbstractCache -{ - protected $store; - - protected $key; - - protected $expire; - - public function __construct(CacheInterface $store, $key = 'flysystem', $expire = null) - { - $this->key = $key; - $this->store = $store; - $this->expire = $expire; - } - - /** - * Store the cache. - */ - public function save() - { - $contents = $this->getForStorage(); - - $this->store->set($this->key, $contents, $this->expire); - } - - /** - * Load the cache. - */ - public function load() - { - $contents = $this->store->get($this->key); - - if (!is_null($contents)) { - $this->setFromStorage($contents); - } - } -} diff --git a/vendor/topthink/think-filesystem/src/filesystem/Driver.php b/vendor/topthink/think-filesystem/src/filesystem/Driver.php deleted file mode 100644 index 81089b8..0000000 --- a/vendor/topthink/think-filesystem/src/filesystem/Driver.php +++ /dev/null @@ -1,144 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\AbstractAdapter; -use League\Flysystem\Cached\CachedAdapter; -use League\Flysystem\Cached\Storage\Memory as MemoryStore; -use League\Flysystem\Filesystem; -use RuntimeException; -use think\Cache; -use think\File; - -/** - * Class Driver - * @package think\filesystem - * @mixin Filesystem - */ -abstract class Driver -{ - - /** @var Cache */ - protected $cache; - - /** @var Filesystem */ - protected $filesystem; - - /** - * 配置参数 - * @var array - */ - protected $config = []; - - public function __construct(Cache $cache, array $config) - { - $this->cache = $cache; - $this->config = array_merge($this->config, $config); - - $adapter = $this->createAdapter(); - $this->filesystem = $this->createFilesystem($adapter); - } - - protected function createCacheStore($config) - { - if (true === $config) { - return new MemoryStore; - } - - return new CacheStore( - $this->cache->store($config['store']), - $config['prefix'] ?? 'flysystem', - $config['expire'] ?? null - ); - } - - abstract protected function createAdapter(): AdapterInterface; - - protected function createFilesystem(AdapterInterface $adapter): Filesystem - { - if (!empty($this->config['cache'])) { - $adapter = new CachedAdapter($adapter, $this->createCacheStore($this->config['cache'])); - } - - $config = array_intersect_key($this->config, array_flip(['visibility', 'disable_asserts', 'url'])); - - return new Filesystem($adapter, count($config) > 0 ? $config : []); - } - - /** - * 获取文件完整路径 - * @param string $path - * @return string - */ - public function path(string $path): string - { - $adapter = $this->filesystem->getAdapter(); - - if ($adapter instanceof AbstractAdapter) { - return $adapter->applyPathPrefix($path); - } - - return $path; - } - - protected function concatPathToUrl($url, $path) - { - return rtrim($url, '/') . '/' . ltrim($path, '/'); - } - - public function url(string $path): string - { - throw new RuntimeException('This driver does not support retrieving URLs.'); - } - - /** - * 保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param null|string|\Closure $rule 文件名规则 - * @param array $options 参数 - * @return bool|string - */ - public function putFile(string $path, File $file, $rule = null, array $options = []) - { - return $this->putFileAs($path, $file, $file->hashName($rule), $options); - } - - /** - * 指定文件名保存文件 - * @param string $path 路径 - * @param File $file 文件 - * @param string $name 文件名 - * @param array $options 参数 - * @return bool|string - */ - public function putFileAs(string $path, File $file, string $name, array $options = []) - { - $stream = fopen($file->getRealPath(), 'r'); - $path = trim($path . '/' . $name, '/'); - - $result = $this->putStream($path, $stream, $options); - - if (is_resource($stream)) { - fclose($stream); - } - - return $result ? $path : false; - } - - public function __call($method, $parameters) - { - return $this->filesystem->$method(...$parameters); - } -} diff --git a/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php b/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php deleted file mode 100644 index 5749335..0000000 --- a/vendor/topthink/think-filesystem/src/filesystem/driver/Local.php +++ /dev/null @@ -1,59 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\filesystem\driver; - -use League\Flysystem\AdapterInterface; -use League\Flysystem\Adapter\Local as LocalAdapter; -use think\filesystem\Driver; - -class Local extends Driver -{ - /** - * 配置参数 - * @var array - */ - protected $config = [ - 'root' => '', - ]; - - protected function createAdapter(): AdapterInterface - { - $permissions = $this->config['permissions'] ?? []; - - $links = ($this->config['links'] ?? null) === 'skip' - ? LocalAdapter::SKIP_LINKS - : LocalAdapter::DISALLOW_LINKS; - - return new LocalAdapter( - $this->config['root'], - LOCK_EX, - $links, - $permissions - ); - } - - /** - * 获取文件访问地址 - * @param string $path 文件路径 - * @return string - */ - public function url(string $path): string - { - $path = str_replace('\\', '/', $path); - - if (isset($this->config['url'])) { - return $this->concatPathToUrl($this->config['url'], $path); - } - return parent::url($path); - } -} diff --git a/vendor/topthink/think-filesystem/tests/FilesystemTest.php b/vendor/topthink/think-filesystem/tests/FilesystemTest.php deleted file mode 100644 index a589771..0000000 --- a/vendor/topthink/think-filesystem/tests/FilesystemTest.php +++ /dev/null @@ -1,131 +0,0 @@ -app = m::mock(App::class)->makePartial(); - Container::setInstance($this->app); - $this->app->shouldReceive('make')->with(App::class)->andReturn($this->app); - $this->config = m::mock(Config::class); - $this->config->shouldReceive('get')->with('filesystem.default', null)->andReturn('local'); - $this->app->shouldReceive('get')->with('config')->andReturn($this->config); - $this->filesystem = new Filesystem($this->app); - - $this->root = vfsStream::setup('rootDir'); - } - - protected function tearDown(): void - { - m::close(); - } - - public function testDisk() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.foo', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk('foo')); - } - - public function testCache() - { - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => 'local', - 'root' => $this->root->url(), - 'cache' => true, - ]); - - $this->assertInstanceOf(Local::class, $this->filesystem->disk()); - - $this->config->shouldReceive('get')->with('filesystem.disks.cache', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $this->root->url(), - 'cache' => [ - 'store' => 'flysystem', - ], - ]); - - $cache = m::mock(Cache::class); - - $cacheDriver = m::mock(File::class); - - $cache->shouldReceive('store')->once()->with('flysystem')->andReturn($cacheDriver); - - $this->app->shouldReceive('make')->with(Cache::class)->andReturn($cache); - - $cacheDriver->shouldReceive('get')->with('flysystem')->once()->andReturn(null); - - $cacheDriver->shouldReceive('set')->withAnyArgs(); - - $this->filesystem->disk('cache')->put('test.txt', 'aa'); - } - - public function testPutFile() - { - $root = vfsStream::setup('rootDir', null, [ - 'foo.jpg' => 'hello', - ]); - - $this->config->shouldReceive('get')->with('filesystem.disks.local', null)->andReturn([ - 'type' => NullDriver::class, - 'root' => $root->url(), - 'cache' => true, - ]); - - $file = m::mock(\think\File::class); - - $file->shouldReceive('hashName')->with(null)->once()->andReturn('foo.jpg'); - - $file->shouldReceive('getRealPath')->once()->andReturn($root->getChild('foo.jpg')->url()); - - $this->filesystem->putFile('test', $file); - } -} - -class NullDriver extends Driver -{ - protected function createAdapter(): AdapterInterface - { - return new NullAdapter(); - } -} diff --git a/vendor/topthink/think-filesystem/tests/bootstrap.php b/vendor/topthink/think-filesystem/tests/bootstrap.php deleted file mode 100644 index a4abe2d..0000000 --- a/vendor/topthink/think-filesystem/tests/bootstrap.php +++ /dev/null @@ -1,2 +0,0 @@ -makePromise(parent::install($repo, $package)); - } - - public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) - { - return $this->makePromise(parent::update($repo, $initial, $target)); - } - - protected function makePromise($promise) - { - if ($promise instanceof PromiseInterface) { - return $promise; - } - return new Promise(); - } -} diff --git a/vendor/topthink/think-installer/src/Plugin.php b/vendor/topthink/think-installer/src/Plugin.php deleted file mode 100644 index 4415232..0000000 --- a/vendor/topthink/think-installer/src/Plugin.php +++ /dev/null @@ -1,34 +0,0 @@ -getInstallationManager(); - - //框架核心 - $manager->addInstaller(new ThinkFramework($io, $composer)); - - //单元测试 - $manager->addInstaller(new ThinkTesting($io, $composer)); - - //扩展 - $manager->addInstaller(new ThinkExtend($io, $composer)); - } - - public function deactivate(Composer $composer, IOInterface $io) - { - - } - - public function uninstall(Composer $composer, IOInterface $io) - { - - } -} diff --git a/vendor/topthink/think-installer/src/Promise.php b/vendor/topthink/think-installer/src/Promise.php deleted file mode 100644 index 6bfed5d..0000000 --- a/vendor/topthink/think-installer/src/Promise.php +++ /dev/null @@ -1,11 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\composer; - -use Composer\Package\PackageInterface; -use Composer\Repository\InstalledRepositoryInterface; - -class ThinkExtend extends LibraryInstaller -{ - public function install(InstalledRepositoryInterface $repo, PackageInterface $package) - { - return parent::install($repo, $package) - ->then(function () use ($package) { - $this->copyExtraFiles($package); - }); - } - - public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) - { - return parent::update($repo, $initial, $target) - ->then(function () use ($target) { - $this->copyExtraFiles($target); - }); - } - - protected function copyExtraFiles(PackageInterface $package) - { - if ($this->composer->getPackage()->getType() == 'project') { - - $extra = $package->getExtra(); - - if (!empty($extra['think-config'])) { - - $configDir = 'config'; - - $this->filesystem->ensureDirectoryExists($configDir); - - //配置文件 - foreach ((array) $extra['think-config'] as $name => $config) { - $target = $configDir . DIRECTORY_SEPARATOR . $name . '.php'; - $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $config; - - if (is_file($target)) { - $this->io->write("File {$target} exist!"); - continue; - } - - if (!is_file($source)) { - $this->io->write("File {$target} not exist!"); - continue; - } - - copy($source, $target); - } - } - } - } - - public function supports($packageType) - { - return 'think-extend' === $packageType; - } -} diff --git a/vendor/topthink/think-installer/src/ThinkFramework.php b/vendor/topthink/think-installer/src/ThinkFramework.php deleted file mode 100644 index 2a7cc03..0000000 --- a/vendor/topthink/think-installer/src/ThinkFramework.php +++ /dev/null @@ -1,66 +0,0 @@ -getPrettyName()) { - throw new InvalidArgumentException('Unable to install this library!'); - } - - if ($this->composer->getPackage()->getType() !== 'project') { - return parent::getInstallPath($package); - } - - if ($this->composer->getPackage()) { - $extra = $this->composer->getPackage()->getExtra(); - if (!empty($extra['think-path'])) { - return $extra['think-path']; - } - } - - return 'thinkphp'; - } - - public function install(InstalledRepositoryInterface $repo, PackageInterface $package) - { - return parent::install($repo, $package) - ->then(function () use ($package) { - $this->removeTestDir($package); - }); - } - - public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) - { - return parent::update($repo, $initial, $target) - ->then(function () use ($target) { - $this->removeTestDir($target); - }); - } - - protected function removeTestDir(PackageInterface $target) - { - if ($this->composer->getPackage()->getType() == 'project' && $target->getInstallationSource() != 'source') { - //remove tests dir - $this->filesystem->removeDirectory($this->getInstallPath($target) . DIRECTORY_SEPARATOR . 'tests'); - } - } - - /** - * {@inheritDoc} - */ - public function supports($packageType) - { - return 'think-framework' === $packageType; - } -} diff --git a/vendor/topthink/think-installer/src/ThinkTesting.php b/vendor/topthink/think-installer/src/ThinkTesting.php deleted file mode 100644 index af74d20..0000000 --- a/vendor/topthink/think-installer/src/ThinkTesting.php +++ /dev/null @@ -1,66 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\composer; - -use Composer\Package\PackageInterface; -use Composer\Repository\InstalledRepositoryInterface; -use InvalidArgumentException; - -class ThinkTesting extends LibraryInstaller -{ - /** - * {@inheritDoc} - */ - public function getInstallPath(PackageInterface $package) - { - if ('topthink/think-testing' !== $package->getPrettyName()) { - throw new InvalidArgumentException('Unable to install this library!'); - } - - return parent::getInstallPath($package); - } - - public function install(InstalledRepositoryInterface $repo, PackageInterface $package) - { - return parent::install($repo, $package) - ->then(function () use ($package) { - $this->copyTestDir($package); - }); - } - - public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) - { - return parent::update($repo, $initial, $target) - ->then(function () use ($target) { - $this->copyTestDir($target); - }); - } - - private function copyTestDir(PackageInterface $package) - { - $appDir = dirname($this->vendorDir); - $source = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . 'example'; - if (!is_file($appDir . DIRECTORY_SEPARATOR . 'phpunit.xml')) { - $this->filesystem->copyThenRemove($source, $appDir); - } else { - $this->filesystem->removeDirectoryPhp($source); - } - } - - /** - * {@inheritDoc} - */ - public function supports($packageType) - { - return 'think-testing' === $packageType; - } -} diff --git a/vendor/topthink/think-migration/.gitignore b/vendor/topthink/think-migration/.gitignore deleted file mode 100644 index 30babff..0000000 --- a/vendor/topthink/think-migration/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/vendor/ -.idea -composer.lock diff --git a/vendor/topthink/think-migration/LICENSE b/vendor/topthink/think-migration/LICENSE deleted file mode 100644 index 2c76a5a..0000000 --- a/vendor/topthink/think-migration/LICENSE +++ /dev/null @@ -1,32 +0,0 @@ - -ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 -版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn) -All rights reserved。 -ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 - -Apache Licence是著名的非盈利开源组织Apache采用的协议。 -该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, -允许代码修改,再作为开源或商业软件发布。需要满足 -的条件: -1. 需要给代码的用户一份Apache Licence ; -2. 如果你修改了代码,需要在被修改的文件中说明; -3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 -带有原来代码中的协议,商标,专利声明和其他原来作者规 -定需要包含的说明; -4. 如果再发布的产品中包含一个Notice文件,则在Notice文 -件中需要带有本协议内容。你可以在Notice中增加自己的 -许可,但不可以表现为对Apache Licence构成更改。 -具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 - -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. \ No newline at end of file diff --git a/vendor/topthink/think-migration/README.md b/vendor/topthink/think-migration/README.md deleted file mode 100644 index 39e6584..0000000 --- a/vendor/topthink/think-migration/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# thinkphp6 数据库迁移工具 - -## 安装 -~~~ -composer require topthink/think-migration -~~~ diff --git a/vendor/topthink/think-migration/composer.json b/vendor/topthink/think-migration/composer.json deleted file mode 100644 index 78af31f..0000000 --- a/vendor/topthink/think-migration/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "topthink/think-migration", - "authors": [ - { - "name": "yunwuxin", - "email": "448901948@qq.com" - } - ], - "license": "Apache-2.0", - "autoload": { - "psr-4": { - "Phinx\\": "phinx/src/Phinx", - "think\\migration\\": "src" - } - }, - "extra": { - "think": { - "services": [ - "think\\migration\\Service" - ] - } - }, - "require": { - "topthink/framework": "^6.0", - "topthink/think-helper": "^3.0.3" - }, - "minimum-stability": "dev", - "suggest": { - "fzaninotto/faker": "Required to use the factory builder (^1.8)." - }, - "require-dev": { - "fzaninotto/faker": "^1.8" - } -} diff --git a/vendor/topthink/think-migration/phinx/CHANGELOG.md b/vendor/topthink/think-migration/phinx/CHANGELOG.md deleted file mode 100644 index df1c2e4..0000000 --- a/vendor/topthink/think-migration/phinx/CHANGELOG.md +++ /dev/null @@ -1,370 +0,0 @@ -# Version History - -**0.6.5** (Thursday, 27 October 2016) - -* Documentation updates -* Pull requests - * [#831](https://github.com/robmorgan/phinx/pull/831) Typos - * [#929](https://github.com/robmorgan/phinx/pull/929) Support glob brace for seed paths - * [#949](https://github.com/robmorgan/phinx/pull/949) Fix for Config::getMigrationBaseClassName - * [#958](https://github.com/robmorgan/phinx/pull/958) Allow console input to be used within adapters - -**0.6.4** (Wednesday, 27th July 2016) - -* Documentation updates -* Pull requests - * [#909](https://github.com/robmorgan/phinx/pull/909) Declare test class properties - * [#910](https://github.com/robmorgan/phinx/pull/910), [#916](https://github.com/robmorgan/phinx/pull/916) Remove unused variables - * [#912](https://github.com/robmorgan/phinx/pull/912) ConfigInterface usage consistency - * [#914](https://github.com/robmorgan/phinx/pull/914) Set return values and @return documentation - * [#918](https://github.com/robmorgan/phinx/pull/918) Docblock correction for Phinx\Migration\Manager::executeSeed() - * [#921](https://github.com/robmorgan/phinx/pull/921) Add Phinx\Wrapper\TextWrapper::getSeed() -* Bug fixes - * [#908](https://github.com/robmorgan/phinx/pull/908) Fix setting options for Column, ForeignKey and Index - * [#922](https://github.com/robmorgan/phinx/pull/922) SQLite adapter drops table on changeColumn if there's a foreign key - -**0.6.3** (Monday, 18th July 2016) - -* New features - * [#707](https://github.com/robmorgan/phinx/pull/707/files) Add arguments for timestamps columns names -* Documentation cleanup -* Bug fixes - * [#884](https://github.com/robmorgan/phinx/pull/884) Only rollback 1 migration when only 2 migrations exist - * Input and Output are now correctly supplied to migration template creation classes - -**0.6.2** (Thursday, 23rd June 2016) - -* Fix breakpoint support for Postgres -* HHVM now passes all tests - -**0.6.1** (Tuesday, 21st June 2016) - -* Fix rollback when only 1 migration - -**0.6.0** (Tuesday, 21st June 2016) - -* Backward incompatibility - see [UPGRADE_0.6](UPGRADE_0.6.md) document -* Introduce Input and Output access to migrations and template creation -* New breakpoint command -* Moved version history to this CHANGELOG.md document -* More tests - -**0.5.5** (Friday, 17th May 2016) - -* Fix support for running multiple seeders -* Bug fix for migration template source - defaults and command line -* Bug fixes - -**0.5.4** (Monday, 25th April 2016) - -* Added support for running multiple seeders -* Use `GLOB_BRACE` when finding migrations only if its available -* Added support for MySQL `VARBINARY` column type -* Minor bug fixes - -**0.5.3** (Monday, 7th March 2016) - -* Critical fix: allow `migration_name` to be `null`. Introduced in 0.5.2 -* Status command now shows migration start and end times -* Bug fix for rolling back by date -* Documentation improvements - -**0.5.2** (Tuesday, 1st March 2016) - -* Status command now includes missing migration names -* Added support for Postgres table comments -* Added `insert()` for the TablePrefixAdapter -* Fixed the migration verbosity flag -* Added MySQL 5.7 JSON support -* Added support for MySQL `FULLTEXT` indexes -* Postgres now supports `BIGSERIAL` for primary keys -* Added support for MySQL index limits -* Initial support for multiple migration paths (using glob) -* Documentation improvements -* Unit test enhancements - -**0.5.1** (Wednesday, 30th December 2015) - -* **PHP 5.3 is no longer supported!** -* Add support for Symfony 3.0 components -* Ensure that the `status` command returns the correct exit code -* Allow `$version` to be passed into templates -* Support for MySQL `YEAR` column type -* Multiple documentation updates and corrections - -**0.5.0** (Monday, 30th November 2015) - -* Support for seeding data after database creation -* The migration and seed directories are now nested under `db` by default -* Moved `Phinx\Migration\Util` to `Phinx\Util\Util` -* All `insert()` methods now have a slightly different method signature -* Fixed key/insert operations for MySQL -* Introduced `AdapterInterface::hasIndexByName()` -* Improved `dropForeignKey()` handling for SQLite -* Added support for the MySQL `binary` datatype. BLOBs now use the proper type. -* The status command shows a count of pending migrations in JSON output -* We are now testing against PHP 7 - -**0.4.6** (Friday, 11th September 2015) - -* You can now set custom migration templates in the config files -* Support for MySQL unsigned booleans -* Support for Postgres `smallint` column types -* Support for `AFTER` when using `changeColumn()` with MySQL -* Support for `precision` and `scale` when using the Postgres `decimal` type -* Fixed a bug where duplicate migration names could be used -* The schema table is now created with a primary key -* Fixed issues when using the MySQL `STRICT_TRANS_TABLE` mode -* Improved the docs in the default migration template -* Made Box PHAR ignore the bundled `phinx.yml` configuration file -* Updated Box installer URL -* Internal code improvements -* Documentation improvements - -**0.4.5** (Tuesday, 1st September 2015) - -* The rollback command now supports a date argument -* Fixed DBLIB DSN strings for Microsoft SQL Server -* Postgres support for `jsonb` columns added -* The `addTimestamps()` helper method no longer updates the `created_at` column -* Fix for Postgres named foreign keys -* Unit test improvements (including strict warnings) -* Documentation improvements - -**0.4.4** (Sunday, 14th June 2015) - -* The `change` method is now the default -* Added a generic adapter insert method. Warning: The implementation will change! -* Updated Symfony depdencies to ~2.7 -* Support for MySQL `BLOB` column types -* SQLite migration fixes -* Documentation improvements - -**0.4.3** (Monday, 23rd Feburary 2015) - -* Postgres bugfix for modifying column DEFAULTs -* MySQL bugfix for setting column INTEGER lengths -* SQLite bugfix for creating multiple indexes with similar names - -**0.4.2.1** (Saturday, 7th Feburary 2015) - -* Proper release, updated docs - -**0.4.2** (Friday, 6th Feburary 2015) - -* Postgres support for `json` columns added -* MySQL support for `enum` and `set` columns added -* Allow setting `identity` option on columns -* Template configuration and generation made more extensible -* Created a base class for `ProxyAdapter` and `TablePrefixAdapter` -* Switched to PSR-4 - -**0.4.1** (Tuesday, 23rd December 2014) - -* MySQL support for reserved words in hasColumn and getColumns methods -* Better MySQL Adapter test coverage and performance fixes -* Updated dependent Symfony components to 2.6.x - -**0.4.0** (Sunday, 14th December 2014) - -* Adding initial support for running Phinx via a web interface -* Support for table prefixes and suffixes -* Bugfix for foreign key options -* MySQL keeps column default when renaming columns -* MySQL support for tiny/medium and longtext columns added -* Changed SQL Server binary columns to varbinary -* MySQL supports table comments -* Postgres supports column comments -* Empty strings are now supported for default column values -* Booleans are now supported for default column values -* Fixed SQL Server default constraint error when changing column types -* Migration timestamps are now created in UTC -* Locked Symfony Components to 2.5.0 -* Support for custom migration base classes -* Cleaned up source code formatting -* Migrations have access to the output stream -* Support for custom PDO connections when a PHP config -* Added support for Postgres UUID type -* Fixed issue with Postgres dropping foreign keys - -**0.3.8** (Sunday, 5th October 2014) - -* Added new CHAR & Geospatial column types -* Added MySQL unix socket support -* Added precision & scale support for SQL Server -* Several bug fixes for SQLite -* Improved error messages -* Overall code optimizations -* Optimizations to MySQL hasTable method - -**0.3.7** (Tuesday, 12th August 2014) - -* Smarter configuration file support -* Support for Postgres Schemas -* Fixed charset support for Microsoft SQL Server -* Fix for Unique indexes in all adapters -* Improvements for MySQL foreign key migration syntax -* Allow MySQL column types with extra info -* Fixed SQLite autoincrement behaviour -* PHPDoc improvements -* Documentation improvements -* Unit test improvements -* Removing primary_key as a type - -**0.3.6** (Sunday, 29th June 2014) - -* Add custom adapter support -* Fix PHP 5.3 compatibility for SQL Server - -**0.3.5** (Saturday, 21st June 2014) - -* Added Microsoft SQL Server support -* Removed Primary Key column type -* Cleaned up and optimized many methods -* Updated Symfony dependencies to v2.5.0 -* PHPDoc improvements - -**0.3.4** (Sunday, 27th April 2014) - -* Added support MySQL unsigned integer, biginteger, float and decimal types -* Added JSON output support for the status command -* Fix a bug where Postgres couldnt rollback foreign keys -* Moved Phinx type references to interface constants -* Fixed a bug with SQLite in-memory databases - -**0.3.3** (Saturday, 22nd March 2014) - -* Added support for JSON configuration -* Named index support for all adapters (thanks @archer308) -* Updated Composer dependencies -* Fix for SQLite Integer Type -* Fix for MySQL port option - -**0.3.2** (Monday, 24th February 2014) - -* Adding better Postgres type support - -**0.3.1** (Sunday, 23rd February 2014) - -* Adding MySQL charset support to the YAML config -* Removing trailing spaces - -**0.3.0** (Sunday, 2nd February 2014) - -* PSR-2 support -* Method to add timestamps easily to tables -* Support for column comments in the Postgres adapter -* Fixes for MySQL driver options -* Fixes for MySQL biginteger type - -**0.2.9** (Saturday, 16th November 2013) - -* Added SQLite Support -* Improving the unit tests, especially on Windows - -**0.2.8** (Sunday, 25th August 2013) - -* Added PostgresSQL Support - -**0.2.7** (Saturday, 24th August 2013) - -* Critical fix for a token parsing bug -* Removed legacy build system -* Improving docs - -**0.2.6** (Saturday, 24th August 2013) - -* Added support for environment vars in config files -* Added support for environment vars to set the Phinx Env -* Improving docs -* Fixed a bug with column names in indexes -* Changes for developers in regards to the unit tests - -**0.2.5** (Sunday, 26th May 2013) - -* Added support for Box Phar Archive Packaging -* Added support for MYSQL_ATTR driver options -* Fixed a bug where foreign keys cannot be removed -* Added support for MySQL table collation -* Updated Composer dependencies -* Removed verbosity options, now relies on Symfony instead -* Improved unit tests - -**0.2.4** (Saturday, 20th April 2013) - -* The Rollback command supports the verbosity parameter -* The Rollback command has more detailed output -* Table::dropForeignKey now returns the table instance - -**0.2.3** (Saturday, 6th April 2013) - -* Fixed a reporting bug when Phinx couldn't connect to a database -* Added support for the MySQL 'ON UPDATE' function -* Phinx timestamp is now mapped to MySQL timestamp instead of datetime -* Fixed a docs typo for the minimum PHP version -* Added UTF8 support for migrations -* Changed regex to handle migration names differently -* Added support for custom MySQL table engines such as MyISAM -* Added the change method to the migration template - -**0.2.2** (Sunday, 3rd March 2013) - -* Added a new verbosity parameter to see more output when migrating -* Support for PHP config files - -**0.2.1** (Sunday, 3rd March 2013) - -* Broken Release. Do not use! -* Unit tests no longer rely on the default phinx.yml file -* Running migrate for the first time does not give php warnings -* `default_migration_table` is now actually supported -* Updated docblocks to 2013. - -**0.2.0** (Sunday, 13th January 2013) - -* First Birthday Release -* Added Reversible Migrations -* Removed options parameter from AdapterInterface::hasColumn() - -**0.1.7** (Tuesday, 8th January 2013) - -* Improved documentation on the YAML configuration file -* Removed options parameter from AdapterInterface::dropIndex() - -**0.1.6** (Sunday, 9th December 2012) - -* Added foreign key support -* Removed PEAR support -* Support for auto_increment on custom id columns -* Bugfix for column default value 0 -* Documentation improvements - -**0.1.5** (Sunday, 4th November 2012) - -* Added a test command -* Added transactions for adapters that support it -* Changing the Table API to use pending column methods -* Fixed a bug when defining multiple indexes on a table - -**0.1.4** (Sunday, 21st October 2012) - -* Documentation Improvements - -**0.1.3** (Saturday, 20th October 2012) - -* Fixed broken composer support - -**0.1.2** (Saturday, 20th October 2012) - -* Added composer support -* Now forces migrations to be in CamelCase format -* Now specifies the database name when migrating -* Creates the internal log table using its API instead of raw SQL - -**0.1.1** (Wednesday, 13th June 2012) - -* First point release. Ready for limited production use. - -**0.1.0** (Friday, 13th January 2012) - -* Initial public release. diff --git a/vendor/topthink/think-migration/phinx/CONTRIBUTING.md b/vendor/topthink/think-migration/phinx/CONTRIBUTING.md deleted file mode 100644 index 73b54ac..0000000 --- a/vendor/topthink/think-migration/phinx/CONTRIBUTING.md +++ /dev/null @@ -1,66 +0,0 @@ -# How to contribute to Phinx - -Phinx relies heavily on external contributions in order to make it the best database migration -tool possible. Without the support of our 115+ contributors we wouldn't be where we are today! -We encourage anyone to submit documentation enhancements and code. - -Issues, feature requests and bugs should be submitted using the Github issue tool: -https://github.com/robmorgan/phinx/issues. - -This document briefly outlines the requirements to contribute code to Phinx. - -## Considerations - -Before you submit your pull request take a moment to answer the following questions. - -Answering '**YES**' to all questions will increase the likelihood of your PR being accepted! - -* Have I implemented my feature for as many database adapters as possible? -* Does my new feature improve Phinx's performance or keep it consistent? -* Does my feature fit within the database migration space? -* Is the code entirely my own and free from any commercial licensing? -* Am I happy to release my code under the MIT license? -* Is my code formatted using the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) coding standard? - -**Note:** We accept bug fixes much faster into our development branch than features. - -## Getting Started - -Great, so you want to contribute. Let's get started: - -1. Start by forking Phinx on GitHub: https://github.com/robmorgan/phinx - -1. Clone your repository to a local directory on your development box. - -1. If you do not have Composer set up already, install it: - - ``` - curl -sS https://getcomposer.org/installer | php - ``` - -1. Change to your Phinx clone directory and pull the necessary dependencies: - - ``` - php composer.phar install - ``` - -1. Copy the `phpunit.xml.dist` template to `phpunit.xml` and change the configuration to suit your environment. If you are not using any particular adapter you can disable it in the `phpunit.xml` file. - -1. Run the unit tests locally to ensure they pass: - - ``` - php vendor/bin/phpunit --config phpunit.xml - ``` - -1. Write the code and unit tests for your bug fix or feature. - -1. Add any relevant documentation. - -1. Run the unit tests again and ensure they pass. - -1. Open a pull request on the Github project page. Ensure the code is being merged into the latest development branch (e.g: `0.5.x-dev`) and not `master`. - -## Documentation - -The Phinx documentation is stored in the **docs** directory using the [RestructedText](http://docutils.sourceforge.net/rst.html) format. All documentation merged to `master` is automatically published to the Phinx documentation site available -at: http://docs.phinx.org. Keep this in mind when submitting your PR, or ask someone to merge the development branch back down to master. diff --git a/vendor/topthink/think-migration/phinx/LICENSE b/vendor/topthink/think-migration/phinx/LICENSE deleted file mode 100644 index 26ade90..0000000 --- a/vendor/topthink/think-migration/phinx/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -(The MIT license) - -Copyright (c) 2014 Rob Morgan - -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. \ No newline at end of file diff --git a/vendor/topthink/think-migration/phinx/README.md b/vendor/topthink/think-migration/phinx/README.md deleted file mode 100644 index ed1badc..0000000 --- a/vendor/topthink/think-migration/phinx/README.md +++ /dev/null @@ -1,128 +0,0 @@ -# [Phinx](https://phinx.org): Simple PHP Database Migrations - -[![Build Status](https://travis-ci.org/robmorgan/phinx.png?branch=master)](https://travis-ci.org/robmorgan/phinx) -[![Build status](https://ci.appveyor.com/api/projects/status/9vag4892hfq6effr)](https://ci.appveyor.com/project/robmorgan/phinx) -[![Code Coverage](https://scrutinizer-ci.com/g/robmorgan/phinx/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/robmorgan/phinx/) -[![Latest Stable Version](https://poser.pugx.org/robmorgan/phinx/version.png)](https://packagist.org/packages/robmorgan/phinx) -[![Total Downloads](https://poser.pugx.org/robmorgan/phinx/d/total.png)](https://packagist.org/packages/robmorgan/phinx) - -Phinx makes it ridiculously easy to manage the database migrations for your PHP app. In less than 5 minutes you can install Phinx and create your first database migration. Phinx is just about migrations without all the bloat of a database ORM system or framework. - -**Check out http://docs.phinx.org for the comprehensive documentation.** - -![phinxterm](https://cloud.githubusercontent.com/assets/178939/3887559/e6b5e524-21f2-11e4-8256-0ba6040725fc.gif) - -### Features - -* Write database migrations using database agnostic PHP code. -* Migrate up and down. -* Migrate on deployment. -* Seed data after database creation. -* Get going in less than 5 minutes. -* Stop worrying about the state of your database. -* Take advantage of SCM features such as branching. -* Integrate with any app. - -### Supported Adapters - -Phinx natively supports the following database adapters: - -* MySQL -* PostgreSQL -* SQLite -* Microsoft SQL Server - -## Install & Run - -### Composer - -The fastest way to install Phinx is to add it to your project using Composer (http://getcomposer.org/). - -1. Install Composer: - - ``` - curl -sS https://getcomposer.org/installer | php - ``` - -1. Require Phinx as a dependency using Composer: - - ``` - php composer.phar require robmorgan/phinx - ``` - -1. Install Phinx: - - ``` - php composer.phar install - ``` - -1. Execute Phinx: - - ``` - php vendor/bin/phinx - ``` - -### As a Phar - -You can also use the Box application to build Phinx as a Phar archive (https://box-project.github.io/box2/). - -1. Clone Phinx from GitHub - - ``` - git clone git://github.com/robmorgan/phinx.git - cd phinx - ``` - -1. Install Composer - - ``` - curl -s https://getcomposer.org/installer | php - ``` - -1. Install the Phinx dependencies - - ``` - php composer.phar install - ``` - -1. Install Box: - - ``` - curl -LSs https://box-project.github.io/box2/installer.php | php - ``` - -1. Create a Phar archive - - ``` - php box.phar build - ``` - -## Documentation - -Check out http://docs.phinx.org for the comprehensive documentation. - -## Contributing - -Please read the [CONTRIBUTING](CONTRIBUTING.md) document. - -## News & Updates - -Follow Rob (@\_rjm\_) on Twitter to stay up to date (http://twitter.com/_rjm_) - -## Misc - -### Version History - -Please read the [CHANGELOG](CHANGELOG.md) document. - -### License - -(The MIT license) - -Copyright (c) 2016 Rob Morgan - -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. diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php deleted file mode 100644 index 90674f9..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterFactory.php +++ /dev/null @@ -1,181 +0,0 @@ - - */ -class AdapterFactory -{ - /** - * @var AdapterFactory - */ - protected static $instance; - - /** - * Get the factory singleton instance. - * - * @return AdapterFactory - */ - public static function instance() - { - if (!static::$instance) { - static::$instance = new static(); - } - return static::$instance; - } - - /** - * Class map of database adapters, indexed by PDO::ATTR_DRIVER_NAME. - * - * @var array - */ - protected $adapters = array( - 'mysql' => 'Phinx\Db\Adapter\MysqlAdapter', - 'pgsql' => 'Phinx\Db\Adapter\PostgresAdapter', - 'sqlite' => 'Phinx\Db\Adapter\SQLiteAdapter', - 'sqlsrv' => 'Phinx\Db\Adapter\SqlServerAdapter', - ); - - /** - * Class map of adapters wrappers, indexed by name. - * - * @var array - */ - protected $wrappers = array( - 'prefix' => 'Phinx\Db\Adapter\TablePrefixAdapter', - 'proxy' => 'Phinx\Db\Adapter\ProxyAdapter', - ); - - /** - * Add or replace an adapter with a fully qualified class name. - * - * @throws \RuntimeException - * @param string $name - * @param string $class - * @return $this - */ - public function registerAdapter($name, $class) - { - if (!is_subclass_of($class, 'Phinx\Db\Adapter\AdapterInterface')) { - throw new \RuntimeException(sprintf( - 'Adapter class "%s" must implement Phinx\\Db\\Adapter\\AdapterInterface', - $class - )); - } - $this->adapters[$name] = $class; - return $this; - } - - /** - * Get an adapter class by name. - * - * @throws \RuntimeException - * @param string $name - * @return string - */ - protected function getClass($name) - { - if (empty($this->adapters[$name])) { - throw new \RuntimeException(sprintf( - 'Adapter "%s" has not been registered', - $name - )); - } - return $this->adapters[$name]; - } - - /** - * Get an adapter instance by name. - * - * @param string $name - * @param array $options - * @return AdapterInterface - */ - public function getAdapter($name, array $options) - { - $class = $this->getClass($name); - return new $class($options); - } - - /** - * Add or replace a wrapper with a fully qualified class name. - * - * @throws \RuntimeException - * @param string $name - * @param string $class - * @return $this - */ - public function registerWrapper($name, $class) - { - if (!is_subclass_of($class, 'Phinx\Db\Adapter\WrapperInterface')) { - throw new \RuntimeException(sprintf( - 'Wrapper class "%s" must be implement Phinx\\Db\\Adapter\\WrapperInterface', - $class - )); - } - $this->wrappers[$name] = $class; - return $this; - } - - /** - * Get a wrapper class by name. - * - * @throws \RuntimeException - * @param string $name - * @return string - */ - protected function getWrapperClass($name) - { - if (empty($this->wrappers[$name])) { - throw new \RuntimeException(sprintf( - 'Wrapper "%s" has not been registered', - $name - )); - } - return $this->wrappers[$name]; - } - - /** - * Get a wrapper instance by name. - * - * @param string $name - * @param AdapterInterface $adapter - * @return AdapterInterface - */ - public function getWrapper($name, AdapterInterface $adapter) - { - $class = $this->getWrapperClass($name); - return new $class($adapter); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterInterface.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterInterface.php deleted file mode 100644 index f2e9fe1..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterInterface.php +++ /dev/null @@ -1,510 +0,0 @@ - - */ -interface AdapterInterface -{ - const PHINX_TYPE_STRING = 'string'; - const PHINX_TYPE_CHAR = 'char'; - const PHINX_TYPE_TEXT = 'text'; - const PHINX_TYPE_INTEGER = 'integer'; - const PHINX_TYPE_BIG_INTEGER = 'biginteger'; - const PHINX_TYPE_FLOAT = 'float'; - const PHINX_TYPE_DECIMAL = 'decimal'; - const PHINX_TYPE_DATETIME = 'datetime'; - const PHINX_TYPE_TIMESTAMP = 'timestamp'; - const PHINX_TYPE_TIME = 'time'; - const PHINX_TYPE_DATE = 'date'; - const PHINX_TYPE_BINARY = 'binary'; - const PHINX_TYPE_VARBINARY = 'varbinary'; - const PHINX_TYPE_BLOB = 'blob'; - const PHINX_TYPE_BOOLEAN = 'boolean'; - const PHINX_TYPE_JSON = 'json'; - const PHINX_TYPE_JSONB = 'jsonb'; - const PHINX_TYPE_UUID = 'uuid'; - const PHINX_TYPE_FILESTREAM = 'filestream'; - - // Geospatial database types - const PHINX_TYPE_GEOMETRY = 'geometry'; - const PHINX_TYPE_POINT = 'point'; - const PHINX_TYPE_LINESTRING = 'linestring'; - const PHINX_TYPE_POLYGON = 'polygon'; - - // only for mysql so far - const PHINX_TYPE_ENUM = 'enum'; - const PHINX_TYPE_SET = 'set'; - - /** - * Get all migrated version numbers. - * - * @return array - */ - public function getVersions(); - - /** - * Get all migration log entries, indexed by version number. - * - * @return array - */ - public function getVersionLog(); - - /** - * Set adapter configuration options. - * - * @param array $options - * @return AdapterInterface - */ - public function setOptions(array $options); - - /** - * Get all adapter options. - * - * @return array - */ - public function getOptions(); - - /** - * Check if an option has been set. - * - * @param string $name - * @return boolean - */ - public function hasOption($name); - - /** - * Get a single adapter option, or null if the option does not exist. - * - * @param string $name - * @return mixed - */ - public function getOption($name); - - /** - * Sets the console input. - * - * @param InputInterface $input Input - * @return AdapterInterface - */ - public function setInput(InputInterface $input); - - /** - * Gets the console input. - * - * @return InputInterface - */ - public function getInput(); - - /** - * Sets the console output. - * - * @param OutputInterface $output Output - * @return AdapterInterface - */ - public function setOutput(OutputInterface $output); - - /** - * Gets the console output. - * - * @return OutputInterface - */ - public function getOutput(); - - /** - * Records a migration being run. - * - * @param MigrationInterface $migration Migration - * @param string $direction Direction - * @param int $startTime Start Time - * @param int $endTime End Time - * @return AdapterInterface - */ - public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime); - - /** - * Toggle a migration breakpoint. - * - * @param MigrationInterface $migration - * - * @return AdapterInterface - */ - public function toggleBreakpoint(MigrationInterface $migration); - - /** - * Reset all migration breakpoints. - * - * @return int The number of breakpoints reset - */ - public function resetAllBreakpoints(); - - /** - * Does the schema table exist? - * - * @deprecated use hasTable instead. - * @return boolean - */ - public function hasSchemaTable(); - - /** - * Creates the schema table. - * - * @return void - */ - public function createSchemaTable(); - - /** - * Returns the adapter type. - * - * @return string - */ - public function getAdapterType(); - - /** - * Initializes the database connection. - * - * @throws \RuntimeException When the requested database driver is not installed. - * @return void - */ - public function connect(); - - /** - * Closes the database connection. - * - * @return void - */ - public function disconnect(); - - /** - * Does the adapter support transactions? - * - * @return boolean - */ - public function hasTransactions(); - - /** - * Begin a transaction. - * - * @return void - */ - public function beginTransaction(); - - /** - * Commit a transaction. - * - * @return void - */ - public function commitTransaction(); - - /** - * Rollback a transaction. - * - * @return void - */ - public function rollbackTransaction(); - - /** - * Executes a SQL statement and returns the number of affected rows. - * - * @param string $sql SQL - * @return int - */ - public function execute($sql); - - /** - * Executes a SQL statement and returns the result as an array. - * - * @param string $sql SQL - * @return array - */ - public function query($sql); - - /** - * Executes a query and returns only one row as an array. - * - * @param string $sql SQL - * @return array - */ - public function fetchRow($sql); - - /** - * Executes a query and returns an array of rows. - * - * @param string $sql SQL - * @return array - */ - public function fetchAll($sql); - - /** - * Inserts data into a table. - * - * @param Table $table where to insert data - * @param array $row - * @return void - */ - public function insert(Table $table, $row); - - /** - * Quotes a table name for use in a query. - * - * @param string $tableName Table Name - * @return string - */ - public function quoteTableName($tableName); - - /** - * Quotes a column name for use in a query. - * - * @param string $columnName Table Name - * @return string - */ - public function quoteColumnName($columnName); - - /** - * Checks to see if a table exists. - * - * @param string $tableName Table Name - * @return boolean - */ - public function hasTable($tableName); - - /** - * Creates the specified database table. - * - * @param Table $table Table - * @return void - */ - public function createTable(Table $table); - - /** - * Renames the specified database table. - * - * @param string $tableName Table Name - * @param string $newName New Name - * @return void - */ - public function renameTable($tableName, $newName); - - /** - * Drops the specified database table. - * - * @param string $tableName Table Name - * @return void - */ - public function dropTable($tableName); - - /** - * Returns table columns - * - * @param string $tableName Table Name - * @return Column[] - */ - public function getColumns($tableName); - - /** - * Checks to see if a column exists. - * - * @param string $tableName Table Name - * @param string $columnName Column Name - * @return boolean - */ - public function hasColumn($tableName, $columnName); - - /** - * Adds the specified column to a database table. - * - * @param Table $table Table - * @param Column $column Column - * @return void - */ - public function addColumn(Table $table, Column $column); - - /** - * Renames the specified column. - * - * @param string $tableName Table Name - * @param string $columnName Column Name - * @param string $newColumnName New Column Name - * @return void - */ - public function renameColumn($tableName, $columnName, $newColumnName); - - /** - * Change a table column type. - * - * @param string $tableName Table Name - * @param string $columnName Column Name - * @param Column $newColumn New Column - * @return Table - */ - public function changeColumn($tableName, $columnName, Column $newColumn); - - /** - * Drops the specified column. - * - * @param string $tableName Table Name - * @param string $columnName Column Name - * @return void - */ - public function dropColumn($tableName, $columnName); - - /** - * Checks to see if an index exists. - * - * @param string $tableName Table Name - * @param mixed $columns Column(s) - * @return boolean - */ - public function hasIndex($tableName, $columns); - - /** - * Checks to see if an index specified by name exists. - * - * @param string $tableName Table Name - * @param string $indexName - * @return boolean - */ - public function hasIndexByName($tableName, $indexName); - - /** - * Adds the specified index to a database table. - * - * @param Table $table Table - * @param Index $index Index - * @return void - */ - public function addIndex(Table $table, Index $index); - - /** - * Drops the specified index from a database table. - * - * @param string $tableName - * @param mixed $columns Column(s) - * @return void - */ - public function dropIndex($tableName, $columns); - - /** - * Drops the index specified by name from a database table. - * - * @param string $tableName - * @param string $indexName - * @return void - */ - public function dropIndexByName($tableName, $indexName); - - /** - * Checks to see if a foreign key exists. - * - * @param string $tableName - * @param string[] $columns Column(s) - * @param string $constraint Constraint name - * @return boolean - */ - public function hasForeignKey($tableName, $columns, $constraint = null); - - /** - * Adds the specified foreign key to a database table. - * - * @param Table $table - * @param ForeignKey $foreignKey - * @return void - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey); - - /** - * Drops the specified foreign key from a database table. - * - * @param string $tableName - * @param string[] $columns Column(s) - * @param string $constraint Constraint name - * @return void - */ - public function dropForeignKey($tableName, $columns, $constraint = null); - - /** - * Returns an array of the supported Phinx column types. - * - * @return array - */ - public function getColumnTypes(); - - /** - * Checks that the given column is of a supported type. - * - * @param Column $column - * @return boolean - */ - public function isValidColumnType(Column $column); - - /** - * Converts the Phinx logical type to the adapter's SQL type. - * - * @param string $type - * @param integer $limit - * @return string - */ - public function getSqlType($type, $limit = null); - - /** - * Creates a new database. - * - * @param string $name Database Name - * @param array $options Options - * @return void - */ - public function createDatabase($name, $options = array()); - - /** - * Checks to see if a database exists. - * - * @param string $name Database Name - * @return boolean - */ - public function hasDatabase($name); - - /** - * Drops the specified database. - * - * @param string $name Database Name - * @return void - */ - public function dropDatabase($name); -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterWrapper.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterWrapper.php deleted file mode 100644 index ae5ec39..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/AdapterWrapper.php +++ /dev/null @@ -1,507 +0,0 @@ - - */ -abstract class AdapterWrapper implements AdapterInterface, WrapperInterface -{ - /** - * @var AdapterInterface - */ - protected $adapter; - - /** - * {@inheritdoc} - */ - public function __construct(AdapterInterface $adapter) - { - $this->setAdapter($adapter); - } - - /** - * {@inheritdoc} - */ - public function setAdapter(AdapterInterface $adapter) - { - $this->adapter = $adapter; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->adapter->setOptions($options); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return $this->adapter->getOptions(); - } - - /** - * {@inheritdoc} - */ - public function hasOption($name) - { - return $this->adapter->hasOption($name); - } - - /** - * {@inheritdoc} - */ - public function getOption($name) - { - return $this->adapter->getOption($name); - } - - /** - * {@inheritdoc} - */ - public function setInput(InputInterface $input) - { - $this->adapter->setInput($input); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getInput() - { - return $this->adapter->getInput(); - } - - /** - * {@inheritdoc} - */ - public function setOutput(OutputInterface $output) - { - $this->adapter->setOutput($output); - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOutput() - { - return $this->adapter->getOutput(); - } - - /** - * {@inheritdoc} - */ - public function connect() - { - return $this->getAdapter()->connect(); - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - return $this->getAdapter()->disconnect(); - } - - /** - * {@inheritdoc} - */ - public function execute($sql) - { - return $this->getAdapter()->execute($sql); - } - - /** - * {@inheritdoc} - */ - public function query($sql) - { - return $this->getAdapter()->query($sql); - } - - /** - * {@inheritdoc} - */ - public function insert(Table $table, $row) - { - return $this->getAdapter()->insert($table, $row); - } - - /** - * {@inheritdoc} - */ - public function fetchRow($sql) - { - return $this->getAdapter()->fetchRow($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchAll($sql) - { - return $this->getAdapter()->fetchAll($sql); - } - - /** - * {@inheritdoc} - */ - public function getVersions() - { - return $this->getAdapter()->getVersions(); - } - - /** - * {@inheritdoc} - */ - public function getVersionLog() - { - return $this->getAdapter()->getVersionLog(); - } - - /** - * {@inheritdoc} - */ - public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime) - { - $this->getAdapter()->migrated($migration, $direction, $startTime, $endTime); - return $this; - } - - /** - * @inheritDoc - */ - public function toggleBreakpoint(MigrationInterface $migration) - { - $this->getAdapter()->toggleBreakpoint($migration); - return $this; - } - - /** - * @inheritDoc - */ - public function resetAllBreakpoints() - { - return $this->getAdapter()->resetAllBreakpoints(); - } - - /** - * {@inheritdoc} - */ - public function hasSchemaTable() - { - return $this->getAdapter()->hasSchemaTable(); - } - - /** - * {@inheritdoc} - */ - public function createSchemaTable() - { - return $this->getAdapter()->createSchemaTable(); - } - - /** - * {@inheritdoc} - */ - public function getColumnTypes() - { - return $this->getAdapter()->getColumnTypes(); - } - - /** - * {@inheritdoc} - */ - public function isValidColumnType(Column $column) - { - return $this->getAdapter()->isValidColumnType($column); - } - - /** - * {@inheritdoc} - */ - public function hasTransactions() - { - return $this->getAdapter()->hasTransactions(); - } - - /** - * {@inheritdoc} - */ - public function beginTransaction() - { - return $this->getAdapter()->beginTransaction(); - } - - /** - * {@inheritdoc} - */ - public function commitTransaction() - { - return $this->getAdapter()->commitTransaction(); - } - - /** - * {@inheritdoc} - */ - public function rollbackTransaction() - { - return $this->getAdapter()->rollbackTransaction(); - } - - /** - * {@inheritdoc} - */ - public function quoteTableName($tableName) - { - return $this->getAdapter()->quoteTableName($tableName); - } - - /** - * {@inheritdoc} - */ - public function quoteColumnName($columnName) - { - return $this->getAdapter()->quoteColumnName($columnName); - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - return $this->getAdapter()->hasTable($tableName); - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - return $this->getAdapter()->createTable($table); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - return $this->getAdapter()->renameTable($tableName, $newTableName); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - return $this->getAdapter()->dropTable($tableName); - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - return $this->getAdapter()->getColumns($tableName); - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName) - { - return $this->getAdapter()->hasColumn($tableName, $columnName); - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - return $this->getAdapter()->addColumn($table, $column); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - return $this->getAdapter()->renameColumn($tableName, $columnName, $newColumnName); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - return $this->getAdapter()->changeColumn($tableName, $columnName, $newColumn); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - return $this->getAdapter()->dropColumn($tableName, $columnName); - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - return $this->getAdapter()->hasIndex($tableName, $columns); - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - return $this->getAdapter()->hasIndexByName($tableName, $indexName); - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - return $this->getAdapter()->addIndex($table, $index); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns, $options = array()) - { - return $this->getAdapter()->dropIndex($tableName, $columns, $options); - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - return $this->getAdapter()->dropIndexByName($tableName, $indexName); - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - return $this->getAdapter()->hasForeignKey($tableName, $columns, $constraint); - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - return $this->getAdapter()->addForeignKey($table, $foreignKey); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - return $this->getAdapter()->dropForeignKey($tableName, $columns, $constraint); - } - - /** - * {@inheritdoc} - */ - public function getSqlType($type, $limit = null) - { - return $this->getAdapter()->getSqlType($type, $limit); - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - return $this->getAdapter()->createDatabase($name, $options); - } - - /** - * {@inheritdoc} - */ - public function hasDatabase($name) - { - return $this->getAdapter()->hasDatabase($name); - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - return $this->getAdapter()->dropDatabase($name); - } - - /** - * @inheritDoc - */ - public function castToBool($value) - { - return $this->getAdapter()->castToBool($value); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php deleted file mode 100644 index f882fb5..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php +++ /dev/null @@ -1,1145 +0,0 @@ - - */ -class MysqlAdapter extends PdoAdapter implements AdapterInterface -{ - - protected $signedColumnTypes = array('integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true, 'boolean' => true); - - const TEXT_TINY = 255; - const TEXT_SMALL = 255; /* deprecated, alias of TEXT_TINY */ - const TEXT_REGULAR = 65535; - const TEXT_MEDIUM = 16777215; - const TEXT_LONG = 4294967295; - - // According to https://dev.mysql.com/doc/refman/5.0/en/blob.html BLOB sizes are the same as TEXT - const BLOB_TINY = 255; - const BLOB_SMALL = 255; /* deprecated, alias of BLOB_TINY */ - const BLOB_REGULAR = 65535; - const BLOB_MEDIUM = 16777215; - const BLOB_LONG = 4294967295; - - const INT_TINY = 255; - const INT_SMALL = 65535; - const INT_MEDIUM = 16777215; - const INT_REGULAR = 4294967295; - const INT_BIG = 18446744073709551615; - - const TYPE_YEAR = 'year'; - - /** - * {@inheritdoc} - */ - public function connect() - { - if (null === $this->connection) { - if (!class_exists('PDO') || !in_array('mysql', \PDO::getAvailableDrivers(), true)) { - // @codeCoverageIgnoreStart - throw new \RuntimeException('You need to enable the PDO_Mysql extension for Phinx to run properly.'); - // @codeCoverageIgnoreEnd - } - - $db = null; - $options = $this->getOptions(); - - $dsn = 'mysql:'; - - if (!empty($options['unix_socket'])) { - // use socket connection - $dsn .= 'unix_socket=' . $options['unix_socket']; - } else { - // use network connection - $dsn .= 'host=' . $options['host']; - if (!empty($options['port'])) { - $dsn .= ';port=' . $options['port']; - } - } - - $dsn .= ';dbname=' . $options['name']; - - // charset support - if (!empty($options['charset'])) { - $dsn .= ';charset=' . $options['charset']; - } - - $driverOptions = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION); - - // support arbitrary \PDO::MYSQL_ATTR_* driver options and pass them to PDO - // http://php.net/manual/en/ref.pdo-mysql.php#pdo-mysql.constants - foreach ($options as $key => $option) { - if (strpos($key, 'mysql_attr_') === 0) { - $driverOptions[constant('\PDO::' . strtoupper($key))] = $option; - } - } - - try { - $db = new \PDO($dsn, $options['user'], $options['pass'], $driverOptions); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - $this->connection = null; - } - - /** - * {@inheritdoc} - */ - public function hasTransactions() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function beginTransaction() - { - $this->execute('START TRANSACTION'); - } - - /** - * {@inheritdoc} - */ - public function commitTransaction() - { - $this->execute('COMMIT'); - } - - /** - * {@inheritdoc} - */ - public function rollbackTransaction() - { - $this->execute('ROLLBACK'); - } - - /** - * {@inheritdoc} - */ - public function quoteTableName($tableName) - { - return str_replace('.', '`.`', $this->quoteColumnName($tableName)); - } - - /** - * {@inheritdoc} - */ - public function quoteColumnName($columnName) - { - return '`' . str_replace('`', '``', $columnName) . '`'; - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - $options = $this->getOptions(); - - $exists = $this->fetchRow(sprintf( - "SELECT TABLE_NAME - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = '%s' AND TABLE_NAME = '%s'", - $options['name'], $tableName - )); - - return !empty($exists); - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $this->startCommandTimer(); - - // This method is based on the MySQL docs here: http://dev.mysql.com/doc/refman/5.1/en/create-index.html - $defaultOptions = array( - 'engine' => 'InnoDB', - 'collation' => 'utf8_general_ci' - ); - $options = array_merge($defaultOptions, $table->getOptions()); - - // Add the default primary key - $columns = $table->getPendingColumns(); - - if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { - $options['id'] = 'id'; - } - - if (isset($options['id']) && is_string($options['id'])) { - // Handle id => "field_name" to support AUTO_INCREMENT - $column = new Column(); - $column->setName($options['id']) - ->setType('integer') - ->setSigned(isset($options['signed']) ? $options['signed'] : true) - ->setIdentity(true); - - array_unshift($columns, $column); - $options['primary_key'] = $options['id']; - } - - // TODO - process table options like collation etc - - // process table engine (default to InnoDB) - $optionsStr = 'ENGINE = InnoDB'; - if (isset($options['engine'])) { - $optionsStr = sprintf('ENGINE = %s', $options['engine']); - } - - // process table collation - if (isset($options['collation'])) { - $charset = explode('_', $options['collation']); - $optionsStr .= sprintf(' CHARACTER SET %s', $charset[0]); - $optionsStr .= sprintf(' COLLATE %s', $options['collation']); - } - - // set the table comment - if (isset($options['comment'])) { - $optionsStr .= sprintf(" COMMENT=%s ", $this->getConnection()->quote($options['comment'])); - } - - $sql = 'CREATE TABLE '; - $sql .= $this->quoteTableName($table->getName()) . ' ('; - foreach ($columns as $column) { - $sql .= $this->quoteColumnName($column->getName()) . ' ' . $this->getColumnSqlDefinition($column) . ', '; - } - - // set the primary key(s) - if (isset($options['primary_key'])) { - $sql = rtrim($sql); - $sql .= ' PRIMARY KEY ('; - if (is_string($options['primary_key'])) { // handle primary_key => 'id' - $sql .= $this->quoteColumnName($options['primary_key']); - } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') - // PHP 5.4 will allow access of $this, so we can call quoteColumnName() directly in the - // anonymous function, but for now just hard-code the adapter quotes - $sql .= implode( - ',', - array_map( - function ($v) { - return '`' . $v . '`'; - }, - $options['primary_key'] - ) - ); - } - $sql .= ')'; - } else { - $sql = substr(rtrim($sql), 0, -1); // no primary keys - } - - // set the indexes - $indexes = $table->getIndexes(); - if (!empty($indexes)) { - foreach ($indexes as $index) { - $sql .= ', ' . $this->getIndexSqlDefinition($index); - } - } - - // set the foreign keys - $foreignKeys = $table->getForeignKeys(); - if (!empty($foreignKeys)) { - foreach ($foreignKeys as $foreignKey) { - $sql .= ', ' . $this->getForeignKeySqlDefinition($foreignKey); - } - } - - $sql .= ') ' . $optionsStr; - $sql = rtrim($sql) . ';'; - - // execute the sql - $this->writeCommand('createTable', array($table->getName())); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $this->startCommandTimer(); - $this->writeCommand('renameTable', array($tableName, $newTableName)); - $this->execute(sprintf('RENAME TABLE %s TO %s', $this->quoteTableName($tableName), $this->quoteTableName($newTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $this->startCommandTimer(); - $this->writeCommand('dropTable', array($tableName)); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - $columns = array(); - $rows = $this->fetchAll(sprintf('SHOW COLUMNS FROM %s', $this->quoteTableName($tableName))); - foreach ($rows as $columnInfo) { - - $phinxType = $this->getPhinxType($columnInfo['Type']); - - $column = new Column(); - $column->setName($columnInfo['Field']) - ->setNull($columnInfo['Null'] !== 'NO') - ->setDefault($columnInfo['Default']) - ->setType($phinxType['name']) - ->setLimit($phinxType['limit']); - - if ($columnInfo['Extra'] === 'auto_increment') { - $column->setIdentity(true); - } - - $columns[] = $column; - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName) - { - $rows = $this->fetchAll(sprintf('SHOW COLUMNS FROM %s', $this->quoteTableName($tableName))); - foreach ($rows as $column) { - if (strcasecmp($column['Field'], $columnName) === 0) { - return true; - } - } - - return false; - } - - /** - * Get the defintion for a `DEFAULT` statement. - * - * @param mixed $default - * @return string - */ - protected function getDefaultValueDefinition($default) - { - if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { - $default = $this->getConnection()->quote($default); - } elseif (is_bool($default)) { - $default = $this->castToBool($default); - } - return isset($default) ? ' DEFAULT ' . $default : ''; - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $this->startCommandTimer(); - $sql = sprintf( - 'ALTER TABLE %s ADD %s %s', - $this->quoteTableName($table->getName()), - $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) - ); - - if ($column->getAfter()) { - $sql .= ' AFTER ' . $this->quoteColumnName($column->getAfter()); - } - - $this->writeCommand('addColumn', array($table->getName(), $column->getName(), $column->getType())); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $this->startCommandTimer(); - $rows = $this->fetchAll(sprintf('DESCRIBE %s', $this->quoteTableName($tableName))); - foreach ($rows as $row) { - if (strcasecmp($row['Field'], $columnName) === 0) { - $null = ($row['Null'] == 'NO') ? 'NOT NULL' : 'NULL'; - $extra = ' ' . strtoupper($row['Extra']); - if (!is_null($row['Default'])) { - $extra .= $this->getDefaultValueDefinition($row['Default']); - } - $definition = $row['Type'] . ' ' . $null . $extra; - - $this->writeCommand('renameColumn', array($tableName, $columnName, $newColumnName)); - $this->execute( - sprintf( - 'ALTER TABLE %s CHANGE COLUMN %s %s %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $this->quoteColumnName($newColumnName), - $definition - ) - ); - $this->endCommandTimer(); - return; - } - } - - throw new \InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' - . $columnName - )); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - $this->startCommandTimer(); - $this->writeCommand('changeColumn', array($tableName, $columnName, $newColumn->getType())); - $after = $newColumn->getAfter() ? ' AFTER ' . $this->quoteColumnName($newColumn->getAfter()) : ''; - $this->execute( - sprintf( - 'ALTER TABLE %s CHANGE %s %s %s%s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $this->quoteColumnName($newColumn->getName()), - $this->getColumnSqlDefinition($newColumn), - $after - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - $this->startCommandTimer(); - $this->writeCommand('dropColumn', array($tableName, $columnName)); - $this->execute( - sprintf( - 'ALTER TABLE %s DROP COLUMN %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) - ) - ); - $this->endCommandTimer(); - } - - /** - * Get an array of indexes from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getIndexes($tableName) - { - $indexes = array(); - $rows = $this->fetchAll(sprintf('SHOW INDEXES FROM %s', $this->quoteTableName($tableName))); - foreach ($rows as $row) { - if (!isset($indexes[$row['Key_name']])) { - $indexes[$row['Key_name']] = array('columns' => array()); - } - $indexes[$row['Key_name']]['columns'][] = strtolower($row['Column_name']); - } - return $indexes; - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $columns = array_map('strtolower', $columns); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $index) { - if ($columns == $index['columns']) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $name => $index) { - if ($name === $indexName) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $this->startCommandTimer(); - $this->writeCommand('addIndex', array($table->getName(), $index->getColumns())); - $this->execute( - sprintf( - 'ALTER TABLE %s ADD %s', - $this->quoteTableName($table->getName()), - $this->getIndexSqlDefinition($index) - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropIndex', array($tableName, $columns)); - $indexes = $this->getIndexes($tableName); - $columns = array_map('strtolower', $columns); - - foreach ($indexes as $indexName => $index) { - if ($columns == $index['columns']) { - $this->execute( - sprintf( - 'ALTER TABLE %s DROP INDEX %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($indexName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $this->startCommandTimer(); - $this->writeCommand('dropIndexByName', array($tableName, $indexName)); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $name => $index) { - //$a = array_diff($columns, $index['columns']); - if ($name === $indexName) { - $this->execute( - sprintf( - 'ALTER TABLE %s DROP INDEX %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($indexName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $foreignKeys = $this->getForeignKeys($tableName); - if ($constraint) { - if (isset($foreignKeys[$constraint])) { - return !empty($foreignKeys[$constraint]); - } - return false; - } else { - foreach ($foreignKeys as $key) { - $a = array_diff($columns, $key['columns']); - if ($columns == $key['columns']) { - return true; - } - } - return false; - } - } - - /** - * Get an array of foreign keys from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getForeignKeys($tableName) - { - $foreignKeys = array(); - $rows = $this->fetchAll(sprintf( - "SELECT - CONSTRAINT_NAME, - TABLE_NAME, - COLUMN_NAME, - REFERENCED_TABLE_NAME, - REFERENCED_COLUMN_NAME - FROM information_schema.KEY_COLUMN_USAGE - WHERE REFERENCED_TABLE_SCHEMA = DATABASE() - AND REFERENCED_TABLE_NAME IS NOT NULL - AND TABLE_NAME = '%s' - ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", - $tableName - )); - foreach ($rows as $row) { - $foreignKeys[$row['CONSTRAINT_NAME']]['table'] = $row['TABLE_NAME']; - $foreignKeys[$row['CONSTRAINT_NAME']]['columns'][] = $row['COLUMN_NAME']; - $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_table'] = $row['REFERENCED_TABLE_NAME']; - $foreignKeys[$row['CONSTRAINT_NAME']]['referenced_columns'][] = $row['REFERENCED_COLUMN_NAME']; - } - return $foreignKeys; - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - $this->startCommandTimer(); - $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns())); - $this->execute( - sprintf( - 'ALTER TABLE %s ADD %s', - $this->quoteTableName($table->getName()), - $this->getForeignKeySqlDefinition($foreignKey) - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropForeignKey', array($tableName, $columns)); - - if ($constraint) { - $this->execute( - sprintf( - 'ALTER TABLE %s DROP FOREIGN KEY %s', - $this->quoteTableName($tableName), - $constraint - ) - ); - $this->endCommandTimer(); - return; - } else { - foreach ($columns as $column) { - $rows = $this->fetchAll(sprintf( - "SELECT - CONSTRAINT_NAME - FROM information_schema.KEY_COLUMN_USAGE - WHERE REFERENCED_TABLE_SCHEMA = DATABASE() - AND REFERENCED_TABLE_NAME IS NOT NULL - AND TABLE_NAME = '%s' - AND COLUMN_NAME = '%s' - ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", - $tableName, - $column - )); - foreach ($rows as $row) { - $this->dropForeignKey($tableName, $columns, $row['CONSTRAINT_NAME']); - } - } - } - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getSqlType($type, $limit = null) - { - switch ($type) { - case static::PHINX_TYPE_STRING: - return array('name' => 'varchar', 'limit' => $limit ? $limit : 255); - break; - case static::PHINX_TYPE_CHAR: - return array('name' => 'char', 'limit' => $limit ? $limit : 255); - break; - case static::PHINX_TYPE_TEXT: - if ($limit) { - $sizes = array( - // Order matters! Size must always be tested from longest to shortest! - 'longtext' => static::TEXT_LONG, - 'mediumtext' => static::TEXT_MEDIUM, - 'text' => static::TEXT_REGULAR, - 'tinytext' => static::TEXT_SMALL, - ); - foreach ($sizes as $name => $length) { - if ($limit >= $length) { - return array('name' => $name); - } - } - } - return array('name' => 'text'); - break; - case static::PHINX_TYPE_BINARY: - return array('name' => 'binary', 'limit' => $limit ? $limit : 255); - break; - case static::PHINX_TYPE_VARBINARY: - return array('name' => 'varbinary', 'limit' => $limit ? $limit : 255); - break; - case static::PHINX_TYPE_BLOB: - if ($limit) { - $sizes = array( - // Order matters! Size must always be tested from longest to shortest! - 'longblob' => static::BLOB_LONG, - 'mediumblob' => static::BLOB_MEDIUM, - 'blob' => static::BLOB_REGULAR, - 'tinyblob' => static::BLOB_SMALL, - ); - foreach ($sizes as $name => $length) { - if ($limit >= $length) { - return array('name' => $name); - } - } - } - return array('name' => 'blob'); - break; - case static::PHINX_TYPE_INTEGER: - if ($limit && $limit >= static::INT_TINY) { - $sizes = array( - // Order matters! Size must always be tested from longest to shortest! - 'bigint' => static::INT_BIG, - 'int' => static::INT_REGULAR, - 'mediumint' => static::INT_MEDIUM, - 'smallint' => static::INT_SMALL, - 'tinyint' => static::INT_TINY, - ); - $limits = array( - 'int' => 11, - 'bigint' => 20, - ); - foreach ($sizes as $name => $length) { - if ($limit >= $length) { - $def = array('name' => $name); - if (isset($limits[$name])) { - $def['limit'] = $limits[$name]; - } - return $def; - } - } - } elseif (!$limit) { - $limit = 11; - } - return array('name' => 'int', 'limit' => $limit); - break; - case static::PHINX_TYPE_BIG_INTEGER: - return array('name' => 'bigint', 'limit' => 20); - break; - case static::PHINX_TYPE_FLOAT: - return array('name' => 'float'); - break; - case static::PHINX_TYPE_DECIMAL: - return array('name' => 'decimal'); - break; - case static::PHINX_TYPE_DATETIME: - return array('name' => 'datetime'); - break; - case static::PHINX_TYPE_TIMESTAMP: - return array('name' => 'timestamp'); - break; - case static::PHINX_TYPE_TIME: - return array('name' => 'time'); - break; - case static::PHINX_TYPE_DATE: - return array('name' => 'date'); - break; - case static::PHINX_TYPE_BOOLEAN: - return array('name' => 'tinyint', 'limit' => 1); - break; - case static::PHINX_TYPE_UUID: - return array('name' => 'char', 'limit' => 36); - // Geospatial database types - case static::PHINX_TYPE_GEOMETRY: - case static::PHINX_TYPE_POINT: - case static::PHINX_TYPE_LINESTRING: - case static::PHINX_TYPE_POLYGON: - return array('name' => $type); - case static::PHINX_TYPE_ENUM: - return array('name' => 'enum'); - break; - case static::PHINX_TYPE_SET: - return array('name' => 'set'); - break; - case static::TYPE_YEAR: - if (!$limit || in_array($limit, array(2, 4))) - $limit = 4; - return array('name' => 'year', 'limit' => $limit); - break; - case static::PHINX_TYPE_JSON: - return array('name' => 'json'); - break; - default: - throw new \RuntimeException('The type: "' . $type . '" is not supported.'); - } - } - - /** - * Returns Phinx type by SQL type - * - * @param string $sqlTypeDef - * @throws \RuntimeException - * @internal param string $sqlType SQL type - * @returns string Phinx type - */ - public function getPhinxType($sqlTypeDef) - { - if (!preg_match('/^([\w]+)(\(([\d]+)*(,([\d]+))*\))*(.+)*$/', $sqlTypeDef, $matches)) { - throw new \RuntimeException('Column type ' . $sqlTypeDef . ' is not supported'); - } else { - $limit = null; - $precision = null; - $type = $matches[1]; - if (count($matches) > 2) { - $limit = $matches[3] ? (int) $matches[3] : null; - } - if (count($matches) > 4) { - $precision = (int) $matches[5]; - } - if ($type === 'tinyint' && $limit === 1) { - $type = static::PHINX_TYPE_BOOLEAN; - $limit = null; - } - switch ($type) { - case 'varchar': - $type = static::PHINX_TYPE_STRING; - if ($limit === 255) { - $limit = null; - } - break; - case 'char': - $type = static::PHINX_TYPE_CHAR; - if ($limit === 255) { - $limit = null; - } - if ($limit === 36) { - $type = static::PHINX_TYPE_UUID; - } - break; - case 'tinyint': - $type = static::PHINX_TYPE_INTEGER; - $limit = static::INT_TINY; - break; - case 'smallint': - $type = static::PHINX_TYPE_INTEGER; - $limit = static::INT_SMALL; - break; - case 'mediumint': - $type = static::PHINX_TYPE_INTEGER; - $limit = static::INT_MEDIUM; - break; - case 'int': - $type = static::PHINX_TYPE_INTEGER; - if ($limit === 11) { - $limit = null; - } - break; - case 'bigint': - if ($limit === 20) { - $limit = null; - } - $type = static::PHINX_TYPE_BIG_INTEGER; - break; - case 'blob': - $type = static::PHINX_TYPE_BINARY; - break; - case 'tinyblob': - $type = static::PHINX_TYPE_BINARY; - $limit = static::BLOB_TINY; - break; - case 'mediumblob': - $type = static::PHINX_TYPE_BINARY; - $limit = static::BLOB_MEDIUM; - break; - case 'longblob': - $type = static::PHINX_TYPE_BINARY; - $limit = static::BLOB_LONG; - break; - case 'tinytext': - $type = static::PHINX_TYPE_TEXT; - $limit = static::TEXT_TINY; - break; - case 'mediumtext': - $type = static::PHINX_TYPE_TEXT; - $limit = static::TEXT_MEDIUM; - break; - case 'longtext': - $type = static::PHINX_TYPE_TEXT; - $limit = static::TEXT_LONG; - break; - } - - $this->getSqlType($type, $limit); - - return array( - 'name' => $type, - 'limit' => $limit, - 'precision' => $precision - ); - } - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - $this->startCommandTimer(); - $this->writeCommand('createDatabase', array($name)); - $charset = isset($options['charset']) ? $options['charset'] : 'utf8'; - - if (isset($options['collation'])) { - $this->execute(sprintf('CREATE DATABASE `%s` DEFAULT CHARACTER SET `%s` COLLATE `%s`', $name, $charset, $options['collation'])); - } else { - $this->execute(sprintf('CREATE DATABASE `%s` DEFAULT CHARACTER SET `%s`', $name, $charset)); - } - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function hasDatabase($name) - { - $rows = $this->fetchAll( - sprintf( - 'SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', - $name - ) - ); - - foreach ($rows as $row) { - if (!empty($row)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - $this->startCommandTimer(); - $this->writeCommand('dropDatabase', array($name)); - $this->execute(sprintf('DROP DATABASE IF EXISTS `%s`', $name)); - $this->endCommandTimer(); - } - - /** - * Gets the MySQL Column Definition for a Column object. - * - * @param Column $column Column - * @return string - */ - protected function getColumnSqlDefinition(Column $column) - { - $sqlType = $this->getSqlType($column->getType(), $column->getLimit()); - - $def = ''; - $def .= strtoupper($sqlType['name']); - if ($column->getPrecision() && $column->getScale()) { - $def .= '(' . $column->getPrecision() . ',' . $column->getScale() . ')'; - } elseif (isset($sqlType['limit'])) { - $def .= '(' . $sqlType['limit'] . ')'; - } - if (($values = $column->getValues()) && is_array($values)) { - $def .= "('" . implode("', '", $values) . "')"; - } - $def .= (!$column->isSigned() && isset($this->signedColumnTypes[$column->getType()])) ? ' unsigned' : '' ; - $def .= ($column->isNull() == false) ? ' NOT NULL' : ' NULL'; - $def .= ($column->isIdentity()) ? ' AUTO_INCREMENT' : ''; - $def .= $this->getDefaultValueDefinition($column->getDefault()); - - if ($column->getComment()) { - $def .= ' COMMENT ' . $this->getConnection()->quote($column->getComment()); - } - - if ($column->getUpdate()) { - $def .= ' ON UPDATE ' . $column->getUpdate(); - } - - return $def; - } - - /** - * Gets the MySQL Index Definition for an Index object. - * - * @param Index $index Index - * @return string - */ - protected function getIndexSqlDefinition(Index $index) - { - $def = ''; - $limit = ''; - if ($index->getLimit()) { - $limit = '(' . $index->getLimit() . ')'; - } - - if ($index->getType() == Index::UNIQUE) { - $def .= ' UNIQUE'; - } - - if ($index->getType() == Index::FULLTEXT) { - $def .= ' FULLTEXT'; - } - - $def .= ' KEY'; - - if (is_string($index->getName())) { - $def .= ' `' . $index->getName() . '`'; - } - - $def .= ' (`' . implode('`,`', $index->getColumns()) . '`' . $limit . ')'; - - return $def; - } - - /** - * Gets the MySQL Foreign Key Definition for an ForeignKey object. - * - * @param ForeignKey $foreignKey - * @return string - */ - protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) - { - $def = ''; - if ($foreignKey->getConstraint()) { - $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); - } - $columnNames = array(); - foreach ($foreignKey->getColumns() as $column) { - $columnNames[] = $this->quoteColumnName($column); - } - $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; - $refColumnNames = array(); - foreach ($foreignKey->getReferencedColumns() as $column) { - $refColumnNames[] = $this->quoteColumnName($column); - } - $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; - if ($foreignKey->getOnDelete()) { - $def .= ' ON DELETE ' . $foreignKey->getOnDelete(); - } - if ($foreignKey->getOnUpdate()) { - $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate(); - } - return $def; - } - - /** - * Describes a database table. This is a MySQL adapter specific method. - * - * @param string $tableName Table name - * @return array - */ - public function describeTable($tableName) - { - $options = $this->getOptions(); - - // mysql specific - $sql = sprintf( - "SELECT * - FROM information_schema.tables - WHERE table_schema = '%s' - AND table_name = '%s'", - $options['name'], - $tableName - ); - - return $this->fetchRow($sql); - } - - /** - * Returns MySQL column types (inherited and MySQL specified). - * @return array - */ - public function getColumnTypes() - { - return array_merge(parent::getColumnTypes(), array('enum', 'set', 'year', 'json')); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PdoAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PdoAdapter.php deleted file mode 100644 index 9924c3a..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PdoAdapter.php +++ /dev/null @@ -1,587 +0,0 @@ - - */ -abstract class PdoAdapter implements AdapterInterface -{ - /** - * @var array - */ - protected $options = array(); - - /** - * @var InputInterface - */ - protected $input; - - /** - * @var OutputInterface - */ - protected $output; - - /** - * @var string - */ - protected $schemaTableName = 'migrations'; - - /** - * @var \PDO - */ - protected $connection; - - /** - * @var float - */ - protected $commandStartTime; - - /** - * Class Constructor. - * - * @param array $options Options - * @param InputInterface $input Input Interface - * @param OutputInterface $output Output Interface - */ - public function __construct(array $options, InputInterface $input = null, OutputInterface $output = null) - { - $this->setOptions($options); - if (null !== $input) { - $this->setInput($input); - } - if (null !== $output) { - $this->setOutput($output); - } - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->options = $options; - - if (isset($options['default_migration_table'])) { - $this->setSchemaTableName($options['default_migration_table']); - } - - if (isset($options['connection'])) { - $this->setConnection($options['connection']); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritdoc} - */ - public function hasOption($name) - { - return isset($this->options[$name]); - } - - /** - * {@inheritdoc} - */ - public function getOption($name) - { - if (!$this->hasOption($name)) { - return; - } - return $this->options[$name]; - } - - /** - * {@inheritdoc} - */ - public function setInput(InputInterface $input) - { - $this->input = $input; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getInput() - { - return $this->input; - } - - /** - * {@inheritdoc} - */ - public function setOutput(OutputInterface $output) - { - $this->output = $output; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOutput() - { - if (null === $this->output) { - $output = new OutputInterface('nothing'); - $this->setOutput($output); - } - return $this->output; - } - - /** - * Sets the schema table name. - * - * @param string $schemaTableName Schema Table Name - * @return PdoAdapter - */ - public function setSchemaTableName($schemaTableName) - { - $this->schemaTableName = $schemaTableName; - return $this; - } - - /** - * Gets the schema table name. - * - * @return string - */ - public function getSchemaTableName() - { - return $this->schemaTableName; - } - - /** - * Sets the database connection. - * - * @param \PDO $connection Connection - * @return AdapterInterface - */ - public function setConnection(\PDO $connection) - { - $this->connection = $connection; - - // Create the schema table if it doesn't already exist - if (!$this->hasSchemaTable()) { - $this->createSchemaTable(); - } else { - $table = new Table($this->getSchemaTableName(), array(), $this); - if (!$table->hasColumn('migration_name')) { - $table - ->addColumn('migration_name', 'string', - array('limit' => 100, 'after' => 'version', 'default' => null, 'null' => true) - ) - ->save(); - } - if (!$table->hasColumn('breakpoint')) { - $table - ->addColumn('breakpoint', 'boolean', array('default' => false)) - ->save(); - } - } - - return $this; - } - - /** - * Gets the database connection - * - * @return \PDO - */ - public function getConnection() - { - if (null === $this->connection) { - $this->connect(); - } - return $this->connection; - } - - /** - * Sets the command start time - * - * @param int $time - * @return AdapterInterface - */ - public function setCommandStartTime($time) - { - $this->commandStartTime = $time; - return $this; - } - - /** - * Gets the command start time - * - * @return int - */ - public function getCommandStartTime() - { - return $this->commandStartTime; - } - - /** - * Start timing a command. - * - * @return void - */ - public function startCommandTimer() - { - $this->setCommandStartTime(microtime(true)); - } - - /** - * Stop timing the current command and write the elapsed time to the - * output. - * - * @return void - */ - public function endCommandTimer() - { - $end = microtime(true); - if (OutputInterface::VERBOSITY_VERBOSE <= $this->getOutput()->getVerbosity()) { - $this->getOutput()->writeln(' -> ' . sprintf('%.4fs', $end - $this->getCommandStartTime())); - } - } - - /** - * Write a Phinx command to the output. - * - * @param string $command Command Name - * @param array $args Command Args - * @return void - */ - public function writeCommand($command, $args = array()) - { - if (OutputInterface::VERBOSITY_VERBOSE <= $this->getOutput()->getVerbosity()) { - if (count($args)) { - $outArr = array(); - foreach ($args as $arg) { - if (is_array($arg)) { - $arg = array_map(function ($value) { - return '\'' . $value . '\''; - }, $arg); - $outArr[] = '[' . implode(', ', $arg) . ']'; - continue; - } - - $outArr[] = '\'' . $arg . '\''; - } - $this->getOutput()->writeln(' -- ' . $command . '(' . implode(', ', $outArr) . ')'); - return; - } - $this->getOutput()->writeln(' -- ' . $command); - } - } - - /** - * {@inheritdoc} - */ - public function connect() - { - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - } - - /** - * {@inheritdoc} - */ - public function execute($sql) - { - return $this->getConnection()->exec($sql); - } - - /** - * {@inheritdoc} - */ - public function query($sql) - { - return $this->getConnection()->query($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchRow($sql) - { - $result = $this->query($sql); - return $result->fetch(); - } - - /** - * {@inheritdoc} - */ - public function fetchAll($sql) - { - $rows = array(); - $result = $this->query($sql); - while ($row = $result->fetch()) { - $rows[] = $row; - } - return $rows; - } - - /** - * {@inheritdoc} - */ - public function insert(Table $table, $row) - { - $this->startCommandTimer(); - $this->writeCommand('insert', array($table->getName())); - - $sql = sprintf( - "INSERT INTO %s ", - $this->quoteTableName($table->getName()) - ); - - $columns = array_keys($row); - $sql .= "(". implode(', ', array_map(array($this, 'quoteColumnName'), $columns)) . ")"; - $sql .= " VALUES (" . implode(', ', array_fill(0, count($columns), '?')) . ")"; - - $stmt = $this->getConnection()->prepare($sql); - $stmt->execute(array_values($row)); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getVersions() - { - $rows = $this->getVersionLog(); - - return array_keys($rows); - } - - /** - * {@inheritdoc} - */ - public function getVersionLog() - { - $result = array(); - $rows = $this->fetchAll(sprintf('SELECT * FROM %s ORDER BY version ASC', $this->getSchemaTableName())); - foreach ($rows as $version) { - $result[$version['version']] = $version; - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function migrated(MigrationInterface $migration, $direction, $startTime, $endTime) - { - if (strcasecmp($direction, MigrationInterface::UP) === 0) { - // up - $sql = sprintf( - "INSERT INTO %s (%s, %s, %s, %s, %s) VALUES ('%s', '%s', '%s', '%s', %s);", - $this->getSchemaTableName(), - $this->quoteColumnName('version'), - $this->quoteColumnName('migration_name'), - $this->quoteColumnName('start_time'), - $this->quoteColumnName('end_time'), - $this->quoteColumnName('breakpoint'), - $migration->getVersion(), - substr($migration->getName(), 0, 100), - $startTime, - $endTime, - $this->castToBool(false) - ); - - $this->query($sql); - } else { - // down - $sql = sprintf( - "DELETE FROM %s WHERE %s = '%s'", - $this->getSchemaTableName(), - $this->quoteColumnName('version'), - $migration->getVersion() - ); - - $this->query($sql); - } - - return $this; - } - - /** - * @inheritDoc - */ - public function toggleBreakpoint(MigrationInterface $migration) - { - $this->query( - sprintf( - 'UPDATE %1$s SET %2$s = CASE %2$s WHEN %3$s THEN %4$s ELSE %3$s END WHERE %5$s = \'%6$s\';', - $this->getSchemaTableName(), - $this->quoteColumnName('breakpoint'), - $this->castToBool(true), - $this->castToBool(false), - $this->quoteColumnName('version'), - $migration->getVersion() - ) - ); - - return $this; - } - - /** - * @inheritDoc - */ - public function resetAllBreakpoints() - { - return $this->execute( - sprintf( - 'UPDATE %1$s SET %2$s = %3$s WHERE %2$s <> %3$s;', - $this->getSchemaTableName(), - $this->quoteColumnName('breakpoint'), - $this->castToBool(false) - ) - ); - } - - /** - * {@inheritdoc} - */ - public function hasSchemaTable() - { - return $this->hasTable($this->getSchemaTableName()); - } - - /** - * {@inheritdoc} - */ - public function createSchemaTable() - { - try { - $options = array( - 'id' => false, - 'primary_key' => 'version' - ); - - $table = new Table($this->getSchemaTableName(), $options, $this); - - if ($this->getConnection()->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql' - && version_compare($this->getConnection()->getAttribute(\PDO::ATTR_SERVER_VERSION), '5.6.0', '>=')) { - $table->addColumn('version', 'biginteger', array('limit' => 14)) - ->addColumn('migration_name', 'string', array('limit' => 100, 'default' => null, 'null' => true)) - ->addColumn('start_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP')) - ->addColumn('end_time', 'timestamp', array('default' => 'CURRENT_TIMESTAMP')) - ->addColumn('breakpoint', 'boolean', array('default' => false)) - ->save(); - } else { - $table->addColumn('version', 'biginteger') - ->addColumn('migration_name', 'string', array('limit' => 100, 'default' => null, 'null' => true)) - ->addColumn('start_time', 'timestamp') - ->addColumn('end_time', 'timestamp') - ->addColumn('breakpoint', 'boolean', array('default' => false)) - ->save(); - } - } catch (\Exception $exception) { - throw new \InvalidArgumentException('There was a problem creating the schema table: ' . $exception->getMessage()); - } - } - - /** - * {@inheritdoc} - */ - public function getAdapterType() - { - return $this->getOption('adapter'); - } - - /** - * {@inheritdoc} - */ - public function getColumnTypes() - { - return array( - 'string', - 'char', - 'text', - 'integer', - 'biginteger', - 'float', - 'decimal', - 'datetime', - 'timestamp', - 'time', - 'date', - 'blob', - 'binary', - 'varbinary', - 'boolean', - 'uuid', - // Geospatial data types - 'geometry', - 'point', - 'linestring', - 'polygon', - ); - } - - /** - * {@inheritdoc} - */ - public function isValidColumnType(Column $column) { - return in_array($column->getType(), $this->getColumnTypes()); - } - - /** - * Cast a value to a boolean appropriate for the adapter. - * - * @param mixed $value The value to be cast - * - * @return mixed - */ - public function castToBool($value) - { - return (bool) $value ? 1 : 0; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PostgresAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PostgresAdapter.php deleted file mode 100644 index 3c506bd..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/PostgresAdapter.php +++ /dev/null @@ -1,1182 +0,0 @@ -connection) { - if (!class_exists('PDO') || !in_array('pgsql', \PDO::getAvailableDrivers(), true)) { - // @codeCoverageIgnoreStart - throw new \RuntimeException('You need to enable the PDO_Pgsql extension for Phinx to run properly.'); - // @codeCoverageIgnoreEnd - } - - $db = null; - $options = $this->getOptions(); - - // if port is specified use it, otherwise use the PostgreSQL default - if (isset($options['port'])) { - $dsn = 'pgsql:host=' . $options['host'] . ';port=' . $options['port'] . ';dbname=' . $options['name']; - } else { - $dsn = 'pgsql:host=' . $options['host'] . ';dbname=' . $options['name']; - } - - try { - $db = new \PDO($dsn, $options['user'], $options['pass'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION)); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - $this->connection = null; - } - - /** - * {@inheritdoc} - */ - public function hasTransactions() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function beginTransaction() - { - $this->execute('BEGIN'); - } - - /** - * {@inheritdoc} - */ - public function commitTransaction() - { - $this->execute('COMMIT'); - } - - /** - * {@inheritdoc} - */ - public function rollbackTransaction() - { - $this->execute('ROLLBACK'); - } - - /** - * Quotes a schema name for use in a query. - * - * @param string $schemaName Schema Name - * @return string - */ - public function quoteSchemaName($schemaName) - { - return $this->quoteColumnName($schemaName); - } - - /** - * {@inheritdoc} - */ - public function quoteTableName($tableName) - { - return $this->quoteSchemaName($this->getSchemaName()) . '.' . $this->quoteColumnName($tableName); - } - - /** - * {@inheritdoc} - */ - public function quoteColumnName($columnName) - { - return '"'. $columnName . '"'; - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - $result = $this->getConnection()->query( - sprintf( - 'SELECT * - FROM information_schema.tables - WHERE table_schema = %s - AND lower(table_name) = lower(%s)', - $this->getConnection()->quote($this->getSchemaName()), - $this->getConnection()->quote($tableName) - ) - ); - - return $result->rowCount() === 1; - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $this->startCommandTimer(); - $options = $table->getOptions(); - - // Add the default primary key - $columns = $table->getPendingColumns(); - if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { - $column = new Column(); - $column->setName('id') - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - $options['primary_key'] = 'id'; - - } elseif (isset($options['id']) && is_string($options['id'])) { - // Handle id => "field_name" to support AUTO_INCREMENT - $column = new Column(); - $column->setName($options['id']) - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - $options['primary_key'] = $options['id']; - } - - // TODO - process table options like collation etc - $sql = 'CREATE TABLE '; - $sql .= $this->quoteTableName($table->getName()) . ' ('; - - $this->columnsWithComments = array(); - foreach ($columns as $column) { - $sql .= $this->quoteColumnName($column->getName()) . ' ' . $this->getColumnSqlDefinition($column) . ', '; - - // set column comments, if needed - if ($column->getComment()) { - $this->columnsWithComments[] = $column; - } - } - - // set the primary key(s) - if (isset($options['primary_key'])) { - $sql = rtrim($sql); - $sql .= sprintf(' CONSTRAINT %s_pkey PRIMARY KEY (', $table->getName()); - if (is_string($options['primary_key'])) { // handle primary_key => 'id' - $sql .= $this->quoteColumnName($options['primary_key']); - } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') - // PHP 5.4 will allow access of $this, so we can call quoteColumnName() directly in the anonymous function, - // but for now just hard-code the adapter quotes - $sql .= implode( - ',', - array_map( - function ($v) { - return '"' . $v . '"'; - }, - $options['primary_key'] - ) - ); - } - $sql .= ')'; - } else { - $sql = substr(rtrim($sql), 0, -1); // no primary keys - } - - // set the foreign keys - $foreignKeys = $table->getForeignKeys(); - if (!empty($foreignKeys)) { - foreach ($foreignKeys as $foreignKey) { - $sql .= ', ' . $this->getForeignKeySqlDefinition($foreignKey, $table->getName()); - } - } - - $sql .= ');'; - - // process column comments - if (!empty($this->columnsWithComments)) { - foreach ($this->columnsWithComments as $column) { - $sql .= $this->getColumnCommentSqlDefinition($column, $table->getName()); - } - } - - // set the indexes - $indexes = $table->getIndexes(); - if (!empty($indexes)) { - foreach ($indexes as $index) { - $sql .= $this->getIndexSqlDefinition($index, $table->getName()); - } - } - - // execute the sql - $this->writeCommand('createTable', array($table->getName())); - $this->execute($sql); - - // process table comments - if (isset($options['comment'])) { - $sql = sprintf( - 'COMMENT ON TABLE %s IS %s', - $this->quoteTableName($table->getName()), - $this->getConnection()->quote($options['comment']) - ); - $this->execute($sql); - } - - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $this->startCommandTimer(); - $this->writeCommand('renameTable', array($tableName, $newTableName)); - $sql = sprintf( - 'ALTER TABLE %s RENAME TO %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($newTableName) - ); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $this->startCommandTimer(); - $this->writeCommand('dropTable', array($tableName)); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - $columns = array(); - $sql = sprintf( - "SELECT column_name, data_type, is_identity, is_nullable, - column_default, character_maximum_length, numeric_precision, numeric_scale - FROM information_schema.columns - WHERE table_name ='%s'", - $tableName - ); - $columnsInfo = $this->fetchAll($sql); - - foreach ($columnsInfo as $columnInfo) { - $column = new Column(); - $column->setName($columnInfo['column_name']) - ->setType($this->getPhinxType($columnInfo['data_type'])) - ->setNull($columnInfo['is_nullable'] === 'YES') - ->setDefault($columnInfo['column_default']) - ->setIdentity($columnInfo['is_identity'] === 'YES') - ->setPrecision($columnInfo['numeric_precision']) - ->setScale($columnInfo['numeric_scale']); - - if (preg_match('/\bwith time zone$/', $columnInfo['data_type'])) { - $column->setTimezone(true); - } - - if (isset($columnInfo['character_maximum_length'])) { - $column->setLimit($columnInfo['character_maximum_length']); - } - $columns[] = $column; - } - return $columns; - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName, $options = array()) - { - $sql = sprintf("SELECT count(*) - FROM information_schema.columns - WHERE table_schema = '%s' AND table_name = '%s' AND column_name = '%s'", - $this->getSchemaName(), - $tableName, - $columnName - ); - - $result = $this->fetchRow($sql); - return $result['count'] > 0; - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $this->startCommandTimer(); - $this->writeCommand('addColumn', array($table->getName(), $column->getName(), $column->getType())); - $sql = sprintf( - 'ALTER TABLE %s ADD %s %s', - $this->quoteTableName($table->getName()), - $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) - ); - - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $this->startCommandTimer(); - $sql = sprintf( - "SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END AS column_exists - FROM information_schema.columns - WHERE table_name ='%s' AND column_name = '%s'", - $tableName, - $columnName - ); - $result = $this->fetchRow($sql); - if (!(bool) $result['column_exists']) { - throw new \InvalidArgumentException("The specified column does not exist: $columnName"); - } - $this->writeCommand('renameColumn', array($tableName, $columnName, $newColumnName)); - $this->execute( - sprintf( - 'ALTER TABLE %s RENAME COLUMN %s TO %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $newColumnName - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - // TODO - is it possible to merge these 3 queries into less? - $this->startCommandTimer(); - $this->writeCommand('changeColumn', array($tableName, $columnName, $newColumn->getType())); - // change data type - $sql = sprintf( - 'ALTER TABLE %s ALTER COLUMN %s TYPE %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $this->getColumnSqlDefinition($newColumn) - ); - //NULL and DEFAULT cannot be set while changing column type - $sql = preg_replace('/ NOT NULL/', '', $sql); - $sql = preg_replace('/ NULL/', '', $sql); - //If it is set, DEFAULT is the last definition - $sql = preg_replace('/DEFAULT .*/', '', $sql); - $this->execute($sql); - // process null - $sql = sprintf( - 'ALTER TABLE %s ALTER COLUMN %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) - ); - if ($newColumn->isNull()) { - $sql .= ' DROP NOT NULL'; - } else { - $sql .= ' SET NOT NULL'; - } - $this->execute($sql); - if (!is_null($newColumn->getDefault())) { - //change default - $this->execute( - sprintf( - 'ALTER TABLE %s ALTER COLUMN %s SET %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $this->getDefaultValueDefinition($newColumn->getDefault()) - ) - ); - } - else { - //drop default - $this->execute( - sprintf( - 'ALTER TABLE %s ALTER COLUMN %s DROP DEFAULT', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) - ) - ); - } - // rename column - if ($columnName !== $newColumn->getName()) { - $this->execute( - sprintf( - 'ALTER TABLE %s RENAME COLUMN %s TO %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName), - $this->quoteColumnName($newColumn->getName()) - ) - ); - } - - // change column comment if needed - if ($newColumn->getComment()) { - $sql = $this->getColumnCommentSqlDefinition($newColumn, $tableName); - $this->execute($sql); - } - - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - $this->startCommandTimer(); - $this->writeCommand('dropColumn', array($tableName, $columnName)); - $this->execute( - sprintf( - 'ALTER TABLE %s DROP COLUMN %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) - ) - ); - $this->endCommandTimer(); - } - - /** - * Get an array of indexes from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getIndexes($tableName) - { - $indexes = array(); - $sql = "SELECT - i.relname AS index_name, - a.attname AS column_name - FROM - pg_class t, - pg_class i, - pg_index ix, - pg_attribute a - WHERE - t.oid = ix.indrelid - AND i.oid = ix.indexrelid - AND a.attrelid = t.oid - AND a.attnum = ANY(ix.indkey) - AND t.relkind = 'r' - AND t.relname = '$tableName' - ORDER BY - t.relname, - i.relname;"; - $rows = $this->fetchAll($sql); - foreach ($rows as $row) { - if (!isset($indexes[$row['index_name']])) { - $indexes[$row['index_name']] = array('columns' => array()); - } - $indexes[$row['index_name']]['columns'][] = strtolower($row['column_name']); - } - return $indexes; - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - if (is_string($columns)) { - $columns = array($columns); - } - $columns = array_map('strtolower', $columns); - $indexes = $this->getIndexes($tableName); - foreach ($indexes as $index) { - if (array_diff($index['columns'], $columns) === array_diff($columns, $index['columns'])) { - return true; - } - } - return false; - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - $indexes = $this->getIndexes($tableName); - foreach ($indexes as $name => $index) { - if ($name === $indexName) { - return true; - } - } - return false; - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $this->startCommandTimer(); - $this->writeCommand('addIndex', array($table->getName(), $index->getColumns())); - $sql = $this->getIndexSqlDefinition($index, $table->getName()); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropIndex', array($tableName, $columns)); - $indexes = $this->getIndexes($tableName); - $columns = array_map('strtolower', $columns); - - foreach ($indexes as $indexName => $index) { - $a = array_diff($columns, $index['columns']); - if (empty($a)) { - $this->execute( - sprintf( - 'DROP INDEX IF EXISTS %s', - $this->quoteColumnName($indexName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $this->startCommandTimer(); - $this->writeCommand('dropIndexByName', array($tableName, $indexName)); - $sql = sprintf( - 'DROP INDEX IF EXISTS %s', - $indexName - ); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $foreignKeys = $this->getForeignKeys($tableName); - if ($constraint) { - if (isset($foreignKeys[$constraint])) { - return !empty($foreignKeys[$constraint]); - } - return false; - } else { - foreach ($foreignKeys as $key) { - $a = array_diff($columns, $key['columns']); - if (empty($a)) { - return true; - } - } - return false; - } - } - - /** - * Get an array of foreign keys from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getForeignKeys($tableName) - { - $foreignKeys = array(); - $rows = $this->fetchAll(sprintf( - "SELECT - tc.constraint_name, - tc.table_name, kcu.column_name, - ccu.table_name AS referenced_table_name, - ccu.column_name AS referenced_column_name - FROM - information_schema.table_constraints AS tc - JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name - JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name - WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' - ORDER BY kcu.position_in_unique_constraint", - $tableName - )); - foreach ($rows as $row) { - $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; - $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name']; - $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name']; - $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name']; - } - return $foreignKeys; - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - $this->startCommandTimer(); - $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns())); - $sql = sprintf( - 'ALTER TABLE %s ADD %s', - $this->quoteTableName($table->getName()), - $this->getForeignKeySqlDefinition($foreignKey, $table->getName()) - ); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $this->writeCommand('dropForeignKey', array($tableName, $columns)); - - if ($constraint) { - $this->execute( - sprintf( - 'ALTER TABLE %s DROP CONSTRAINT %s', - $this->quoteTableName($tableName), - $constraint - ) - ); - } else { - foreach ($columns as $column) { - $rows = $this->fetchAll(sprintf( - "SELECT CONSTRAINT_NAME - FROM information_schema.KEY_COLUMN_USAGE - WHERE TABLE_SCHEMA = CURRENT_SCHEMA() - AND TABLE_NAME IS NOT NULL - AND TABLE_NAME = '%s' - AND COLUMN_NAME = '%s' - ORDER BY POSITION_IN_UNIQUE_CONSTRAINT", - $tableName, - $column - )); - - foreach ($rows as $row) { - $this->dropForeignKey($tableName, $columns, $row['constraint_name']); - } - } - } - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getSqlType($type, $limit = null) - { - switch ($type) { - case static::PHINX_TYPE_INTEGER: - if ($limit && $limit == static::INT_SMALL) { - return array( - 'name' => 'smallint', - 'limit' => static::INT_SMALL - ); - } - return array('name' => $type); - case static::PHINX_TYPE_TEXT: - case static::PHINX_TYPE_TIME: - case static::PHINX_TYPE_DATE: - case static::PHINX_TYPE_BOOLEAN: - case static::PHINX_TYPE_JSON: - case static::PHINX_TYPE_JSONB: - case static::PHINX_TYPE_UUID: - return array('name' => $type); - case static::PHINX_TYPE_DECIMAL: - return array('name' => $type, 'precision' => 18, 'scale' => 0); - case static::PHINX_TYPE_STRING: - return array('name' => 'character varying', 'limit' => 255); - case static::PHINX_TYPE_CHAR: - return array('name' => 'character', 'limit' => 255); - case static::PHINX_TYPE_BIG_INTEGER: - return array('name' => 'bigint'); - case static::PHINX_TYPE_FLOAT: - return array('name' => 'real'); - case static::PHINX_TYPE_DATETIME: - case static::PHINX_TYPE_TIMESTAMP: - return array('name' => 'timestamp'); - case static::PHINX_TYPE_BLOB: - case static::PHINX_TYPE_BINARY: - return array('name' => 'bytea'); - // Geospatial database types - // Spatial storage in Postgres is done via the PostGIS extension, - // which enables the use of the "geography" type in combination - // with SRID 4326. - case static::PHINX_TYPE_GEOMETRY: - return array('name' => 'geography', 'geometry', 4326); - break; - case static::PHINX_TYPE_POINT: - return array('name' => 'geography', 'point', 4326); - break; - case static::PHINX_TYPE_LINESTRING: - return array('name' => 'geography', 'linestring', 4326); - break; - case static::PHINX_TYPE_POLYGON: - return array('name' => 'geography', 'polygon', 4326); - break; - default: - if ($this->isArrayType($type)) { - return array('name' => $type); - } - // Return array type - throw new \RuntimeException('The type: "' . $type . '" is not supported'); - } - } - - /** - * Returns Phinx type by SQL type - * - * @param string $sqlType SQL type - * @returns string Phinx type - */ - public function getPhinxType($sqlType) - { - switch ($sqlType) { - case 'character varying': - case 'varchar': - return static::PHINX_TYPE_STRING; - case 'character': - case 'char': - return static::PHINX_TYPE_CHAR; - case 'text': - return static::PHINX_TYPE_TEXT; - case 'json': - return static::PHINX_TYPE_JSON; - case 'jsonb': - return static::PHINX_TYPE_JSONB; - case 'smallint': - return array( - 'name' => 'smallint', - 'limit' => static::INT_SMALL - ); - case 'int': - case 'int4': - case 'integer': - return static::PHINX_TYPE_INTEGER; - case 'decimal': - case 'numeric': - return static::PHINX_TYPE_DECIMAL; - case 'bigint': - case 'int8': - return static::PHINX_TYPE_BIG_INTEGER; - case 'real': - case 'float4': - return static::PHINX_TYPE_FLOAT; - case 'bytea': - return static::PHINX_TYPE_BINARY; - break; - case 'time': - case 'timetz': - case 'time with time zone': - case 'time without time zone': - return static::PHINX_TYPE_TIME; - case 'date': - return static::PHINX_TYPE_DATE; - case 'timestamp': - case 'timestamptz': - case 'timestamp with time zone': - case 'timestamp without time zone': - return static::PHINX_TYPE_DATETIME; - case 'bool': - case 'boolean': - return static::PHINX_TYPE_BOOLEAN; - case 'uuid': - return static::PHINX_TYPE_UUID; - default: - throw new \RuntimeException('The PostgreSQL type: "' . $sqlType . '" is not supported'); - } - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - $this->startCommandTimer(); - $this->writeCommand('createDatabase', array($name)); - $charset = isset($options['charset']) ? $options['charset'] : 'utf8'; - $this->execute(sprintf("CREATE DATABASE %s WITH ENCODING = '%s'", $name, $charset)); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function hasDatabase($databaseName) - { - $sql = sprintf("SELECT count(*) FROM pg_database WHERE datname = '%s'", $databaseName); - $result = $this->fetchRow($sql); - return $result['count'] > 0; - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - $this->startCommandTimer(); - $this->writeCommand('dropDatabase', array($name)); - $this->disconnect(); - $this->execute(sprintf('DROP DATABASE IF EXISTS %s', $name)); - $this->connect(); - $this->endCommandTimer(); - } - - /** - * Get the defintion for a `DEFAULT` statement. - * - * @param mixed $default - * @return string - */ - protected function getDefaultValueDefinition($default) - { - if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { - $default = $this->getConnection()->quote($default); - } elseif (is_bool($default)) { - $default = $this->castToBool($default); - } - return isset($default) ? 'DEFAULT ' . $default : ''; - } - - /** - * Gets the PostgreSQL Column Definition for a Column object. - * - * @param Column $column Column - * @return string - */ - protected function getColumnSqlDefinition(Column $column) - { - $buffer = array(); - if ($column->isIdentity()) { - $buffer[] = $column->getType() == 'biginteger' ? 'BIGSERIAL' : 'SERIAL'; - } else { - $sqlType = $this->getSqlType($column->getType(), $column->getLimit()); - $buffer[] = strtoupper($sqlType['name']); - // integers cant have limits in postgres - if (static::PHINX_TYPE_DECIMAL === $sqlType['name'] && ($column->getPrecision() || $column->getScale())) { - $buffer[] = sprintf( - '(%s, %s)', - $column->getPrecision() ? $column->getPrecision() : $sqlType['precision'], - $column->getScale() ? $column->getScale() : $sqlType['scale'] - ); - } elseif (!in_array($sqlType['name'], array('integer', 'smallint'))) { - if ($column->getLimit() || isset($sqlType['limit'])) { - $buffer[] = sprintf('(%s)', $column->getLimit() ? $column->getLimit() : $sqlType['limit']); - } - } - - $timeTypes = array( - 'time', - 'timestamp', - ); - if (in_array($sqlType['name'], $timeTypes) && $column->isTimezone()) { - $buffer[] = strtoupper('with time zone'); - } - } - - $buffer[] = $column->isNull() ? 'NULL' : 'NOT NULL'; - - if (!is_null($column->getDefault())) { - $buffer[] = $this->getDefaultValueDefinition($column->getDefault()); - } - - return implode(' ', $buffer); - } - - /** - * Gets the PostgreSQL Column Comment Defininition for a column object. - * - * @param Column $column Column - * @param string $tableName Table name - * @return string - */ - protected function getColumnCommentSqlDefinition(Column $column, $tableName) - { - // passing 'null' is to remove column comment - $comment = (strcasecmp($column->getComment(), 'NULL') !== 0) - ? $this->getConnection()->quote($column->getComment()) - : 'NULL'; - - return sprintf( - 'COMMENT ON COLUMN %s.%s IS %s;', - $tableName, - $column->getName(), - $comment - ); - } - - /** - * Gets the PostgreSQL Index Definition for an Index object. - * - * @param Index $index Index - * @param string $tableName Table name - * @return string - */ - protected function getIndexSqlDefinition(Index $index, $tableName) - { - if (is_string($index->getName())) { - $indexName = $index->getName(); - } else { - $columnNames = $index->getColumns(); - if (is_string($columnNames)) { - $columnNames = array($columnNames); - } - $indexName = sprintf('%s_%s', $tableName, implode('_', $columnNames)); - } - $def = sprintf( - "CREATE %s INDEX %s ON %s (%s);", - ($index->getType() === Index::UNIQUE ? 'UNIQUE' : ''), - $indexName, - $this->quoteTableName($tableName), - implode(',', $index->getColumns()) - ); - return $def; - } - - /** - * Gets the MySQL Foreign Key Definition for an ForeignKey object. - * - * @param ForeignKey $foreignKey - * @param string $tableName Table name - * @return string - */ - protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) - { - $constraintName = $foreignKey->getConstraint() ?: $tableName . '_' . implode('_', $foreignKey->getColumns()); - $def = ' CONSTRAINT "' . $constraintName . '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; - $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; - if ($foreignKey->getOnDelete()) { - $def .= " ON DELETE {$foreignKey->getOnDelete()}"; - } - if ($foreignKey->getOnUpdate()) { - $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; - } - return $def; - } - - /** - * {@inheritdoc} - */ - public function createSchemaTable() - { - // Create the public/custom schema if it doesn't already exist - if (false === $this->hasSchema($this->getSchemaName())) { - $this->createSchema($this->getSchemaName()); - } - - $this->fetchAll(sprintf('SET search_path TO %s', $this->getSchemaName())); - - return parent::createSchemaTable(); - } - - /** - * Creates the specified schema. - * - * @param string $schemaName Schema Name - * @return void - */ - public function createSchema($schemaName = 'public') - { - $this->startCommandTimer(); - $this->writeCommand('addSchema', array($schemaName)); - $sql = sprintf('CREATE SCHEMA %s;', $this->quoteSchemaName($schemaName)); // from postgres 9.3 we can use "CREATE SCHEMA IF NOT EXISTS schema_name" - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * Checks to see if a schema exists. - * - * @param string $schemaName Schema Name - * @return boolean - */ - public function hasSchema($schemaName) - { - $sql = sprintf( - "SELECT count(*) - FROM pg_namespace - WHERE nspname = '%s'", - $schemaName - ); - $result = $this->fetchRow($sql); - return $result['count'] > 0; - } - - /** - * Drops the specified schema table. - * - * @param string $schemaName Schema name - * @return void - */ - public function dropSchema($schemaName) - { - $this->startCommandTimer(); - $this->writeCommand('dropSchema', array($schemaName)); - $sql = sprintf("DROP SCHEMA IF EXISTS %s CASCADE;", $this->quoteSchemaName($schemaName)); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * Drops all schemas. - * - * @return void - */ - public function dropAllSchemas() - { - $this->startCommandTimer(); - $this->writeCommand('dropAllSchemas'); - foreach ($this->getAllSchemas() as $schema) { - $this->dropSchema($schema); - } - $this->endCommandTimer(); - } - - /** - * Returns schemas. - * - * @return array - */ - public function getAllSchemas() - { - $sql = "SELECT schema_name - FROM information_schema.schemata - WHERE schema_name <> 'information_schema' AND schema_name !~ '^pg_'"; - $items = $this->fetchAll($sql); - $schemaNames = array(); - foreach ($items as $item) { - $schemaNames[] = $item['schema_name']; - } - return $schemaNames; - } - - /** - * {@inheritdoc} - */ - public function getColumnTypes() - { - return array_merge(parent::getColumnTypes(), array('json', 'jsonb')); - } - - /** - * {@inheritdoc} - */ - public function isValidColumnType(Column $column) - { - // If not a standard column type, maybe it is array type? - return (parent::isValidColumnType($column) || $this->isArrayType($column->getType())); - } - - /** - * Check if the given column is an array of a valid type. - * - * @param string $columnType - * @return bool - */ - protected function isArrayType($columnType) - { - if (!preg_match('/^([a-z]+)(?:\[\]){1,}$/', $columnType, $matches)) { - return false; - } - - $baseType = $matches[1]; - return in_array($baseType, $this->getColumnTypes()); - } - - /** - * Gets the schema name. - * - * @return string - */ - private function getSchemaName() - { - $options = $this->getOptions(); - return empty($options['schema']) ? 'public' : $options['schema']; - } - - /** - * Cast a value to a boolean appropriate for the adapter. - * - * @param mixed $value The value to be cast - * - * @return mixed - */ - public function castToBool($value) - { - return (bool) $value ? 'TRUE' : 'FALSE'; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/ProxyAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/ProxyAdapter.php deleted file mode 100644 index 1236031..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/ProxyAdapter.php +++ /dev/null @@ -1,325 +0,0 @@ - - */ -class ProxyAdapter extends AdapterWrapper -{ - /** - * @var array - */ - protected $commands; - - /** - * {@inheritdoc} - */ - public function getAdapterType() - { - return 'ProxyAdapter'; - } - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $this->recordCommand('createTable', array($table->getName())); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $this->recordCommand('renameTable', array($tableName, $newTableName)); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $this->recordCommand('dropTable', array($tableName)); - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $this->recordCommand('addColumn', array($table, $column)); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $this->recordCommand('renameColumn', array($tableName, $columnName, $newColumnName)); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - $this->recordCommand('changeColumn', array($tableName, $columnName, $newColumn)); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - $this->recordCommand('dropColumn', array($tableName, $columnName)); - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $this->recordCommand('addIndex', array($table, $index)); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns, $options = array()) - { - $this->recordCommand('dropIndex', array($tableName, $columns, $options)); - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $this->recordCommand('dropIndexByName', array($tableName, $indexName)); - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - $this->recordCommand('addForeignKey', array($table, $foreignKey)); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - $this->recordCommand('dropForeignKey', array($columns, $constraint)); - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - $this->recordCommand('createDatabase', array($name, $options)); - } - - /** - * Record a command for execution later. - * - * @param string $name Command Name - * @param array $arguments Command Arguments - * @return void - */ - public function recordCommand($name, $arguments) - { - $this->commands[] = array( - 'name' => $name, - 'arguments' => $arguments - ); - } - - /** - * Sets an array of recorded commands. - * - * @param array $commands Commands - * @return ProxyAdapter - */ - public function setCommands($commands) - { - $this->commands = $commands; - return $this; - } - - /** - * Gets an array of the recorded commands. - * - * @return array - */ - public function getCommands() - { - return $this->commands; - } - - /** - * Gets an array of the recorded commands in reverse. - * - * @throws IrreversibleMigrationException if a command cannot be reversed. - * @return array - */ - public function getInvertedCommands() - { - if (null === $this->getCommands()) { - return array(); - } - - $invCommands = array(); - $supportedCommands = array( - 'createTable', 'renameTable', 'addColumn', - 'renameColumn', 'addIndex', 'addForeignKey' - ); - foreach (array_reverse($this->getCommands()) as $command) { - if (!in_array($command['name'], $supportedCommands)) { - throw new IrreversibleMigrationException(sprintf( - 'Cannot reverse a "%s" command', - $command['name'] - )); - } - $invertMethod = 'invert' . ucfirst($command['name']); - $invertedCommand = $this->$invertMethod($command['arguments']); - $invCommands[] = array( - 'name' => $invertedCommand['name'], - 'arguments' => $invertedCommand['arguments'] - ); - } - - return $invCommands; - } - - /** - * Execute the recorded commands. - * - * @return void - */ - public function executeCommands() - { - $commands = $this->getCommands(); - foreach ($commands as $command) { - call_user_func_array(array($this->getAdapter(), $command['name']), $command['arguments']); - } - } - - /** - * Execute the recorded commands in reverse. - * - * @return void - */ - public function executeInvertedCommands() - { - $commands = $this->getInvertedCommands(); - foreach ($commands as $command) { - call_user_func_array(array($this->getAdapter(), $command['name']), $command['arguments']); - } - } - - /** - * Returns the reverse of a createTable command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertCreateTable($args) - { - return array('name' => 'dropTable', 'arguments' => array($args[0])); - } - - /** - * Returns the reverse of a renameTable command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertRenameTable($args) - { - return array('name' => 'renameTable', 'arguments' => array($args[1], $args[0])); - } - - /** - * Returns the reverse of a addColumn command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertAddColumn($args) - { - return array('name' => 'dropColumn', 'arguments' => array($args[0]->getName(), $args[1]->getName())); - } - - /** - * Returns the reverse of a renameColumn command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertRenameColumn($args) - { - return array('name' => 'renameColumn', 'arguments' => array($args[0], $args[2], $args[1])); - } - - /** - * Returns the reverse of a addIndex command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertAddIndex($args) - { - return array('name' => 'dropIndex', 'arguments' => array($args[0]->getName(), $args[1]->getColumns())); - } - - /** - * Returns the reverse of a addForeignKey command. - * - * @param array $args Method Arguments - * @return array - */ - public function invertAddForeignKey($args) - { - return array('name' => 'dropForeignKey', 'arguments' => array($args[0]->getName(), $args[1]->getColumns())); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SQLiteAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SQLiteAdapter.php deleted file mode 100644 index 4ff7b74..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SQLiteAdapter.php +++ /dev/null @@ -1,1136 +0,0 @@ - - * @author Richard McIntyre - */ -class SQLiteAdapter extends PdoAdapter implements AdapterInterface -{ - protected $definitionsWithLimits = array( - 'CHARACTER', - 'VARCHAR', - 'VARYING CHARACTER', - 'NCHAR', - 'NATIVE CHARACTER', - 'NVARCHAR' - ); - - /** - * {@inheritdoc} - */ - public function connect() - { - if (null === $this->connection) { - if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers(), true)) { - // @codeCoverageIgnoreStart - throw new \RuntimeException('You need to enable the PDO_SQLITE extension for Phinx to run properly.'); - // @codeCoverageIgnoreEnd - } - - $db = null; - $options = $this->getOptions(); - - // if port is specified use it, otherwise use the MySQL default - if (isset($options['memory'])) { - $dsn = 'sqlite::memory:'; - } else { - $dsn = 'sqlite:' . $options['name']; - if (file_exists($options['name'] . '.sqlite3')) { - $dsn = 'sqlite:' . $options['name'] . '.sqlite3'; - } - } - - try { - $db = new \PDO($dsn); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - $this->connection = null; - } - - /** - * {@inheritdoc} - */ - public function hasTransactions() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function beginTransaction() - { - $this->execute('BEGIN TRANSACTION'); - } - - /** - * {@inheritdoc} - */ - public function commitTransaction() - { - $this->execute('COMMIT'); - } - - /** - * {@inheritdoc} - */ - public function rollbackTransaction() - { - $this->execute('ROLLBACK'); - } - - /** - * {@inheritdoc} - */ - public function quoteTableName($tableName) - { - return str_replace('.', '`.`', $this->quoteColumnName($tableName)); - } - - /** - * {@inheritdoc} - */ - public function quoteColumnName($columnName) - { - return '`' . str_replace('`', '``', $columnName) . '`'; - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - $tables = array(); - $rows = $this->fetchAll(sprintf('SELECT name FROM sqlite_master WHERE type=\'table\' AND name=\'%s\'', $tableName)); - foreach ($rows as $row) { - $tables[] = strtolower($row[0]); - } - - return in_array(strtolower($tableName), $tables); - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $this->startCommandTimer(); - - // Add the default primary key - $columns = $table->getPendingColumns(); - $options = $table->getOptions(); - if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { - $column = new Column(); - $column->setName('id') - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - - } elseif (isset($options['id']) && is_string($options['id'])) { - // Handle id => "field_name" to support AUTO_INCREMENT - $column = new Column(); - $column->setName($options['id']) - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - } - - $sql = 'CREATE TABLE '; - $sql .= $this->quoteTableName($table->getName()) . ' ('; - foreach ($columns as $column) { - $sql .= $this->quoteColumnName($column->getName()) . ' ' . $this->getColumnSqlDefinition($column) . ', '; - } - - // set the primary key(s) - if (isset($options['primary_key'])) { - $sql = rtrim($sql); - $sql .= ' PRIMARY KEY ('; - if (is_string($options['primary_key'])) { // handle primary_key => 'id' - $sql .= $this->quoteColumnName($options['primary_key']); - } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') - // PHP 5.4 will allow access of $this, so we can call quoteColumnName() directly in the anonymous function, - // but for now just hard-code the adapter quotes - $sql .= implode( - ',', - array_map( - function ($v) { - return '`' . $v . '`'; - }, - $options['primary_key'] - ) - ); - } - $sql .= ')'; - } else { - $sql = substr(rtrim($sql), 0, -1); // no primary keys - } - - // set the foreign keys - $foreignKeys = $table->getForeignKeys(); - if (!empty($foreignKeys)) { - foreach ($foreignKeys as $foreignKey) { - $sql .= ', ' . $this->getForeignKeySqlDefinition($foreignKey); - } - } - - $sql = rtrim($sql) . ');'; - // execute the sql - $this->writeCommand('createTable', array($table->getName())); - $this->execute($sql); - $this->endCommandTimer(); - - foreach ($table->getIndexes() as $index) { - $this->addIndex($table, $index); - } - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $this->startCommandTimer(); - $this->writeCommand('renameTable', array($tableName, $newTableName)); - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $this->quoteTableName($tableName), $this->quoteTableName($newTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $this->startCommandTimer(); - $this->writeCommand('dropTable', array($tableName)); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - $columns = array(); - $rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - - foreach ($rows as $columnInfo) { - $column = new Column(); - $type = strtolower($columnInfo['type']); - $column->setName($columnInfo['name']) - ->setNull($columnInfo['notnull'] !== '1') - ->setDefault($columnInfo['dflt_value']); - - $phinxType = $this->getPhinxType($type); - $column->setType($phinxType['name']) - ->setLimit($phinxType['limit']); - - if ($columnInfo['pk'] == 1) { - $column->setIdentity(true); - } - - $columns[] = $column; - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName) - { - $rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - foreach ($rows as $column) { - if (strcasecmp($column['name'], $columnName) === 0) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $this->startCommandTimer(); - - $sql = sprintf( - 'ALTER TABLE %s ADD COLUMN %s %s', - $this->quoteTableName($table->getName()), - $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) - ); - - $this->writeCommand('addColumn', array($table->getName(), $column->getName(), $column->getType())); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $tmpTableName = 'tmp_' . $tableName; - - $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); - - $sql = ''; - foreach ($rows as $table) { - if ($table['tbl_name'] === $tableName) { - $sql = $table['sql']; - } - } - - $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - $selectColumns = array(); - $writeColumns = array(); - foreach ($columns as $column) { - $selectName = $column['name']; - $writeName = ($selectName == $columnName) ? $newColumnName : $selectName; - $selectColumns[] = $this->quoteColumnName($selectName); - $writeColumns[] = $this->quoteColumnName($writeName); - } - - if (!in_array($this->quoteColumnName($columnName), $selectColumns)) { - throw new \InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' . $columnName - )); - } - - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $tableName, $tmpTableName)); - - $sql = str_replace( - $this->quoteColumnName($columnName), - $this->quoteColumnName($newColumnName), - $sql - ); - $this->execute($sql); - - $sql = sprintf( - 'INSERT INTO %s(%s) SELECT %s FROM %s', - $tableName, - implode(', ', $writeColumns), - implode(', ', $selectColumns), - $tmpTableName - ); - - $this->execute($sql); - - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - - // TODO: DRY this up.... - - $this->startCommandTimer(); - $this->writeCommand('changeColumn', array($tableName, $columnName, $newColumn->getType())); - - $tmpTableName = 'tmp_' . $tableName; - - $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); - - $sql = ''; - foreach ($rows as $table) { - if ($table['tbl_name'] === $tableName) { - $sql = $table['sql']; - } - } - - $columns = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - $selectColumns = array(); - $writeColumns = array(); - foreach ($columns as $column) { - $selectName = $column['name']; - $writeName = ($selectName === $columnName) ? $newColumn->getName() : $selectName; - $selectColumns[] = $this->quoteColumnName($selectName); - $writeColumns[] = $this->quoteColumnName($writeName); - } - - if (!in_array($this->quoteColumnName($columnName), $selectColumns)) { - throw new \InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' . $columnName - )); - } - - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $tableName, $tmpTableName)); - - $sql = preg_replace( - sprintf("/%s[^,]+([,)])/", $this->quoteColumnName($columnName)), - sprintf('%s %s$1', $this->quoteColumnName($newColumn->getName()), $this->getColumnSqlDefinition($newColumn)), - $sql, - 1 - ); - - $this->execute($sql); - - $sql = sprintf( - 'INSERT INTO %s(%s) SELECT %s FROM %s', - $tableName, - implode(', ', $writeColumns), - implode(', ', $selectColumns), - $tmpTableName - ); - - $this->execute($sql); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - // TODO: DRY this up.... - - $this->startCommandTimer(); - $this->writeCommand('dropColumn', array($tableName, $columnName)); - - $tmpTableName = 'tmp_' . $tableName; - - $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); - - $sql = ''; - foreach ($rows as $table) { - if ($table['tbl_name'] === $tableName) { - $sql = $table['sql']; - } - } - - $rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - $columns = array(); - $columnType = null; - foreach ($rows as $row) { - if ($row['name'] !== $columnName) { - $columns[] = $row['name']; - } else { - $found = true; - $columnType = $row['type']; - } - } - - if (!isset($found)) { - throw new \InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' . $columnName - )); - } - - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $tableName, $tmpTableName)); - - $sql = preg_replace( - sprintf("/%s\s%s[^,)]*(,\s|\))/", preg_quote($this->quoteColumnName($columnName)), preg_quote($columnType)), - "", - $sql - ); - - if (substr($sql, -2) === ', ') { - $sql = substr($sql, 0, -2) . ')'; - } - - $this->execute($sql); - - $sql = sprintf( - 'INSERT INTO %s(%s) SELECT %s FROM %s', - $tableName, - implode(', ', $columns), - implode(', ', $columns), - $tmpTableName - ); - - $this->execute($sql); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName))); - $this->endCommandTimer(); - } - - /** - * Get an array of indexes from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getIndexes($tableName) - { - $indexes = array(); - $rows = $this->fetchAll(sprintf('pragma index_list(%s)', $tableName)); - - foreach ($rows as $row) { - $indexData = $this->fetchAll(sprintf('pragma index_info(%s)', $row['name'])); - if (!isset($indexes[$tableName])) { - $indexes[$tableName] = array('index' => $row['name'], 'columns' => array()); - } - foreach ($indexData as $indexItem) { - $indexes[$tableName]['columns'][] = strtolower($indexItem['name']); - } - } - return $indexes; - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $columns = array_map('strtolower', $columns); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $index) { - $a = array_diff($columns, $index['columns']); - if (empty($a)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $index) { - if ($indexName === $index['index']) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $this->startCommandTimer(); - $this->writeCommand('addIndex', array($table->getName(), $index->getColumns())); - $indexColumnArray = array(); - foreach ($index->getColumns() as $column) { - $indexColumnArray []= sprintf('`%s` ASC', $column); - } - $indexColumns = implode(',', $indexColumnArray); - $this->execute( - sprintf( - 'CREATE %s ON %s (%s)', - $this->getIndexSqlDefinition($table, $index), - $this->quoteTableName($table->getName()), - $indexColumns - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropIndex', array($tableName, $columns)); - $indexes = $this->getIndexes($tableName); - $columns = array_map('strtolower', $columns); - - foreach ($indexes as $index) { - $a = array_diff($columns, $index['columns']); - if (empty($a)) { - $this->execute( - sprintf( - 'DROP INDEX %s', - $this->quoteColumnName($index['index']) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $this->startCommandTimer(); - - $this->writeCommand('dropIndexByName', array($tableName, $indexName)); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $index) { - if ($indexName === $index['index']) { - $this->execute( - sprintf( - 'DROP INDEX %s', - $this->quoteColumnName($indexName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $foreignKeys = $this->getForeignKeys($tableName); - - $a = array_diff($columns, $foreignKeys); - if (empty($a)) { - return true; - } - return false; - } - - /** - * Get an array of foreign keys from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getForeignKeys($tableName) - { - $foreignKeys = array(); - $rows = $this->fetchAll( - "SELECT sql, tbl_name - FROM ( - SELECT sql sql, type type, tbl_name tbl_name, name name - FROM sqlite_master - UNION ALL - SELECT sql, type, tbl_name, name - FROM sqlite_temp_master - ) - WHERE type != 'meta' - AND sql NOTNULL - AND name NOT LIKE 'sqlite_%' - ORDER BY substr(type, 2, 1), name" - ); - - foreach ($rows as $row) { - if ($row['tbl_name'] === $tableName) { - - if (strpos($row['sql'], 'REFERENCES') !== false) { - preg_match_all("/\(`([^`]*)`\) REFERENCES/", $row['sql'], $matches); - foreach ($matches[1] as $match) { - $foreignKeys[] = $match; - } - } - } - } - return $foreignKeys; - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - // TODO: DRY this up.... - $this->startCommandTimer(); - $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns())); - $this->execute('pragma foreign_keys = ON'); - - $tmpTableName = 'tmp_' . $table->getName(); - $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); - - $sql = ''; - foreach ($rows as $row) { - if ($row['tbl_name'] === $table->getName()) { - $sql = $row['sql']; - } - } - - $rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($table->getName()))); - $columns = array(); - foreach ($rows as $column) { - $columns[] = $this->quoteColumnName($column['name']); - } - - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $this->quoteTableName($table->getName()), $tmpTableName)); - - $sql = substr($sql, 0, -1) . ',' . $this->getForeignKeySqlDefinition($foreignKey) . ')'; - $this->execute($sql); - - $sql = sprintf( - 'INSERT INTO %s(%s) SELECT %s FROM %s', - $this->quoteTableName($table->getName()), - implode(', ', $columns), - implode(', ', $columns), - $this->quoteTableName($tmpTableName) - ); - - $this->execute($sql); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - // TODO: DRY this up.... - - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropForeignKey', array($tableName, $columns)); - - $tmpTableName = 'tmp_' . $tableName; - - $rows = $this->fetchAll('select * from sqlite_master where `type` = \'table\''); - - $sql = ''; - foreach ($rows as $table) { - if ($table['tbl_name'] === $tableName) { - $sql = $table['sql']; - } - } - - $rows = $this->fetchAll(sprintf('pragma table_info(%s)', $this->quoteTableName($tableName))); - $replaceColumns = array(); - foreach ($rows as $row) { - if (!in_array($row['name'], $columns)) { - $replaceColumns[] = $row['name']; - } else { - $found = true; - } - } - - if (!isset($found)) { - throw new \InvalidArgumentException(sprintf( - 'The specified column doesn\'t exist: ' - )); - } - - $this->execute(sprintf('ALTER TABLE %s RENAME TO %s', $this->quoteTableName($tableName), $tmpTableName)); - - foreach ($columns as $columnName) { - $search = sprintf( - "/,[^,]*\(%s(?:,`?(.*)`?)?\) REFERENCES[^,]*\([^\)]*\)[^,)]*/", - $this->quoteColumnName($columnName) - ); - $sql = preg_replace($search, '', $sql, 1); - } - - $this->execute($sql); - - $sql = sprintf( - 'INSERT INTO %s(%s) SELECT %s FROM %s', - $tableName, - implode(', ', $columns), - implode(', ', $columns), - $tmpTableName - ); - - $this->execute($sql); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tmpTableName))); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function insert(Table $table, $row) - { - $this->startCommandTimer(); - $this->writeCommand('insert', array($table->getName())); - - $sql = sprintf( - "INSERT INTO %s ", - $this->quoteTableName($table->getName()) - ); - - $columns = array_keys($row); - $sql .= "(". implode(', ', array_map(array($this, 'quoteColumnName'), $columns)) . ")"; - $sql .= " VALUES "; - - $sql .= "(" . implode(', ', array_map(function ($value) { - if (is_numeric($value)) { - return $value; - } - return "'{$value}'"; - }, $row)) . ")"; - - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getSqlType($type, $limit = null) - { - switch ($type) { - case static::PHINX_TYPE_STRING: - return array('name' => 'varchar', 'limit' => 255); - break; - case static::PHINX_TYPE_CHAR: - return array('name' => 'char', 'limit' => 255); - break; - case static::PHINX_TYPE_TEXT: - return array('name' => 'text'); - break; - case static::PHINX_TYPE_INTEGER: - return array('name' => 'integer'); - break; - case static::PHINX_TYPE_BIG_INTEGER: - return array('name' => 'bigint'); - break; - case static::PHINX_TYPE_FLOAT: - return array('name' => 'float'); - break; - case static::PHINX_TYPE_DECIMAL: - return array('name' => 'decimal'); - break; - case static::PHINX_TYPE_DATETIME: - return array('name' => 'datetime'); - break; - case static::PHINX_TYPE_TIMESTAMP: - return array('name' => 'datetime'); - break; - case static::PHINX_TYPE_TIME: - return array('name' => 'time'); - break; - case static::PHINX_TYPE_DATE: - return array('name' => 'date'); - break; - case static::PHINX_TYPE_BLOB: - case static::PHINX_TYPE_BINARY: - return array('name' => 'blob'); - break; - case static::PHINX_TYPE_BOOLEAN: - return array('name' => 'boolean'); - break; - case static::PHINX_TYPE_UUID: - return array('name' => 'char', 'limit' => 36); - case static::PHINX_TYPE_ENUM: - return array('name' => 'enum'); - // Geospatial database types - // No specific data types exist in SQLite, instead all geospatial - // functionality is handled in the client. See also: SpatiaLite. - case static::PHINX_TYPE_GEOMETRY: - case static::PHINX_TYPE_POLYGON: - return array('name' => 'text'); - return; - case static::PHINX_TYPE_LINESTRING: - return array('name' => 'varchar', 'limit' => 255); - break; - case static::PHINX_TYPE_POINT: - return array('name' => 'float'); - default: - throw new \RuntimeException('The type: "' . $type . '" is not supported.'); - } - } - - /** - * Returns Phinx type by SQL type - * - * @param string $sqlTypeDef SQL type - * @returns string Phinx type - */ - public function getPhinxType($sqlTypeDef) - { - if (!preg_match('/^([\w]+)(\(([\d]+)*(,([\d]+))*\))*$/', $sqlTypeDef, $matches)) { - throw new \RuntimeException('Column type ' . $sqlTypeDef . ' is not supported'); - } else { - $limit = null; - $precision = null; - $type = $matches[1]; - if (count($matches) > 2) { - $limit = $matches[3] ? $matches[3] : null; - } - if (count($matches) > 4) { - $precision = $matches[5]; - } - switch ($matches[1]) { - case 'varchar': - $type = static::PHINX_TYPE_STRING; - if ($limit === 255) { - $limit = null; - } - break; - case 'char': - $type = static::PHINX_TYPE_CHAR; - if ($limit === 255) { - $limit = null; - } - if ($limit === 36) { - $type = static::PHINX_TYPE_UUID; - } - break; - case 'int': - $type = static::PHINX_TYPE_INTEGER; - if ($limit === 11) { - $limit = null; - } - break; - case 'bigint': - if ($limit === 11) { - $limit = null; - } - $type = static::PHINX_TYPE_BIG_INTEGER; - break; - case 'blob': - $type = static::PHINX_TYPE_BINARY; - break; - } - if ($type === 'tinyint') { - if ($matches[3] === 1) { - $type = static::PHINX_TYPE_BOOLEAN; - $limit = null; - } - } - - $this->getSqlType($type); - - return array( - 'name' => $type, - 'limit' => $limit, - 'precision' => $precision - ); - } - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - $this->startCommandTimer(); - $this->writeCommand('createDatabase', array($name)); - touch($name . '.sqlite3'); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function hasDatabase($name) - { - return is_file($name . '.sqlite3'); - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - $this->startCommandTimer(); - $this->writeCommand('dropDatabase', array($name)); - if (file_exists($name . '.sqlite3')) { - unlink($name . '.sqlite3'); - } - $this->endCommandTimer(); - } - - /** - * Get the definition for a `DEFAULT` statement. - * - * @param mixed $default - * @return string - */ - protected function getDefaultValueDefinition($default) - { - if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { - $default = $this->getConnection()->quote($default); - } elseif (is_bool($default)) { - $default = $this->castToBool($default); - } - return isset($default) ? ' DEFAULT ' . $default : ''; - } - - /** - * Gets the SQLite Column Definition for a Column object. - * - * @param Column $column Column - * @return string - */ - protected function getColumnSqlDefinition(Column $column) - { - $sqlType = $this->getSqlType($column->getType()); - $def = ''; - $def .= strtoupper($sqlType['name']); - if ($column->getPrecision() && $column->getScale()) { - $def .= '(' . $column->getPrecision() . ',' . $column->getScale() . ')'; - } - $limitable = in_array(strtoupper($sqlType['name']), $this->definitionsWithLimits); - if (($column->getLimit() || isset($sqlType['limit'])) && $limitable) { - $def .= '(' . ($column->getLimit() ? $column->getLimit() : $sqlType['limit']) . ')'; - } - if (($values = $column->getValues()) && is_array($values)) { - $def .= " CHECK({$column->getName()} IN ('" . implode("', '", $values) . "'))"; - } - - $default = $column->getDefault(); - - $def .= ($column->isNull() || is_null($default)) ? ' NULL' : ' NOT NULL'; - $def .= $this->getDefaultValueDefinition($default); - $def .= ($column->isIdentity()) ? ' PRIMARY KEY AUTOINCREMENT' : ''; - - if ($column->getUpdate()) { - $def .= ' ON UPDATE ' . $column->getUpdate(); - } - - $def .= $this->getCommentDefinition($column); - - return $def; - } - - /** - * Gets the comment Definition for a Column object. - * - * @param Column $column Column - * @return string - */ - protected function getCommentDefinition(Column $column) - { - if ($column->getComment()) { - return ' /* ' . $column->getComment() . ' */ '; - } - return ''; - } - - /** - * Gets the SQLite Index Definition for an Index object. - * - * @param Index $index Index - * @return string - */ - protected function getIndexSqlDefinition(Table $table, Index $index) - { - if ($index->getType() === Index::UNIQUE) { - $def = 'UNIQUE INDEX'; - } else { - $def = 'INDEX'; - } - if (is_string($index->getName())) { - $indexName = $index->getName(); - } else { - $indexName = $table->getName() . '_'; - foreach ($index->getColumns() as $column) { - $indexName .= $column . '_'; - } - $indexName .= 'index'; - } - $def .= ' `' . $indexName . '`'; - return $def; - } - - /** - * {@inheritdoc} - */ - public function getColumnTypes() - { - return array_merge(parent::getColumnTypes(), array('enum')); - } - - /** - * Gets the SQLite Foreign Key Definition for an ForeignKey object. - * - * @param ForeignKey $foreignKey - * @return string - */ - protected function getForeignKeySqlDefinition(ForeignKey $foreignKey) - { - $def = ''; - if ($foreignKey->getConstraint()) { - $def .= ' CONSTRAINT ' . $this->quoteColumnName($foreignKey->getConstraint()); - } else { - $columnNames = array(); - foreach ($foreignKey->getColumns() as $column) { - $columnNames[] = $this->quoteColumnName($column); - } - $def .= ' FOREIGN KEY (' . implode(',', $columnNames) . ')'; - $refColumnNames = array(); - foreach ($foreignKey->getReferencedColumns() as $column) { - $refColumnNames[] = $this->quoteColumnName($column); - } - $def .= ' REFERENCES ' . $this->quoteTableName($foreignKey->getReferencedTable()->getName()) . ' (' . implode(',', $refColumnNames) . ')'; - if ($foreignKey->getOnDelete()) { - $def .= ' ON DELETE ' . $foreignKey->getOnDelete(); - } - if ($foreignKey->getOnUpdate()) { - $def .= ' ON UPDATE ' . $foreignKey->getOnUpdate(); - } - } - return $def; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SqlServerAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SqlServerAdapter.php deleted file mode 100644 index 99f8a82..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/SqlServerAdapter.php +++ /dev/null @@ -1,1165 +0,0 @@ - - */ -class SqlServerAdapter extends PdoAdapter implements AdapterInterface -{ - protected $schema = 'dbo'; - - protected $signedColumnTypes = array('integer' => true, 'biginteger' => true, 'float' => true, 'decimal' => true); - - /** - * {@inheritdoc} - */ - public function connect() - { - if (null === $this->connection) { - if (!class_exists('PDO') || !in_array('sqlsrv', \PDO::getAvailableDrivers(), true)) { - // try our connection via freetds (Mac/Linux) - return $this->connectDblib(); - } - - $db = null; - $options = $this->getOptions(); - - // if port is specified use it, otherwise use the SqlServer default - if (empty($options['port'])) { - $dsn = 'sqlsrv:server=' . $options['host'] . ';database=' . $options['name']; - } else { - $dsn = 'sqlsrv:server=' . $options['host'] . ',' . $options['port'] . ';database=' . $options['name']; - } - $dsn .= ';MultipleActiveResultSets=false'; - - $driverOptions = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION); - - // charset support - if (isset($options['charset'])) { - $driverOptions[\PDO::SQLSRV_ATTR_ENCODING] = $options['charset']; - } - - // support arbitrary \PDO::SQLSRV_ATTR_* driver options and pass them to PDO - // http://php.net/manual/en/ref.pdo-sqlsrv.php#pdo-sqlsrv.constants - foreach ($options as $key => $option) { - if (strpos($key, 'sqlsrv_attr_') === 0) { - $driverOptions[constant('\PDO::' . strtoupper($key))] = $option; - } - } - - try { - $db = new \PDO($dsn, $options['user'], $options['pass'], $driverOptions); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } - } - - /** - * Connect to MSSQL using dblib/freetds. - * - * The "sqlsrv" driver is not available on Unix machines. - * - * @throws \InvalidArgumentException - */ - protected function connectDblib() - { - if (!class_exists('PDO') || !in_array('dblib', \PDO::getAvailableDrivers(), true)) { - // @codeCoverageIgnoreStart - throw new \RuntimeException('You need to enable the PDO_Dblib extension for Phinx to run properly.'); - // @codeCoverageIgnoreEnd - } - - $options = $this->getOptions(); - - // if port is specified use it, otherwise use the SqlServer default - if (empty($options['port'])) { - $dsn = 'dblib:host=' . $options['host'] . ';dbname=' . $options['name']; - } else { - $dsn = 'dblib:host=' . $options['host'] . ':' . $options['port'] . ';dbname=' . $options['name']; - } - - $driverOptions = array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION); - - try { - $db = new \PDO($dsn, $options['user'], $options['pass'], $driverOptions); - } catch (\PDOException $exception) { - throw new \InvalidArgumentException(sprintf( - 'There was a problem connecting to the database: %s', - $exception->getMessage() - )); - } - - $this->setConnection($db); - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - $this->connection = null; - } - - /** - * {@inheritdoc} - */ - public function hasTransactions() - { - return true; - } - - /** - * {@inheritdoc} - */ - public function beginTransaction() - { - $this->execute('BEGIN TRANSACTION'); - } - - /** - * {@inheritdoc} - */ - public function commitTransaction() - { - $this->execute('COMMIT TRANSACTION'); - } - - /** - * {@inheritdoc} - */ - public function rollbackTransaction() - { - $this->execute('ROLLBACK TRANSACTION'); - } - - /** - * {@inheritdoc} - */ - public function quoteTableName($tableName) - { - return str_replace('.', '].[', $this->quoteColumnName($tableName)); - } - - /** - * {@inheritdoc} - */ - public function quoteColumnName($columnName) - { - return '[' . str_replace(']', '\]', $columnName) . ']'; - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - $result = $this->fetchRow(sprintf('SELECT count(*) as [count] FROM information_schema.tables WHERE table_name = \'%s\';', $tableName)); - return $result['count'] > 0; - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $this->startCommandTimer(); - - $options = $table->getOptions(); - - // Add the default primary key - $columns = $table->getPendingColumns(); - if (!isset($options['id']) || (isset($options['id']) && $options['id'] === true)) { - $column = new Column(); - $column->setName('id') - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - $options['primary_key'] = 'id'; - - } elseif (isset($options['id']) && is_string($options['id'])) { - // Handle id => "field_name" to support AUTO_INCREMENT - $column = new Column(); - $column->setName($options['id']) - ->setType('integer') - ->setIdentity(true); - - array_unshift($columns, $column); - $options['primary_key'] = $options['id']; - } - - $sql = 'CREATE TABLE '; - $sql .= $this->quoteTableName($table->getName()) . ' ('; - $sqlBuffer = array(); - $columnsWithComments = array(); - foreach ($columns as $column) { - $sqlBuffer[] = $this->quoteColumnName($column->getName()) . ' ' . $this->getColumnSqlDefinition($column); - - // set column comments, if needed - if ($column->getComment()) { - $columnsWithComments[] = $column; - } - } - - // set the primary key(s) - if (isset($options['primary_key'])) { - $pkSql = sprintf('CONSTRAINT PK_%s PRIMARY KEY (', $table->getName()); - if (is_string($options['primary_key'])) { // handle primary_key => 'id' - $pkSql .= $this->quoteColumnName($options['primary_key']); - } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') - // PHP 5.4 will allow access of $this, so we can call quoteColumnName() directly in the anonymous function, - // but for now just hard-code the adapter quotes - $pkSql .= implode( - ',', - array_map( - function ($v) { - return '[' . $v . ']'; - }, - $options['primary_key'] - ) - ); - } - $pkSql .= ')'; - $sqlBuffer[] = $pkSql; - } - - // set the foreign keys - $foreignKeys = $table->getForeignKeys(); - if (!empty($foreignKeys)) { - foreach ($foreignKeys as $foreignKey) { - $sqlBuffer[] = $this->getForeignKeySqlDefinition($foreignKey, $table->getName()); - } - } - - $sql .= implode(', ', $sqlBuffer); - $sql .= ');'; - - // process column comments - if (!empty($columnsWithComments)) { - foreach ($columnsWithComments as $column) { - $sql .= $this->getColumnCommentSqlDefinition($column, $table->getName()); - } - } - - // set the indexes - $indexes = $table->getIndexes(); - if (!empty($indexes)) { - foreach ($indexes as $index) { - $sql .= $this->getIndexSqlDefinition($index, $table->getName()); - } - } - - // execute the sql - $this->writeCommand('createTable', array($table->getName())); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * Gets the SqlServer Column Comment Defininition for a column object. - * - * @param Column $column Column - * @param string $tableName Table name - * - * @return string - */ - protected function getColumnCommentSqlDefinition(Column $column, $tableName) - { - // passing 'null' is to remove column comment - $currentComment = $this->getColumnComment($tableName, $column->getName()); - - $comment = (strcasecmp($column->getComment(), 'NULL') !== 0) ? $this->getConnection()->quote($column->getComment()) : '\'\''; - $command = $currentComment === false ? 'sp_addextendedproperty' : 'sp_updateextendedproperty'; - return sprintf( - "EXECUTE %s N'MS_Description', N%s, N'SCHEMA', N'%s', N'TABLE', N'%s', N'COLUMN', N'%s';", - $command, - $comment, - $this->schema, - $tableName, - $column->getName() - ); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $this->startCommandTimer(); - $this->writeCommand('renameTable', array($tableName, $newTableName)); - $this->execute(sprintf('EXEC sp_rename \'%s\', \'%s\'', $tableName, $newTableName)); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $this->startCommandTimer(); - $this->writeCommand('dropTable', array($tableName)); - $this->execute(sprintf('DROP TABLE %s', $this->quoteTableName($tableName))); - $this->endCommandTimer(); - } - - public function getColumnComment($tableName, $columnName) - { - $sql = sprintf("SELECT cast(extended_properties.[value] as nvarchar(4000)) comment - FROM sys.schemas - INNER JOIN sys.tables - ON schemas.schema_id = tables.schema_id - INNER JOIN sys.columns - ON tables.object_id = columns.object_id - INNER JOIN sys.extended_properties - ON tables.object_id = extended_properties.major_id - AND columns.column_id = extended_properties.minor_id - AND extended_properties.name = 'MS_Description' - WHERE schemas.[name] = '%s' AND tables.[name] = '%s' AND columns.[name] = '%s'", $this->schema, $tableName, $columnName); - $row = $this->fetchRow($sql); - - if ($row) { - return $row['comment']; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - $columns = array(); - $sql = sprintf( - "SELECT DISTINCT TABLE_SCHEMA AS [schema], TABLE_NAME as [table_name], COLUMN_NAME AS [name], DATA_TYPE AS [type], - IS_NULLABLE AS [null], COLUMN_DEFAULT AS [default], - CHARACTER_MAXIMUM_LENGTH AS [char_length], - NUMERIC_PRECISION AS [precision], - NUMERIC_SCALE AS [scale], ORDINAL_POSITION AS [ordinal_position], - COLUMNPROPERTY(object_id(TABLE_NAME), COLUMN_NAME, 'IsIdentity') as [identity] - FROM INFORMATION_SCHEMA.COLUMNS - WHERE TABLE_NAME = '%s' - ORDER BY ordinal_position", - $tableName - ); - $rows = $this->fetchAll($sql); - foreach ($rows as $columnInfo) { - $column = new Column(); - $column->setName($columnInfo['name']) - ->setType($this->getPhinxType($columnInfo['type'])) - ->setNull($columnInfo['null'] !== 'NO') - ->setDefault($this->parseDefault($columnInfo['default'])) - ->setIdentity($columnInfo['identity'] === '1') - ->setComment($this->getColumnComment($columnInfo['table_name'], $columnInfo['name'])); - - if (!empty($columnInfo['char_length'])) { - $column->setLimit($columnInfo['char_length']); - } - - $columns[$columnInfo['name']] = $column; - } - - return $columns; - } - - protected function parseDefault($default) - { - $default = preg_replace(array("/\('(.*)'\)/", "/\(\((.*)\)\)/", "/\((.*)\)/"), '$1', $default); - - if (strtoupper($default) === 'NULL') { - $default = null; - } elseif (is_numeric($default)) { - $default = (int) $default; - } - - return $default; - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName, $options = array()) - { - $sql = sprintf( - "SELECT count(*) as [count] - FROM information_schema.columns - WHERE table_name = '%s' AND column_name = '%s'", - $tableName, - $columnName - ); - $result = $this->fetchRow($sql); - - return $result['count'] > 0; - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $this->startCommandTimer(); - $sql = sprintf( - 'ALTER TABLE %s ADD %s %s', - $this->quoteTableName($table->getName()), - $this->quoteColumnName($column->getName()), - $this->getColumnSqlDefinition($column) - ); - - $this->writeCommand('addColumn', array($table->getName(), $column->getName(), $column->getType())); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $this->startCommandTimer(); - - if (!$this->hasColumn($tableName, $columnName)) { - throw new \InvalidArgumentException("The specified column does not exist: $columnName"); - } - $this->writeCommand('renameColumn', array($tableName, $columnName, $newColumnName)); - $this->renameDefault($tableName, $columnName, $newColumnName); - $this->execute( - sprintf( - "EXECUTE sp_rename N'%s.%s', N'%s', 'COLUMN' ", - $tableName, - $columnName, - $newColumnName - ) - ); - $this->endCommandTimer(); - } - - protected function renameDefault($tableName, $columnName, $newColumnName) - { - $oldConstraintName = "DF_{$tableName}_{$columnName}"; - $newConstraintName = "DF_{$tableName}_{$newColumnName}"; - $sql = <<execute(sprintf( - $sql, - $oldConstraintName, - $newConstraintName - )); - } - - public function changeDefault($tableName, Column $newColumn) - { - $constraintName = "DF_{$tableName}_{$newColumn->getName()}"; - $default = $newColumn->getDefault(); - - if ($default === null) { - $default = 'DEFAULT NULL'; - } else { - $default = $this->getDefaultValueDefinition($default); - } - - if (empty($default)) { - return; - } - - $this->execute(sprintf( - 'ALTER TABLE %s ADD CONSTRAINT %s %s FOR %s', - $this->quoteTableName($tableName), - $constraintName, - $default, - $this->quoteColumnName($newColumn->getName()) - )); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - $this->startCommandTimer(); - $this->writeCommand('changeColumn', array($tableName, $columnName, $newColumn->getType())); - $columns = $this->getColumns($tableName); - $changeDefault = $newColumn->getDefault() !== $columns[$columnName]->getDefault() || $newColumn->getType() !== $columns[$columnName]->getType(); - if ($columnName !== $newColumn->getName()) { - $this->renameColumn($tableName, $columnName, $newColumn->getName()); - } - - if ($changeDefault) { - $this->dropDefaultConstraint($tableName, $newColumn->getName()); - } - - $this->execute( - sprintf( - 'ALTER TABLE %s ALTER COLUMN %s %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($newColumn->getName()), - $this->getColumnSqlDefinition($newColumn, false) - ) - ); - // change column comment if needed - if ($newColumn->getComment()) { - $sql = $this->getColumnCommentSqlDefinition($newColumn, $tableName); - $this->execute($sql); - } - - if ($changeDefault) { - $this->changeDefault($tableName, $newColumn); - } - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - $this->startCommandTimer(); - $this->writeCommand('dropColumn', array($tableName, $columnName)); - $this->dropDefaultConstraint($tableName, $columnName); - - $this->execute( - sprintf( - 'ALTER TABLE %s DROP COLUMN %s', - $this->quoteTableName($tableName), - $this->quoteColumnName($columnName) - ) - ); - $this->endCommandTimer(); - } - - protected function dropDefaultConstraint($tableName, $columnName) - { - $defaultConstraint = $this->getDefaultConstraint($tableName, $columnName); - - if (!$defaultConstraint) { - return; - } - - $this->dropForeignKey($tableName, $columnName, $defaultConstraint); - } - - protected function getDefaultConstraint($tableName, $columnName) - { - $sql = "SELECT - default_constraints.name -FROM - sys.all_columns - - INNER JOIN - sys.tables - ON all_columns.object_id = tables.object_id - - INNER JOIN - sys.schemas - ON tables.schema_id = schemas.schema_id - - INNER JOIN - sys.default_constraints - ON all_columns.default_object_id = default_constraints.object_id - -WHERE - schemas.name = 'dbo' - AND tables.name = '{$tableName}' - AND all_columns.name = '{$columnName}'"; - - $rows = $this->fetchAll($sql); - return empty($rows) ? false : $rows[0]['name']; - } - - protected function getIndexColums($tableId, $indexId) - { - $sql = "SELECT AC.[name] AS [column_name] -FROM sys.[index_columns] IC - INNER JOIN sys.[all_columns] AC ON IC.[column_id] = AC.[column_id] -WHERE AC.[object_id] = {$tableId} AND IC.[index_id] = {$indexId} AND IC.[object_id] = {$tableId} -ORDER BY IC.[key_ordinal];"; - - $rows = $this->fetchAll($sql); - $columns = array(); - foreach($rows as $row) { - $columns[] = strtolower($row['column_name']); - } - return $columns; - } - - /** - * Get an array of indexes from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - public function getIndexes($tableName) - { - $indexes = array(); - $sql = "SELECT I.[name] AS [index_name], I.[index_id] as [index_id], T.[object_id] as [table_id] -FROM sys.[tables] AS T - INNER JOIN sys.[indexes] I ON T.[object_id] = I.[object_id] -WHERE T.[is_ms_shipped] = 0 AND I.[type_desc] <> 'HEAP' AND T.[name] = '{$tableName}' -ORDER BY T.[name], I.[index_id];"; - - $rows = $this->fetchAll($sql); - foreach ($rows as $row) { - $columns = $this->getIndexColums($row['table_id'], $row['index_id']); - $indexes[$row['index_name']] = array('columns' => $columns); - } - - return $indexes; - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $columns = array_map('strtolower', $columns); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $index) { - $a = array_diff($columns, $index['columns']); - - if (empty($a)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $name => $index) { - if ($name === $indexName) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $this->startCommandTimer(); - $this->writeCommand('addIndex', array($table->getName(), $index->getColumns())); - $sql = $this->getIndexSqlDefinition($index, $table->getName()); - $this->execute($sql); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropIndex', array($tableName, $columns)); - $indexes = $this->getIndexes($tableName); - $columns = array_map('strtolower', $columns); - - foreach ($indexes as $indexName => $index) { - $a = array_diff($columns, $index['columns']); - if (empty($a)) { - $this->execute( - sprintf( - 'DROP INDEX %s ON %s', - $this->quoteColumnName($indexName), - $this->quoteTableName($tableName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $this->startCommandTimer(); - - $this->writeCommand('dropIndexByName', array($tableName, $indexName)); - $indexes = $this->getIndexes($tableName); - - foreach ($indexes as $name => $index) { - if ($name === $indexName) { - $this->execute( - sprintf( - 'DROP INDEX %s ON %s', - $this->quoteColumnName($indexName), - $this->quoteTableName($tableName) - ) - ); - $this->endCommandTimer(); - return; - } - } - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $foreignKeys = $this->getForeignKeys($tableName); - if ($constraint) { - if (isset($foreignKeys[$constraint])) { - return !empty($foreignKeys[$constraint]); - } - return false; - } else { - foreach ($foreignKeys as $key) { - $a = array_diff($columns, $key['columns']); - if (empty($a)) { - return true; - } - } - return false; - } - } - - /** - * Get an array of foreign keys from a particular table. - * - * @param string $tableName Table Name - * @return array - */ - protected function getForeignKeys($tableName) - { - $foreignKeys = array(); - $rows = $this->fetchAll(sprintf( - "SELECT - tc.constraint_name, - tc.table_name, kcu.column_name, - ccu.table_name AS referenced_table_name, - ccu.column_name AS referenced_column_name - FROM - information_schema.table_constraints AS tc - JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name - JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name - WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' - ORDER BY kcu.ordinal_position", - $tableName - )); - foreach ($rows as $row) { - $foreignKeys[$row['constraint_name']]['table'] = $row['table_name']; - $foreignKeys[$row['constraint_name']]['columns'][] = $row['column_name']; - $foreignKeys[$row['constraint_name']]['referenced_table'] = $row['referenced_table_name']; - $foreignKeys[$row['constraint_name']]['referenced_columns'][] = $row['referenced_column_name']; - } - - return $foreignKeys; - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - $this->startCommandTimer(); - $this->writeCommand('addForeignKey', array($table->getName(), $foreignKey->getColumns())); - $this->execute( - sprintf( - 'ALTER TABLE %s ADD %s', - $this->quoteTableName($table->getName()), - $this->getForeignKeySqlDefinition($foreignKey, $table->getName()) - ) - ); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - $this->startCommandTimer(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - - $this->writeCommand('dropForeignKey', array($tableName, $columns)); - - if ($constraint) { - $this->execute( - sprintf( - 'ALTER TABLE %s DROP CONSTRAINT %s', - $this->quoteTableName($tableName), - $constraint - ) - ); - $this->endCommandTimer(); - return; - } else { - foreach ($columns as $column) { - $rows = $this->fetchAll(sprintf( - "SELECT - tc.constraint_name, - tc.table_name, kcu.column_name, - ccu.table_name AS referenced_table_name, - ccu.column_name AS referenced_column_name - FROM - information_schema.table_constraints AS tc - JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name - JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name - WHERE constraint_type = 'FOREIGN KEY' AND tc.table_name = '%s' and ccu.column_name='%s' - ORDER BY kcu.ordinal_position", - $tableName, - $column - )); - foreach ($rows as $row) { - $this->dropForeignKey($tableName, $columns, $row['constraint_name']); - } - } - } - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function getSqlType($type, $limit = null) - { - switch ($type) { - case static::PHINX_TYPE_STRING: - return array('name' => 'nvarchar', 'limit' => 255); - break; - case static::PHINX_TYPE_CHAR: - return array('name' => 'nchar', 'limit' => 255); - break; - case static::PHINX_TYPE_TEXT: - return array('name' => 'ntext'); - break; - case static::PHINX_TYPE_INTEGER: - return array('name' => 'int'); - break; - case static::PHINX_TYPE_BIG_INTEGER: - return array('name' => 'bigint'); - break; - case static::PHINX_TYPE_FLOAT: - return array('name' => 'float'); - break; - case static::PHINX_TYPE_DECIMAL: - return array('name' => 'decimal'); - break; - case static::PHINX_TYPE_DATETIME: - case static::PHINX_TYPE_TIMESTAMP: - return array('name' => 'datetime'); - break; - case static::PHINX_TYPE_TIME: - return array('name' => 'time'); - break; - case static::PHINX_TYPE_DATE: - return array('name' => 'date'); - break; - case static::PHINX_TYPE_BLOB: - case static::PHINX_TYPE_BINARY: - return array('name' => 'varbinary'); - break; - case static::PHINX_TYPE_BOOLEAN: - return array('name' => 'bit'); - break; - case static::PHINX_TYPE_UUID: - return array('name' => 'uniqueidentifier'); - case static::PHINX_TYPE_FILESTREAM: - return array('name' => 'varbinary', 'limit' => 'max'); - // Geospatial database types - case static::PHINX_TYPE_GEOMETRY: - case static::PHINX_TYPE_POINT: - case static::PHINX_TYPE_LINESTRING: - case static::PHINX_TYPE_POLYGON: - // SQL Server stores all spatial data using a single data type. - // Specific types (point, polygon, etc) are set at insert time. - return array('name' => 'geography'); - break; - default: - throw new \RuntimeException('The type: "' . $type . '" is not supported.'); - } - } - - /** - * Returns Phinx type by SQL type - * - * @param $sqlTypeDef - * @throws \RuntimeException - * @internal param string $sqlType SQL type - * @returns string Phinx type - */ - public function getPhinxType($sqlType) - { - switch ($sqlType) { - case 'nvarchar': - case 'varchar': - return static::PHINX_TYPE_STRING; - case 'char': - case 'nchar': - return static::PHINX_TYPE_CHAR; - case 'text': - case 'ntext': - return static::PHINX_TYPE_TEXT; - case 'int': - case 'integer': - return static::PHINX_TYPE_INTEGER; - case 'decimal': - case 'numeric': - case 'money': - return static::PHINX_TYPE_DECIMAL; - case 'bigint': - return static::PHINX_TYPE_BIG_INTEGER; - case 'real': - case 'float': - return static::PHINX_TYPE_FLOAT; - case 'binary': - case 'image': - case 'varbinary': - return static::PHINX_TYPE_BINARY; - break; - case 'time': - return static::PHINX_TYPE_TIME; - case 'date': - return static::PHINX_TYPE_DATE; - case 'datetime': - case 'timestamp': - return static::PHINX_TYPE_DATETIME; - case 'bit': - return static::PHINX_TYPE_BOOLEAN; - case 'uniqueidentifier': - return static::PHINX_TYPE_UUID; - case 'filestream': - return static::PHINX_TYPE_FILESTREAM; - default: - throw new \RuntimeException('The SqlServer type: "' . $sqlType . '" is not supported'); - } - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options = array()) - { - $this->startCommandTimer(); - $this->writeCommand('createDatabase', array($name)); - - if (isset($options['collation'])) { - $this->execute(sprintf('CREATE DATABASE [%s] COLLATE [%s]', $name, $options['collation'])); - } else { - $this->execute(sprintf('CREATE DATABASE [%s]', $name)); - } - $this->execute(sprintf('USE [%s]', $name)); - $this->endCommandTimer(); - } - - /** - * {@inheritdoc} - */ - public function hasDatabase($name) - { - $result = $this->fetchRow( - sprintf( - 'SELECT count(*) as [count] FROM master.dbo.sysdatabases WHERE [name] = \'%s\'', - $name - ) - ); - - return $result['count'] > 0; - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - $this->startCommandTimer(); - $this->writeCommand('dropDatabase', array($name)); - $sql = <<execute($sql); - $this->endCommandTimer(); - } - - /** - * Get the defintion for a `DEFAULT` statement. - * - * @param mixed $default - * @return string - */ - protected function getDefaultValueDefinition($default) - { - if (is_string($default) && 'CURRENT_TIMESTAMP' !== $default) { - $default = $this->getConnection()->quote($default); - } elseif (is_bool($default)) { - $default = $this->castToBool($default); - } - return isset($default) ? ' DEFAULT ' . $default : ''; - } - - /** - * Gets the SqlServer Column Definition for a Column object. - * - * @param Column $column Column - * @return string - */ - protected function getColumnSqlDefinition(Column $column, $create = true) - { - $buffer = array(); - - $sqlType = $this->getSqlType($column->getType()); - $buffer[] = strtoupper($sqlType['name']); - // integers cant have limits in SQlServer - $noLimits = array( - 'bigint', - 'int', - 'tinyint' - ); - if (!in_array($sqlType['name'], $noLimits) && ($column->getLimit() || isset($sqlType['limit']))) { - $buffer[] = sprintf('(%s)', $column->getLimit() ? $column->getLimit() : $sqlType['limit']); - } - if ($column->getPrecision() && $column->getScale()) { - $buffer[] = '(' . $column->getPrecision() . ',' . $column->getScale() . ')'; - } - - $properties = $column->getProperties(); - $buffer[] = $column->getType() === 'filestream' ? 'FILESTREAM' : ''; - $buffer[] = isset($properties['rowguidcol']) ? 'ROWGUIDCOL' : ''; - - $buffer[] = $column->isNull() ? 'NULL' : 'NOT NULL'; - - if ($create === true) { - if ($column->getDefault() === null && $column->isNull()) { - $buffer[] = ' DEFAULT NULL'; - } else { - $buffer[] = $this->getDefaultValueDefinition($column->getDefault()); - } - } - - if ($column->isIdentity()) { - $buffer[] = 'IDENTITY(1, 1)'; - } - - return implode(' ', $buffer); - } - - /** - * Gets the SqlServer Index Definition for an Index object. - * - * @param Index $index Index - * @return string - */ - protected function getIndexSqlDefinition(Index $index, $tableName) - { - if (is_string($index->getName())) { - $indexName = $index->getName(); - } else { - $columnNames = $index->getColumns(); - if (is_string($columnNames)) { - $columnNames = array($columnNames); - } - $indexName = sprintf('%s_%s', $tableName, implode('_', $columnNames)); - } - $def = sprintf( - "CREATE %s INDEX %s ON %s (%s);", - ($index->getType() === Index::UNIQUE ? 'UNIQUE' : ''), - $indexName, - $this->quoteTableName($tableName), - '[' . implode('],[', $index->getColumns()) . ']' - ); - - return $def; - } - - /** - * Gets the SqlServer Foreign Key Definition for an ForeignKey object. - * - * @param ForeignKey $foreignKey - * @return string - */ - protected function getForeignKeySqlDefinition(ForeignKey $foreignKey, $tableName) - { - $def = ' CONSTRAINT "'; - $def .= $tableName . '_' . implode('_', $foreignKey->getColumns()); - $def .= '" FOREIGN KEY ("' . implode('", "', $foreignKey->getColumns()) . '")'; - $def .= " REFERENCES {$this->quoteTableName($foreignKey->getReferencedTable()->getName())} (\"" . implode('", "', $foreignKey->getReferencedColumns()) . '")'; - if ($foreignKey->getOnDelete()) { - $def .= " ON DELETE {$foreignKey->getOnDelete()}"; - } - if ($foreignKey->getOnUpdate()) { - $def .= " ON UPDATE {$foreignKey->getOnUpdate()}"; - } - - return $def; - } - - /** - * {@inheritdoc} - */ - public function getColumnTypes() - { - return array_merge(parent::getColumnTypes(), array('filestream')); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/TablePrefixAdapter.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/TablePrefixAdapter.php deleted file mode 100644 index 66a850c..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/TablePrefixAdapter.php +++ /dev/null @@ -1,272 +0,0 @@ - - */ -class TablePrefixAdapter extends AdapterWrapper -{ - /** - * {@inheritdoc} - */ - public function getAdapterType() - { - return 'TablePrefixAdapter'; - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::hasTable($adapterTableName); - } - - /** - * {@inheritdoc} - */ - public function createTable(Table $table) - { - $adapterTable = clone $table; - $adapterTableName = $this->getAdapterTableName($table->getName()); - $adapterTable->setName($adapterTableName); - - foreach ($adapterTable->getForeignKeys() as $fk) { - $adapterReferenceTable = $fk->getReferencedTable(); - $adapterReferenceTableName = $this->getAdapterTableName($adapterReferenceTable->getName()); - $adapterReferenceTable->setName($adapterReferenceTableName); - } - - return parent::createTable($adapterTable); - } - - /** - * {@inheritdoc} - */ - public function renameTable($tableName, $newTableName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - $adapterNewTableName = $this->getAdapterTableName($newTableName); - return parent::renameTable($adapterTableName, $adapterNewTableName); - } - - /** - * {@inheritdoc} - */ - public function dropTable($tableName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::dropTable($adapterTableName); - } - - /** - * {@inheritdoc} - */ - public function getColumns($tableName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::getColumns($adapterTableName); - } - - /** - * {@inheritdoc} - */ - public function hasColumn($tableName, $columnName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::hasColumn($adapterTableName, $columnName); - } - - /** - * {@inheritdoc} - */ - public function addColumn(Table $table, Column $column) - { - $adapterTable = clone $table; - $adapterTableName = $this->getAdapterTableName($table->getName()); - $adapterTable->setName($adapterTableName); - return parent::addColumn($adapterTable, $column); - } - - /** - * {@inheritdoc} - */ - public function renameColumn($tableName, $columnName, $newColumnName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::renameColumn($adapterTableName, $columnName, $newColumnName); - } - - /** - * {@inheritdoc} - */ - public function changeColumn($tableName, $columnName, Column $newColumn) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::changeColumn($adapterTableName, $columnName, $newColumn); - } - - /** - * {@inheritdoc} - */ - public function dropColumn($tableName, $columnName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::dropColumn($adapterTableName, $columnName); - } - - /** - * {@inheritdoc} - */ - public function hasIndex($tableName, $columns) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::hasIndex($adapterTableName, $columns); - } - - /** - * {@inheritdoc} - */ - public function hasIndexByName($tableName, $indexName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::hasIndexByName($adapterTableName, $indexName); - } - - /** - * {@inheritdoc} - */ - public function addIndex(Table $table, Index $index) - { - $adapterTable = clone $table; - $adapterTableName = $this->getAdapterTableName($table->getName()); - $adapterTable->setName($adapterTableName); - return parent::addIndex($adapterTable, $index); - } - - /** - * {@inheritdoc} - */ - public function dropIndex($tableName, $columns, $options = array()) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::dropIndex($adapterTableName, $columns, $options); - } - - /** - * {@inheritdoc} - */ - public function dropIndexByName($tableName, $indexName) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::dropIndexByName($adapterTableName, $indexName); - } - - /** - * {@inheritdoc} - */ - public function hasForeignKey($tableName, $columns, $constraint = null) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::hasForeignKey($adapterTableName, $columns, $constraint); - } - - /** - * {@inheritdoc} - */ - public function addForeignKey(Table $table, ForeignKey $foreignKey) - { - $adapterTable = clone $table; - $adapterTableName = $this->getAdapterTableName($table->getName()); - $adapterTable->setName($adapterTableName); - return parent::addForeignKey($adapterTable, $foreignKey); - } - - /** - * {@inheritdoc} - */ - public function dropForeignKey($tableName, $columns, $constraint = null) - { - $adapterTableName = $this->getAdapterTableName($tableName); - return parent::dropForeignKey($adapterTableName, $columns, $constraint); - } - - /** - * {@inheritdoc} - */ - public function insert(Table $table, $row) - { - $adapterTable = clone $table; - $adapterTableName = $this->getAdapterTableName($table->getName()); - $adapterTable->setName($adapterTableName); - return parent::insert($adapterTable, $row); - } - - /** - * Gets the table prefix. - * - * @return string - */ - public function getPrefix() - { - return (string) $this->getOption('table_prefix'); - } - - /** - * Gets the table suffix. - * - * @return string - */ - public function getSuffix() - { - return (string) $this->getOption('table_suffix'); - } - - /** - * Applies the prefix and suffix to the table name. - * - * @param string $tableName - * @return string - */ - public function getAdapterTableName($tableName) - { - return $this->getPrefix() . $tableName . $this->getSuffix(); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/WrapperInterface.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/WrapperInterface.php deleted file mode 100644 index b8181d4..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Adapter/WrapperInterface.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -interface WrapperInterface -{ - /** - * Class constructor, must always wrap another adapter. - * - * @param AdapterInterface $adapter - */ - public function __construct(AdapterInterface $adapter); - - /** - * Sets the database adapter to proxy commands to. - * - * @param AdapterInterface $adapter - * @return AdapterInterface - */ - public function setAdapter(AdapterInterface $adapter); - - /** - * Gets the database adapter. - * - * @throws \RuntimeException if the adapter has not been set - * @return AdapterInterface - */ - public function getAdapter(); -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table.php deleted file mode 100644 index b0e7202..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table.php +++ /dev/null @@ -1,674 +0,0 @@ -setName($name); - $this->setOptions($options); - - if (null !== $adapter) { - $this->setAdapter($adapter); - } - } - - /** - * Sets the table name. - * - * @param string $name Table Name - * @return Table - */ - public function setName($name) - { - $this->name = $name; - return $this; - } - - /** - * Gets the table name. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the table options. - * - * @param array $options - * @return Table - */ - public function setOptions($options) - { - $this->options = $options; - return $this; - } - - /** - * Gets the table options. - * - * @return array - */ - public function getOptions() - { - return $this->options; - } - - /** - * Sets the database adapter. - * - * @param AdapterInterface $adapter Database Adapter - * @return Table - */ - public function setAdapter(AdapterInterface $adapter) - { - $this->adapter = $adapter; - return $this; - } - - /** - * Gets the database adapter. - * - * @return AdapterInterface - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * Does the table exist? - * - * @return boolean - */ - public function exists() - { - return $this->getAdapter()->hasTable($this->getName()); - } - - /** - * Drops the database table. - * - * @return void - */ - public function drop() - { - $this->getAdapter()->dropTable($this->getName()); - } - - /** - * Renames the database table. - * - * @param string $newTableName New Table Name - * @return Table - */ - public function rename($newTableName) - { - $this->getAdapter()->renameTable($this->getName(), $newTableName); - $this->setName($newTableName); - return $this; - } - - /** - * Sets an array of columns waiting to be committed. - * Use setPendingColumns - * - * @deprecated - * @param array $columns Columns - * @return Table - */ - public function setColumns($columns) - { - $this->setPendingColumns($columns); - } - - /** - * Gets an array of the table columns. - * - * @return Column[] - */ - public function getColumns() - { - return $this->getAdapter()->getColumns($this->getName()); - } - - /** - * Sets an array of columns waiting to be committed. - * - * @param array $columns Columns - * @return Table - */ - public function setPendingColumns($columns) - { - $this->columns = $columns; - return $this; - } - - /** - * Gets an array of columns waiting to be committed. - * - * @return Column[] - */ - public function getPendingColumns() - { - return $this->columns; - } - - /** - * Sets an array of columns waiting to be indexed. - * - * @param array $indexes Indexes - * @return Table - */ - public function setIndexes($indexes) - { - $this->indexes = $indexes; - return $this; - } - - /** - * Gets an array of indexes waiting to be committed. - * - * @return array - */ - public function getIndexes() - { - return $this->indexes; - } - - /** - * Sets an array of foreign keys waiting to be commited. - * - * @param ForeignKey[] $foreignKeys foreign keys - * @return Table - */ - public function setForeignKeys($foreignKeys) - { - $this->foreignKeys = $foreignKeys; - return $this; - } - - /** - * Gets an array of foreign keys waiting to be commited. - * - * @return array|ForeignKey[] - */ - public function getForeignKeys() - { - return $this->foreignKeys; - } - - /** - * Sets an array of data to be inserted. - * - * @param array $data Data - * @return Table - */ - public function setData($data) - { - $this->data = $data; - return $this; - } - - /** - * Gets the data waiting to be inserted. - * - * @return array - */ - public function getData() - { - return $this->data; - } - - /** - * Resets all of the pending table changes. - * - * @return void - */ - public function reset() - { - $this->setPendingColumns(array()); - $this->setIndexes(array()); - $this->setForeignKeys(array()); - $this->setData(array()); - } - - /** - * Add a table column. - * - * Type can be: string, text, integer, float, decimal, datetime, timestamp, - * time, date, binary, boolean. - * - * Valid options can be: limit, default, null, precision or scale. - * - * @param string|Column $columnName Column Name - * @param string $type Column Type - * @param array $options Column Options - * @throws \RuntimeException - * @throws \InvalidArgumentException - * @return Table - */ - public function addColumn($columnName, $type = null, $options = array()) - { - // we need an adapter set to add a column - if (null === $this->getAdapter()) { - throw new \RuntimeException('An adapter must be specified to add a column.'); - } - - // create a new column object if only strings were supplied - if (!$columnName instanceof Column) { - $column = new Column(); - $column->setName($columnName); - $column->setType($type); - $column->setOptions($options); // map options to column methods - } else { - $column = $columnName; - } - - // Delegate to Adapters to check column type - if (!$this->getAdapter()->isValidColumnType($column)) { - throw new \InvalidArgumentException(sprintf( - 'An invalid column type "%s" was specified for column "%s".', - $column->getType(), - $column->getName() - )); - } - - $this->columns[] = $column; - return $this; - } - - /** - * Remove a table column. - * - * @param string $columnName Column Name - * @return Table - */ - public function removeColumn($columnName) - { - $this->getAdapter()->dropColumn($this->getName(), $columnName); - return $this; - } - - /** - * Rename a table column. - * - * @param string $oldName Old Column Name - * @param string $newName New Column Name - * @return Table - */ - public function renameColumn($oldName, $newName) - { - $this->getAdapter()->renameColumn($this->getName(), $oldName, $newName); - return $this; - } - - /** - * Change a table column type. - * - * @param string $columnName Column Name - * @param string|Column $newColumnType New Column Type - * @param array $options Options - * @return Table - */ - public function changeColumn($columnName, $newColumnType, $options = array()) - { - // create a column object if one wasn't supplied - if (!$newColumnType instanceof Column) { - $newColumn = new Column(); - $newColumn->setType($newColumnType); - $newColumn->setOptions($options); - } else { - $newColumn = $newColumnType; - } - - // if the name was omitted use the existing column name - if (null === $newColumn->getName() || strlen($newColumn->getName()) === 0) { - $newColumn->setName($columnName); - } - - $this->getAdapter()->changeColumn($this->getName(), $columnName, $newColumn); - return $this; - } - - /** - * Checks to see if a column exists. - * - * @param string $columnName Column Name - * @param array $options Options - * @return boolean - */ - public function hasColumn($columnName, $options = array()) - { - return $this->getAdapter()->hasColumn($this->getName(), $columnName, $options); - } - - /** - * Add an index to a database table. - * - * In $options you can specific unique = true/false or name (index name). - * - * @param string|array|Index $columns Table Column(s) - * @param array $options Index Options - * @return Table - */ - public function addIndex($columns, $options = array()) - { - // create a new index object if strings or an array of strings were supplied - if (!$columns instanceof Index) { - $index = new Index(); - if (is_string($columns)) { - $columns = array($columns); // str to array - } - $index->setColumns($columns); - $index->setOptions($options); - } else { - $index = $columns; - } - - $this->indexes[] = $index; - return $this; - } - - /** - * Removes the given index from a table. - * - * @param array $columns Columns - * @param array $options Options - * @return Table - */ - public function removeIndex($columns, $options = array()) - { - $this->getAdapter()->dropIndex($this->getName(), $columns, $options); - return $this; - } - - /** - * Removes the given index identified by its name from a table. - * - * @param string $name Index name - * @return Table - */ - public function removeIndexByName($name) - { - $this->getAdapter()->dropIndexByName($this->getName(), $name); - return $this; - } - - /** - * Checks to see if an index exists. - * - * @param string|array $columns Columns - * @param array $options Options - * @return boolean - */ - public function hasIndex($columns, $options = array()) - { - return $this->getAdapter()->hasIndex($this->getName(), $columns, $options); - } - - /** - * Add a foreign key to a database table. - * - * In $options you can specify on_delete|on_delete = cascade|no_action .., - * on_update, constraint = constraint name. - * - * @param string|array $columns Columns - * @param string|Table $referencedTable Referenced Table - * @param string|array $referencedColumns Referenced Columns - * @param array $options Options - * @return Table - */ - public function addForeignKey($columns, $referencedTable, $referencedColumns = array('id'), $options = array()) - { - if (is_string($referencedColumns)) { - $referencedColumns = array($referencedColumns); // str to array - } - $fk = new ForeignKey(); - if ($referencedTable instanceof Table) { - $fk->setReferencedTable($referencedTable); - } else { - $fk->setReferencedTable(new Table($referencedTable, array(), $this->adapter)); - } - $fk->setColumns($columns) - ->setReferencedColumns($referencedColumns) - ->setOptions($options); - $this->foreignKeys[] = $fk; - - return $this; - } - - /** - * Removes the given foreign key from the table. - * - * @param string|array $columns Column(s) - * @param null|string $constraint Constraint names - * @return Table - */ - public function dropForeignKey($columns, $constraint = null) - { - if (is_string($columns)) { - $columns = array($columns); - } - if ($constraint) { - $this->getAdapter()->dropForeignKey($this->getName(), array(), $constraint); - } else { - $this->getAdapter()->dropForeignKey($this->getName(), $columns); - } - - return $this; - } - - /** - * Checks to see if a foreign key exists. - * - * @param string|array $columns Column(s) - * @param null|string $constraint Constraint names - * @return boolean - */ - public function hasForeignKey($columns, $constraint = null) - { - return $this->getAdapter()->hasForeignKey($this->getName(), $columns, $constraint); - } - - /** - * Add timestamp columns created_at and updated_at to the table. - * - * @param string $createdAtColumnName - * @param string $updatedAtColumnName - * - * @return Table - */ - public function addTimestamps($createdAtColumnName = 'created_at', $updatedAtColumnName = 'updated_at') - { - $createdAtColumnName = is_null($createdAtColumnName) ? 'created_at' : $createdAtColumnName; - $updatedAtColumnName = is_null($updatedAtColumnName) ? 'updated_at' : $updatedAtColumnName; - $this->addColumn($createdAtColumnName, 'timestamp', array( - 'default' => 'CURRENT_TIMESTAMP', - 'update' => '' - )) - ->addColumn($updatedAtColumnName, 'timestamp', array( - 'null' => true, - 'default' => null - )); - - return $this; - } - - /** - * Insert data into the table. - * - * @param $data array of data in the form: - * array( - * array("col1" => "value1", "col2" => "anotherValue1"), - * array("col2" => "value2", "col2" => "anotherValue2"), - * ) - * or array("col1" => "value1", "col2" => "anotherValue1") - * - * @return Table - */ - public function insert($data) - { - // handle array of array situations - if (isset($data[0]) && is_array($data[0])) { - foreach ($data as $row) { - $this->data[] = $row; - } - return $this; - } - $this->data[] = $data; - return $this; - } - - /** - * Creates a table from the object instance. - * - * @return void - */ - public function create() - { - $this->getAdapter()->createTable($this); - $this->saveData(); - $this->reset(); // reset pending changes - } - - /** - * Updates a table from the object instance. - * - * @throws \RuntimeException - * @return void - */ - public function update() - { - if (!$this->exists()) { - throw new \RuntimeException('Cannot update a table that doesn\'t exist!'); - } - - // update table - foreach ($this->getPendingColumns() as $column) { - $this->getAdapter()->addColumn($this, $column); - } - - foreach ($this->getIndexes() as $index) { - $this->getAdapter()->addIndex($this, $index); - } - - foreach ($this->getForeignKeys() as $foreignKey) { - $this->getAdapter()->addForeignKey($this, $foreignKey); - } - - $this->saveData(); - $this->reset(); // reset pending changes - } - - /** - * Commit the pending data waiting for insertion. - * - * @return void - */ - public function saveData() - { - foreach ($this->getData() as $row) { - $this->getAdapter()->insert($this, $row); - } - } - - /** - * Commits the table changes. - * - * If the table doesn't exist it is created otherwise it is updated. - * - * @return void - */ - public function save() - { - if ($this->exists()) { - $this->update(); // update the table - } else { - $this->create(); // create the table - } - - $this->reset(); // reset pending changes - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Column.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Column.php deleted file mode 100644 index 874341e..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Column.php +++ /dev/null @@ -1,550 +0,0 @@ -name = $name; - return $this; - } - - /** - * Gets the column name. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the column type. - * - * @param string $type - * @return $this - */ - public function setType($type) - { - $this->type = $type; - return $this; - } - - /** - * Gets the column type. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Sets the column limit. - * - * @param integer $limit - * @return $this - */ - public function setLimit($limit) - { - $this->limit = $limit; - return $this; - } - - /** - * Gets the column limit. - * - * @return integer - */ - public function getLimit() - { - return $this->limit; - } - - /** - * Sets whether the column allows nulls. - * - * @param boolean $null - * @return $this - */ - public function setNull($null) - { - $this->null = (bool) $null; - return $this; - } - - /** - * Gets whether the column allows nulls. - * - * @return boolean - */ - public function getNull() - { - return $this->null; - } - - /** - * Does the column allow nulls? - * - * @return boolean - */ - public function isNull() - { - return $this->getNull(); - } - - /** - * Sets the default column value. - * - * @param mixed $default - * @return $this - */ - public function setDefault($default) - { - $this->default = $default; - return $this; - } - - /** - * Gets the default column value. - * - * @return mixed - */ - public function getDefault() - { - return $this->default; - } - - /** - * Sets whether or not the column is an identity column. - * - * @param boolean $identity - * @return $this - */ - public function setIdentity($identity) - { - $this->identity = $identity; - return $this; - } - - /** - * Gets whether or not the column is an identity column. - * - * @return boolean - */ - public function getIdentity() - { - return $this->identity; - } - - /** - * Is the column an identity column? - * - * @return boolean - */ - public function isIdentity() - { - return $this->getIdentity(); - } - - /** - * Sets the name of the column to add this column after. - * - * @param string $after After - * @return $this - */ - public function setAfter($after) - { - $this->after = $after; - return $this; - } - - /** - * Returns the name of the column to add this column after. - * - * @return string - */ - public function getAfter() - { - return $this->after; - } - - /** - * Sets the 'ON UPDATE' mysql column function. - * - * @param string $update On Update function - * @return $this - */ - public function setUpdate($update) - { - $this->update = $update; - return $this; - } - - /** - * Returns the value of the ON UPDATE column function. - * - * @return string - */ - public function getUpdate() - { - return $this->update; - } - - /** - * Sets the column precision for decimal. - * - * @param integer $precision - * @return $this - */ - public function setPrecision($precision) - { - $this->precision = $precision; - return $this; - } - - /** - * Gets the column precision for decimal. - * - * @return integer - */ - public function getPrecision() - { - return $this->precision; - } - - /** - * Sets the column scale for decimal. - * - * @param integer $scale - * @return $this - */ - public function setScale($scale) - { - $this->scale = $scale; - return $this; - } - - /** - * Gets the column scale for decimal. - * - * @return integer - */ - public function getScale() - { - return $this->scale; - } - - /** - * Sets the column comment. - * - * @param string $comment - * @return $this - */ - public function setComment($comment) - { - $this->comment = $comment; - return $this; - } - - /** - * Gets the column comment. - * - * @return string - */ - public function getComment() - { - return $this->comment; - } - - /** - * Sets whether field should be signed. - * - * @param bool $signed - * @return $this - */ - public function setSigned($signed) - { - $this->signed = (bool) $signed; - return $this; - } - - /** - * Gets whether field should be signed. - * - * @return string - */ - public function getSigned() - { - return $this->signed; - } - - /** - * Should the column be signed? - * - * @return boolean - */ - public function isSigned() - { - return $this->getSigned(); - } - - /** - * Sets whether the field should have a timezone identifier. - * Used for date/time columns only! - * - * @param bool $timezone - * @return $this - */ - public function setTimezone($timezone) - { - $this->timezone = (bool) $timezone; - return $this; - } - - /** - * Gets whether field has a timezone identifier. - * - * @return boolean - */ - public function getTimezone() - { - return $this->timezone; - } - - /** - * Should the column have a timezone? - * - * @return boolean - */ - public function isTimezone() - { - return $this->getTimezone(); - } - - /** - * Sets field properties. - * - * @param array $properties - * - * @return $this - */ - public function setProperties($properties) - { - $this->properties = $properties; - return $this; - } - - /** - * Gets field properties - * - * @return array - */ - public function getProperties() - { - return $this->properties; - } - - /** - * Sets field values. - * - * @param mixed (array|string) $values - * - * @return $this - */ - public function setValues($values) - { - if (!is_array($values)) { - $values = preg_split('/,\s*/', $values); - } - $this->values = $values; - return $this; - } - - /** - * Gets field values - * - * @return string - */ - public function getValues() - { - return $this->values; - } - - /** - * Gets all allowed options. Each option must have a corresponding `setFoo` method. - * - * @return array - */ - protected function getValidOptions() - { - return array( - 'limit', - 'default', - 'null', - 'identity', - 'precision', - 'scale', - 'after', - 'update', - 'comment', - 'signed', - 'timezone', - 'properties', - 'values', - ); - } - - /** - * Gets all aliased options. Each alias must reference a valid option. - * - * @return array - */ - protected function getAliasedOptions() - { - return array( - 'length' => 'limit', - ); - } - - /** - * Utility method that maps an array of column options to this objects methods. - * - * @param array $options Options - * @return $this - */ - public function setOptions($options) - { - $validOptions = $this->getValidOptions(); - $aliasOptions = $this->getAliasedOptions(); - - foreach ($options as $option => $value) { - if (isset($aliasOptions[$option])) { - // proxy alias -> option - $option = $aliasOptions[$option]; - } - - if (!in_array($option, $validOptions, true)) { - throw new \RuntimeException(sprintf('"%s" is not a valid column option.', $option)); - } - - $method = 'set' . ucfirst($option); - $this->$method($value); - } - return $this; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/ForeignKey.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/ForeignKey.php deleted file mode 100644 index 3033503..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/ForeignKey.php +++ /dev/null @@ -1,252 +0,0 @@ - - */ -namespace Phinx\Db\Table; - -use Phinx\Db\Table; - -class ForeignKey -{ - const CASCADE = 'CASCADE'; - const RESTRICT = 'RESTRICT'; - const SET_NULL = 'SET NULL'; - const NO_ACTION = 'NO ACTION'; - - /** - * @var array - */ - protected $columns = array(); - - /** - * @var Table - */ - protected $referencedTable; - - /** - * @var array - */ - protected $referencedColumns = array(); - - /** - * @var string - */ - protected $onDelete; - - /** - * @var string - */ - protected $onUpdate; - - /** - * @var string|boolean - */ - protected $constraint; - - /** - * Sets the foreign key columns. - * - * @param array|string $columns - * @return ForeignKey - */ - public function setColumns($columns) - { - if (is_string($columns)) { - $columns = array($columns); - } - $this->columns = $columns; - return $this; - } - - /** - * Gets the foreign key columns. - * - * @return array - */ - public function getColumns() - { - return $this->columns; - } - - /** - * Sets the foreign key referenced table. - * - * @param Table $table - * @return ForeignKey - */ - public function setReferencedTable(Table $table) - { - $this->referencedTable = $table; - return $this; - } - - /** - * Gets the foreign key referenced table. - * - * @return Table - */ - public function getReferencedTable() - { - return $this->referencedTable; - } - - /** - * Sets the foreign key referenced columns. - * - * @param array $referencedColumns - * @return ForeignKey - */ - public function setReferencedColumns(array $referencedColumns) - { - $this->referencedColumns = $referencedColumns; - return $this; - } - - /** - * Gets the foreign key referenced columns. - * - * @return array - */ - public function getReferencedColumns() - { - return $this->referencedColumns; - } - - /** - * Sets ON DELETE action for the foreign key. - * - * @param string $onDelete - * @return ForeignKey - */ - public function setOnDelete($onDelete) - { - $this->onDelete = $this->normalizeAction($onDelete); - return $this; - } - - /** - * Gets ON DELETE action for the foreign key. - * - * @return string - */ - public function getOnDelete() - { - return $this->onDelete; - } - - /** - * Gets ON UPDATE action for the foreign key. - * - * @return string - */ - public function getOnUpdate() - { - return $this->onUpdate; - } - - /** - * Sets ON UPDATE action for the foreign key. - * - * @param string $onUpdate - * @return ForeignKey - */ - public function setOnUpdate($onUpdate) - { - $this->onUpdate = $this->normalizeAction($onUpdate); - return $this; - } - - /** - * Sets constraint for the foreign key. - * - * @param string $constraint - * @return ForeignKey - */ - public function setConstraint($constraint) - { - $this->constraint = $constraint; - return $this; - } - - /** - * Gets constraint name for the foreign key. - * - * @return string - */ - public function getConstraint() - { - return $this->constraint; - } - - /** - * Utility method that maps an array of index options to this objects methods. - * - * @param array $options Options - * @throws \RuntimeException - * @throws \InvalidArgumentException - * @return ForeignKey - */ - public function setOptions($options) - { - // Valid Options - $validOptions = array('delete', 'update', 'constraint'); - foreach ($options as $option => $value) { - if (!in_array($option, $validOptions, true)) { - throw new \RuntimeException(sprintf('"%s" is not a valid foreign key option.', $option)); - } - - // handle $options['delete'] as $options['update'] - if ('delete' === $option) { - $this->setOnDelete($value); - } elseif ('update' === $option) { - $this->setOnUpdate($value); - } else { - $method = 'set' . ucfirst($option); - $this->$method($value); - } - } - - return $this; - } - - /** - * From passed value checks if it's correct and fixes if needed - * - * @param string $action - * @throws \InvalidArgumentException - * @return string - */ - protected function normalizeAction($action) - { - $constantName = 'static::' . str_replace(' ', '_', strtoupper(trim($action))); - if (!defined($constantName)) { - throw new \InvalidArgumentException('Unknown action passed: ' . $action); - } - return constant($constantName); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Index.php b/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Index.php deleted file mode 100644 index 82404cb..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Db/Table/Index.php +++ /dev/null @@ -1,185 +0,0 @@ -columns = $columns; - return $this; - } - - /** - * Gets the index columns. - * - * @return array - */ - public function getColumns() - { - return $this->columns; - } - - /** - * Sets the index type. - * - * @param string $type - * @return Index - */ - public function setType($type) - { - $this->type = $type; - return $this; - } - - /** - * Gets the index type. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Sets the index name. - * - * @param string $name - * @return Index - */ - public function setName($name) - { - $this->name = $name; - return $this; - } - - /** - * Gets the index name. - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the index limit. - * - * @param integer $limit - * @return Index - */ - public function setLimit($limit) - { - $this->limit = $limit; - return $this; - } - - /** - * Gets the index limit. - * - * @return integer - */ - public function getLimit() - { - return $this->limit; - } - - /** - * Utility method that maps an array of index options to this objects methods. - * - * @param array $options Options - * @throws \RuntimeException - * @return Index - */ - public function setOptions($options) - { - // Valid Options - $validOptions = array('type', 'unique', 'name', 'limit'); - foreach ($options as $option => $value) { - if (!in_array($option, $validOptions, true)) { - throw new \RuntimeException(sprintf('"%s" is not a valid index option.', $option)); - } - - // handle $options['unique'] - if (strcasecmp($option, self::UNIQUE) === 0) { - if ((bool) $value) { - $this->setType(self::UNIQUE); - } - continue; - } - - $method = 'set' . ucfirst($option); - $this->$method($value); - } - return $this; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractMigration.php b/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractMigration.php deleted file mode 100644 index 1598cfb..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractMigration.php +++ /dev/null @@ -1,273 +0,0 @@ - - */ -abstract class AbstractMigration implements MigrationInterface -{ - /** - * @var float - */ - protected $version; - - /** - * @var AdapterInterface - */ - protected $adapter; - - /** - * @var OutputInterface - */ - protected $output; - - /** - * @var InputInterface - */ - protected $input; - - /** - * Class Constructor. - * - * @param int $version Migration Version - * @param InputInterface|null $input - * @param OutputInterface|null $output - */ - final public function __construct($version, InputInterface $input = null, OutputInterface $output = null) - { - $this->version = $version; - if (!is_null($input)){ - $this->setInput($input); - } - if (!is_null($output)){ - $this->setOutput($output); - } - - $this->init(); - } - - /** - * Initialize method. - * - * @return void - */ - protected function init() - { - } - - /** - * {@inheritdoc} - */ - public function up() - { - } - - /** - * {@inheritdoc} - */ - public function down() - { - } - - /** - * {@inheritdoc} - */ - public function setAdapter(AdapterInterface $adapter) - { - $this->adapter = $adapter; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * {@inheritdoc} - */ - public function setInput(InputInterface $input) - { - $this->input = $input; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getInput() - { - return $this->input; - } - - /** - * {@inheritdoc} - */ - public function setOutput(OutputInterface $output) - { - $this->output = $output; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOutput() - { - return $this->output; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return get_class($this); - } - - /** - * {@inheritdoc} - */ - public function setVersion($version) - { - $this->version = $version; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getVersion() - { - return $this->version; - } - - /** - * {@inheritdoc} - */ - public function execute($sql) - { - return $this->getAdapter()->execute($sql); - } - - /** - * {@inheritdoc} - */ - public function query($sql) - { - return $this->getAdapter()->query($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchRow($sql) - { - return $this->getAdapter()->fetchRow($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchAll($sql) - { - return $this->getAdapter()->fetchAll($sql); - } - - /** - * {@inheritdoc} - */ - public function insert($table, $data) - { - // convert to table object - if (is_string($table)) { - $table = new Table($table, array(), $this->getAdapter()); - } - return $table->insert($data)->save(); - } - - /** - * {@inheritdoc} - */ - public function createDatabase($name, $options) - { - $this->getAdapter()->createDatabase($name, $options); - } - - /** - * {@inheritdoc} - */ - public function dropDatabase($name) - { - $this->getAdapter()->dropDatabase($name); - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - return $this->getAdapter()->hasTable($tableName); - } - - /** - * {@inheritdoc} - */ - public function table($tableName, $options = array()) - { - return new Table($tableName, $options, $this->getAdapter()); - } - - /** - * A short-hand method to drop the given database table. - * - * @param string $tableName Table Name - * @return void - */ - public function dropTable($tableName) - { - $this->table($tableName)->drop(); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractTemplateCreation.php b/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractTemplateCreation.php deleted file mode 100644 index 589a5f7..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/AbstractTemplateCreation.php +++ /dev/null @@ -1,97 +0,0 @@ -setInput($input); - } - if (!is_null($output)) { - $this->setOutput($output); - } - } - - /** - * {@inheritdoc} - */ - public function getInput() - { - return $this->input; - } - - /** - * {@inheritdoc} - */ - public function setInput(InputInterface $input) - { - $this->input = $input; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOutput() - { - return $this->output; - } - - /** - * {@inheritdoc} - */ - public function setOutput(OutputInterface $output) - { - $this->output = $output; - - return $this; - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/CreationInterface.php b/vendor/topthink/think-migration/phinx/src/Phinx/Migration/CreationInterface.php deleted file mode 100644 index b60c889..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/CreationInterface.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ -interface CreationInterface -{ - /** - * CreationInterface constructor. - * - * @param InputInterface|null $input - * @param OutputInterface|null $output - */ - public function __construct(InputInterface $input = null, OutputInterface $output = null); - - /** - * @param InputInterface $input - * - * @return CreationInterface - */ - public function setInput(InputInterface $input); - - /** - * @param OutputInterface $output - * - * @return CreationInterface - */ - public function setOutput(OutputInterface $output); - - /** - * @return InputInterface - */ - public function getInput(); - - /** - * @return OutputInterface - */ - public function getOutput(); - - /** - * Get the migration template. - * - * This will be the content that Phinx will amend to generate the migration file. - * - * @return string The content of the template for Phinx to amend. - */ - public function getMigrationTemplate(); - - /** - * Post Migration Creation. - * - * Once the migration file has been created, this method will be called, allowing any additional - * processing, specific to the template to be performed. - * - * @param string $migrationFilename The name of the newly created migration. - * @param string $className The class name. - * @param string $baseClassName The name of the base class. - * @return void - */ - public function postMigrationCreation($migrationFilename, $className, $baseClassName); -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/IrreversibleMigrationException.php b/vendor/topthink/think-migration/phinx/src/Phinx/Migration/IrreversibleMigrationException.php deleted file mode 100644 index 9c2a8d2..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/IrreversibleMigrationException.php +++ /dev/null @@ -1,39 +0,0 @@ - - */ -class IrreversibleMigrationException extends \Exception -{ -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/Migration.template.php.dist b/vendor/topthink/think-migration/phinx/src/Phinx/Migration/Migration.template.php.dist deleted file mode 100644 index 80ac0c1..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Migration/Migration.template.php.dist +++ /dev/null @@ -1,32 +0,0 @@ - - */ -interface MigrationInterface -{ - /** - * @var string - */ - const CHANGE = 'change'; - - /** - * @var string - */ - const UP = 'up'; - - /** - * @var string - */ - const DOWN = 'down'; - - /** - * Migrate Up - * - * @return void - */ - public function up(); - - /** - * Migrate Down - * - * @return void - */ - public function down(); - - /** - * Sets the database adapter. - * - * @param AdapterInterface $adapter Database Adapter - * @return MigrationInterface - */ - public function setAdapter(AdapterInterface $adapter); - - /** - * Gets the database adapter. - * - * @return AdapterInterface - */ - public function getAdapter(); - - /** - * Sets the input object to be used in migration object - * - * @param InputInterface $input - * @return MigrationInterface - */ - public function setInput(InputInterface $input); - - /** - * Gets the input object to be used in migration object - * - * @return InputInterface - */ - public function getInput(); - - /** - * Sets the output object to be used in migration object - * - * @param OutputInterface $output - * @return MigrationInterface - */ - public function setOutput(OutputInterface $output); - - /** - * Gets the output object to be used in migration object - * - * @return OutputInterface - */ - public function getOutput(); - - /** - * Gets the name. - * - * @return string - */ - public function getName(); - - /** - * Sets the migration version number. - * - * @param float $version Version - * @return MigrationInterface - */ - public function setVersion($version); - - /** - * Gets the migration version number. - * - * @return float - */ - public function getVersion(); - - /** - * Executes a SQL statement and returns the number of affected rows. - * - * @param string $sql SQL - * @return int - */ - public function execute($sql); - - /** - * Executes a SQL statement and returns the result as an array. - * - * @param string $sql SQL - * @return array - */ - public function query($sql); - - /** - * Executes a query and returns only one row as an array. - * - * @param string $sql SQL - * @return array - */ - public function fetchRow($sql); - - /** - * Executes a query and returns an array of rows. - * - * @param string $sql SQL - * @return array - */ - public function fetchAll($sql); - - /** - * Insert data into a table. - * - * @param string $tableName - * @param array $data - * @return void - */ - public function insert($tableName, $data); - - /** - * Create a new database. - * - * @param string $name Database Name - * @param array $options Options - * @return void - */ - public function createDatabase($name, $options); - - /** - * Drop a database. - * - * @param string $name Database Name - * @return void - */ - public function dropDatabase($name); - - /** - * Checks to see if a table exists. - * - * @param string $tableName Table Name - * @return boolean - */ - public function hasTable($tableName); - - /** - * Returns an instance of the \Table class. - * - * You can use this class to create and manipulate tables. - * - * @param string $tableName Table Name - * @param array $options Options - * @return Table - */ - public function table($tableName, $options); -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Seed/AbstractSeed.php b/vendor/topthink/think-migration/phinx/src/Phinx/Seed/AbstractSeed.php deleted file mode 100644 index 4d631f5..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Seed/AbstractSeed.php +++ /dev/null @@ -1,215 +0,0 @@ - - */ -abstract class AbstractSeed implements SeedInterface -{ - /** - * @var AdapterInterface - */ - protected $adapter; - - /** - * @var InputInterface - */ - protected $input; - - /** - * @var OutputInterface - */ - protected $output; - - /** - * Class Constructor. - * - * @param InputInterface $input - * @param OutputInterface $output - */ - final public function __construct(InputInterface $input = null, OutputInterface $output = null) - { - if (!is_null($input)){ - $this->setInput($input); - } - if (!is_null($output)){ - $this->setOutput($output); - } - - $this->init(); - } - - /** - * Initialize method. - * - * @return void - */ - protected function init() - { - } - - /** - * {@inheritdoc} - */ - public function run() - { - } - - /** - * {@inheritdoc} - */ - public function setAdapter(AdapterInterface $adapter) - { - $this->adapter = $adapter; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getAdapter() - { - return $this->adapter; - } - - /** - * {@inheritdoc} - */ - public function setInput(InputInterface $input) - { - $this->input = $input; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getInput() - { - return $this->input; - } - - /** - * {@inheritdoc} - */ - public function setOutput(OutputInterface $output) - { - $this->output = $output; - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOutput() - { - return $this->output; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return get_class($this); - } - - /** - * {@inheritdoc} - */ - public function execute($sql) - { - return $this->getAdapter()->execute($sql); - } - - /** - * {@inheritdoc} - */ - public function query($sql) - { - return $this->getAdapter()->query($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchRow($sql) - { - return $this->getAdapter()->fetchRow($sql); - } - - /** - * {@inheritdoc} - */ - public function fetchAll($sql) - { - return $this->getAdapter()->fetchAll($sql); - } - - /** - * {@inheritdoc} - */ - public function insert($table, $data) - { - // convert to table object - if (is_string($table)) { - $table = new Table($table, array(), $this->getAdapter()); - } - return $table->insert($data)->save(); - } - - /** - * {@inheritdoc} - */ - public function hasTable($tableName) - { - return $this->getAdapter()->hasTable($tableName); - } - - /** - * {@inheritdoc} - */ - public function table($tableName, $options = array()) - { - return new Table($tableName, $options, $this->getAdapter()); - } -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Seed/Seed.template.php.dist b/vendor/topthink/think-migration/phinx/src/Phinx/Seed/Seed.template.php.dist deleted file mode 100644 index 698ae26..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Seed/Seed.template.php.dist +++ /dev/null @@ -1,19 +0,0 @@ - - */ -interface SeedInterface -{ - /** - * @var string - */ - const RUN = 'run'; - - /** - * Run the seeder. - * - * @return void - */ - public function run(); - - /** - * Sets the database adapter. - * - * @param AdapterInterface $adapter Database Adapter - * @return MigrationInterface - */ - public function setAdapter(AdapterInterface $adapter); - - /** - * Gets the database adapter. - * - * @return AdapterInterface - */ - public function getAdapter(); - - /** - * Sets the input object to be used in migration object - * - * @param InputInterface $input - * @return MigrationInterface - */ - public function setInput(InputInterface $input); - - /** - * Gets the input object to be used in migration object - * - * @return InputInterface - */ - public function getInput(); - - /** - * Sets the output object to be used in migration object - * - * @param OutputInterface $output - * @return MigrationInterface - */ - public function setOutput(OutputInterface $output); - - /** - * Gets the output object to be used in migration object - * - * @return OutputInterface - */ - public function getOutput(); - - /** - * Gets the name. - * - * @return string - */ - public function getName(); - - /** - * Executes a SQL statement and returns the number of affected rows. - * - * @param string $sql SQL - * @return int - */ - public function execute($sql); - - /** - * Executes a SQL statement and returns the result as an array. - * - * @param string $sql SQL - * @return array - */ - public function query($sql); - - /** - * Executes a query and returns only one row as an array. - * - * @param string $sql SQL - * @return array - */ - public function fetchRow($sql); - - /** - * Executes a query and returns an array of rows. - * - * @param string $sql SQL - * @return array - */ - public function fetchAll($sql); - - /** - * Insert data into a table. - * - * @param string $tableName - * @param array $data - * @return void - */ - public function insert($tableName, $data); - - /** - * Checks to see if a table exists. - * - * @param string $tableName Table Name - * @return boolean - */ - public function hasTable($tableName); - - /** - * Returns an instance of the \Table class. - * - * You can use this class to create and manipulate tables. - * - * @param string $tableName Table Name - * @param array $options Options - * @return Table - */ - public function table($tableName, $options); -} diff --git a/vendor/topthink/think-migration/phinx/src/Phinx/Util/Util.php b/vendor/topthink/think-migration/phinx/src/Phinx/Util/Util.php deleted file mode 100644 index 9b8edf2..0000000 --- a/vendor/topthink/think-migration/phinx/src/Phinx/Util/Util.php +++ /dev/null @@ -1,190 +0,0 @@ -format(static::DATE_FORMAT); - } - - /** - * Gets an array of all the existing migration class names. - * - * @return string - */ - public static function getExistingMigrationClassNames($path) - { - $classNames = array(); - - if (!is_dir($path)) { - return $classNames; - } - - // filter the files to only get the ones that match our naming scheme - $phpFiles = glob($path . DIRECTORY_SEPARATOR . '*.php'); - - foreach ($phpFiles as $filePath) { - if (preg_match('/([0-9]+)_([_a-z0-9]*).php/', basename($filePath))) { - $classNames[] = static::mapFileNameToClassName(basename($filePath)); - } - } - - return $classNames; - } - - /** - * Get the version from the beginning of a file name. - * - * @param string $fileName File Name - * @return string - */ - public static function getVersionFromFileName($fileName) - { - $matches = array(); - preg_match('/^[0-9]+/', basename($fileName), $matches); - return $matches[0]; - } - - /** - * Turn migration names like 'CreateUserTable' into file names like - * '12345678901234_create_user_table.php' or 'LimitResourceNamesTo30Chars' into - * '12345678901234_limit_resource_names_to_30_chars.php'. - * - * @param string $className Class Name - * @return string - */ - public static function mapClassNameToFileName($className) - { - $arr = preg_split('/(?=[A-Z])/', $className); - unset($arr[0]); // remove the first element ('') - $fileName = static::getCurrentTimestamp() . '_' . strtolower(implode('_', $arr)) . '.php'; - return $fileName; - } - - /** - * Turn file names like '12345678901234_create_user_table.php' into class - * names like 'CreateUserTable'. - * - * @param string $fileName File Name - * @return string - */ - public static function mapFileNameToClassName($fileName) - { - $matches = array(); - if (preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches)) { - $fileName = $matches[1]; - } - - return str_replace(' ', '', ucwords(str_replace('_', ' ', $fileName))); - } - - /** - * Check if a migration class name is unique regardless of the - * timestamp. - * - * This method takes a class name and a path to a migrations directory. - * - * Migration class names must be in CamelCase format. - * e.g: CreateUserTable or AddIndexToPostsTable. - * - * Single words are not allowed on their own. - * - * @param string $className Class Name - * @param string $path Path - * @return boolean - */ - public static function isUniqueMigrationClassName($className, $path) - { - $existingClassNames = static::getExistingMigrationClassNames($path); - return !(in_array($className, $existingClassNames)); - } - - /** - * Check if a migration/seed class name is valid. - * - * Migration & Seed class names must be in CamelCase format. - * e.g: CreateUserTable, AddIndexToPostsTable or UserSeeder. - * - * Single words are not allowed on their own. - * - * @param string $className Class Name - * @return boolean - */ - public static function isValidPhinxClassName($className) - { - return (bool) preg_match('/^([A-Z][a-z0-9]+)+$/', $className); - } - - /** - * Check if a migration file name is valid. - * - * @param string $fileName File Name - * @return boolean - */ - public static function isValidMigrationFileName($fileName) - { - $matches = array(); - return preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches); - } - - /** - * Check if a seed file name is valid. - * - * @param string $fileName File Name - * @return boolean - */ - public static function isValidSeedFileName($fileName) - { - $matches = array(); - return preg_match(static::SEED_FILE_NAME_PATTERN, $fileName, $matches); - } -} diff --git a/vendor/topthink/think-migration/src/Command.php b/vendor/topthink/think-migration/src/Command.php deleted file mode 100644 index 6551897..0000000 --- a/vendor/topthink/think-migration/src/Command.php +++ /dev/null @@ -1,90 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace think\migration; - -use InvalidArgumentException; -use Phinx\Db\Adapter\AdapterFactory; - -abstract class Command extends \think\console\Command -{ - protected $adapter; - - public function getAdapter() - { - if (isset($this->adapter)) { - return $this->adapter; - } - - $options = $this->getDbConfig(); - - $adapter = AdapterFactory::instance()->getAdapter($options['adapter'], $options); - - if ($adapter->hasOption('table_prefix') || $adapter->hasOption('table_suffix')) { - $adapter = AdapterFactory::instance()->getWrapper('prefix', $adapter); - } - - $this->adapter = $adapter; - - return $adapter; - } - - /** - * 获取数据库配置 - * @return array - */ - protected function getDbConfig(): array - { - $default = $this->app->config->get('database.default'); - - $config = $this->app->config->get("database.connections.{$default}"); - - if (0 == $config['deploy']) { - $dbConfig = [ - 'adapter' => $config['type'], - 'host' => $config['hostname'], - 'name' => $config['database'], - 'user' => $config['username'], - 'pass' => $config['password'], - 'port' => $config['hostport'], - 'charset' => $config['charset'], - 'table_prefix' => $config['prefix'], - ]; - } else { - $dbConfig = [ - 'adapter' => explode(',', $config['type'])[0], - 'host' => explode(',', $config['hostname'])[0], - 'name' => explode(',', $config['database'])[0], - 'user' => explode(',', $config['username'])[0], - 'pass' => explode(',', $config['password'])[0], - 'port' => explode(',', $config['hostport'])[0], - 'charset' => explode(',', $config['charset'])[0], - 'table_prefix' => explode(',', $config['prefix'])[0], - ]; - } - - $table = $this->app->config->get('database.migration_table', 'migrations'); - - $dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . $table; - - return $dbConfig; - } - - protected function verifyMigrationDirectory(string $path) - { - if (!is_dir($path)) { - throw new InvalidArgumentException(sprintf('Migration directory "%s" does not exist', $path)); - } - - if (!is_writable($path)) { - throw new InvalidArgumentException(sprintf('Migration directory "%s" is not writable', $path)); - } - } -} diff --git a/vendor/topthink/think-migration/src/Creator.php b/vendor/topthink/think-migration/src/Creator.php deleted file mode 100644 index f4bc804..0000000 --- a/vendor/topthink/think-migration/src/Creator.php +++ /dev/null @@ -1,77 +0,0 @@ -app = $app; - } - - public function create(string $className) - { - $path = $this->ensureDirectory(); - - if (!Util::isValidPhinxClassName($className)) { - throw new InvalidArgumentException(sprintf('The migration class name "%s" is invalid. Please use CamelCase format.', $className)); - } - - if (!Util::isUniqueMigrationClassName($className, $path)) { - throw new InvalidArgumentException(sprintf('The migration class name "%s" already exists', $className)); - } - - // Compute the file path - $fileName = Util::mapClassNameToFileName($className); - $filePath = $path . DIRECTORY_SEPARATOR . $fileName; - - if (is_file($filePath)) { - throw new InvalidArgumentException(sprintf('The file "%s" already exists', $filePath)); - } - - // Verify that the template creation class (or the aliased class) exists and that it implements the required interface. - $aliasedClassName = null; - - // Load the alternative template if it is defined. - $contents = file_get_contents($this->getTemplate()); - - // inject the class names appropriate to this migration - $contents = strtr($contents, [ - 'MigratorClass' => $className, - ]); - - if (false === file_put_contents($filePath, $contents)) { - throw new RuntimeException(sprintf('The file "%s" could not be written to', $path)); - } - - return $filePath; - } - - protected function ensureDirectory() - { - $path = $this->app->getRootPath() . 'database' . DIRECTORY_SEPARATOR . 'migrations'; - - if (!is_dir($path) && !mkdir($path, 0755, true)) { - throw new InvalidArgumentException(sprintf('directory "%s" does not exist', $path)); - } - - if (!is_writable($path)) { - throw new InvalidArgumentException(sprintf('directory "%s" is not writable', $path)); - } - - return $path; - } - - protected function getTemplate() - { - return __DIR__ . '/command/stubs/migrate.stub'; - } -} diff --git a/vendor/topthink/think-migration/src/Factory.php b/vendor/topthink/think-migration/src/Factory.php deleted file mode 100644 index 976a999..0000000 --- a/vendor/topthink/think-migration/src/Factory.php +++ /dev/null @@ -1,313 +0,0 @@ -faker = $faker; - } - - /** - * Define a class with a given short-name. - * - * @param string $class - * @param string $name - * @param callable $attributes - * @return $this - */ - public function defineAs(string $class, string $name, callable $attributes) - { - return $this->define($class, $attributes, $name); - } - - /** - * Define a class with a given set of attributes. - * - * @param string $class - * @param callable $attributes - * @param string $name - * @return $this - */ - public function define(string $class, callable $attributes, string $name = 'default') - { - $this->definitions[$class][$name] = $attributes; - - return $this; - } - - /** - * Define a state with a given set of attributes. - * - * @param string $class - * @param string $state - * @param callable|array $attributes - * @return $this - */ - public function state(string $class, string $state, $attributes) - { - $this->states[$class][$state] = $attributes; - - return $this; - } - - /** - * Define a callback to run after making a model. - * - * @param string $class - * @param callable $callback - * @param string $name - * @return $this - */ - public function afterMaking(string $class, callable $callback, string $name = 'default') - { - $this->afterMaking[$class][$name][] = $callback; - - return $this; - } - - /** - * Define a callback to run after making a model with given state. - * - * @param string $class - * @param string $state - * @param callable $callback - * @return $this - */ - public function afterMakingState(string $class, string $state, callable $callback) - { - return $this->afterMaking($class, $callback, $state); - } - - /** - * Define a callback to run after creating a model. - * - * @param string $class - * @param callable $callback - * @param string $name - * @return $this - */ - public function afterCreating(string $class, callable $callback, string $name = 'default') - { - $this->afterCreating[$class][$name][] = $callback; - - return $this; - } - - /** - * Define a callback to run after creating a model with given state. - * - * @param string $class - * @param string $state - * @param callable $callback - * @return $this - */ - public function afterCreatingState(string $class, string $state, callable $callback) - { - return $this->afterCreating($class, $callback, $state); - } - - /** - * Create an instance of the given model and persist it to the database. - * - * @param string $class - * @param array $attributes - * @return mixed - */ - public function create(string $class, array $attributes = []) - { - return $this->of($class)->create($attributes); - } - - /** - * Create an instance of the given model and type and persist it to the database. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return mixed - */ - public function createAs(string $class, string $name, array $attributes = []) - { - return $this->of($class, $name)->create($attributes); - } - - /** - * Create an instance of the given model. - * - * @param string $class - * @param array $attributes - * @return mixed - */ - public function make(string $class, array $attributes = []) - { - return $this->of($class)->make($attributes); - } - - /** - * Create an instance of the given model and type. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return mixed - */ - public function makeAs(string $class, string $name, array $attributes = []) - { - return $this->of($class, $name)->make($attributes); - } - - /** - * Get the raw attribute array for a given named model. - * - * @param string $class - * @param string $name - * @param array $attributes - * @return array - */ - public function rawOf(string $class, string $name, array $attributes = []) - { - return $this->raw($class, $attributes, $name); - } - - /** - * Get the raw attribute array for a given model. - * - * @param string $class - * @param array $attributes - * @param string $name - * @return array - */ - public function raw(string $class, array $attributes = [], string $name = 'default') - { - return array_merge( - call_user_func($this->definitions[$class][$name], $this->faker), $attributes - ); - } - - /** - * Create a builder for the given model. - * - * @param string $class - * @param string $name - * @return FactoryBuilder - */ - public function of(string $class, string $name = 'default') - { - return new FactoryBuilder( - $class, $name, $this->definitions, $this->states, - $this->afterMaking, $this->afterCreating, $this->faker - ); - } - - /** - * Load factories from path. - * - * @param string $path - * @return $this - */ - public function load(string $path) - { - $factory = $this; - - if (is_dir($path)) { - foreach (glob($path . '*.php') as $file) { - require $file; - } - } - - return $factory; - } - - /** - * Determine if the given offset exists. - * - * @param string $offset - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->definitions[$offset]); - } - - /** - * Get the value of the given offset. - * - * @param string $offset - * @return mixed - */ - public function offsetGet($offset) - { - return $this->make($offset); - } - - /** - * Set the given offset to the given value. - * - * @param string $offset - * @param callable $value - * @return void - */ - public function offsetSet($offset, $value) - { - $this->define($offset, $value); - } - - /** - * Unset the value at the given offset. - * - * @param string $offset - * @return void - */ - public function offsetUnset($offset) - { - unset($this->definitions[$offset]); - } - -} diff --git a/vendor/topthink/think-migration/src/FactoryBuilder.php b/vendor/topthink/think-migration/src/FactoryBuilder.php deleted file mode 100644 index a72b07e..0000000 --- a/vendor/topthink/think-migration/src/FactoryBuilder.php +++ /dev/null @@ -1,437 +0,0 @@ -name = $name; - $this->class = $class; - $this->faker = $faker; - $this->states = $states; - $this->definitions = $definitions; - $this->afterMaking = $afterMaking; - $this->afterCreating = $afterCreating; - } - - /** - * Set the amount of models you wish to create / make. - * - * @param int $amount - * @return $this - */ - public function times($amount) - { - $this->amount = $amount; - - return $this; - } - - /** - * Set the state to be applied to the model. - * - * @param string $state - * @return $this - */ - public function state($state) - { - return $this->states([$state]); - } - - /** - * Set the states to be applied to the model. - * - * @param array|mixed $states - * @return $this - */ - public function states($states) - { - $this->activeStates = is_array($states) ? $states : func_get_args(); - - return $this; - } - - /** - * Set the database connection on which the model instance should be persisted. - * - * @param string $name - * @return $this - */ - public function connection($name) - { - $this->connection = $name; - - return $this; - } - - /** - * Create a model and persist it in the database if requested. - * - * @param array $attributes - * @return \Closure - */ - public function lazy(array $attributes = []) - { - return function () use ($attributes) { - return $this->create($attributes); - }; - } - - /** - * Create a collection of models and persist them to the database. - * - * @param array $attributes - * @return mixed - */ - public function create(array $attributes = []) - { - $results = $this->make($attributes); - - if ($results instanceof Model) { - $this->store(new Collection([$results])); - - $this->callAfterCreating(new Collection([$results])); - } else { - $this->store($results); - - $this->callAfterCreating($results); - } - - return $results; - } - - /** - * Set the connection name on the results and store them. - * - * @param Collection $results - * @return void - */ - protected function store($results) - { - $results->each(function (Model $model) { - $model->save(); - }); - } - - /** - * Create a collection of models. - * - * @param array $attributes - * @return mixed - */ - public function make(array $attributes = []) - { - if ($this->amount === null) { - return tap($this->makeInstance($attributes), function ($instance) { - $this->callAfterMaking(new Collection([$instance])); - }); - } - - if ($this->amount < 1) { - return (new $this->class)->toCollection(); - } - - $instances = (new $this->class)->toCollection(array_map(function () use ($attributes) { - return $this->makeInstance($attributes); - }, range(1, $this->amount))); - - $this->callAfterMaking($instances); - - return $instances; - } - - /** - * Create an array of raw attribute arrays. - * - * @param array $attributes - * @return mixed - */ - public function raw(array $attributes = []) - { - if ($this->amount === null) { - return $this->getRawAttributes($attributes); - } - - if ($this->amount < 1) { - return []; - } - - return array_map(function () use ($attributes) { - return $this->getRawAttributes($attributes); - }, range(1, $this->amount)); - } - - /** - * Get a raw attributes array for the model. - * - * @param array $attributes - * @return mixed - * - * @throws \InvalidArgumentException - */ - protected function getRawAttributes(array $attributes = []) - { - if (!isset($this->definitions[$this->class][$this->name])) { - throw new InvalidArgumentException("Unable to locate factory with name [{$this->name}] [{$this->class}]."); - } - - $definition = call_user_func( - $this->definitions[$this->class][$this->name], - $this->faker, $attributes - ); - - return $this->expandAttributes( - array_merge($this->applyStates($definition, $attributes), $attributes) - ); - } - - /** - * Make an instance of the model with the given attributes. - * - * @param array $attributes - * @return Model - */ - protected function makeInstance(array $attributes = []) - { - /** @var Model $model */ - $model = new $this->class; - - $model->setAttrs($this->getRawAttributes($attributes)); - - return $model; - } - - /** - * Apply the active states to the model definition array. - * - * @param array $definition - * @param array $attributes - * @return array - */ - protected function applyStates(array $definition, array $attributes = []) - { - foreach ($this->activeStates as $state) { - if (!isset($this->states[$this->class][$state])) { - if ($this->stateHasAfterCallback($state)) { - continue; - } - - throw new InvalidArgumentException("Unable to locate [{$state}] state for [{$this->class}]."); - } - - $definition = array_merge( - $definition, - $this->stateAttributes($state, $attributes) - ); - } - - return $definition; - } - - /** - * Get the state attributes. - * - * @param string $state - * @param array $attributes - * @return array - */ - protected function stateAttributes($state, array $attributes) - { - $stateAttributes = $this->states[$this->class][$state]; - - if (!is_callable($stateAttributes)) { - return $stateAttributes; - } - - return call_user_func( - $stateAttributes, - $this->faker, $attributes - ); - } - - /** - * Expand all attributes to their underlying values. - * - * @param array $attributes - * @return array - */ - protected function expandAttributes(array $attributes) - { - foreach ($attributes as &$attribute) { - if (is_callable($attribute) && !is_string($attribute) && !is_array($attribute)) { - $attribute = $attribute($attributes); - } - - if ($attribute instanceof static) { - $attribute = $attribute->create()->getKey(); - } - - if ($attribute instanceof Model) { - $attribute = $attribute->getKey(); - } - } - - return $attributes; - } - - /** - * Run after making callbacks on a collection of models. - * - * @param Collection $models - * @return void - */ - public function callAfterMaking($models) - { - $this->callAfter($this->afterMaking, $models); - } - - /** - * Run after creating callbacks on a collection of models. - * - * @param Collection $models - * @return void - */ - public function callAfterCreating($models) - { - $this->callAfter($this->afterCreating, $models); - } - - /** - * Call after callbacks for each model and state. - * - * @param array $afterCallbacks - * @param Collection $models - * @return void - */ - protected function callAfter(array $afterCallbacks, $models) - { - $states = array_merge([$this->name], $this->activeStates); - - $models->each(function ($model) use ($states, $afterCallbacks) { - foreach ($states as $state) { - $this->callAfterCallbacks($afterCallbacks, $model, $state); - } - }); - } - - /** - * Call after callbacks for each model and state. - * - * @param array $afterCallbacks - * @param Model $model - * @param string $state - * @return void - */ - protected function callAfterCallbacks(array $afterCallbacks, $model, $state) - { - if (!isset($afterCallbacks[$this->class][$state])) { - return; - } - - foreach ($afterCallbacks[$this->class][$state] as $callback) { - $callback($model, $this->faker); - } - } - - /** - * Determine if the given state has an "after" callback. - * - * @param string $state - * @return bool - */ - protected function stateHasAfterCallback($state) - { - return isset($this->afterMaking[$this->class][$state]) || - isset($this->afterCreating[$this->class][$state]); - } -} diff --git a/vendor/topthink/think-migration/src/Migrator.php b/vendor/topthink/think-migration/src/Migrator.php deleted file mode 100644 index 1965953..0000000 --- a/vendor/topthink/think-migration/src/Migrator.php +++ /dev/null @@ -1,27 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace think\migration; - -use Phinx\Migration\AbstractMigration; -use think\migration\db\Table; - -class Migrator extends AbstractMigration -{ - /** - * @param string $tableName - * @param array $options - * @return Table - */ - public function table($tableName, $options = []) - { - return new Table($tableName, $options, $this->getAdapter()); - } -} diff --git a/vendor/topthink/think-migration/src/Seeder.php b/vendor/topthink/think-migration/src/Seeder.php deleted file mode 100644 index 4b5f7f2..0000000 --- a/vendor/topthink/think-migration/src/Seeder.php +++ /dev/null @@ -1,24 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace think\migration; - -use Phinx\Seed\AbstractSeed; - -class Seeder extends AbstractSeed -{ - /** - * @return Factory - */ - public function factory() - { - return app(Factory::class); - } -} diff --git a/vendor/topthink/think-migration/src/Service.php b/vendor/topthink/think-migration/src/Service.php deleted file mode 100644 index 614e9e0..0000000 --- a/vendor/topthink/think-migration/src/Service.php +++ /dev/null @@ -1,51 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration; - -use Faker\Factory as FakerFactory; -use Faker\Generator as FakerGenerator; -use think\migration\command\factory\Create as FactoryCreate; -use think\migration\command\migrate\Breakpoint as MigrateBreakpoint; -use think\migration\command\migrate\Create as MigrateCreate; -use think\migration\command\migrate\Rollback as MigrateRollback; -use think\migration\command\migrate\Run as MigrateRun; -use think\migration\command\migrate\Status as MigrateStatus; -use think\migration\command\seed\Create as SeedCreate; -use think\migration\command\seed\Run as SeedRun; - -class Service extends \think\Service -{ - - public function boot() - { - $this->app->bind(FakerGenerator::class, function () { - return FakerFactory::create($this->app->config->get('app.faker_locale', 'zh_CN')); - }); - - $this->app->bind(Factory::class, function () { - return (new Factory($this->app->make(FakerGenerator::class)))->load($this->app->getRootPath() . 'database/factories/'); - }); - - $this->app->bind('migration.creator', Creator::class); - - $this->commands([ - MigrateCreate::class, - MigrateRun::class, - MigrateRollback::class, - MigrateBreakpoint::class, - MigrateStatus::class, - SeedCreate::class, - SeedRun::class, - FactoryCreate::class, - ]); - } -} diff --git a/vendor/topthink/think-migration/src/command/Migrate.php b/vendor/topthink/think-migration/src/command/Migrate.php deleted file mode 100644 index 1d97973..0000000 --- a/vendor/topthink/think-migration/src/command/Migrate.php +++ /dev/null @@ -1,146 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command; - -use Phinx\Db\Adapter\AdapterFactory; -use Phinx\Db\Adapter\ProxyAdapter; -use Phinx\Migration\AbstractMigration; -use Phinx\Migration\MigrationInterface; -use Phinx\Util\Util; -use think\migration\Command; -use think\migration\Migrator; - -abstract class Migrate extends Command -{ - /** - * @var array - */ - protected $migrations; - - protected function getPath() - { - return $this->app->getRootPath() . 'database' . DIRECTORY_SEPARATOR . 'migrations'; - } - - protected function executeMigration(MigrationInterface $migration, $direction = MigrationInterface::UP) - { - $this->output->writeln(''); - $this->output->writeln(' ==' . ' ' . $migration->getVersion() . ' ' . $migration->getName() . ':' . ' ' . (MigrationInterface::UP === $direction ? 'migrating' : 'reverting') . ''); - - // Execute the migration and log the time elapsed. - $start = microtime(true); - - $startTime = time(); - $direction = (MigrationInterface::UP === $direction) ? MigrationInterface::UP : MigrationInterface::DOWN; - $migration->setAdapter($this->getAdapter()); - - // begin the transaction if the adapter supports it - if ($this->getAdapter()->hasTransactions()) { - $this->getAdapter()->beginTransaction(); - } - - // Run the migration - if (method_exists($migration, MigrationInterface::CHANGE)) { - if (MigrationInterface::DOWN === $direction) { - // Create an instance of the ProxyAdapter so we can record all - // of the migration commands for reverse playback - /** @var ProxyAdapter $proxyAdapter */ - $proxyAdapter = AdapterFactory::instance()->getWrapper('proxy', $this->getAdapter()); - $migration->setAdapter($proxyAdapter); - /** @noinspection PhpUndefinedMethodInspection */ - $migration->change(); - $proxyAdapter->executeInvertedCommands(); - $migration->setAdapter($this->getAdapter()); - } else { - /** @noinspection PhpUndefinedMethodInspection */ - $migration->change(); - } - } else { - $migration->{$direction}(); - } - - // commit the transaction if the adapter supports it - if ($this->getAdapter()->hasTransactions()) { - $this->getAdapter()->commitTransaction(); - } - - // Record it in the database - $this->getAdapter() - ->migrated($migration, $direction, date('Y-m-d H:i:s', $startTime), date('Y-m-d H:i:s', time())); - - $end = microtime(true); - - $this->output->writeln(' ==' . ' ' . $migration->getVersion() . ' ' . $migration->getName() . ':' . ' ' . (MigrationInterface::UP === $direction ? 'migrated' : 'reverted') . ' ' . sprintf('%.4fs', $end - $start) . ''); - } - - protected function getVersionLog() - { - return $this->getAdapter()->getVersionLog(); - } - - protected function getVersions() - { - return $this->getAdapter()->getVersions(); - } - - protected function getMigrations() - { - if (null === $this->migrations) { - $phpFiles = glob($this->getPath() . DIRECTORY_SEPARATOR . '*.php', defined('GLOB_BRACE') ? GLOB_BRACE : 0); - - // filter the files to only get the ones that match our naming scheme - $fileNames = []; - /** @var Migrator[] $versions */ - $versions = []; - - foreach ($phpFiles as $filePath) { - if (Util::isValidMigrationFileName(basename($filePath))) { - $version = Util::getVersionFromFileName(basename($filePath)); - - if (isset($versions[$version])) { - throw new \InvalidArgumentException(sprintf('Duplicate migration - "%s" has the same version as "%s"', $filePath, $versions[$version]->getVersion())); - } - - // convert the filename to a class name - $class = Util::mapFileNameToClassName(basename($filePath)); - - if (isset($fileNames[$class])) { - throw new \InvalidArgumentException(sprintf('Migration "%s" has the same name as "%s"', basename($filePath), $fileNames[$class])); - } - - $fileNames[$class] = basename($filePath); - - // load the migration file - /** @noinspection PhpIncludeInspection */ - require_once $filePath; - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('Could not find class "%s" in file "%s"', $class, $filePath)); - } - - // instantiate it - $migration = new $class($version, $this->input, $this->output); - - if (!($migration instanceof AbstractMigration)) { - throw new \InvalidArgumentException(sprintf('The class "%s" in file "%s" must extend \Phinx\Migration\AbstractMigration', $class, $filePath)); - } - - $versions[$version] = $migration; - } - } - - ksort($versions); - $this->migrations = $versions; - } - - return $this->migrations; - } -} diff --git a/vendor/topthink/think-migration/src/command/Seed.php b/vendor/topthink/think-migration/src/command/Seed.php deleted file mode 100644 index e7a2c06..0000000 --- a/vendor/topthink/think-migration/src/command/Seed.php +++ /dev/null @@ -1,73 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command; - -use InvalidArgumentException; -use Phinx\Seed\AbstractSeed; -use Phinx\Util\Util; -use think\migration\Command; -use think\migration\Seeder; - -abstract class Seed extends Command -{ - - /** - * @var array - */ - protected $seeds; - - protected function getPath() - { - return $this->app->getRootPath() . 'database' . DIRECTORY_SEPARATOR . 'seeds'; - } - - public function getSeeds() - { - if (null === $this->seeds) { - $phpFiles = glob($this->getPath() . DIRECTORY_SEPARATOR . '*.php', defined('GLOB_BRACE') ? GLOB_BRACE : 0); - - // filter the files to only get the ones that match our naming scheme - $fileNames = []; - /** @var Seeder[] $seeds */ - $seeds = []; - - foreach ($phpFiles as $filePath) { - if (Util::isValidSeedFileName(basename($filePath))) { - // convert the filename to a class name - $class = pathinfo($filePath, PATHINFO_FILENAME); - $fileNames[$class] = basename($filePath); - - // load the seed file - /** @noinspection PhpIncludeInspection */ - require_once $filePath; - if (!class_exists($class)) { - throw new InvalidArgumentException(sprintf('Could not find class "%s" in file "%s"', $class, $filePath)); - } - - // instantiate it - $seed = new $class($this->input, $this->output); - - if (!($seed instanceof AbstractSeed)) { - throw new InvalidArgumentException(sprintf('The class "%s" in file "%s" must extend \Phinx\Seed\AbstractSeed', $class, $filePath)); - } - - $seeds[$class] = $seed; - } - } - - ksort($seeds); - $this->seeds = $seeds; - } - - return $this->seeds; - } -} diff --git a/vendor/topthink/think-migration/src/command/factory/Create.php b/vendor/topthink/think-migration/src/command/factory/Create.php deleted file mode 100644 index a7b4684..0000000 --- a/vendor/topthink/think-migration/src/command/factory/Create.php +++ /dev/null @@ -1,82 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\factory; - -use InvalidArgumentException; -use Phinx\Util\Util; -use RuntimeException; -use think\console\Command; -use think\console\input\Argument as InputArgument; - -class Create extends Command -{ - protected function configure() - { - $this->setName('factory:create') - ->setDescription('Create a new model factory') - ->addArgument('name', InputArgument::REQUIRED, 'What is the name of the model?'); - } - - public function handle() - { - $path = $this->getPath(); - - if (!file_exists($path)) { - mkdir($path, 0755, true); - } - - if (!is_dir($path)) { - throw new InvalidArgumentException(sprintf('Factory directory "%s" does not exist', $path)); - } - - if (!is_writable($path)) { - throw new InvalidArgumentException(sprintf('Factory directory "%s" is not writable', $path)); - } - - $path = realpath($path); - $className = $this->input->getArgument('name'); - - if (!Util::isValidPhinxClassName($className)) { - throw new InvalidArgumentException(sprintf('The migration class name "%s" is invalid. Please use CamelCase format.', $className)); - } - - $filePath = $path . DIRECTORY_SEPARATOR . $className . '.php'; - - if (is_file($filePath)) { - throw new InvalidArgumentException(sprintf('The file "%s" already exists', $filePath)); - } - - // Load the alternative template if it is defined. - $contents = file_get_contents($this->getTemplate()); - - // inject the class names appropriate to this migration - $contents = strtr($contents, [ - '"ModelClass"' => "\\app\\model\\" . $className . '::class', - ]); - - if (false === file_put_contents($filePath, $contents)) { - throw new RuntimeException(sprintf('The file "%s" could not be written to', $path)); - } - - $this->output->writeln('created .' . str_replace(getcwd(), '', $filePath)); - } - - protected function getTemplate() - { - return __DIR__ . '/../stubs/factory.stub'; - } - - protected function getPath() - { - return $this->app->getRootPath() . 'database' . DIRECTORY_SEPARATOR . 'factories'; - } -} diff --git a/vendor/topthink/think-migration/src/command/migrate/Breakpoint.php b/vendor/topthink/think-migration/src/command/migrate/Breakpoint.php deleted file mode 100644 index cfb2d32..0000000 --- a/vendor/topthink/think-migration/src/command/migrate/Breakpoint.php +++ /dev/null @@ -1,92 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\migrate; - -use think\console\Input; -use think\console\input\Option as InputOption; -use think\console\Output; -use think\migration\command\Migrate; - -class Breakpoint extends Migrate -{ - protected function configure() - { - $this->setName('migrate:breakpoint') - ->setDescription('Manage breakpoints') - ->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to set or clear a breakpoint against') - ->addOption('--remove-all', '-r', InputOption::VALUE_NONE, 'Remove all breakpoints') - ->setHelp(<<breakpoint command allows you to set or clear a breakpoint against a specific target to inhibit rollbacks beyond a certain target. -If no target is supplied then the most recent migration will be used. -You cannot specify un-migrated targets - -php think migrate:breakpoint -php think migrate:breakpoint -t 20110103081132 -php think migrate:breakpoint -r -EOT - ); - } - - protected function execute(Input $input, Output $output) - { - $version = $input->getOption('target'); - $removeAll = $input->getOption('remove-all'); - - if ($version && $removeAll) { - throw new \InvalidArgumentException('Cannot toggle a breakpoint and remove all breakpoints at the same time.'); - } - - // Remove all breakpoints - if ($removeAll) { - $this->removeBreakpoints(); - } else { - // Toggle the breakpoint. - $this->toggleBreakpoint($version); - } - } - - protected function toggleBreakpoint($version) - { - $migrations = $this->getMigrations(); - $versions = $this->getVersionLog(); - - if (empty($versions) || empty($migrations)) { - return; - } - - if (null === $version) { - $lastVersion = end($versions); - $version = $lastVersion['version']; - } - - if (0 != $version && !isset($migrations[$version])) { - $this->output->writeln(sprintf('warning %s is not a valid version', $version)); - return; - } - - $this->getAdapter()->toggleBreakpoint($migrations[$version]); - - $versions = $this->getVersionLog(); - - $this->output->writeln(' Breakpoint ' . ($versions[$version]['breakpoint'] ? 'set' : 'cleared') . ' for ' . $version . '' . ' ' . $migrations[$version]->getName() . ''); - } - - /** - * Remove all breakpoints - * - * @return void - */ - protected function removeBreakpoints() - { - $this->output->writeln(sprintf(' %d breakpoints cleared.', $this->getAdapter()->resetAllBreakpoints())); - } -} diff --git a/vendor/topthink/think-migration/src/command/migrate/Create.php b/vendor/topthink/think-migration/src/command/migrate/Create.php deleted file mode 100644 index 8f96de7..0000000 --- a/vendor/topthink/think-migration/src/command/migrate/Create.php +++ /dev/null @@ -1,55 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\migrate; - -use InvalidArgumentException; -use RuntimeException; -use think\console\Command; -use think\console\Input; -use think\console\input\Argument as InputArgument; -use think\console\Output; -use think\migration\Creator; - -class Create extends Command -{ - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('migrate:create') - ->setDescription('Create a new migration') - ->addArgument('name', InputArgument::REQUIRED, 'What is the name of the migration?') - ->setHelp(sprintf('%sCreates a new database migration%s', PHP_EOL, PHP_EOL)); - } - - /** - * Create the new migration. - * - * @param Input $input - * @param Output $output - * @return void - * @throws InvalidArgumentException - * @throws RuntimeException - */ - protected function execute(Input $input, Output $output) - { - /** @var Creator $creator */ - $creator = $this->app->get('migration.creator'); - - $className = $input->getArgument('name'); - - $path = $creator->create($className); - - $output->writeln('created .' . str_replace(getcwd(), '', realpath($path))); - } - -} diff --git a/vendor/topthink/think-migration/src/command/migrate/Rollback.php b/vendor/topthink/think-migration/src/command/migrate/Rollback.php deleted file mode 100644 index e668ac7..0000000 --- a/vendor/topthink/think-migration/src/command/migrate/Rollback.php +++ /dev/null @@ -1,146 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\migrate; - -use Phinx\Migration\MigrationInterface; -use think\console\input\Option as InputOption; -use think\console\Input; -use think\console\Output; -use think\migration\command\Migrate; - -class Rollback extends Migrate -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('migrate:rollback') - ->setDescription('Rollback the last or to a specific migration') - ->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to rollback to') - ->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to rollback to') - ->addOption('--force', '-f', InputOption::VALUE_NONE, 'Force rollback to ignore breakpoints') - ->setHelp(<<migrate:rollback command reverts the last migration, or optionally up to a specific version - -php think migrate:rollback -php think migrate:rollback -t 20111018185412 -php think migrate:rollback -d 20111018 -php think migrate:rollback -v - -EOT - ); - } - - /** - * Rollback the migration. - * - * @param Input $input - * @param Output $output - * @return void - */ - protected function execute(Input $input, Output $output) - { - $version = $input->getOption('target'); - $date = $input->getOption('date'); - $force = !!$input->getOption('force'); - - // rollback the specified environment - $start = microtime(true); - if (null !== $date) { - $this->rollbackToDateTime(new \DateTime($date), $force); - } else { - $this->rollback($version, $force); - } - $end = microtime(true); - - $output->writeln(''); - $output->writeln('All Done. Took ' . sprintf('%.4fs', $end - $start) . ''); - } - - protected function rollback($version = null, $force = false) - { - $migrations = $this->getMigrations(); - $versionLog = $this->getVersionLog(); - $versions = array_keys($versionLog); - - ksort($migrations); - sort($versions); - - // Check we have at least 1 migration to revert - if (empty($versions) || $version == end($versions)) { - $this->output->writeln('No migrations to rollback'); - return; - } - - // If no target version was supplied, revert the last migration - if (null === $version) { - // Get the migration before the last run migration - $prev = count($versions) - 2; - $version = $prev < 0 ? 0 : $versions[$prev]; - } else { - // Get the first migration number - $first = $versions[0]; - - // If the target version is before the first migration, revert all migrations - if ($version < $first) { - $version = 0; - } - } - - // Check the target version exists - if (0 !== $version && !isset($migrations[$version])) { - $this->output->writeln("Target version ($version) not found"); - return; - } - - // Revert the migration(s) - krsort($migrations); - foreach ($migrations as $migration) { - if ($migration->getVersion() <= $version) { - break; - } - - if (in_array($migration->getVersion(), $versions)) { - if (isset($versionLog[$migration->getVersion()]) && 0 != $versionLog[$migration->getVersion()]['breakpoint'] && !$force) { - $this->output->writeln('Breakpoint reached. Further rollbacks inhibited.'); - break; - } - $this->executeMigration($migration, MigrationInterface::DOWN); - } - } - } - - protected function rollbackToDateTime(\DateTime $dateTime, $force = false) - { - $versions = $this->getVersions(); - $dateString = $dateTime->format('YmdHis'); - sort($versions); - - $earlierVersion = null; - $availableMigrations = array_filter($versions, function ($version) use ($dateString, &$earlierVersion) { - if ($version <= $dateString) { - $earlierVersion = $version; - } - return $version >= $dateString; - }); - - if (count($availableMigrations) > 0) { - if (is_null($earlierVersion)) { - $this->output->writeln('Rolling back all migrations'); - $migration = 0; - } else { - $this->output->writeln('Rolling back to version ' . $earlierVersion); - $migration = $earlierVersion; - } - $this->rollback($migration, $force); - } - } -} diff --git a/vendor/topthink/think-migration/src/command/migrate/Run.php b/vendor/topthink/think-migration/src/command/migrate/Run.php deleted file mode 100644 index 4714f02..0000000 --- a/vendor/topthink/think-migration/src/command/migrate/Run.php +++ /dev/null @@ -1,140 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\migrate; - -use Phinx\Migration\MigrationInterface; -use think\console\Input; -use think\console\input\Option as InputOption; -use think\console\Output; -use think\migration\command\Migrate; - -class Run extends Migrate -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('migrate:run') - ->setDescription('Migrate the database') - ->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to migrate to') - ->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to migrate to') - ->setHelp(<<migrate:run command runs all available migrations, optionally up to a specific version - -php think migrate:run -php think migrate:run -t 20110103081132 -php think migrate:run -d 20110103 -php think migrate:run -v - -EOT - ); - } - - /** - * Migrate the database. - * - * @param Input $input - * @param Output $output - */ - protected function execute(Input $input, Output $output) - { - $version = $input->getOption('target'); - $date = $input->getOption('date'); - - // run the migrations - $start = microtime(true); - if (null !== $date) { - $this->migrateToDateTime(new \DateTime($date)); - } else { - $this->migrate($version); - } - $end = microtime(true); - - $output->writeln(''); - $output->writeln('All Done. Took ' . sprintf('%.4fs', $end - $start) . ''); - } - - public function migrateToDateTime(\DateTime $dateTime) - { - $versions = array_keys($this->getMigrations()); - $dateString = $dateTime->format('YmdHis'); - - $outstandingMigrations = array_filter($versions, function ($version) use ($dateString) { - return $version <= $dateString; - }); - - if (count($outstandingMigrations) > 0) { - $migration = max($outstandingMigrations); - $this->output->writeln('Migrating to version ' . $migration); - $this->migrate($migration); - } - } - - protected function migrate($version = null) - { - $migrations = $this->getMigrations(); - $versions = $this->getVersions(); - $current = $this->getCurrentVersion(); - - if (empty($versions) && empty($migrations)) { - return; - } - - if (null === $version) { - $version = max(array_merge($versions, array_keys($migrations))); - } else { - if (0 != $version && !isset($migrations[$version])) { - $this->output->writeln(sprintf('warning %s is not a valid version', $version)); - return; - } - } - - // are we migrating up or down? - $direction = $version > $current ? MigrationInterface::UP : MigrationInterface::DOWN; - - if ($direction === MigrationInterface::DOWN) { - // run downs first - krsort($migrations); - foreach ($migrations as $migration) { - if ($migration->getVersion() <= $version) { - break; - } - - if (in_array($migration->getVersion(), $versions)) { - $this->executeMigration($migration, MigrationInterface::DOWN); - } - } - } - - ksort($migrations); - foreach ($migrations as $migration) { - if ($migration->getVersion() > $version) { - break; - } - - if (!in_array($migration->getVersion(), $versions)) { - $this->executeMigration($migration, MigrationInterface::UP); - } - } - } - - protected function getCurrentVersion() - { - $versions = $this->getVersions(); - $version = 0; - - if (!empty($versions)) { - $version = end($versions); - } - - return $version; - } -} diff --git a/vendor/topthink/think-migration/src/command/migrate/Status.php b/vendor/topthink/think-migration/src/command/migrate/Status.php deleted file mode 100644 index ccf424a..0000000 --- a/vendor/topthink/think-migration/src/command/migrate/Status.php +++ /dev/null @@ -1,126 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\migrate; - -use think\console\input\Option as InputOption; -use think\console\Input; -use think\console\Output; -use think\migration\command\Migrate; - -class Status extends Migrate -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('migrate:status') - ->setDescription('Show migration status') - ->addOption('--format', '-f', InputOption::VALUE_REQUIRED, 'The output format: text or json. Defaults to text.') - ->setHelp(<<migrate:status command prints a list of all migrations, along with their current status - -php think migrate:status -php think migrate:status -f json -EOT - ); - } - - /** - * Show the migration status. - * - * @param Input $input - * @param Output $output - * @return integer 0 if all migrations are up, or an error code - */ - protected function execute(Input $input, Output $output) - { - $format = $input->getOption('format'); - - if (null !== $format) { - $output->writeln('using format ' . $format); - } - - // print the status - return $this->printStatus($format); - } - - protected function printStatus($format = null) - { - $output = $this->output; - $migrations = []; - if (count($this->getMigrations())) { - // TODO - rewrite using Symfony Table Helper as we already have this library - // included and it will fix formatting issues (e.g drawing the lines) - $output->writeln(''); - $output->writeln(' Status Migration ID Started Finished Migration Name '); - $output->writeln('----------------------------------------------------------------------------------'); - - $versions = $this->getVersionLog(); - $maxNameLength = $versions ? max(array_map(function ($version) { - return strlen($version['migration_name']); - }, $versions)) : 0; - - foreach ($this->getMigrations() as $migration) { - $version = array_key_exists($migration->getVersion(), $versions) ? $versions[$migration->getVersion()] : false; - if ($version) { - $status = ' up '; - } else { - $status = ' down '; - $version = []; - $version['start_time'] = $version['end_time'] = $version['breakpoint'] = ''; - } - $maxNameLength = max($maxNameLength, strlen($migration->getName())); - - $output->writeln(sprintf('%s %14.0f %19s %19s %s', $status, $migration->getVersion(), $version['start_time'], $version['end_time'], $migration->getName())); - - if ($version && $version['breakpoint']) { - $output->writeln(' BREAKPOINT SET'); - } - - $migrations[] = [ - 'migration_status' => trim(strip_tags($status)), - 'migration_id' => sprintf('%14.0f', $migration->getVersion()), - 'migration_name' => $migration->getName() - ]; - unset($versions[$migration->getVersion()]); - } - - if (count($versions)) { - foreach ($versions as $missing => $version) { - $output->writeln(sprintf(' up %14.0f %19s %19s %s ** MISSING **', $missing, $version['start_time'], $version['end_time'], str_pad($version['migration_name'], $maxNameLength, ' '))); - - if ($version && $version['breakpoint']) { - $output->writeln(' BREAKPOINT SET'); - } - } - } - } else { - // there are no migrations - $output->writeln(''); - $output->writeln('There are no available migrations. Try creating one using the create command.'); - } - - // write an empty line - $output->writeln(''); - if ($format !== null) { - switch ($format) { - case 'json': - $output->writeln(json_encode([ - 'pending_count' => count($this->getMigrations()), - 'migrations' => $migrations - ])); - break; - default: - $output->writeln('Unsupported format: ' . $format . ''); - } - } - } -} diff --git a/vendor/topthink/think-migration/src/command/seed/Create.php b/vendor/topthink/think-migration/src/command/seed/Create.php deleted file mode 100644 index 6873980..0000000 --- a/vendor/topthink/think-migration/src/command/seed/Create.php +++ /dev/null @@ -1,83 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\seed; - -use Phinx\Util\Util; -use think\console\Input; -use think\console\input\Argument as InputArgument; -use think\console\Output; -use think\migration\command\Seed; - -class Create extends Seed -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('seed:create') - ->setDescription('Create a new database seeder') - ->addArgument('name', InputArgument::REQUIRED, 'What is the name of the seeder?') - ->setHelp(sprintf('%sCreates a new database seeder%s', PHP_EOL, PHP_EOL)); - } - - /** - * Create the new seeder. - * - * @param Input $input - * @param Output $output - * @return void - * @throws \InvalidArgumentException - * @throws \RuntimeException - */ - protected function execute(Input $input, Output $output) - { - $path = $this->getPath(); - - if (!file_exists($path)) { - mkdir($path, 0755, true); - } - - $this->verifyMigrationDirectory($path); - - $path = realpath($path); - - $className = $input->getArgument('name'); - - if (!Util::isValidPhinxClassName($className)) { - throw new \InvalidArgumentException(sprintf('The seed class name "%s" is invalid. Please use CamelCase format', $className)); - } - - // Compute the file path - $filePath = $path . DIRECTORY_SEPARATOR . $className . '.php'; - - if (is_file($filePath)) { - throw new \InvalidArgumentException(sprintf('The file "%s" already exists', basename($filePath))); - } - - // inject the class names appropriate to this seeder - $contents = file_get_contents($this->getTemplate()); - $classes = [ - 'SeederClass' => $className, - ]; - $contents = strtr($contents, $classes); - - if (false === file_put_contents($filePath, $contents)) { - throw new \RuntimeException(sprintf('The file "%s" could not be written to', $path)); - } - - $output->writeln('created .' . str_replace(getcwd(), '', $filePath)); - } - - protected function getTemplate() - { - return __DIR__ . '/../stubs/seed.stub'; - } -} diff --git a/vendor/topthink/think-migration/src/command/seed/Run.php b/vendor/topthink/think-migration/src/command/seed/Run.php deleted file mode 100644 index a0ac8f9..0000000 --- a/vendor/topthink/think-migration/src/command/seed/Run.php +++ /dev/null @@ -1,107 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\command\seed; - -use Phinx\Seed\SeedInterface; -use think\console\Input; -use think\console\input\Option as InputOption; -use think\console\Output; -use think\migration\command\Seed; - -class Run extends Seed -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->setName('seed:run') - ->setDescription('Run database seeders') - ->addOption('--seed', '-s', InputOption::VALUE_REQUIRED, 'What is the name of the seeder?') - ->setHelp(<<seed:run command runs all available or individual seeders - -php think seed:run -php think seed:run -s UserSeeder -php think seed:run -v - -EOT - ); - } - - /** - * Run database seeders. - * - * @param Input $input - * @param Output $output - * @return void - */ - protected function execute(Input $input, Output $output) - { - $seed = $input->getOption('seed'); - - // run the seed(ers) - $start = microtime(true); - $this->seed($seed); - $end = microtime(true); - - $output->writeln(''); - $output->writeln('All Done. Took ' . sprintf('%.4fs', $end - $start) . ''); - } - - public function seed($seed = null) - { - $seeds = $this->getSeeds(); - - if (null === $seed) { - // run all seeders - foreach ($seeds as $seeder) { - if (array_key_exists($seeder->getName(), $seeds)) { - $this->executeSeed($seeder); - } - } - } else { - // run only one seeder - if (array_key_exists($seed, $seeds)) { - $this->executeSeed($seeds[$seed]); - } else { - throw new \InvalidArgumentException(sprintf('The seed class "%s" does not exist', $seed)); - } - } - } - - protected function executeSeed(SeedInterface $seed) - { - $this->output->writeln(''); - $this->output->writeln(' ==' . ' ' . $seed->getName() . ':' . ' seeding'); - - // Execute the seeder and log the time elapsed. - $start = microtime(true); - $seed->setAdapter($this->getAdapter()); - - // begin the transaction if the adapter supports it - if ($this->getAdapter()->hasTransactions()) { - $this->getAdapter()->beginTransaction(); - } - - // Run the seeder - if (method_exists($seed, SeedInterface::RUN)) { - $seed->run(); - } - - // commit the transaction if the adapter supports it - if ($this->getAdapter()->hasTransactions()) { - $this->getAdapter()->commitTransaction(); - } - $end = microtime(true); - - $this->output->writeln(' ==' . ' ' . $seed->getName() . ':' . ' seeded' . ' ' . sprintf('%.4fs', $end - $start) . ''); - } -} diff --git a/vendor/topthink/think-migration/src/command/stubs/factory.stub b/vendor/topthink/think-migration/src/command/stubs/factory.stub deleted file mode 100644 index eef91dc..0000000 --- a/vendor/topthink/think-migration/src/command/stubs/factory.stub +++ /dev/null @@ -1,11 +0,0 @@ -define("ModelClass", function (Faker $faker) { - return [ - // - ]; -}); diff --git a/vendor/topthink/think-migration/src/command/stubs/migrate.stub b/vendor/topthink/think-migration/src/command/stubs/migrate.stub deleted file mode 100644 index f11d29a..0000000 --- a/vendor/topthink/think-migration/src/command/stubs/migrate.stub +++ /dev/null @@ -1,33 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\db; - -use Phinx\Db\Adapter\AdapterInterface; -use Phinx\Db\Adapter\MysqlAdapter; - -class Column extends \Phinx\Db\Table\Column -{ - protected $unique = false; - - public function setNullable() - { - return $this->setNull(true); - } - - public function setUnsigned() - { - return $this->setSigned(false); - } - - public function setUnique() - { - $this->unique = true; - return $this; - } - - public function getUnique() - { - return $this->unique; - } - - public function isUnique() - { - return $this->getUnique(); - } - - public static function make($name, $type, $options = []) - { - $column = new self(); - $column->setName($name); - $column->setType($type); - $column->setOptions($options); - return $column; - } - - public static function bigInteger($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_BIG_INTEGER); - } - - public static function binary($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_BLOB); - } - - public static function boolean($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_BOOLEAN); - } - - public static function char($name, $length = 255) - { - return self::make($name, AdapterInterface::PHINX_TYPE_CHAR, compact('length')); - } - - public static function date($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_DATE); - } - - public static function dateTime($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_DATETIME); - } - - public static function decimal($name, $precision = 8, $scale = 2) - { - return self::make($name, AdapterInterface::PHINX_TYPE_DECIMAL, compact('precision', 'scale')); - } - - public static function enum($name, array $values) - { - return self::make($name, AdapterInterface::PHINX_TYPE_ENUM, compact('values')); - } - - public static function float($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_FLOAT); - } - - public static function integer($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_INTEGER); - } - - public static function json($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_JSON); - } - - public static function jsonb($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_JSONB); - } - - public static function longText($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_TEXT, ['length' => MysqlAdapter::TEXT_LONG]); - } - - public static function mediumInteger($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_INTEGER, ['length' => MysqlAdapter::INT_MEDIUM]); - } - - public static function mediumText($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_TEXT, ['length' => MysqlAdapter::TEXT_MEDIUM]); - } - - public static function smallInteger($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_INTEGER, ['length' => MysqlAdapter::INT_SMALL]); - } - - public static function string($name, $length = 255) - { - return self::make($name, AdapterInterface::PHINX_TYPE_STRING, compact('length')); - } - - public static function text($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_TEXT); - } - - public static function time($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_TIME); - } - - public static function tinyInteger($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_INTEGER, ['length' => MysqlAdapter::INT_TINY]); - } - - public static function unsignedInteger($name) - { - return self::integer($name)->setUnSigned(); - } - - public static function timestamp($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_TIMESTAMP); - } - - public static function uuid($name) - { - return self::make($name, AdapterInterface::PHINX_TYPE_UUID); - } - -} diff --git a/vendor/topthink/think-migration/src/db/Table.php b/vendor/topthink/think-migration/src/db/Table.php deleted file mode 100644 index cf4daa9..0000000 --- a/vendor/topthink/think-migration/src/db/Table.php +++ /dev/null @@ -1,135 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace think\migration\db; - -use Phinx\Db\Table\Index; - -class Table extends \Phinx\Db\Table -{ - /** - * 设置id - * @param $id - * @return $this - */ - public function setId($id) - { - $this->options['id'] = $id; - return $this; - } - - /** - * 设置主键 - * @param $key - * @return $this - */ - public function setPrimaryKey($key) - { - $this->options['primary_key'] = $key; - return $this; - } - - /** - * 设置引擎 - * @param $engine - * @return $this - */ - public function setEngine($engine) - { - $this->options['engine'] = $engine; - return $this; - } - - /** - * 设置表注释 - * @param $comment - * @return $this - */ - public function setComment($comment) - { - $this->options['comment'] = $comment; - return $this; - } - - /** - * 设置排序比对方法 - * @param $collation - * @return $this - */ - public function setCollation($collation) - { - $this->options['collation'] = $collation; - return $this; - } - - public function addSoftDelete() - { - $this->addColumn(Column::timestamp('delete_time')->setNullable()); - return $this; - } - - public function addMorphs($name, $indexName = null) - { - $this->addColumn(Column::unsignedInteger("{$name}_id")); - $this->addColumn(Column::string("{$name}_type")); - $this->addIndex(["{$name}_id", "{$name}_type"], ['name' => $indexName]); - return $this; - } - - public function addNullableMorphs($name, $indexName = null) - { - $this->addColumn(Column::unsignedInteger("{$name}_id")->setNullable()); - $this->addColumn(Column::string("{$name}_type")->setNullable()); - $this->addIndex(["{$name}_id", "{$name}_type"], ['name' => $indexName]); - return $this; - } - - /** - * @param string $createdAtColumnName - * @param string $updatedAtColumnName - * @return \Phinx\Db\Table|Table - */ - public function addTimestamps($createdAtColumnName = 'create_time', $updatedAtColumnName = 'update_time') - { - return parent::addTimestamps($createdAtColumnName, $updatedAtColumnName); - } - - /** - * @param \Phinx\Db\Table\Column|string $columnName - * @param null $type - * @param array $options - * @return \Phinx\Db\Table|Table - */ - public function addColumn($columnName, $type = null, $options = []) - { - if ($columnName instanceof Column && $columnName->getUnique()) { - $index = new Index(); - $index->setColumns([$columnName->getName()]); - $index->setType(Index::UNIQUE); - $this->addIndex($index); - } - return parent::addColumn($columnName, $type, $options); - } - - /** - * @param string $columnName - * @param null $newColumnType - * @param array $options - * @return \Phinx\Db\Table|Table - */ - public function changeColumn($columnName, $newColumnType = null, $options = []) - { - if ($columnName instanceof \Phinx\Db\Table\Column) { - return parent::changeColumn($columnName->getName(), $columnName, $options); - } - return parent::changeColumn($columnName, $newColumnType, $options); - } -} diff --git a/vendor/topthink/think-migration/src/helper.php b/vendor/topthink/think-migration/src/helper.php deleted file mode 100644 index 6dc47ab..0000000 --- a/vendor/topthink/think-migration/src/helper.php +++ /dev/null @@ -1,40 +0,0 @@ -of($arguments[0], $arguments[1])->times($arguments[2] ?? null); - } elseif (isset($arguments[1])) { - return $factory->of($arguments[0])->times($arguments[1]); - } - - return $factory->of($arguments[0]); - } -} - -if (!function_exists('database_path')) { - /** - * 获取数据迁移脚本地址 - * @param string $path - * @return string - */ - function database_path($path = '') - { - return app()->getRootPath() . 'database' . DIRECTORY_SEPARATOR . $path; - } -} diff --git a/vendor/topthink/think-orm/README.md b/vendor/topthink/think-orm/README.md index c65afe9..869de15 100644 --- a/vendor/topthink/think-orm/README.md +++ b/vendor/topthink/think-orm/README.md @@ -1,6 +1,6 @@ # ThinkORM -基于PHP7.1+ 和PDO实现的ORM,支持多数据库,2.0版本主要特性包括: +基于PHP8.0+ 和PDO实现的ORM,支持多数据库,3.0版本主要特性包括: * 基于PDO和PHP强类型实现 * 支持原生查询和查询构造器 diff --git a/vendor/topthink/think-orm/composer.json b/vendor/topthink/think-orm/composer.json index 097d924..a9760bd 100644 --- a/vendor/topthink/think-orm/composer.json +++ b/vendor/topthink/think-orm/composer.json @@ -1,10 +1,10 @@ { "name": "topthink/think-orm", - "description": "think orm", + "description": "the PHP Database&ORM Framework", "keywords": [ "orm", "database" - ], + ], "license": "Apache-2.0", "authors": [ { @@ -13,15 +13,15 @@ } ], "require": { - "php": ">=7.1.0", + "php": ">=8.0.0", "ext-json": "*", "ext-pdo": "*", - "psr/simple-cache": "^1.0|^2.0", - "psr/log": "^1.0|^2.0", + "psr/simple-cache": ">=1.0", + "psr/log": ">=1.0", "topthink/think-helper":"^3.1" }, "require-dev": { - "phpunit/phpunit": "^7|^8|^9.5" + "phpunit/phpunit": "^8|^9.5|^10" }, "autoload": { "psr-4": { diff --git a/vendor/topthink/think-orm/src/DbManager.php b/vendor/topthink/think-orm/src/DbManager.php index 1c1314e..416e1c8 100644 --- a/vendor/topthink/think-orm/src/DbManager.php +++ b/vendor/topthink/think-orm/src/DbManager.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -21,64 +22,71 @@ use think\db\Query; use think\db\Raw; /** - * Class DbManager - * @package think + * Class DbManager. + * * @mixin BaseQuery * @mixin Query */ class DbManager { /** - * 数据库连接实例 + * 数据库连接实例. + * * @var array */ protected $instance = []; /** - * 数据库配置 + * 数据库配置. + * * @var array */ protected $config = []; /** - * Event对象或者数组 + * Event对象或者数组. + * * @var array|object */ protected $event; /** - * SQL监听 + * SQL监听. + * * @var array */ protected $listen = []; /** - * SQL日志 + * SQL日志. + * * @var array */ protected $dbLog = []; /** - * 查询次数 + * 查询次数. + * * @var int */ protected $queryTimes = 0; /** * 查询缓存对象 + * * @var CacheInterface */ protected $cache; /** * 查询日志对象 + * * @var LoggerInterface */ protected $log; /** - * 架构函数 - * @access public + * 架构函数. */ public function __construct() { @@ -87,7 +95,7 @@ class DbManager /** * 注入模型对象 - * @access public + * * @return void */ protected function modelMaker() @@ -116,17 +124,19 @@ class DbManager } /** - * 监听SQL - * @access protected + * 监听SQL. + * * @return void */ public function triggerSql(): void - {} + { + } /** - * 初始化配置参数 - * @access public + * 初始化配置参数. + * * @param array $config 连接配置 + * * @return void */ public function setConfig($config): void @@ -136,8 +146,9 @@ class DbManager /** * 设置缓存对象 - * @access public + * * @param CacheInterface $cache 缓存对象 + * * @return void */ public function setCache(CacheInterface $cache): void @@ -147,8 +158,9 @@ class DbManager /** * 设置日志对象 - * @access public + * * @param LoggerInterface $log 日志对象 + * * @return void */ public function setLog(LoggerInterface $log): void @@ -157,10 +169,11 @@ class DbManager } /** - * 记录SQL日志 - * @access protected + * 记录SQL日志. + * * @param string $log SQL日志信息 * @param string $type 日志类型 + * * @return void */ public function log(string $log, string $type = 'sql') @@ -173,9 +186,10 @@ class DbManager } /** - * 获得查询日志(没有设置日志对象使用) - * @access public + * 获得查询日志(没有设置日志对象使用). + * * @param bool $clear 是否清空 + * * @return array */ public function getDbLog(bool $clear = false): array @@ -189,10 +203,11 @@ class DbManager } /** - * 获取配置参数 - * @access public + * 获取配置参数. + * * @param string $name 配置参数 * @param mixed $default 默认值 + * * @return mixed */ public function getConfig(string $name = '', $default = null) @@ -205,10 +220,11 @@ class DbManager } /** - * 创建/切换数据库连接查询 - * @access public + * 创建/切换数据库连接查询. + * * @param string|null $name 连接配置标识 * @param bool $force 强制重新连接 + * * @return ConnectionInterface */ public function connect(string $name = null, bool $force = false) @@ -217,10 +233,11 @@ class DbManager } /** - * 创建数据库连接实例 - * @access protected + * 创建数据库连接实例. + * * @param string|null $name 连接标识 * @param bool $force 强制重新连接 + * * @return ConnectionInterface */ protected function instance(string $name = null, bool $force = false): ConnectionInterface @@ -237,8 +254,10 @@ class DbManager } /** - * 获取连接配置 + * 获取连接配置. + * * @param string $name + * * @return array */ protected function getConnectionConfig(string $name): array @@ -252,8 +271,10 @@ class DbManager } /** - * 创建连接 + * 创建连接. + * * @param $name + * * @return ConnectionInterface */ protected function createConnection(string $name): ConnectionInterface @@ -262,7 +283,7 @@ class DbManager $type = !empty($config['type']) ? $config['type'] : 'mysql'; - if (false !== strpos($type, '\\')) { + if (str_contains($type, '\\')) { $class = $type; } else { $class = '\\think\\db\\connector\\' . ucfirst($type); @@ -280,9 +301,10 @@ class DbManager } /** - * 使用表达式设置数据 - * @access public + * 使用表达式设置数据. + * * @param string $value 表达式 + * * @return Raw */ public function raw(string $value): Raw @@ -291,8 +313,8 @@ class DbManager } /** - * 更新查询次数 - * @access public + * 更新查询次数. + * * @return void */ public function updateQueryTimes(): void @@ -301,8 +323,8 @@ class DbManager } /** - * 重置查询次数 - * @access public + * 重置查询次数. + * * @return void */ public function clearQueryTimes(): void @@ -311,9 +333,9 @@ class DbManager } /** - * 获得查询次数 - * @access public - * @return integer + * 获得查询次数. + * + * @return int */ public function getQueryTimes(): int { @@ -321,9 +343,10 @@ class DbManager } /** - * 监听SQL执行 - * @access public + * 监听SQL执行. + * * @param callable $callback 回调方法 + * * @return void */ public function listen(callable $callback): void @@ -332,18 +355,18 @@ class DbManager } /** - * 获取监听SQL执行 - * @access public + * 获取监听SQL执行. + * * @return array */ public function getListen(): array { return $this->listen; } - + /** - * 获取所有连接实列 - * @access public + * 获取所有连接实列. + * * @return array */ public function getInstance(): array @@ -352,10 +375,11 @@ class DbManager } /** - * 注册回调方法 - * @access public + * 注册回调方法. + * * @param string $event 事件名 * @param callable $callback 回调方法 + * * @return void */ public function event(string $event, callable $callback): void @@ -364,10 +388,11 @@ class DbManager } /** - * 触发事件 - * @access public + * 触发事件. + * * @param string $event 事件名 * @param mixed $params 传入参数 + * * @return mixed */ public function trigger(string $event, $params = null) diff --git a/vendor/topthink/think-orm/src/Model.php b/vendor/topthink/think-orm/src/Model.php index a8332e9..f100613 100644 --- a/vendor/topthink/think-orm/src/Model.php +++ b/vendor/topthink/think-orm/src/Model.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -20,20 +21,21 @@ use think\contract\Jsonable; use think\db\BaseQuery as Query; /** - * Class Model - * @package think + * Class Model. + * * @mixin Query - * @method void onAfterRead(Model $model) static after_read事件定义 - * @method mixed onBeforeInsert(Model $model) static before_insert事件定义 - * @method void onAfterInsert(Model $model) static after_insert事件定义 - * @method mixed onBeforeUpdate(Model $model) static before_update事件定义 - * @method void onAfterUpdate(Model $model) static after_update事件定义 - * @method mixed onBeforeWrite(Model $model) static before_write事件定义 - * @method void onAfterWrite(Model $model) static after_write事件定义 - * @method mixed onBeforeDelete(Model $model) static before_write事件定义 - * @method void onAfterDelete(Model $model) static after_delete事件定义 - * @method void onBeforeRestore(Model $model) static before_restore事件定义 - * @method void onAfterRestore(Model $model) static after_restore事件定义 + * + * @method static void onAfterRead(Model $model) after_read事件定义 + * @method static mixed onBeforeInsert(Model $model) before_insert事件定义 + * @method static void onAfterInsert(Model $model) after_insert事件定义 + * @method static mixed onBeforeUpdate(Model $model) before_update事件定义 + * @method static void onAfterUpdate(Model $model) after_update事件定义 + * @method static mixed onBeforeWrite(Model $model) before_write事件定义 + * @method static void onAfterWrite(Model $model) after_write事件定义 + * @method static mixed onBeforeDelete(Model $model) before_write事件定义 + * @method static void onAfterDelete(Model $model) after_delete事件定义 + * @method static void onBeforeRestore(Model $model) before_restore事件定义 + * @method static void onAfterRestore(Model $model) after_restore事件定义 */ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonable { @@ -44,111 +46,122 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab use model\concern\Conversion; /** - * 数据是否存在 + * 数据是否存在. + * * @var bool */ private $exists = false; /** - * 是否强制更新所有数据 + * 是否强制更新所有数据. + * * @var bool */ private $force = false; /** - * 是否Replace + * 是否Replace. + * * @var bool */ private $replace = false; /** * 数据表后缀 + * * @var string */ protected $suffix; /** - * 更新条件 + * 更新条件. + * * @var array */ private $updateWhere; /** - * 数据库配置 + * 数据库配置. + * * @var string */ protected $connection; /** - * 模型名称 + * 模型名称. + * * @var string */ protected $name; /** * 主键值 + * * @var string */ protected $key; /** - * 数据表名称 + * 数据表名称. + * * @var string */ protected $table; /** * 初始化过的模型. + * * @var array */ protected static $initialized = []; /** * 软删除字段默认值 + * * @var mixed */ protected $defaultSoftDelete; /** - * 全局查询范围 + * 全局查询范围. + * * @var array */ protected $globalScope = []; - /** - * 延迟保存信息 - * @var bool - */ - private $lazySave = false; - /** * Db对象 + * * @var DbManager */ protected static $db; /** - * 容器对象的依赖注入方法 + * 容器对象的依赖注入方法. + * * @var callable */ protected static $invoker; /** - * 服务注入 + * 服务注入. + * * @var Closure[] */ protected static $maker = []; /** - * 方法注入 + * 方法注入. + * * @var Closure[][] */ protected static $macro = []; /** - * 设置服务注入 - * @access public + * 设置服务注入. + * * @param Closure $maker + * * @return void */ public static function maker(Closure $maker) @@ -157,10 +170,11 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 设置方法注入 - * @access public - * @param string $method + * 设置方法注入. + * + * @param string $method * @param Closure $closure + * * @return void */ public static function macro(string $method, Closure $closure) @@ -173,8 +187,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 设置Db对象 - * @access public + * * @param DbManager $db Db对象 + * * @return void */ public static function setDb(DbManager $db) @@ -183,9 +198,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 设置容器对象的依赖注入方法 - * @access public + * 设置容器对象的依赖注入方法. + * * @param callable $callable 依赖注入方法 + * * @return void */ public static function setInvoker(callable $callable): void @@ -194,16 +210,18 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 调用反射执行模型方法 支持参数绑定 - * @access public + * 调用反射执行模型方法 支持参数绑定. + * * @param mixed $method - * @param array $vars 参数 + * @param array $vars 参数 + * * @return mixed */ public function invoke($method, array $vars = []) { if (self::$invoker) { $call = self::$invoker; + return $call($method instanceof Closure ? $method : Closure::fromCallable([$this, $method]), $vars); } @@ -211,29 +229,21 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 架构函数 - * @access public - * @param array $data 数据 + * 架构函数. + * + * @param array|object $data 数据 */ - public function __construct(array $data = []) + public function __construct(array|object $data = []) { - $this->data = $data; - - if (!empty($this->data)) { - // 废弃字段 - foreach ((array) $this->disuse as $key) { - if (array_key_exists($key, $this->data)) { - unset($this->data[$key]); - } - } - } + // 设置数据 + $this->data($data); // 记录原始数据 $this->origin = $this->data; if (empty($this->name)) { // 当前模型名 - $name = str_replace('\\', '/', static::class); + $name = str_replace('\\', '/', static::class); $this->name = basename($name); } @@ -248,8 +258,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 获取当前模型名称 - * @access public + * 获取当前模型名称. + * * @return string */ public function getName(): string @@ -258,11 +268,12 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 创建新的模型实例 - * @access public - * @param array $data 数据 - * @param mixed $where 更新条件 - * @param array $options 参数 + * 创建新的模型实例. + * + * @param array $data 数据 + * @param mixed $where 更新条件 + * @param array $options 参数 + * * @return Model */ public function newInstance(array $data = [], $where = null, array $options = []): Model @@ -291,9 +302,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 设置模型的更新条件 - * @access protected + * 设置模型的更新条件. + * * @param mixed $where 更新条件 + * * @return void */ protected function setUpdateWhere($where): void @@ -302,20 +314,22 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 设置当前模型的数据库连接 - * @access public + * 设置当前模型的数据库连接. + * * @param string $connection 数据表连接标识 + * * @return $this */ public function setConnection(string $connection) { $this->connection = $connection; + return $this; } /** - * 获取当前模型的数据库连接标识 - * @access public + * 获取当前模型的数据库连接标识. + * * @return string */ public function getConnection(): string @@ -325,19 +339,21 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 设置当前模型数据表的后缀 - * @access public + * * @param string $suffix 数据表后缀 + * * @return $this */ public function setSuffix(string $suffix) { $this->suffix = $suffix; + return $this; } /** * 获取当前模型的数据表后缀 - * @access public + * * @return string */ public function getSuffix(): string @@ -347,8 +363,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 获取当前模型的数据库查询对象 - * @access public + * * @param array $scope 设置不使用的全局查询范围 + * * @return Query */ public function db($scope = []): Query @@ -364,7 +381,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab $query->model($this) ->json($this->json, $this->jsonAssoc) - ->setFieldType(array_merge($this->schema, $this->jsonType)); + ->setFieldType(array_merge($this->schema, $this->jsonType)) + ->setKey($this->getKey()) + ->lazyFields($this->lazyFields); // 软删除 if (property_exists($this, 'withTrashed') && !$this->withTrashed) { @@ -382,8 +401,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 初始化模型 - * @access private + * 初始化模型. + * * @return void */ private function initialize(): void @@ -395,8 +414,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 初始化处理 - * @access protected + * 初始化处理. + * * @return void */ protected static function init() @@ -412,20 +431,22 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 更新是否强制写入数据 而不做比较(亦可用于软删除的强制删除) - * @access public + * 更新是否强制写入数据 而不做比较(亦可用于软删除的强制删除). + * * @param bool $force + * * @return $this */ public function force(bool $force = true) { $this->force = $force; + return $this; } /** - * 判断force - * @access public + * 判断force. + * * @return bool */ public function isForce(): bool @@ -434,29 +455,32 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 新增数据是否使用Replace - * @access public + * 新增数据是否使用Replace. + * * @param bool $replace + * * @return $this */ public function replace(bool $replace = true) { $this->replace = $replace; + return $this; } /** - * 刷新模型数据 - * @access public + * 刷新模型数据. + * * @param bool $relation 是否刷新关联数据 + * * @return $this */ public function refresh(bool $relation = false) { if ($this->exists) { - $this->data = $this->db()->find($this->getKey())->getData(); - $this->origin = $this->data; - $this->get = []; + $this->data = $this->db()->find($this->getKey())->getData(); + $this->origin = $this->data; + $this->get = []; if ($relation) { $this->relation = []; @@ -467,20 +491,22 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 设置数据是否存在 - * @access public + * 设置数据是否存在. + * * @param bool $exists + * * @return $this */ public function exists(bool $exists = true) { $this->exists = $exists; + return $this; } /** - * 判断数据是否存在数据库 - * @access public + * 判断数据是否存在数据库. + * * @return bool */ public function isExists(): bool @@ -489,8 +515,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 判断模型是否为空 - * @access public + * 判断模型是否为空. + * * @return bool */ public function isEmpty(): bool @@ -498,34 +524,22 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab return empty($this->data); } - /** - * 延迟保存当前数据对象 - * @access public - * @param array|bool $data 数据 - * @return void - */ - public function lazySave($data = []): void - { - if (false === $data) { - $this->lazySave = false; - } else { - if (is_array($data)) { - $this->setAttrs($data); - } - - $this->lazySave = true; - } - } - /** * 保存当前数据对象 - * @access public - * @param array $data 数据 + * + * @param array|object $data 数据 * @param string $sequence 自增序列名 + * * @return bool */ - public function save(array $data = [], string $sequence = null): bool + public function save(array|object $data = [], string $sequence = null): bool { + if ($data instanceof Model) { + $data = $data->getData(); + } elseif (is_object($data)) { + $data = get_object_vars($data); + } + // 数据对象赋值 $this->setAttrs($data); @@ -545,14 +559,13 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab // 重新记录原始数据 $this->origin = $this->data; $this->get = []; - $this->lazySave = false; return true; } /** - * 检查数据是否允许写入 - * @access protected + * 检查数据是否允许写入. + * * @return array */ protected function checkAllowFields(): array @@ -586,8 +599,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 保存写入数据 - * @access protected + * 保存写入数据. + * * @return bool */ protected function updateData(): bool @@ -613,7 +626,7 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab if ($this->autoWriteTimestamp && $this->updateTime) { // 自动写入更新时间 - $data[$this->updateTime] = $this->autoWriteTimestamp(); + $data[$this->updateTime] = $this->autoWriteTimestamp(); $this->data[$this->updateTime] = $data[$this->updateTime]; } @@ -636,10 +649,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab $db = $this->db(); $db->transaction(function () use ($data, $allowFields, $db) { - $this->key = null; - $where = $this->getWhere(); - - $result = $db->where($where) + $this->key = null; + $where = $this->getWhere(); + $result = $db->where($where) ->strict(false) ->cache(true) ->setOption('key', $this->key) @@ -661,9 +673,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 新增写入数据 - * @access protected + * 新增写入数据. + * * @param string $sequence 自增名 + * * @return bool */ protected function insertData(string $sequence = null): bool @@ -678,12 +691,12 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab // 时间戳自动写入 if ($this->autoWriteTimestamp) { if ($this->createTime && !isset($data[$this->createTime])) { - $data[$this->createTime] = $this->autoWriteTimestamp(); + $data[$this->createTime] = $this->autoWriteTimestamp(); $this->data[$this->createTime] = $data[$this->createTime]; } if ($this->updateTime && !isset($data[$this->updateTime])) { - $data[$this->updateTime] = $this->autoWriteTimestamp(); + $data[$this->updateTime] = $this->autoWriteTimestamp(); $this->data[$this->updateTime] = $data[$this->updateTime]; } } @@ -727,8 +740,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 获取当前的更新条件 - * @access public + * 获取当前的更新条件. + * * @return mixed */ public function getWhere() @@ -736,7 +749,7 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab $pk = $this->getPk(); if (is_string($pk) && isset($this->origin[$pk])) { - $where = [[$pk, '=', $this->origin[$pk]]]; + $where = [[$pk, '=', $this->origin[$pk]]]; $this->key = $this->origin[$pk]; } elseif (is_array($pk)) { foreach ($pk as $field) { @@ -755,18 +768,19 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 保存多个数据到当前数据对象 - * @access public + * * @param iterable $dataSet 数据 - * @param boolean $replace 是否自动识别更新和写入 - * @return Collection + * @param bool $replace 是否自动识别更新和写入 + * * @throws \Exception + * + * @return Collection */ public function saveAll(iterable $dataSet, bool $replace = true): Collection { $db = $this->db(); $result = $db->transaction(function () use ($replace, $dataSet) { - $pk = $this->getPk(); $result = []; @@ -776,7 +790,7 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab if ($replace) { $exists = true; foreach ((array) $pk as $field) { - if (!isset($data[$field])) { + if (is_string($field) && !isset($data[$field])) { $exists = false; } } @@ -796,8 +810,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 删除当前的记录 - * @access public + * 删除当前的记录. + * * @return bool */ public function delete(): bool @@ -807,9 +821,8 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } // 读取更新条件 - $where = $this->getWhere(); - - $db = $this->db(); + $where = $this->getWhere(); + $db = $this->db(); $db->transaction(function () use ($where, $db) { // 删除当前模型数据 @@ -824,18 +837,18 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab $this->trigger('AfterDelete'); $this->exists = false; - $this->lazySave = false; return true; } /** - * 写入数据 - * @access public + * 写入数据. + * * @param array $data 数据数组 * @param array $allowField 允许字段 * @param bool $replace 使用Replace * @param string $suffix 数据表后缀 + * * @return static */ public static function create(array $data, array $allowField = [], bool $replace = false, string $suffix = ''): Model @@ -856,12 +869,13 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 更新数据 - * @access public + * 更新数据. + * * @param array $data 数据数组 * @param mixed $where 更新条件 * @param array $allowField 允许字段 * @param string $suffix 数据表后缀 + * * @return static */ public static function update(array $data, $where = [], array $allowField = [], string $suffix = '') @@ -886,10 +900,11 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 删除记录 - * @access public + * 删除记录. + * * @param mixed $data 主键列表 支持闭包查询条件 * @param bool $force 是否强制删除 + * * @return bool */ public static function destroy($data, bool $force = false): bool @@ -899,18 +914,17 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } $model = new static(); - $query = $model->db(); if (is_array($data) && key($data) !== 0) { $query->where($data); - $data = null; + $data = []; } elseif ($data instanceof \Closure) { $data($query); - $data = null; + $data = []; } - $resultSet = $query->select($data); + $resultSet = $query->select((array) $data); foreach ($resultSet as $result) { $result->force($force)->delete(); @@ -920,7 +934,7 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 解序列化后处理 + * 解序列化后处理. */ public function __wakeup() { @@ -929,9 +943,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 修改器 设置数据对象的值 - * @access public + * * @param string $name 名称 * @param mixed $value 值 + * * @return void */ public function __set(string $name, $value): void @@ -941,8 +956,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 获取器 获取数据对象的值 - * @access public + * * @param string $name 名称 + * * @return mixed */ public function __get(string $name) @@ -952,8 +968,9 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 检测数据对象的值 - * @access public + * * @param string $name 名称 + * * @return bool */ public function __isset(string $name): bool @@ -963,49 +980,49 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab /** * 销毁数据对象的值 - * @access public + * * @param string $name 名称 + * * @return void */ public function __unset(string $name): void { - unset($this->data[$name], + unset( + $this->data[$name], $this->get[$name], - $this->relation[$name]); + $this->relation[$name] + ); } // ArrayAccess - #[\ReturnTypeWillChange] - public function offsetSet($name, $value) + public function offsetSet(mixed $name, mixed $value): void { $this->setAttr($name, $value); } - #[\ReturnTypeWillChange] - public function offsetExists($name): bool + public function offsetExists(mixed $name): bool { return $this->__isset($name); } - #[\ReturnTypeWillChange] - public function offsetUnset($name) + public function offsetUnset(mixed $name): void { $this->__unset($name); } - #[\ReturnTypeWillChange] - public function offsetGet($name) + public function offsetGet(mixed $name): mixed { return $this->getAttr($name); } /** - * 设置不使用的全局查询范围 - * @access public + * 设置不使用的全局查询范围. + * * @param array $scope 不启用的全局查询范围 + * * @return Query */ - public static function withoutGlobalScope(array $scope = null) + public static function withoutGlobalScope(array $scope = null): Query { $model = new static(); @@ -1013,9 +1030,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 切换后缀进行查询 - * @access public + * 切换后缀进行查询. + * * @param string $suffix 切换的表后缀 + * * @return Model */ public static function suffix(string $suffix) @@ -1027,9 +1045,10 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab } /** - * 切换数据库连接进行查询 - * @access public + * 切换数据库连接进行查询. + * * @param string $connection 数据库连接标识 + * * @return Model */ public static function connect(string $connection) @@ -1040,6 +1059,15 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab return $model; } + /** + * 创建一个查询对象 + * @return Query + */ + public static function query(): Query + { + return (new static())->db(); + } + public function __call($method, $args) { if (isset(static::$macro[static::class][$method])) { @@ -1059,15 +1087,4 @@ abstract class Model implements JsonSerializable, ArrayAccess, Arrayable, Jsonab return call_user_func_array([$model->db(), $method], $args); } - - /** - * 析构方法 - * @access public - */ - public function __destruct() - { - if ($this->lazySave) { - $this->save(); - } - } } diff --git a/vendor/topthink/think-orm/src/Paginator.php b/vendor/topthink/think-orm/src/Paginator.php index eace6ba..971b052 100644 --- a/vendor/topthink/think-orm/src/Paginator.php +++ b/vendor/topthink/think-orm/src/Paginator.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think; @@ -23,55 +24,64 @@ use think\paginator\driver\Bootstrap; use Traversable; /** - * 分页基础类 + * 分页基础类. + * * @mixin Collection */ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable { /** - * 是否简洁模式 + * 是否简洁模式. + * * @var bool */ protected $simple = false; /** - * 数据集 + * 数据集. + * * @var Collection */ protected $items; /** - * 当前页 + * 当前页. + * * @var int */ protected $currentPage; /** - * 最后一页 + * 最后一页. + * * @var int */ protected $lastPage; /** - * 数据总数 - * @var integer|null + * 数据总数. + * + * @var int|null */ protected $total; /** - * 每页数量 + * 每页数量. + * * @var int */ protected $listRows; /** - * 是否有下一页 + * 是否有下一页. + * * @var bool */ protected $hasMore; /** - * 分页配置 + * 分页配置. + * * @var array */ protected $options = [ @@ -83,12 +93,14 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * 获取当前页码 + * * @var Closure */ protected static $currentPageResolver; /** - * 获取当前路径 + * 获取当前路径. + * * @var Closure */ protected static $currentPathResolver; @@ -112,26 +124,26 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } if ($simple) { - $this->currentPage = $this->setCurrentPage($currentPage); - $this->hasMore = count($items) > ($this->listRows); - $items = $items->slice(0, $this->listRows); + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = count($items) > ($this->listRows); + $items = $items->slice(0, $this->listRows); } else { - $this->total = $total; - $this->lastPage = (int) ceil($total / $listRows); - $this->currentPage = $this->setCurrentPage($currentPage); - $this->hasMore = $this->currentPage < $this->lastPage; + $this->total = $total; + $this->lastPage = (int) ceil($total / $listRows); + $this->currentPage = $this->setCurrentPage($currentPage); + $this->hasMore = $this->currentPage < $this->lastPage; } $this->items = $items; } /** - * @access public * @param mixed $items * @param int $listRows * @param int $currentPage * @param int $total * @param bool $simple * @param array $options + * * @return Paginator */ public static function make($items, int $listRows, int $currentPage = 1, int $total = null, bool $simple = false, array $options = []) @@ -158,10 +170,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 获取页码对应的链接 + * 获取页码对应的链接. * - * @access protected * @param int $page + * * @return string */ protected function url(int $page): string @@ -170,7 +182,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J $page = 1; } - if (strpos($this->options['path'], '[PAGE]') === false) { + if (!str_contains($this->options['path'], '[PAGE]')) { $parameters = [$this->options['var_page'] => $page]; $path = $this->options['path']; } else { @@ -192,9 +204,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * 自动获取当前页码 - * @access public + * * @param string $varPage * @param int $default + * * @return int */ public static function getCurrentPage(string $varPage = 'page', int $default = 1): int @@ -207,7 +220,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 设置获取当前页码闭包 + * 设置获取当前页码闭包. + * * @param Closure $resolver */ public static function currentPageResolver(Closure $resolver) @@ -216,9 +230,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 自动获取当前的path - * @access public + * 自动获取当前的path. + * * @param string $default + * * @return string */ public static function getCurrentPath($default = '/'): string @@ -231,7 +246,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 设置获取当前路径闭包 + * 设置获取当前路径闭包. + * * @param Closure $resolver */ public static function currentPathResolver(Closure $resolver) @@ -240,7 +256,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 获取数据总条数 + * 获取数据总条数. + * * @return int */ public function total(): int @@ -253,7 +270,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 获取每页数量 + * 获取每页数量. + * * @return int */ public function listRows(): int @@ -263,6 +281,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * 获取当前页页码 + * * @return int */ public function currentPage(): int @@ -272,6 +291,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J /** * 获取最后一页页码 + * * @return int */ public function lastPage(): int @@ -284,8 +304,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 数据是否足够分页 - * @access public + * 数据是否足够分页. + * * @return bool */ public function hasPages(): bool @@ -294,11 +314,11 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 创建一组分页链接 + * 创建一组分页链接. * - * @access public * @param int $start * @param int $end + * * @return array */ public function getUrlRange(int $start, int $end): array @@ -313,10 +333,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 设置URL锚点 + * 设置URL锚点. * - * @access public * @param string|null $fragment + * * @return $this */ public function fragment(string $fragment = null) @@ -327,10 +347,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 添加URL参数 + * 添加URL参数. * - * @access public * @param array $append + * * @return $this */ public function appends(array $append) @@ -345,9 +365,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 构造锚点字符串 + * 构造锚点字符串. * - * @access public * @return string */ protected function buildFragment(): string @@ -356,8 +375,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 渲染分页html - * @access public + * 渲染分页html. + * * @return mixed */ abstract public function render(); @@ -368,7 +387,7 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 获取数据集 + * 获取数据集. * * @return Collection|\think\model\Collection */ @@ -378,9 +397,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 设置数据集 + * 设置数据集. * * @param Collection $items + * * @return $this */ public function setCollection(Collection $items) @@ -396,10 +416,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 给每个元素执行个回调 + * 给每个元素执行个回调. * - * @access public * @param callable $callback + * * @return $this */ public function each(callable $callback) @@ -418,68 +438,68 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * Retrieve an external iterator - * @access public + * Retrieve an external iterator. + * * @return Traversable An instance of an object implementing Iterator or - * Traversable + * Traversable */ - #[\ReturnTypeWillChange] public function getIterator(): Traversable { return new ArrayIterator($this->items->all()); } /** - * Whether a offset exists - * @access public + * Whether a offset exists. + * * @param mixed $offset + * * @return bool */ - #[\ReturnTypeWillChange] - public function offsetExists($offset): bool + public function offsetExists(mixed $offset): bool { return $this->items->offsetExists($offset); } /** - * Offset to retrieve - * @access public + * Offset to retrieve. + * * @param mixed $offset + * * @return mixed */ - #[\ReturnTypeWillChange] - public function offsetGet($offset) + public function offsetGet(mixed $offset): mixed { return $this->items->offsetGet($offset); } /** - * Offset to set - * @access public + * Offset to set. + * * @param mixed $offset * @param mixed $value */ - #[\ReturnTypeWillChange] - public function offsetSet($offset, $value) + public function offsetSet(mixed $offset, mixed $value): void { $this->items->offsetSet($offset, $value); } /** - * Offset to unset - * @access public + * Offset to unset. + * * @param mixed $offset + * * @return void + * * @since 5.0.0 */ - #[\ReturnTypeWillChange] - public function offsetUnset($offset) + public function offsetUnset(mixed $offset): void { $this->items->offsetUnset($offset); } /** - * 统计数据集条数 + * 统计数据集条数. + * * @return int */ public function count(): int @@ -493,7 +513,8 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * 转换为数组 + * 转换为数组. + * * @return array */ public function toArray(): array @@ -514,10 +535,9 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J } /** - * Specify data which should be serialized to JSON + * Specify data which should be serialized to JSON. */ - #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { return $this->toArray(); } @@ -528,10 +548,10 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J if ($result instanceof Collection) { $this->items = $result; + return $this; } return $result; } - } diff --git a/vendor/topthink/think-orm/src/db/BaseBuilder.php b/vendor/topthink/think-orm/src/db/BaseBuilder.php new file mode 100644 index 0000000..6cc48fc --- /dev/null +++ b/vendor/topthink/think-orm/src/db/BaseBuilder.php @@ -0,0 +1,960 @@ + +// +---------------------------------------------------------------------- +declare(strict_types=1); + +namespace think\db; + +use Closure; +use think\db\BaseQuery as Query; +use think\db\exception\DbException as Exception; + +/** + * Db Base Builder. + */ +abstract class BaseBuilder +{ + /** + * Connection对象 + * + * @var ConnectionInterface + */ + protected $connection; + + /** + * 查询表达式映射. + * + * @var array + */ + protected $exp = ['NOTLIKE' => 'NOT LIKE', 'NOTIN' => 'NOT IN', 'NOTBETWEEN' => 'NOT BETWEEN', 'NOTEXISTS' => 'NOT EXISTS', 'NOTNULL' => 'NOT NULL', 'NOTBETWEEN TIME' => 'NOT BETWEEN TIME']; + + /** + * 查询表达式解析. + * + * @var array + */ + protected $parser = [ + 'parseCompare' => ['=', '<>', '>', '>=', '<', '<='], + 'parseLike' => ['LIKE', 'NOT LIKE'], + 'parseBetween' => ['NOT BETWEEN', 'BETWEEN'], + 'parseIn' => ['NOT IN', 'IN'], + 'parseExp' => ['EXP'], + 'parseNull' => ['NOT NULL', 'NULL'], + 'parseBetweenTime' => ['BETWEEN TIME', 'NOT BETWEEN TIME'], + 'parseTime' => ['< TIME', '> TIME', '<= TIME', '>= TIME'], + 'parseExists' => ['NOT EXISTS', 'EXISTS'], + 'parseColumn' => ['COLUMN'], + ]; + + /** + * SELECT SQL表达式. + * + * @var string + */ + protected $selectSql = 'SELECT%DISTINCT%%EXTRA% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * INSERT SQL表达式. + * + * @var string + */ + protected $insertSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; + + /** + * INSERT ALL SQL表达式. + * + * @var string + */ + protected $insertAllSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; + + /** + * UPDATE SQL表达式. + * + * @var string + */ + protected $updateSql = 'UPDATE%EXTRA% %TABLE% SET %SET%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * DELETE SQL表达式. + * + * @var string + */ + protected $deleteSql = 'DELETE%EXTRA% FROM %TABLE%%USING%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; + + /** + * 架构函数. + * + * @param ConnectionInterface $connection 数据库连接对象实例 + */ + public function __construct(ConnectionInterface $connection) + { + $this->connection = $connection; + } + + /** + * 获取当前的连接对象实例. + * + * @return ConnectionInterface + */ + public function getConnection(): ConnectionInterface + { + return $this->connection; + } + + /** + * 注册查询表达式解析. + * + * @param string $name 解析方法 + * @param array $parser 匹配表达式数据 + * + * @return $this + */ + public function bindParser(string $name, array $parser) + { + $this->parser[$name] = $parser; + + return $this; + } + + /** + * 数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * @param array $fields 字段信息 + * @param array $bind 参数绑定 + * + * @return array + */ + abstract protected function parseData(Query $query, array $data = [], array $fields = [], array $bind = []): array; + + /** + * 数据绑定处理. + * + * @param Query $query 查询对象 + * @param string $key 字段名 + * @param mixed $data 数据 + * @param array $bind 绑定数据 + * + * @return string + */ + abstract protected function parseDataBind(Query $query, string $key, $data, array $bind = []): string; + + /** + * 字段名分析. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * + * @return string + */ + abstract public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string; + + /** + * 查询额外参数分析. + * + * @param Query $query 查询对象 + * @param string $extra 额外参数 + * + * @return string + */ + abstract protected function parseExtra(Query $query, string $extra): string; + + /** + * field分析. + * + * @param Query $query 查询对象 + * @param array $fields 字段名 + * + * @return string + */ + abstract protected function parseField(Query $query, array $fields): string; + + /** + * table分析. + * + * @param Query $query 查询对象 + * @param array|string $tables 表名 + * + * @return string + */ + abstract protected function parseTable(Query $query, array|string $tables): string; + + /** + * where分析. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * + * @return string + */ + abstract protected function parseWhere(Query $query, array $where): string; + + /** + * 生成查询条件SQL. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * + * @return string + */ + public function buildWhere(Query $query, array $where): string + { + if (empty($where)) { + $where = []; + } + + $whereStr = ''; + + $binds = $query->getFieldsBindType(); + + foreach ($where as $logic => $val) { + $str = $this->parseWhereLogic($query, $logic, $val, $binds); + + $whereStr .= empty($whereStr) ? substr(implode(' ', $str), strlen($logic) + 1) : implode(' ', $str); + } + + return $whereStr; + } + + /** + * 不同字段使用相同查询条件(AND). + * + * @param Query $query 查询对象 + * @param string $logic Logic + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * + * @return array + */ + protected function parseWhereLogic(Query $query, string $logic, array $val, array $binds = []): array + { + $where = []; + foreach ($val as $value) { + if ($value instanceof Raw) { + $where[] = ' ' . $logic . ' ( ' . $this->parseRaw($query, $value) . ' )'; + continue; + } + + if (is_array($value)) { + if (key($value) !== 0) { + throw new Exception('where express error:' . var_export($value, true)); + } + $field = array_shift($value); + } elseif (true === $value) { + $where[] = ' ' . $logic . ' 1 '; + continue; + } elseif (!($value instanceof Closure)) { + throw new Exception('where express error:' . var_export($value, true)); + } + + if ($value instanceof Closure) { + // 使用闭包查询 + $whereClosureStr = $this->parseClosureWhere($query, $value, $logic); + if ($whereClosureStr) { + $where[] = $whereClosureStr; + } + } elseif (is_array($field)) { + $where[] = $this->parseMultiWhereField($query, $value, $field, $logic, $binds); + } elseif ($field instanceof Raw) { + $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); + } elseif (str_contains($field, '|')) { + $where[] = $this->parseFieldsOr($query, $value, $field, $logic, $binds); + } elseif (str_contains($field, '&')) { + $where[] = $this->parseFieldsAnd($query, $value, $field, $logic, $binds); + } else { + // 对字段使用表达式查询 + $field = is_string($field) ? $field : ''; + $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); + } + } + + return $where; + } + + /** + * 不同字段使用相同查询条件(AND). + * + * @param Query $query 查询对象 + * @param mixed $value 查询条件 + * @param string $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseFieldsAnd(Query $query, $value, string $field, string $logic, array $binds): string + { + $item = []; + + foreach (explode('&', $field) as $k) { + $item[] = $this->parseWhereItem($query, $k, $value, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; + } + + /** + * 不同字段使用相同查询条件(OR). + * + * @param Query $query 查询对象 + * @param array $value 查询条件 + * @param string $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseFieldsOr(Query $query, array $value, string $field, string $logic, array $binds): string + { + $item = []; + + foreach (explode('|', $field) as $k) { + $item[] = $this->parseWhereItem($query, $k, $value, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; + } + + /** + * 闭包查询. + * + * @param Query $query 查询对象 + * @param Closure $value 查询条件 + * @param string $logic Logic + * + * @return string + */ + protected function parseClosureWhere(Query $query, Closure $value, string $logic): string + { + $newQuery = $query->newQuery(); + $value($newQuery); + $whereClosure = $this->buildWhere($newQuery, $newQuery->getOptions('where') ?: []); + + if (!empty($whereClosure)) { + $query->bind($newQuery->getBind(false)); + $where = ' ' . $logic . ' ( ' . $whereClosure . ' )'; + } + + return $where ?? ''; + } + + /** + * 复合条件查询. + * + * @param Query $query 查询对象 + * @param mixed $value 查询条件 + * @param mixed $field 查询字段 + * @param string $logic Logic + * @param array $binds 参数绑定 + * + * @return string + */ + protected function parseMultiWhereField(Query $query, array $value, $field, string $logic, array $binds): string + { + array_unshift($value, $field); + + $where = []; + foreach ($value as $item) { + $where[] = $this->parseWhereItem($query, array_shift($item), $item, $binds); + } + + return ' ' . $logic . ' ( ' . implode(' AND ', $where) . ' )'; + } + + /** + * where子单元分析. + * + * @param Query $query 查询对象 + * @param mixed $field 查询字段 + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * + * @return string + */ + abstract protected function parseWhereItem(Query $query, $field, array $val, array $binds = []): string; + + /** + * 模糊查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * @param string $logic + * + * @return string + */ + abstract protected function parseLike(Query $query, string $key, string $exp, $value, $field, int $bindType, string $logic): string; + + /** + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseExp(Query $query, string $key, string $exp, Raw $value, string $field, int $bindType): string + { + // 表达式查询 + return '( ' . $key . ' ' . $this->parseRaw($query, $value) . ' )'; + } + + /** + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseColumn(Query $query, string $key, $exp, array $value, string $field, int $bindType): string + { + // 字段比较查询 + [$op, $field] = $value; + + if (!in_array(trim($op), ['=', '<>', '>', '>=', '<', '<='])) { + throw new Exception('where express error:' . var_export($value, true)); + } + + return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field, true) . ' )'; + } + + /** + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string; + + /** + * 范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseBetween(Query $query, string $key, string $exp, array|string $value, $field, int $bindType): string; + + /** + * Exists查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw|Closure $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseExists(Query $query, string $key, string $exp, Raw|Closure $value, string $field, int $bindType): string + { + // EXISTS 查询 + if ($value instanceof Closure) { + $value = $this->parseClosure($query, $value, false); + } elseif ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } + + return $exp . ' ( ' . $value . ' )'; + } + + /** + * 时间比较查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); + } + + /** + * 大小比较查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseCompare(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + if (is_array($value)) { + throw new Exception('where express error:' . $exp . var_export($value, true)); + } + + // 比较运算 + if ($value instanceof Closure) { + $value = $this->parseClosure($query, $value); + } elseif ($value instanceof Raw) { + $value = $this->parseRaw($query, $value); + } + + if ('=' == $exp && is_null($value)) { + return $key . ' IS NULL'; + } + + return $key . ' ' . $exp . ' ' . $value; + } + + /** + * 时间范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseBetweenTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + if (is_string($value)) { + $value = explode(',', $value); + } + + return $key . ' ' . substr($exp, 0, -4) + . $this->parseDateTime($query, $value[0], $field, $bindType) + . ' AND ' + . $this->parseDateTime($query, $value[1], $field, $bindType); + } + + /** + * IN查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + abstract protected function parseIn(Query $query, string $key, string $exp, $value, $field, int $bindType): string; + + /** + * 闭包子查询. + * + * @param Query $query 查询对象 + * @param Closure $call + * @param bool $show + * + * @return string + */ + protected function parseClosure(Query $query, Closure $call, bool $show = true): string + { + $newQuery = $query->newQuery()->removeOption(); + $call($newQuery); + + return $newQuery->buildSql($show); + } + + /** + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $key + * @param int $bindType + * + * @return string + */ + abstract protected function parseDateTime(Query $query, $value, string $key, int $bindType): string; + + /** + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * + * @return string + */ + abstract protected function parseLimit(Query $query, string $limit): string; + + /** + * join分析. + * + * @param Query $query 查询对象 + * @param array $join + * + * @return string + */ + abstract protected function parseJoin(Query $query, array $join): string; + + /** + * order分析. + * + * @param Query $query 查询对象 + * @param array $order + * + * @return string + */ + abstract protected function parseOrder(Query $query, array $order): string; + + /** + * 分析Raw对象 + * + * @param Query $query 查询对象 + * @param Raw $raw Raw对象 + * + * @return string + */ + abstract protected function parseRaw(Query $query, Raw $raw): string; + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * + * @return string + */ + abstract protected function parseRand(Query $query): string; + + /** + * group分析. + * + * @param Query $query 查询对象 + * @param mixed $group + * + * @return string + */ + abstract protected function parseGroup(Query $query, string|array $group): string; + + /** + * having分析. + * + * @param Query $query 查询对象 + * @param string $having + * + * @return string + */ + abstract protected function parseHaving(Query $query, string $having): string; + + /** + * comment分析. + * + * @param Query $query 查询对象 + * @param string $comment + * + * @return string + */ + protected function parseComment(Query $query, string $comment): string + { + if (str_contains($comment, '*/')) { + $comment = strstr($comment, '*/', true); + } + + return !empty($comment) ? ' /* ' . $comment . ' */' : ''; + } + + /** + * distinct分析. + * + * @param Query $query 查询对象 + * @param mixed $distinct + * + * @return string + */ + abstract protected function parseDistinct(Query $query, bool $distinct): string; + + /** + * union分析. + * + * @param Query $query 查询对象 + * @param array $union + * + * @return string + */ + protected function parseUnion(Query $query, array $union): string + { + if (empty($union)) { + return ''; + } + + $type = $union['type']; + unset($union['type']); + + foreach ($union as $u) { + if ($u instanceof Closure) { + $sql[] = $type . ' ' . $this->parseClosure($query, $u); + } elseif (is_string($u)) { + $sql[] = $type . ' ( ' . $u . ' )'; + } + } + + return ' ' . implode(' ', $sql); + } + + /** + * index分析,可在操作链中指定需要强制使用的索引. + * + * @param Query $query 查询对象 + * @param mixed $index + * + * @return string + */ + abstract protected function parseForce(Query $query, string|array $index): string; + + /** + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * + * @return string + */ + abstract protected function parseLock(Query $query, bool|string $lock = false): string; + + /** + * 生成查询SQL. + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * + * @return string + */ + public function select(Query $query, bool $one = false): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%DISTINCT%', '%EXTRA%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'], + [ + $this->parseTable($query, $options['table']), + $this->parseDistinct($query, $options['distinct']), + $this->parseExtra($query, $options['extra']), + $this->parseField($query, $options['field'] ?? []), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseGroup($query, $options['group']), + $this->parseHaving($query, $options['having']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $one ? '1' : $options['limit']), + $this->parseUnion($query, $options['union']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + $this->parseForce($query, $options['force']), + ], + $this->selectSql + ); + } + + /** + * 生成Insert SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function insert(Query $query): string + { + $options = $query->getOptions(); + + // 分析并处理数据 + $data = $this->parseData($query, $options['data']); + if (empty($data)) { + return ''; + } + + $fields = array_keys($data); + $values = array_values($data); + + return str_replace( + ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $fields), + implode(' , ', $values), + $this->parseComment($query, $options['comment']), + ], + $this->insertSql + ); + } + + /** + * 生成insertall SQL. + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * + * @return string + */ + public function insertAll(Query $query, array $dataSet): string + { + $options = $query->getOptions(); + + // 获取绑定信息 + $bind = $query->getFieldsBindType(); + + // 获取合法的字段 + if (empty($options['field']) || '*' == $options['field']) { + $allowFields = array_keys($bind); + } else { + $allowFields = $options['field']; + } + + $fields = []; + $values = []; + + foreach ($dataSet as $k => $data) { + $data = $this->parseData($query, $data, $allowFields, $bind); + + $values[] = 'SELECT ' . implode(',', array_values($data)); + + if (!isset($insertFields)) { + $insertFields = array_keys($data); + } + } + + foreach ($insertFields as $field) { + $fields[] = $this->parseKey($query, $field); + } + + return str_replace( + ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], + [ + !empty($options['replace']) ? 'REPLACE' : 'INSERT', + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $fields), + implode(' UNION ALL ', $values), + $this->parseComment($query, $options['comment']), + ], + $this->insertAllSql + ); + } + + /** + * 生成slect insert SQL. + * + * @param Query $query 查询对象 + * @param array $fields 数据 + * @param string $table 数据表 + * + * @return string + */ + public function selectInsert(Query $query, array $fields, string $table): string + { + foreach ($fields as &$field) { + $field = $this->parseKey($query, $field, true); + } + + return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); + } + + /** + * 生成update SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function update(Query $query): string + { + $options = $query->getOptions(); + + $data = $this->parseData($query, $options['data']); + + if (empty($data)) { + return ''; + } + + $set = []; + foreach ($data as $key => $val) { + $set[] = $key . ' = ' . $val; + } + + return str_replace( + ['%TABLE%', '%EXTRA%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + implode(' , ', $set), + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->updateSql + ); + } + + /** + * 生成delete SQL. + * + * @param Query $query 查询对象 + * + * @return string + */ + public function delete(Query $query): string + { + $options = $query->getOptions(); + + return str_replace( + ['%TABLE%', '%EXTRA%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], + [ + $this->parseTable($query, $options['table']), + $this->parseExtra($query, $options['extra']), + !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', + $this->parseJoin($query, $options['join']), + $this->parseWhere($query, $options['where']), + $this->parseOrder($query, $options['order']), + $this->parseLimit($query, $options['limit']), + $this->parseLock($query, $options['lock']), + $this->parseComment($query, $options['comment']), + ], + $this->deleteSql + ); + } +} diff --git a/vendor/topthink/think-orm/src/db/BaseQuery.php b/vendor/topthink/think-orm/src/db/BaseQuery.php index 60aa21e..6f9d823 100644 --- a/vendor/topthink/think-orm/src/db/BaseQuery.php +++ b/vendor/topthink/think-orm/src/db/BaseQuery.php @@ -1,126 +1,149 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; +use Closure; +use Psr\SimpleCache\CacheInterface; use think\Collection; use think\db\exception\DataNotFoundException; use think\db\exception\DbException as Exception; use think\db\exception\ModelNotFoundException; use think\helper\Str; -use think\Model; use think\Paginator; /** - * 数据查询基础类 + * 数据查询基础类. */ abstract class BaseQuery { use concern\TimeFieldQuery; use concern\AggregateQuery; use concern\ModelRelationQuery; + use concern\ParamsBind; use concern\ResultOperation; use concern\Transaction; use concern\WhereQuery; /** * 当前数据库连接对象 + * * @var Connection */ protected $connection; /** - * 当前数据表名称(不含前缀) + * 当前数据表名称(不含前缀). + * * @var string */ protected $name = ''; /** - * 当前数据表主键 + * 当前数据表主键. + * * @var string|array */ protected $pk; /** - * 当前数据表自增主键 + * 当前数据表自增主键. + * * @var string */ protected $autoinc; /** * 当前数据表前缀 + * * @var string */ protected $prefix = ''; /** - * 当前查询参数 + * 当前查询参数. + * * @var array */ protected $options = []; /** - * 架构函数 - * @access public + * 架构函数. + * * @param ConnectionInterface $connection 数据库连接对象 */ public function __construct(ConnectionInterface $connection) { - $this->connection = $connection; - - $this->prefix = $this->connection->getConfig('prefix'); + $this->connection = $connection; + $this->prefix = $this->connection->getConfig('prefix'); } /** - * 利用__call方法实现一些特殊的Model方法 - * @access public + * 利用__call方法实现一些特殊的Model方法. + * * @param string $method 方法名称 * @param array $args 调用参数 - * @return mixed + * * @throws Exception + * + * @return mixed */ public function __call(string $method, array $args) { if (strtolower(substr($method, 0, 5)) == 'getby') { // 根据某个字段获取记录 $field = Str::snake(substr($method, 5)); + return $this->where($field, '=', $args[0])->find(); - } elseif (strtolower(substr($method, 0, 10)) == 'getfieldby') { + } + + if (strtolower(substr($method, 0, 10)) == 'getfieldby') { // 根据某个字段获取记录的某个值 $name = Str::snake(substr($method, 10)); + return $this->where($name, '=', $args[0])->value($args[1]); - } elseif (strtolower(substr($method, 0, 7)) == 'whereor') { + } + + if (strtolower(substr($method, 0, 7)) == 'whereor') { $name = Str::snake(substr($method, 7)); array_unshift($args, $name); + return call_user_func_array([$this, 'whereOr'], $args); - } elseif (strtolower(substr($method, 0, 5)) == 'where') { + } + + if (strtolower(substr($method, 0, 5)) == 'where') { $name = Str::snake(substr($method, 5)); array_unshift($args, $name); + return call_user_func_array([$this, 'where'], $args); - } elseif ($this->model && method_exists($this->model, 'scope' . $method)) { + } + + if ($this->model && method_exists($this->model, 'scope' . $method)) { // 动态调用命名范围 $method = 'scope' . $method; array_unshift($args, $this); call_user_func_array([$this->model, $method], $args); + return $this; - } else { - throw new Exception('method not exist:' . static::class . '->' . $method); } + + throw new Exception('method not exist:' . static::class . '->' . $method); } /** * 创建一个新的查询对象 - * @access public + * * @return BaseQuery */ public function newQuery(): BaseQuery @@ -145,12 +168,16 @@ abstract class BaseQuery $query->setFieldType($this->options['field_type']); } + if (isset($this->options['lazy_fields'])) { + $query->lazyFields($this->options['lazy_fields']); + } + return $query; } /** * 获取当前的数据库Connection对象 - * @access public + * * @return ConnectionInterface */ public function getConnection() @@ -159,20 +186,22 @@ abstract class BaseQuery } /** - * 指定当前数据表名(不含前缀) - * @access public + * 指定当前数据表名(不含前缀). + * * @param string $name 不含前缀的数据表名字 + * * @return $this */ public function name(string $name) { $this->name = $name; + return $this; } /** - * 获取当前的数据表名称 - * @access public + * 获取当前的数据表名称. + * * @return string */ public function getName(): string @@ -181,9 +210,45 @@ abstract class BaseQuery } /** - * 获取数据库的配置参数 - * @access public + * 设置主键值. + * + * @param mixed $key 主键值 + * + * @return $this + */ + public function setKey($key) + { + $this->options['key'] = $key; + + return $this; + } + + /** + * 获取主键值. + * @param array $data 数据 + * + * @return mixed + */ + public function getKey(array $data = []) + { + if (!empty($data)) { + $pk = $this->getPk(); + if (is_string($pk) && isset($data[$pk])) { + $id = $data[$pk]; + } else { + $id = null; + } + return $id; + } + + return $this->getOptions('key'); + } + + /** + * 获取数据库的配置参数. + * * @param string $name 参数名称 + * * @return mixed */ public function getConfig(string $name = '') @@ -192,9 +257,10 @@ abstract class BaseQuery } /** - * 得到当前或者指定名称的数据表 - * @access public + * 得到当前或者指定名称的数据表. + * * @param string $name 不含前缀的数据表名字 + * * @return mixed */ public function getTable(string $name = '') @@ -209,20 +275,22 @@ abstract class BaseQuery } /** - * 设置字段类型信息 - * @access public + * 设置字段类型信息. + * * @param array $type 字段类型信息 + * * @return $this */ public function setFieldType(array $type) { $this->options['field_type'] = $type; + return $this; } /** - * 获取最近一次查询的sql语句 - * @access public + * 获取最近一次查询的sql语句. + * * @return string */ public function getLastSql(): string @@ -231,9 +299,9 @@ abstract class BaseQuery } /** - * 获取返回或者影响的记录数 - * @access public - * @return integer + * 获取返回或者影响的记录数. + * + * @return int */ public function getNumRows(): int { @@ -241,9 +309,10 @@ abstract class BaseQuery } /** - * 获取最近插入的ID - * @access public + * 获取最近插入的ID. + * * @param string $sequence 自增序列名 + * * @return mixed */ public function getLastInsID(string $sequence = null) @@ -253,9 +322,10 @@ abstract class BaseQuery /** * 得到某个字段的值 - * @access public + * * @param string $field 字段名 * @param mixed $default 默认值 + * * @return mixed */ public function value(string $field, $default = null) @@ -269,13 +339,14 @@ abstract class BaseQuery } /** - * 得到某个列的数组 - * @access public + * 得到某个列的数组. + * * @param string|array $field 字段名 多个字段用逗号分隔 * @param string $key 索引 + * * @return array */ - public function column($field, string $key = ''): array + public function column(string|array $field, string $key = ''): array { $result = $this->connection->column($this, $field, $key); @@ -287,13 +358,14 @@ abstract class BaseQuery } /** - * 查询SQL组装 union - * @access public - * @param mixed $union UNION - * @param boolean $all 是否适用UNION ALL + * 查询SQL组装 union. + * + * @param string|array|Closure $union UNION + * @param bool $all 是否适用UNION ALL + * * @return $this */ - public function union($union, bool $all = false) + public function union(string|array|Closure $union, bool $all = false) { $this->options['union']['type'] = $all ? 'UNION ALL' : 'UNION'; @@ -307,28 +379,31 @@ abstract class BaseQuery } /** - * 查询SQL组装 union all - * @access public + * 查询SQL组装 union all. + * * @param mixed $union UNION数据 + * * @return $this */ - public function unionAll($union) + public function unionAll(string|array|Closure $union) { return $this->union($union, true); } /** - * 指定查询字段 - * @access public - * @param mixed $field 字段信息 + * 指定查询字段. + * + * @param string|array|Raw|true $field 字段信息 + * * @return $this */ - public function field($field) + public function field(string|array|Raw|bool $field) { if (empty($field)) { return $this; } elseif ($field instanceof Raw) { $this->options['field'][] = $field; + return $this; } @@ -356,12 +431,13 @@ abstract class BaseQuery } /** - * 指定要排除的查询字段 - * @access public + * 指定要排除的查询字段. + * * @param array|string $field 要排除的字段 + * * @return $this */ - public function withoutField($field) + public function withoutField(array|string $field) { if (empty($field)) { return $this; @@ -385,15 +461,16 @@ abstract class BaseQuery } /** - * 指定其它数据表的查询字段 - * @access public - * @param mixed $field 字段信息 - * @param string $tableName 数据表名 - * @param string $prefix 字段前缀 - * @param string $alias 别名前缀 + * 指定其它数据表的查询字段. + * + * @param string|array|true $field 字段信息 + * @param string $tableName 数据表名 + * @param string $prefix 字段前缀 + * @param string $alias 别名前缀 + * * @return $this */ - public function tableField($field, string $tableName, string $prefix = '', string $alias = '') + public function tableField(string|array|bool $field, string $tableName, string $prefix = '', string $alias = '') { if (empty($field)) { return $this; @@ -430,9 +507,10 @@ abstract class BaseQuery } /** - * 设置数据 - * @access public + * 设置数据. + * * @param array $data 数据 + * * @return $this */ public function data(array $data) @@ -443,16 +521,17 @@ abstract class BaseQuery } /** - * 去除查询参数 - * @access public + * 去除查询参数. + * * @param string $option 参数名 留空去除所有参数 + * * @return $this */ public function removeOption(string $option = '') { if ('' === $option) { - $this->options = []; - $this->bind = []; + $this->options = []; + $this->bind = []; } elseif (isset($this->options[$option])) { unset($this->options[$option]); } @@ -461,10 +540,11 @@ abstract class BaseQuery } /** - * 指定查询数量 - * @access public + * 指定查询数量. + * * @param int $offset 起始位置 * @param int $length 查询数量 + * * @return $this */ public function limit(int $offset, int $length = null) @@ -475,10 +555,11 @@ abstract class BaseQuery } /** - * 指定分页 - * @access public + * 指定分页. + * * @param int $page 页数 * @param int $listRows 每页数量 + * * @return $this */ public function page(int $page, int $listRows = null) @@ -489,70 +570,97 @@ abstract class BaseQuery } /** - * 指定当前操作的数据表 - * @access public - * @param mixed $table 表名 + * 指定当前操作的数据表. + * + * @param string|array|Raw $table 表名 + * * @return $this */ - public function table($table) + public function table(string|array|Raw $table) { - if (is_string($table)) { - if (strpos($table, ')')) { - // 子查询 - } elseif (false === strpos($table, ',')) { - if (strpos($table, ' ')) { - [$item, $alias] = explode(' ', $table); - $table = []; - $this->alias([$item => $alias]); - $table[$item] = $alias; - } - } else { - $tables = explode(',', $table); - $table = []; - - foreach ($tables as $item) { - $item = trim($item); - if (strpos($item, ' ')) { - [$item, $alias] = explode(' ', $item); - $this->alias([$item => $alias]); - $table[$item] = $alias; - } else { - $table[] = $item; - } - } - } + if (is_string($table) && !str_contains($table, ')')) { + $table = $this->tableStr($table); } elseif (is_array($table)) { - $tables = $table; - $table = []; - - foreach ($tables as $key => $val) { - if (is_numeric($key)) { - $table[] = $val; - } else { - $this->alias([$key => $val]); - $table[$key] = $val; - } - } + $table = $this->tableArr($table); } $this->options['table'] = $table; - return $this; } /** - * 指定排序 order('id','desc') 或者 order(['id'=>'desc','create_time'=>'desc']) - * @access public + * 指定数据表(字符串). + * + * @param string $table 表名 + * + * @return array|string + */ + protected function tableStr(string $table): array|string + { + if (!str_contains($table, ',')) { + // 单表 + if (str_contains($table, ' ')) { + [$item, $alias] = explode(' ', $table); + $table = []; + $this->alias([$item => $alias]); + $table[$item] = $alias; + } + } else { + // 多表 + $tables = explode(',', $table); + $table = []; + + foreach ($tables as $item) { + $item = trim($item); + if (str_contains($item, ' ')) { + [$item, $alias] = explode(' ', $item); + $this->alias([$item => $alias]); + $table[$item] = $alias; + } else { + $table[] = $item; + } + } + } + return $table; + } + + /** + * 指定多个数据表(数组格式). + * + * @param array $tables 表名列表 + * + * @return array + */ + protected function tableArr(array $tables): array + { + $table = []; + foreach ($tables as $key => $val) { + if (is_numeric($key)) { + $table[] = $val; + } else { + $this->alias([$key => $val]); + $table[$key] = $val; + } + } + + return $table; + } + + /** + * 指定排序 order('id','desc') 或者 order(['id'=>'desc','create_time'=>'desc']). + * * @param string|array|Raw $field 排序字段 * @param string $order 排序 + * * @return $this */ - public function order($field, string $order = '') + public function order(string|array|Raw $field, string $order = '') { if (empty($field)) { return $this; } elseif ($field instanceof Raw) { $this->options['order'][] = $field; + return $this; } @@ -560,7 +668,7 @@ abstract class BaseQuery if (!empty($this->options['via'])) { $field = $this->options['via'] . '.' . $field; } - if (strpos($field, ',')) { + if (str_contains($field, ',')) { $field = array_map('trim', explode(',', $field)); } else { $field = empty($order) ? $field : [$field => $order]; @@ -590,14 +698,16 @@ abstract class BaseQuery } /** - * 分页查询 - * @access public + * 分页查询. + * * @param int|array $listRows 每页数量 数组表示配置参数 * @param int|bool $simple 是否简洁模式或者总记录数 - * @return Paginator + * * @throws Exception + * + * @return Paginator */ - public function paginate($listRows = null, $simple = false): Paginator + public function paginate(int|array $listRows = null, int|bool $simple = false): Paginator { if (is_int($simple)) { $total = $simple; @@ -612,17 +722,15 @@ abstract class BaseQuery ]; if (is_array($listRows)) { - $config = array_merge($defaultConfig, $listRows); - $listRows = intval($config['list_rows']); + $config = array_merge($defaultConfig, $listRows); + $listRows = intval($config['list_rows']); } else { - $config = $defaultConfig; - $listRows = intval($listRows ?: $config['list_rows']); + $config = $defaultConfig; + $listRows = intval($listRows ?: $config['list_rows']); } - $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); - - $page = $page < 1 ? 1 : $page; - + $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); + $page = max($page, 1); $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); if (!isset($total) && !$simple) { @@ -630,8 +738,8 @@ abstract class BaseQuery unset($this->options['order'], $this->options['cache'], $this->options['limit'], $this->options['page'], $this->options['field']); - $bind = $this->bind; - $total = $this->count(); + $bind = $this->bind; + $total = $this->count(); if ($total > 0) { $results = $this->options($options)->bind($bind)->page($page, $listRows)->select(); } else { @@ -642,10 +750,10 @@ abstract class BaseQuery } } } elseif ($simple) { - $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); - $total = null; + $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); + $total = null; } else { - $results = $this->page($page, $listRows)->select(); + $results = $this->page($page, $listRows)->select(); } $this->removeOption('limit'); @@ -655,15 +763,17 @@ abstract class BaseQuery } /** - * 根据数字类型字段进行分页查询(大数据) - * @access public + * 根据数字类型字段进行分页查询(大数据). + * * @param int|array $listRows 每页数量或者分页配置 * @param string $key 分页索引键 * @param string $sort 索引键排序 asc|desc - * @return Paginator + * * @throws Exception + * + * @return Paginator */ - public function paginateX($listRows = null, string $key = null, string $sort = null): Paginator + public function paginateX(int|array $listRows = null, string $key = null, string $sort = null): Paginator { $defaultConfig = [ 'query' => [], //url额外参数 @@ -672,15 +782,15 @@ abstract class BaseQuery 'list_rows' => 15, //每页数量 ]; - $config = is_array($listRows) ? array_merge($defaultConfig, $listRows) : $defaultConfig; - $listRows = is_int($listRows) ? $listRows : (int) $config['list_rows']; - $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); - $page = $page < 1 ? 1 : $page; + $config = is_array($listRows) ? array_merge($defaultConfig, $listRows) : $defaultConfig; + $listRows = is_int($listRows) ? $listRows : (int) $config['list_rows']; + $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); + $page = max($page, 1); $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); - $key = $key ?: $this->getPk(); - $options = $this->getOptions(); + $key = $key ?: $this->getPk(); + $options = $this->getOptions(); if (is_null($sort)) { $order = $options['order'] ?? ''; @@ -725,16 +835,18 @@ abstract class BaseQuery } /** - * 根据最后ID查询更多N个数据 - * @access public + * 根据最后ID查询更多N个数据. + * * @param int $limit LIMIT * @param int|string $lastId LastId * @param string $key 分页索引键 默认为主键 * @param string $sort 索引键排序 asc|desc - * @return array + * * @throws Exception + * + * @return array */ - public function more(int $limit, $lastId = null, string $key = null, string $sort = null): array + public function more(int $limit, int|string $lastId = null, string $key = null, string $sort = null): array { $key = $key ?: $this->getPk(); @@ -765,16 +877,27 @@ abstract class BaseQuery } /** - * 查询缓存 数据为空不缓存 - * @access public - * @param mixed $key 缓存key - * @param integer|\DateTime $expire 缓存有效期 - * @param string|array $tag 缓存标签 + * 获取当前的缓存对象 + * + * @return CacheInterface|null + */ + public function getCache() + { + return $this->getConnection()->getCache(); + } + + /** + * 查询缓存 数据为空不缓存. + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * * @return $this */ public function cache($key = true, $expire = null, $tag = null) { - if (false === $key || !$this->getConnection()->getCache()) { + if (false === $key || !$this->getCache()) { return $this; } @@ -784,21 +907,21 @@ abstract class BaseQuery } $this->options['cache'] = [$key, $expire, $tag ?: $this->getTable()]; - return $this; } /** - * 查询缓存 允许缓存空数据 - * @access public - * @param mixed $key 缓存key - * @param integer|\DateTime $expire 缓存有效期 - * @param string|array $tag 缓存标签 + * 查询缓存 允许缓存空数据. + * + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string|array $tag 缓存标签 + * * @return $this */ public function cacheAlways($key = true, $expire = null, $tag = null) { - $this->options['cache_always'] = true; + $this->options['cache_always'] = true; return $this->cache($key, $expire, $tag); } @@ -813,17 +936,19 @@ abstract class BaseQuery */ public function cacheForce($key = true, $expire = null, $tag = null) { - $this->options['force_cache'] = true; + $this->options['force_cache'] = true; + return $this->cache($key, $expire, $tag); } /** - * 指定查询lock - * @access public + * 指定查询lock. + * * @param bool|string $lock 是否lock + * * @return $this */ - public function lock($lock = false) + public function lock(bool|string $lock = false) { $this->options['lock'] = $lock; @@ -835,12 +960,13 @@ abstract class BaseQuery } /** - * 指定数据表别名 - * @access public + * 指定数据表别名. + * * @param array|string $alias 数据表别名 + * * @return $this */ - public function alias($alias) + public function alias(array|string $alias) { if (is_array($alias)) { $this->options['alias'] = $alias; @@ -854,84 +980,110 @@ abstract class BaseQuery } /** - * 设置从主服务器读取数据 - * @access public + * 设置从主服务器读取数据. + * * @param bool $readMaster 是否从主服务器读取 + * * @return $this */ public function master(bool $readMaster = true) { $this->options['master'] = $readMaster; + return $this; } /** - * 设置是否严格检查字段名 - * @access public + * 设置是否严格检查字段名. + * * @param bool $strict 是否严格检查字段 + * * @return $this */ public function strict(bool $strict = true) { $this->options['strict'] = $strict; + return $this; } /** - * 设置自增序列名 - * @access public + * 设置自增序列名. + * * @param string $sequence 自增序列名 + * * @return $this */ public function sequence(string $sequence = null) { $this->options['sequence'] = $sequence; + return $this; } /** - * 设置JSON字段信息 - * @access public + * 设置JSON字段信息. + * * @param array $json JSON字段 * @param bool $assoc 是否取出数组 + * * @return $this */ public function json(array $json = [], bool $assoc = false) { - $this->options['json'] = $json; - $this->options['json_assoc'] = $assoc; + $this->options['json'] = $json; + $this->options['json_assoc'] = $assoc; return $this; } /** - * 指定数据表主键 - * @access public - * @param string|array $pk 主键 + * 设置延迟写入字段 用于实时获取缓存数据 + * + * @param array $fields 延迟写入字段 + * * @return $this */ - public function pk($pk) + public function lazyFields(array $fields) + { + $this->options['lazy_fields'] = $fields; + + return $this; + } + + /** + * 指定数据表主键. + * + * @param string|array|bool $pk 主键 + * + * @return $this + */ + public function pk(string|array|bool $pk) { $this->pk = $pk; + return $this; } /** * 查询参数批量赋值 - * @access protected + * * @param array $options 表达式参数 + * * @return $this */ protected function options(array $options) { $this->options = $options; + return $this; } /** - * 获取当前的查询参数 - * @access public + * 获取当前的查询参数. + * * @param string $name 参数名 + * * @return mixed */ public function getOptions(string $name = '') @@ -944,22 +1096,25 @@ abstract class BaseQuery } /** - * 设置当前的查询参数 - * @access public + * 设置当前的查询参数. + * * @param string $option 参数名 * @param mixed $value 参数值 + * * @return $this */ public function setOption(string $option, $value) { $this->options[$option] = $value; + return $this; } /** - * 设置当前字段添加的表别名 - * @access public + * 设置当前字段添加的表别名. + * * @param string $via 临时表别名 + * * @return $this */ public function via(string $via = '') @@ -970,11 +1125,12 @@ abstract class BaseQuery } /** - * 保存记录 自动判断insert或者update - * @access public + * 保存记录 自动判断insert或者update. + * * @param array $data 数据 * @param bool $forceInsert 是否强制insert - * @return integer + * + * @return int */ public function save(array $data = [], bool $forceInsert = false) { @@ -994,11 +1150,12 @@ abstract class BaseQuery } /** - * 插入记录 - * @access public - * @param array $data 数据 - * @param boolean $getLastInsID 返回自增主键 - * @return integer|string + * 插入记录. + * + * @param array $data 数据 + * @param bool $getLastInsID 返回自增主键 + * + * @return int|string */ public function insert(array $data = [], bool $getLastInsID = false) { @@ -1010,10 +1167,11 @@ abstract class BaseQuery } /** - * 插入记录并获取自增ID - * @access public + * 插入记录并获取自增ID. + * * @param array $data 数据 - * @return integer|string + * + * @return int|string */ public function insertGetId(array $data) { @@ -1021,11 +1179,12 @@ abstract class BaseQuery } /** - * 批量插入记录 - * @access public - * @param array $dataSet 数据集 - * @param integer $limit 每次写入数据限制 - * @return integer + * 批量插入记录. + * + * @param array $dataSet 数据集 + * @param int $limit 每次写入数据限制 + * + * @return int */ public function insertAll(array $dataSet = [], int $limit = 0): int { @@ -1033,11 +1192,11 @@ abstract class BaseQuery $dataSet = $this->options['data'] ?? []; } - if (empty($limit) && !empty($this->options['limit']) && is_numeric($this->options['limit'])) { - $limit = (int) $this->options['limit']; + if ($limit) { + $this->limit($limit); } - return $this->connection->insertAll($this, $dataSet, $limit); + return $this->connection->insertAll($this, $dataSet); } /** @@ -1050,19 +1209,20 @@ abstract class BaseQuery */ public function insertAllByKeys(array $keys, array $values, int $limit = 0): int { - if (empty($limit) && !empty($this->options['limit']) && is_numeric($this->options['limit'])) { - $limit = (int) $this->options['limit']; + if ($limit) { + $this->limit($limit); } - return $this->connection->insertAllByKeys($this, $keys, $values, $limit); + return $this->connection->insertAllByKeys($this, $keys, $values); } /** - * 通过Select方式插入记录 - * @access public + * 通过Select方式插入记录. + * * @param array $fields 要插入的数据表字段名 * @param string $table 要插入的数据表名 - * @return integer + * + * @return int */ public function selectInsert(array $fields, string $table): int { @@ -1070,11 +1230,13 @@ abstract class BaseQuery } /** - * 更新记录 - * @access public - * @param mixed $data 数据 - * @return integer + * 更新记录. + * + * @param array $data 数据 + * * @throws Exception + * + * @return int */ public function update(array $data = []): int { @@ -1099,11 +1261,13 @@ abstract class BaseQuery } /** - * 删除记录 - * @access public + * 删除记录. + * * @param mixed $data 表达式 true 表示强制删除 - * @return int + * * @throws Exception + * + * @return int */ public function delete($data = null): int { @@ -1138,17 +1302,19 @@ abstract class BaseQuery } /** - * 查找记录 - * @access public - * @param mixed $data 数据 - * @return Collection|array|static[] + * 查找记录. + * + * @param array $data 主键数据 + * * @throws Exception * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return Collection|array|static[] */ - public function select($data = null): Collection + public function select(array $data = []): Collection { - if (!is_null($data)) { + if (!empty($data)) { // 主键条件分析 $this->parsePkWhere($data); } @@ -1172,13 +1338,15 @@ abstract class BaseQuery } /** - * 查找单条记录 - * @access public - * @param mixed $data 查询数据 - * @return array|Model|null|static|mixed + * 查找单条记录. + * + * @param mixed $data 主键数据 + * * @throws Exception * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return mixed */ public function find($data = null) { @@ -1209,8 +1377,8 @@ abstract class BaseQuery } /** - * 分析表达式(可用于查询或者写入操作) - * @access public + * 分析表达式(可用于查询或者写入操作). + * * @return array */ public function parseOptions(): array @@ -1254,10 +1422,12 @@ abstract class BaseQuery if (isset($options['page'])) { // 根据页数计算limit [$page, $listRows] = $options['page']; - $page = $page > 0 ? $page : 1; - $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); - $offset = $listRows * ($page - 1); - $options['limit'] = $offset . ',' . $listRows; + + $page = $page > 0 ? $page : 1; + $listRows = $listRows ?: (is_numeric($options['limit']) ? $options['limit'] : 20); + $offset = $listRows * ($page - 1); + + $options['limit'] = $offset . ',' . $listRows; } $this->options = $options; @@ -1266,15 +1436,17 @@ abstract class BaseQuery } /** - * 分析数据是否存在更新条件 - * @access public + * 分析数据是否存在更新条件. + * * @param array $data 数据 - * @return bool + * * @throws Exception + * + * @return bool */ - public function parseUpdateData(&$data): bool + public function parseUpdateData(array &$data): bool { - $pk = $this->getPk(); + $pk = $this->getPk(); $isUpdate = false; // 如果存在主键数据 则自动作为更新条件 if (is_string($pk) && isset($data[$pk])) { @@ -1299,42 +1471,46 @@ abstract class BaseQuery } /** - * 把主键值转换为查询条件 支持复合主键 - * @access public - * @param array|string $data 主键数据 - * @return void + * 把主键值转换为查询条件 支持复合主键. + * + * @param mixed $data 主键数据 + * * @throws Exception + * + * @return void */ public function parsePkWhere($data): void { $pk = $this->getPk(); - if (is_string($pk)) { - // 获取数据表 - if (empty($this->options['table'])) { - $this->options['table'] = $this->getTable(); - } + if (!is_string($pk)) { + return; + } - $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table']; + // 获取数据表 + if (empty($this->options['table'])) { + $this->options['table'] = $this->getTable(); + } - if (!empty($this->options['alias'][$table])) { - $alias = $this->options['alias'][$table]; - } + $table = is_array($this->options['table']) ? key($this->options['table']) : $this->options['table']; - $key = isset($alias) ? $alias . '.' . $pk : $pk; - // 根据主键查询 - if (is_array($data)) { - $this->where($key, 'in', $data); - } else { - $this->where($key, '=', $data); - $this->options['key'] = $data; - } + if (!empty($this->options['alias'][$table])) { + $alias = $this->options['alias'][$table]; + } + + $key = isset($alias) ? $alias . '.' . $pk : $pk; + // 根据主键查询 + if (is_array($data)) { + $this->where($key, 'in', $data); + } else { + $this->where($key, '=', $data); + $this->options['key'] = $data; } } /** - * 获取模型的更新条件 - * @access protected + * 获取模型的更新条件. + * * @param array $options 查询参数 */ protected function getModelUpdateCondition(array $options) diff --git a/vendor/topthink/think-orm/src/db/Builder.php b/vendor/topthink/think-orm/src/db/Builder.php index 2bde77c..898e465 100644 --- a/vendor/topthink/think-orm/src/db/Builder.php +++ b/vendor/topthink/think-orm/src/db/Builder.php @@ -1,125 +1,37 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; use Closure; -use PDO; +use Stringable; +use think\db\BaseQuery as Query; use think\db\exception\DbException as Exception; /** - * Db Builder + * Db Builder. */ -abstract class Builder +class Builder extends BaseBuilder { - /** - * Connection对象 - * @var ConnectionInterface - */ - protected $connection; /** - * 查询表达式映射 - * @var array - */ - protected $exp = ['NOTLIKE' => 'NOT LIKE', 'NOTIN' => 'NOT IN', 'NOTBETWEEN' => 'NOT BETWEEN', 'NOTEXISTS' => 'NOT EXISTS', 'NOTNULL' => 'NOT NULL', 'NOTBETWEEN TIME' => 'NOT BETWEEN TIME']; - - /** - * 查询表达式解析 - * @var array - */ - protected $parser = [ - 'parseCompare' => ['=', '<>', '>', '>=', '<', '<='], - 'parseLike' => ['LIKE', 'NOT LIKE'], - 'parseBetween' => ['NOT BETWEEN', 'BETWEEN'], - 'parseIn' => ['NOT IN', 'IN'], - 'parseExp' => ['EXP'], - 'parseNull' => ['NOT NULL', 'NULL'], - 'parseBetweenTime' => ['BETWEEN TIME', 'NOT BETWEEN TIME'], - 'parseTime' => ['< TIME', '> TIME', '<= TIME', '>= TIME'], - 'parseExists' => ['NOT EXISTS', 'EXISTS'], - 'parseColumn' => ['COLUMN'], - ]; - - /** - * SELECT SQL表达式 - * @var string - */ - protected $selectSql = 'SELECT%DISTINCT%%EXTRA% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT% %LOCK%%COMMENT%'; - - /** - * INSERT SQL表达式 - * @var string - */ - protected $insertSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; - - /** - * INSERT ALL SQL表达式 - * @var string - */ - protected $insertAllSql = '%INSERT%%EXTRA% INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; - - /** - * UPDATE SQL表达式 - * @var string - */ - protected $updateSql = 'UPDATE%EXTRA% %TABLE% SET %SET%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; - - /** - * DELETE SQL表达式 - * @var string - */ - protected $deleteSql = 'DELETE%EXTRA% FROM %TABLE%%USING%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; - - /** - * 架构函数 - * @access public - * @param ConnectionInterface $connection 数据库连接对象实例 - */ - public function __construct(ConnectionInterface $connection) - { - $this->connection = $connection; - } - - /** - * 获取当前的连接对象实例 - * @access public - * @return ConnectionInterface - */ - public function getConnection(): ConnectionInterface - { - return $this->connection; - } - - /** - * 注册查询表达式解析 - * @access public - * @param string $name 解析方法 - * @param array $parser 匹配表达式数据 - * @return $this - */ - public function bindParser(string $name, array $parser) - { - $this->parser[$name] = $parser; - return $this; - } - - /** - * 数据分析 - * @access protected - * @param Query $query 查询对象 - * @param array $data 数据 - * @param array $fields 字段信息 - * @param array $bind 参数绑定 + * 数据分析. + * + * @param Query $query 查询对象 + * @param array $data 数据 + * @param array $fields 字段信息 + * @param array $bind 参数绑定 + * * @return array */ protected function parseData(Query $query, array $data = [], array $fields = [], array $bind = []): array @@ -155,32 +67,29 @@ abstract class Builder $val = json_encode($val); } - if (false !== strpos($key, '->')) { - [$key, $name] = explode('->', $key, 2); - $item = $this->parseKey($query, $key); + if (str_contains($key, '->')) { + [$key, $name] = explode('->', $key, 2); + $item = $this->parseKey($query, $key); $result[$item . '->' . $name] = 'json_set(' . $item . ', \'$.' . $name . '\', ' . $this->parseDataBind($query, $key . '->' . $name, $val, $bind) . ')'; - } elseif (false === strpos($key, '.') && !in_array($key, $fields, true)) { + } elseif (!str_contains($key, '.') && !in_array($key, $fields, true)) { if ($options['strict']) { throw new Exception('fields not exists:[' . $key . ']'); } } elseif (is_null($val)) { $result[$item] = 'NULL'; } elseif (is_array($val) && !empty($val) && is_string($val[0])) { - switch (strtoupper($val[0])) { - case 'INC': - $result[$item] = $item . ' + ' . floatval($val[1]); - break; - case 'DEC': - $result[$item] = $item . ' - ' . floatval($val[1]); - break; + if (in_array(strtoupper($val[0]), ['INC', 'DEC'])) { + $result[$item] = match (strtoupper($val[0])) { + 'INC' => $item . ' + ' . floatval($val[1]), + 'DEC' => $item . ' - ' . floatval($val[1]), + }; } } elseif (is_scalar($val)) { // 过滤非标量数据 - if (!$query->isAutoBind() && PDO::PARAM_STR == $bind[$key]) { + if (!$query->isAutoBind() && Connection::PARAM_STR == $bind[$key]) { $val = '\'' . $val . '\''; } - $result[$item] = !$query->isAutoBind() ? $val : $this->parseDataBind($query, $key, $val, $bind); } } @@ -189,12 +98,13 @@ abstract class Builder } /** - * 数据绑定处理 - * @access protected - * @param Query $query 查询对象 - * @param string $key 字段名 - * @param mixed $data 数据 - * @param array $bind 绑定数据 + * 数据绑定处理. + * + * @param Query $query 查询对象 + * @param string $key 字段名 + * @param mixed $data 数据 + * @param array $bind 绑定数据 + * * @return string */ protected function parseDataBind(Query $query, string $key, $data, array $bind = []): string @@ -203,29 +113,31 @@ abstract class Builder return $this->parseRaw($query, $data); } - $name = $query->bindValue($data, $bind[$key] ?? PDO::PARAM_STR); + $name = $query->bindValue($data, $bind[$key] ?? Connection::PARAM_STR); return ':' . $name; } /** - * 字段名分析 - * @access public - * @param Query $query 查询对象 - * @param mixed $key 字段名 - * @param bool $strict 严格检测 + * 字段名分析. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { return $key; } /** - * 查询额外参数分析 - * @access protected - * @param Query $query 查询对象 - * @param string $extra 额外参数 + * 查询额外参数分析. + * + * @param Query $query 查询对象 + * @param string $extra 额外参数 + * * @return string */ protected function parseExtra(Query $query, string $extra): string @@ -234,15 +146,16 @@ abstract class Builder } /** - * field分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $fields 字段名 + * field分析. + * + * @param Query $query 查询对象 + * @param array $fields 字段名 + * * @return string */ - protected function parseField(Query $query, $fields): string + protected function parseField(Query $query, array $fields): string { - if (is_array($fields)) { + if (!empty($fields)) { // 支持 'field1'=>'field2' 这样的字段别名定义 $array = []; @@ -265,15 +178,16 @@ abstract class Builder } /** - * table分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $tables 表名 + * table分析. + * + * @param Query $query 查询对象 + * @param array|string $tables 表名 + * * @return string */ - protected function parseTable(Query $query, $tables): string + protected function parseTable(Query $query, array|string $tables): string { - $item = []; + $item = []; $options = $query->getOptions(); foreach ((array) $tables as $key => $table) { @@ -292,22 +206,23 @@ abstract class Builder } /** - * where分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $where 查询条件 + * where分析. + * + * @param Query $query 查询对象 + * @param array $where 查询条件 + * * @return string */ protected function parseWhere(Query $query, array $where): string { - $options = $query->getOptions(); + $options = $query->getOptions(); $whereStr = $this->buildWhere($query, $where); if (!empty($options['soft_delete'])) { // 附加软删除条件 [$field, $condition] = $options['soft_delete']; - $binds = $query->getFieldsBindType(); + $binds = $query->getFieldsBindType(); $whereStr = $whereStr ? '( ' . $whereStr . ' ) AND ' : ''; $whereStr = $whereStr . $this->parseWhereItem($query, $field, $condition, $binds); } @@ -316,178 +231,13 @@ abstract class Builder } /** - * 生成查询条件SQL - * @access public - * @param Query $query 查询对象 - * @param mixed $where 查询条件 - * @return string - */ - public function buildWhere(Query $query, array $where): string - { - if (empty($where)) { - $where = []; - } - - $whereStr = ''; - - $binds = $query->getFieldsBindType(); - - foreach ($where as $logic => $val) { - $str = $this->parseWhereLogic($query, $logic, $val, $binds); - - $whereStr .= empty($whereStr) ? substr(implode(' ', $str), strlen($logic) + 1) : implode(' ', $str); - } - - return $whereStr; - } - - /** - * 不同字段使用相同查询条件(AND) - * @access protected - * @param Query $query 查询对象 - * @param string $logic Logic - * @param array $val 查询条件 - * @param array $binds 参数绑定 - * @return array - */ - protected function parseWhereLogic(Query $query, string $logic, array $val, array $binds = []): array - { - $where = []; - foreach ($val as $value) { - if ($value instanceof Raw) { - $where[] = ' ' . $logic . ' ( ' . $this->parseRaw($query, $value) . ' )'; - continue; - } - - if (is_array($value)) { - if (key($value) !== 0) { - throw new Exception('where express error:' . var_export($value, true)); - } - $field = array_shift($value); - } elseif (true === $value) { - $where[] = ' ' . $logic . ' 1 '; - continue; - } elseif (!($value instanceof Closure)) { - throw new Exception('where express error:' . var_export($value, true)); - } - - if ($value instanceof Closure) { - // 使用闭包查询 - $whereClosureStr = $this->parseClosureWhere($query, $value, $logic); - if ($whereClosureStr) { - $where[] = $whereClosureStr; - } - } elseif (is_array($field)) { - $where[] = $this->parseMultiWhereField($query, $value, $field, $logic, $binds); - } elseif ($field instanceof Raw) { - $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); - } elseif (strpos($field, '|')) { - $where[] = $this->parseFieldsOr($query, $value, $field, $logic, $binds); - } elseif (strpos($field, '&')) { - $where[] = $this->parseFieldsAnd($query, $value, $field, $logic, $binds); - } else { - // 对字段使用表达式查询 - $field = is_string($field) ? $field : ''; - $where[] = ' ' . $logic . ' ' . $this->parseWhereItem($query, $field, $value, $binds); - } - } - - return $where; - } - - /** - * 不同字段使用相同查询条件(AND) - * @access protected - * @param Query $query 查询对象 - * @param mixed $value 查询条件 - * @param string $field 查询字段 - * @param string $logic Logic - * @param array $binds 参数绑定 - * @return string - */ - protected function parseFieldsAnd(Query $query, $value, string $field, string $logic, array $binds): string - { - $item = []; - - foreach (explode('&', $field) as $k) { - $item[] = $this->parseWhereItem($query, $k, $value, $binds); - } - - return ' ' . $logic . ' ( ' . implode(' AND ', $item) . ' )'; - } - - /** - * 不同字段使用相同查询条件(OR) - * @access protected - * @param Query $query 查询对象 - * @param mixed $value 查询条件 - * @param string $field 查询字段 - * @param string $logic Logic - * @param array $binds 参数绑定 - * @return string - */ - protected function parseFieldsOr(Query $query, $value, string $field, string $logic, array $binds): string - { - $item = []; - - foreach (explode('|', $field) as $k) { - $item[] = $this->parseWhereItem($query, $k, $value, $binds); - } - - return ' ' . $logic . ' ( ' . implode(' OR ', $item) . ' )'; - } - - /** - * 闭包查询 - * @access protected - * @param Query $query 查询对象 - * @param Closure $value 查询条件 - * @param string $logic Logic - * @return string - */ - protected function parseClosureWhere(Query $query, Closure $value, string $logic): string - { - $newQuery = $query->newQuery(); - $value($newQuery); - $whereClosure = $this->buildWhere($newQuery, $newQuery->getOptions('where') ?: []); - - if (!empty($whereClosure)) { - $query->bind($newQuery->getBind(false)); - $where = ' ' . $logic . ' ( ' . $whereClosure . ' )'; - } - - return $where ?? ''; - } - - /** - * 复合条件查询 - * @access protected - * @param Query $query 查询对象 - * @param mixed $value 查询条件 - * @param mixed $field 查询字段 - * @param string $logic Logic - * @param array $binds 参数绑定 - * @return string - */ - protected function parseMultiWhereField(Query $query, $value, $field, string $logic, array $binds): string - { - array_unshift($value, $field); - - $where = []; - foreach ($value as $item) { - $where[] = $this->parseWhereItem($query, array_shift($item), $item, $binds); - } - - return ' ' . $logic . ' ( ' . implode(' AND ', $where) . ' )'; - } - - /** - * where子单元分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $field 查询字段 - * @param array $val 查询条件 - * @param array $binds 参数绑定 + * where子单元分析. + * + * @param Query $query 查询对象 + * @param mixed $field 查询字段 + * @param array $val 查询条件 + * @param array $binds 参数绑定 + * * @return string */ protected function parseWhereItem(Query $query, $field, array $val, array $binds = []): string @@ -508,22 +258,21 @@ abstract class Builder } if (is_string($field) && 'LIKE' != $exp) { - $bindType = $binds[$field] ?? PDO::PARAM_STR; + $bindType = $binds[$field] ?? Connection::PARAM_STR; } else { - $bindType = PDO::PARAM_STR; + $bindType = Connection::PARAM_STR; } if ($value instanceof Raw) { - - } elseif (is_object($value) && method_exists($value, '__toString')) { + } elseif ($value instanceof Stringable) { // 对象数据写入 $value = $value->__toString(); } - if (is_scalar($value) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && strpos($exp, 'TIME') === false) { - if (is_string($value) && 0 === strpos($value, ':') && $query->isBind(substr($value, 1))) { + if (is_scalar($value) && !in_array($exp, ['EXP', 'NOT NULL', 'NULL', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN']) && !str_contains($exp, 'TIME')) { + if (is_string($value) && str_starts_with($value, ':') && $query->isBind(substr($value, 1))) { } else { - $name = $query->bindValue($value, $bindType); + $name = $query->bindValue($value, $bindType); $value = ':' . $name; } } @@ -539,15 +288,16 @@ abstract class Builder } /** - * 模糊查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param array $value - * @param string $field - * @param integer $bindType - * @param string $logic + * 模糊查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param array $value + * @param string $field + * @param int $bindType + * @param string $logic + * * @return string */ protected function parseLike(Query $query, string $key, string $exp, $value, $field, int $bindType, string $logic): string @@ -556,7 +306,7 @@ abstract class Builder if (is_array($value)) { $array = []; foreach ($value as $item) { - $name = $query->bindValue($item, PDO::PARAM_STR); + $name = $query->bindValue($item, Connection::PARAM_STR); $array[] = $key . ' ' . $exp . ' :' . $name; } @@ -569,14 +319,15 @@ abstract class Builder } /** - * 表达式查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param array $value - * @param string $field - * @param integer $bindType + * 表达式查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param Raw $value + * @param string $field + * @param int $bindType + * * @return string */ protected function parseExp(Query $query, string $key, string $exp, Raw $value, string $field, int $bindType): string @@ -586,37 +337,15 @@ abstract class Builder } /** - * 表达式查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param array $value - * @param string $field - * @param integer $bindType - * @return string - */ - protected function parseColumn(Query $query, string $key, $exp, array $value, string $field, int $bindType): string - { - // 字段比较查询 - [$op, $field] = $value; - - if (!in_array(trim($op), ['=', '<>', '>', '>=', '<', '<='])) { - throw new Exception('where express error:' . var_export($value, true)); - } - - return '( ' . $key . ' ' . $op . ' ' . $this->parseKey($query, $field, true) . ' )'; - } - - /** - * Null查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * * @return string */ protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string @@ -626,17 +355,18 @@ abstract class Builder } /** - * 范围查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType + * 范围查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * * @return string */ - protected function parseBetween(Query $query, string $key, string $exp, $value, $field, int $bindType): string + protected function parseBetween(Query $query, string $key, string $exp, array|string $value, $field, int $bindType): string { // BETWEEN 查询 $data = is_array($value) ? $value : explode(',', $value); @@ -648,110 +378,15 @@ abstract class Builder } /** - * Exists查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType - * @return string - */ - protected function parseExists(Query $query, string $key, string $exp, $value, string $field, int $bindType): string - { - // EXISTS 查询 - if ($value instanceof Closure) { - $value = $this->parseClosure($query, $value, false); - } elseif ($value instanceof Raw) { - $value = $this->parseRaw($query, $value); - } else { - throw new Exception('where express error:' . $value); - } - - return $exp . ' ( ' . $value . ' )'; - } - - /** - * 时间比较查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType - * @return string - */ - protected function parseTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string - { - return $key . ' ' . substr($exp, 0, 2) . ' ' . $this->parseDateTime($query, $value, $field, $bindType); - } - - /** - * 大小比较查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType - * @return string - */ - protected function parseCompare(Query $query, string $key, string $exp, $value, $field, int $bindType): string - { - if (is_array($value)) { - throw new Exception('where express error:' . $exp . var_export($value, true)); - } - - // 比较运算 - if ($value instanceof Closure) { - $value = $this->parseClosure($query, $value); - } elseif ($value instanceof Raw) { - $value = $this->parseRaw($query, $value); - } - - if ('=' == $exp && is_null($value)) { - return $key . ' IS NULL'; - } - - return $key . ' ' . $exp . ' ' . $value; - } - - /** - * 时间范围查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType - * @return string - */ - protected function parseBetweenTime(Query $query, string $key, string $exp, $value, $field, int $bindType): string - { - if (is_string($value)) { - $value = explode(',', $value); - } - - return $key . ' ' . substr($exp, 0, -4) - . $this->parseDateTime($query, $value[0], $field, $bindType) - . ' AND ' - . $this->parseDateTime($query, $value[1], $field, $bindType); - - } - - /** - * IN查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field - * @param integer $bindType + * IN查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * * @return string */ protected function parseIn(Query $query, string $key, string $exp, $value, $field, int $bindType): string @@ -774,13 +409,13 @@ abstract class Builder $array[] = ':' . $name; } $value = implode(',', $array); - } elseif (PDO::PARAM_STR == $bindType) { + } elseif (Connection::PARAM_STR == $bindType) { $value = '\'' . implode('\',\'', $value) . '\''; } else { $value = implode(',', $value); } - if (false === strpos($value, ',')) { + if (!str_contains($value, ',')) { return $key . ('IN' == $exp ? ' = ' : ' <> ') . $value; } } @@ -789,28 +424,13 @@ abstract class Builder } /** - * 闭包子查询 - * @access protected - * @param Query $query 查询对象 - * @param \Closure $call - * @param bool $show - * @return string - */ - protected function parseClosure(Query $query, Closure $call, bool $show = true): string - { - $newQuery = $query->newQuery()->removeOption(); - $call($newQuery); - - return $newQuery->buildSql($show); - } - - /** - * 日期时间条件解析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $value - * @param string $key - * @param integer $bindType + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $key + * @param int $bindType + * * @return string */ protected function parseDateTime(Query $query, $value, string $key, int $bindType): string @@ -818,7 +438,7 @@ abstract class Builder $options = $query->getOptions(); // 获取时间字段类型 - if (strpos($key, '.')) { + if (str_contains($key, '.')) { [$table, $key] = explode('.', $key); if (isset($options['alias']) && $pos = array_search($table, $options['alias'])) { @@ -852,22 +472,24 @@ abstract class Builder } /** - * limit分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $limit + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * * @return string */ protected function parseLimit(Query $query, string $limit): string { - return (!empty($limit) && false === strpos($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; + return (!empty($limit) && !str_contains($limit, '(')) ? ' LIMIT ' . $limit . ' ' : ''; } /** - * join分析 - * @access protected - * @param Query $query 查询对象 - * @param array $join + * join分析. + * + * @param Query $query 查询对象 + * @param array $join + * * @return string */ protected function parseJoin(Query $query, array $join): string @@ -877,7 +499,7 @@ abstract class Builder foreach ($join as $item) { [$table, $type, $on] = $item; - if (strpos($on, '=')) { + if (str_contains($on, '=')) { [$val1, $val2] = explode('=', $on, 2); $condition = $this->parseKey($query, $val1) . '=' . $this->parseKey($query, $val2); @@ -894,10 +516,11 @@ abstract class Builder } /** - * order分析 - * @access protected - * @param Query $query 查询对象 - * @param array $order + * order分析. + * + * @param Query $query 查询对象 + * @param array $order + * * @return string */ protected function parseOrder(Query $query, array $order): string @@ -912,14 +535,14 @@ abstract class Builder $array[] = $this->parseRand($query); } elseif (is_string($val)) { if (is_numeric($key)) { - [$key, $sort] = explode(' ', strpos($val, ' ') ? $val : $val . ' '); + [$key, $sort] = explode(' ', str_contains($val, ' ') ? $val : $val . ' '); } else { $sort = $val; } if (preg_match('/^[\w\.]+$/', $key)) { - $sort = strtoupper($sort); - $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; + $sort = strtoupper($sort); + $sort = in_array($sort, ['ASC', 'DESC'], true) ? ' ' . $sort : ''; $array[] = $this->parseKey($query, $key, true) . $sort; } else { throw new Exception('order express error:' . $key); @@ -932,15 +555,16 @@ abstract class Builder /** * 分析Raw对象 - * @access protected - * @param Query $query 查询对象 - * @param Raw $raw Raw对象 + * + * @param Query $query 查询对象 + * @param Raw $raw Raw对象 + * * @return string */ protected function parseRaw(Query $query, Raw $raw): string { - $sql = $raw->getValue(); - $bind = $raw->getBind(); + $sql = $raw->getValue(); + $bind = $raw->getBind(); if ($bind) { $query->bindParams($sql, $bind); @@ -950,9 +574,10 @@ abstract class Builder } /** - * 随机排序 - * @access protected - * @param Query $query 查询对象 + * 随机排序. + * + * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string @@ -961,11 +586,12 @@ abstract class Builder } /** - * orderField分析 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param array $val + * orderField分析. + * + * @param Query $query 查询对象 + * @param string $key + * @param array $val + * * @return string */ protected function parseOrderField(Query $query, string $key, array $val): string @@ -989,13 +615,14 @@ abstract class Builder } /** - * group分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $group + * group分析. + * + * @param Query $query 查询对象 + * @param mixed $group + * * @return string */ - protected function parseGroup(Query $query, $group): string + protected function parseGroup(Query $query, string|array $group): string { if (empty($group)) { return ''; @@ -1014,10 +641,11 @@ abstract class Builder } /** - * having分析 - * @access protected - * @param Query $query 查询对象 - * @param string $having + * having分析. + * + * @param Query $query 查询对象 + * @param string $having + * * @return string */ protected function parseHaving(Query $query, string $having): string @@ -1026,15 +654,16 @@ abstract class Builder } /** - * comment分析 - * @access protected - * @param Query $query 查询对象 - * @param string $comment + * comment分析. + * + * @param Query $query 查询对象 + * @param string $comment + * * @return string */ protected function parseComment(Query $query, string $comment): string { - if (false !== strpos($comment, '*/')) { + if (str_contains($comment, '*/')) { $comment = strstr($comment, '*/', true); } @@ -1042,10 +671,11 @@ abstract class Builder } /** - * distinct分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $distinct + * distinct分析. + * + * @param Query $query 查询对象 + * @param mixed $distinct + * * @return string */ protected function parseDistinct(Query $query, bool $distinct): string @@ -1054,60 +684,35 @@ abstract class Builder } /** - * union分析 - * @access protected - * @param Query $query 查询对象 - * @param array $union + * index分析,可在操作链中指定需要强制使用的索引. + * + * @param Query $query 查询对象 + * @param mixed $index + * * @return string */ - protected function parseUnion(Query $query, array $union): string - { - if (empty($union)) { - return ''; - } - - $type = $union['type']; - unset($union['type']); - - foreach ($union as $u) { - if ($u instanceof Closure) { - $sql[] = $type . ' ' . $this->parseClosure($query, $u); - } elseif (is_string($u)) { - $sql[] = $type . ' ( ' . $u . ' )'; - } - } - - return ' ' . implode(' ', $sql); - } - - /** - * index分析,可在操作链中指定需要强制使用的索引 - * @access protected - * @param Query $query 查询对象 - * @param mixed $index - * @return string - */ - protected function parseForce(Query $query, $index): string + protected function parseForce(Query $query, string|array $index): string { if (empty($index)) { return ''; } if (is_array($index)) { - $index = join(',', $index); + $index = implode(',', $index); } - return sprintf(" FORCE INDEX ( %s ) ", $index); + return sprintf(' FORCE INDEX ( %s ) ', $index); } /** - * 设置锁机制 - * @access protected - * @param Query $query 查询对象 - * @param bool|string $lock + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * * @return string */ - protected function parseLock(Query $query, $lock = false): string + protected function parseLock(Query $query, bool|string $lock = false): string { if (is_bool($lock)) { return $lock ? ' FOR UPDATE ' : ''; @@ -1115,135 +720,17 @@ abstract class Builder if (is_string($lock) && !empty($lock)) { return ' ' . trim($lock) . ' '; - } else { - return ''; } + return ''; } /** - * 生成查询SQL - * @access public - * @param Query $query 查询对象 - * @param bool $one 是否仅获取一个记录 - * @return string - */ - public function select(Query $query, bool $one = false): string - { - $options = $query->getOptions(); - - return str_replace( - ['%TABLE%', '%DISTINCT%', '%EXTRA%', '%FIELD%', '%JOIN%', '%WHERE%', '%GROUP%', '%HAVING%', '%ORDER%', '%LIMIT%', '%UNION%', '%LOCK%', '%COMMENT%', '%FORCE%'], - [ - $this->parseTable($query, $options['table']), - $this->parseDistinct($query, $options['distinct']), - $this->parseExtra($query, $options['extra']), - $this->parseField($query, $options['field'] ?? '*'), - $this->parseJoin($query, $options['join']), - $this->parseWhere($query, $options['where']), - $this->parseGroup($query, $options['group']), - $this->parseHaving($query, $options['having']), - $this->parseOrder($query, $options['order']), - $this->parseLimit($query, $one ? '1' : $options['limit']), - $this->parseUnion($query, $options['union']), - $this->parseLock($query, $options['lock']), - $this->parseComment($query, $options['comment']), - $this->parseForce($query, $options['force']), - ], - $this->selectSql - ); - } - - /** - * 生成Insert SQL - * @access public - * @param Query $query 查询对象 - * @return string - */ - public function insert(Query $query): string - { - $options = $query->getOptions(); - - // 分析并处理数据 - $data = $this->parseData($query, $options['data']); - if (empty($data)) { - return ''; - } - - $fields = array_keys($data); - $values = array_values($data); - - return str_replace( - ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], - [ - !empty($options['replace']) ? 'REPLACE' : 'INSERT', - $this->parseTable($query, $options['table']), - $this->parseExtra($query, $options['extra']), - implode(' , ', $fields), - implode(' , ', $values), - $this->parseComment($query, $options['comment']), - ], - $this->insertSql - ); - } - - /** - * 生成insertall SQL - * @access public - * @param Query $query 查询对象 - * @param array $dataSet 数据集 - * @return string - */ - public function insertAll(Query $query, array $dataSet): string - { - $options = $query->getOptions(); - - // 获取绑定信息 - $bind = $query->getFieldsBindType(); - - // 获取合法的字段 - if (empty($options['field']) || '*' == $options['field']) { - $allowFields = array_keys($bind); - } else { - $allowFields = $options['field']; - } - - $fields = []; - $values = []; - - foreach ($dataSet as $k => $data) { - $data = $this->parseData($query, $data, $allowFields, $bind); - - $values[] = 'SELECT ' . implode(',', array_values($data)); - - if (!isset($insertFields)) { - $insertFields = array_keys($data); - } - } - - foreach ($insertFields as $field) { - $fields[] = $this->parseKey($query, $field); - } - - return str_replace( - ['%INSERT%', '%TABLE%', '%EXTRA%', '%FIELD%', '%DATA%', '%COMMENT%'], - [ - !empty($options['replace']) ? 'REPLACE' : 'INSERT', - $this->parseTable($query, $options['table']), - $this->parseExtra($query, $options['extra']), - implode(' , ', $fields), - implode(' UNION ALL ', $values), - $this->parseComment($query, $options['comment']), - ], - $this->insertAllSql - ); - } - - /** - * 生成insertall SQL - * @access public - * @param Query $query 查询对象 + * 生成insertall SQL. + * + * @param Query $query 查询对象 * @param array $keys 字段名 * @param array $datas 数据 + * * @return string */ public function insertAllByKeys(Query $query, array $keys, array $datas): string @@ -1259,10 +746,10 @@ abstract class Builder $fields[] = $this->parseKey($query, $field); } - foreach ($datas as $data) { + foreach ($datas as $k => $data) { foreach ($data as $key => &$val) { if (!$query->isAutoBind()) { - $val = PDO::PARAM_STR == $bind[$keys[$key]] ? '\'' . $val . '\'' : $val; + $val = Connection::PARAM_STR == $bind[$keys[$key]] ? '\'' . $val . '\'' : $val; } else { $val = $this->parseDataBind($query, $keys[$key], $val, $bind); } @@ -1284,86 +771,4 @@ abstract class Builder $this->insertAllSql ); } - - /** - * 生成slect insert SQL - * @access public - * @param Query $query 查询对象 - * @param array $fields 数据 - * @param string $table 数据表 - * @return string - */ - public function selectInsert(Query $query, array $fields, string $table): string - { - foreach ($fields as &$field) { - $field = $this->parseKey($query, $field, true); - } - - return 'INSERT INTO ' . $this->parseTable($query, $table) . ' (' . implode(',', $fields) . ') ' . $this->select($query); - } - - /** - * 生成update SQL - * @access public - * @param Query $query 查询对象 - * @return string - */ - public function update(Query $query): string - { - $options = $query->getOptions(); - - $data = $this->parseData($query, $options['data']); - - if (empty($data)) { - return ''; - } - - $set = []; - foreach ($data as $key => $val) { - $set[] = $key . ' = ' . $val; - } - - return str_replace( - ['%TABLE%', '%EXTRA%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], - [ - $this->parseTable($query, $options['table']), - $this->parseExtra($query, $options['extra']), - implode(' , ', $set), - $this->parseJoin($query, $options['join']), - $this->parseWhere($query, $options['where']), - $this->parseOrder($query, $options['order']), - $this->parseLimit($query, $options['limit']), - $this->parseLock($query, $options['lock']), - $this->parseComment($query, $options['comment']), - ], - $this->updateSql - ); - } - - /** - * 生成delete SQL - * @access public - * @param Query $query 查询对象 - * @return string - */ - public function delete(Query $query): string - { - $options = $query->getOptions(); - - return str_replace( - ['%TABLE%', '%EXTRA%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'], - [ - $this->parseTable($query, $options['table']), - $this->parseExtra($query, $options['extra']), - !empty($options['using']) ? ' USING ' . $this->parseTable($query, $options['using']) . ' ' : '', - $this->parseJoin($query, $options['join']), - $this->parseWhere($query, $options['where']), - $this->parseOrder($query, $options['order']), - $this->parseLimit($query, $options['limit']), - $this->parseLock($query, $options['lock']), - $this->parseComment($query, $options['comment']), - ], - $this->deleteSql - ); - } } diff --git a/vendor/topthink/think-orm/src/db/CacheItem.php b/vendor/topthink/think-orm/src/db/CacheItem.php index 839f384..1499e1d 100644 --- a/vendor/topthink/think-orm/src/db/CacheItem.php +++ b/vendor/topthink/think-orm/src/db/CacheItem.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; @@ -18,36 +19,41 @@ use DateTimeInterface; use think\db\exception\InvalidArgumentException; /** - * CacheItem实现类 + * CacheItem实现类. */ class CacheItem { /** - * 缓存Key + * 缓存Key. + * * @var string */ protected $key; /** - * 缓存内容 + * 缓存内容. + * * @var mixed */ protected $value; /** - * 过期时间 + * 过期时间. + * * @var int|DateTimeInterface */ protected $expire; /** - * 缓存tag + * 缓存tag. + * * @var string */ protected $tag; /** - * 缓存是否命中 + * 缓存是否命中. + * * @var bool */ protected $isHit = false; @@ -58,20 +64,22 @@ class CacheItem } /** - * 为此缓存项设置「键」 - * @access public - * @param string $key + * 为此缓存项设置「键」. + * + * @param string $key + * * @return $this */ public function setKey(string $key) { $this->key = $key; + return $this; } /** - * 返回当前缓存项的「键」 - * @access public + * 返回当前缓存项的「键」. + * * @return string */ public function getKey() @@ -81,7 +89,7 @@ class CacheItem /** * 返回当前缓存项的有效期 - * @access public + * * @return DateTimeInterface|int|null */ public function getExpire() @@ -94,8 +102,8 @@ class CacheItem } /** - * 获取缓存Tag - * @access public + * 获取缓存Tag. + * * @return string|array */ public function getTag() @@ -104,8 +112,8 @@ class CacheItem } /** - * 凭借此缓存项的「键」从缓存系统里面取出缓存项 - * @access public + * 凭借此缓存项的「键」从缓存系统里面取出缓存项. + * * @return mixed */ public function get() @@ -114,8 +122,8 @@ class CacheItem } /** - * 确认缓存项的检查是否命中 - * @access public + * 确认缓存项的检查是否命中. + * * @return bool */ public function isHit(): bool @@ -124,34 +132,39 @@ class CacheItem } /** - * 为此缓存项设置「值」 - * @access public - * @param mixed $value + * 为此缓存项设置「值」. + * + * @param mixed $value + * * @return $this */ public function set($value) { $this->value = $value; $this->isHit = true; + return $this; } /** - * 为此缓存项设置所属标签 - * @access public - * @param string|array $tag + * 为此缓存项设置所属标签. + * + * @param string|array $tag + * * @return $this */ public function tag($tag = null) { $this->tag = $tag; + return $this; } /** * 设置缓存项的有效期 - * @access public - * @param mixed $expire + * + * @param mixed $expire + * * @return $this */ public function expire($expire) @@ -170,28 +183,27 @@ class CacheItem } /** - * 设置缓存项的准确过期时间点 - * @access public - * @param DateTimeInterface $expiration + * 设置缓存项的准确过期时间点. + * + * @param DateTimeInterface $expiration + * * @return $this */ - public function expiresAt($expiration) + public function expiresAt(DateTimeInterface $expiration) { - if ($expiration instanceof DateTimeInterface) { - $this->expire = $expiration; - } else { - throw new InvalidArgumentException('not support datetime'); - } + $this->expire = $expiration; return $this; } /** - * 设置缓存项的过期时间 - * @access public + * 设置缓存项的过期时间. + * * @param int|DateInterval $timeInterval - * @return $this + * * @throws InvalidArgumentException + * + * @return $this */ public function expiresAfter($timeInterval) { @@ -205,5 +217,4 @@ class CacheItem return $this; } - } diff --git a/vendor/topthink/think-orm/src/db/Connection.php b/vendor/topthink/think-orm/src/db/Connection.php index 015cf44..03a3d27 100644 --- a/vendor/topthink/think-orm/src/db/Connection.php +++ b/vendor/topthink/think-orm/src/db/Connection.php @@ -1,8 +1,9 @@ db->getListen(); if (empty($listen)) { $listen[] = function ($sql, $time, $master) { - if (0 === strpos($sql, 'CONNECT:')) { + if (str_starts_with($sql, 'CONNECT:')) { $this->db->log($sql); + return; } @@ -253,7 +282,7 @@ abstract class Connection implements ConnectionInterface } $runtime = number_format((microtime(true) - $this->queryStartTime), 6); - $sql = $sql ?: $this->getLastsql(); + $sql = $sql ?: $this->getLastsql(); if (empty($this->config['deploy'])) { $master = null; @@ -267,8 +296,8 @@ abstract class Connection implements ConnectionInterface } /** - * 缓存数据 - * @access protected + * 缓存数据. + * * @param CacheItem $cacheItem 缓存Item */ protected function cacheData(CacheItem $cacheItem) @@ -281,10 +310,11 @@ abstract class Connection implements ConnectionInterface } /** - * 分析缓存Key - * @access protected - * @param BaseQuery $query 查询对象 + * 分析缓存Key. + * + * @param BaseQuery $query 查询对象 * @param string $method 查询方法 + * * @return string */ protected function getCacheKey(BaseQuery $query, string $method = ''): string @@ -299,11 +329,12 @@ abstract class Connection implements ConnectionInterface } /** - * 分析缓存 - * @access protected - * @param BaseQuery $query 查询对象 - * @param array $cache 缓存信息 + * 分析缓存. + * + * @param BaseQuery $query 查询对象 + * @param array $cache 缓存信息 * @param string $method 查询方法 + * * @return CacheItem */ protected function parseCache(BaseQuery $query, array $cache, string $method = ''): CacheItem @@ -326,9 +357,9 @@ abstract class Connection implements ConnectionInterface } /** - * 获取返回或者影响的记录数 - * @access public - * @return integer + * 获取返回或者影响的记录数. + * + * @return int */ public function getNumRows(): int { @@ -336,8 +367,36 @@ abstract class Connection implements ConnectionInterface } /** - * 析构方法 - * @access public + * 获取最终的SQL语句. + * + * @param string $sql 带参数绑定的sql语句 + * @param array $bind 参数绑定列表 + * + * @return string + */ + public function getRealSql(string $sql, array $bind = []): string + { + foreach ($bind as $key => $val) { + $value = strval(is_array($val) ? $val[0] : $val); + $type = is_array($val) ? $val[1] : self::PARAM_STR; + + if (self::PARAM_FLOAT == $type || self::PARAM_STR == $type) { + $value = '\'' . addslashes($value) . '\''; + } elseif (self::PARAM_INT == $type && '' === $value) { + $value = '0'; + } + + // 判断占位符 + $sql = is_numeric($key) ? + substr_replace($sql, $value, strpos($sql, '?'), 1) : + substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key)); + } + + return rtrim($sql); + } + + /** + * 析构方法. */ public function __destruct() { diff --git a/vendor/topthink/think-orm/src/db/ConnectionInterface.php b/vendor/topthink/think-orm/src/db/ConnectionInterface.php index 18fe131..84bbb03 100644 --- a/vendor/topthink/think-orm/src/db/ConnectionInterface.php +++ b/vendor/topthink/think-orm/src/db/ConnectionInterface.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; @@ -16,175 +17,210 @@ use Psr\SimpleCache\CacheInterface; use think\DbManager; /** - * Connection interface + * Connection interface. */ interface ConnectionInterface { /** - * 获取当前连接器类对应的Query类 - * @access public + * 获取当前连接器类对应的Query类. + * * @return string */ public function getQueryClass(): string; /** - * 指定表名开始查询 + * 指定表名开始查询. + * * @param $table + * * @return BaseQuery */ public function table($table); /** - * 指定表名开始查询(不带前缀) + * 指定表名开始查询(不带前缀). + * * @param $name + * * @return BaseQuery */ public function name($name); /** - * 连接数据库方法 - * @access public - * @param array $config 接参数 - * @param integer $linkNum 连接序号 + * 连接数据库方法. + * + * @param array $config 接参数 + * @param int $linkNum 连接序号 + * * @return mixed */ public function connect(array $config = [], $linkNum = 0); /** * 设置当前的数据库Db对象 - * @access public + * * @param DbManager $db + * * @return void */ public function setDb(DbManager $db); /** * 设置当前的缓存对象 - * @access public + * * @param CacheInterface $cache + * * @return void */ public function setCache(CacheInterface $cache); /** - * 获取数据库的配置参数 - * @access public + * 获取数据库的配置参数. + * * @param string $config 配置名称 + * * @return mixed */ public function getConfig(string $config = ''); /** - * 关闭数据库(或者重新连接) - * @access public + * 关闭数据库(或者重新连接). + * * @return $this */ public function close(); /** - * 查找单条记录 - * @access public + * 查找单条记录. + * * @param BaseQuery $query 查询对象 + * * @return array */ public function find(BaseQuery $query): array; /** - * 查找记录 - * @access public + * 查找记录. + * * @param BaseQuery $query 查询对象 + * * @return array */ public function select(BaseQuery $query): array; /** - * 插入记录 - * @access public - * @param BaseQuery $query 查询对象 - * @param boolean $getLastInsID 返回自增主键 + * 插入记录. + * + * @param BaseQuery $query 查询对象 + * @param bool $getLastInsID 返回自增主键 + * * @return mixed */ public function insert(BaseQuery $query, bool $getLastInsID = false); /** - * 批量插入记录 - * @access public - * @param BaseQuery $query 查询对象 - * @param mixed $dataSet 数据集 - * @return integer + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param mixed $dataSet 数据集 + * + * @return int */ public function insertAll(BaseQuery $query, array $dataSet = []): int; /** - * 更新记录 - * @access public + * 更新记录. + * * @param BaseQuery $query 查询对象 - * @return integer + * + * @return int */ public function update(BaseQuery $query): int; /** - * 删除记录 - * @access public + * 删除记录. + * * @param BaseQuery $query 查询对象 + * * @return int */ public function delete(BaseQuery $query): int; /** * 得到某个字段的值 - * @access public - * @param BaseQuery $query 查询对象 - * @param string $field 字段名 - * @param mixed $default 默认值 + * + * @param BaseQuery $query 查询对象 + * @param string $field 字段名 + * @param mixed $default 默认值 + * * @return mixed */ public function value(BaseQuery $query, string $field, $default = null); /** - * 得到某个列的数组 - * @access public - * @param BaseQuery $query 查询对象 + * 得到某个列的数组. + * + * @param BaseQuery $query 查询对象 * @param string|array $column 字段名 多个字段用逗号分隔 - * @param string $key 索引 + * @param string $key 索引 + * * @return array */ - public function column(BaseQuery $query, $column, string $key = ''): array; + public function column(BaseQuery $query, string|array $column, string $key = ''): array; /** * 执行数据库事务 - * @access public + * * @param callable $callback 数据操作方法回调 + * * @return mixed */ public function transaction(callable $callback); /** * 启动事务 - * @access public + * * @return void */ public function startTrans(); /** - * 用于非自动提交状态下面的查询提交 - * @access public + * 用于非自动提交状态下面的查询提交. + * * @return void */ public function commit(); /** - * 事务回滚 - * @access public + * 事务回滚. + * * @return void */ public function rollback(); /** - * 获取最近一次查询的sql语句 - * @access public + * 取得数据表的字段信息. + * + * @param string $tableName + * + * @return array + */ + public function getTableFields(string $tableName): array; + + /** + * 获取最近一次查询的sql语句. + * * @return string */ public function getLastSql(): string; + /** + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 + * @param string $sequence 自增序列名 + * + * @return mixed + */ + public function getLastInsID(BaseQuery $query, string $sequence = null); } diff --git a/vendor/topthink/think-orm/src/db/Fetch.php b/vendor/topthink/think-orm/src/db/Fetch.php index a997a85..0d51803 100644 --- a/vendor/topthink/think-orm/src/db/Fetch.php +++ b/vendor/topthink/think-orm/src/db/Fetch.php @@ -1,39 +1,37 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; +use think\db\BaseQuery as Query; use think\db\exception\DbException as Exception; use think\helper\Str; /** - * SQL获取类 + * SQL获取类. */ class Fetch { - /** - * 查询对象 - * @var Query - */ - protected $query; - /** * Connection对象 + * * @var Connection */ protected $connection; /** * Builder对象 + * * @var Builder */ protected $builder; @@ -41,20 +39,20 @@ class Fetch /** * 创建一个查询SQL获取对象 * - * @param Query $query 查询对象 + * @param Query $query 查询对象 */ - public function __construct(Query $query) + public function __construct(protected Query $query) { - $this->query = $query; - $this->connection = $query->getConnection(); - $this->builder = $this->connection->getBuilder(); + $this->connection = $query->getConnection(); + $this->builder = $this->connection->getBuilder(); } /** - * 聚合查询 - * @access protected - * @param string $aggregate 聚合方法 - * @param string $field 字段名 + * 聚合查询. + * + * @param string $aggregate 聚合方法 + * @param string $field 字段名 + * * @return string */ protected function aggregate(string $aggregate, string $field): string @@ -68,10 +66,11 @@ class Fetch /** * 得到某个字段的值 - * @access public - * @param string $field 字段名 - * @param mixed $default 默认值 - * @param bool $one + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * @param bool $one + * * @return string */ public function value(string $field, $default = null, bool $one = true): string @@ -97,10 +96,11 @@ class Fetch } /** - * 得到某个列的数组 - * @access public - * @param string $field 字段名 多个字段用逗号分隔 - * @param string $key 索引 + * 得到某个列的数组. + * + * @param string $field 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * * @return string */ public function column(string $field, string $key = ''): string @@ -132,9 +132,10 @@ class Fetch } /** - * 插入记录 - * @access public - * @param array $data 数据 + * 插入记录. + * + * @param array $data 数据 + * * @return string */ public function insert(array $data = []): string @@ -151,9 +152,10 @@ class Fetch } /** - * 插入记录并获取自增ID - * @access public - * @param array $data 数据 + * 插入记录并获取自增ID. + * + * @param array $data 数据 + * * @return string */ public function insertGetId(array $data = []): string @@ -162,10 +164,11 @@ class Fetch } /** - * 保存数据 自动判断insert或者update - * @access public - * @param array $data 数据 - * @param bool $forceInsert 是否强制insert + * 保存数据 自动判断insert或者update. + * + * @param array $data 数据 + * @param bool $forceInsert 是否强制insert + * * @return string */ public function save(array $data = [], bool $forceInsert = false): string @@ -188,10 +191,11 @@ class Fetch } /** - * 批量插入记录 - * @access public - * @param array $dataSet 数据集 - * @param integer $limit 每次写入数据限制 + * 批量插入记录. + * + * @param array $dataSet 数据集 + * @param int $limit 每次写入数据限制 + * * @return string */ public function insertAll(array $dataSet = [], int $limit = null): string @@ -207,10 +211,10 @@ class Fetch } if ($limit) { - $array = array_chunk($dataSet, $limit, true); + $array = array_chunk($dataSet, $limit, true); $fetchSql = []; foreach ($array as $item) { - $sql = $this->builder->insertAll($this->query, $item); + $sql = $this->builder->insertAll($this->query, $item); $bind = $this->query->getBind(); $fetchSql[] = $this->connection->getRealSql($sql, $bind); @@ -225,10 +229,11 @@ class Fetch } /** - * 通过Select方式插入记录 - * @access public - * @param array $fields 要插入的数据表字段名 - * @param string $table 要插入的数据表名 + * 通过Select方式插入记录. + * + * @param array $fields 要插入的数据表字段名 + * @param string $table 要插入的数据表名 + * * @return string */ public function selectInsert(array $fields, string $table): string @@ -241,9 +246,10 @@ class Fetch } /** - * 更新记录 - * @access public - * @param mixed $data 数据 + * 更新记录. + * + * @param mixed $data 数据 + * * @return string */ public function update(array $data = []): string @@ -288,9 +294,10 @@ class Fetch } /** - * 删除记录 - * @access public - * @param mixed $data 表达式 true 表示强制删除 + * 删除记录. + * + * @param mixed $data 表达式 true 表示强制删除 + * * @return string */ public function delete($data = null): string @@ -310,6 +317,7 @@ class Fetch $this->query->setOption('data', [$field => $condition]); // 生成删除SQL语句 $sql = $this->builder->delete($this->query); + return $this->fetch($sql); } } @@ -321,16 +329,17 @@ class Fetch } /** - * 查找记录 返回SQL - * @access public - * @param mixed $data + * 查找记录 返回SQL. + * + * @param array $data + * * @return string */ - public function select($data = null): string + public function select(array $data = []): string { $this->query->parseOptions(); - if (!is_null($data)) { + if (!empty($data)) { // 主键条件分析 $this->query->parsePkWhere($data); } @@ -342,9 +351,10 @@ class Fetch } /** - * 查找单条记录 返回SQL语句 - * @access public - * @param mixed $data + * 查找单条记录 返回SQL语句. + * + * @param mixed $data + * * @return string */ public function find($data = null): string @@ -364,9 +374,10 @@ class Fetch } /** - * 查找多条记录 如果不存在则抛出异常 - * @access public - * @param mixed $data + * 查找多条记录 如果不存在则抛出异常. + * + * @param mixed $data + * * @return string */ public function selectOrFail($data = null): string @@ -375,9 +386,10 @@ class Fetch } /** - * 查找单条记录 如果不存在则抛出异常 - * @access public - * @param mixed $data + * 查找单条记录 如果不存在则抛出异常. + * + * @param mixed $data + * * @return string */ public function findOrFail($data = null): string @@ -386,9 +398,10 @@ class Fetch } /** - * 查找单条记录 不存在返回空数据(或者空模型) - * @access public - * @param mixed $data 数据 + * 查找单条记录 不存在返回空数据(或者空模型). + * + * @param mixed $data 数据 + * * @return string */ public function findOrEmpty($data = null) @@ -397,9 +410,10 @@ class Fetch } /** - * 获取实际的SQL语句 - * @access public - * @param string $sql + * 获取实际的SQL语句. + * + * @param string $sql + * * @return string */ public function fetch(string $sql): string @@ -410,9 +424,10 @@ class Fetch } /** - * COUNT查询 - * @access public - * @param string $field 字段名 + * COUNT查询. + * + * @param string $field 字段名 + * * @return string */ public function count(string $field = '*'): string @@ -422,7 +437,7 @@ class Fetch if (!empty($options['group'])) { // 支持GROUP $subSql = $this->query->field('count(' . $field . ') AS think_count')->buildSql(); - $query = $this->query->newQuery()->table([$subSql => '_group_count_']); + $query = $this->query->newQuery()->table([$subSql => '_group_count_']); return $query->fetchsql()->aggregate('COUNT', '*'); } else { @@ -431,9 +446,10 @@ class Fetch } /** - * SUM查询 - * @access public - * @param string $field 字段名 + * SUM查询. + * + * @param string $field 字段名 + * * @return string */ public function sum(string $field): string @@ -442,9 +458,10 @@ class Fetch } /** - * MIN查询 - * @access public - * @param string $field 字段名 + * MIN查询. + * + * @param string $field 字段名 + * * @return string */ public function min(string $field): string @@ -453,9 +470,10 @@ class Fetch } /** - * MAX查询 - * @access public - * @param string $field 字段名 + * MAX查询. + * + * @param string $field 字段名 + * * @return string */ public function max(string $field): string @@ -464,9 +482,10 @@ class Fetch } /** - * AVG查询 - * @access public - * @param string $field 字段名 + * AVG查询. + * + * @param string $field 字段名 + * * @return string */ public function avg(string $field): string @@ -479,14 +498,17 @@ class Fetch if (strtolower(substr($method, 0, 5)) == 'getby') { // 根据某个字段获取记录 $field = Str::snake(substr($method, 5)); + return $this->where($field, '=', $args[0])->find(); } elseif (strtolower(substr($method, 0, 10)) == 'getfieldby') { // 根据某个字段获取记录的某个值 $name = Str::snake(substr($method, 10)); + return $this->where($name, '=', $args[0])->value($args[1]); } $result = call_user_func_array([$this->query, $method], $args); + return $result === $this->query ? $this : $result; } } diff --git a/vendor/topthink/think-orm/src/db/Mongo.php b/vendor/topthink/think-orm/src/db/Mongo.php index cf6e9c4..1f87418 100644 --- a/vendor/topthink/think-orm/src/db/Mongo.php +++ b/vendor/topthink/think-orm/src/db/Mongo.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); + namespace think\db; use MongoDB\Driver\Command; @@ -24,22 +26,25 @@ class Mongo extends BaseQuery { /** * 当前数据库连接对象 + * * @var \think\db\connector\Mongo */ protected $connection; /** - * 执行指令 返回数据集 - * @access public - * @param Command $command 指令 - * @param string $dbName - * @param ReadPreference $readPreference readPreference - * @param string|array $typeMap 指定返回的typeMap - * @return mixed + * 执行指令 返回数据集. + * + * @param Command $command 指令 + * @param string $dbName + * @param ReadPreference $readPreference readPreference + * @param string|array $typeMap 指定返回的typeMap + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return mixed */ public function command(Command $command, string $dbName = '', ReadPreference $readPreference = null, $typeMap = null) { @@ -47,35 +52,40 @@ class Mongo extends BaseQuery } /** - * 执行command - * @access public - * @param string|array|object $command 指令 - * @param mixed $extra 额外参数 - * @param string $db 数据库名 + * 执行command. + * + * @param string|array|object $command 指令 + * @param mixed $extra 额外参数 + * @param string $db 数据库名 + * * @return array */ public function cmd($command, $extra = null, string $db = ''): array { $this->parseOptions(); + return $this->connection->cmd($this, $command, $extra, $db); } /** - * 指定distinct查询 - * @access public - * @param string $field 字段名 + * 指定distinct查询. + * + * @param string $field 字段名 + * * @return array */ public function getDistinct(string $field) { $result = $this->cmd('distinct', $field); + return $result[0]['values']; } /** - * 获取数据库的所有collection - * @access public - * @param string $db 数据库名称 留空为当前数据库 + * 获取数据库的所有collection. + * + * @param string $db 数据库名称 留空为当前数据库 + * * @throws Exception */ public function listCollections(string $db = '') @@ -90,10 +100,11 @@ class Mongo extends BaseQuery } /** - * COUNT查询 - * @access public - * @param string $field 字段名 - * @return integer + * COUNT查询. + * + * @param string $field 字段名 + * + * @return int */ public function count(string $field = null): int { @@ -103,17 +114,18 @@ class Mongo extends BaseQuery } /** - * 聚合查询 - * @access public - * @param string $aggregate 聚合指令 - * @param string $field 字段名 - * @param bool $force 强制转为数字类型 + * 聚合查询. + * + * @param string $aggregate 聚合指令 + * @param string $field 字段名 + * @param bool $force 强制转为数字类型 + * * @return mixed */ - public function aggregate(string $aggregate, $field, bool $force = false) + public function aggregate(string $aggregate, $field, bool $force = false, bool $one = false) { $result = $this->cmd('aggregate', [strtolower($aggregate), $field]); - $value = $result[0]['aggregate'] ?? 0; + $value = $result[0]['aggregate'] ?? 0; if ($force) { $value += 0; @@ -123,10 +135,11 @@ class Mongo extends BaseQuery } /** - * 多聚合操作 + * 多聚合操作. + * + * @param array $aggregate 聚合指令, 可以聚合多个参数, 如 ['sum' => 'field1', 'avg' => 'field2'] + * @param array $groupBy 类似mysql里面的group字段, 可以传入多个字段, 如 ['field_a', 'field_b', 'field_c'] * - * @param array $aggregate 聚合指令, 可以聚合多个参数, 如 ['sum' => 'field1', 'avg' => 'field2'] - * @param array $groupBy 类似mysql里面的group字段, 可以传入多个字段, 如 ['field_a', 'field_b', 'field_c'] * @return array 查询结果 */ public function multiAggregate(array $aggregate, array $groupBy): array @@ -147,9 +160,10 @@ class Mongo extends BaseQuery /** * 字段值增长 - * @access public - * @param string $field 字段名 - * @param float $step 增长值 + * + * @param string $field 字段名 + * @param float $step 增长值 + * * @return $this */ public function inc(string $field, float $step = 1) @@ -160,10 +174,11 @@ class Mongo extends BaseQuery } /** - * 字段值减少 - * @access public - * @param string $field 字段名 - * @param float $step 减少值 + * 字段值减少. + * + * @param string $field 字段名 + * @param float $step 减少值 + * * @return $this */ public function dec(string $field, float $step = 1) @@ -172,9 +187,10 @@ class Mongo extends BaseQuery } /** - * 指定当前操作的Collection - * @access public + * 指定当前操作的Collection. + * * @param string $table 表名 + * * @return $this */ public function table($table) @@ -185,9 +201,10 @@ class Mongo extends BaseQuery } /** - * table方法的别名 - * @access public - * @param string $collection + * table方法的别名. + * + * @param string $collection + * * @return $this */ public function collection(string $collection) @@ -196,129 +213,150 @@ class Mongo extends BaseQuery } /** - * 设置typeMap - * @access public + * 设置typeMap. + * * @param string|array $typeMap + * * @return $this */ public function typeMap($typeMap) { $this->options['typeMap'] = $typeMap; + return $this; } /** - * awaitData - * @access public + * awaitData. + * * @param bool $awaitData + * * @return $this */ public function awaitData(bool $awaitData) { $this->options['awaitData'] = $awaitData; + return $this; } /** - * batchSize - * @access public - * @param integer $batchSize + * batchSize. + * + * @param int $batchSize + * * @return $this */ public function batchSize(int $batchSize) { $this->options['batchSize'] = $batchSize; + return $this; } /** - * exhaust - * @access public + * exhaust. + * * @param bool $exhaust + * * @return $this */ public function exhaust(bool $exhaust) { $this->options['exhaust'] = $exhaust; + return $this; } /** - * 设置modifiers - * @access public + * 设置modifiers. + * * @param array $modifiers + * * @return $this */ public function modifiers(array $modifiers) { $this->options['modifiers'] = $modifiers; + return $this; } /** - * 设置noCursorTimeout - * @access public + * 设置noCursorTimeout. + * * @param bool $noCursorTimeout + * * @return $this */ public function noCursorTimeout(bool $noCursorTimeout) { $this->options['noCursorTimeout'] = $noCursorTimeout; + return $this; } /** - * 设置oplogReplay - * @access public + * 设置oplogReplay. + * * @param bool $oplogReplay + * * @return $this */ public function oplogReplay(bool $oplogReplay) { $this->options['oplogReplay'] = $oplogReplay; + return $this; } /** - * 设置partial - * @access public + * 设置partial. + * * @param bool $partial + * * @return $this */ public function partial(bool $partial) { $this->options['partial'] = $partial; + return $this; } /** - * maxTimeMS - * @access public + * maxTimeMS. + * * @param string $maxTimeMS + * * @return $this */ public function maxTimeMS(string $maxTimeMS) { $this->options['maxTimeMS'] = $maxTimeMS; + return $this; } /** - * collation - * @access public + * collation. + * * @param array $collation + * * @return $this */ public function collation(array $collation) { $this->options['collation'] = $collation; + return $this; } /** - * 设置是否REPLACE - * @access public + * 设置是否REPLACE. + * * @param bool $replace 是否使用REPLACE写入数据 + * * @return $this */ public function replace(bool $replace = true) @@ -327,9 +365,10 @@ class Mongo extends BaseQuery } /** - * 设置返回字段 - * @access public - * @param mixed $field 字段信息 + * 设置返回字段. + * + * @param mixed $field 字段信息 + * * @return $this */ public function field($field) @@ -357,9 +396,10 @@ class Mongo extends BaseQuery } /** - * 指定要排除的查询字段 - * @access public + * 指定要排除的查询字段. + * * @param array|string $field 要排除的字段 + * * @return $this */ public function withoutField($field) @@ -382,38 +422,44 @@ class Mongo extends BaseQuery } $this->options['projection'] = $projection; + return $this; } /** - * 设置skip - * @access public - * @param integer $skip + * 设置skip. + * + * @param int $skip + * * @return $this */ public function skip(int $skip) { $this->options['skip'] = $skip; + return $this; } /** - * 设置slaveOk - * @access public + * 设置slaveOk. + * * @param bool $slaveOk + * * @return $this */ public function slaveOk(bool $slaveOk) { $this->options['slaveOk'] = $slaveOk; + return $this; } /** - * 指定查询数量 - * @access public + * 指定查询数量. + * * @param int $offset 起始位置 * @param int $length 查询数量 + * * @return $this */ public function limit(int $offset, int $length = null) @@ -423,17 +469,18 @@ class Mongo extends BaseQuery $offset = 0; } - $this->options['skip'] = $offset; + $this->options['skip'] = $offset; $this->options['limit'] = $length; return $this; } /** - * 设置sort - * @access public - * @param array|string $field - * @param string $order + * 设置sort. + * + * @param array|string $field + * @param string $order + * * @return $this */ public function order($field, string $order = '') @@ -443,36 +490,41 @@ class Mongo extends BaseQuery } else { $this->options['sort'][$field] = 'asc' == strtolower($order) ? 1 : -1; } + return $this; } /** - * 设置tailable - * @access public - * @param bool $tailable + * 设置tailable. + * + * @param bool $tailable + * * @return $this */ public function tailable(bool $tailable) { $this->options['tailable'] = $tailable; + return $this; } /** * 设置writeConcern对象 - * @access public - * @param WriteConcern $writeConcern + * + * @param WriteConcern $writeConcern + * * @return $this */ public function writeConcern(WriteConcern $writeConcern) { $this->options['writeConcern'] = $writeConcern; + return $this; } /** - * 获取当前数据表的主键 - * @access public + * 获取当前数据表的主键. + * * @return string|array */ public function getPk() @@ -482,7 +534,7 @@ class Mongo extends BaseQuery /** * 执行查询但只返回Cursor对象 - * @access public + * * @return Cursor */ public function getCursor(): Cursor @@ -493,9 +545,10 @@ class Mongo extends BaseQuery } /** - * 获取当前的查询标识 - * @access public + * 获取当前的查询标识. + * * @param mixed $data 要序列化的数据 + * * @return string */ public function getQueryGuid($data = null): string @@ -504,17 +557,19 @@ class Mongo extends BaseQuery } /** - * 分页查询 - * @access public + * 分页查询. + * * @param int|array $listRows 每页数量 数组表示配置参数 * @param int|bool $simple 是否简洁模式或者总记录数 - * @return Paginator + * * @throws Exception + * + * @return Paginator */ public function paginate($listRows = null, $simple = false): Paginator { if (is_int($simple)) { - $total = $simple; + $total = $simple; $simple = false; } @@ -526,16 +581,16 @@ class Mongo extends BaseQuery ]; if (is_array($listRows)) { - $config = array_merge($defaultConfig, $listRows); + $config = array_merge($defaultConfig, $listRows); $listRows = intval($config['list_rows']); } else { - $config = $defaultConfig; + $config = $defaultConfig; $listRows = intval($listRows ?: $config['list_rows']); } $page = isset($config['page']) ? (int) $config['page'] : Paginator::getCurrentPage($config['var_page']); - $page = $page < 1 ? 1 : $page; + $page = max($page, 1); $config['path'] = $config['path'] ?? Paginator::getCurrentPath(); @@ -544,11 +599,11 @@ class Mongo extends BaseQuery unset($this->options['order'], $this->options['limit'], $this->options['page'], $this->options['field']); - $total = $this->count(); + $total = $this->count(); $results = $this->options($options)->page($page, $listRows)->select(); } elseif ($simple) { $results = $this->limit(($page - 1) * $listRows, $listRows + 1)->select(); - $total = null; + $total = null; } else { $results = $this->page($page, $listRows)->select(); } @@ -560,19 +615,21 @@ class Mongo extends BaseQuery } /** - * 分批数据返回处理 - * @access public - * @param integer $count 每次处理的数据数量 + * 分批数据返回处理. + * + * @param int $count 每次处理的数据数量 * @param callable $callback 处理回调方法 * @param string|array $column 分批处理的字段名 * @param string $order 字段排序 - * @return bool + * * @throws Exception + * + * @return bool */ public function chunk(int $count, callable $callback, $column = null, string $order = 'asc'): bool { $options = $this->getOptions(); - $column = $column ?: $this->getPk(); + $column = $column ?: $this->getPk(); if (isset($options['order'])) { unset($options['order']); @@ -584,7 +641,7 @@ class Mongo extends BaseQuery } else { $query = $this->options($options)->limit($count); - if (strpos($column, '.')) { + if (str_contains($column, '.')) { [$alias, $key] = explode('.', $column); } else { $key = $column; @@ -602,7 +659,7 @@ class Mongo extends BaseQuery $times++; $query = $this->options($options)->page($times, $count); } else { - $end = $resultSet->pop(); + $end = $resultSet->pop(); $lastId = is_array($end) ? $end[$key] : $end->getData($key); $query = $this->options($options) @@ -617,8 +674,8 @@ class Mongo extends BaseQuery } /** - * 分析表达式(可用于查询或者写入操作) - * @access public + * 分析表达式(可用于查询或者写入操作). + * * @return array */ public function parseOptions(): array @@ -667,10 +724,10 @@ class Mongo extends BaseQuery // 根据页数计算limit [$page, $listRows] = $options['page']; - $page = $page > 0 ? $page : 1; - $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); - $offset = $listRows * ($page - 1); - $options['skip'] = intval($offset); + $page = $page > 0 ? $page : 1; + $listRows = $listRows > 0 ? $listRows : (is_numeric($options['limit']) ? $options['limit'] : 20); + $offset = $listRows * ($page - 1); + $options['skip'] = intval($offset); $options['limit'] = intval($listRows); } @@ -680,8 +737,8 @@ class Mongo extends BaseQuery } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @return array */ public function getFieldsType(): array @@ -694,9 +751,10 @@ class Mongo extends BaseQuery } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @param string $field 字段名 + * * @return string|null */ public function getFieldType(string $field) diff --git a/vendor/topthink/think-orm/src/db/PDOConnection.php b/vendor/topthink/think-orm/src/db/PDOConnection.php index 8f89fe3..cfdcce7 100644 --- a/vendor/topthink/think-orm/src/db/PDOConnection.php +++ b/vendor/topthink/think-orm/src/db/PDOConnection.php @@ -1,8 +1,9 @@ PDO::PARAM_STR, - 'str' => PDO::PARAM_STR, - 'integer' => PDO::PARAM_INT, - 'int' => PDO::PARAM_INT, - 'boolean' => PDO::PARAM_BOOL, - 'bool' => PDO::PARAM_BOOL, + 'string' => self::PARAM_STR, + 'str' => self::PARAM_STR, + 'integer' => self::PARAM_INT, + 'int' => self::PARAM_INT, + 'boolean' => self::PARAM_BOOL, + 'bool' => self::PARAM_BOOL, 'float' => self::PARAM_FLOAT, - 'datetime' => PDO::PARAM_STR, - 'timestamp' => PDO::PARAM_STR, + 'datetime' => self::PARAM_STR, + 'timestamp' => self::PARAM_STR, ]; /** - * 服务器断线标识字符 + * 服务器断线标识字符. + * * @var array */ protected $breakMatchStr = [ @@ -200,14 +212,15 @@ abstract class PDOConnection extends Connection ]; /** - * 绑定参数 + * 绑定参数. + * * @var array */ protected $bind = []; /** - * 获取当前连接器类对应的Query类 - * @access public + * 获取当前连接器类对应的Query类. + * * @return string */ public function getQueryClass(): string @@ -216,8 +229,8 @@ abstract class PDOConnection extends Connection } /** - * 获取当前连接器类对应的Builder类 - * @access public + * 获取当前连接器类对应的Builder类. + * * @return string */ public function getBuilderClass(): string @@ -226,57 +239,55 @@ abstract class PDOConnection extends Connection } /** - * 解析pdo连接的dsn信息 - * @access protected + * 解析pdo连接的dsn信息. + * * @param array $config 连接信息 + * * @return string */ abstract protected function parseDsn(array $config): string; /** - * 取得数据表的字段信息 - * @access public + * 取得数据表的字段信息. + * * @param string $tableName 数据表名称 + * * @return array */ abstract public function getFields(string $tableName): array; /** - * 取得数据库的表信息 - * @access public + * 取得数据库的表信息. + * * @param string $dbName 数据库名称 + * * @return array */ abstract public function getTables(string $dbName = ''): array; /** - * 对返数据表字段信息进行大小写转换出来 - * @access public + * 对返数据表字段信息进行大小写转换出来. + * * @param array $info 字段信息 + * * @return array */ public function fieldCase(array $info): array { // 字段大小写转换 - switch ($this->attrCase) { - case PDO::CASE_LOWER: - $info = array_change_key_case($info); - break; - case PDO::CASE_UPPER: - $info = array_change_key_case($info, CASE_UPPER); - break; - case PDO::CASE_NATURAL: - default: - // 不做转换 - } - - return $info; + return match ($this->attrCase) { + PDO::CASE_LOWER => array_change_key_case($info), + PDO::CASE_UPPER => array_change_key_case($info, CASE_UPPER), + PDO::CASE_NATURAL => $info, + default => $info, + }; } /** - * 获取字段类型 - * @access protected + * 获取字段类型. + * * @param string $type 字段类型 + * * @return string */ protected function getFieldType(string $type): string @@ -303,49 +314,52 @@ abstract class PDOConnection extends Connection } /** - * 获取字段绑定类型 - * @access public + * 获取字段绑定类型. + * * @param string $type 字段类型 - * @return integer + * + * @return int */ public function getFieldBindType(string $type): int { if (in_array($type, ['integer', 'string', 'float', 'boolean', 'bool', 'int', 'str'])) { $bind = $this->bindType[$type]; - } elseif (0 === strpos($type, 'set') || 0 === strpos($type, 'enum')) { - $bind = PDO::PARAM_STR; + } elseif (str_starts_with($type, 'set') || str_starts_with($type, 'enum')) { + $bind = self::PARAM_STR; } elseif (preg_match('/(double|float|decimal|real|numeric)/is', $type)) { $bind = self::PARAM_FLOAT; } elseif (preg_match('/(int|serial|bit)/is', $type)) { - $bind = PDO::PARAM_INT; + $bind = self::PARAM_INT; } elseif (preg_match('/bool/is', $type)) { - $bind = PDO::PARAM_BOOL; + $bind = self::PARAM_BOOL; } else { - $bind = PDO::PARAM_STR; + $bind = self::PARAM_STR; } return $bind; } /** - * 获取数据表信息缓存key - * @access protected + * 获取数据表信息缓存key. + * * @param string $schema 数据表名称 + * * @return string */ protected function getSchemaCacheKey(string $schema): string { - return $this->getConfig('hostname') . ':' . $this->getConfig('hostport') . '@' . $schema; + return $this->getConfig('hostname') . '_' . $this->getConfig('hostport') . '|' . $schema; } /** * @param string $tableName 数据表名称 - * @param bool $force 强制从数据库获取 + * @param bool $force 强制从数据库获取 + * * @return array */ public function getSchemaInfo(string $tableName, $force = false) { - if (!strpos($tableName, '.')) { + if (!str_contains($tableName, '.')) { $schema = $this->getConfig('database') . '.' . $tableName; } else { $schema = $tableName; @@ -353,7 +367,7 @@ abstract class PDOConnection extends Connection if (!isset($this->info[$schema]) || $force) { // 读取字段缓存 - $cacheKey = $this->getSchemaCacheKey($schema); + $cacheKey = $this->getSchemaCacheKey($schema); if ($this->config['fields_cache'] && !empty($this->cache) && !$force) { $info = $this->cache->get($cacheKey); } @@ -365,7 +379,7 @@ abstract class PDOConnection extends Connection } } - $pk = $info['_pk'] ?? null; + $pk = $info['_pk'] ?? null; $autoinc = $info['_autoinc'] ?? null; unset($info['_pk'], $info['_autoinc']); @@ -387,10 +401,11 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表信息 - * @access public + * 获取数据表信息. + * * @param mixed $tableName 数据表名 留空自动获取 * @param string $fetch 获取信息类型 包括 fields type bind pk + * * @return mixed */ public function getTableInfo($tableName, string $fetch = '') @@ -399,7 +414,7 @@ abstract class PDOConnection extends Connection $tableName = key($tableName) ?: current($tableName); } - if (strpos($tableName, ',') || strpos($tableName, ')')) { + if (str_contains($tableName, ',') || str_contains($tableName, ')')) { // 多表不获取字段信息 return []; } @@ -412,15 +427,16 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表的字段信息 - * @access public + * 获取数据表的字段信息. + * * @param string $tableName 数据表名 + * * @return array */ public function getTableFieldsInfo(string $tableName): array { $fields = $this->getFields($tableName); - $info = []; + $info = []; foreach ($fields as $key => $val) { // 记录字段类型 @@ -437,7 +453,7 @@ abstract class PDOConnection extends Connection if (isset($pk)) { // 设置主键 - $pk = count($pk) > 1 ? $pk : $pk[0]; + $pk = count($pk) > 1 ? $pk : $pk[0]; $info['_pk'] = $pk; } @@ -449,9 +465,10 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表的主键 - * @access public + * 获取数据表的主键. + * * @param mixed $tableName 数据表名 + * * @return string|array */ public function getPk($tableName) @@ -460,9 +477,10 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表的自增主键 - * @access public + * 获取数据表的自增主键. + * * @param mixed $tableName 数据表名 + * * @return string */ public function getAutoInc($tableName) @@ -471,9 +489,10 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表字段信息 - * @access public + * 获取数据表字段信息. + * * @param mixed $tableName 数据表名 + * * @return array */ public function getTableFields($tableName): array @@ -482,10 +501,11 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表字段类型 - * @access public + * 获取数据表字段类型. + * * @param mixed $tableName 数据表名 * @param string $field 字段名 + * * @return array|string */ public function getFieldsType($tableName, string $field = null) @@ -500,9 +520,10 @@ abstract class PDOConnection extends Connection } /** - * 获取数据表绑定信息 - * @access public + * 获取数据表绑定信息. + * * @param mixed $tableName 数据表名 + * * @return array */ public function getFieldsBind($tableName): array @@ -511,13 +532,15 @@ abstract class PDOConnection extends Connection } /** - * 连接数据库方法 - * @access public + * 连接数据库方法. + * * @param array $config 连接参数 - * @param integer $linkNum 连接序号 + * @param int $linkNum 连接序号 * @param array|bool $autoConnection 是否自动连接主数据库(用于分布式) - * @return PDO + * * @throws PDOException + * + * @return PDO */ public function connect(array $config = [], $linkNum = 0, $autoConnection = false): PDO { @@ -563,6 +586,7 @@ abstract class PDOConnection extends Connection } catch (\PDOException $e) { if ($autoConnection) { $this->db->log($e->getMessage(), 'error'); + return $this->connect($autoConnection, $linkNum); } else { throw $e; @@ -571,9 +595,10 @@ abstract class PDOConnection extends Connection } /** - * 视图查询 - * @access public + * 视图查询. + * * @param array $args + * * @return BaseQuery */ public function view(...$args) @@ -582,11 +607,13 @@ abstract class PDOConnection extends Connection } /** - * 创建PDO实例 + * 创建PDO实例. + * * @param $dsn * @param $username * @param $password * @param $params + * * @return PDO */ protected function createPdo($dsn, $username, $password, $params) @@ -595,8 +622,7 @@ abstract class PDOConnection extends Connection } /** - * 释放查询结果 - * @access public + * 释放查询结果. */ public function free(): void { @@ -605,7 +631,7 @@ abstract class PDOConnection extends Connection /** * 获取PDO对象 - * @access public + * * @return PDO|false */ public function getPdo() @@ -618,14 +644,16 @@ abstract class PDOConnection extends Connection } /** - * 执行查询 使用生成器返回数据 - * @access public + * 执行查询 使用生成器返回数据. + * * @param BaseQuery $query 查询对象 * @param string $sql sql指令 * @param Model|null $model 模型对象实例 * @param null $condition 查询条件 - * @return \Generator + * * @throws DbException + * + * @return \Generator */ public function getCursor(BaseQuery $query, string $sql, $model = null, $condition = null) { @@ -642,13 +670,15 @@ abstract class PDOConnection extends Connection } /** - * 执行查询 返回数据集 - * @access public + * 执行查询 返回数据集. + * * @param string $sql sql指令 * @param array $bind 参数绑定 * @param bool $master 主库读取 - * @return array + * * @throws DbException + * + * @return array */ public function query(string $sql, array $bind = [], bool $master = false): array { @@ -656,12 +686,14 @@ abstract class PDOConnection extends Connection } /** - * 执行语句 - * @access public + * 执行语句. + * * @param string $sql sql指令 * @param array $bind 参数绑定 - * @return int + * * @throws DbException + * + * @return int */ public function execute(string $sql, array $bind = []): int { @@ -669,13 +701,15 @@ abstract class PDOConnection extends Connection } /** - * 执行查询 返回数据集 - * @access protected + * 执行查询 返回数据集. + * * @param BaseQuery $query 查询对象 * @param mixed $sql sql指令 * @param bool $master 主库读取 - * @return array + * * @throws DbException + * + * @return array */ protected function pdoQuery(BaseQuery $query, $sql, bool $master = null): array { @@ -687,7 +721,7 @@ abstract class PDOConnection extends Connection // 检查查询缓存 $cacheItem = $this->parseCache($query, $query->getOptions('cache')); if (!$query->getOptions('force_cache')) { - $key = $cacheItem->getKey(); + $key = $cacheItem->getKey(); $data = $this->cache->get($key); @@ -698,19 +732,19 @@ abstract class PDOConnection extends Connection } if ($sql instanceof Closure) { - $sql = $sql($query); + $sql = $sql($query); $bind = $query->getBind(); } if (!isset($master)) { - $master = $query->getOptions('master') ? true : false; + $master = (bool) $query->getOptions('master'); } - $procedure = $query->getOptions('procedure') ? true : in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + $procedure = $query->getOptions('procedure') || in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); $this->getPDOStatement($sql, $bind, $master, $procedure); - $resultSet = $this->getResult($procedure); + $resultSet = $this->getResult($procedure); $requireCache = $query->getOptions('cache_always') || !empty($resultSet); if (isset($cacheItem) && $requireCache) { @@ -724,10 +758,12 @@ abstract class PDOConnection extends Connection /** * 执行查询但只返回PDOStatement对象 - * @access public + * * @param BaseQuery $query 查询对象 - * @return \PDOStatement + * * @throws DbException + * + * @return \PDOStatement */ public function pdo(BaseQuery $query): PDOStatement { @@ -739,13 +775,15 @@ abstract class PDOConnection extends Connection /** * 执行查询但只返回PDOStatement对象 - * @access public + * * @param string $sql sql指令 * @param array $bind 参数绑定 * @param bool $master 是否在主服务器读操作 * @param bool $procedure 是否为存储过程调用 - * @return PDOStatement + * * @throws DbException + * + * @return PDOStatement */ public function getPDOStatement(string $sql, array $bind = [], bool $master = false, bool $procedure = false): PDOStatement { @@ -753,7 +791,7 @@ abstract class PDOConnection extends Connection $this->initConnect($this->readMaster ?: $master); // 记录SQL语句 $this->queryStr = $sql; - $this->bind = $bind; + $this->bind = $bind; $this->db->updateQueryTimes(); $this->queryStartTime = microtime(true); @@ -788,7 +826,8 @@ abstract class PDOConnection extends Connection } } else { if ($this->reConnectTimes < 4 && $this->isBreak($e)) { - ++$this->reConnectTimes; + $this->reConnectTimes++; + return $this->close()->getPDOStatement($sql, $bind, $master, $procedure); } } @@ -802,13 +841,15 @@ abstract class PDOConnection extends Connection } /** - * 执行语句 - * @access protected + * 执行语句. + * * @param BaseQuery $query 查询对象 * @param string $sql sql指令 * @param bool $origin 是否原生查询 - * @return int + * * @throws DbException + * + * @return int */ protected function pdoExecute(BaseQuery $query, string $sql, bool $origin = false): int { @@ -827,8 +868,8 @@ abstract class PDOConnection extends Connection if ($query->getOptions('cache')) { // 清理缓存数据 $cacheItem = $this->parseCache($query, $query->getOptions('cache')); - $key = $cacheItem->getKey(); - $tag = $cacheItem->getTag(); + $key = $cacheItem->getKey(); + $tag = $cacheItem->getTag(); if (isset($key) && $this->cache->has($key)) { $this->cache->delete($key); @@ -843,25 +884,29 @@ abstract class PDOConnection extends Connection /** * @param BaseQuery $query * @param string $sql - * @return PDOStatement + * * @throws DbException + * + * @return PDOStatement */ protected function queryPDOStatement(BaseQuery $query, string $sql): PDOStatement { - $options = $query->getOptions(); - $bind = $query->getBind(); - $master = !empty($options['master']) ? true : false; - $procedure = !empty($options['procedure']) ? true : in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); + $options = $query->getOptions(); + $bind = $query->getBind(); + $master = !empty($options['master']); + $procedure = !empty($options['procedure']) || in_array(strtolower(substr(trim($sql), 0, 4)), ['call', 'exec']); return $this->getPDOStatement($sql, $bind, $master, $procedure); } /** - * 查找单条记录 - * @access public + * 查找单条记录. + * * @param BaseQuery $query 查询对象 - * @return array + * * @throws DbException + * + * @return array */ public function find(BaseQuery $query): array { @@ -881,9 +926,10 @@ abstract class PDOConnection extends Connection } /** - * 使用游标查询记录 - * @access public + * 使用游标查询记录. + * * @param BaseQuery $query 查询对象 + * * @return \Generator */ public function cursor(BaseQuery $query) @@ -901,11 +947,13 @@ abstract class PDOConnection extends Connection } /** - * 查找记录 - * @access public + * 查找记录. + * * @param BaseQuery $query 查询对象 - * @return array + * * @throws DbException + * + * @return array */ public function select(BaseQuery $query): array { @@ -922,10 +970,11 @@ abstract class PDOConnection extends Connection } /** - * 插入记录 - * @access public + * 插入记录. + * * @param BaseQuery $query 查询对象 - * @param boolean $getLastInsID 返回自增主键 + * @param bool $getLastInsID 返回自增主键 + * * @return mixed */ public function insert(BaseQuery $query, bool $getLastInsID = false) @@ -940,7 +989,7 @@ abstract class PDOConnection extends Connection $result = '' == $sql ? 0 : $this->pdoExecute($query, $sql); if ($result) { - $sequence = $options['sequence'] ?? null; + $sequence = $options['sequence'] ?? null; $lastInsId = $this->getLastInsID($query, $sequence); $data = $options['data']; @@ -965,23 +1014,30 @@ abstract class PDOConnection extends Connection } /** - * 批量插入记录 - * @access public + * 批量插入记录. + * * @param BaseQuery $query 查询对象 - * @param mixed $dataSet 数据集 - * @param integer $limit 每次写入数据限制 - * @return integer + * @param array $dataSet 数据集 + * * @throws \Exception * @throws \Throwable + * + * @return int */ - public function insertAll(BaseQuery $query, array $dataSet = [], int $limit = 0): int + public function insertAll(BaseQuery $query, array $dataSet = []): int { - $query->parseOptions(); - if (!is_array(reset($dataSet))) { return 0; } + $options = $query->parseOptions(); + + if (!empty($options['limit']) && is_numeric($options['limit'])) { + $limit = (int) $options['limit']; + } else { + $limit = 0; + } + if (0 === $limit && count($dataSet) >= 5000) { $limit = 1000; } @@ -1003,6 +1059,7 @@ abstract class PDOConnection extends Connection $this->commit(); } catch (\Exception | \Throwable $e) { $this->rollback(); + throw $e; } @@ -1015,19 +1072,26 @@ abstract class PDOConnection extends Connection } /** - * 批量插入记录 - * @access public + * 批量插入记录. + * * @param BaseQuery $query 查询对象 * @param array $keys 键值 * @param array $values 数据 - * @param integer $limit 每次写入数据限制 - * @return integer + * * @throws \Exception * @throws \Throwable + * + * @return int */ - public function insertAllByKeys(BaseQuery $query, array $keys, array $values, int $limit = 0): int + public function insertAllByKeys(BaseQuery $query, array $keys, array $values): int { - $query->parseOptions(); + $options = $query->parseOptions(); + + if (!empty($options['limit']) && is_numeric($options['limit'])) { + $limit = (int) $options['limit']; + } else { + $limit = 0; + } if (0 === $limit && count($values) >= 5000) { $limit = 1000; @@ -1050,6 +1114,7 @@ abstract class PDOConnection extends Connection $this->commit(); } catch (\Exception | \Throwable $e) { $this->rollback(); + throw $e; } @@ -1062,13 +1127,15 @@ abstract class PDOConnection extends Connection } /** - * 通过Select方式插入记录 - * @access public + * 通过Select方式插入记录. + * * @param BaseQuery $query 查询对象 * @param array $fields 要插入的数据表字段名 * @param string $table 要插入的数据表名 - * @return integer + * * @throws PDOException + * + * @return int */ public function selectInsert(BaseQuery $query, array $fields, string $table): int { @@ -1081,11 +1148,13 @@ abstract class PDOConnection extends Connection } /** - * 更新记录 - * @access public + * 更新记录. + * * @param BaseQuery $query 查询对象 - * @return integer + * * @throws PDOException + * + * @return int */ public function update(BaseQuery $query): int { @@ -1105,11 +1174,13 @@ abstract class PDOConnection extends Connection } /** - * 删除记录 - * @access public + * 删除记录. + * * @param BaseQuery $query 查询对象 - * @return int + * * @throws PDOException + * + * @return int */ public function delete(BaseQuery $query): int { @@ -1131,11 +1202,12 @@ abstract class PDOConnection extends Connection /** * 得到某个字段的值 - * @access public + * * @param BaseQuery $query 查询对象 * @param string $field 字段名 * @param mixed $default 默认值 * @param bool $one 返回一个值 + * * @return mixed */ public function value(BaseQuery $query, string $field, $default = null, bool $one = true) @@ -1154,9 +1226,8 @@ abstract class PDOConnection extends Connection if (!empty($options['cache'])) { $cacheItem = $this->parseCache($query, $options['cache'], 'value'); - - if (!$query->getOptions('force_cache')) { - $key = $cacheItem->getKey(); + if (empty($options['force_cache'])) { + $key = $cacheItem->getKey(); if ($this->cache->has($key)) { return $this->cache->get($key); @@ -1193,14 +1264,15 @@ abstract class PDOConnection extends Connection /** * 得到某个字段的值 - * @access public + * * @param BaseQuery $query 查询对象 * @param string $aggregate 聚合方法 * @param mixed $field 字段名 * @param bool $force 强制转为数字类型 + * * @return mixed */ - public function aggregate(BaseQuery $query, string $aggregate, $field, bool $force = false) + public function aggregate(BaseQuery $query, string $aggregate, $field, bool $force = false, bool $one = true) { if (is_string($field) && 0 === stripos($field, 'DISTINCT ')) { [$distinct, $field] = explode(' ', $field); @@ -1208,20 +1280,21 @@ abstract class PDOConnection extends Connection $field = $aggregate . '(' . (!empty($distinct) ? 'DISTINCT ' : '') . $this->builder->parseKey($query, $field, true) . ') AS think_' . strtolower($aggregate); - $result = $this->value($query, $field, 0); + $result = $this->value($query, $field, 0, $one); return $force ? (float) $result : $result; } /** - * 得到某个列的数组 - * @access public - * @param BaseQuery $query 查询对象 - * @param string|array $column 字段名 多个字段用逗号分隔 - * @param string $key 索引 + * 得到某个列的数组. + * + * @param BaseQuery $query 查询对象 + * @param string|array $column 字段名 多个字段用逗号分隔 + * @param string $key 索引 + * * @return array */ - public function column(BaseQuery $query, $column, string $key = ''): array + public function column(BaseQuery $query, string|array $column, string $key = ''): array { $options = $query->parseOptions(); @@ -1238,12 +1311,8 @@ abstract class PDOConnection extends Connection if ('*' !== $column) { $column = array_map('trim', explode(',', $column)); } - } elseif (is_array($column)) { - if (in_array('*', $column)) { - $column = '*'; - } - } else { - throw new DbException('not support type'); + } elseif (in_array('*', $column)) { + $column = '*'; } $field = $column; @@ -1251,13 +1320,13 @@ abstract class PDOConnection extends Connection $field[] = $key; } - $query->setOption('field', $field); + $query->setOption('field', (array) $field); if (!empty($options['cache'])) { // 判断查询缓存 $cacheItem = $this->parseCache($query, $options['cache'], 'column'); - if (!$query->getOptions('force_cache')) { - $name = $cacheItem->getKey(); + if (empty($options['force_cache'])) { + $name = $cacheItem->getKey(); if ($this->cache->has($name)) { return $this->cache->get($name); @@ -1275,10 +1344,10 @@ abstract class PDOConnection extends Connection } // 执行查询操作 - $pdo = $this->getPDOStatement($sql, $query->getBind(), $options['master']); + $pdo = $this->getPDOStatement($sql, $query->getBind(), $options['master']); $resultSet = $pdo->fetchAll(PDO::FETCH_ASSOC); - if (is_string($key) && strpos($key, '.')) { + if (is_string($key) && str_contains($key, '.')) { [$alias, $key] = explode('.', $key); } @@ -1286,15 +1355,15 @@ abstract class PDOConnection extends Connection $result = []; } elseif ('*' !== $column && count($column) === 1) { $column = array_shift($column); - if (strpos($column, ' ')) { + if (str_contains($column, ' ')) { $column = substr(strrchr(trim($column), ' '), 1); } - if (strpos($column, '.')) { + if (str_contains($column, '.')) { [$alias, $column] = explode('.', $column); } - if (strpos($column, '->')) { + if (str_contains($column, '->')) { $column = $this->builder->parseKey($query, $column); } @@ -1314,42 +1383,16 @@ abstract class PDOConnection extends Connection return $result; } - /** - * 根据参数绑定组装最终的SQL语句 便于调试 - * @access public - * @param string $sql 带参数绑定的sql语句 - * @param array $bind 参数绑定列表 - * @return string - */ - public function getRealSql(string $sql, array $bind = []): string - { - foreach ($bind as $key => $val) { - $value = strval(is_array($val) ? $val[0] : $val); - $type = is_array($val) ? $val[1] : PDO::PARAM_STR; - - if (self::PARAM_FLOAT == $type || PDO::PARAM_STR == $type) { - $value = '\'' . addslashes($value) . '\''; - } elseif (PDO::PARAM_INT == $type && '' === $value) { - $value = '0'; - } - - // 判断占位符 - $sql = is_numeric($key) ? - substr_replace($sql, $value, strpos($sql, '?'), 1) : - substr_replace($sql, $value, strpos($sql, ':' . $key), strlen(':' . $key)); - } - - return rtrim($sql); - } - /** * 参数绑定 * 支持 ['name'=>'value','id'=>123] 对应命名占位符 - * 或者 ['value',123] 对应问号占位符 - * @access public + * 或者 ['value',123] 对应问号占位符. + * * @param array $bind 要绑定的参数列表 - * @return void + * * @throws BindParamException + * + * @return void */ protected function bindValue(array $bind = []): void { @@ -1358,11 +1401,11 @@ abstract class PDOConnection extends Connection $param = is_numeric($key) ? $key + 1 : ':' . $key; if (is_array($val)) { - if (PDO::PARAM_INT == $val[1] && '' === $val[0]) { + if (self::PARAM_INT == $val[1] && '' === $val[0]) { $val[0] = 0; } elseif (self::PARAM_FLOAT == $val[1]) { $val[0] = is_string($val[0]) ? (float) $val[0] : $val[0]; - $val[1] = PDO::PARAM_STR; + $val[1] = self::PARAM_STR; } $result = $this->PDOStatement->bindValue($param, $val[0], $val[1]); @@ -1382,11 +1425,13 @@ abstract class PDOConnection extends Connection } /** - * 存储过程的输入输出参数绑定 - * @access public + * 存储过程的输入输出参数绑定. + * * @param array $bind 要绑定的参数列表 - * @return void + * * @throws BindParamException + * + * @return void */ protected function bindParam(array $bind): void { @@ -1414,9 +1459,10 @@ abstract class PDOConnection extends Connection } /** - * 获得数据集数组 - * @access protected + * 获得数据集数组. + * * @param bool $procedure 是否存储过程 + * * @return array */ protected function getResult(bool $procedure = false): array @@ -1434,8 +1480,8 @@ abstract class PDOConnection extends Connection } /** - * 获得存储过程数据集 - * @access protected + * 获得存储过程数据集. + * * @return array */ protected function procedure(): array @@ -1456,12 +1502,14 @@ abstract class PDOConnection extends Connection /** * 执行数据库事务 - * @access public - * @param callable $callback 数据操作方法回调 - * @return mixed + * + * @param callable $callback 数据操作方法回调 + * * @throws PDOException * @throws \Exception * @throws \Throwable + * + * @return mixed */ public function transaction(callable $callback) { @@ -1474,26 +1522,29 @@ abstract class PDOConnection extends Connection } $this->commit(); + return $result; } catch (\Exception | \Throwable $e) { $this->rollback(); + throw $e; } } /** * 启动事务 - * @access public - * @return void + * * @throws \PDOException * @throws \Exception + * + * @return void */ public function startTrans(): void { try { $this->initConnect(true); - ++$this->transTimes; + $this->transTimes++; if (1 == $this->transTimes) { $this->linkID->beginTransaction(); @@ -1505,24 +1556,26 @@ abstract class PDOConnection extends Connection $this->reConnectTimes = 0; } catch (\Throwable | \Exception $e) { if (1 === $this->transTimes && $this->reConnectTimes < 4 && $this->isBreak($e)) { - --$this->transTimes; - ++$this->reConnectTimes; + $this->transTimes--; + $this->reConnectTimes++; $this->close()->startTrans(); } else { if ($this->isBreak($e)) { // 尝试对事务计数进行重置 $this->transTimes = 0; } + throw $e; } } } /** - * 用于非自动提交状态下面的查询提交 - * @access public - * @return void + * 用于非自动提交状态下面的查询提交. + * * @throws \PDOException + * + * @return void */ public function commit(): void { @@ -1532,14 +1585,15 @@ abstract class PDOConnection extends Connection $this->linkID->commit(); } - --$this->transTimes; + $this->transTimes--; } /** - * 事务回滚 - * @access public - * @return void + * 事务回滚. + * * @throws \PDOException + * + * @return void */ public function rollback(): void { @@ -1559,7 +1613,8 @@ abstract class PDOConnection extends Connection } /** - * 是否支持事务嵌套 + * 是否支持事务嵌套. + * * @return bool */ protected function supportSavepoint(): bool @@ -1568,9 +1623,10 @@ abstract class PDOConnection extends Connection } /** - * 生成定义保存点的SQL - * @access protected + * 生成定义保存点的SQL. + * * @param string $name 标识 + * * @return string */ protected function parseSavepoint(string $name): string @@ -1579,9 +1635,10 @@ abstract class PDOConnection extends Connection } /** - * 生成回滚到保存点的SQL - * @access protected + * 生成回滚到保存点的SQL. + * * @param string $name 标识 + * * @return string */ protected function parseSavepointRollBack(string $name): string @@ -1591,10 +1648,11 @@ abstract class PDOConnection extends Connection /** * 批处理执行SQL语句 - * 批处理的指令都认为是execute操作 - * @access public + * 批处理的指令都认为是execute操作. + * * @param BaseQuery $query 查询对象 * @param array $sqlArray SQL批处理指令 + * * @return bool */ public function batchQuery(BaseQuery $query, array $sqlArray = []): bool @@ -1610,6 +1668,7 @@ abstract class PDOConnection extends Connection $this->commit(); } catch (\Exception $e) { $this->rollback(); + throw $e; } @@ -1617,16 +1676,16 @@ abstract class PDOConnection extends Connection } /** - * 关闭数据库(或者重新连接) - * @access public + * 关闭数据库(或者重新连接). + * * @return $this */ public function close() { - $this->linkID = null; - $this->linkWrite = null; - $this->linkRead = null; - $this->links = []; + $this->linkID = null; + $this->linkWrite = null; + $this->linkRead = null; + $this->links = []; $this->transTimes = 0; $this->free(); @@ -1636,8 +1695,9 @@ abstract class PDOConnection extends Connection /** * 是否断线 - * @access protected + * * @param \PDOException|\Exception $e 异常对象 + * * @return bool */ protected function isBreak($e): bool @@ -1658,8 +1718,8 @@ abstract class PDOConnection extends Connection } /** - * 获取最近一次查询的sql语句 - * @access public + * 获取最近一次查询的sql语句. + * * @return string */ public function getLastSql(): string @@ -1668,10 +1728,11 @@ abstract class PDOConnection extends Connection } /** - * 获取最近插入的ID - * @access public + * 获取最近插入的ID. + * * @param BaseQuery $query 查询对象 * @param string $sequence 自增序列名 + * * @return mixed */ public function getLastInsID(BaseQuery $query, string $sequence = null) @@ -1686,10 +1747,11 @@ abstract class PDOConnection extends Connection } /** - * 获取最近插入的ID - * @access public + * 获取最近插入的ID. + * * @param BaseQuery $query 查询对象 * @param string $insertId 自增ID + * * @return mixed */ protected function autoInsIDType(BaseQuery $query, string $insertId) @@ -1699,7 +1761,7 @@ abstract class PDOConnection extends Connection if ($pk) { $type = $this->getFieldsBind($query->getTable())[$pk]; - if (PDO::PARAM_INT == $type) { + if (self::PARAM_INT == $type) { $insertId = (int) $insertId; } elseif (self::PARAM_FLOAT == $type) { $insertId = (float) $insertId; @@ -1710,8 +1772,8 @@ abstract class PDOConnection extends Connection } /** - * 获取最近的错误信息 - * @access public + * 获取最近的错误信息. + * * @return string */ public function getError(): string @@ -1731,9 +1793,10 @@ abstract class PDOConnection extends Connection } /** - * 初始化数据库连接 - * @access protected - * @param boolean $master 是否主服务器 + * 初始化数据库连接. + * + * @param bool $master 是否主服务器 + * * @return void */ protected function initConnect(bool $master = true): void @@ -1760,9 +1823,10 @@ abstract class PDOConnection extends Connection } /** - * 连接分布式服务器 - * @access protected - * @param boolean $master 主服务器 + * 连接分布式服务器. + * + * @param bool $master 主服务器 + * * @return PDO */ protected function multiConnect(bool $master = false): PDO @@ -1779,8 +1843,7 @@ abstract class PDOConnection extends Connection if ($this->config['rw_separate']) { // 主从式采用读写分离 - if ($master) // 主服务器写入 - { + if ($master) { // 主服务器写入 $r = $m; } elseif (is_numeric($this->config['slave_no'])) { // 指定服务器读 @@ -1812,9 +1875,10 @@ abstract class PDOConnection extends Connection } /** - * 获取数据库的唯一标识 - * @access public + * 获取数据库的唯一标识. + * * @param string $suffix 标识后缀 + * * @return string */ public function getUniqueXid(string $suffix = ''): string @@ -1824,13 +1888,15 @@ abstract class PDOConnection extends Connection /** * 执行数据库Xa事务 - * @access public - * @param callable $callback 数据操作方法回调 - * @param array $dbs 多个查询对象或者连接对象 - * @return mixed + * + * @param callable $callback 数据操作方法回调 + * @param array $dbs 多个查询对象或者连接对象 + * * @throws PDOException * @throws \Exception * @throws \Throwable + * + * @return mixed */ public function transactionXa(callable $callback, array $dbs = []) { @@ -1847,7 +1913,7 @@ abstract class PDOConnection extends Connection $dbs[$key] = $db; } - $db->startTransXa($db->getUniqueXid('_' . $xid) ); + $db->startTransXa($db->getUniqueXid('_' . $xid)); } try { @@ -1861,22 +1927,24 @@ abstract class PDOConnection extends Connection } foreach ($dbs as $db) { - $db->commitXa($db->getUniqueXid('_' . $xid) ); + $db->commitXa($db->getUniqueXid('_' . $xid)); } return $result; } catch (\Exception | \Throwable $e) { foreach ($dbs as $db) { - $db->rollbackXa($db->getUniqueXid('_' . $xid) ); + $db->rollbackXa($db->getUniqueXid('_' . $xid)); } + throw $e; } } /** * 启动XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function startTransXa(string $xid): void @@ -1885,8 +1953,9 @@ abstract class PDOConnection extends Connection /** * 预编译XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function prepareXa(string $xid): void @@ -1895,8 +1964,9 @@ abstract class PDOConnection extends Connection /** * 提交XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function commitXa(string $xid): void @@ -1905,8 +1975,9 @@ abstract class PDOConnection extends Connection /** * 回滚XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function rollbackXa(string $xid): void diff --git a/vendor/topthink/think-orm/src/db/Query.php b/vendor/topthink/think-orm/src/db/Query.php index 35e66bc..b464809 100644 --- a/vendor/topthink/think-orm/src/db/Query.php +++ b/vendor/topthink/think-orm/src/db/Query.php @@ -1,21 +1,23 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; use PDOStatement; +use think\db\exception\DbException as Exception; /** - * PDO数据查询类 + * PDO数据查询类. */ class Query extends BaseQuery { @@ -24,10 +26,11 @@ class Query extends BaseQuery use concern\TableFieldInfo; /** - * 表达式方式指定Field排序 - * @access public + * 表达式方式指定Field排序. + * * @param string $field 排序字段 * @param array $bind 参数绑定 + * * @return $this */ public function orderRaw(string $field, array $bind = []) @@ -38,9 +41,10 @@ class Query extends BaseQuery } /** - * 表达式方式指定查询字段 - * @access public + * 表达式方式指定查询字段. + * * @param string $field 字段名 + * * @return $this */ public function fieldRaw(string $field) @@ -51,11 +55,12 @@ class Query extends BaseQuery } /** - * 指定Field排序 orderField('id',[1,2,3],'desc') - * @access public + * 指定Field排序 orderField('id',[1,2,3],'desc'). + * * @param string $field 排序字段 * @param array $values 排序值 * @param string $order 排序 desc/asc + * * @return $this */ public function orderField(string $field, array $values, string $order = '') @@ -70,33 +75,37 @@ class Query extends BaseQuery } /** - * 随机排序 - * @access public + * 随机排序. + * * @return $this */ public function orderRand() { $this->options['order'][] = '[rand]'; + return $this; } /** - * 使用表达式设置数据 - * @access public + * 使用表达式设置数据. + * * @param string $field 字段名 * @param string $value 字段值 + * * @return $this */ public function exp(string $field, string $value) { $this->options['data'][$field] = new Raw($value); + return $this; } /** - * 表达式方式指定当前操作的数据表 - * @access public + * 表达式方式指定当前操作的数据表. + * * @param mixed $table 表名 + * * @return $this */ public function tableRaw(string $table) @@ -107,9 +116,10 @@ class Query extends BaseQuery } /** - * 获取执行的SQL语句而不进行实际的查询 - * @access public + * 获取执行的SQL语句而不进行实际的查询. + * * @param bool $fetch 是否返回sql + * * @return $this|Fetch */ public function fetchSql(bool $fetch = true) @@ -125,9 +135,10 @@ class Query extends BaseQuery /** * 批处理执行SQL语句 - * 批处理的指令都认为是execute操作 - * @access public + * 批处理的指令都认为是execute操作. + * * @param array $sql SQL批处理指令 + * * @return bool */ public function batchQuery(array $sql = []): bool @@ -136,143 +147,167 @@ class Query extends BaseQuery } /** - * USING支持 用于多表删除 - * @access public + * USING支持 用于多表删除. + * * @param mixed $using USING + * * @return $this */ public function using($using) { $this->options['using'] = $using; + return $this; } /** - * 存储过程调用 - * @access public + * 存储过程调用. + * * @param bool $procedure 是否为存储过程查询 + * * @return $this */ public function procedure(bool $procedure = true) { $this->options['procedure'] = $procedure; + return $this; } /** - * 指定group查询 - * @access public + * 指定group查询. + * * @param string|array $group GROUP + * * @return $this */ public function group($group) { $this->options['group'] = $group; + return $this; } /** - * 指定having查询 - * @access public + * 指定having查询. + * * @param string $having having + * * @return $this */ public function having(string $having) { $this->options['having'] = $having; + return $this; } /** - * 指定distinct查询 - * @access public + * 指定distinct查询. + * * @param bool $distinct 是否唯一 + * * @return $this */ public function distinct(bool $distinct = true) { $this->options['distinct'] = $distinct; + return $this; } /** - * 指定强制索引 - * @access public + * 指定强制索引. + * * @param string $force 索引名称 + * * @return $this */ public function force(string $force) { $this->options['force'] = $force; + return $this; } /** - * 查询注释 - * @access public + * 查询注释. + * * @param string $comment 注释 + * * @return $this */ public function comment(string $comment) { $this->options['comment'] = $comment; + return $this; } /** - * 设置是否REPLACE - * @access public + * 设置是否REPLACE. + * * @param bool $replace 是否使用REPLACE写入数据 + * * @return $this */ public function replace(bool $replace = true) { $this->options['replace'] = $replace; + return $this; } /** - * 设置当前查询所在的分区 - * @access public + * 设置当前查询所在的分区. + * * @param string|array $partition 分区名称 + * * @return $this */ public function partition($partition) { $this->options['partition'] = $partition; + return $this; } /** - * 设置DUPLICATE - * @access public + * 设置DUPLICATE. + * * @param array|string|Raw $duplicate DUPLICATE信息 + * * @return $this */ public function duplicate($duplicate) { $this->options['duplicate'] = $duplicate; + return $this; } /** - * 设置查询的额外参数 - * @access public + * 设置查询的额外参数. + * * @param string $extra 额外信息 + * * @return $this */ public function extra(string $extra) { $this->options['extra'] = $extra; + return $this; } /** - * 创建子查询SQL - * @access public + * 创建子查询SQL. + * * @param bool $sub 是否添加括号 - * @return string + * * @throws Exception + * + * @return string */ public function buildSql(bool $sub = true): string { @@ -280,8 +315,8 @@ class Query extends BaseQuery } /** - * 获取当前数据表的主键 - * @access public + * 获取当前数据表的主键. + * * @return string|array */ public function getPk() @@ -294,20 +329,22 @@ class Query extends BaseQuery } /** - * 指定数据表自增主键 - * @access public + * 指定数据表自增主键. + * * @param string $autoinc 自增键 + * * @return $this */ public function autoinc(string $autoinc) { $this->autoinc = $autoinc; + return $this; } /** - * 获取当前数据表的自增主键 - * @access public + * 获取当前数据表的自增主键. + * * @return string|null */ public function getAutoInc() @@ -323,9 +360,10 @@ class Query extends BaseQuery /** * 字段值增长 - * @access public - * @param string $field 字段名 - * @param float $step 增长值 + * + * @param string $field 字段名 + * @param float $step 增长值 + * * @return $this */ public function inc(string $field, float $step = 1) @@ -336,22 +374,145 @@ class Query extends BaseQuery } /** - * 字段值减少 - * @access public - * @param string $field 字段名 - * @param float $step 增长值 + * 字段值减少. + * + * @param string $field 字段名 + * @param float $step 增长值 + * * @return $this */ public function dec(string $field, float $step = 1) { $this->options['data'][$field] = ['DEC', $step]; + return $this; } /** - * 获取当前的查询标识 - * @access public + * 字段值增长(支持延迟写入) + * + * @param string $field 字段名 + * @param int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return int|false + */ + public function setInc(string $field, int $step = 1, $lazyTime = 0) + { + if (empty($this->options['where']) && $this->model) { + $this->where($this->model->getWhere()); + } + + if (empty($this->options['where'])) { + // 如果没有任何更新条件则不执行 + throw new Exception('miss update condition'); + } + + if ($lazyTime > 0) { + $guid = $this->getLazyFieldCacheKey($field); + $step = $this->lazyWrite('inc', $guid, $step, $lazyTime); + if (false === $step) { + return true; + } + } + + return $this->inc($field, $step)->update(); + } + + /** + * 字段值减少(支持延迟写入) + * + * @param string $field 字段名 + * @param int $step 步进值 + * @param int $lazyTime 延迟时间(秒) + * + * @return int|false + */ + public function setDec(string $field, int $step = 1, int $lazyTime = 0) + { + if (empty($this->options['where']) && $this->model) { + $this->where($this->model->getWhere()); + } + + if (empty($this->options['where'])) { + // 如果没有任何更新条件则不执行 + throw new Exception('miss update condition'); + } + + if ($lazyTime > 0) { + $guid = $this->getLazyFieldCacheKey($field); + $step = $this->lazyWrite('dec', $guid, $step, $lazyTime); + if (false === $step) { + return true; + } + return $this->inc($field, $step)->update(); + } + + return $this->dec($field, $step)->update(); + } + + /** + * 延时更新检查 返回false表示需要延时 + * 否则返回实际写入的数值 + * @access protected + * @param string $type 自增或者自减 + * @param string $guid 写入标识 + * @param int $step 写入步进值 + * @param int $lazyTime 延时时间(s) + * @return false|integer + */ + protected function lazyWrite(string $type, string $guid, int $step, int $lazyTime) + { + $cache = $this->getCache(); + if (!$cache->has($guid . '_time')) { + // 计时开始 + $cache->set($guid . '_time', time()); + $cache->$type($guid, $step); + } elseif (time() > $cache->get($guid . '_time') + $lazyTime) { + // 删除缓存 + $value = $cache->$type($guid, $step); + $cache->delete($guid); + $cache->delete($guid . '_time'); + return 0 === $value ? false : $value; + } else { + // 更新缓存 + $cache->$type($guid, $step); + } + + return false; + } + + /** + * 获取延迟写入字段值. + * + * @param string $field 字段名称 + * @param mixed $id 主键值 + * + * @return int + */ + protected function getLazyFieldValue(string $field, $id = null): int + { + return (int) $this->getCache()->get($this->getLazyFieldCacheKey($field, $id)); + } + + /** + * 获取延迟写入字段的缓存Key + * + * @param string $field 字段名 + * @param mixed $id 主键值 + * + * @return string + */ + protected function getLazyFieldCacheKey(string $field, $id = null): string + { + return 'lazy_' . $this->getTable() . '_' . $field . '_' . ($id ?: $this->getKey()); + } + + /** + * 获取当前的查询标识. + * * @param mixed $data 要序列化的数据 + * * @return string */ public function getQueryGuid($data = null): string @@ -361,7 +522,7 @@ class Query extends BaseQuery /** * 执行查询但只返回PDOStatement对象 - * @access public + * * @return PDOStatement */ public function getPdo(): PDOStatement @@ -370,9 +531,10 @@ class Query extends BaseQuery } /** - * 使用游标查找记录 - * @access public + * 使用游标查找记录. + * * @param mixed $data 数据 + * * @return \Generator */ public function cursor($data = null) @@ -390,19 +552,21 @@ class Query extends BaseQuery } /** - * 分批数据返回处理 - * @access public - * @param integer $count 每次处理的数据数量 + * 分批数据返回处理. + * + * @param int $count 每次处理的数据数量 * @param callable $callback 处理回调方法 * @param string|array $column 分批处理的字段名 * @param string $order 字段排序 - * @return bool + * * @throws Exception + * + * @return bool */ - public function chunk(int $count, callable $callback, $column = null, string $order = 'asc'): bool + public function chunk(int $count, callable $callback, string|array $column = null, string $order = 'asc'): bool { $options = $this->getOptions(); - $column = $column ?: $this->getPk(); + $column = $column ?: $this->getPk(); if (isset($options['order'])) { unset($options['order']); @@ -416,7 +580,7 @@ class Query extends BaseQuery } else { $query = $this->options($options)->limit($count); - if (strpos($column, '.')) { + if (str_contains($column, '.')) { [$alias, $key] = explode('.', $column); } else { $key = $column; @@ -434,7 +598,7 @@ class Query extends BaseQuery $times++; $query = $this->options($options)->page($times, $count); } else { - $end = $resultSet->pop(); + $end = $resultSet->pop(); $lastId = is_array($end) ? $end[$key] : $end->getData($key); $query = $this->options($options) diff --git a/vendor/topthink/think-orm/src/db/Raw.php b/vendor/topthink/think-orm/src/db/Raw.php index b956ff6..30c551e 100644 --- a/vendor/topthink/think-orm/src/db/Raw.php +++ b/vendor/topthink/think-orm/src/db/Raw.php @@ -1,51 +1,39 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; +use Stringable; + /** - * SQL Raw + * SQL Raw. */ class Raw { /** - * 查询表达式 + * 创建一个查询表达式. * - * @var string - */ - protected $value; - - /** - * 参数绑定 + * @param string|Stringable $value + * @param array $bind * - * @var array - */ - protected $bind = []; - - /** - * 创建一个查询表达式 - * - * @param string $value - * @param array $bind * @return void */ - public function __construct(string $value, array $bind = []) + public function __construct(protected string|Stringable $value, protected array $bind = []) { - $this->value = $value; - $this->bind = $bind; } /** - * 获取表达式 + * 获取表达式. * * @return string */ @@ -55,7 +43,7 @@ class Raw } /** - * 获取参数绑定 + * 获取参数绑定. * * @return string */ @@ -63,5 +51,4 @@ class Raw { return $this->bind; } - } diff --git a/vendor/topthink/think-orm/src/db/Where.php b/vendor/topthink/think-orm/src/db/Where.php index 0880460..bce9f04 100644 --- a/vendor/topthink/think-orm/src/db/Where.php +++ b/vendor/topthink/think-orm/src/db/Where.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db; @@ -20,44 +21,32 @@ use ArrayAccess; class Where implements ArrayAccess { /** - * 查询表达式 - * @var array - */ - protected $where = []; - - /** - * 是否需要把查询条件两边增加括号 - * @var bool - */ - protected $enclose = false; - - /** - * 创建一个查询表达式 + * 创建一个查询表达式. * - * @param array $where 查询条件数组 - * @param bool $enclose 是否增加括号 + * @param array $where 查询条件数组 + * @param bool $enclose 是否增加括号 */ - public function __construct(array $where = [], bool $enclose = false) + public function __construct(protected array $where = [], protected bool $enclose = false) { - $this->where = $where; - $this->enclose = $enclose; } /** - * 设置是否添加括号 - * @access public - * @param bool $enclose + * 设置是否添加括号. + * + * @param bool $enclose + * * @return $this */ public function enclose(bool $enclose = true) { $this->enclose = $enclose; + return $this; } /** - * 解析为Query对象可识别的查询条件数组 - * @access public + * 解析为Query对象可识别的查询条件数组. + * * @return array */ public function parse(): array @@ -80,15 +69,16 @@ class Where implements ArrayAccess } /** - * 分析查询表达式 - * @access protected - * @param string $field 查询字段 - * @param array $where 查询条件 + * 分析查询表达式. + * + * @param string $field 查询字段 + * @param array $where 查询条件 + * * @return array */ protected function parseItem(string $field, array $where = []): array { - $op = $where[0]; + $op = $where[0]; $condition = $where[1] ?? null; if (is_array($op)) { @@ -115,9 +105,10 @@ class Where implements ArrayAccess /** * 修改器 设置数据对象的值 - * @access public - * @param string $name 名称 - * @param mixed $value 值 + * + * @param string $name 名称 + * @param mixed $value 值 + * * @return void */ public function __set($name, $value) @@ -127,8 +118,9 @@ class Where implements ArrayAccess /** * 获取器 获取数据对象的值 - * @access public - * @param string $name 名称 + * + * @param string $name 名称 + * * @return mixed */ public function __get($name) @@ -138,8 +130,9 @@ class Where implements ArrayAccess /** * 检测数据对象的值 - * @access public - * @param string $name 名称 + * + * @param string $name 名称 + * * @return bool */ public function __isset($name) @@ -149,8 +142,9 @@ class Where implements ArrayAccess /** * 销毁数据对象的值 - * @access public - * @param string $name 名称 + * + * @param string $name 名称 + * * @return void */ public function __unset($name) @@ -159,24 +153,23 @@ class Where implements ArrayAccess } // ArrayAccess - public function offsetSet($name, $value) + public function offsetSet(mixed $name, mixed $value): void { $this->__set($name, $value); } - public function offsetExists($name) + public function offsetExists(mixed $name): bool { return $this->__isset($name); } - public function offsetUnset($name) + public function offsetUnset(mixed $name): void { $this->__unset($name); } - public function offsetGet($name) + public function offsetGet(mixed $name) { return $this->__get($name); } - } diff --git a/vendor/topthink/think-orm/src/db/builder/Mongo.php b/vendor/topthink/think-orm/src/db/builder/Mongo.php index 85ee551..ad691c4 100644 --- a/vendor/topthink/think-orm/src/db/builder/Mongo.php +++ b/vendor/topthink/think-orm/src/db/builder/Mongo.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); + namespace think\db\builder; use MongoDB\BSON\Javascript; @@ -30,8 +32,8 @@ class Mongo protected $exp = ['<>' => 'ne', '=' => 'eq', '>' => 'gt', '>=' => 'gte', '<' => 'lt', '<=' => 'lte', 'in' => 'in', 'not in' => 'nin', 'nin' => 'nin', 'mod' => 'mod', 'exists' => 'exists', 'null' => 'null', 'notnull' => 'not null', 'not null' => 'not null', 'regex' => 'regex', 'type' => 'type', 'all' => 'all', '> time' => '> time', '< time' => '< time', 'between' => 'between', 'not between' => 'not between', 'between time' => 'between time', 'not between time' => 'not between time', 'notbetween time' => 'not between time', 'like' => 'like', 'near' => 'near', 'size' => 'size']; /** - * 架构函数 - * @access public + * 架构函数. + * * @param Connection $connection 数据库连接对象实例 */ public function __construct(Connection $connection) @@ -40,8 +42,8 @@ class Mongo } /** - * 获取当前的连接对象实例 - * @access public + * 获取当前的连接对象实例. + * * @return Connection */ public function getConnection(): Connection @@ -50,14 +52,15 @@ class Mongo } /** - * key分析 - * @access protected + * key分析. + * * @param string $key + * * @return string */ protected function parseKey(Query $query, string $key): string { - if (0 === strpos($key, '__TABLE__.')) { + if (str_starts_with($key, '__TABLE__.')) { [$collection, $key] = explode('.', $key, 2); } @@ -69,11 +72,12 @@ class Mongo } /** - * value分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $value - * @param string $field + * value分析. + * + * @param Query $query 查询对象 + * @param mixed $value + * @param string $field + * * @return string */ protected function parseValue(Query $query, $value, $field = '') @@ -90,10 +94,11 @@ class Mongo } /** - * insert数据分析 - * @access protected + * insert数据分析. + * * @param Query $query 查询对象 - * @param array $data 数据 + * @param array $data 数据 + * * @return array */ protected function parseData(Query $query, array $data): array @@ -120,10 +125,11 @@ class Mongo } /** - * Set数据分析 - * @access protected + * Set数据分析. + * * @param Query $query 查询对象 - * @param array $data 数据 + * @param array $data 数据 + * * @return array */ protected function parseSet(Query $query, array $data): array @@ -137,7 +143,7 @@ class Mongo foreach ($data as $key => $val) { $item = $this->parseKey($query, $key); - if (is_array($val) && isset($val[0]) && is_string($val[0]) && 0 === strpos($val[0], '$')) { + if (is_array($val) && isset($val[0]) && is_string($val[0]) && str_starts_with($val[0], '$')) { $result[$val[0]][$item] = $this->parseValue($query, $val[1], $key); } else { $result['$set'][$item] = $this->parseValue($query, $val, $key); @@ -148,10 +154,11 @@ class Mongo } /** - * 生成查询过滤条件 - * @access public + * 生成查询过滤条件. + * * @param Query $query 查询对象 * @param mixed $where + * * @return array */ public function parseWhere(Query $query, array $where): array @@ -162,30 +169,30 @@ class Mongo $filter = []; foreach ($where as $logic => $val) { - $logic = '$' . strtolower($logic); + $logic = '$'.strtolower($logic); foreach ($val as $field => $value) { if (is_array($value)) { if (key($value) !== 0) { - throw new Exception('where express error:' . var_export($value, true)); + throw new Exception('where express error:'.var_export($value, true)); } $field = array_shift($value); } elseif (!($value instanceof \Closure)) { - throw new Exception('where express error:' . var_export($value, true)); + throw new Exception('where express error:'.var_export($value, true)); } if ($value instanceof \Closure) { // 使用闭包查询 $query = new Query($this->connection); - call_user_func_array($value, [ & $query]); + call_user_func_array($value, [&$query]); $filter[$logic][] = $this->parseWhere($query, $query->getOptions('where')); } else { - if (strpos($field, '|')) { + if (str_contains($field, '|')) { // 不同字段使用相同查询条件(OR) $array = explode('|', $field); foreach ($array as $k) { $filter['$or'][] = $this->parseWhereItem($query, $k, $value); } - } elseif (strpos($field, '&')) { + } elseif (str_contains($field, '&')) { // 不同字段使用相同查询条件(AND) $array = explode('&', $field); foreach ($array as $k) { @@ -193,7 +200,7 @@ class Mongo } } else { // 对字段使用表达式查询 - $field = is_string($field) ? $field : ''; + $field = is_string($field) ? $field : ''; $filter[$logic][] = $this->parseWhereItem($query, $field, $value); } } @@ -204,7 +211,7 @@ class Mongo if (!empty($options['soft_delete'])) { // 附加软删除条件 [$field, $condition] = $options['soft_delete']; - $filter['$and'][] = $this->parseWhereItem($query, $field, $condition); + $filter['$and'][] = $this->parseWhereItem($query, $field, $condition); } return $filter; @@ -224,7 +231,7 @@ class Mongo if (is_array($exp)) { $data = []; foreach ($val as $value) { - $exp = $value[0]; + $exp = $value[0]; $value = $value[1]; if (!in_array($exp, $this->exp)) { $exp = strtolower($exp); @@ -232,17 +239,18 @@ class Mongo $exp = $this->exp[$exp]; } } - $k = '$' . $exp; + $k = '$'.$exp; $data[$k] = $value; } $result[$key] = $data; + return $result; } elseif (!in_array($exp, $this->exp)) { $exp = strtolower($exp); if (isset($this->exp[$exp])) { $exp = $this->exp[$exp]; } else { - throw new Exception('where express error:' . $exp); + throw new Exception('where express error:'.$exp); } } @@ -252,7 +260,7 @@ class Mongo $result[$key] = $this->parseValue($query, $value, $key); } elseif (in_array($exp, ['neq', 'ne', 'gt', 'egt', 'gte', 'lt', 'lte', 'elt', 'mod'])) { // 比较运算 - $k = '$' . $exp; + $k = '$'.$exp; $result[$key] = [$k => $this->parseValue($query, $value, $key)]; } elseif ('null' == $exp) { // NULL 查询 @@ -264,11 +272,11 @@ class Mongo $result[$key] = ['$all', $this->parseValue($query, $value, $key)]; } elseif ('between' == $exp) { // 区间查询 - $value = is_array($value) ? $value : explode(',', $value); + $value = is_array($value) ? $value : explode(',', $value); $result[$key] = ['$gte' => $this->parseValue($query, $value[0], $key), '$lte' => $this->parseValue($query, $value[1], $key)]; } elseif ('not between' == $exp) { // 范围查询 - $value = is_array($value) ? $value : explode(',', $value); + $value = is_array($value) ? $value : explode(',', $value); $result[$key] = ['$lt' => $this->parseValue($query, $value[0], $key), '$gt' => $this->parseValue($query, $value[1], $key)]; } elseif ('exists' == $exp) { // 字段是否存在 @@ -288,7 +296,7 @@ class Mongo foreach ($value as $k => $val) { $value[$k] = $this->parseValue($query, $val, $key); } - $result[$key] = ['$' . $exp => $value]; + $result[$key] = ['$'.$exp => $value]; } elseif ('regex' == $exp) { $result[$key] = $value instanceof Regex ? $value : new Regex($value, 'i'); } elseif ('< time' == $exp) { @@ -297,11 +305,11 @@ class Mongo $result[$key] = ['$gt' => $this->parseDateTime($query, $value, $field)]; } elseif ('between time' == $exp) { // 区间查询 - $value = is_array($value) ? $value : explode(',', $value); + $value = is_array($value) ? $value : explode(',', $value); $result[$key] = ['$gte' => $this->parseDateTime($query, $value[0], $field), '$lte' => $this->parseDateTime($query, $value[1], $field)]; } elseif ('not between time' == $exp) { // 范围查询 - $value = is_array($value) ? $value : explode(',', $value); + $value = is_array($value) ? $value : explode(',', $value); $result[$key] = ['$lt' => $this->parseDateTime($query, $value[0], $field), '$gt' => $this->parseDateTime($query, $value[1], $field)]; } elseif ('near' == $exp) { // 经纬度查询 @@ -318,11 +326,12 @@ class Mongo } /** - * 日期时间条件解析 - * @access protected - * @param Query $query 查询对象 - * @param string $value - * @param string $key + * 日期时间条件解析. + * + * @param Query $query 查询对象 + * @param string $value + * @param string $key + * * @return string */ protected function parseDateTime(Query $query, $value, $key) @@ -350,8 +359,8 @@ class Mongo } /** - * 获取最后写入的ID 如果是insertAll方法的话 返回所有写入的ID - * @access public + * 获取最后写入的ID 如果是insertAll方法的话 返回所有写入的ID. + * * @return mixed */ public function getLastInsID() @@ -361,8 +370,9 @@ class Mongo /** * 生成insert BulkWrite对象 - * @access public - * @param Query $query 查询对象 + * + * @param Query $query 查询对象 + * * @return BulkWrite */ public function insert(Query $query): BulkWrite @@ -372,7 +382,7 @@ class Mongo $data = $this->parseData($query, $options['data']); - $bulk = new BulkWrite; + $bulk = new BulkWrite(); if ($insertId = $bulk->insert($data)) { $this->insertId = $insertId; @@ -385,14 +395,15 @@ class Mongo /** * 生成insertall BulkWrite对象 - * @access public - * @param Query $query 查询对象 - * @param array $dataSet 数据集 + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * * @return BulkWrite */ public function insertAll(Query $query, array $dataSet): BulkWrite { - $bulk = new BulkWrite; + $bulk = new BulkWrite(); $options = $query->getOptions(); $this->insertId = []; @@ -411,15 +422,16 @@ class Mongo /** * 生成update BulkWrite对象 - * @access public - * @param Query $query 查询对象 + * + * @param Query $query 查询对象 + * * @return BulkWrite */ public function update(Query $query): BulkWrite { $options = $query->getOptions(); - $data = $this->parseSet($query, $options['data']); + $data = $this->parseSet($query, $options['data']); $where = $this->parseWhere($query, $options['where']); if (1 == $options['limit']) { @@ -428,7 +440,7 @@ class Mongo $updateOptions = ['multi' => true]; } - $bulk = new BulkWrite; + $bulk = new BulkWrite(); $bulk->update($where, $data, $updateOptions); @@ -439,16 +451,17 @@ class Mongo /** * 生成delete BulkWrite对象 - * @access public - * @param Query $query 查询对象 + * + * @param Query $query 查询对象 + * * @return BulkWrite */ public function delete(Query $query): BulkWrite { $options = $query->getOptions(); - $where = $this->parseWhere($query, $options['where']); + $where = $this->parseWhere($query, $options['where']); - $bulk = new BulkWrite; + $bulk = new BulkWrite(); if (1 == $options['limit']) { $deleteOptions = ['limit' => 1]; @@ -465,9 +478,10 @@ class Mongo /** * 生成Mongo查询对象 - * @access public - * @param Query $query 查询对象 - * @param bool $one 是否仅获取一个记录 + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * * @return MongoQuery */ public function select(Query $query, bool $one = false): MongoQuery @@ -488,9 +502,10 @@ class Mongo } /** - * 生成Count命令 - * @access public - * @param Query $query 查询对象 + * 生成Count命令. + * + * @param Query $query 查询对象 + * * @return Command */ public function count(Query $query): Command @@ -513,33 +528,34 @@ class Mongo } /** - * 聚合查询命令 - * @access public - * @param Query $query 查询对象 - * @param array $extra 指令和字段 + * 聚合查询命令. + * + * @param Query $query 查询对象 + * @param array $extra 指令和字段 + * * @return Command */ public function aggregate(Query $query, array $extra): Command { - $options = $query->getOptions(); + $options = $query->getOptions(); [$fun, $field] = $extra; if ('id' == $field && $this->connection->getConfig('pk_convert_id')) { $field = '_id'; } - $group = isset($options['group']) ? '$' . $options['group'] : null; + $group = isset($options['group']) ? '$'.$options['group'] : null; $pipeline = [ ['$match' => (object) $this->parseWhere($query, $options['where'])], - ['$group' => ['_id' => $group, 'aggregate' => ['$' . $fun => '$' . $field]]], + ['$group' => ['_id' => $group, 'aggregate' => ['$'.$fun => '$'.$field]]], ]; $cmd = [ 'aggregate' => $options['table'], 'allowDiskUse' => true, 'pipeline' => $pipeline, - 'cursor' => new \stdClass, + 'cursor' => new \stdClass(), ]; foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) { @@ -556,10 +572,11 @@ class Mongo } /** - * 多聚合查询命令, 可以对多个字段进行 group by 操作 + * 多聚合查询命令, 可以对多个字段进行 group by 操作. + * + * @param Query $query 查询对象 + * @param array $extra 指令和字段 * - * @param Query $query 查询对象 - * @param array $extra 指令和字段 * @return Command */ public function multiAggregate(Query $query, $extra): Command @@ -571,11 +588,11 @@ class Mongo $groups = ['_id' => []]; foreach ($groupBy as $field) { - $groups['_id'][$field] = '$' . $field; + $groups['_id'][$field] = '$'.$field; } foreach ($aggregate as $fun => $field) { - $groups[$field . '_' . $fun] = ['$' . $fun => '$' . $field]; + $groups[$field.'_'.$fun] = ['$'.$fun => '$'.$field]; } $pipeline = [ @@ -587,7 +604,7 @@ class Mongo 'aggregate' => $options['table'], 'allowDiskUse' => true, 'pipeline' => $pipeline, - 'cursor' => new \stdClass, + 'cursor' => new \stdClass(), ]; foreach (['explain', 'collation', 'bypassDocumentValidation', 'readConcern'] as $option) { @@ -603,10 +620,11 @@ class Mongo } /** - * 生成distinct命令 - * @access public - * @param Query $query 查询对象 - * @param string $field 字段名 + * 生成distinct命令. + * + * @param Query $query 查询对象 + * @param string $field 字段名 + * * @return Command */ public function distinct(Query $query, $field): Command @@ -634,13 +652,13 @@ class Mongo } /** - * 查询所有的collection - * @access public + * 查询所有的collection. + * * @return Command */ public function listcollections(): Command { - $cmd = ['listCollections' => 1]; + $cmd = ['listCollections' => 1]; $command = new Command($cmd); $this->log('cmd', 'listCollections', $cmd); @@ -649,16 +667,17 @@ class Mongo } /** - * 查询数据表的状态信息 - * @access public - * @param Query $query 查询对象 + * 查询数据表的状态信息. + * + * @param Query $query 查询对象 + * * @return Command */ public function collStats(Query $query): Command { $options = $query->getOptions(); - $cmd = ['collStats' => $options['table']]; + $cmd = ['collStats' => $options['table']]; $command = new Command($cmd); $this->log('cmd', 'collStats', $cmd); diff --git a/vendor/topthink/think-orm/src/db/builder/Mysql.php b/vendor/topthink/think-orm/src/db/builder/Mysql.php index 7dda33a..96aad75 100644 --- a/vendor/topthink/think-orm/src/db/builder/Mysql.php +++ b/vendor/topthink/think-orm/src/db/builder/Mysql.php @@ -1,30 +1,32 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\builder; use PDO; use think\db\Builder; use think\db\exception\DbException as Exception; -use think\db\Query; +use think\db\BaseQuery as Query; use think\db\Raw; /** - * mysql数据库驱动 + * mysql数据库驱动. */ class Mysql extends Builder { /** - * 查询表达式解析 + * 查询表达式解析. + * * @var array */ protected $parser = [ @@ -43,40 +45,46 @@ class Mysql extends Builder ]; /** - * SELECT SQL表达式 + * SELECT SQL表达式. + * * @var string */ protected $selectSql = 'SELECT%DISTINCT%%EXTRA% %FIELD% FROM %TABLE%%PARTITION%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%UNION%%ORDER%%LIMIT% %LOCK%%COMMENT%'; /** - * INSERT SQL表达式 + * INSERT SQL表达式. + * * @var string */ protected $insertSql = '%INSERT%%EXTRA% INTO %TABLE%%PARTITION% SET %SET% %DUPLICATE%%COMMENT%'; /** - * INSERT ALL SQL表达式 + * INSERT ALL SQL表达式. + * * @var string */ protected $insertAllSql = '%INSERT%%EXTRA% INTO %TABLE%%PARTITION% (%FIELD%) VALUES %DATA% %DUPLICATE%%COMMENT%'; /** - * UPDATE SQL表达式 + * UPDATE SQL表达式. + * * @var string */ protected $updateSql = 'UPDATE%EXTRA% %TABLE%%PARTITION% %JOIN% SET %SET% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%'; /** - * DELETE SQL表达式 + * DELETE SQL表达式. + * * @var string */ protected $deleteSql = 'DELETE%EXTRA% FROM %TABLE%%PARTITION%%USING%%JOIN%%WHERE%%ORDER%%LIMIT% %LOCK%%COMMENT%'; /** - * 生成查询SQL - * @access public - * @param Query $query 查询对象 - * @param bool $one 是否仅获取一个记录 + * 生成查询SQL. + * + * @param Query $query 查询对象 + * @param bool $one 是否仅获取一个记录 + * * @return string */ public function select(Query $query, bool $one = false): string @@ -90,7 +98,7 @@ class Mysql extends Builder $this->parsePartition($query, $options['partition']), $this->parseDistinct($query, $options['distinct']), $this->parseExtra($query, $options['extra']), - $this->parseField($query, $options['field'] ?? '*'), + $this->parseField($query, $options['field'] ?? []), $this->parseJoin($query, $options['join']), $this->parseWhere($query, $options['where']), $this->parseGroup($query, $options['group']), @@ -107,9 +115,10 @@ class Mysql extends Builder } /** - * 生成Insert SQL - * @access public - * @param Query $query 查询对象 + * 生成Insert SQL. + * + * @param Query $query 查询对象 + * * @return string */ public function insert(Query $query): string @@ -143,18 +152,17 @@ class Mysql extends Builder } /** - * 生成insertall SQL - * @access public - * @param Query $query 查询对象 - * @param array $dataSet 数据集 + * 生成insertall SQL. + * + * @param Query $query 查询对象 + * @param array $dataSet 数据集 + * * @return string */ public function insertAll(Query $query, array $dataSet): string { - $options = $query->getOptions(); - - // 获取绑定信息 - $bind = $query->getFieldsBindType(); + $options = $query->getOptions(); + $bind = $query->getFieldsBindType(); // 获取合法的字段 if (empty($options['field']) || '*' == $options['field']) { @@ -207,8 +215,6 @@ class Mysql extends Builder public function insertAllByKeys(Query $query, array $keys, array $datas): string { $options = $query->getOptions(); - - // 获取绑定信息 $bind = $query->getFieldsBindType(); $fields = []; $values = []; @@ -245,16 +251,16 @@ class Mysql extends Builder } /** - * 生成update SQL - * @access public - * @param Query $query 查询对象 + * 生成update SQL. + * + * @param Query $query 查询对象 + * * @return string */ public function update(Query $query): string { - $options = $query->getOptions(); - - $data = $this->parseData($query, $options['data']); + $options = $query->getOptions(); + $data = $this->parseData($query, $options['data']); if (empty($data)) { return ''; @@ -262,7 +268,7 @@ class Mysql extends Builder $set = []; foreach ($data as $key => $val) { - $set[] = (strpos($key, '->') ? strstr($key, '->', true) : $key) . ' = ' . $val; + $set[] = (str_contains($key, '->') ? strstr($key, '->', true) : $key) . ' = ' . $val; } return str_replace( @@ -284,9 +290,10 @@ class Mysql extends Builder } /** - * 生成delete SQL - * @access public - * @param Query $query 查询对象 + * 生成delete SQL. + * + * @param Query $query 查询对象 + * * @return string */ public function delete(Query $query): string @@ -312,13 +319,14 @@ class Mysql extends Builder } /** - * 正则查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field + * 正则查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * * @return string */ protected function parseRegexp(Query $query, string $key, string $exp, $value, string $field): string @@ -331,13 +339,14 @@ class Mysql extends Builder } /** - * FIND_IN_SET 查询 - * @access protected - * @param Query $query 查询对象 - * @param string $key - * @param string $exp - * @param mixed $value - * @param string $field + * FIND_IN_SET 查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * * @return string */ protected function parseFindInSet(Query $query, string $key, string $exp, $value, string $field): string @@ -350,14 +359,15 @@ class Mysql extends Builder } /** - * 字段和表名处理 - * @access public - * @param Query $query 查询对象 - * @param mixed $key 字段名 - * @param bool $strict 严格检测 + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param mixed $key 字段名 + * @param bool $strict 严格检测 + * * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { if (is_int($key)) { return (string) $key; @@ -367,16 +377,17 @@ class Mysql extends Builder $key = trim($key); - if (strpos($key, '->>') && false === strpos($key, '(')) { + if (str_contains($key, '->>') && !str_contains($key, '(')) { // JSON字段支持 [$field, $name] = explode('->>', $key, 2); - return $this->parseKey($query, $field, true) . '->>\'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->>', '.', $name) . '\''; - } elseif (strpos($key, '->') && false === strpos($key, '(')) { + return $this->parseKey($query, $field, true) . '->>\'$' . (str_starts_with($name, '[') ? '' : '.') . str_replace('->>', '.', $name) . '\''; + } elseif (str_contains($key, '->') && !str_contains($key, '(')) { // JSON字段支持 [$field, $name] = explode('->', $key, 2); - return 'json_extract(' . $this->parseKey($query, $field, true) . ', \'$' . (strpos($name, '[') === 0 ? '' : '.') . str_replace('->', '.', $name) . '\')'; - } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { + + return 'json_extract(' . $this->parseKey($query, $field, true) . ', \'$' . (str_starts_with($name, '[') ? '' : '.') . str_replace('->', '.', $name) . '\')'; + } elseif (str_contains($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { [$table, $key] = explode('.', $key, 2); $alias = $query->getOptions('alias'); @@ -400,7 +411,7 @@ class Mysql extends Builder } if (isset($table)) { - if (strpos($table, '.')) { + if (str_contains($table, '.')) { $table = str_replace('.', '`.`', $table); } @@ -411,9 +422,35 @@ class Mysql extends Builder } /** - * 随机排序 - * @access protected - * @param Query $query 查询对象 + * Null查询. + * + * @param Query $query 查询对象 + * @param string $key + * @param string $exp + * @param mixed $value + * @param string $field + * @param int $bindType + * + * @return string + */ + protected function parseNull(Query $query, string $key, string $exp, $value, $field, int $bindType): string + { + if (str_starts_with($key, "json_extract")) { + if ($exp === 'NULL') { + return '(' . $key . ' is null OR json_type(' . $key . ') = \'NULL\')'; + }elseif ($exp === 'NOT NULL'){ + return '(' . $key . ' is not null AND json_type(' . $key . ') != \'NULL\')'; + } + } + + return parent::parseNull($query, $key, $exp, $value, $field, $bindType); + } + + /** + * 随机排序. + * + * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string @@ -422,10 +459,11 @@ class Mysql extends Builder } /** - * Partition 分析 - * @access protected - * @param Query $query 查询对象 - * @param string|array $partition 分区 + * Partition 分析. + * + * @param Query $query 查询对象 + * @param string|array $partition 分区 + * * @return string */ protected function parsePartition(Query $query, $partition): string @@ -442,10 +480,11 @@ class Mysql extends Builder } /** - * ON DUPLICATE KEY UPDATE 分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $duplicate + * ON DUPLICATE KEY UPDATE 分析. + * + * @param Query $query 查询对象 + * @param mixed $duplicate + * * @return string */ protected function parseDuplicate(Query $query, $duplicate): string @@ -465,13 +504,13 @@ class Mysql extends Builder $updates = []; foreach ($duplicate as $key => $val) { if (is_numeric($key)) { - $val = $this->parseKey($query, $val); + $val = $this->parseKey($query, $val); $updates[] = $val . ' = VALUES(' . $val . ')'; } elseif ($val instanceof Raw) { - $updates[] = $this->parseKey($query, $key) . " = " . $this->parseRaw($query, $val); + $updates[] = $this->parseKey($query, $key) . ' = ' . $this->parseRaw($query, $val); } else { - $name = $query->bindValue($val, $query->getConnection()->getFieldBindType($key)); - $updates[] = $this->parseKey($query, $key) . " = :" . $name; + $name = $query->bindValue($val, $query->getConnection()->getFieldBindType($key)); + $updates[] = $this->parseKey($query, $key) . ' = :' . $name; } } diff --git a/vendor/topthink/think-orm/src/db/builder/Oracle.php b/vendor/topthink/think-orm/src/db/builder/Oracle.php index 38feb5d..61f072b 100644 --- a/vendor/topthink/think-orm/src/db/builder/Oracle.php +++ b/vendor/topthink/think-orm/src/db/builder/Oracle.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\builder; use think\db\Builder; -use think\db\Query; use think\db\exception\DbException as Exception; +use think\db\BaseQuery as Query; use think\db\Raw; /** - * Oracle数据库驱动 + * Oracle数据库驱动. */ class Oracle extends Builder { protected $selectSql = 'SELECT * FROM (SELECT thinkphp.*, rownum AS numrow FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%) thinkphp ) %LIMIT%%COMMENT%'; /** - * limit分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $limit + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * * @return string */ protected function parseLimit(Query $query, string $limit): string @@ -37,24 +39,24 @@ class Oracle extends Builder $limit = explode(',', $limit); if (count($limit) > 1) { - $limitStr = "(numrow>" . $limit[0] . ") AND (numrow<=" . ($limit[0] + $limit[1]) . ")"; + $limitStr = '(numrow>' . $limit[0] . ') AND (numrow<=' . ($limit[0] + $limit[1]) . ')'; } else { - $limitStr = "(numrow>0 AND numrow<=" . $limit[0] . ")"; + $limitStr = '(numrow>0 AND numrow<=' . $limit[0] . ')'; } - } return $limitStr ? ' WHERE ' . $limitStr : ''; } /** - * 设置锁机制 - * @access protected - * @param Query $query 查询对象 - * @param bool|false $lock + * 设置锁机制. + * + * @param Query $query 查询对象 + * @param bool|string $lock + * * @return string */ - protected function parseLock(Query $query, $lock = false): string + protected function parseLock(Query $query, bool|string $lock = false): string { if (!$lock) { return ''; @@ -64,15 +66,17 @@ class Oracle extends Builder } /** - * 字段和表名处理 - * @access public - * @param Query $query 查询对象 - * @param string $key - * @param bool $strict - * @return string + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key + * @param bool $strict + * * @throws Exception + * + * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { if (is_int($key)) { return (string) $key; @@ -82,11 +86,11 @@ class Oracle extends Builder $key = trim($key); - if (strpos($key, '->') && false === strpos($key, '(')) { + if (str_contains($key, '->') && !str_contains($key, '(')) { // JSON字段支持 [$field, $name] = explode($key, '->'); - $key = $field . '."' . $name . '"'; - } elseif (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { + $key = $field . '."' . $name . '"'; + } elseif (str_contains($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { [$table, $key] = explode('.', $key, 2); $alias = $query->getOptions('alias'); @@ -117,9 +121,10 @@ class Oracle extends Builder } /** - * 随机排序 - * @access protected - * @param Query $query 查询对象 + * 随机排序. + * + * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string diff --git a/vendor/topthink/think-orm/src/db/builder/Pgsql.php b/vendor/topthink/think-orm/src/db/builder/Pgsql.php index 4eace0a..384deca 100644 --- a/vendor/topthink/think-orm/src/db/builder/Pgsql.php +++ b/vendor/topthink/think-orm/src/db/builder/Pgsql.php @@ -1,43 +1,47 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\builder; use think\db\Builder; -use think\db\Query; +use think\db\BaseQuery as Query; use think\db\Raw; /** - * Pgsql数据库驱动 + * Pgsql数据库驱动. */ class Pgsql extends Builder { /** - * INSERT SQL表达式 + * INSERT SQL表达式. + * * @var string */ protected $insertSql = 'INSERT INTO %TABLE% (%FIELD%) VALUES (%DATA%) %COMMENT%'; /** - * INSERT ALL SQL表达式 + * INSERT ALL SQL表达式. + * * @var string */ protected $insertAllSql = 'INSERT INTO %TABLE% (%FIELD%) %DATA% %COMMENT%'; /** - * limit分析 - * @access protected - * @param Query $query 查询对象 - * @param mixed $limit + * limit分析. + * + * @param Query $query 查询对象 + * @param mixed $limit + * * @return string */ public function parseLimit(Query $query, string $limit): string @@ -57,14 +61,15 @@ class Pgsql extends Builder } /** - * 字段和表名处理 - * @access public - * @param Query $query 查询对象 - * @param mixed $key 字段名 - * @param bool $strict 严格检测 + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key 字段名 + * @param bool $strict 严格检测 + * * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { if (is_int($key)) { return (string) $key; @@ -74,11 +79,11 @@ class Pgsql extends Builder $key = trim($key); - if (strpos($key, '->') && false === strpos($key, '(')) { + if (str_contains($key, '->') && !str_contains($key, '(')) { // JSON字段支持 [$field, $name] = explode('->', $key); - $key = '"' . $field . '"' . '->>\'' . $name . '\''; - } elseif (strpos($key, '.')) { + $key = '"' . $field . '"' . '->>\'' . $name . '\''; + } elseif (str_contains($key, '.')) { [$table, $key] = explode('.', $key, 2); $alias = $query->getOptions('alias'); @@ -105,14 +110,14 @@ class Pgsql extends Builder } /** - * 随机排序 - * @access protected - * @param Query $query 查询对象 + * 随机排序. + * + * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string { return 'RANDOM()'; } - } diff --git a/vendor/topthink/think-orm/src/db/builder/Sqlite.php b/vendor/topthink/think-orm/src/db/builder/Sqlite.php index ff17c5d..af21e7d 100644 --- a/vendor/topthink/think-orm/src/db/builder/Sqlite.php +++ b/vendor/topthink/think-orm/src/db/builder/Sqlite.php @@ -1,31 +1,33 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\builder; use think\db\Builder; -use think\db\Query; +use think\db\BaseQuery as Query; use think\db\Raw; /** - * Sqlite数据库驱动 + * Sqlite数据库驱动. */ class Sqlite extends Builder { /** - * limit - * @access public + * limit. + * * @param Query $query 查询对象 * @param mixed $limit + * * @return string */ public function parseLimit(Query $query, string $limit): string @@ -45,9 +47,10 @@ class Sqlite extends Builder } /** - * 随机排序 - * @access protected + * 随机排序. + * * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string @@ -56,14 +59,15 @@ class Sqlite extends Builder } /** - * 字段和表名处理 - * @access public + * 字段和表名处理. + * * @param Query $query 查询对象 - * @param mixed $key 字段名 + * @param string|int|Raw $key 字段名 * @param bool $strict 严格检测 + * * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { if (is_int($key)) { return (string) $key; @@ -73,7 +77,7 @@ class Sqlite extends Builder $key = trim($key); - if (strpos($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { + if (str_contains($key, '.') && !preg_match('/[,\'\"\(\)`\s]/', $key)) { [$table, $key] = explode('.', $key, 2); $alias = $query->getOptions('alias'); @@ -100,13 +104,14 @@ class Sqlite extends Builder } /** - * 设置锁机制 - * @access protected + * 设置锁机制. + * * @param Query $query 查询对象 * @param bool|string $lock + * * @return string */ - protected function parseLock(Query $query, $lock = false): string + protected function parseLock(Query $query, bool|string $lock = false): string { return ''; } diff --git a/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php b/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php index 779b5e3..0b72af5 100644 --- a/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php +++ b/vendor/topthink/think-orm/src/db/builder/Sqlsrv.php @@ -1,4 +1,5 @@ parseRand($query); } else { if (is_numeric($key)) { - [$key, $sort] = explode(' ', strpos($val, ' ') ? $val : $val . ' '); + [$key, $sort] = explode(' ', str_contains($val, ' ') ? $val : $val . ' '); } else { $sort = $val; } - $sort = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : ''; + $sort = in_array(strtolower($sort), ['asc', 'desc'], true) ? ' ' . $sort : ''; $array[] = $this->parseKey($query, $key, true) . $sort; } } @@ -92,9 +100,10 @@ class Sqlsrv extends Builder } /** - * 随机排序 - * @access protected - * @param Query $query 查询对象 + * 随机排序. + * + * @param Query $query 查询对象 + * * @return string */ protected function parseRand(Query $query): string @@ -103,14 +112,15 @@ class Sqlsrv extends Builder } /** - * 字段和表名处理 - * @access public - * @param Query $query 查询对象 - * @param mixed $key 字段名 - * @param bool $strict 严格检测 + * 字段和表名处理. + * + * @param Query $query 查询对象 + * @param string|int|Raw $key 字段名 + * @param bool $strict 严格检测 + * * @return string */ - public function parseKey(Query $query, $key, bool $strict = false): string + public function parseKey(Query $query, string|int|Raw $key, bool $strict = false): string { if (is_int($key)) { return (string) $key; @@ -120,7 +130,7 @@ class Sqlsrv extends Builder $key = trim($key); - if (strpos($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { + if (str_contains($key, '.') && !preg_match('/[,\'\"\(\)\[\s]/', $key)) { [$table, $key] = explode('.', $key, 2); $alias = $query->getOptions('alias'); @@ -151,10 +161,11 @@ class Sqlsrv extends Builder } /** - * limit - * @access protected - * @param Query $query 查询对象 - * @param mixed $limit + * limit. + * + * @param Query $query 查询对象 + * @param mixed $limit + * * @return string */ protected function parseLimit(Query $query, string $limit): string @@ -168,7 +179,7 @@ class Sqlsrv extends Builder if (count($limit) > 1) { $limitStr = '(T1.ROW_NUMBER BETWEEN ' . $limit[0] . ' + 1 AND ' . $limit[0] . ' + ' . $limit[1] . ')'; } else { - $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND ' . $limit[0] . ")"; + $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND ' . $limit[0] . ')'; } return 'WHERE ' . $limitStr; @@ -180,5 +191,4 @@ class Sqlsrv extends Builder return parent::selectInsert($query, $fields, $table); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php b/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php index d137d05..5e5194e 100644 --- a/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php +++ b/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -16,27 +17,29 @@ use think\db\exception\DbException; use think\db\Raw; /** - * 聚合查询 + * 聚合查询. */ trait AggregateQuery { /** - * 聚合查询 - * @access protected + * 聚合查询. + * * @param string $aggregate 聚合方法 * @param string|Raw $field 字段名 * @param bool $force 强制转为数字类型 + * * @return mixed */ - protected function aggregate(string $aggregate, $field, bool $force = false) + protected function aggregate(string $aggregate, string|Raw $field, bool $force = false, bool $one = false) { - return $this->connection->aggregate($this, $aggregate, $field, $force); + return $this->connection->aggregate($this, $aggregate, $field, $force, $one); } /** - * COUNT查询 - * @access public - * @param string|Raw $field 字段名 + * COUNT查询. + * + * @param string $field 字段名 + * * @return int */ public function count(string $field = '*'): int @@ -74,49 +77,52 @@ trait AggregateQuery } /** - * SUM查询 - * @access public + * SUM查询. + * * @param string|Raw $field 字段名 + * * @return float */ - public function sum($field): float + public function sum(string|Raw $field): float { return $this->aggregate('SUM', $field, true); } /** - * MIN查询 - * @access public + * MIN查询. + * * @param string|Raw $field 字段名 * @param bool $force 强制转为数字类型 + * * @return mixed */ - public function min($field, bool $force = true) + public function min(string|Raw $field, bool $force = true) { return $this->aggregate('MIN', $field, $force); } /** - * MAX查询 - * @access public + * MAX查询. + * * @param string|Raw $field 字段名 * @param bool $force 强制转为数字类型 + * * @return mixed */ - public function max($field, bool $force = true) + public function max(string|Raw $field, bool $force = true) { return $this->aggregate('MAX', $field, $force); } /** - * AVG查询 - * @access public + * AVG查询. + * * @param string|Raw $field 字段名 + * * @return float */ - public function avg($field): float + public function avg(string|Raw $field): float { return $this->aggregate('AVG', $field, true); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php b/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php index 2828949..7c28608 100644 --- a/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php +++ b/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php @@ -1,35 +1,36 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; use think\db\Raw; /** - * JOIN和VIEW查询 + * JOIN和VIEW查询. */ trait JoinAndViewQuery { - /** - * 查询SQL组装 join - * @access public - * @param mixed $join 关联的表名 + * 查询SQL组装 join. + * + * @param array|string|Raw $join 关联的表名 * @param mixed $condition 条件 * @param string $type JOIN类型 * @param array $bind 参数绑定 + * * @return $this */ - public function join($join, string $condition = null, string $type = 'INNER', array $bind = []) + public function join(array|string|Raw $join, string $condition = null, string $type = 'INNER', array $bind = []) { $table = $this->getJoinTable($join); @@ -43,57 +44,62 @@ trait JoinAndViewQuery } /** - * LEFT JOIN - * @access public - * @param mixed $join 关联的表名 + * LEFT JOIN. + * + * @param array|string|Raw $join 关联的表名 * @param mixed $condition 条件 * @param array $bind 参数绑定 + * * @return $this */ - public function leftJoin($join, string $condition = null, array $bind = []) + public function leftJoin(array|string|Raw $join, string $condition = null, array $bind = []) { return $this->join($join, $condition, 'LEFT', $bind); } /** - * RIGHT JOIN - * @access public - * @param mixed $join 关联的表名 + * RIGHT JOIN. + * + * @param array|string|Raw $join 关联的表名 * @param mixed $condition 条件 * @param array $bind 参数绑定 + * * @return $this */ - public function rightJoin($join, string $condition = null, array $bind = []) + public function rightJoin(array|string|Raw $join, string $condition = null, array $bind = []) { return $this->join($join, $condition, 'RIGHT', $bind); } /** - * FULL JOIN - * @access public - * @param mixed $join 关联的表名 + * FULL JOIN. + * + * @param array|string|Raw $join 关联的表名 * @param mixed $condition 条件 * @param array $bind 参数绑定 + * * @return $this */ - public function fullJoin($join, string $condition = null, array $bind = []) + public function fullJoin(array|string|Raw $join, string $condition = null, array $bind = []) { return $this->join($join, $condition, 'FULL'); } /** * 获取Join表名及别名 支持 - * ['prefix_table或者子查询'=>'alias'] 'table alias' - * @access protected + * ['prefix_table或者子查询'=>'alias'] 'table alias'. + * * @param array|string|Raw $join JION表名 * @param string $alias 别名 + * * @return string|array */ - protected function getJoinTable($join, &$alias = null) + protected function getJoinTable(array|string|Raw $join, string &$alias = null) { if (is_array($join)) { $table = $join; $alias = array_shift($join); + return $table; } elseif ($join instanceof Raw) { return $join; @@ -101,22 +107,22 @@ trait JoinAndViewQuery $join = trim($join); - if (false !== strpos($join, '(')) { + if (str_contains($join, '(')) { // 使用子查询 $table = $join; } else { // 使用别名 - if (strpos($join, ' ')) { + if (str_contains($join, ' ')) { // 使用别名 [$table, $alias] = explode(' ', $join); } else { $table = $join; - if (false === strpos($join, '.')) { + if (!str_contains($join, '.')) { $alias = $join; } } - if ($this->prefix && false === strpos($table, '.') && 0 !== strpos($table, $this->prefix)) { + if ($this->prefix && !str_contains($table, '.') && !str_starts_with($table, $this->prefix)) { $table = $this->getTable($table); } } @@ -129,21 +135,22 @@ trait JoinAndViewQuery } /** - * 指定JOIN查询字段 - * @access public - * @param string|array $join 数据表 - * @param string|array $field 查询字段 + * 指定JOIN查询字段. + * + * @param array|string|Raw $join 数据表 + * @param string|array|bool $field 查询字段 * @param string $on JOIN条件 * @param string $type JOIN类型 * @param array $bind 参数绑定 + * * @return $this */ - public function view($join, $field = true, $on = null, string $type = 'INNER', array $bind = []) + public function view(array|string|Raw $join, string|array|bool $field = true, string $on = null, string $type = 'INNER', array $bind = []) { $this->options['view'] = true; $fields = []; - $table = $this->getJoinTable($join, $alias); + $table = $this->getJoinTable($join, $alias); if (true === $field) { $fields = $alias . '.*'; @@ -183,9 +190,10 @@ trait JoinAndViewQuery } /** - * 视图查询处理 - * @access protected + * 视图查询处理. + * * @param array $options 查询参数 + * * @return void */ protected function parseView(array &$options): void @@ -207,7 +215,7 @@ trait JoinAndViewQuery // 视图查询排序处理 foreach ($options['order'] as $key => $val) { if (is_numeric($key) && is_string($val)) { - if (strpos($val, ' ')) { + if (str_contains($val, ' ')) { [$field, $sort] = explode(' ', $val); if (array_key_exists($field, $options['map'])) { $options['order'][$options['map'][$field]] = $sort; @@ -224,5 +232,4 @@ trait JoinAndViewQuery } } } - } diff --git a/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php b/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php index cabd65b..734f1fd 100644 --- a/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php +++ b/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -18,32 +19,34 @@ use think\Model; use think\model\Collection as ModelCollection; /** - * 模型及关联查询 + * 模型及关联查询. */ trait ModelRelationQuery { - /** * 当前模型对象 + * * @var Model */ protected $model; /** - * 指定模型 - * @access public + * 指定模型. + * * @param Model $model 模型对象实例 + * * @return $this */ public function model(Model $model) { $this->model = $model; + return $this; } /** * 获取当前的模型对象 - * @access public + * * @return Model|null */ public function getModel() @@ -52,9 +55,10 @@ trait ModelRelationQuery } /** - * 设置需要隐藏的输出属性 - * @access public - * @param array $hidden 属性列表 + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * * @return $this */ public function hidden(array $hidden = []) @@ -65,9 +69,10 @@ trait ModelRelationQuery } /** - * 设置需要输出的属性 - * @access public - * @param array $visible + * 设置需要输出的属性. + * + * @param array $visible + * * @return $this */ public function visible(array $visible = []) @@ -78,9 +83,10 @@ trait ModelRelationQuery } /** - * 设置需要附加的输出属性 - * @access public - * @param array $append 属性列表 + * 设置需要附加的输出属性. + * + * @param array $append 属性列表 + * * @return $this */ public function append(array $append = []) @@ -91,10 +97,11 @@ trait ModelRelationQuery } /** - * 添加查询范围 - * @access public + * 添加查询范围. + * * @param array|string|Closure $scope 查询范围定义 * @param array $args 参数 + * * @return $this */ public function scope($scope, ...$args) @@ -104,6 +111,7 @@ trait ModelRelationQuery if ($scope instanceof Closure) { call_user_func_array($scope, $args); + return $this; } @@ -126,9 +134,10 @@ trait ModelRelationQuery } /** - * 设置关联查询 - * @access public + * 设置关联查询. + * * @param array $relation 关联名称 + * * @return $this */ public function relation(array $relation) @@ -138,15 +147,17 @@ trait ModelRelationQuery } $this->options['relation'] = $relation; + return $this; } /** - * 使用搜索器条件搜索字段 - * @access public - * @param string|array $fields 搜索字段 - * @param mixed $data 搜索数据 - * @param string $prefix 字段前缀标识 + * 使用搜索器条件搜索字段. + * + * @param string|array $fields 搜索字段 + * @param mixed $data 搜索数据 + * @param string $prefix 字段前缀标识 + * * @return $this */ public function withSearch($fields, $data = [], string $prefix = '') @@ -163,7 +174,7 @@ trait ModelRelationQuery } elseif ($this->model) { // 检测搜索器 $fieldName = is_numeric($key) ? $field : $key; - $method = 'search' . Str::studly($fieldName) . 'Attr'; + $method = 'search' . Str::studly($fieldName) . 'Attr'; if (method_exists($this->model, $method)) { $this->model->$method($this, $data[$field] ?? null, $data, $prefix); @@ -177,28 +188,71 @@ trait ModelRelationQuery } /** - * 设置数据字段获取器 - * @access public - * @param string|array $name 字段名 - * @param callable $callback 闭包获取器 + * 限制关联数据的字段 已废弃直接使用field或withoutfield替代. + * + * @deprecated + * + * @param array|string $field 关联字段限制 + * * @return $this */ - public function withAttr($name, callable $callback = null) + public function withField($field) + { + return $this->field($field); + } + + /** + * 限制关联数据的数量 已废弃直接使用limit替代. + * + * @deprecated + * + * @param int $limit 关联数量限制 + * + * @return $this + */ + public function withLimit(int $limit) + { + return $this->limit($limit); + } + + /** + * 设置关联数据不存在的时候默认值 + * + * @param mixed $data 默认值 + * + * @return $this + */ + public function withDefault($data = null) + { + $this->options['default_model'] = $data; + + return $this; + } + + /** + * 设置数据字段获取器. + * + * @param string|array $name 字段名 + * @param callable $callback 闭包获取器 + * + * @return $this + */ + public function withAttr(string|array $name, callable $callback = null) { if (is_array($name)) { foreach ($name as $key => $val) { $this->withAttr($key, $val); } + return $this; } $this->options['with_attr'][$name] = $callback; - if (strpos($name, '.')) { + if (str_contains($name, '.')) { [$relation, $field] = explode('.', $name); if (!empty($this->options['json']) && in_array($relation, $this->options['json'])) { - } else { $this->options['with_relation_attr'][$relation][$field] = $callback; unset($this->options['with_attr'][$name]); @@ -209,49 +263,52 @@ trait ModelRelationQuery } /** - * 关联预载入 In方式 - * @access public + * 关联预载入 In方式. + * * @param array|string $with 关联方法名称 + * * @return $this */ - public function with($with) + public function with(array|string $with) { if (empty($this->model) || empty($with)) { return $this; } $this->options['with'] = (array) $with; + return $this; } /** - * 关联预载入 JOIN方式 - * @access protected + * 关联预载入 JOIN方式. + * * @param array|string $with 关联方法名 * @param string $joinType JOIN方式 + * * @return $this */ - public function withJoin($with, string $joinType = '') + public function withJoin(array|string $with, string $joinType = '') { if (empty($this->model) || empty($with)) { return $this; } - $with = (array) $with; + $with = (array) $with; $first = true; foreach ($with as $key => $relation) { $closure = null; - $field = true; + $field = true; if ($relation instanceof Closure) { // 支持闭包查询过滤关联条件 - $closure = $relation; + $closure = $relation; $relation = $key; } elseif (is_array($relation)) { - $field = $relation; + $field = $relation; $relation = $key; - } elseif (is_string($relation) && strpos($relation, '.')) { + } elseif (is_string($relation) && str_contains($relation, '.')) { $relation = strstr($relation, '.', true); } @@ -272,14 +329,15 @@ trait ModelRelationQuery /** * 关联统计 - * @access protected + * * @param array|string $relations 关联方法名 * @param string $aggregate 聚合查询方法 * @param string $field 字段 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - protected function withAggregate($relations, string $aggregate = 'count', $field = '*', bool $subQuery = true) + protected function withAggregate(string|array $relations, string $aggregate = 'count', $field = '*', bool $subQuery = true) { if (empty($this->model)) { return $this; @@ -287,6 +345,7 @@ trait ModelRelationQuery if (!$subQuery) { $this->options['with_aggregate'][] = [(array) $relations, $aggregate, $field]; + return $this; } @@ -295,19 +354,21 @@ trait ModelRelationQuery } $this->model->relationCount($this, (array) $relations, $aggregate, $field, true); + return $this; } /** - * 关联缓存 - * @access public + * 关联缓存. + * * @param string|array|bool $relation 关联方法名 - * @param mixed $key 缓存key - * @param integer|\DateTime $expire 缓存有效期 - * @param string $tag 缓存标签 + * @param mixed $key 缓存key + * @param int|\DateTime $expire 缓存有效期 + * @param string $tag 缓存标签 + * * @return $this */ - public function withCache($relation = true, $key = true, $expire = null, string $tag = null) + public function withCache(string|array|bool $relation = true, $key = true, $expire = null, string $tag = null) { if (empty($this->model)) { return $this; @@ -319,11 +380,12 @@ trait ModelRelationQuery if ($key instanceof \DateTimeInterface || $key instanceof \DateInterval || (is_int($key) && is_null($expire))) { $expire = $key; - $key = true; + $key = true; } if (true === $relation || is_numeric($relation)) { $this->options['with_cache'] = $relation; + return $this; } @@ -341,76 +403,82 @@ trait ModelRelationQuery /** * 关联统计 - * @access public + * * @param string|array $relation 关联方法名 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - public function withCount($relation, bool $subQuery = true) + public function withCount(string|array $relation, bool $subQuery = true) { return $this->withAggregate($relation, 'count', '*', $subQuery); } /** - * 关联统计Sum - * @access public + * 关联统计Sum. + * * @param string|array $relation 关联方法名 * @param string $field 字段 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - public function withSum($relation, string $field, bool $subQuery = true) + public function withSum(string|array $relation, string $field, bool $subQuery = true) { return $this->withAggregate($relation, 'sum', $field, $subQuery); } /** - * 关联统计Max - * @access public + * 关联统计Max. + * * @param string|array $relation 关联方法名 * @param string $field 字段 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - public function withMax($relation, string $field, bool $subQuery = true) + public function withMax(string|array $relation, string $field, bool $subQuery = true) { return $this->withAggregate($relation, 'max', $field, $subQuery); } /** - * 关联统计Min - * @access public + * 关联统计Min. + * * @param string|array $relation 关联方法名 * @param string $field 字段 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - public function withMin($relation, string $field, bool $subQuery = true) + public function withMin(string|array $relation, string $field, bool $subQuery = true) { return $this->withAggregate($relation, 'min', $field, $subQuery); } /** - * 关联统计Avg - * @access public + * 关联统计Avg. + * * @param string|array $relation 关联方法名 * @param string $field 字段 * @param bool $subQuery 是否使用子查询 + * * @return $this */ - public function withAvg($relation, string $field, bool $subQuery = true) + public function withAvg(string|array $relation, string $field, bool $subQuery = true) { return $this->withAggregate($relation, 'avg', $field, $subQuery); } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $relation 关联方法名 - * @param mixed $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 + * 根据关联条件查询当前模型. + * + * @param string $relation 关联方法名 + * @param mixed $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * * @return $this */ public function has(string $relation, string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '') @@ -419,12 +487,13 @@ trait ModelRelationQuery } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $relation 关联方法名 - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 + * 根据关联条件查询当前模型. + * + * @param string $relation 关联方法名 + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * * @return $this */ public function hasWhere(string $relation, $where = [], string $fields = '*', string $joinType = '') @@ -433,9 +502,10 @@ trait ModelRelationQuery } /** - * JSON字段数据转换 - * @access protected - * @param array $result 查询数据 + * JSON字段数据转换. + * + * @param array $result 查询数据 + * * @return void */ protected function jsonModelResult(array &$result): void @@ -460,8 +530,9 @@ trait ModelRelationQuery /** * 查询数据转换为模型数据集对象 - * @access protected + * * @param array $resultSet 数据集 + * * @return ModelCollection */ protected function resultSetToModelCollection(array $resultSet): ModelCollection @@ -484,7 +555,7 @@ trait ModelRelationQuery $resultSet, $this->options[$with], $this->options['with_relation_attr'], - 'with_join' == $with ? true : false, + 'with_join' == $with, $this->options['with_cache'] ?? false ); } @@ -496,8 +567,9 @@ trait ModelRelationQuery /** * 查询数据转换为模型对象 - * @access protected - * @param array $result 查询数据 + * + * @param array $result 查询数据 + * * @return void */ protected function resultToModel(array &$result): void @@ -507,6 +579,14 @@ trait ModelRelationQuery $this->jsonModelResult($result); } + // 实时读取延迟数据 + if (!empty($this->options['lazy_fields'])) { + $id = $this->getKey($result); + foreach ($this->options['lazy_fields'] as $field) { + $result[$field] += $this->getLazyFieldValue($field, $id); + } + } + $result = $this->model->newInstance( $result, !empty($this->options['is_resultSet']) ? null : $this->getModelUpdateCondition($this->options), @@ -530,7 +610,7 @@ trait ModelRelationQuery $result->eagerlyResult( $this->options[$with], $this->options['with_relation_attr'], - 'with_join' == $with ? true : false, + 'with_join' == $with, $this->options['with_cache'] ?? false ); } @@ -558,5 +638,4 @@ trait ModelRelationQuery // 刷新原始数据 $result->refreshOrigin(); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/ParamsBind.php b/vendor/topthink/think-orm/src/db/concern/ParamsBind.php index 88293fa..5c39704 100644 --- a/vendor/topthink/think-orm/src/db/concern/ParamsBind.php +++ b/vendor/topthink/think-orm/src/db/concern/ParamsBind.php @@ -1,18 +1,19 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; -use PDO; +use think\db\Connection; /** * 参数绑定支持 @@ -20,65 +21,73 @@ use PDO; trait ParamsBind { /** - * 当前参数绑定 + * 当前参数绑定. + * * @var array */ protected $bind = []; /** - * 批量参数绑定 - * @access public + * 批量参数绑定. + * * @param array $value 绑定变量值 + * * @return $this */ public function bind(array $value) { $this->bind = array_merge($this->bind, $value); + return $this; } /** - * 单个参数绑定 - * @access public - * @param mixed $value 绑定变量值 - * @param integer $type 绑定类型 - * @param string $name 绑定标识 + * 单个参数绑定. + * + * @param mixed $value 绑定变量值 + * @param int $type 绑定类型 + * @param string $name 绑定标识 + * * @return string */ public function bindValue($value, int $type = null, string $name = null) { $name = $name ?: 'ThinkBind_' . (count($this->bind) + 1) . '_' . mt_rand() . '_'; - $this->bind[$name] = [$value, $type ?: PDO::PARAM_STR]; + $this->bind[$name] = [$value, $type ?: Connection::PARAM_STR]; + return $name; } /** - * 检测参数是否已经绑定 - * @access public + * 检测参数是否已经绑定. + * * @param string $key 参数名 + * * @return bool */ - public function isBind($key) + public function isBind(string $key) { return isset($this->bind[$key]); } /** - * 设置自动参数绑定 - * @access public + * 设置自动参数绑定. + * * @param bool $bind 是否自动参数绑定 + * * @return $this */ public function autoBind(bool $bind) { $this->options['auto_bind'] = $bind; + return $this; } /** - * 检测是否开启自动参数绑定 - * @access public + * 检测是否开启自动参数绑定. + * * @return bool */ public function isAutoBind(): bool @@ -92,10 +101,11 @@ trait ParamsBind } /** - * 参数绑定 - * @access public + * 参数绑定. + * * @param string $sql 绑定的sql表达式 * @param array $bind 参数绑定 + * * @return void */ public function bindParams(string &$sql, array $bind = []): void @@ -116,9 +126,10 @@ trait ParamsBind } /** - * 获取绑定的参数 并清空 - * @access public + * 获取绑定的参数 并清空. + * * @param bool $clear 是否清空绑定数据 + * * @return array */ public function getBind(bool $clear = true): array diff --git a/vendor/topthink/think-orm/src/db/concern/ResultOperation.php b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php index ea26916..d5db949 100644 --- a/vendor/topthink/think-orm/src/db/concern/ResultOperation.php +++ b/vendor/topthink/think-orm/src/db/concern/ResultOperation.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -22,15 +23,16 @@ use think\helper\Str; use think\Model; /** - * 查询数据处理 + * 查询数据处理. */ trait ResultOperation { /** - * 设置数据处理(支持模型) - * @access public + * 设置数据处理(支持模型). + * * @param callable $filter 数据处理Callable * @param string $index 索引(唯一) + * * @return $this */ public function filter(callable $filter, string $index = null) @@ -40,37 +42,43 @@ trait ResultOperation } else { $this->options['filter'][] = $filter; } + return $this; } /** - * 是否允许返回空数据(或空模型) - * @access public + * 是否允许返回空数据(或空模型). + * * @param bool $allowEmpty 是否允许为空 + * * @return $this */ public function allowEmpty(bool $allowEmpty = true) { $this->options['allow_empty'] = $allowEmpty; + return $this; } /** - * 设置查询数据不存在是否抛出异常 - * @access public + * 设置查询数据不存在是否抛出异常. + * * @param bool $fail 数据不存在是否抛出异常 + * * @return $this */ public function failException(bool $fail = true) { $this->options['fail'] = $fail; + return $this; } /** - * 处理数据 - * @access protected + * 处理数据. + * * @param array $result 查询数据 + * * @return void */ protected function result(array &$result): void @@ -80,6 +88,14 @@ trait ResultOperation $this->jsonResult($result); } + // 实时读取延迟数据 + if (!empty($this->options['lazy_fields'])) { + $id = $this->getKey($result); + foreach ($this->options['lazy_fields'] as $field) { + $result[$field] += $this->getLazyFieldValue($field, $id); + } + } + // 查询数据处理 foreach ($this->options['filter'] as $filter) { $result = call_user_func_array($filter, [$result, $this->options]); @@ -92,10 +108,11 @@ trait ResultOperation } /** - * 处理数据集 - * @access public - * @param array $resultSet 数据集 + * 处理数据集. + * + * @param array $resultSet 数据集 * @param bool $toCollection 是否转为对象 + * * @return void */ protected function resultSet(array &$resultSet, bool $toCollection = true): void @@ -111,10 +128,11 @@ trait ResultOperation } /** - * 使用获取器处理数据 - * @access protected + * 使用获取器处理数据. + * * @param array $result 查询数据 * @param array $withAttr 字段获取器 + * * @return void */ protected function getResultAttr(array &$result, array $withAttr = []): void @@ -122,7 +140,7 @@ trait ResultOperation foreach ($withAttr as $name => $closure) { $name = Str::snake($name); - if (strpos($name, '.')) { + if (str_contains($name, '.')) { // 支持JSON字段 获取器定义 [$key, $field] = explode('.', $name); @@ -136,12 +154,13 @@ trait ResultOperation } /** - * 处理空数据 - * @access protected - * @return array|Model|null|static + * 处理空数据. + * * @throws DbException * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return array|Model|null|static */ protected function resultToEmpty() { @@ -153,9 +172,10 @@ trait ResultOperation } /** - * 查找单条记录 不存在返回空数据(或者空模型) - * @access public + * 查找单条记录 不存在返回空数据(或者空模型). + * * @param mixed $data 数据 + * * @return array|Model|static|mixed */ public function findOrEmpty($data = null) @@ -164,9 +184,10 @@ trait ResultOperation } /** - * JSON字段数据转换 - * @access protected + * JSON字段数据转换. + * * @param array $result 查询数据 + * * @return void */ protected function jsonResult(array &$result): void @@ -181,47 +202,53 @@ trait ResultOperation } /** - * 查询失败 抛出异常 - * @access protected - * @return void + * 查询失败 抛出异常. + * * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return void */ protected function throwNotFound(): void { if (!empty($this->model)) { $class = get_class($this->model); - throw new ModelNotFoundException('model data Not Found:' . $class, $class, $this->options); + + throw new ModelNotFoundException('model data Not Found:'.$class, $class, $this->options); } $table = $this->getTable(); - throw new DataNotFoundException('table data not Found:' . $table, $table, $this->options); + + throw new DataNotFoundException('table data not Found:'.$table, $table, $this->options); } /** - * 查找多条记录 如果不存在则抛出异常 - * @access public + * 查找多条记录 如果不存在则抛出异常. + * * @param array|string|Query|Closure $data 数据 - * @return array|Collection|static[] + * * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return array|Collection|static[] */ - public function selectOrFail($data = null) + public function selectOrFail($data = []) { return $this->failException(true)->select($data); } /** - * 查找单条记录 如果不存在则抛出异常 - * @access public + * 查找单条记录 如果不存在则抛出异常. + * * @param array|string|Query|Closure $data 数据 - * @return array|Model|static|mixed + * * @throws ModelNotFoundException * @throws DataNotFoundException + * + * @return array|Model|static|mixed */ public function findOrFail($data = null) { return $this->failException(true)->find($data); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php b/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php index 9070bef..814d1aa 100644 --- a/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php +++ b/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php @@ -1,30 +1,31 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; /** - * 数据字段信息 + * 数据字段信息. */ trait TableFieldInfo { - /** - * 获取数据表字段信息 - * @access public + * 获取数据表字段信息. + * * @param string $tableName 数据表名 + * * @return array */ - public function getTableFields($tableName = ''): array + public function getTableFields(string $tableName = ''): array { if ('' == $tableName) { $tableName = $this->getTable(); @@ -34,9 +35,10 @@ trait TableFieldInfo } /** - * 获取详细字段类型信息 - * @access public + * 获取详细字段类型信息. + * * @param string $tableName 数据表名称 + * * @return array */ public function getFields(string $tableName = ''): array @@ -45,8 +47,8 @@ trait TableFieldInfo } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @return array */ public function getFieldsType(): array @@ -59,9 +61,10 @@ trait TableFieldInfo } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @param string $field 字段名 + * * @return string|null */ public function getFieldType(string $field) @@ -72,8 +75,8 @@ trait TableFieldInfo } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @return array */ public function getFieldsBindType(): array @@ -84,9 +87,10 @@ trait TableFieldInfo } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @param string $field 字段名 + * * @return int */ public function getFieldBindType(string $field): int @@ -95,5 +99,4 @@ trait TableFieldInfo return $this->connection->getFieldBindType($fieldType ?: ''); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php b/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php index 69b7eae..b5830fe 100644 --- a/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php +++ b/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -18,7 +19,8 @@ namespace think\db\concern; trait TimeFieldQuery { /** - * 日期查询表达式 + * 日期查询表达式. + * * @var array */ protected $timeRule = [ @@ -33,34 +35,33 @@ trait TimeFieldQuery ]; /** - * 添加日期或者时间查询规则 - * @access public + * 添加日期或者时间查询规则. + * * @param array $rule 时间表达式 + * * @return $this */ public function timeRule(array $rule) { $this->timeRule = array_merge($this->timeRule, $rule); + return $this; } /** - * 查询日期或者时间 - * @access public + * 查询日期或者时间. + * * @param string $field 日期字段名 * @param string $op 比较运算符或者表达式 - * @param string|array $range 比较范围 + * @param mixed $range 比较范围 * @param string $logic AND OR + * * @return $this */ public function whereTime(string $field, string $op, $range = null, string $logic = 'AND') { if (is_null($range)) { - if (isset($this->timeRule[$op])) { - $range = $this->timeRule[$op]; - } else { - $range = $op; - } + $range = $this->timeRule[$op] ?? $op; $op = is_array($range) ? 'between' : '>='; } @@ -68,30 +69,32 @@ trait TimeFieldQuery } /** - * 查询某个时间间隔数据 - * @access public + * 查询某个时间间隔数据. + * * @param string $field 日期字段名 * @param string $start 开始时间 * @param string $interval 时间间隔单位 day/month/year/week/hour/minute/second * @param int $step 间隔 * @param string $logic AND OR + * * @return $this */ public function whereTimeInterval(string $field, string $start, string $interval = 'day', int $step = 1, string $logic = 'AND') { $startTime = strtotime($start); - $endTime = strtotime(($step > 0 ? '+' : '-') . abs($step) . ' ' . $interval . (abs($step) > 1 ? 's' : ''), $startTime); + $endTime = strtotime(($step > 0 ? '+' : '-') . abs($step) . ' ' . $interval . (abs($step) > 1 ? 's' : ''), $startTime); return $this->whereTime($field, 'between', $step > 0 ? [$startTime, $endTime - 1] : [$endTime, $startTime - 1], $logic); } /** - * 查询月数据 whereMonth('time_field', '2018-1') - * @access public + * 查询月数据 whereMonth('time_field', '2018-1'). + * * @param string $field 日期字段名 * @param string $month 月份信息 * @param int $step 间隔 * @param string $logic AND OR + * * @return $this */ public function whereMonth(string $field, string $month = 'this month', int $step = 1, string $logic = 'AND') @@ -104,12 +107,13 @@ trait TimeFieldQuery } /** - * 查询周数据 whereWeek('time_field', '2018-1-1') 从2018-1-1开始的一周数据 - * @access public + * 查询周数据 whereWeek('time_field', '2018-1-1') 从2018-1-1开始的一周数据. + * * @param string $field 日期字段名 * @param string $week 周信息 * @param int $step 间隔 * @param string $logic AND OR + * * @return $this */ public function whereWeek(string $field, string $week = 'this week', int $step = 1, string $logic = 'AND') @@ -122,12 +126,13 @@ trait TimeFieldQuery } /** - * 查询年数据 whereYear('time_field', '2018') - * @access public + * 查询年数据 whereYear('time_field', '2018'). + * * @param string $field 日期字段名 * @param string $year 年份信息 - * @param int $step 间隔 + * @param int $step 间隔 * @param string $logic AND OR + * * @return $this */ public function whereYear(string $field, string $year = 'this year', int $step = 1, string $logic = 'AND') @@ -140,12 +145,13 @@ trait TimeFieldQuery } /** - * 查询日数据 whereDay('time_field', '2018-1-1') - * @access public + * 查询日数据 whereDay('time_field', '2018-1-1'). + * * @param string $field 日期字段名 * @param string $day 日期信息 - * @param int $step 间隔 + * @param int $step 间隔 * @param string $logic AND OR + * * @return $this */ public function whereDay(string $field, string $day = 'today', int $step = 1, string $logic = 'AND') @@ -158,12 +164,13 @@ trait TimeFieldQuery } /** - * 查询日期或者时间范围 whereBetweenTime('time_field', '2018-1-1','2018-1-15') - * @access public + * 查询日期或者时间范围 whereBetweenTime('time_field', '2018-1-1','2018-1-15'). + * * @param string $field 日期字段名 * @param string|int $startTime 开始时间 * @param string|int $endTime 结束时间 * @param string $logic AND OR + * * @return $this */ public function whereBetweenTime(string $field, $startTime, $endTime, string $logic = 'AND') @@ -172,11 +179,12 @@ trait TimeFieldQuery } /** - * 查询日期或者时间范围 whereNotBetweenTime('time_field', '2018-1-1','2018-1-15') - * @access public + * 查询日期或者时间范围 whereNotBetweenTime('time_field', '2018-1-1','2018-1-15'). + * * @param string $field 日期字段名 * @param string|int $startTime 开始时间 * @param string|int $endTime 结束时间 + * * @return $this */ public function whereNotBetweenTime(string $field, $startTime, $endTime) @@ -186,10 +194,11 @@ trait TimeFieldQuery } /** - * 查询当前时间在两个时间字段范围 whereBetweenTimeField('start_time', 'end_time') - * @access public + * 查询当前时间在两个时间字段范围 whereBetweenTimeField('start_time', 'end_time'). + * * @param string $startField 开始时间字段 * @param string $endField 结束时间字段 + * * @return $this */ public function whereBetweenTimeField(string $startField, string $endField) @@ -199,10 +208,11 @@ trait TimeFieldQuery } /** - * 查询当前时间不在两个时间字段范围 whereNotBetweenTimeField('start_time', 'end_time') - * @access public + * 查询当前时间不在两个时间字段范围 whereNotBetweenTimeField('start_time', 'end_time'). + * * @param string $startField 开始时间字段 * @param string $endField 结束时间字段 + * * @return $this */ public function whereNotBetweenTimeField(string $startField, string $endField) @@ -210,5 +220,4 @@ trait TimeFieldQuery return $this->whereTime($startField, '>', time()) ->whereTime($endField, '<', time(), 'OR'); } - } diff --git a/vendor/topthink/think-orm/src/db/concern/Transaction.php b/vendor/topthink/think-orm/src/db/concern/Transaction.php index b586132..3aa82de 100644 --- a/vendor/topthink/think-orm/src/db/concern/Transaction.php +++ b/vendor/topthink/think-orm/src/db/concern/Transaction.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -17,16 +18,17 @@ namespace think\db\concern; */ trait Transaction { - /** * 执行数据库Xa事务 - * @access public - * @param callable $callback 数据操作方法回调 - * @param array $dbs 多个查询对象或者连接对象 - * @return mixed - * @throws PDOException + * + * @param callable $callback 数据操作方法回调 + * @param array $dbs 多个查询对象或者连接对象 + * + * @throws \PDOException * @throws \Exception * @throws \Throwable + * + * @return mixed */ public function transactionXa(callable $callback, array $dbs = []) { @@ -35,8 +37,9 @@ trait Transaction /** * 执行数据库事务 - * @access public + * * @param callable $callback 数据操作方法回调 + * * @return mixed */ public function transaction(callable $callback) @@ -46,7 +49,7 @@ trait Transaction /** * 启动事务 - * @access public + * * @return void */ public function startTrans(): void @@ -55,10 +58,11 @@ trait Transaction } /** - * 用于非自动提交状态下面的查询提交 - * @access public + * 用于非自动提交状态下面的查询提交. + * + * @throws \PDOException + * * @return void - * @throws PDOException */ public function commit(): void { @@ -66,10 +70,11 @@ trait Transaction } /** - * 事务回滚 - * @access public + * 事务回滚. + * + * @throws \PDOException + * * @return void - * @throws PDOException */ public function rollback(): void { @@ -78,8 +83,9 @@ trait Transaction /** * 启动XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function startTransXa(string $xid): void @@ -89,8 +95,9 @@ trait Transaction /** * 预编译XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function prepareXa(string $xid): void @@ -100,8 +107,9 @@ trait Transaction /** * 提交XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function commitXa(string $xid): void @@ -111,8 +119,9 @@ trait Transaction /** * 回滚XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function rollbackXa(string $xid): void diff --git a/vendor/topthink/think-orm/src/db/concern/WhereQuery.php b/vendor/topthink/think-orm/src/db/concern/WhereQuery.php index f1b49db..a6412f3 100644 --- a/vendor/topthink/think-orm/src/db/concern/WhereQuery.php +++ b/vendor/topthink/think-orm/src/db/concern/WhereQuery.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\concern; @@ -19,43 +20,53 @@ use think\db\Raw; trait WhereQuery { /** - * 指定AND查询条件 - * @access public + * 指定AND查询条件. + * * @param mixed $field 查询字段 * @param mixed $op 查询表达式 * @param mixed $condition 查询条件 + * * @return $this */ public function where($field, $op = null, $condition = null) { if ($field instanceof $this) { $this->parseQueryWhere($field); + return $this; } elseif (true === $field || 1 === $field) { $this->options['where']['AND'][] = true; + return $this; } + $pk = $this->getPk(); + if ((is_null($condition) || '=' == $op) && is_string($pk) && $pk == $field ) { + $this->options['key'] = is_null($condition) ? $op : $condition; + } + $param = func_get_args(); array_shift($param); + return $this->parseWhereExp('AND', $field, $op, $condition, $param); } /** - * 解析Query对象查询条件 - * @access public + * 解析Query对象查询条件. + * * @param BaseQuery $query 查询对象 + * * @return void */ protected function parseQueryWhere(BaseQuery $query): void { $this->options['where'] = $query->getOptions('where') ?? []; + $via = $query->getOptions('via'); - if ($query->getOptions('via')) { - $via = $query->getOptions('via'); + if ($via) { foreach ($this->options['where'] as $logic => &$where) { foreach ($where as $key => &$val) { - if (is_array($val) && !strpos($val[0], '.')) { + if (is_array($val) && !str_contains($val[0], '.')) { $val[0] = $via . '.' . $val[0]; } } @@ -66,40 +77,45 @@ trait WhereQuery } /** - * 指定OR查询条件 - * @access public + * 指定OR查询条件. + * * @param mixed $field 查询字段 * @param mixed $op 查询表达式 * @param mixed $condition 查询条件 + * * @return $this */ public function whereOr($field, $op = null, $condition = null) { $param = func_get_args(); array_shift($param); + return $this->parseWhereExp('OR', $field, $op, $condition, $param); } /** - * 指定XOR查询条件 - * @access public + * 指定XOR查询条件. + * * @param mixed $field 查询字段 * @param mixed $op 查询表达式 * @param mixed $condition 查询条件 + * * @return $this */ public function whereXor($field, $op = null, $condition = null) { $param = func_get_args(); array_shift($param); + return $this->parseWhereExp('XOR', $field, $op, $condition, $param); } /** - * 指定Null查询条件 - * @access public + * 指定Null查询条件. + * * @param mixed $field 查询字段 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNull(string $field, string $logic = 'AND') @@ -108,10 +124,11 @@ trait WhereQuery } /** - * 指定NotNull查询条件 - * @access public + * 指定NotNull查询条件. + * * @param mixed $field 查询字段 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNotNull(string $field, string $logic = 'AND') @@ -120,10 +137,11 @@ trait WhereQuery } /** - * 指定Exists查询条件 - * @access public + * 指定Exists查询条件. + * * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereExists($condition, string $logic = 'AND') @@ -133,14 +151,16 @@ trait WhereQuery } $this->options['where'][strtoupper($logic)][] = ['', 'EXISTS', $condition]; + return $this; } /** - * 指定NotExists查询条件 - * @access public + * 指定NotExists查询条件. + * * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNotExists($condition, string $logic = 'AND') @@ -150,15 +170,17 @@ trait WhereQuery } $this->options['where'][strtoupper($logic)][] = ['', 'NOT EXISTS', $condition]; + return $this; } /** - * 指定In查询条件 - * @access public + * 指定In查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereIn(string $field, $condition, string $logic = 'AND') @@ -167,11 +189,12 @@ trait WhereQuery } /** - * 指定NotIn查询条件 - * @access public + * 指定NotIn查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNotIn(string $field, $condition, string $logic = 'AND') @@ -180,11 +203,12 @@ trait WhereQuery } /** - * 指定Like查询条件 - * @access public + * 指定Like查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereLike(string $field, $condition, string $logic = 'AND') @@ -193,11 +217,12 @@ trait WhereQuery } /** - * 指定NotLike查询条件 - * @access public + * 指定NotLike查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNotLike(string $field, $condition, string $logic = 'AND') @@ -206,11 +231,12 @@ trait WhereQuery } /** - * 指定Between查询条件 - * @access public + * 指定Between查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereBetween(string $field, $condition, string $logic = 'AND') @@ -219,11 +245,12 @@ trait WhereQuery } /** - * 指定NotBetween查询条件 - * @access public + * 指定NotBetween查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereNotBetween(string $field, $condition, string $logic = 'AND') @@ -232,11 +259,12 @@ trait WhereQuery } /** - * 指定FIND_IN_SET查询条件 - * @access public + * 指定FIND_IN_SET查询条件. + * * @param mixed $field 查询字段 * @param mixed $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereFindInSet(string $field, $condition, string $logic = 'AND') @@ -245,18 +273,19 @@ trait WhereQuery } /** - * 比较两个字段 - * @access public + * 比较两个字段. + * * @param string $field1 查询字段 * @param string $operator 比较操作符 * @param string $field2 比较字段 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereColumn(string $field1, string $operator, string $field2 = null, string $logic = 'AND') { if (is_null($field2)) { - $field2 = $operator; + $field2 = $operator; $operator = '='; } @@ -264,10 +293,11 @@ trait WhereQuery } /** - * 设置软删除字段及条件 - * @access public + * 设置软删除字段及条件. + * * @param string $field 查询字段 * @param mixed $condition 查询条件 + * * @return $this */ public function useSoftDelete(string $field, $condition = null) @@ -280,12 +310,13 @@ trait WhereQuery } /** - * 指定Exp查询条件 - * @access public + * 指定Exp查询条件. + * * @param mixed $field 查询字段 * @param string $where 查询条件 * @param array $bind 参数绑定 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereExp(string $field, string $where, array $bind = [], string $logic = 'AND') @@ -296,31 +327,34 @@ trait WhereQuery } /** - * 指定字段Raw查询 - * @access public + * 指定字段Raw查询. + * * @param string $field 查询字段表达式 * @param mixed $op 查询表达式 * @param string $condition 查询条件 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereFieldRaw(string $field, $op, $condition = null, string $logic = 'AND') { if (is_null($condition)) { $condition = $op; - $op = '='; + $op = '='; } $this->options['where'][$logic][] = [new Raw($field), $op, $condition]; + return $this; } /** - * 指定表达式查询条件 - * @access public + * 指定表达式查询条件. + * * @param string $where 查询条件 * @param array $bind 参数绑定 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function whereRaw(string $where, array $bind = [], string $logic = 'AND') @@ -331,10 +365,11 @@ trait WhereQuery } /** - * 指定表达式查询条件 OR - * @access public + * 指定表达式查询条件 OR. + * * @param string $where 查询条件 * @param array $bind 参数绑定 + * * @return $this */ public function whereOrRaw(string $where, array $bind = []) @@ -343,21 +378,22 @@ trait WhereQuery } /** - * 分析查询表达式 - * @access protected + * 分析查询表达式. + * * @param string $logic 查询逻辑 and or xor * @param mixed $field 查询字段 * @param mixed $op 查询表达式 * @param mixed $condition 查询条件 * @param array $param 查询参数 * @param bool $strict 严格模式 + * * @return $this */ protected function parseWhereExp(string $logic, $field, $op, $condition, array $param = [], bool $strict = false) { $logic = strtoupper($logic); - if (is_string($field) && !empty($this->options['via']) && false === strpos($field, '.')) { + if (is_string($field) && !empty($this->options['via']) && !str_contains($field, '.')) { $field = $this->options['via'] . '.' . $field; } @@ -375,11 +411,11 @@ trait WhereQuery $where = $field; } elseif (is_string($field)) { if ($condition instanceof Raw) { - } elseif (preg_match('/[,=\<\'\"\(\s]/', $field)) { return $this->whereRaw($field, is_array($op) ? $op : [], $logic); } elseif (is_string($op) && strtolower($op) == 'exp' && !is_null($condition)) { $bind = isset($param[2]) && is_array($param[2]) ? $param[2] : []; + return $this->whereExp($field, $condition, $bind, $logic); } @@ -394,13 +430,14 @@ trait WhereQuery } /** - * 分析查询表达式 - * @access protected + * 分析查询表达式. + * * @param string $logic 查询逻辑 and or xor * @param mixed $field 查询字段 * @param mixed $op 查询表达式 * @param mixed $condition 查询条件 * @param array $param 查询参数 + * * @return array */ protected function parseWhereItem(string $logic, $field, $op, $condition, array $param = []): array @@ -431,10 +468,11 @@ trait WhereQuery } /** - * 相等查询的主键处理 - * @access protected + * 相等查询的主键处理. + * * @param string $field 字段名 * @param mixed $value 字段值 + * * @return array */ protected function whereEq(string $field, $value): array @@ -447,10 +485,11 @@ trait WhereQuery } /** - * 数组批量查询 - * @access protected + * 数组批量查询. + * * @param array $field 批量查询 * @param string $logic 查询逻辑 and or xor + * * @return $this */ protected function parseArrayWhereItems(array $field, string $logic) @@ -468,17 +507,18 @@ trait WhereQuery if (!empty($where)) { $this->options['where'][$logic] = isset($this->options['where'][$logic]) ? - array_merge($this->options['where'][$logic], $where) : $where; + array_merge($this->options['where'][$logic], $where) : $where; } return $this; } /** - * 去除某个查询条件 - * @access public + * 去除某个查询条件. + * * @param string $field 查询字段 * @param string $logic 查询逻辑 and or xor + * * @return $this */ public function removeWhereField(string $field, string $logic = 'AND') @@ -497,11 +537,12 @@ trait WhereQuery } /** - * 条件查询 - * @access public + * 条件查询. + * * @param mixed $condition 满足条件(支持闭包) * @param Closure|array $query 满足条件后执行的查询表达式(闭包或数组) * @param Closure|array $otherwise 不满足条件后执行 + * * @return $this */ public function when($condition, $query, $otherwise = null) diff --git a/vendor/topthink/think-orm/src/db/connector/Mongo.php b/vendor/topthink/think-orm/src/db/connector/Mongo.php index 418dc50..5668894 100644 --- a/vendor/topthink/think-orm/src/db/connector/Mongo.php +++ b/vendor/topthink/think-orm/src/db/connector/Mongo.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\connector; @@ -32,16 +33,16 @@ use think\db\exception\DbException as Exception; use think\db\Mongo as Query; /** - * Mongo数据库驱动 + * Mongo数据库驱动. + * * @property Manager[] $links * @property Manager $linkRead * @property Manager $linkWrite */ class Mongo extends Connection { - // 查询数据类型 - protected $dbName = ''; + protected $dbName = ''; protected $typeMap = 'array'; protected $mongo; // MongoDb Object protected $cursor; // MongoCursor Object @@ -104,8 +105,8 @@ class Mongo extends Connection ]; /** - * 获取当前连接器类对应的Query类 - * @access public + * 获取当前连接器类对应的Query类. + * * @return string */ public function getQueryClass(): string @@ -115,7 +116,7 @@ class Mongo extends Connection /** * 获取当前的builder实例对象 - * @access public + * * @return Builder */ public function getBuilder() @@ -124,8 +125,8 @@ class Mongo extends Connection } /** - * 获取当前连接器类对应的Builder类 - * @access public + * 获取当前连接器类对应的Builder类. + * * @return string */ public function getBuilderClass(): string @@ -134,13 +135,15 @@ class Mongo extends Connection } /** - * 连接数据库方法 - * @access public - * @param array $config 连接参数 - * @param integer $linkNum 连接序号 - * @return Manager + * 连接数据库方法. + * + * @param array $config 连接参数 + * @param int $linkNum 连接序号 + * * @throws InvalidArgumentException * @throws RuntimeException + * + * @return Manager */ public function connect(array $config = [], $linkNum = 0) { @@ -151,7 +154,7 @@ class Mongo extends Connection $config = array_merge($this->config, $config); } - $this->dbName = $config['database']; + $this->dbName = $config['database']; $this->typeMap = $config['type_map']; if ($config['pk_convert_id'] && '_id' == $config['pk']) { @@ -170,7 +173,6 @@ class Mongo extends Connection // 记录数据库连接信息 $this->trigger('CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']); } - } return $this->links[$linkNum]; @@ -178,7 +180,7 @@ class Mongo extends Connection /** * 获取Mongo Manager对象 - * @access public + * * @return Manager|null */ public function getMongo() @@ -187,9 +189,10 @@ class Mongo extends Connection } /** - * 设置/获取当前操作的database - * @access public + * 设置/获取当前操作的database. + * * @param string $db db + * * @return string */ public function db(string $db = null) @@ -203,8 +206,9 @@ class Mongo extends Connection /** * 执行查询但只返回Cursor对象 - * @access public + * * @param Query $query 查询对象 + * * @return Cursor */ public function cursor($query) @@ -214,8 +218,7 @@ class Mongo extends Connection // 生成MongoQuery对象 $mongoQuery = $this->builder->select($query); - - $master = $query->getOptions('master') ? true : false; + $master = (bool) $query->getOptions('master'); // 执行查询操作 return $this->getCursor($query, $mongoQuery, $master); @@ -223,25 +226,27 @@ class Mongo extends Connection /** * 执行查询并返回Cursor对象 - * @access public - * @param BaseQuery $query 查询对象 + * + * @param BaseQuery $query 查询对象 * @param MongoQuery|Closure $mongoQuery Mongo查询对象 - * @param bool $master 是否主库操作 - * @return Cursor + * @param bool $master 是否主库操作 + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return Cursor */ public function getCursor(BaseQuery $query, $mongoQuery, bool $master = false): Cursor { $this->initConnect($master); $this->db->updateQueryTimes(); - $options = $query->getOptions(); - $namespace = $options['table']; + $options = $query->getOptions(); + $namespace = $options['table']; - if (false === strpos($namespace, '.')) { + if (!str_contains($namespace, '.')) { $namespace = $this->dbName . '.' . $namespace; } @@ -254,11 +259,11 @@ class Mongo extends Connection $mongoQuery = $mongoQuery($query); } - $readPreference = $options['readPreference'] ?? null; + $readPreference = $options['readPreference'] ?? null; $this->queryStartTime = microtime(true); if ($session = $this->getSession()) { - $this->cursor = $this->mongo->executeQuery($namespace, $query, [ + $this->cursor = $this->mongo->executeQuery($namespace, $mongoQuery, [ 'readPreference' => is_null($readPreference) ? new ReadPreference(ReadPreference::RP_PRIMARY) : $readPreference, 'session' => $session, ]); @@ -275,14 +280,16 @@ class Mongo extends Connection } /** - * 执行查询 返回数据集 - * @access public - * @param MongoQuery $query 查询对象 - * @return mixed + * 执行查询 返回数据集. + * + * @param MongoQuery $query 查询对象 + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return mixed */ public function query(MongoQuery $query) { @@ -290,15 +297,17 @@ class Mongo extends Connection } /** - * 执行语句 - * @access public - * @param BulkWrite $bulk - * @return int + * 执行语句. + * + * @param BulkWrite $bulk + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return int */ public function execute(BulkWrite $bulk) { @@ -306,15 +315,17 @@ class Mongo extends Connection } /** - * 执行查询 - * @access protected - * @param BaseQuery $query 查询对象 + * 执行查询. + * + * @param BaseQuery $query 查询对象 * @param MongoQuery|Closure $mongoQuery Mongo查询对象 - * @return array + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return array */ protected function mongoQuery(BaseQuery $query, $mongoQuery): array { @@ -322,8 +333,8 @@ class Mongo extends Connection if ($query->getOptions('cache')) { // 检查查询缓存 - $cacheItem = $this->parseCache($query, $query->getOptions('cache')); - $key = $cacheItem->getKey(); + $cacheItem = $this->parseCache($query, $query->getOptions('cache')); + $key = $cacheItem->getKey(); if ($this->cache->has($key)) { return $this->cache->get($key); @@ -334,7 +345,7 @@ class Mongo extends Connection $mongoQuery = $mongoQuery($query); } - $master = $query->getOptions('master') ? true : false; + $master = (bool) $query->getOptions('master'); $this->getCursor($query, $mongoQuery, $master); $resultSet = $this->getResult($options['typeMap']); @@ -349,27 +360,27 @@ class Mongo extends Connection } /** - * 执行写操作 - * @access protected + * 执行写操作. + * * @param BaseQuery $query * @param BulkWrite $bulk * - * @return WriteResult * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return WriteResult */ protected function mongoExecute(BaseQuery $query, BulkWrite $bulk) { $this->initConnect(true); $this->db->updateQueryTimes(); - $options = $query->getOptions(); - - $namespace = $options['table']; - if (false === strpos($namespace, '.')) { + $options = $query->getOptions(); + $namespace = $options['table']; + if (!str_contains($namespace, '.')) { $namespace = $this->dbName . '.' . $namespace; } @@ -378,7 +389,7 @@ class Mongo extends Connection $this->queryStr = 'db' . strstr($namespace, '.') . '.' . $this->queryStr; } - $writeConcern = $options['writeConcern'] ?? null; + $writeConcern = $options['writeConcern'] ?? null; $this->queryStartTime = microtime(true); if ($session = $this->getSession()) { @@ -399,9 +410,9 @@ class Mongo extends Connection if ($query->getOptions('cache')) { // 清理缓存数据 - $cacheItem = $this->parseCache($query, $query->getOptions('cache')); - $key = $cacheItem->getKey(); - $tag = $cacheItem->getTag(); + $cacheItem = $this->parseCache($query, $query->getOptions('cache')); + $key = $cacheItem->getKey(); + $tag = $cacheItem->getTag(); if (isset($key) && $this->cache->has($key)) { $this->cache->delete($key); @@ -414,18 +425,20 @@ class Mongo extends Connection } /** - * 执行指令 - * @access public - * @param Command $command 指令 - * @param string $dbName 当前数据库名 - * @param ReadPreference $readPreference readPreference - * @param string|array $typeMap 指定返回的typeMap - * @param bool $master 是否主库操作 - * @return array + * 执行指令. + * + * @param Command $command 指令 + * @param string $dbName 当前数据库名 + * @param ReadPreference $readPreference readPreference + * @param string|array $typeMap 指定返回的typeMap + * @param bool $master 是否主库操作 + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return array */ public function command(Command $command, string $dbName = '', ReadPreference $readPreference = null, $typeMap = null, bool $master = false): array { @@ -458,9 +471,10 @@ class Mongo extends Connection } /** - * 获得数据集 - * @access protected - * @param string|array $typeMap 指定返回的typeMap + * 获得数据集. + * + * @param string|array $typeMap 指定返回的typeMap + * * @return mixed */ protected function getResult($typeMap = null): array @@ -490,9 +504,10 @@ class Mongo extends Connection } /** - * ObjectID处理 - * @access protected - * @param array $data 数据 + * ObjectID处理. + * + * @param array $data 数据 + * * @return void */ protected function convertObjectID(array &$data): void @@ -504,11 +519,12 @@ class Mongo extends Connection } /** - * 数据库日志记录(仅供参考) - * @access public - * @param string $type 类型 - * @param mixed $data 数据 - * @param array $options 参数 + * 数据库日志记录(仅供参考). + * + * @param string $type 类型 + * @param mixed $data 数据 + * @param array $options 参数 + * * @return void */ public function mongoLog(string $type, $data, array $options = []) @@ -557,13 +573,11 @@ class Mongo extends Connection $this->queryStr = $data . '(' . json_encode($options) . ');'; break; } - - $this->options = $options; } /** - * 获取最近执行的指令 - * @access public + * 获取最近执行的指令. + * * @return string */ public function getLastSql(): string @@ -572,22 +586,22 @@ class Mongo extends Connection } /** - * 关闭数据库 - * @access public + * 关闭数据库. */ public function close() { - $this->mongo = null; - $this->cursor = null; - $this->linkRead = null; - $this->linkWrite = null; - $this->links = []; + $this->mongo = null; + $this->cursor = null; + $this->linkRead = null; + $this->linkWrite = null; + $this->links = []; } /** - * 初始化数据库连接 - * @access protected - * @param boolean $master 是否主服务器 + * 初始化数据库连接. + * + * @param bool $master 是否主服务器 + * * @return void */ protected function initConnect(bool $master = true): void @@ -614,9 +628,10 @@ class Mongo extends Connection } /** - * 连接分布式服务器 - * @access protected - * @param boolean $master 主服务器 + * 连接分布式服务器. + * + * @param bool $master 主服务器 + * * @return Manager */ protected function multiConnect(bool $master = false): Manager @@ -632,8 +647,7 @@ class Mongo extends Connection if ($this->config['rw_separate']) { // 主从式采用读写分离 - if ($master) // 主服务器写入 - { + if ($master) { // 主服务器写入 if ($this->config['is_replica_set']) { return $this->replicaSetConnect(); } else { @@ -661,15 +675,15 @@ class Mongo extends Connection } /** - * 创建基于复制集的连接 + * 创建基于复制集的连接. + * * @return Manager */ public function replicaSetConnect(): Manager { - $this->dbName = $this->config['database']; - $this->typeMap = $this->config['type_map']; - - $startTime = microtime(true); + $this->dbName = $this->config['database']; + $this->typeMap = $this->config['type_map']; + $startTime = microtime(true); $this->config['params']['replicaSet'] = $this->config['database']; @@ -684,7 +698,8 @@ class Mongo extends Connection } /** - * 根据配置信息 生成适用于连接复制集的 URL + * 根据配置信息 生成适用于连接复制集的 URL. + * * @return string */ private function buildUrl(): string @@ -698,20 +713,22 @@ class Mongo extends Connection $url = $url . $hostList[$i] . ':' . $portList[0] . ','; } - return rtrim($url, ",") . '/'; + return rtrim($url, ',') . '/'; } /** - * 插入记录 - * @access public - * @param BaseQuery $query 查询对象 - * @param boolean $getLastInsID 返回自增主键 - * @return mixed + * 插入记录. + * + * @param BaseQuery $query 查询对象 + * @param bool $getLastInsID 返回自增主键 + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return mixed */ public function insert(BaseQuery $query, bool $getLastInsID = false) { @@ -723,18 +740,17 @@ class Mongo extends Connection } // 生成bulk对象 - $bulk = $this->builder->insert($query); - - $writeResult = $this->mongoExecute($query, $bulk); - $result = $writeResult->getInsertedCount(); + $bulk = $this->builder->insert($query); + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getInsertedCount(); if ($result) { - $data = $options['data']; - $lastInsId = $this->getLastInsID($query); + $data = $options['data']; + $lastInsId = $this->getLastInsID($query); if ($lastInsId) { - $pk = $query->getPk(); - $data[$pk] = $lastInsId; + $pk = $query->getPk(); + $data[$pk] = $lastInsId; } $query->setOption('data', $data); @@ -750,12 +766,14 @@ class Mongo extends Connection } /** - * 获取最近插入的ID - * @access public + * 获取最近插入的ID. + * * @param BaseQuery $query 查询对象 + * @param string $sequence 自增序列名 + * * @return mixed */ - public function getLastInsID(BaseQuery $query) + public function getLastInsID(BaseQuery $query, string $sequence = null) { $id = $this->builder->getLastInsID(); @@ -773,16 +791,18 @@ class Mongo extends Connection } /** - * 批量插入记录 - * @access public - * @param BaseQuery $query 查询对象 - * @param array $dataSet 数据集 - * @return integer + * 批量插入记录. + * + * @param BaseQuery $query 查询对象 + * @param array $dataSet 数据集 + * * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return int */ public function insertAll(BaseQuery $query, array $dataSet = []): int { @@ -794,35 +814,34 @@ class Mongo extends Connection } // 生成bulkWrite对象 - $bulk = $this->builder->insertAll($query, $dataSet); - - $writeResult = $this->mongoExecute($query, $bulk); + $bulk = $this->builder->insertAll($query, $dataSet); + $writeResult = $this->mongoExecute($query, $bulk); return $writeResult->getInsertedCount(); } /** - * 更新记录 - * @access public - * @param BaseQuery $query 查询对象 - * @return int + * 更新记录. + * + * @param BaseQuery $query 查询对象 + * * @throws Exception * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return int */ public function update(BaseQuery $query): int { $query->parseOptions(); // 生成bulkWrite对象 - $bulk = $this->builder->update($query); - - $writeResult = $this->mongoExecute($query, $bulk); - - $result = $writeResult->getModifiedCount(); + $bulk = $this->builder->update($query); + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getModifiedCount(); if ($result) { $this->db->trigger('after_update', $query); @@ -832,16 +851,18 @@ class Mongo extends Connection } /** - * 删除记录 - * @access public - * @param BaseQuery $query 查询对象 - * @return int + * 删除记录. + * + * @param BaseQuery $query 查询对象 + * * @throws Exception * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException * @throws BulkWriteException + * + * @return int */ public function delete(BaseQuery $query): int { @@ -849,12 +870,10 @@ class Mongo extends Connection $query->parseOptions(); // 生成bulkWrite对象 - $bulk = $this->builder->delete($query); - + $bulk = $this->builder->delete($query); // 执行操作 - $writeResult = $this->mongoExecute($query, $bulk); - - $result = $writeResult->getDeletedCount(); + $writeResult = $this->mongoExecute($query, $bulk); + $result = $writeResult->getDeletedCount(); if ($result) { $this->db->trigger('after_delete', $query); @@ -864,16 +883,18 @@ class Mongo extends Connection } /** - * 查找记录 - * @access public - * @param BaseQuery $query 查询对象 - * @return array + * 查找记录. + * + * @param BaseQuery $query 查询对象 + * * @throws ModelNotFoundException * @throws DataNotFoundException * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return array */ public function select(BaseQuery $query): array { @@ -889,16 +910,18 @@ class Mongo extends Connection } /** - * 查找单条记录 - * @access public - * @param BaseQuery $query 查询对象 - * @return array + * 查找单条记录. + * + * @param BaseQuery $query 查询对象 + * * @throws ModelNotFoundException * @throws DataNotFoundException * @throws AuthenticationException * @throws InvalidArgumentException * @throws ConnectionException * @throws RuntimeException + * + * @return array */ public function find(BaseQuery $query): array { @@ -919,9 +942,10 @@ class Mongo extends Connection /** * 得到某个字段的值 - * @access public - * @param string $field 字段名 - * @param mixed $default 默认值 + * + * @param string $field 字段名 + * @param mixed $default 默认值 + * * @return mixed */ public function value(BaseQuery $query, string $field, $default = null) @@ -936,7 +960,7 @@ class Mongo extends Connection if (!empty($options['cache'])) { $cacheItem = $this->parseCache($query, $options['cache']); - $key = $cacheItem->getKey(); + $key = $cacheItem->getKey(); if ($this->cache->has($key)) { return $this->cache->get($key); @@ -971,14 +995,15 @@ class Mongo extends Connection } /** - * 得到某个列的数组 - * @access public + * 得到某个列的数组. + * * @param BaseQuery $query * @param string|array $field 字段名 多个字段用逗号分隔 * @param string $key 索引 + * * @return array */ - public function column(BaseQuery $query, $field, string $key = ''): array + public function column(BaseQuery $query, string|array $field, string $key = ''): array { $options = $query->parseOptions(); @@ -999,8 +1024,8 @@ class Mongo extends Connection if (!empty($options['cache'])) { // 判断查询缓存 - $cacheItem = $this->parseCache($query, $options['cache']); - $key = $cacheItem->getKey(); + $cacheItem = $this->parseCache($query, $options['cache']); + $key = $cacheItem->getKey(); if ($this->cache->has($key)) { return $this->cache->get($key); @@ -1018,7 +1043,7 @@ class Mongo extends Connection // 执行查询操作 $resultSet = $this->mongoQuery($query, $mongoQuery); - if (('*' == $field || strpos($field, ',')) && $key) { + if (('*' == $field || str_contains($field, ',')) && $key) { $result = array_column($resultSet, null, $key); } elseif (!empty($resultSet)) { $result = array_column($resultSet, $field, $key); @@ -1036,18 +1061,18 @@ class Mongo extends Connection } /** - * 执行command - * @access public - * @param BaseQuery $query 查询对象 - * @param string|array|object $command 指令 - * @param mixed $extra 额外参数 - * @param string $db 数据库名 + * 执行command. + * + * @param BaseQuery $query 查询对象 + * @param string|array|object $command 指令 + * @param mixed $extra 额外参数 + * @param string $db 数据库名 + * * @return array */ public function cmd(BaseQuery $query, $command, $extra = null, string $db = ''): array { if (is_array($command) || is_object($command)) { - $this->mongoLog('cmd', 'cmd', $command); // 直接创建Command对象 @@ -1061,9 +1086,10 @@ class Mongo extends Connection } /** - * 获取数据库字段 - * @access public + * 获取数据库字段. + * * @param mixed $tableName 数据表名 + * * @return array */ public function getTableFields($tableName): array @@ -1073,53 +1099,57 @@ class Mongo extends Connection /** * 执行数据库事务 - * @access public - * @param callable $callback 数据操作方法回调 - * @return mixed + * + * @param callable $callback 数据操作方法回调 + * * @throws PDOException * @throws \Exception * @throws \Throwable + * + * @return mixed */ public function transaction(callable $callback) { $this->startTrans(); + try { $result = null; if (is_callable($callback)) { $result = call_user_func_array($callback, [$this]); } $this->commit(); + return $result; - } catch (\Exception $e) { - $this->rollback(); - throw $e; - } catch (\Throwable $e) { + } catch (\Throwable $e) { $this->rollback(); + throw $e; } } /** * 启动事务 - * @access public - * @return void + * * @throws \PDOException * @throws \Exception + * + * @return void */ public function startTrans() { $this->initConnect(true); - $this->session_uuid = uniqid(); + $this->session_uuid = uniqid(); $this->sessions[$this->session_uuid] = $this->getMongo()->startSession(); $this->sessions[$this->session_uuid]->startTransaction([]); } /** - * 用于非自动提交状态下面的查询提交 - * @access public - * @return void + * 用于非自动提交状态下面的查询提交. + * * @throws PDOException + * + * @return void */ public function commit() { @@ -1130,10 +1160,11 @@ class Mongo extends Connection } /** - * 事务回滚 - * @access public - * @return void + * 事务回滚. + * * @throws PDOException + * + * @return void */ public function rollback() { @@ -1144,7 +1175,8 @@ class Mongo extends Connection } /** - * 结束当前会话,设置上一个会话为当前会话 + * 结束当前会话,设置上一个会话为当前会话. + * * @author klinson */ protected function setLastSession() @@ -1162,14 +1194,16 @@ class Mongo extends Connection } /** - * 获取当前会话 + * 获取当前会话. + * * @return \MongoDB\Driver\Session|null + * * @author klinson */ public function getSession() { return ($this->session_uuid && isset($this->sessions[$this->session_uuid])) - ? $this->sessions[$this->session_uuid] - : null; + ? $this->sessions[$this->session_uuid] + : null; } } diff --git a/vendor/topthink/think-orm/src/db/connector/Mysql.php b/vendor/topthink/think-orm/src/db/connector/Mysql.php index fd9e63a..f18da99 100644 --- a/vendor/topthink/think-orm/src/db/connector/Mysql.php +++ b/vendor/topthink/think-orm/src/db/connector/Mysql.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\connector; @@ -16,15 +17,15 @@ use PDO; use think\db\PDOConnection; /** - * mysql数据库驱动 + * mysql数据库驱动. */ class Mysql extends PDOConnection { - /** - * 解析pdo连接的dsn信息 - * @access protected - * @param array $config 连接信息 + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * * @return string */ protected function parseDsn(array $config): string @@ -46,17 +47,18 @@ class Mysql extends PDOConnection } /** - * 取得数据表的字段信息 - * @access public - * @param string $tableName + * 取得数据表的字段信息. + * + * @param string $tableName + * * @return array */ public function getFields(string $tableName): array { [$tableName] = explode(' ', $tableName); - if (false === strpos($tableName, '`')) { - if (strpos($tableName, '.')) { + if (!str_contains($tableName, '`')) { + if (str_contains($tableName, '.')) { $tableName = str_replace('.', '`.`', $tableName); } $tableName = '`' . $tableName . '`'; @@ -87,9 +89,10 @@ class Mysql extends PDOConnection } /** - * 取得数据库的表信息 - * @access public - * @param string $dbName + * 取得数据库的表信息. + * + * @param string $dbName + * * @return array */ public function getTables(string $dbName = ''): array @@ -113,8 +116,9 @@ class Mysql extends PDOConnection /** * 启动XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function startTransXa(string $xid): void @@ -125,8 +129,9 @@ class Mysql extends PDOConnection /** * 预编译XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function prepareXa(string $xid): void @@ -138,8 +143,9 @@ class Mysql extends PDOConnection /** * 提交XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function commitXa(string $xid): void @@ -150,8 +156,9 @@ class Mysql extends PDOConnection /** * 回滚XA事务 - * @access public - * @param string $xid XA事务id + * + * @param string $xid XA事务id + * * @return void */ public function rollbackXa(string $xid): void diff --git a/vendor/topthink/think-orm/src/db/connector/Oracle.php b/vendor/topthink/think-orm/src/db/connector/Oracle.php index c8e957a..3877b97 100644 --- a/vendor/topthink/think-orm/src/db/connector/Oracle.php +++ b/vendor/topthink/think-orm/src/db/connector/Oracle.php @@ -1,4 +1,5 @@ getPDOStatement($sql); $result = $pdo->fetchAll(PDO::FETCH_ASSOC); $info = []; @@ -76,9 +79,10 @@ class Oracle extends PDOConnection } /** - * 取得数据库的表信息(暂时实现取得用户表信息) - * @access public + * 取得数据库的表信息(暂时实现取得用户表信息). + * * @param string $dbName + * * @return array */ public function getTables(string $dbName = ''): array @@ -96,16 +100,17 @@ class Oracle extends PDOConnection } /** - * 获取最近插入的ID - * @access public - * @param BaseQuery $query 查询对象 + * 获取最近插入的ID. + * + * @param BaseQuery $query 查询对象 * @param string|null $sequence 自增序列名 + * * @return mixed */ public function getLastInsID(BaseQuery $query, string $sequence = null) { - if(!is_null($sequence)) { - $pdo = $this->linkID->query("select {$sequence}.currval as id from dual"); + if (!is_null($sequence)) { + $pdo = $this->linkID->query("select {$sequence}.currval as id from dual"); $result = $pdo->fetchColumn(); } diff --git a/vendor/topthink/think-orm/src/db/connector/Pgsql.php b/vendor/topthink/think-orm/src/db/connector/Pgsql.php index fec8f84..023a886 100644 --- a/vendor/topthink/think-orm/src/db/connector/Pgsql.php +++ b/vendor/topthink/think-orm/src/db/connector/Pgsql.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -15,13 +15,13 @@ use PDO; use think\db\PDOConnection; /** - * Pgsql数据库驱动 + * Pgsql数据库驱动. */ class Pgsql extends PDOConnection { - /** - * 默认PDO连接参数 + * 默认PDO连接参数. + * * @var array */ protected $params = [ @@ -32,9 +32,10 @@ class Pgsql extends PDOConnection ]; /** - * 解析pdo连接的dsn信息 - * @access protected - * @param array $config 连接信息 + * 解析pdo连接的dsn信息. + * + * @param array $config 连接信息 + * * @return string */ protected function parseDsn(array $config): string @@ -49,16 +50,17 @@ class Pgsql extends PDOConnection } /** - * 取得数据表的字段信息 - * @access public - * @param string $tableName + * 取得数据表的字段信息. + * + * @param string $tableName + * * @return array */ public function getFields(string $tableName): array { [$tableName] = explode(' ', $tableName); - $sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');'; + $sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $tableName . '\');'; $pdo = $this->getPDOStatement($sql); $result = $pdo->fetchAll(PDO::FETCH_ASSOC); $info = []; @@ -73,7 +75,7 @@ class Pgsql extends PDOConnection 'notnull' => (bool) ('' !== $val['null']), 'default' => $val['default'], 'primary' => !empty($val['key']), - 'autoinc' => (0 === strpos($val['extra'], 'nextval(')), + 'autoinc' => str_starts_with((string) $val['extra'], 'nextval('), ]; } } @@ -82,9 +84,10 @@ class Pgsql extends PDOConnection } /** - * 取得数据库的表信息 - * @access public - * @param string $dbName + * 取得数据库的表信息. + * + * @param string $dbName + * * @return array */ public function getTables(string $dbName = ''): array diff --git a/vendor/topthink/think-orm/src/db/connector/Sqlite.php b/vendor/topthink/think-orm/src/db/connector/Sqlite.php index 3e42a90..5a429a3 100644 --- a/vendor/topthink/think-orm/src/db/connector/Sqlite.php +++ b/vendor/topthink/think-orm/src/db/connector/Sqlite.php @@ -1,8 +1,9 @@ getPDOStatement($sql); $result = $pdo->fetchAll(PDO::FETCH_ASSOC); $info = []; @@ -67,15 +67,16 @@ class Sqlite extends PDOConnection } /** - * 取得数据库的表信息 - * @access public - * @param string $dbName + * 取得数据库的表信息. + * + * @param string $dbName + * * @return array */ public function getTables(string $dbName = ''): array { $sql = "SELECT name FROM sqlite_master WHERE type='table' " - . "UNION ALL SELECT name FROM sqlite_temp_master " + . 'UNION ALL SELECT name FROM sqlite_temp_master ' . "WHERE type='table' ORDER BY name"; $pdo = $this->getPDOStatement($sql); diff --git a/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php b/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php index 835605d..b925891 100644 --- a/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php +++ b/vendor/topthink/think-orm/src/db/connector/Sqlsrv.php @@ -1,4 +1,5 @@ getPDOStatement($sql); $result = $pdo->fetchAll(PDO::FETCH_ASSOC); $info = []; @@ -100,9 +104,10 @@ class Sqlsrv extends PDOConnection } /** - * 取得数据表的字段信息 - * @access public - * @param string $dbName + * 取得数据表的字段信息. + * + * @param string $dbName + * * @return array */ public function getTables(string $dbName = ''): array @@ -122,5 +127,4 @@ class Sqlsrv extends PDOConnection return $info; } - } diff --git a/vendor/topthink/think-orm/src/db/connector/pgsql12.sql b/vendor/topthink/think-orm/src/db/connector/pgsql12.sql new file mode 100644 index 0000000..332b4f0 --- /dev/null +++ b/vendor/topthink/think-orm/src/db/connector/pgsql12.sql @@ -0,0 +1,117 @@ +CREATE OR REPLACE FUNCTION pgsql_type(a_type varchar) RETURNS varchar AS +$BODY$ +DECLARE + v_type varchar; +BEGIN + IF a_type='int8' THEN + v_type:='bigint'; + ELSIF a_type='int4' THEN + v_type:='integer'; + ELSIF a_type='int2' THEN + v_type:='smallint'; + ELSIF a_type='bpchar' THEN + v_type:='char'; + ELSE + v_type:=a_type; + END IF; + RETURN v_type; +END; +$BODY$ +LANGUAGE PLPGSQL; + +CREATE TYPE "public"."tablestruct" AS ( + "fields_key_name" varchar(100), + "fields_name" VARCHAR(200), + "fields_type" VARCHAR(20), + "fields_length" BIGINT, + "fields_not_null" VARCHAR(10), + "fields_default" VARCHAR(500), + "fields_comment" VARCHAR(1000) +); + +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_schema_name varchar, a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; + v_oid oid; + v_sql varchar; + v_rec RECORD; + v_key varchar; +BEGIN + SELECT + pg_class.oid INTO v_oid + FROM + pg_class + INNER JOIN pg_namespace ON (pg_class.relnamespace = pg_namespace.oid AND lower(pg_namespace.nspname) = a_schema_name) + WHERE + pg_class.relname=a_table_name; + IF NOT FOUND THEN + RETURN; + END IF; + + v_sql=' + SELECT + pg_attribute.attname AS fields_name, + pg_attribute.attnum AS fields_index, + pgsql_type(pg_type.typname::varchar) AS fields_type, + pg_attribute.atttypmod-4 as fields_length, + CASE WHEN pg_attribute.attnotnull THEN ''not null'' + ELSE '''' + END AS fields_not_null, + pg_get_expr(pg_attrdef.adbin, pg_attrdef.adrelid) AS fields_default, + pg_description.description AS fields_comment + FROM + pg_attribute + INNER JOIN pg_class ON pg_attribute.attrelid = pg_class.oid + INNER JOIN pg_type ON pg_attribute.atttypid = pg_type.oid + LEFT OUTER JOIN pg_attrdef ON pg_attrdef.adrelid = pg_class.oid AND pg_attrdef.adnum = pg_attribute.attnum + LEFT OUTER JOIN pg_description ON pg_description.objoid = pg_class.oid AND pg_description.objsubid = pg_attribute.attnum + WHERE + pg_attribute.attnum > 0 + AND attisdropped <> ''t'' + AND pg_class.oid = ' || v_oid || ' + ORDER BY pg_attribute.attnum' ; + + FOR v_rec IN EXECUTE v_sql LOOP + v_ret.fields_name=v_rec.fields_name; + v_ret.fields_type=v_rec.fields_type; + IF v_rec.fields_length > 0 THEN + v_ret.fields_length:=v_rec.fields_length; + ELSE + v_ret.fields_length:=NULL; + END IF; + v_ret.fields_not_null=v_rec.fields_not_null; + v_ret.fields_default=v_rec.fields_default; + v_ret.fields_comment=v_rec.fields_comment; + SELECT constraint_name INTO v_key FROM information_schema.key_column_usage WHERE table_schema=a_schema_name AND table_name=a_table_name AND column_name=v_rec.fields_name; + IF FOUND THEN + v_ret.fields_key_name=v_key; + ELSE + v_ret.fields_key_name=''; + END IF; + RETURN NEXT v_ret; + END LOOP; + RETURN ; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_schema_name varchar, a_table_name varchar) +IS '获得表信息'; + +---重载一个函数 +CREATE OR REPLACE FUNCTION "public"."table_msg" (a_table_name varchar) RETURNS SETOF "public"."tablestruct" AS +$body$ +DECLARE + v_ret tablestruct; +BEGIN + FOR v_ret IN SELECT * FROM table_msg('public',a_table_name) LOOP + RETURN NEXT v_ret; + END LOOP; + RETURN; +END; +$body$ +LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER; + +COMMENT ON FUNCTION "public"."table_msg"(a_table_name varchar) +IS '获得表信息'; \ No newline at end of file diff --git a/vendor/topthink/think-orm/src/db/exception/BindParamException.php b/vendor/topthink/think-orm/src/db/exception/BindParamException.php index 08bb388..b5faa67 100644 --- a/vendor/topthink/think-orm/src/db/exception/BindParamException.php +++ b/vendor/topthink/think-orm/src/db/exception/BindParamException.php @@ -1,31 +1,31 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\exception; /** - * PDO参数绑定异常 + * PDO参数绑定异常. */ class BindParamException extends DbException { - /** * BindParamException constructor. - * @access public - * @param string $message - * @param array $config - * @param string $sql - * @param array $bind - * @param int $code + * + * @param string $message + * @param array $config + * @param string $sql + * @param array $bind + * @param int $code */ public function __construct(string $message, array $config, string $sql, array $bind, int $code = 10502) { diff --git a/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php b/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php index d10dd43..f91cb98 100644 --- a/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php +++ b/vendor/topthink/think-orm/src/db/exception/DataNotFoundException.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\exception; @@ -18,22 +19,22 @@ class DataNotFoundException extends DbException /** * DbException constructor. - * @access public - * @param string $message - * @param string $table - * @param array $config + * + * @param string $message + * @param string $table + * @param array $config */ public function __construct(string $message, string $table = '', array $config = []) { $this->message = $message; - $this->table = $table; + $this->table = $table; $this->setData('Database Config', $config); } /** - * 获取数据表名 - * @access public + * 获取数据表名. + * * @return string */ public function getTable() diff --git a/vendor/topthink/think-orm/src/db/exception/DbEventException.php b/vendor/topthink/think-orm/src/db/exception/DbEventException.php index 394a1e8..414384b 100644 --- a/vendor/topthink/think-orm/src/db/exception/DbEventException.php +++ b/vendor/topthink/think-orm/src/db/exception/DbEventException.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\exception; use think\Exception; /** - * Database相关异常处理类 + * Database相关异常处理类. */ class DbException extends Exception { /** * DbException constructor. - * @access public - * @param string $message - * @param array $config - * @param string $sql - * @param int $code + * + * @param string $message + * @param array $config + * @param string $sql + * @param int $code */ public function __construct(string $message, array $config = [], string $sql = '', int $code = 10500) { $this->message = $message; - $this->code = $code; + $this->code = $code; $this->setData('Database Status', [ 'Error Code' => $code, diff --git a/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php b/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php index 047e45e..226eb07 100644 --- a/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php +++ b/vendor/topthink/think-orm/src/db/exception/InvalidArgumentException.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); + namespace think\db\exception; use Psr\SimpleCache\InvalidArgumentException as SimpleCacheInvalidArgumentInterface; /** - * 非法数据异常 + * 非法数据异常. */ class InvalidArgumentException extends \InvalidArgumentException implements SimpleCacheInvalidArgumentInterface { diff --git a/vendor/topthink/think-orm/src/db/exception/ModelEventException.php b/vendor/topthink/think-orm/src/db/exception/ModelEventException.php index 767bc1a..6692bcd 100644 --- a/vendor/topthink/think-orm/src/db/exception/ModelEventException.php +++ b/vendor/topthink/think-orm/src/db/exception/ModelEventException.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\exception; @@ -17,28 +18,27 @@ class ModelNotFoundException extends DbException protected $model; /** - * 构造方法 - * @access public - * @param string $message - * @param string $model - * @param array $config + * 构造方法. + * + * @param string $message + * @param string $model + * @param array $config */ public function __construct(string $message, string $model = '', array $config = []) { $this->message = $message; - $this->model = $model; + $this->model = $model; $this->setData('Database Config', $config); } /** - * 获取模型类名 - * @access public + * 获取模型类名. + * * @return string */ public function getModel() { return $this->model; } - } diff --git a/vendor/topthink/think-orm/src/db/exception/PDOException.php b/vendor/topthink/think-orm/src/db/exception/PDOException.php index efe78b9..247e6a7 100644 --- a/vendor/topthink/think-orm/src/db/exception/PDOException.php +++ b/vendor/topthink/think-orm/src/db/exception/PDOException.php @@ -1,41 +1,42 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\db\exception; /** * PDO异常处理类 - * 重新封装了系统的\PDOException类 + * 重新封装了系统的\PDOException类. */ class PDOException extends DbException { /** * PDOException constructor. - * @access public - * @param \PDOException $exception - * @param array $config - * @param string $sql - * @param int $code + * + * @param \PDOException $exception + * @param array $config + * @param string $sql + * @param int $code */ public function __construct(\PDOException $exception, array $config = [], string $sql = '', int $code = 10501) { - $error = $exception->errorInfo; + $error = $exception->errorInfo; $message = $exception->getMessage(); if (!empty($error)) { $this->setData('PDO Error Info', [ 'SQLSTATE' => $error[0], - 'Driver Error Code' => isset($error[1]) ? $error[1] : 0, - 'Driver Error Message' => isset($error[2]) ? $error[2] : '', + 'Driver Error Code' => $error[1] ?? 0, + 'Driver Error Message' => $error[2] ?? '', ]); } diff --git a/vendor/topthink/think-orm/src/facade/Db.php b/vendor/topthink/think-orm/src/facade/Db.php index b0296c6..e75bf53 100644 --- a/vendor/topthink/think-orm/src/facade/Db.php +++ b/vendor/topthink/think-orm/src/facade/Db.php @@ -1,8 +1,9 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model; @@ -17,7 +18,7 @@ use think\Model; use think\Paginator; /** - * 模型数据集类 + * 模型数据集类. * * @template TKey of array-key * @template TModel of \think\Model @@ -27,25 +28,26 @@ use think\Paginator; class Collection extends BaseCollection { /** - * 延迟预载入关联查询 - * @access public - * @param array|string $relation 关联 - * @param mixed $cache 关联缓存 + * 延迟预载入关联查询. + * + * @param array $relation 关联 + * @param mixed $cache 关联缓存 + * * @return $this */ - public function load($relation, $cache = false) + public function load(array $relation, $cache = false) { if (!$this->isEmpty()) { $item = current($this->items); - $item->eagerlyResultSet($this->items, (array) $relation, [], false, $cache); + $item->eagerlyResultSet($this->items, $relation, [], false, $cache); } return $this; } /** - * 删除数据集的数据 - * @access public + * 删除数据集的数据. + * * @return bool */ public function delete(): bool @@ -58,10 +60,11 @@ class Collection extends BaseCollection } /** - * 更新数据 - * @access public + * 更新数据. + * * @param array $data 数据数组 * @param array $allowField 允许字段 + * * @return bool */ public function update(array $data, array $allowField = []): bool @@ -78,10 +81,11 @@ class Collection extends BaseCollection } /** - * 设置需要隐藏的输出属性 - * @access public - * @param array $hidden 属性列表 - * @param bool $merge 是否合并 + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * @param bool $merge 是否合并 + * * @return $this */ public function hidden(array $hidden, bool $merge = false) @@ -94,10 +98,11 @@ class Collection extends BaseCollection } /** - * 设置需要输出的属性 - * @access public - * @param array $visible - * @param bool $merge 是否合并 + * 设置需要输出的属性. + * + * @param array $visible + * @param bool $merge 是否合并 + * * @return $this */ public function visible(array $visible, bool $merge = false) @@ -110,10 +115,11 @@ class Collection extends BaseCollection } /** - * 设置需要追加的输出属性 - * @access public - * @param array $append 属性列表 - * @param bool $merge 是否合并 + * 设置需要追加的输出属性. + * + * @param array $append 属性列表 + * @param bool $merge 是否合并 + * * @return $this */ public function append(array $append, bool $merge = false) @@ -126,9 +132,10 @@ class Collection extends BaseCollection } /** - * 设置模型输出场景 - * @access public - * @param string $scene 场景名称 + * 设置模型输出场景. + * + * @param string $scene 场景名称 + * * @return $this */ public function scene(string $scene) @@ -141,9 +148,10 @@ class Collection extends BaseCollection } /** - * 设置父模型 - * @access public - * @param Model $parent 父模型 + * 设置父模型. + * + * @param Model $parent 父模型 + * * @return $this */ public function setParent(Model $parent) @@ -156,13 +164,14 @@ class Collection extends BaseCollection } /** - * 设置数据字段获取器 - * @access public - * @param string|array $name 字段名 - * @param callable $callback 闭包获取器 + * 设置数据字段获取器. + * + * @param string|array $name 字段名 + * @param callable $callback 闭包获取器 + * * @return $this */ - public function withAttr($name, $callback = null) + public function withAttr(string|array $name, callable $callback = null) { $this->each(function (Model $model) use ($name, $callback) { $model->withAttr($name, $callback); @@ -172,12 +181,14 @@ class Collection extends BaseCollection } /** - * 绑定(一对一)关联属性到当前模型 - * @access protected - * @param string $relation 关联名称 - * @param array $attrs 绑定属性 - * @return $this + * 绑定(一对一)关联属性到当前模型. + * + * @param string $relation 关联名称 + * @param array $attrs 绑定属性 + * * @throws Exception + * + * @return $this */ public function bindAttr(string $relation, array $attrs = []) { @@ -189,11 +200,11 @@ class Collection extends BaseCollection } /** - * 按指定键整理数据 + * 按指定键整理数据. * - * @access public * @param mixed $items 数据 * @param string|null $indexKey 键名 + * * @return array */ public function dictionary($items = null, string &$indexKey = null) @@ -216,11 +227,11 @@ class Collection extends BaseCollection } /** - * 比较数据集,返回差集 + * 比较数据集,返回差集. * - * @access public * @param mixed $items 数据 * @param string|null $indexKey 指定比较的键名 + * * @return static */ public function diff($items, string $indexKey = null) @@ -229,7 +240,7 @@ class Collection extends BaseCollection return new static($items); } - $diff = []; + $diff = []; $dictionary = $this->dictionary($items, $indexKey); if (is_string($indexKey)) { @@ -244,11 +255,11 @@ class Collection extends BaseCollection } /** - * 比较数据集,返回交集 + * 比较数据集,返回交集. * - * @access public * @param mixed $items 数据 * @param string|null $indexKey 指定比较的键名 + * * @return static */ public function intersect($items, string $indexKey = null) @@ -257,7 +268,7 @@ class Collection extends BaseCollection return new static([]); } - $intersect = []; + $intersect = []; $dictionary = $this->dictionary($items, $indexKey); if (is_string($indexKey)) { diff --git a/vendor/topthink/think-orm/src/model/Pivot.php b/vendor/topthink/think-orm/src/model/Pivot.php index ac16d9e..07144e8 100644 --- a/vendor/topthink/think-orm/src/model/Pivot.php +++ b/vendor/topthink/think-orm/src/model/Pivot.php @@ -1,40 +1,42 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model; use think\Model; /** - * 多对多中间表模型类 + * 多对多中间表模型类. */ class Pivot extends Model { - /** - * 父模型 + * 父模型. + * * @var Model */ public $parent; /** - * 是否时间自动写入 + * 是否时间自动写入. + * * @var bool */ protected $autoWriteTimestamp = false; /** - * 架构函数 - * @access public + * 架构函数. + * * @param array $data 数据 * @param Model|null $parent 上级模型 * @param string $table 中间数据表名 @@ -51,19 +53,20 @@ class Pivot extends Model } /** - * 创建新的模型实例 - * @access public + * 创建新的模型实例. + * * @param array $data 数据 * @param mixed $where 更新条件 * @param array $options 参数 + * * @return Model */ public function newInstance(array $data = [], $where = null, array $options = []): Model { $model = parent::newInstance($data, $where, $options); - $model->parent = $this->parent; - $model->name = $this->name; + $model->parent = $this->parent; + $model->name = $this->name; return $model; } diff --git a/vendor/topthink/think-orm/src/model/Relation.php b/vendor/topthink/think-orm/src/model/Relation.php index 7bb6d9f..6699fd1 100644 --- a/vendor/topthink/think-orm/src/model/Relation.php +++ b/vendor/topthink/think-orm/src/model/Relation.php @@ -1,93 +1,103 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model; use Closure; -use ReflectionFunction; use think\db\BaseQuery as Query; use think\db\exception\DbException as Exception; use think\Model; /** - * 模型关联基础类 - * @package think\model + * 模型关联基础类. + * * @mixin Query */ abstract class Relation { /** * 父模型对象 + * * @var Model */ protected $parent; /** - * 当前关联的模型类名 + * 当前关联的模型类名. + * * @var string */ protected $model; /** * 关联模型查询对象 + * * @var Query */ protected $query; /** - * 关联表外键 + * 关联表外键. + * * @var string */ protected $foreignKey; /** - * 关联表主键 + * 关联表主键. + * * @var string */ protected $localKey; /** - * 是否执行关联基础查询 + * 是否执行关联基础查询. + * * @var bool */ protected $baseQuery; /** - * 是否为自关联 + * 是否为自关联. + * * @var bool */ protected $selfRelation = false; /** - * 关联数据字段限制 + * 关联数据字段限制. + * * @var array */ protected $withField; /** - * 排除关联数据字段 + * 排除关联数据字段. + * * @var array */ protected $withoutField; /** - * 默认数据 + * 默认数据. + * * @var mixed */ protected $default; /** - * 获取关联的所属模型 - * @access public + * 获取关联的所属模型. + * * @return Model */ public function getParent(): Model @@ -96,8 +106,8 @@ abstract class Relation } /** - * 获取当前的关联模型类的Query实例 - * @access public + * 获取当前的关联模型类的Query实例. + * * @return Query */ public function getQuery() @@ -106,28 +116,28 @@ abstract class Relation } /** - * 获取关联表外键 - * @access public + * 获取关联表外键. + * * @return string */ - public function getForeignKey() + public function getForeignKey(): string { return $this->foreignKey; } /** - * 获取关联表主键 - * @access public + * 获取关联表主键. + * * @return string */ - public function getLocalKey() + public function getLocalKey(): string { return $this->localKey; } /** - * 获取当前的关联模型类的实例 - * @access public + * 获取当前的关联模型类的实例. + * * @return Model */ public function getModel(): Model @@ -136,8 +146,8 @@ abstract class Relation } /** - * 当前关联是否为自关联 - * @access public + * 当前关联是否为自关联. + * * @return bool */ public function isSelfRelation(): bool @@ -146,20 +156,22 @@ abstract class Relation } /** - * 封装关联数据集 - * @access public - * @param array $resultSet 数据集 - * @param Model $parent 父模型 + * 封装关联数据集. + * + * @param array $resultSet 数据集 + * @param Model $parent 父模型 + * * @return mixed */ protected function resultSetBuild(array $resultSet, Model $parent = null) { - return (new $this->model)->toCollection($resultSet)->setParent($parent); + return (new $this->model())->toCollection($resultSet)->setParent($parent); } protected function getQueryFields(string $model) { $fields = $this->query->getOptions('field'); + return $this->getRelationQueryFields($fields, $model); } @@ -174,7 +186,7 @@ abstract class Relation } foreach ($fields as &$field) { - if (false === strpos($field, '.')) { + if (!str_contains($field, '.')) { $field = $model . '.' . $field; } } @@ -186,116 +198,43 @@ abstract class Relation { foreach ($where as $key => &$val) { if (is_string($key)) { - $where[] = [false === strpos($key, '.') ? $relation . '.' . $key : $key, '=', $val]; + $where[] = [!str_contains($key, '.') ? $relation . '.' . $key : $key, '=', $val]; unset($where[$key]); - } elseif (isset($val[0]) && false === strpos($val[0], '.')) { + } elseif (isset($val[0]) && !str_contains($val[0], '.')) { $val[0] = $relation . '.' . $val[0]; } } } - /** - * 限制关联数据的字段 - * @access public - * @param array|string $field 关联字段限制 - * @return $this - */ - public function withField($field) - { - if (is_string($field)) { - $field = array_map('trim', explode(',', $field)); - } - - $this->withField = $field; - return $this; - } - - /** - * 排除关联数据的字段 - * @access public - * @param array|string $field 关联字段限制 - * @return $this - */ - public function withoutField($field) - { - if (is_string($field)) { - $field = array_map('trim', explode(',', $field)); - } - - $this->withoutField = $field; - return $this; - } - - /** - * 限制关联数据的数量 - * @access public - * @param int $limit 关联数量限制 - * @return $this - */ - public function withLimit(int $limit) - { - $this->query->limit($limit); - return $this; - } - - /** - * 设置关联数据不存在的时候默认值 - * @access public - * @param mixed $data 默认值 - * @return $this - */ - public function withDefault($data = null) - { - $this->default = $data; - return $this; - } - /** * 获取关联数据默认值 - * @access protected + * + * @param mixed $data 模型数据 + * * @return mixed */ - protected function getDefaultModel() + protected function getDefaultModel($data) { - if (is_array($this->default)) { - $model = (new $this->model)->data($this->default); - } elseif ($this->default instanceof Closure) { - $closure = $this->default; - $model = new $this->model; - $closure($model); + if (is_array($data)) { + $model = (new $this->model())->data($data); + } elseif ($data instanceof Closure) { + $model = new $this->model(); + $data($model); } else { - $model = $this->default; + $model = $data; } return $model; } /** - * 判断闭包的参数类型 - * @access protected - * @return mixed - */ - protected function getClosureType(Closure $closure, $query = null) - { - $reflect = new ReflectionFunction($closure); - $params = $reflect->getParameters(); - - if (!empty($params)) { - $type = $params[0]->getType(); - $query = $query ?: $this->query; - return is_null($type) || Relation::class == $type->getName() ? $this : $query; - } - - return $this; - } - - /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void - {} + { + } public function __call($method, $args) { diff --git a/vendor/topthink/think-orm/src/model/concern/Attribute.php b/vendor/topthink/think-orm/src/model/concern/Attribute.php index 4359a4c..0b94232 100644 --- a/vendor/topthink/think-orm/src/model/concern/Attribute.php +++ b/vendor/topthink/think-orm/src/model/concern/Attribute.php @@ -1,114 +1,138 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; +use Closure; use InvalidArgumentException; +use Stringable; use think\db\Raw; use think\helper\Str; use think\model\Relation; /** - * 模型数据处理 + * 模型数据处理. */ trait Attribute { /** - * 数据表主键 复合主键使用数组定义 + * 数据表主键 复合主键使用数组定义. + * * @var string|array */ protected $pk = 'id'; /** - * 数据表字段信息 留空则自动获取 + * 数据表字段信息 留空则自动获取. + * * @var array */ protected $schema = []; /** - * 当前允许写入的字段 + * 当前允许写入的字段. + * * @var array */ protected $field = []; /** - * 字段自动类型转换 + * 字段自动类型转换. + * * @var array */ protected $type = []; /** - * 数据表废弃字段 + * 数据表废弃字段. + * * @var array */ protected $disuse = []; /** - * 数据表只读字段 + * 数据表只读字段. + * * @var array */ protected $readonly = []; /** - * 当前模型数据 + * 当前模型数据. + * * @var array */ private $data = []; /** - * 原始数据 + * 原始数据. + * * @var array */ private $origin = []; /** - * JSON数据表字段 + * JSON数据表字段. + * * @var array */ protected $json = []; /** - * JSON数据表字段类型 + * JSON数据表字段类型. + * * @var array */ protected $jsonType = []; /** - * JSON数据取出是否需要转换为数组 + * JSON数据取出是否需要转换为数组. + * * @var bool */ protected $jsonAssoc = false; /** - * 是否严格字段大小写 + * 是否严格字段大小写. + * * @var bool */ protected $strict = true; /** - * 获取器数据 + * 获取器数据. + * * @var array */ private $get = []; /** - * 动态获取器 + * 动态获取器. + * * @var array */ private $withAttr = []; /** - * 获取模型对象的主键 - * @access public + * 数据表延迟写入的字段 + * + * @var array + */ + protected $lazyFields = []; + + /** + * 获取模型对象的主键. + * * @return string|array */ public function getPk() @@ -117,9 +141,10 @@ trait Attribute } /** - * 判断一个字段名是否为主键字段 - * @access public - * @param string $key 名称 + * 判断一个字段名是否为主键字段. + * + * @param string $key 名称 + * * @return bool */ protected function isPk(string $key): bool @@ -137,7 +162,7 @@ trait Attribute /** * 获取模型对象的主键值 - * @access public + * * @return mixed */ public function getKey() @@ -147,14 +172,13 @@ trait Attribute if (is_string($pk) && array_key_exists($pk, $this->data)) { return $this->data[$pk]; } - - return; } /** - * 设置允许写入的字段 - * @access public - * @param array $field 允许写入的字段 + * 设置允许写入的字段. + * + * @param array $field 允许写入的字段 + * * @return $this */ public function allowField(array $field) @@ -165,9 +189,10 @@ trait Attribute } /** - * 设置只读字段 - * @access public - * @param array $field 只读字段 + * 设置只读字段. + * + * @param array $field 只读字段 + * * @return $this */ public function readOnly(array $field) @@ -178,9 +203,10 @@ trait Attribute } /** - * 获取实际的字段名 - * @access protected - * @param string $name 字段名 + * 获取实际的字段名. + * + * @param string $name 字段名 + * * @return string */ protected function getRealFieldName(string $name): string @@ -194,14 +220,21 @@ trait Attribute /** * 设置数据对象值 - * @access public - * @param array $data 数据 - * @param bool $set 是否调用修改器 - * @param array $allow 允许的字段名 + * + * @param array|object $data 数据 + * @param bool $set 是否调用修改器 + * @param array $allow 允许的字段名 + * * @return $this */ - public function data(array $data, bool $set = false, array $allow = []) + public function data(array|object $data, bool $set = false, array $allow = []) { + if ($data instanceof Model) { + $data = $data->getData(); + } elseif (is_object($data)) { + $data = get_object_vars($data); + } + // 清空数据 $this->data = []; @@ -222,21 +255,17 @@ trait Attribute $data = $result; } - if ($set) { - // 数据对象赋值 - $this->setAttrs($data); - } else { - $this->data = $data; - } + $this->appendData($data, $set); return $this; } /** * 批量追加数据对象值 - * @access public - * @param array $data 数据 - * @param bool $set 是否需要进行数据处理 + * + * @param array $data 数据 + * @param bool $set 是否需要进行数据处理 + * * @return $this */ public function appendData(array $data, bool $set = false) @@ -251,20 +280,22 @@ trait Attribute } /** - * 刷新对象原始数据(为当前数据) - * @access public + * 刷新对象原始数据(为当前数据). + * * @return $this */ public function refreshOrigin() { $this->origin = $this->data; + return $this; } /** - * 获取对象原始数据 如果不存在指定字段返回null - * @access public - * @param string $name 字段名 留空获取全部 + * 获取对象原始数据 如果不存在指定字段返回null. + * + * @param string $name 字段名 留空获取全部 + * * @return mixed */ public function getOrigin(string $name = null) @@ -279,11 +310,13 @@ trait Attribute } /** - * 获取当前对象数据 如果不存在指定字段返回false - * @access public - * @param string $name 字段名 留空获取全部 - * @return mixed + * 获取当前对象数据 如果不存在指定字段返回false. + * + * @param string $name 字段名 留空获取全部 + * * @throws InvalidArgumentException + * + * @return mixed */ public function getData(string $name = null) { @@ -295,7 +328,9 @@ trait Attribute if (array_key_exists($fieldName, $this->data)) { return $this->data[$fieldName]; - } elseif (array_key_exists($fieldName, $this->relation)) { + } + + if (array_key_exists($fieldName, $this->relation)) { return $this->relation[$fieldName]; } @@ -303,8 +338,8 @@ trait Attribute } /** - * 获取变化的数据 并排除只读数据 - * @access public + * 获取变化的数据 并排除只读数据. + * * @return array */ public function getChangedData(): array @@ -329,9 +364,10 @@ trait Attribute /** * 直接设置数据对象值 - * @access public - * @param string $name 属性名 - * @param mixed $value 值 + * + * @param string $name 属性名 + * @param mixed $value 值 + * * @return void */ public function set(string $name, $value): void @@ -344,8 +380,9 @@ trait Attribute /** * 通过修改器 批量设置数据对象值 - * @access public - * @param array $data 数据 + * + * @param array $data 数据 + * * @return void */ public function setAttrs(array $data): void @@ -358,10 +395,11 @@ trait Attribute /** * 通过修改器 设置数据对象值 - * @access public - * @param string $name 属性名 - * @param mixed $value 属性值 - * @param array $data 数据 + * + * @param string $name 属性名 + * @param mixed $value 属性值 + * @param array $data 数据 + * * @return void */ public function setAttr(string $name, $value, array $data = []): void @@ -373,7 +411,6 @@ trait Attribute if (method_exists($this, $method)) { $array = $this->data; - $value = $this->$method($value, array_merge($this->data, $data)); if (is_null($value) && $array !== $this->data) { @@ -383,8 +420,9 @@ trait Attribute // 类型转换 $value = $this->writeTransform($value, $this->type[$name]); } elseif ($this->isRelationAttr($name)) { + // 关联属性 $this->relation[$name] = $value; - } elseif ((array_key_exists($name, $this->origin) || empty($this->origin)) && is_object($value) && method_exists($value, '__toString')) { + } elseif ((array_key_exists($name, $this->origin) || empty($this->origin)) && $value instanceof Stringable) { // 对象类型 $value = $value->__toString(); } @@ -395,13 +433,14 @@ trait Attribute } /** - * 数据写入 类型转换 - * @access protected - * @param mixed $value 值 - * @param string|array $type 要转换的类型 + * 数据写入 类型转换. + * + * @param mixed $value 值 + * @param string|array $type 要转换的类型 + * * @return mixed */ - protected function writeTransform($value, $type) + protected function writeTransform($value, string|array $type) { if (is_null($value)) { return; @@ -413,73 +452,41 @@ trait Attribute if (is_array($type)) { [$type, $param] = $type; - } elseif (strpos($type, ':')) { + } elseif (str_contains($type, ':')) { [$type, $param] = explode(':', $type, 2); } - switch ($type) { - case 'integer': - $value = (int) $value; - break; - case 'float': - if (empty($param)) { - $value = (float) $value; - } else { - $value = (float) number_format($value, (int) $param, '.', ''); - } - break; - case 'boolean': - $value = (bool) $value; - break; - case 'timestamp': - if (!is_numeric($value)) { - $value = strtotime($value); - } - break; - case 'datetime': - $value = is_numeric($value) ? $value : strtotime($value); - $value = $this->formatDateTime('Y-m-d H:i:s.u', $value, true); - break; - case 'object': - if (is_object($value)) { - $value = json_encode($value, JSON_FORCE_OBJECT); - } - break; - case 'array': - $value = (array) $value; - // no break - case 'json': - $option = !empty($param) ? (int) $param : JSON_UNESCAPED_UNICODE; - $value = json_encode($value, $option); - break; - case 'serialize': - $value = serialize($value); - break; - default: - if (is_object($value) && false !== strpos($type, '\\') && method_exists($value, '__toString')) { - // 对象类型 - $value = $value->__toString(); - } - } - - return $value; + return match ($type) { + 'integer' => (int) $value, + 'float' => empty($param) ? (float) $value : (float) number_format($value, (int) $param, '.', ''), + 'boolean' => (bool) $value, + 'timestamp' => !is_numeric($value) ? strtotime($value) : $value, + 'datetime' => $this->formatDateTime('Y-m-d H:i:s.u', $value, true), + 'object' => is_object($value) ? json_encode($value, JSON_FORCE_OBJECT) : $value, + 'array' => json_encode((array) $value, !empty($param) ? (int) $param : JSON_UNESCAPED_UNICODE), + 'json' => json_encode($value, !empty($param) ? (int) $param : JSON_UNESCAPED_UNICODE), + 'serialize' => serialize($value), + default => $value instanceof Stringable && str_contains($type, '\\') ? $value->__toString() : $value, + }; } /** * 获取器 获取数据对象的值 - * @access public - * @param string $name 名称 - * @return mixed + * + * @param string $name 名称 + * * @throws InvalidArgumentException + * + * @return mixed */ public function getAttr(string $name) { try { - $relation = false; - $value = $this->getData($name); + $relation = false; + $value = $this->getData($name); } catch (InvalidArgumentException $e) { - $relation = $this->isRelationAttr($name); - $value = null; + $relation = $this->isRelationAttr($name); + $value = null; } return $this->getValue($name, $value, $relation); @@ -487,14 +494,16 @@ trait Attribute /** * 获取经过获取器处理后的数据对象的值 - * @access protected - * @param string $name 字段名称 - * @param mixed $value 字段值 - * @param bool|string $relation 是否为关联属性或者关联名 - * @return mixed + * + * @param string $name 字段名称 + * @param mixed $value 字段值 + * @param bool|string $relation 是否为关联属性或者关联名 + * * @throws InvalidArgumentException + * + * @return mixed */ - protected function getValue(string $name, $value, $relation = false) + protected function getValue(string $name, $value, bool|string $relation = false) { // 检测属性获取器 $fieldName = $this->getRealFieldName($name); @@ -541,12 +550,13 @@ trait Attribute /** * 获取JSON字段属性值 - * @access protected - * @param string $name 属性名 - * @param mixed $value JSON数据 + * + * @param string $name 属性名 + * @param mixed $value JSON数据 + * * @return mixed */ - protected function getJsonValue($name, $value) + protected function getJsonValue(string $name, $value) { if (is_null($value)) { return $value; @@ -565,8 +575,9 @@ trait Attribute /** * 获取关联属性值 - * @access protected - * @param string $relation 关联名 + * + * @param string $relation 关联名 + * * @return mixed */ protected function getRelationValue(string $relation) @@ -577,13 +588,14 @@ trait Attribute } /** - * 数据读取 类型转换 - * @access protected - * @param mixed $value 值 - * @param string|array $type 要转换的类型 + * 数据读取 类型转换. + * + * @param mixed $value 值 + * @param string|array $type 要转换的类型 + * * @return mixed */ - protected function readTransform($value, $type) + protected function readTransform($value, string|array $type) { if (is_null($value)) { return; @@ -591,70 +603,42 @@ trait Attribute if (is_array($type)) { [$type, $param] = $type; - } elseif (strpos($type, ':')) { + } elseif (str_contains($type, ':')) { [$type, $param] = explode(':', $type, 2); } - switch ($type) { - case 'integer': - $value = (int) $value; - break; - case 'float': - if (empty($param)) { - $value = (float) $value; - } else { - $value = (float) number_format($value, (int) $param, '.', ''); - } - break; - case 'boolean': - $value = (bool) $value; - break; - case 'timestamp': - if (!is_null($value)) { - $format = !empty($param) ? $param : $this->dateFormat; - $value = $this->formatDateTime($format, $value, true); - } - break; - case 'datetime': - if (!is_null($value)) { - $format = !empty($param) ? $param : $this->dateFormat; - $value = $this->formatDateTime($format, $value); - } - break; - case 'json': - $value = json_decode($value, true); - break; - case 'array': - $value = empty($value) ? [] : json_decode($value, true); - break; - case 'object': - $value = empty($value) ? new \stdClass() : json_decode($value); - break; - case 'serialize': - try { - $value = unserialize($value); - } catch (\Exception $e) { - $value = null; - } - break; - default: - if (false !== strpos($type, '\\')) { - // 对象类型 - $value = new $type($value); - } - } + $call = function ($value) { + try { + $value = unserialize($value); + } catch (\Exception $e) { + $value = null; + } + return $value; + }; - return $value; + return match ($type) { + 'integer' => (int) $value, + 'float' => empty($param) ? (float) $value : (float) number_format($value, (int) $param, '.', ''), + 'boolean' => (bool) $value, + 'timestamp' => !is_null($value) ? $this->formatDateTime(!empty($param) ? $param : $this->dateFormat, $value, true) : null, + 'datetime' => !is_null($value) ? $this->formatDateTime(!empty($param) ? $param : $this->dateFormat, $value) : null, + 'json' => json_decode($value, true), + 'array' => empty($value) ? [] : json_decode($value, true), + 'object' => empty($value) ? new \stdClass() : json_decode($value), + 'serialize' => $call($value), + default => str_contains($type, '\\') ? new $type($value) : $value, + }; } /** - * 设置数据字段获取器 - * @access public - * @param string|array $name 字段名 - * @param callable $callback 闭包获取器 + * 设置数据字段获取器. + * + * @param string|array $name 字段名 + * @param Closure $callback 闭包获取器 + * * @return $this */ - public function withAttr($name, callable $callback = null) + public function withAttr(string|array $name, Closure $callback = null) { if (is_array($name)) { foreach ($name as $key => $val) { @@ -663,7 +647,7 @@ trait Attribute } else { $name = $this->getRealFieldName($name); - if (strpos($name, '.')) { + if (str_contains($name, '.')) { [$name, $key] = explode('.', $name); $this->withAttr[$name][$key] = $callback; @@ -674,5 +658,4 @@ trait Attribute return $this; } - } diff --git a/vendor/topthink/think-orm/src/model/concern/Conversion.php b/vendor/topthink/think-orm/src/model/concern/Conversion.php index 136a90f..a47bbf2 100644 --- a/vendor/topthink/think-orm/src/model/concern/Conversion.php +++ b/vendor/topthink/think-orm/src/model/concern/Conversion.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; @@ -20,86 +21,78 @@ use think\model\Collection as ModelCollection; use think\model\relation\OneToOne; /** - * 模型数据转换处理 + * 模型数据转换处理. */ trait Conversion { /** - * 数据输出显示的属性 + * 数据输出显示的属性. + * * @var array */ protected $visible = []; /** - * 数据输出隐藏的属性 + * 数据输出隐藏的属性. + * * @var array */ protected $hidden = []; /** - * 数据输出需要追加的属性 + * 数据输出需要追加的属性. + * * @var array */ protected $append = []; /** - * 场景 + * 场景. + * * @var array */ protected $scene = []; /** - * 数据输出字段映射 + * 数据输出字段映射. + * * @var array */ protected $mapping = []; /** - * 数据集对象名 + * 数据集对象名. + * * @var string */ protected $resultSetType; /** - * 数据命名是否自动转为驼峰 + * 数据命名是否自动转为驼峰. + * * @var bool */ protected $convertNameToCamel; /** - * 转换数据为驼峰命名(用于输出) - * @access public - * @param bool $toCamel 是否自动驼峰命名 + * 转换数据为驼峰命名(用于输出). + * + * @param bool $toCamel 是否自动驼峰命名 + * * @return $this */ public function convertNameToCamel(bool $toCamel = true) { $this->convertNameToCamel = $toCamel; - return $this; - } - - /** - * 设置需要附加的输出属性 - * @access public - * @param array $append 属性列表 - * @param bool $merge 是否合并 - * @return $this - */ - public function append(array $append = [], bool $merge = false) - { - if ($merge) { - $this->append = array_merge($this->append, $append); - } else { - $this->append = $append; - } return $this; } /** - * 设置输出层场景 - * @access public - * @param string $scene 场景名称 + * 设置输出层场景. + * + * @param string $scene 场景名称 + * * @return $this */ public function scene(string $scene) @@ -117,22 +110,20 @@ trait Conversion } /** - * 设置附加关联对象的属性 - * @access public - * @param string $attr 关联属性 - * @param string|array $append 追加属性名 - * @return $this + * 设置附加关联对象的属性. + * + * @param string $attr 关联属性 + * @param string|array $append 追加属性名 + * * @throws Exception + * + * @return $this */ public function appendRelationAttr(string $attr, array $append) { $relation = Str::camel($attr); - if (isset($this->relation[$relation])) { - $model = $this->relation[$relation]; - } else { - $model = $this->getRelationData($this->$relation()); - } + $model = $this->relation[$relation] ?? $this->getRelationData($this->$relation()); if ($model instanceof Model) { foreach ($append as $key => $attr) { @@ -149,10 +140,30 @@ trait Conversion } /** - * 设置需要隐藏的输出属性 - * @access public - * @param array $hidden 属性列表 - * @param bool $merge 是否合并 + * 设置需要附加的输出属性. + * + * @param array $append 属性列表 + * @param bool $merge 是否合并 + * + * @return $this + */ + public function append(array $append = [], bool $merge = false) + { + if ($merge) { + $this->append = array_merge($this->append, $append); + } else { + $this->append = $append; + } + + return $this; + } + + /** + * 设置需要隐藏的输出属性. + * + * @param array $hidden 属性列表 + * @param bool $merge 是否合并 + * * @return $this */ public function hidden(array $hidden = [], bool $merge = false) @@ -167,10 +178,11 @@ trait Conversion } /** - * 设置需要输出的属性 - * @access public - * @param array $visible - * @param bool $merge 是否合并 + * 设置需要输出的属性. + * + * @param array $visible + * @param bool $merge 是否合并 + * * @return $this */ public function visible(array $visible = [], bool $merge = false) @@ -185,9 +197,10 @@ trait Conversion } /** - * 设置属性的映射输出 - * @access public - * @param array $map + * 设置属性的映射输出. + * + * @param array $map + * * @return $this */ public function mapping(array $map) @@ -198,8 +211,8 @@ trait Conversion } /** - * 转换当前模型对象为数组 - * @access public + * 转换当前模型对象为数组. + * * @return array */ public function toArray(): array @@ -209,24 +222,28 @@ trait Conversion foreach ($this->visible as $key => $val) { if (is_string($val)) { - if (strpos($val, '.')) { + if (str_contains($val, '.')) { [$relation, $name] = explode('.', $val); $visible[$relation][] = $name; } else { $visible[$val] = true; $hasVisible = true; } + } else { + $visible[$key] = $val; } } foreach ($this->hidden as $key => $val) { if (is_string($val)) { - if (strpos($val, '.')) { + if (str_contains($val, '.')) { [$relation, $name] = explode('.', $val); $hidden[$relation][] = $name; } else { $hidden[$val] = true; } + } else { + $hidden[$key] = $val; } } @@ -277,17 +294,17 @@ trait Conversion return $item; } - protected function appendAttrToArray(array &$item, $key, $name, array $visible, array $hidden) + protected function appendAttrToArray(array &$item, $key, array|string $name, array $visible, array $hidden): void { if (is_array($name)) { // 批量追加关联对象属性 $relation = $this->getRelationWith($key, $hidden, $visible); $item[$key] = $relation ? $relation->append($name)->toArray() : []; - } elseif (strpos($name, '.')) { + } elseif (str_contains($name, '.')) { // 追加单个关联对象属性 - [$key, $attr] = explode('.', $name); - $relation = $this->getRelationWith($key, $hidden, $visible); - $item[$key] = $relation ? $relation->append([$attr])->toArray() : []; + [$key, $attr] = explode('.', $name); + $relation = $this->getRelationWith($key, $hidden, $visible); + $item[$key] = $relation ? $relation->append([$attr])->toArray() : []; } else { $value = $this->getAttr($name); $item[$name] = $value; @@ -338,9 +355,10 @@ trait Conversion } /** - * 转换当前模型对象为JSON字符串 - * @access public - * @param integer $options json参数 + * 转换当前模型对象为JSON字符串. + * + * @param int $options json参数 + * * @return string */ public function toJson(int $options = JSON_UNESCAPED_UNICODE): string @@ -354,24 +372,24 @@ trait Conversion } // JsonSerializable - #[\ReturnTypeWillChange] - public function jsonSerialize() + public function jsonSerialize(): array { return $this->toArray(); } /** * 转换数据集为数据集对象 - * @access public - * @param array|Collection $collection 数据集 - * @param string $resultSetType 数据集类 + * + * @param array|Collection $collection 数据集 + * @param string $resultSetType 数据集类 + * * @return Collection */ public function toCollection(iterable $collection = [], string $resultSetType = null): Collection { $resultSetType = $resultSetType ?: $this->resultSetType; - if ($resultSetType && false !== strpos($resultSetType, '\\')) { + if ($resultSetType && str_contains($resultSetType, '\\')) { $collection = new $resultSetType($collection); } else { $collection = new ModelCollection($collection); @@ -379,5 +397,4 @@ trait Conversion return $collection; } - } diff --git a/vendor/topthink/think-orm/src/model/concern/ModelEvent.php b/vendor/topthink/think-orm/src/model/concern/ModelEvent.php index d2388ab..b362856 100644 --- a/vendor/topthink/think-orm/src/model/concern/ModelEvent.php +++ b/vendor/topthink/think-orm/src/model/concern/ModelEvent.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; @@ -16,27 +17,29 @@ use think\db\exception\ModelEventException; use think\helper\Str; /** - * 模型事件处理 + * 模型事件处理. */ trait ModelEvent { - /** * Event对象 + * * @var object */ protected static $event; /** - * 是否需要事件响应 + * 是否需要事件响应. + * * @var bool */ protected $withEvent = true; /** * 设置Event对象 - * @access public + * * @param object $event Event对象 + * * @return void */ public static function setEvent($event) @@ -45,21 +48,24 @@ trait ModelEvent } /** - * 当前操作的事件响应 - * @access protected - * @param bool $event 是否需要事件响应 + * 当前操作的事件响应. + * + * @param bool $event 是否需要事件响应 + * * @return $this */ public function withEvent(bool $event) { $this->withEvent = $event; + return $this; } /** - * 触发事件 - * @access protected - * @param string $event 事件名 + * 触发事件. + * + * @param string $event 事件名 + * * @return bool */ protected function trigger(string $event): bool @@ -80,7 +86,7 @@ trait ModelEvent $result = true; } - return false === $result ? false : true; + return !(false === $result); } catch (ModelEventException $e) { return false; } diff --git a/vendor/topthink/think-orm/src/model/concern/OptimLock.php b/vendor/topthink/think-orm/src/model/concern/OptimLock.php index 5e61318..dcf1ab3 100644 --- a/vendor/topthink/think-orm/src/model/concern/OptimLock.php +++ b/vendor/topthink/think-orm/src/model/concern/OptimLock.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; @@ -25,8 +26,8 @@ trait OptimLock } /** - * 数据检查 - * @access protected + * 数据检查. + * * @return void */ protected function checkData(): void @@ -36,7 +37,7 @@ trait OptimLock /** * 记录乐观锁 - * @access protected + * * @return void */ protected function recordLockVersion(): void @@ -50,7 +51,7 @@ trait OptimLock /** * 更新乐观锁 - * @access protected + * * @return void */ protected function updateLockVersion(): void @@ -65,8 +66,8 @@ trait OptimLock public function getWhere() { - $where = parent::getWhere(); - $optimLock = $this->getOptimLockField(); + $where = parent::getWhere(); + $optimLock = $this->getOptimLockField(); if ($optimLock && $lockVer = $this->getOrigin($optimLock)) { $where[] = [$optimLock, '=', $lockVer]; @@ -81,5 +82,4 @@ trait OptimLock throw new Exception('record has update'); } } - } diff --git a/vendor/topthink/think-orm/src/model/concern/RelationShip.php b/vendor/topthink/think-orm/src/model/concern/RelationShip.php index 37b8af8..738d044 100644 --- a/vendor/topthink/think-orm/src/model/concern/RelationShip.php +++ b/vendor/topthink/think-orm/src/model/concern/RelationShip.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; @@ -32,38 +33,43 @@ use think\model\relation\MorphToMany; use think\model\relation\OneToOne; /** - * 模型关联处理 + * 模型关联处理. */ trait RelationShip { /** * 父关联模型对象 + * * @var object */ private $parent; /** - * 模型关联数据 + * 模型关联数据. + * * @var array */ private $relation = []; /** - * 关联写入定义信息 + * 关联写入定义信息. + * * @var array */ private $together = []; /** - * 关联自动写入信息 + * 关联自动写入信息. + * * @var array */ protected $relationWrite = []; /** * 设置父关联对象 - * @access public - * @param Model $model 模型对象 + * + * @param Model $model 模型对象 + * * @return $this */ public function setParent(Model $model) @@ -75,7 +81,7 @@ trait RelationShip /** * 获取父关联对象 - * @access public + * * @return Model */ public function getParent(): Model @@ -84,10 +90,11 @@ trait RelationShip } /** - * 获取当前模型的关联模型数据 - * @access public - * @param string $name 关联方法名 - * @param bool $auto 不存在是否自动获取 + * 获取当前模型的关联模型数据. + * + * @param string $name 关联方法名 + * @param bool $auto 不存在是否自动获取 + * * @return mixed */ public function getRelation(string $name = null, bool $auto = false) @@ -100,16 +107,18 @@ trait RelationShip return $this->relation[$name]; } elseif ($auto) { $relation = Str::camel($name); + return $this->getRelationValue($relation); } } /** * 设置关联数据对象值 - * @access public - * @param string $name 属性名 - * @param mixed $value 属性值 - * @param array $data 数据 + * + * @param string $name 属性名 + * @param mixed $value 属性值 + * @param array $data 数据 + * * @return $this */ public function setRelation(string $name, $value, array $data = []) @@ -127,34 +136,34 @@ trait RelationShip } /** - * 查询当前模型的关联数据 - * @access public - * @param array $relations 关联名 - * @param array $withRelationAttr 关联获取器 + * 查询当前模型的关联数据. + * + * @param array $relations 关联名 + * @param array $withRelationAttr 关联获取器 + * * @return void */ public function relationQuery(array $relations, array $withRelationAttr = []): void { foreach ($relations as $key => $relation) { $subRelation = []; - $closure = null; + $closure = null; if ($relation instanceof Closure) { // 支持闭包查询过滤关联条件 - $closure = $relation; - $relation = $key; + $closure = $relation; + $relation = $key; } if (is_array($relation)) { - $subRelation = $relation; - $relation = $key; - } elseif (strpos($relation, '.')) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { [$relation, $subRelation] = explode('.', $relation, 2); } - $method = Str::camel($relation); - $relationName = Str::snake($relation); - + $method = Str::camel($relation); + $relationName = Str::snake($relation); $relationResult = $this->$method(); if (isset($withRelationAttr[$relationName])) { @@ -166,9 +175,10 @@ trait RelationShip } /** - * 关联数据写入 - * @access public - * @param array $relation 关联 + * 关联数据写入. + * + * @param array $relation 关联 + * * @return $this */ public function together(array $relation) @@ -181,14 +191,15 @@ trait RelationShip } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $relation 关联方法名 - * @param mixed $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $relation 关联方法名 + * @param mixed $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public static function has(string $relation, string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null): Query @@ -199,13 +210,14 @@ trait RelationShip } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $relation 关联方法名 - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $relation 关联方法名 + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public static function hasWhere(string $relation, $where = [], string $fields = '*', string $joinType = '', Query $query = null): Query @@ -216,62 +228,64 @@ trait RelationShip } /** - * 预载入关联查询 JOIN方式 - * @access public - * @param Query $query Query对象 - * @param string $relation 关联方法名 - * @param mixed $field 字段 - * @param string $joinType JOIN类型 - * @param Closure $closure 闭包 - * @param bool $first + * 预载入关联查询 JOIN方式. + * + * @param Query $query Query对象 + * @param string $relation 关联方法名 + * @param mixed $field 字段 + * @param string $joinType JOIN类型 + * @param Closure $closure 闭包 + * @param bool $first + * * @return bool */ public function eagerly(Query $query, string $relation, $field, string $joinType = '', Closure $closure = null, bool $first = false): bool { - $relation = Str::camel($relation); - $class = $this->$relation(); + $relation = Str::camel($relation); + $class = $this->$relation(); if ($class instanceof OneToOne) { $class->eagerly($query, $relation, $field, $joinType, $closure, $first); + return true; - } else { - return false; } + + return false; } /** - * 预载入关联查询 返回数据集 - * @access public - * @param array $resultSet 数据集 - * @param string $relation 关联名 - * @param array $withRelationAttr 关联获取器 - * @param bool $join 是否为JOIN方式 - * @param mixed $cache 关联缓存 + * 预载入关联查询 返回数据集. + * + * @param array $resultSet 数据集 + * @param string $relation 关联名 + * @param array $withRelationAttr 关联获取器 + * @param bool $join 是否为JOIN方式 + * @param mixed $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, array $relations, array $withRelationAttr = [], bool $join = false, $cache = false): void { foreach ($relations as $key => $relation) { - $subRelation = []; - $closure = null; + $subRelation = []; + $closure = null; if ($relation instanceof Closure) { - $closure = $relation; - $relation = $key; + $closure = $relation; + $relation = $key; } if (is_array($relation)) { - $subRelation = $relation; - $relation = $key; - } elseif (strpos($relation, '.')) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { [$relation, $subRelation] = explode('.', $relation, 2); $subRelation = [$subRelation]; } - $relationName = $relation; - $relation = Str::camel($relation); - + $relationName = $relation; + $relation = Str::camel($relation); $relationResult = $this->$relation(); if (isset($withRelationAttr[$relationName])) { @@ -290,36 +304,36 @@ trait RelationShip /** * 预载入关联查询 返回模型对象 - * @access public - * @param array $relations 关联 - * @param array $withRelationAttr 关联获取器 - * @param bool $join 是否为JOIN方式 - * @param mixed $cache 关联缓存 + * + * @param array $relations 关联 + * @param array $withRelationAttr 关联获取器 + * @param bool $join 是否为JOIN方式 + * @param mixed $cache 关联缓存 + * * @return void */ public function eagerlyResult(array $relations, array $withRelationAttr = [], bool $join = false, $cache = false): void { foreach ($relations as $key => $relation) { - $subRelation = []; - $closure = null; + $subRelation = []; + $closure = null; if ($relation instanceof Closure) { - $closure = $relation; - $relation = $key; + $closure = $relation; + $relation = $key; } if (is_array($relation)) { - $subRelation = $relation; - $relation = $key; - } elseif (strpos($relation, '.')) { + $subRelation = $relation; + $relation = $key; + } elseif (str_contains($relation, '.')) { [$relation, $subRelation] = explode('.', $relation, 2); $subRelation = [$subRelation]; } - $relationName = $relation; - $relation = Str::camel($relation); - + $relationName = $relation; + $relation = Str::camel($relation); $relationResult = $this->$relation(); if (isset($withRelationAttr[$relationName])) { @@ -337,20 +351,22 @@ trait RelationShip } /** - * 绑定(一对一)关联属性到当前模型 - * @access protected - * @param string $relation 关联名称 - * @param array $attrs 绑定属性 - * @return $this + * 绑定(一对一)关联属性到当前模型. + * + * @param string $relation 关联名称 + * @param array $attrs 绑定属性 + * * @throws Exception + * + * @return $this */ public function bindAttr(string $relation, array $attrs = []) { $relation = $this->getRelation($relation, true); foreach ($attrs as $key => $attr) { - $key = is_numeric($key) ? $attr : $key; - $value = $this->getOrigin($key); + $key = is_numeric($key) ? $attr : $key; + $value = $this->getOrigin($key); if (!is_null($value)) { throw new Exception('bind attr has exists:' . $key); @@ -364,12 +380,13 @@ trait RelationShip /** * 关联统计 - * @access public - * @param Query $query 查询对象 - * @param array $relations 关联名 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param bool $useSubQuery 子查询 + * + * @param Query $query 查询对象 + * @param array $relations 关联名 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param bool $useSubQuery 子查询 + * * @return void */ public function relationCount(Query $query, array $relations, string $aggregate = 'sum', string $field = '*', bool $useSubQuery = true): void @@ -378,11 +395,11 @@ trait RelationShip $closure = $name = null; if ($relation instanceof Closure) { - $closure = $relation; - $relation = $key; + $closure = $relation; + $relation = $key; } elseif (is_string($key)) { - $name = $relation; - $relation = $key; + $name = $relation; + $relation = $key; } $relation = Str::camel($relation); @@ -406,11 +423,12 @@ trait RelationShip } /** - * HAS ONE 关联定义 - * @access public - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 当前主键 + * HAS ONE 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前主键 + * * @return HasOne */ public function hasOne(string $model, string $foreignKey = '', string $localKey = ''): HasOne @@ -424,19 +442,20 @@ trait RelationShip } /** - * BELONGS TO 关联定义 - * @access public - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 关联主键 + * BELONGS TO 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * * @return BelongsTo */ public function belongsTo(string $model, string $foreignKey = '', string $localKey = ''): BelongsTo { // 记录当前关联信息 $model = $this->parseModel($model); - $foreignKey = $foreignKey ?: $this->getForeignKey((new $model)->getName()); - $localKey = $localKey ?: (new $model)->getPk(); + $foreignKey = $foreignKey ?: $this->getForeignKey((new $model())->getName()); + $localKey = $localKey ?: (new $model())->getPk(); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $relation = Str::snake($trace[1]['function']); @@ -444,11 +463,12 @@ trait RelationShip } /** - * HAS MANY 关联定义 - * @access public - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 当前主键 + * HAS MANY 关联定义. + * + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前主键 + * * @return HasMany */ public function hasMany(string $model, string $foreignKey = '', string $localKey = ''): HasMany @@ -462,14 +482,15 @@ trait RelationShip } /** - * HAS MANY 远程关联定义 - * @access public - * @param string $model 模型名 - * @param string $through 中间模型名 - * @param string $foreignKey 关联外键 - * @param string $throughKey 关联外键 - * @param string $localKey 当前主键 - * @param string $throughPk 中间表主键 + * HAS MANY 远程关联定义. + * + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 当前主键 + * @param string $throughPk 中间表主键 + * * @return HasManyThrough */ public function hasManyThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = ''): HasManyThrough @@ -479,21 +500,22 @@ trait RelationShip $through = $this->parseModel($through); $localKey = $localKey ?: $this->getPk(); $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); - $throughKey = $throughKey ?: $this->getForeignKey((new $through)->getName()); - $throughPk = $throughPk ?: (new $through)->getPk(); + $throughKey = $throughKey ?: $this->getForeignKey((new $through())->getName()); + $throughPk = $throughPk ?: (new $through())->getPk(); return new HasManyThrough($this, $model, $through, $foreignKey, $throughKey, $localKey, $throughPk); } /** - * HAS ONE 远程关联定义 - * @access public - * @param string $model 模型名 - * @param string $through 中间模型名 - * @param string $foreignKey 关联外键 - * @param string $throughKey 关联外键 - * @param string $localKey 当前主键 - * @param string $throughPk 中间表主键 + * HAS ONE 远程关联定义. + * + * @param string $model 模型名 + * @param string $through 中间模型名 + * @param string $foreignKey 关联外键 + * @param string $throughKey 关联外键 + * @param string $localKey 当前主键 + * @param string $throughPk 中间表主键 + * * @return HasOneThrough */ public function hasOneThrough(string $model, string $through, string $foreignKey = '', string $throughKey = '', string $localKey = '', string $throughPk = ''): HasOneThrough @@ -503,19 +525,20 @@ trait RelationShip $through = $this->parseModel($through); $localKey = $localKey ?: $this->getPk(); $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); - $throughKey = $throughKey ?: $this->getForeignKey((new $through)->getName()); - $throughPk = $throughPk ?: (new $through)->getPk(); + $throughKey = $throughKey ?: $this->getForeignKey((new $through())->getName()); + $throughPk = $throughPk ?: (new $through())->getPk(); return new HasOneThrough($this, $model, $through, $foreignKey, $throughKey, $localKey, $throughPk); } /** - * BELONGS TO MANY 关联定义 - * @access public - * @param string $model 模型名 - * @param string $middle 中间表/模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 当前模型关联键 + * BELONGS TO MANY 关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表/模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型关联键 + * * @return BelongsToMany */ public function belongsToMany(string $model, string $middle = '', string $foreignKey = '', string $localKey = ''): BelongsToMany @@ -531,14 +554,15 @@ trait RelationShip } /** - * MORPH One 关联定义 - * @access public - * @param string $model 模型名 - * @param string|array $morph 多态字段信息 - * @param string $type 多态类型 + * MORPH One 关联定义. + * + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * * @return MorphOne */ - public function morphOne(string $model, $morph = null, string $type = ''): MorphOne + public function morphOne(string $model, string|array $morph = null, string $type = ''): MorphOne { // 记录当前关联信息 $model = $this->parseModel($model); @@ -548,12 +572,7 @@ trait RelationShip $morph = Str::snake($trace[1]['function']); } - if (is_array($morph)) { - [$morphType, $foreignKey] = $morph; - } else { - $morphType = $morph . '_type'; - $foreignKey = $morph . '_id'; - } + [$morphType, $foreignKey] = $this->parseMorph($morph); $type = $type ?: get_class($this); @@ -561,14 +580,15 @@ trait RelationShip } /** - * MORPH MANY 关联定义 - * @access public - * @param string $model 模型名 - * @param string|array $morph 多态字段信息 - * @param string $type 多态类型 + * MORPH MANY 关联定义. + * + * @param string $model 模型名 + * @param string|array $morph 多态字段信息 + * @param string $type 多态类型 + * * @return MorphMany */ - public function morphMany(string $model, $morph = null, string $type = ''): MorphMany + public function morphMany(string $model, string|array $morph = null, string $type = ''): MorphMany { // 记录当前关联信息 $model = $this->parseModel($model); @@ -580,95 +600,75 @@ trait RelationShip $type = $type ?: get_class($this); - if (is_array($morph)) { - [$morphType, $foreignKey] = $morph; - } else { - $morphType = $morph . '_type'; - $foreignKey = $morph . '_id'; - } + [$morphType, $foreignKey] = $this->parseMorph($morph); return new MorphMany($this, $model, $foreignKey, $morphType, $type); } /** - * MORPH TO 关联定义 - * @access public - * @param string|array $morph 多态字段信息 - * @param array $alias 多态别名定义 + * MORPH TO 关联定义. + * + * @param string|array $morph 多态字段信息 + * @param array $alias 多态别名定义 + * * @return MorphTo */ - public function morphTo($morph = null, array $alias = []): MorphTo + public function morphTo(string|array $morph = null, array $alias = []): MorphTo { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); - $relation = Str::snake($trace[1]['function']); + $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); + $relation = Str::snake($trace[1]['function']); if (is_null($morph)) { - $morph = $relation; + $morph = $relation; } - // 记录当前关联信息 - if (is_array($morph)) { - [$morphType, $foreignKey] = $morph; - } else { - $morphType = $morph . '_type'; - $foreignKey = $morph . '_id'; - } + [$morphType, $foreignKey] = $this->parseMorph($morph); return new MorphTo($this, $morphType, $foreignKey, $alias, $relation); } /** - * MORPH TO MANY关联定义 - * @access public - * @param string $model 模型名 - * @param string $middle 中间表名/模型名 - * @param string|array $morph 多态字段信息 - * @param string $localKey 当前模型关联键 + * MORPH TO MANY关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表名/模型名 + * @param string|array $morph 多态字段信息 + * @param string $localKey 当前模型关联键 + * * @return MorphToMany */ - public function morphToMany(string $model, string $middle, $morph = null, string $localKey = null): MorphToMany + public function morphToMany(string $model, string $middle, string|array $morph = null, string $localKey = null): MorphToMany { if (is_null($morph)) { $morph = $middle; } - // 记录当前关联信息 - if (is_array($morph)) { - [$morphType, $morphKey] = $morph; - } else { - $morphType = $morph . '_type'; - $morphKey = $morph . '_id'; - } + [$morphType, $morphKey] = $this->parseMorph($morph); - $model = $this->parseModel($model); - $name = Str::snake(class_basename($model)); - $localKey = $localKey ?: $this->getForeignKey($name); + $model = $this->parseModel($model); + $name = Str::snake(class_basename($model)); + $localKey = $localKey ?: $this->getForeignKey($name); return new MorphToMany($this, $model, $middle, $morphType, $morphKey, $localKey); } /** - * MORPH BY MANY关联定义 - * @access public - * @param string $model 模型名 - * @param string $middle 中间表名/模型名 - * @param string|array $morph 多态字段信息 - * @param string $foreignKey 关联外键 + * MORPH BY MANY关联定义. + * + * @param string $model 模型名 + * @param string $middle 中间表名/模型名 + * @param string|array $morph 多态字段信息 + * @param string $foreignKey 关联外键 + * * @return MorphToMany */ - public function morphByMany(string $model, string $middle, $morph = null, string $foreignKey = null): MorphToMany + public function morphByMany(string $model, string $middle, string|array $morph = null, string $foreignKey = null): MorphToMany { if (is_null($morph)) { $morph = $middle; } - // 记录当前关联信息 - if (is_array($morph)) { - [$morphType, $morphKey] = $morph; - } else { - $morphType = $morph . '_type'; - $morphKey = $morph . '_id'; - } + [$morphType, $morphKey] = $this->parseMorph($morph); $model = $this->parseModel($model); $foreignKey = $foreignKey ?: $this->getForeignKey($this->name); @@ -677,14 +677,34 @@ trait RelationShip } /** - * 解析模型的完整命名空间 - * @access protected - * @param string $model 模型名(或者完整类名) + * 解析多态 + * + * @param string|array $morph + * + * @return array + */ + protected function parseMorph(string|array $morph): array + { + if (is_array($morph)) { + [$morphType, $foreignKey] = $morph; + } else { + $morphType = $morph . '_type'; + $foreignKey = $morph . '_id'; + } + + return [$morphType, $foreignKey]; + } + + /** + * 解析模型的完整命名空间. + * + * @param string $model 模型名(或者完整类名) + * * @return string */ protected function parseModel(string $model): string { - if (false === strpos($model, '\\')) { + if (!str_contains($model, '\\')) { $path = explode('\\', static::class); array_pop($path); array_push($path, Str::studly($model)); @@ -695,14 +715,15 @@ trait RelationShip } /** - * 获取模型的默认外键名 - * @access protected - * @param string $name 模型名 + * 获取模型的默认外键名. + * + * @param string $name 模型名 + * * @return string */ protected function getForeignKey(string $name): string { - if (strpos($name, '\\')) { + if (str_contains($name, '\\')) { $name = class_basename($name); } @@ -710,9 +731,10 @@ trait RelationShip } /** - * 检查属性是否为关联属性 如果是则返回关联方法名 - * @access protected - * @param string $attr 关联属性名 + * 检查属性是否为关联属性 如果是则返回关联方法名. + * + * @param string $attr 关联属性名 + * * @return string|false */ protected function isRelationAttr(string $attr) @@ -727,17 +749,20 @@ trait RelationShip } /** - * 智能获取关联模型数据 - * @access protected - * @param Relation $modelRelation 模型关联对象 + * 智能获取关联模型数据. + * + * @param Relation $modelRelation 模型关联对象 + * * @return mixed */ protected function getRelationData(Relation $modelRelation) { - if ($this->parent && !$modelRelation->isSelfRelation() + if ( + $this->parent && !$modelRelation->isSelfRelation() && get_class($this->parent) == get_class($modelRelation->getModel()) - && $modelRelation instanceof OneToOne + && ($modelRelation instanceof OneToOne || $modelRelation instanceof HasOneThrough || $modelRelation instanceof MorphTo || $modelRelation instanceof MorphOne) ) { + if(empty($this->parent->parent)) $this->parent->parent = $this; return $this->parent; } @@ -746,8 +771,8 @@ trait RelationShip } /** - * 关联数据自动写入检查 - * @access protected + * 关联数据自动写入检查. + * * @return void */ protected function checkAutoRelationWrite(): void @@ -776,8 +801,8 @@ trait RelationShip } /** - * 自动关联数据更新(针对一对一关联) - * @access protected + * 自动关联数据更新(针对一对一关联). + * * @return void */ protected function autoRelationUpdate(): void @@ -796,8 +821,8 @@ trait RelationShip } /** - * 自动关联数据写入(针对一对一关联) - * @access protected + * 自动关联数据写入(针对一对一关联). + * * @return void */ protected function autoRelationInsert(): void @@ -809,9 +834,10 @@ trait RelationShip } /** - * 自动关联数据删除(支持一对一及一对多关联) - * @access protected - * @param bool $force 强制删除 + * 自动关联数据删除(支持一对一及一对多关联). + * + * @param bool $force 强制删除 + * * @return void */ protected function autoRelationDelete($force = false): void @@ -831,13 +857,14 @@ trait RelationShip } /** - * 移除当前模型的关联属性 - * @access public + * 移除当前模型的关联属性. + * * @return $this */ public function removeRelation() { $this->relation = []; + return $this; } } diff --git a/vendor/topthink/think-orm/src/model/concern/SoftDelete.php b/vendor/topthink/think-orm/src/model/concern/SoftDelete.php index b7b1092..3e7eefe 100644 --- a/vendor/topthink/think-orm/src/model/concern/SoftDelete.php +++ b/vendor/topthink/think-orm/src/model/concern/SoftDelete.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; @@ -17,23 +18,25 @@ use think\Model; /** * 数据软删除 + * * @mixin Model + * * @method $this withTrashed() * @method $this onlyTrashed() */ trait SoftDelete { - public function db($scope = []): Query { $query = parent::db($scope); $this->withNoTrashed($query); + return $query; } /** - * 判断当前实例是否被软删除 - * @access public + * 判断当前实例是否被软删除. + * * @return bool */ public function trashed(): bool @@ -47,12 +50,12 @@ trait SoftDelete return false; } - public function scopeWithTrashed(Query $query) + public function scopeWithTrashed(Query $query): void { $query->removeOption('soft_delete'); } - public function scopeOnlyTrashed(Query $query) + public function scopeOnlyTrashed(Query $query): void { $field = $this->getDeleteTimeField(true); @@ -62,8 +65,8 @@ trait SoftDelete } /** - * 获取软删除数据的查询条件 - * @access protected + * 获取软删除数据的查询条件. + * * @return array */ protected function getWithTrashedExp(): array @@ -72,8 +75,8 @@ trait SoftDelete } /** - * 删除当前的记录 - * @access public + * 删除当前的记录. + * * @return bool */ public function delete(): bool @@ -82,7 +85,7 @@ trait SoftDelete return false; } - $name = $this->getDeleteTimeField(); + $name = $this->getDeleteTimeField(); $force = $this->isForce(); if ($name && !$force) { @@ -101,8 +104,6 @@ trait SoftDelete ->where($where) ->removeOption('soft_delete') ->delete(); - - $this->lazySave(false); } // 关联删除 @@ -118,10 +119,11 @@ trait SoftDelete } /** - * 删除记录 - * @access public - * @param mixed $data 主键列表 支持闭包查询条件 - * @param bool $force 是否强制删除 + * 删除记录. + * + * @param mixed $data 主键列表 支持闭包查询条件 + * @param bool $force 是否强制删除 + * * @return bool */ public static function destroy($data, bool $force = false): bool @@ -141,15 +143,13 @@ trait SoftDelete if (is_array($data) && key($data) !== 0) { $query->where($data); - $data = null; + $data = []; } elseif ($data instanceof \Closure) { call_user_func_array($data, [&$query]); - $data = null; - } elseif (is_null($data)) { - return false; + $data = []; } - $resultSet = $query->select($data); + $resultSet = $query->select((array) $data); foreach ($resultSet as $result) { /** @var Model $result */ @@ -160,12 +160,13 @@ trait SoftDelete } /** - * 恢复被软删除的记录 - * @access public + * 恢复被软删除的记录. + * * @param array $where 更新条件 + * * @return bool */ - public function restore($where = []): bool + public function restore(array $where = []): bool { $name = $this->getDeleteTimeField(); @@ -192,12 +193,13 @@ trait SoftDelete } /** - * 获取软删除字段 - * @access protected + * 获取软删除字段. + * * @param bool $read 是否查询操作 写操作的时候会自动去掉表别名 + * * @return string|false */ - protected function getDeleteTimeField(bool $read = false) + public function getDeleteTimeField(bool $read = false): bool|string { $field = property_exists($this, 'deleteTime') && isset($this->deleteTime) ? $this->deleteTime : 'delete_time'; @@ -205,11 +207,11 @@ trait SoftDelete return false; } - if (false === strpos($field, '.')) { + if (!str_contains($field, '.')) { $field = '__TABLE__.' . $field; } - if (!$read && strpos($field, '.')) { + if (!$read && str_contains($field, '.')) { $array = explode('.', $field); $field = array_pop($array); } @@ -218,9 +220,10 @@ trait SoftDelete } /** - * 查询的时候默认排除软删除数据 - * @access protected + * 查询的时候默认排除软删除数据. + * * @param Query $query + * * @return void */ protected function withNoTrashed(Query $query): void diff --git a/vendor/topthink/think-orm/src/model/concern/TimeStamp.php b/vendor/topthink/think-orm/src/model/concern/TimeStamp.php index 9440c3e..b678f2a 100644 --- a/vendor/topthink/think-orm/src/model/concern/TimeStamp.php +++ b/vendor/topthink/think-orm/src/model/concern/TimeStamp.php @@ -1,52 +1,60 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; use DateTime; +use DateTimeInterface; +use Stringable; /** - * 自动时间戳 + * 自动时间戳. */ trait TimeStamp { /** - * 是否需要自动写入时间戳 如果设置为字符串 则表示时间字段的类型 + * 是否需要自动写入时间戳 如果设置为字符串 则表示时间字段的类型. + * * @var bool|string */ protected $autoWriteTimestamp; /** - * 创建时间字段 false表示关闭 + * 创建时间字段 false表示关闭. + * * @var false|string */ protected $createTime = 'create_time'; /** - * 更新时间字段 false表示关闭 + * 更新时间字段 false表示关闭. + * * @var false|string */ protected $updateTime = 'update_time'; /** - * 时间字段显示格式 + * 时间字段显示格式. + * * @var string */ protected $dateFormat; /** - * 是否需要自动写入时间字段 - * @access public - * @param bool|string $auto + * 是否需要自动写入时间字段. + * + * @param bool|string $auto + * * @return $this */ public function isAutoWriteTimestamp($auto) @@ -57,9 +65,10 @@ trait TimeStamp } /** - * 检测时间字段的实际类型 - * @access public - * @param bool|string $type + * 检测时间字段的实际类型. + * + * @param bool|string $type + * * @return mixed */ protected function checkTimeFieldType($type) @@ -78,10 +87,11 @@ trait TimeStamp } /** - * 设置时间字段名称 - * @access public - * @param string $createTime - * @param string $updateTime + * 设置时间字段名称. + * + * @param string $createTime + * @param string $updateTime + * * @return $this */ public function setTimeField(string $createTime, string $updateTime) @@ -93,8 +103,8 @@ trait TimeStamp } /** - * 获取自动写入时间字段 - * @access public + * 获取自动写入时间字段. + * * @return bool|string */ public function getAutoWriteTimestamp() @@ -103,9 +113,10 @@ trait TimeStamp } /** - * 设置时间字段格式化 - * @access public - * @param string|false $format + * 设置时间字段格式化. + * + * @param string|false $format + * * @return $this */ public function setDateFormat($format) @@ -116,8 +127,8 @@ trait TimeStamp } /** - * 获取自动写入时间字段 - * @access public + * 获取自动写入时间字段. + * * @return string|false */ public function getDateFormat() @@ -126,8 +137,8 @@ trait TimeStamp } /** - * 自动写入时间戳 - * @access protected + * 自动写入时间戳. + * * @return mixed */ protected function autoWriteTimestamp() @@ -140,8 +151,9 @@ trait TimeStamp /** * 获取指定类型的时间字段值 - * @access protected - * @param string $type 时间字段类型 + * + * @param string $type 时间字段类型 + * * @return mixed */ protected function getTimeTypeValue(string $type) @@ -155,10 +167,10 @@ trait TimeStamp $value = $this->formatDateTime('Y-m-d H:i:s.u'); break; default: - if (false !== strpos($type, '\\')) { + if (str_contains($type, '\\')) { // 对象数据写入 $obj = new $type(); - if (method_exists($obj, '__toString')) { + if ($obj instanceof Stringable) { // 对象数据写入 $value = $obj->__toString(); } @@ -169,11 +181,12 @@ trait TimeStamp } /** - * 时间日期字段格式化处理 - * @access protected - * @param mixed $format 日期格式 - * @param mixed $time 时间日期表达式 - * @param bool $timestamp 时间表达式是否为时间戳 + * 时间日期字段格式化处理. + * + * @param mixed $format 日期格式 + * @param mixed $time 时间日期表达式 + * @param bool $timestamp 时间表达式是否为时间戳 + * * @return mixed */ protected function formatDateTime($format, $time = 'now', bool $timestamp = false) @@ -184,15 +197,15 @@ trait TimeStamp if (false === $format) { return $time; - } elseif (false !== strpos($format, '\\')) { + } elseif (str_contains($format, '\\')) { return new $format($time); } - if ($time instanceof DateTime) { + if ($time instanceof DateTimeInterface) { $dateTime = $time; } elseif ($timestamp) { $dateTime = new DateTime(); - $dateTime->setTimestamp((int) $time); + $dateTime->setTimestamp(is_numeric($time) ? (int) $time : strtotime($time)); } else { $dateTime = new DateTime($time); } @@ -202,8 +215,9 @@ trait TimeStamp /** * 获取时间字段值 - * @access protected - * @param mixed $value + * + * @param mixed $value + * * @return mixed */ protected function getTimestampValue($value) diff --git a/vendor/topthink/think-orm/src/model/concern/Virtual.php b/vendor/topthink/think-orm/src/model/concern/Virtual.php index 66cdfb7..b58041b 100644 --- a/vendor/topthink/think-orm/src/model/concern/Virtual.php +++ b/vendor/topthink/think-orm/src/model/concern/Virtual.php @@ -1,29 +1,32 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\concern; use think\db\BaseQuery as Query; use think\db\exception\DbException as Exception; +use think\Model; /** - * 虚拟模型 + * 虚拟模型. */ trait Virtual { /** * 获取当前模型的数据库查询对象 - * @access public + * * @param array $scope 设置不使用的全局查询范围 + * * @return Query */ public function db($scope = []): Query @@ -32,23 +35,32 @@ trait Virtual } /** - * 获取字段类型信息 - * @access public + * 获取字段类型信息. + * * @param string $field 字段名 + * * @return string|null */ public function getFieldType(string $field) - {} + { + } /** * 保存当前数据对象 - * @access public - * @param array $data 数据 + * + * @param array|object $data 数据 * @param string $sequence 自增序列名 + * * @return bool */ - public function save(array $data = [], string $sequence = null): bool + public function save(array|object $data = [], string $sequence = null): bool { + if ($data instanceof Model) { + $data = $data->getData(); + } elseif (is_object($data)) { + $data = get_object_vars($data); + } + // 数据对象赋值 $this->setAttrs($data); @@ -65,8 +77,8 @@ trait Virtual } /** - * 删除当前的记录 - * @access public + * 删除当前的记录. + * * @return bool */ public function delete(): bool @@ -86,5 +98,4 @@ trait Virtual return true; } - } diff --git a/vendor/topthink/think-orm/src/model/relation/BelongsTo.php b/vendor/topthink/think-orm/src/model/relation/BelongsTo.php index dfac254..75771a3 100644 --- a/vendor/topthink/think-orm/src/model/relation/BelongsTo.php +++ b/vendor/topthink/think-orm/src/model/relation/BelongsTo.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\relation; @@ -17,27 +18,27 @@ use think\db\BaseQuery as Query; use think\Model; /** - * BelongsTo关联类 + * BelongsTo关联类. */ class BelongsTo extends OneToOne { /** - * 架构函数 - * @access public - * @param Model $parent 上级模型对象 - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 关联主键 - * @param string $relation 关联名 + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 关联主键 + * @param string $relation 关联名 */ public function __construct(Model $parent, string $model, string $foreignKey, string $localKey, string $relation = null) { - $this->parent = $parent; - $this->model = $model; - $this->foreignKey = $foreignKey; - $this->localKey = $localKey; - $this->query = (new $model)->db(); - $this->relation = $relation; + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); + $this->relation = $relation; if (get_class($parent) == $model) { $this->selfRelation = true; @@ -45,21 +46,21 @@ class BelongsTo extends OneToOne } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Model */ public function getRelation(array $subRelation = [], Closure $closure = null) { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } - $foreignKey = $this->foreignKey; - - $relationModel = $this->query + $foreignKey = $this->foreignKey; + $relationModel = $this->query ->removeWhereField($this->localKey) ->where($this->localKey, $this->parent->$foreignKey) ->relation($subRelation) @@ -73,25 +74,27 @@ class BelongsTo extends OneToOne $relationModel->setParent(clone $this->parent); } else { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } return $relationModel; } /** - * 创建关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 聚合字段别名 + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 聚合字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', &$name = ''): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -102,13 +105,14 @@ class BelongsTo extends OneToOne /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 - * @return integer + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) { @@ -119,7 +123,7 @@ class BelongsTo extends OneToOne } if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -128,13 +132,14 @@ class BelongsTo extends OneToOne } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null): Query @@ -158,19 +163,20 @@ class BelongsTo extends OneToOne } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null): Query { - $table = $this->query->getTable(); - $model = class_basename($this->parent); - $relation = class_basename($this->model); + $table = $this->query->getTable(); + $model = class_basename($this->parent); + $relation = class_basename($this->model); if (is_array($where)) { $this->getQueryWhere($where, $relation); @@ -195,13 +201,14 @@ class BelongsTo extends OneToOne } /** - * 预载入关联查询(数据集) - * @access protected - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -209,7 +216,7 @@ class BelongsTo extends OneToOne $localKey = $this->localKey; $foreignKey = $this->foreignKey; - $range = []; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 if (isset($result->$foreignKey)) { @@ -219,6 +226,8 @@ class BelongsTo extends OneToOne if (!empty($range)) { $this->query->removeWhereField($localKey); + $default = $this->query->getOptions('default_model'); + $defaultModel = $this->getDefaultModel($default); $data = $this->eagerlyWhere([ [$localKey, 'in', $range], @@ -228,7 +237,7 @@ class BelongsTo extends OneToOne foreach ($resultSet as $result) { // 关联模型 if (!isset($data[$result->$foreignKey])) { - $relationModel = $this->getDefaultModel(); + $relationModel = $defaultModel; } else { $relationModel = $data[$result->$foreignKey]; $relationModel->setParent(clone $result); @@ -247,13 +256,14 @@ class BelongsTo extends OneToOne } /** - * 预载入关联查询(数据) - * @access protected - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -269,7 +279,8 @@ class BelongsTo extends OneToOne // 关联模型 if (!isset($data[$result->$foreignKey])) { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } else { $relationModel = $data[$result->$foreignKey]; $relationModel->setParent(clone $result); @@ -287,9 +298,10 @@ class BelongsTo extends OneToOne } /** - * 添加关联数据 - * @access public - * @param Model $model关联模型对象 + * 添加关联数据. + * + * @param Model $model关联模型对象 + * * @return Model */ public function associate(Model $model): Model @@ -301,8 +313,8 @@ class BelongsTo extends OneToOne } /** - * 注销关联数据 - * @access public + * 注销关联数据. + * * @return Model */ public function dissociate(): Model @@ -316,8 +328,8 @@ class BelongsTo extends OneToOne } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void diff --git a/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php b/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php index 8c74f34..9c045b8 100644 --- a/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php +++ b/vendor/topthink/think-orm/src/model/relation/BelongsToMany.php @@ -1,8 +1,9 @@ parent = $parent; - $this->model = $model; - $this->foreignKey = $foreignKey; - $this->localKey = $localKey; + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; - if (false !== strpos($middle, '\\')) { + if (str_contains($middle, '\\')) { $this->pivotName = $middle; - $this->middle = class_basename($middle); + $this->middle = class_basename($middle); } else { $this->middle = $middle; } - $this->query = (new $model)->db(); + $this->query = (new $model())->db(); $this->pivot = $this->newPivot(); } /** - * 设置中间表模型 - * @access public - * @param $pivot + * 设置中间表模型. + * + * @param $pivot + * * @return $this */ public function pivot(string $pivot) { $this->pivotName = $pivot; + return $this; } /** - * 设置中间表数据名称 - * @access public - * @param string $name + * 设置中间表数据名称. + * + * @param string $name + * * @return $this */ public function name(string $name) { $this->pivotDataName = $name; + return $this; } /** - * 实例化中间表模型 - * @access public - * @param $data - * @return Pivot + * 实例化中间表模型. + * + * @param $data + * * @throws Exception + * + * @return Pivot */ protected function newPivot(array $data = []): Pivot { @@ -120,16 +131,17 @@ class BelongsToMany extends Relation } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Collection */ public function getRelation(array $subRelation = [], Closure $closure = null): Collection { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } return $this->relation($subRelation) @@ -138,16 +150,17 @@ class BelongsToMany extends Relation } /** - * 组装Pivot模型 - * @access public - * @param Model $result 模型对象 + * 组装Pivot模型. + * + * @param Model $result 模型对象 + * * @return array */ protected function matchPivot(Model $result): array { $pivot = []; foreach ($result->getData() as $key => $val) { - if (strpos($key, '__')) { + if (str_contains($key, '__')) { [$name, $attr] = explode('__', $key, 2); if ('pivot' == $name) { @@ -163,17 +176,19 @@ class BelongsToMany extends Relation ]); $result->setRelation($this->pivotDataName, $pivotData); + return $pivot; } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Model */ public function has(string $operator = '>=', $count = 1, $id = '*', string $joinType = 'INNER', Query $query = null) @@ -182,14 +197,16 @@ class BelongsToMany extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 - * @return Query + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @throws Exception + * + * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null) { @@ -197,34 +214,37 @@ class BelongsToMany extends Relation } /** - * 设置中间表的查询条件 - * @access public - * @param string $field - * @param string $op - * @param mixed $condition + * 设置中间表的查询条件. + * + * @param string $field + * @param string $op + * @param mixed $condition + * * @return $this */ public function wherePivot($field, $op = null, $condition = null) { $this->query->where('pivot.' . $field, $op, $condition); + return $this; } /** - * 预载入关联查询(数据集) - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $localKey = $this->localKey; - $pk = $resultSet[0]->getPk(); - $range = []; + $localKey = $this->localKey; + $pk = $resultSet[0]->getPk(); + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 @@ -251,13 +271,14 @@ class BelongsToMany extends Relation } /** - * 预载入关联查询(单个数据) - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(单个数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void @@ -282,15 +303,16 @@ class BelongsToMany extends Relation /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 - * @return integer + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int */ - public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): float + public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) { $pk = $result->getPk(); @@ -301,7 +323,7 @@ class BelongsToMany extends Relation $pk = $result->$pk; if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ @@ -310,18 +332,19 @@ class BelongsToMany extends Relation } /** - * 获取关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ @@ -332,18 +355,19 @@ class BelongsToMany extends Relation } /** - * 多对多 关联模型预查询 - * @access protected - * @param array $where 关联预查询条件 - * @param array $subRelation 子关联 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 多对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyManyToMany(array $where, array $subRelation = [], Closure $closure = null, array $cache = []): array { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $withLimit = $this->query->getOptions('limit'); @@ -358,10 +382,10 @@ class BelongsToMany extends Relation ->select(); // 组装模型数据 - $data = []; + $data = []; foreach ($list as $set) { $pivot = $this->matchPivot($set); - $key = $pivot[$this->localKey]; + $key = $pivot[$this->localKey]; if ($withLimit && isset($data[$key]) && count($data[$key]) >= $withLimit) { continue; @@ -374,11 +398,12 @@ class BelongsToMany extends Relation } /** - * BELONGS TO MANY 关联查询 - * @access protected - * @param string $foreignKey 关联模型关联键 - * @param string $localKey 当前模型关联键 - * @param array $condition 关联查询条件 + * BELONGS TO MANY 关联查询. + * + * @param string $foreignKey 关联模型关联键 + * @param string $localKey 当前模型关联键 + * @param array $condition 关联查询条件 + * * @return Query */ protected function belongsToManyQuery(string $foreignKey, string $localKey, array $condition = []): Query @@ -386,12 +411,7 @@ class BelongsToMany extends Relation // 关联查询封装 if (empty($this->baseQuery)) { $tableName = $this->query->getTable(); - $table = $this->pivot->db()->getTable(); - - if ($this->withoutField) { - $this->query->withoutField($this->withoutField); - } - + $table = $this->pivot->db()->getTable(); $fields = $this->getQueryFields($tableName); $this->query @@ -399,7 +419,6 @@ class BelongsToMany extends Relation ->tableField(true, $table, 'pivot', 'pivot__') ->join([$table => 'pivot'], 'pivot.' . $foreignKey . '=' . $tableName . '.' . $this->query->getPk()) ->where($condition); - } return $this->query; @@ -407,9 +426,10 @@ class BelongsToMany extends Relation /** * 保存(新增)当前关联数据对象 - * @access public - * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 - * @param array $pivot 中间表额外数据 + * + * @param mixed $data 数据 可以使用数组 关联模型对象 和 关联对象的主键 + * @param array $pivot 中间表额外数据 + * * @return array|Pivot */ public function save($data, array $pivot = []) @@ -420,10 +440,11 @@ class BelongsToMany extends Relation /** * 批量保存当前关联数据对象 - * @access public - * @param iterable $dataSet 数据集 - * @param array $pivot 中间表额外数据 - * @param bool $samePivot 额外数据是否相同 + * + * @param iterable $dataSet 数据集 + * @param array $pivot 中间表额外数据 + * @param bool $samePivot 额外数据是否相同 + * * @return array|false */ public function saveAll(iterable $dataSet, array $pivot = [], bool $samePivot = false) @@ -444,12 +465,14 @@ class BelongsToMany extends Relation } /** - * 附加关联的一个中间表数据 - * @access public - * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 - * @param array $pivot 中间表额外数据 - * @return array|Pivot + * 附加关联的一个中间表数据. + * + * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 + * @param array $pivot 中间表额外数据 + * * @throws Exception + * + * @return array|Pivot */ public function attach($data, array $pivot = []) { @@ -458,8 +481,8 @@ class BelongsToMany extends Relation $id = $data; } else { // 保存关联表数据 - $model = new $this->model; - $id = $model->insertGetId($data); + $model = new $this->model(); + $id = $model->insertGetId($data); } } elseif (is_numeric($data) || is_string($data)) { // 根据关联表主键直接写入中间表 @@ -495,9 +518,10 @@ class BelongsToMany extends Relation } /** - * 判断是否存在关联数据 - * @access public - * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * 判断是否存在关联数据. + * + * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * * @return Pivot|false */ public function attached($data) @@ -517,11 +541,12 @@ class BelongsToMany extends Relation } /** - * 解除关联的一个中间表数据 - * @access public - * @param integer|array $data 数据 可以使用关联对象的主键 - * @param bool $relationDel 是否同时删除关联表数据 - * @return integer + * 解除关联的一个中间表数据. + * + * @param int|array $data 数据 可以使用关联对象的主键 + * @param bool $relationDel 是否同时删除关联表数据 + * + * @return int */ public function detach($data = null, bool $relationDel = false): int { @@ -536,7 +561,7 @@ class BelongsToMany extends Relation } // 删除中间表数据 - $pivot = []; + $pivot = []; $pivot[] = [$this->localKey, '=', $this->parent->getKey()]; if (isset($id)) { @@ -555,10 +580,11 @@ class BelongsToMany extends Relation } /** - * 数据同步 - * @access public - * @param array $ids - * @param bool $detaching + * 数据同步. + * + * @param array $ids + * @param bool $detaching + * * @return array */ public function sync(array $ids, bool $detaching = true): array @@ -603,15 +629,15 @@ class BelongsToMany extends Relation } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void { if (empty($this->baseQuery)) { $foreignKey = $this->foreignKey; - $localKey = $this->localKey; + $localKey = $this->localKey; $this->query->filter(function ($result, $options) { $this->matchPivot($result); @@ -629,5 +655,4 @@ class BelongsToMany extends Relation $this->baseQuery = true; } } - } diff --git a/vendor/topthink/think-orm/src/model/relation/HasMany.php b/vendor/topthink/think-orm/src/model/relation/HasMany.php index 4624955..01854de 100644 --- a/vendor/topthink/think-orm/src/model/relation/HasMany.php +++ b/vendor/topthink/think-orm/src/model/relation/HasMany.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\relation; @@ -19,25 +20,25 @@ use think\Model; use think\model\Relation; /** - * 一对多关联类 + * 一对多关联类. */ class HasMany extends Relation { /** - * 架构函数 - * @access public - * @param Model $parent 上级模型对象 - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 当前模型主键 + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 */ public function __construct(Model $parent, string $model, string $foreignKey, string $localKey) { - $this->parent = $parent; - $this->model = $model; - $this->foreignKey = $foreignKey; - $this->localKey = $localKey; - $this->query = (new $model)->db(); + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); if (get_class($parent) == $model) { $this->selfRelation = true; @@ -45,16 +46,17 @@ class HasMany extends Relation } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Collection */ public function getRelation(array $subRelation = [], Closure $closure = null): Collection { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } return $this->query @@ -65,19 +67,20 @@ class HasMany extends Relation } /** - * 预载入关联查询 - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $localKey = $this->localKey; - $range = []; + $localKey = $this->localKey; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 @@ -104,13 +107,14 @@ class HasMany extends Relation } /** - * 预载入关联查询 - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -118,8 +122,8 @@ class HasMany extends Relation $localKey = $this->localKey; if (isset($result->$localKey)) { - $pk = $result->$localKey; - $data = $this->eagerlyOneToMany([ + $pk = $result->$localKey; + $data = $this->eagerlyOneToMany([ [$this->foreignKey, '=', $pk], ], $subRelation, $closure, $cache); @@ -134,13 +138,14 @@ class HasMany extends Relation /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 - * @return integer + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) { @@ -151,7 +156,7 @@ class HasMany extends Relation } if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -160,18 +165,19 @@ class HasMany extends Relation } /** - * 创建关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query->alias($aggregate . '_table') @@ -181,12 +187,13 @@ class HasMany extends Relation } /** - * 一对多 关联模型预查询 - * @access public - * @param array $where 关联预查询条件 - * @param array $subRelation 子关联 - * @param Closure $closure - * @param array $cache 关联缓存 + * 一对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyOneToMany(array $where, array $subRelation = [], Closure $closure = null, array $cache = []): array @@ -198,11 +205,7 @@ class HasMany extends Relation // 预载入关联查询 支持嵌套预载入 if ($closure) { $this->baseQuery = true; - $closure($this->getClosureType($closure)); - } - - if ($this->withoutField) { - $this->query->withoutField($this->withoutField); + $closure($this->query); } $withLimit = $this->query->getOptions('limit'); @@ -217,8 +220,7 @@ class HasMany extends Relation ->select(); // 组装模型数据 - $data = []; - + $data = []; foreach ($list as $set) { $key = $set->$foreignKey; @@ -234,28 +236,27 @@ class HasMany extends Relation /** * 保存(新增)当前关联数据对象 - * @access public - * @param mixed $data 数据 可以使用数组 关联模型对象 - * @param boolean $replace 是否自动识别更新和写入 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * * @return Model|false */ - public function save($data, bool $replace = true) + public function save(array|Model $data, bool $replace = true) { - if ($data instanceof Model) { - $data = $data->getData(); - } - $model = $this->make(); return $model->replace($replace)->save($data) ? $model : false; } /** - * 创建关联对象实例 + * 创建关联对象实例. + * * @param array|Model $data + * * @return Model */ - public function make($data = []): Model + public function make(array|Model $data = []): Model { if ($data instanceof Model) { $data = $data->getData(); @@ -269,9 +270,10 @@ class HasMany extends Relation /** * 批量保存当前关联数据对象 - * @access public - * @param iterable $dataSet 数据集 - * @param boolean $replace 是否自动识别更新和写入 + * + * @param iterable $dataSet 数据集 + * @param bool $replace 是否自动识别更新和写入 + * * @return array|false */ public function saveAll(iterable $dataSet, bool $replace = true) @@ -286,28 +288,28 @@ class HasMany extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = 'INNER', Query $query = null): Query { - $table = $this->query->getTable(); - - $model = class_basename($this->parent); - $relation = class_basename($this->model); + $table = $this->query->getTable(); + $model = class_basename($this->parent); + $relation = class_basename($this->model); if ('*' != $id) { - $id = $relation . '.' . (new $this->model)->getPk(); + $id = $relation . '.' . (new $this->model())->getPk(); } $softDelete = $this->query->getOptions('soft_delete'); - $query = $query ?: $this->parent->db()->alias($model); + $query = $query ?: $this->parent->db()->alias($model); return $query->field($model . '.*') ->join([$table => $relation], $model . '.' . $this->localKey . '=' . $relation . '.' . $this->foreignKey, $joinType) @@ -319,19 +321,20 @@ class HasMany extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null): Query { - $table = $this->query->getTable(); - $model = class_basename($this->parent); - $relation = class_basename($this->model); + $table = $this->query->getTable(); + $model = class_basename($this->parent); + $relation = class_basename($this->model); if (is_array($where)) { $this->getQueryWhere($where, $relation); @@ -342,9 +345,9 @@ class HasMany extends Relation $where = $this->query; } - $fields = $this->getRelationQueryFields($fields, $model); + $fields = $this->getRelationQueryFields($fields, $model); $softDelete = $this->query->getOptions('soft_delete'); - $query = $query ?: $this->parent->db(); + $query = $query ?: $this->parent->db(); return $query->alias($model) ->group($model . '.' . $this->localKey) @@ -357,8 +360,8 @@ class HasMany extends Relation } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void @@ -372,5 +375,4 @@ class HasMany extends Relation $this->baseQuery = true; } } - } diff --git a/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php b/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php index 4f14399..f543117 100644 --- a/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php +++ b/vendor/topthink/think-orm/src/model/relation/HasManyThrough.php @@ -1,8 +1,9 @@ parent = $parent; - $this->model = $model; - $this->through = (new $through)->db(); - $this->foreignKey = $foreignKey; - $this->throughKey = $throughKey; - $this->localKey = $localKey; - $this->throughPk = $throughPk; - $this->query = (new $model)->db(); + $this->parent = $parent; + $this->model = $model; + $this->through = (new $through())->db(); + $this->foreignKey = $foreignKey; + $this->throughKey = $throughKey; + $this->localKey = $localKey; + $this->throughPk = $throughPk; + $this->query = (new $model())->db(); } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Collection */ public function getRelation(array $subRelation = [], Closure $closure = null) { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $this->baseQuery(); @@ -85,24 +90,25 @@ class HasManyThrough extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null): Query { - $model = Str::snake(class_basename($this->parent)); - $throughTable = $this->through->getTable(); - $pk = $this->throughPk; - $throughKey = $this->throughKey; - $relation = new $this->model; - $relationTable = $relation->getTable(); - $softDelete = $this->query->getOptions('soft_delete'); + $model = Str::snake(class_basename($this->parent)); + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $relation = new $this->model(); + $relationTable = $relation->getTable(); + $softDelete = $this->query->getOptions('soft_delete'); if ('*' != $id) { $id = $relationTable . '.' . $relation->getPk(); @@ -120,21 +126,22 @@ class HasManyThrough extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, $joinType = '', Query $query = null): Query { - $model = Str::snake(class_basename($this->parent)); - $throughTable = $this->through->getTable(); - $pk = $this->throughPk; - $throughKey = $this->throughKey; - $modelTable = (new $this->model)->getTable(); + $model = Str::snake(class_basename($this->parent)); + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = (new $this->model())->getTable(); if (is_array($where)) { $this->getQueryWhere($where, $modelTable); @@ -161,13 +168,14 @@ class HasManyThrough extends Relation } /** - * 预载入关联查询(数据集) - * @access protected - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -175,7 +183,7 @@ class HasManyThrough extends Relation $localKey = $this->localKey; $foreignKey = $this->foreignKey; - $range = []; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 if (isset($result->$localKey)) { @@ -204,13 +212,14 @@ class HasManyThrough extends Relation } /** - * 预载入关联查询(数据) - * @access protected - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -234,30 +243,31 @@ class HasManyThrough extends Relation } /** - * 关联模型预查询 - * @access public - * @param array $where 关联预查询条件 - * @param string $key 关联键名 - * @param array $subRelation 子关联 - * @param Closure $closure - * @param array $cache 关联缓存 + * 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyWhere(array $where, string $key, array $subRelation = [], Closure $closure = null, array $cache = []): array { // 预载入关联查询 支持嵌套预载入 - $throughList = $this->through->where($where)->select(); - $keys = $throughList->column($this->throughPk, $this->throughPk); + $throughList = $this->through->where($where)->select(); + $keys = $throughList->column($this->throughPk, $this->throughPk); if ($closure) { $this->baseQuery = true; - $closure($this->getClosureType($closure)); + $closure($this->query); } $throughKey = $this->throughKey; if ($this->baseQuery) { - $throughKey = Str::snake(class_basename($this->model)) . "." . $this->throughKey; + $throughKey = Str::snake(class_basename($this->model)) . '.' . $this->throughKey; } $withLimit = $this->query->getOptions('limit'); @@ -271,8 +281,8 @@ class HasManyThrough extends Relation ->select(); // 组装模型数据 - $data = []; - $keys = $throughList->column($this->foreignKey, $this->throughPk); + $data = []; + $keys = $throughList->column($this->foreignKey, $this->throughPk); foreach ($list as $set) { $key = $keys[$set->{$this->throughKey}]; @@ -289,12 +299,13 @@ class HasManyThrough extends Relation /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return mixed */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) @@ -306,16 +317,16 @@ class HasManyThrough extends Relation } if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } - $alias = Str::snake(class_basename($this->model)); + $alias = Str::snake(class_basename($this->model)); $throughTable = $this->through->getTable(); - $pk = $this->throughPk; - $throughKey = $this->throughKey; - $modelTable = $this->parent->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); - if (false === strpos($field, '.')) { + if (!str_contains($field, '.')) { $field = $alias . '.' . $field; } @@ -328,27 +339,28 @@ class HasManyThrough extends Relation } /** - * 创建关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } - $alias = Str::snake(class_basename($this->model)); - $throughTable = $this->through->getTable(); - $pk = $this->throughPk; - $throughKey = $this->throughKey; - $modelTable = $this->parent->getTable(); + $alias = Str::snake(class_basename($this->model)); + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); - if (false === strpos($field, '.')) { + if (!str_contains($field, '.')) { $field = $alias . '.' . $field; } @@ -362,24 +374,19 @@ class HasManyThrough extends Relation } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void { if (empty($this->baseQuery) && $this->parent->getData()) { - $alias = Str::snake(class_basename($this->model)); - $throughTable = $this->through->getTable(); - $pk = $this->throughPk; - $throughKey = $this->throughKey; - $modelTable = $this->parent->getTable(); - - if ($this->withoutField) { - $this->query->withoutField($this->withoutField); - } - - $fields = $this->getQueryFields($alias); + $alias = Str::snake(class_basename($this->model)); + $throughTable = $this->through->getTable(); + $pk = $this->throughPk; + $throughKey = $this->throughKey; + $modelTable = $this->parent->getTable(); + $fields = $this->getQueryFields($alias); $this->query ->field($fields) @@ -391,5 +398,4 @@ class HasManyThrough extends Relation $this->baseQuery = true; } } - } diff --git a/vendor/topthink/think-orm/src/model/relation/HasOne.php b/vendor/topthink/think-orm/src/model/relation/HasOne.php index b941f6e..437167a 100644 --- a/vendor/topthink/think-orm/src/model/relation/HasOne.php +++ b/vendor/topthink/think-orm/src/model/relation/HasOne.php @@ -1,14 +1,15 @@ // +---------------------------------------------------------------------- -declare (strict_types = 1); +declare(strict_types=1); namespace think\model\relation; @@ -17,25 +18,25 @@ use think\db\BaseQuery as Query; use think\Model; /** - * HasOne 关联类 + * HasOne 关联类. */ class HasOne extends OneToOne { /** - * 架构函数 - * @access public - * @param Model $parent 上级模型对象 - * @param string $model 模型名 - * @param string $foreignKey 关联外键 - * @param string $localKey 当前模型主键 + * 架构函数. + * + * @param Model $parent 上级模型对象 + * @param string $model 模型名 + * @param string $foreignKey 关联外键 + * @param string $localKey 当前模型主键 */ public function __construct(Model $parent, string $model, string $foreignKey, string $localKey) { - $this->parent = $parent; - $this->model = $model; - $this->foreignKey = $foreignKey; - $this->localKey = $localKey; - $this->query = (new $model)->db(); + $this->parent = $parent; + $this->model = $model; + $this->foreignKey = $foreignKey; + $this->localKey = $localKey; + $this->query = (new $model())->db(); if (get_class($parent) == $model) { $this->selfRelation = true; @@ -43,10 +44,11 @@ class HasOne extends OneToOne } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Model */ public function getRelation(array $subRelation = [], Closure $closure = null) @@ -54,7 +56,7 @@ class HasOne extends OneToOne $localKey = $this->localKey; if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } // 判断关联类型执行查询 @@ -72,25 +74,27 @@ class HasOne extends OneToOne $relationModel->setParent(clone $this->parent); } else { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } return $relationModel; } /** - * 创建关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 创建关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -101,13 +105,14 @@ class HasOne extends OneToOne /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 - * @return integer + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) { @@ -118,7 +123,7 @@ class HasOne extends OneToOne } if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -127,13 +132,14 @@ class HasOne extends OneToOne } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null): Query @@ -157,19 +163,20 @@ class HasOne extends OneToOne } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null): Query { - $table = $this->query->getTable(); - $model = class_basename($this->parent); - $relation = class_basename($this->model); + $table = $this->query->getTable(); + $model = class_basename($this->parent); + $relation = class_basename($this->model); if (is_array($where)) { $this->getQueryWhere($where, $relation); @@ -194,13 +201,14 @@ class HasOne extends OneToOne } /** - * 预载入关联查询(数据集) - * @access protected - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -208,7 +216,7 @@ class HasOne extends OneToOne $localKey = $this->localKey; $foreignKey = $this->foreignKey; - $range = []; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 if (isset($result->$localKey)) { @@ -218,6 +226,8 @@ class HasOne extends OneToOne if (!empty($range)) { $this->query->removeWhereField($foreignKey); + $default = $this->query->getOptions('default_model'); + $defaultModel = $this->getDefaultModel($default); $data = $this->eagerlyWhere([ [$foreignKey, 'in', $range], @@ -227,7 +237,7 @@ class HasOne extends OneToOne foreach ($resultSet as $result) { // 关联模型 if (!isset($data[$result->$localKey])) { - $relationModel = $this->getDefaultModel(); + $relationModel = $defaultModel; } else { $relationModel = $data[$result->$localKey]; $relationModel->setParent(clone $result); @@ -246,13 +256,14 @@ class HasOne extends OneToOne } /** - * 预载入关联查询(数据) - * @access protected - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -268,7 +279,8 @@ class HasOne extends OneToOne // 关联模型 if (!isset($data[$result->$localKey])) { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } else { $relationModel = $data[$result->$localKey]; $relationModel->setParent(clone $result); @@ -286,8 +298,8 @@ class HasOne extends OneToOne } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void diff --git a/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php b/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php index 2734c13..bc1986c 100644 --- a/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php +++ b/vendor/topthink/think-orm/src/model/relation/HasOneThrough.php @@ -1,8 +1,9 @@ getClosureType($closure)); + $closure($this->query); } $this->baseQuery(); @@ -40,20 +41,22 @@ class HasOneThrough extends HasManyThrough if ($relationModel) { $relationModel->setParent(clone $this->parent); } else { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } return $relationModel; } /** - * 预载入关联查询(数据集) - * @access protected - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -61,7 +64,7 @@ class HasOneThrough extends HasManyThrough $localKey = $this->localKey; $foreignKey = $this->foreignKey; - $range = []; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 if (isset($result->$localKey)) { @@ -71,6 +74,8 @@ class HasOneThrough extends HasManyThrough if (!empty($range)) { $this->query->removeWhereField($foreignKey); + $default = $this->query->getOptions('default_model'); + $defaultModel = $this->getDefaultModel($default); $data = $this->eagerlyWhere([ [$this->foreignKey, 'in', $range], @@ -80,7 +85,7 @@ class HasOneThrough extends HasManyThrough foreach ($resultSet as $result) { // 关联模型 if (!isset($data[$result->$localKey])) { - $relationModel = $this->getDefaultModel(); + $relationModel = $defaultModel; } else { $relationModel = $data[$result->$localKey]; $relationModel->setParent(clone $result); @@ -94,13 +99,14 @@ class HasOneThrough extends HasManyThrough } /** - * 预载入关联查询(数据) - * @access protected - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -116,7 +122,8 @@ class HasOneThrough extends HasManyThrough // 关联模型 if (!isset($data[$result->$localKey])) { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } else { $relationModel = $data[$result->$localKey]; $relationModel->setParent(clone $result); @@ -127,13 +134,14 @@ class HasOneThrough extends HasManyThrough } /** - * 关联模型预查询 - * @access public - * @param array $where 关联预查询条件 - * @param string $key 关联键名 - * @param array $subRelation 子关联 - * @param Closure $closure - * @param array $cache 关联缓存 + * 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyWhere(array $where, string $key, array $subRelation = [], Closure $closure = null, array $cache = []): array @@ -142,7 +150,7 @@ class HasOneThrough extends HasManyThrough $keys = $this->through->where($where)->column($this->throughPk, $this->foreignKey); if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $list = $this->query @@ -160,5 +168,4 @@ class HasOneThrough extends HasManyThrough return $data; } - } diff --git a/vendor/topthink/think-orm/src/model/relation/MorphMany.php b/vendor/topthink/think-orm/src/model/relation/MorphMany.php index ed0dd40..e3ba604 100644 --- a/vendor/topthink/think-orm/src/model/relation/MorphMany.php +++ b/vendor/topthink/think-orm/src/model/relation/MorphMany.php @@ -1,8 +1,9 @@ parent = $parent; - $this->model = $model; - $this->type = $type; - $this->morphKey = $morphKey; - $this->morphType = $morphType; - $this->query = (new $model)->db(); + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model())->db(); } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Collection */ public function getRelation(array $subRelation = [], Closure $closure = null): Collection { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $this->baseQuery(); @@ -82,13 +86,14 @@ class MorphMany extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null) @@ -97,12 +102,13 @@ class MorphMany extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null) @@ -111,21 +117,22 @@ class MorphMany extends Relation } /** - * 预载入关联查询 - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $morphType = $this->morphType; - $morphKey = $this->morphKey; - $type = $this->type; - $range = []; + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; foreach ($resultSet as $result) { $pk = $result->getPk(); @@ -154,13 +161,14 @@ class MorphMany extends Relation } /** - * 预载入关联查询 - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -168,8 +176,8 @@ class MorphMany extends Relation $pk = $result->getPk(); if (isset($result->$pk)) { - $key = $result->$pk; - $data = $this->eagerlyMorphToMany([ + $key = $result->$pk; + $data = $this->eagerlyMorphToMany([ [$this->morphKey, '=', $key], [$this->morphType, '=', $this->type], ], $subRelation, $closure, $cache); @@ -184,12 +192,13 @@ class MorphMany extends Relation /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return mixed */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) @@ -201,7 +210,7 @@ class MorphMany extends Relation } if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -213,18 +222,19 @@ class MorphMany extends Relation } /** - * 获取关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->query @@ -235,12 +245,13 @@ class MorphMany extends Relation } /** - * 多态一对多 关联模型预查询 - * @access protected - * @param array $where 关联预查询条件 - * @param array $subRelation 子关联 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 多态一对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyMorphToMany(array $where, array $subRelation = [], Closure $closure = null, array $cache = []): array @@ -250,7 +261,7 @@ class MorphMany extends Relation if ($closure) { $this->baseQuery = true; - $closure($this->getClosureType($closure)); + $closure($this->query); } $withLimit = $this->query->getOptions('limit'); @@ -266,7 +277,7 @@ class MorphMany extends Relation $morphKey = $this->morphKey; // 组装模型数据 - $data = []; + $data = []; foreach ($list as $set) { $key = $set->$morphKey; @@ -282,25 +293,24 @@ class MorphMany extends Relation /** * 保存(新增)当前关联数据对象 - * @access public - * @param mixed $data 数据 可以使用数组 关联模型对象 - * @param bool $replace 是否自动识别更新和写入 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * * @return Model|false */ - public function save($data, bool $replace = true) + public function save(array|Model $data, bool $replace = true) { - if ($data instanceof Model) { - $data = $data->getData(); - } - $model = $this->make(); return $model->replace($replace)->save($data) ? $model : false; } /** - * 创建关联对象实例 + * 创建关联对象实例. + * * @param array|Model $data + * * @return Model */ public function make($data = []): Model @@ -320,9 +330,10 @@ class MorphMany extends Relation /** * 批量保存当前关联数据对象 - * @access public - * @param iterable $dataSet 数据集 - * @param boolean $replace 是否自动识别更新和写入 + * + * @param iterable $dataSet 数据集 + * @param bool $replace 是否自动识别更新和写入 + * * @return array|false */ public function saveAll(iterable $dataSet, bool $replace = true) @@ -337,7 +348,8 @@ class MorphMany extends Relation } /** - * 获取多态关联外键 + * 获取多态关联外键. + * * @return string */ public function getMorphKey() @@ -346,7 +358,8 @@ class MorphMany extends Relation } /** - * 获取多态字段名 + * 获取多态字段名. + * * @return string */ public function getMorphType() @@ -355,7 +368,8 @@ class MorphMany extends Relation } /** - * 获取多态类型 + * 获取多态类型. + * * @return string */ public function getType() @@ -364,8 +378,8 @@ class MorphMany extends Relation } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void @@ -381,5 +395,4 @@ class MorphMany extends Relation $this->baseQuery = true; } } - } diff --git a/vendor/topthink/think-orm/src/model/relation/MorphOne.php b/vendor/topthink/think-orm/src/model/relation/MorphOne.php index d63966f..97bc954 100644 --- a/vendor/topthink/think-orm/src/model/relation/MorphOne.php +++ b/vendor/topthink/think-orm/src/model/relation/MorphOne.php @@ -1,8 +1,9 @@ parent = $parent; - $this->model = $model; - $this->type = $type; - $this->morphKey = $morphKey; - $this->morphType = $morphType; - $this->query = (new $model)->db(); + $this->parent = $parent; + $this->model = $model; + $this->type = $type; + $this->morphKey = $morphKey; + $this->morphType = $morphType; + $this->query = (new $model())->db(); } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包查询条件 + * * @return Model */ public function getRelation(array $subRelation = [], Closure $closure = null) { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $this->baseQuery(); @@ -90,20 +96,22 @@ class MorphOne extends Relation $relationModel->setParent(clone $this->parent); } else { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } return $relationModel; } /** - * 根据关联条件查询当前模型 - * @access public - * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param string $operator 比较操作符 + * @param int $count 个数 + * @param string $id 关联表的统计字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null) @@ -112,12 +120,13 @@ class MorphOne extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 - * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 + * @param string $joinType JOIN类型 + * @param Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null) @@ -126,21 +135,22 @@ class MorphOne extends Relation } /** - * 预载入关联查询 - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $morphType = $this->morphType; - $morphKey = $this->morphKey; - $type = $this->type; - $range = []; + $morphType = $this->morphType; + $morphKey = $this->morphKey; + $type = $this->type; + $range = []; foreach ($resultSet as $result) { $pk = $result->getPk(); @@ -156,10 +166,13 @@ class MorphOne extends Relation [$morphType, '=', $type], ], $subRelation, $closure, $cache); + $default = $this->query->getOptions('default_model'); + $defaultModel = $this->getDefaultModel($default); + // 关联数据封装 foreach ($resultSet as $result) { if (!isset($data[$result->$pk])) { - $relationModel = $this->getDefaultModel(); + $relationModel = $defaultModel; } else { $relationModel = $data[$result->$pk]; $relationModel->setParent(clone $result); @@ -178,13 +191,14 @@ class MorphOne extends Relation } /** - * 预载入关联查询 - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -192,7 +206,7 @@ class MorphOne extends Relation $pk = $result->getPk(); if (isset($result->$pk)) { - $pk = $result->$pk; + $pk = $result->$pk; $data = $this->eagerlyMorphToOne([ [$this->morphKey, '=', $pk], [$this->morphType, '=', $this->type], @@ -203,7 +217,8 @@ class MorphOne extends Relation $relationModel->setParent(clone $result); $relationModel->exists(true); } else { - $relationModel = $this->getDefaultModel(); + $default = $this->query->getOptions('default_model'); + $relationModel = $this->getDefaultModel($default); } if (!empty($this->bindAttr)) { @@ -217,12 +232,13 @@ class MorphOne extends Relation } /** - * 多态一对一 关联模型预查询 - * @access protected - * @param array $where 关联预查询条件 - * @param array $subRelation 子关联 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 多态一对一 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyMorphToOne(array $where, array $subRelation = [], $closure = null, array $cache = []): array @@ -230,7 +246,7 @@ class MorphOne extends Relation // 预载入关联查询 支持嵌套预载入 if ($closure) { $this->baseQuery = true; - $closure($this->getClosureType($closure)); + $closure($this->query); } $list = $this->query @@ -252,27 +268,27 @@ class MorphOne extends Relation /** * 保存(新增)当前关联数据对象 - * @access public - * @param mixed $data 数据 可以使用数组 关联模型对象 - * @param boolean $replace 是否自动识别更新和写入 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * * @return Model|false */ - public function save($data, bool $replace = true) + public function save(array|Model $data, bool $replace = true) { - if ($data instanceof Model) { - $data = $data->getData(); - } - $model = $this->make(); + return $model->replace($replace)->save($data) ? $model : false; } /** - * 创建关联对象实例 + * 创建关联对象实例. + * * @param array|Model $data + * * @return Model */ - public function make($data = []): Model + public function make(array|Model $data = []): Model { if ($data instanceof Model) { $data = $data->getData(); @@ -288,8 +304,8 @@ class MorphOne extends Relation } /** - * 执行基础查询(进执行一次) - * @access protected + * 执行基础查询(进执行一次). + * * @return void */ protected function baseQuery(): void @@ -306,9 +322,10 @@ class MorphOne extends Relation } /** - * 绑定关联表的属性到父模型属性 - * @access public - * @param array $attr 要绑定的属性列表 + * 绑定关联表的属性到父模型属性. + * + * @param array $attr 要绑定的属性列表 + * * @return $this */ public function bind(array $attr) @@ -319,8 +336,8 @@ class MorphOne extends Relation } /** - * 获取绑定属性 - * @access public + * 获取绑定属性. + * * @return array */ public function getBindAttr(): array @@ -329,24 +346,26 @@ class MorphOne extends Relation } /** - * 绑定关联属性到父模型 - * @access protected - * @param Model $result 父模型对象 - * @param Model $model 关联模型对象 - * @return void + * 绑定关联属性到父模型. + * + * @param Model $result 父模型对象 + * @param Model $model 关联模型对象 + * * @throws Exception + * + * @return void */ protected function bindAttr(Model $result, Model $model = null): void { foreach ($this->bindAttr as $key => $attr) { - $key = is_numeric($key) ? $attr : $key; + $key = is_numeric($key) ? $attr : $key; $value = $result->getOrigin($key); if (!is_null($value)) { throw new Exception('bind attr has exists:' . $key); } - $result->setAttr($key, $model ? $model->$attr : null); + $result->setAttr($key, $model?->$attr); } } } diff --git a/vendor/topthink/think-orm/src/model/relation/MorphTo.php b/vendor/topthink/think-orm/src/model/relation/MorphTo.php index d24c082..6e1e837 100644 --- a/vendor/topthink/think-orm/src/model/relation/MorphTo.php +++ b/vendor/topthink/think-orm/src/model/relation/MorphTo.php @@ -1,8 +1,9 @@ parent = $parent; - $this->morphType = $morphType; - $this->morphKey = $morphKey; - $this->alias = $alias; - $this->relation = $relation; + $this->parent = $parent; + $this->morphType = $morphType; + $this->morphKey = $morphKey; + $this->alias = $alias; + $this->relation = $relation; } /** - * 获取当前的关联模型类的实例 - * @access public + * 获取当前的关联模型类的实例. + * * @return Model */ public function getModel(): Model { $morphType = $this->morphType; - $model = $this->parseModel($this->parent->$morphType); + $model = $this->parseModel($this->parent->$morphType); - return (new $model); + return new $model(); } /** - * 延迟获取关联数据 - * @access public - * @param array $subRelation 子关联名 - * @param ?Closure $closure 闭包查询条件 + * 延迟获取关联数据. + * + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包查询条件 + * * @return Model */ public function getRelation(array $subRelation = [], Closure $closure = null) { - $morphKey = $this->morphKey; - $morphType = $this->morphType; + $morphKey = $this->morphKey; + $morphType = $this->morphType; // 多态模型 $model = $this->parseModel($this->parent->$morphType); @@ -98,7 +104,7 @@ class MorphTo extends Relation // 主键数据 $pk = $this->parent->$morphKey; - $relationModel = $this->buildQuery((new $model)->relation($subRelation))->find($pk); + $relationModel = class_exists($model) ? $this->buildQuery((new $model())->relation($subRelation))->find($pk) : null; if ($relationModel) { $relationModel->setParent(clone $this->parent); @@ -108,13 +114,14 @@ class MorphTo extends Relation } /** - * 根据关联条件查询当前模型 - * @access public + * 根据关联条件查询当前模型. + * * @param string $operator 比较操作符 - * @param integer $count 个数 - * @param string $id 关联表的统计字段 + * @param int $count 个数 + * @param string $id 关联表的统计字段 * @param string $joinType JOIN类型 - * @param Query $query Query对象 + * @param Query $query Query对象 + * * @return Query */ public function has(string $operator = '>=', int $count = 1, string $id = '*', string $joinType = '', Query $query = null) @@ -123,20 +130,19 @@ class MorphTo extends Relation } /** - * 根据关联条件查询当前模型 - * @access public - * @param mixed $where 查询条件(数组或者闭包) - * @param mixed $fields 字段 + * 根据关联条件查询当前模型. + * + * @param mixed $where 查询条件(数组或者闭包) + * @param mixed $fields 字段 * @param string $joinType JOIN类型 - * @param ?Query $query Query对象 + * @param ?Query $query Query对象 + * * @return Query */ public function hasWhere($where = [], $fields = null, string $joinType = '', Query $query = null) { $alias = class_basename($this->parent); - $types = $this->parent->distinct()->column($this->morphType); - $query = $query ?: $this->parent->db(); return $query->alias($alias) @@ -161,9 +167,10 @@ class MorphTo extends Relation } /** - * 解析模型的完整命名空间 - * @access protected + * 解析模型的完整命名空间. + * * @param string $model 模型名(或者完整类名) + * * @return Model */ protected function parseModel(string $model): string @@ -172,7 +179,7 @@ class MorphTo extends Relation $model = $this->alias[$model]; } - if (false === strpos($model, '\\')) { + if (!str_contains($model, '\\')) { $path = explode('\\', get_class($this->parent)); array_pop($path); array_push($path, Str::studly($model)); @@ -183,9 +190,10 @@ class MorphTo extends Relation } /** - * 设置多态别名 - * @access public + * 设置多态别名. + * * @param array $alias 别名定义 + * * @return $this */ public function setAlias(array $alias) @@ -196,8 +204,8 @@ class MorphTo extends Relation } /** - * 移除关联查询参数 - * @access public + * 移除关联查询参数. + * * @return $this */ public function removeOption(string $option = '') @@ -206,21 +214,23 @@ class MorphTo extends Relation } /** - * 预载入关联查询 - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param ?Closure $closure 闭包 - * @param array $cache 关联缓存 - * @return void + * 预载入关联查询. + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @throws Exception + * + * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $morphKey = $this->morphKey; - $morphType = $this->morphType; - $range = []; + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 @@ -230,15 +240,14 @@ class MorphTo extends Relation } if (!empty($range)) { - foreach ($range as $key => $val) { // 多态类型映射 $model = $this->parseModel($key); - $obj = new $model; - if (!\is_null($closure)) { + $obj = new $model(); + if (!is_null($closure)) { $obj = $closure($obj); } - $pk = $obj->getPk(); + $pk = $obj->getPk(); $list = $obj->with($subRelation) ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) ->select($val); @@ -267,13 +276,14 @@ class MorphTo extends Relation } /** - * 预载入关联查询 - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param ?Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询. + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param ?Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = []): void @@ -286,36 +296,37 @@ class MorphTo extends Relation /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param ?Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @return integer + * + * @param Model $result 数据对象 + * @param ?Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * + * @return int */ public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*') { } /** - * 多态MorphTo 关联模型预查询 - * @access protected - * @param string $model 关联模型对象 - * @param string $relation 关联名 - * @param Model $result - * @param array $subRelation 子关联 - * @param array $cache 关联缓存 + * 多态MorphTo 关联模型预查询. + * + * @param string $model 关联模型对象 + * @param string $relation 关联名 + * @param Model $result + * @param array $subRelation 子关联 + * @param array $cache 关联缓存 + * * @return void */ protected function eagerlyMorphToOne(string $model, string $relation, Model $result, array $subRelation = [], array $cache = []): void { // 预载入关联查询 支持嵌套预载入 - $pk = $this->parent->{$this->morphKey}; + $pk = $this->parent->{$this->morphKey}; + $data = null; - $data = null; - - if (\class_exists($model)) { - $data = (new $model)->with($subRelation) + if (class_exists($model)) { + $data = (new $model())->with($subRelation) ->cache($cache[0] ?? false, $cache[1] ?? null, $cache[2] ?? null) ->find($pk); @@ -329,17 +340,18 @@ class MorphTo extends Relation } /** - * 添加关联数据 - * @access public - * @param Model $model 关联模型对象 - * @param string $type 多态类型 + * 添加关联数据. + * + * @param Model $model 关联模型对象 + * @param string $type 多态类型 + * * @return Model */ public function associate(Model $model, string $type = ''): Model { - $morphKey = $this->morphKey; - $morphType = $this->morphType; - $pk = $model->getPk(); + $morphKey = $this->morphKey; + $morphType = $this->morphType; + $pk = $model->getPk(); $this->parent->setAttr($morphKey, $model->$pk); $this->parent->setAttr($morphType, $type ?: get_class($model)); @@ -349,14 +361,14 @@ class MorphTo extends Relation } /** - * 注销关联数据 - * @access public + * 注销关联数据. + * * @return Model */ public function dissociate(): Model { - $morphKey = $this->morphKey; - $morphType = $this->morphType; + $morphKey = $this->morphKey; + $morphType = $this->morphType; $this->parent->setAttr($morphKey, null); $this->parent->setAttr($morphType, null); @@ -377,6 +389,7 @@ class MorphTo extends Relation public function __call($method, $args) { $this->queryCaller[] = [$method, $args]; + return $this; } } diff --git a/vendor/topthink/think-orm/src/model/relation/MorphToMany.php b/vendor/topthink/think-orm/src/model/relation/MorphToMany.php index c9d8583..8fa5975 100644 --- a/vendor/topthink/think-orm/src/model/relation/MorphToMany.php +++ b/vendor/topthink/think-orm/src/model/relation/MorphToMany.php @@ -1,8 +1,9 @@ morphType = $morphType; - $this->inverse = $inverse; - $this->morphClass = $inverse ? $model : get_class($parent); + $this->morphType = $morphType; + $this->inverse = $inverse; + $this->morphClass = $inverse ? $model : get_class($parent); + if (isset(static::$morphMap[$this->morphClass])) { $this->morphClass = static::$morphMap[$this->morphClass]; } @@ -76,19 +80,20 @@ class MorphToMany extends BelongsToMany } /** - * 预载入关联查询(数据集) - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void { - $pk = $resultSet[0]->getPk(); - $range = []; + $pk = $resultSet[0]->getPk(); + $range = []; foreach ($resultSet as $result) { // 获取关联外键列表 @@ -116,13 +121,14 @@ class MorphToMany extends BelongsToMany } /** - * 预载入关联查询(单个数据) - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 预载入关联查询(单个数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation, Closure $closure = null, array $cache = []): void @@ -148,15 +154,16 @@ class MorphToMany extends BelongsToMany /** * 关联统计 - * @access public - * @param Model $result 数据对象 - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 - * @return integer + * + * @param Model $result 数据对象 + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * + * @return int */ - public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): float + public function relationCount(Model $result, Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null) { $pk = $result->getPk(); @@ -164,31 +171,30 @@ class MorphToMany extends BelongsToMany return 0; } - $pk = $result->$pk; - if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ - ['pivot.' . $this->localKey, '=', $pk], + ['pivot.' . $this->localKey, '=', $result->$pk], ['pivot.' . $this->morphType, '=', $this->morphClass], ])->$aggregate($field); } /** - * 获取关联统计子查询 - * @access public - * @param Closure $closure 闭包 - * @param string $aggregate 聚合查询方法 - * @param string $field 字段 - * @param string $name 统计字段别名 + * 获取关联统计子查询. + * + * @param Closure $closure 闭包 + * @param string $aggregate 聚合查询方法 + * @param string $field 字段 + * @param string $name 统计字段别名 + * * @return string */ public function getRelationCountQuery(Closure $closure = null, string $aggregate = 'count', string $field = '*', string &$name = null): string { if ($closure) { - $closure($this->getClosureType($closure), $name); + $closure($this->query, $name); } return $this->belongsToManyQuery($this->foreignKey, $this->localKey, [ @@ -198,25 +204,22 @@ class MorphToMany extends BelongsToMany } /** - * BELONGS TO MANY 关联查询 - * @access protected - * @param string $foreignKey 关联模型关联键 - * @param string $localKey 当前模型关联键 - * @param array $condition 关联查询条件 + * BELONGS TO MANY 关联查询. + * + * @param string $foreignKey 关联模型关联键 + * @param string $localKey 当前模型关联键 + * @param array $condition 关联查询条件 + * * @return Query */ protected function belongsToManyQuery(string $foreignKey, string $localKey, array $condition = []): Query { // 关联查询封装 - $tableName = $this->query->getTable(); - $table = $this->pivot->db()->getTable(); + $tableName = $this->query->getTable(); + $table = $this->pivot->db()->getTable(); + $fields = $this->getQueryFields($tableName); - if ($this->withoutField) { - $this->query->withoutField($this->withoutField); - } - - $fields = $this->getQueryFields($tableName); - $query = $this->query + $query = $this->query ->field($fields) ->tableField(true, $table, 'pivot', 'pivot__'); @@ -230,18 +233,19 @@ class MorphToMany extends BelongsToMany } /** - * 多对多 关联模型预查询 - * @access protected - * @param array $where 关联预查询条件 - * @param array $subRelation 子关联 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 + * 多对多 关联模型预查询. + * + * @param array $where 关联预查询条件 + * @param array $subRelation 子关联 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyManyToMany(array $where, array $subRelation = [], Closure $closure = null, array $cache = []): array { if ($closure) { - $closure($this->getClosureType($closure)); + $closure($this->query); } $withLimit = $this->query->getOptions('limit'); @@ -256,11 +260,11 @@ class MorphToMany extends BelongsToMany ->select(); // 组装模型数据 - $data = []; + $data = []; foreach ($list as $set) { $pivot = []; foreach ($set->getData() as $key => $val) { - if (strpos($key, '__')) { + if (str_contains($key, '__')) { [$name, $attr] = explode('__', $key, 2); if ('pivot' == $name) { $pivot[$attr] = $val; @@ -284,10 +288,11 @@ class MorphToMany extends BelongsToMany } /** - * 附加关联的一个中间表数据 - * @access public - * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 - * @param array $pivot 中间表额外数据 + * 附加关联的一个中间表数据. + * + * @param mixed $data 数据 可以使用数组、关联模型对象 或者 关联对象的主键 + * @param array $pivot 中间表额外数据 + * * @return array|Pivot */ public function attach($data, array $pivot = []) @@ -297,8 +302,8 @@ class MorphToMany extends BelongsToMany $id = $data; } else { // 保存关联表数据 - $model = new $this->model; - $id = $model->insertGetId($data); + $model = new $this->model(); + $id = $model->insertGetId($data); } } elseif (is_numeric($data) || is_string($data)) { // 根据关联表主键直接写入中间表 @@ -310,9 +315,9 @@ class MorphToMany extends BelongsToMany if (!empty($id)) { // 保存中间表数据 - $pivot[$this->localKey] = $this->parent->getKey(); + $pivot[$this->localKey] = $this->parent->getKey(); $pivot[$this->morphType] = $this->morphClass; - $ids = (array) $id; + $ids = (array) $id; $result = []; @@ -338,9 +343,10 @@ class MorphToMany extends BelongsToMany } /** - * 判断是否存在关联数据 - * @access public - * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * 判断是否存在关联数据. + * + * @param mixed $data 数据 可以使用关联模型对象 或者 关联对象的主键 + * * @return Pivot|false */ public function attached($data) @@ -361,11 +367,12 @@ class MorphToMany extends BelongsToMany } /** - * 解除关联的一个中间表数据 - * @access public - * @param integer|array $data 数据 可以使用关联对象的主键 - * @param bool $relationDel 是否同时删除关联表数据 - * @return integer + * 解除关联的一个中间表数据. + * + * @param int|array $data 数据 可以使用关联对象的主键 + * @param bool $relationDel 是否同时删除关联表数据 + * + * @return int */ public function detach($data = null, bool $relationDel = false): int { @@ -401,10 +408,11 @@ class MorphToMany extends BelongsToMany } /** - * 数据同步 - * @access public - * @param array $ids - * @param bool $detaching + * 数据同步. + * + * @param array $ids + * @param bool $detaching + * * @return array */ public function sync(array $ids, bool $detaching = true): array @@ -450,15 +458,15 @@ class MorphToMany extends BelongsToMany } /** - * 执行基础查询(仅执行一次) - * @access protected + * 执行基础查询(仅执行一次). + * * @return void */ protected function baseQuery(): void { if (empty($this->baseQuery)) { $foreignKey = $this->foreignKey; - $localKey = $this->localKey; + $localKey = $this->localKey; // 关联查询 $this->belongsToManyQuery($foreignKey, $localKey, [ @@ -471,20 +479,20 @@ class MorphToMany extends BelongsToMany } /** - * 设置或获取多态关系的模型名映射别名的数组 + * 设置或获取多态关系的模型名映射别名的数组. + * + * @param array|null $map + * @param bool $merge * - * @param array|null $map - * @param bool $merge * @return array */ public static function morphMap(array $map = null, $merge = true): array { if (is_array($map)) { static::$morphMap = $merge && static::$morphMap - ? $map + static::$morphMap : $map; + ? $map + static::$morphMap : $map; } return static::$morphMap; } - } diff --git a/vendor/topthink/think-orm/src/model/relation/OneToOne.php b/vendor/topthink/think-orm/src/model/relation/OneToOne.php index d62692a..c45489e 100644 --- a/vendor/topthink/think-orm/src/model/relation/OneToOne.php +++ b/vendor/topthink/think-orm/src/model/relation/OneToOne.php @@ -1,8 +1,9 @@ joinType = $type; + return $this; } /** - * 预载入关联查询(JOIN方式) - * @access public - * @param Query $query 查询对象 - * @param string $relation 关联名 - * @param mixed $field 关联字段 - * @param string $joinType JOIN方式 - * @param Closure $closure 闭包条件 - * @param bool $first + * 预载入关联查询(JOIN方式). + * + * @param Query $query 查询对象 + * @param string $relation 关联名 + * @param mixed $field 关联字段 + * @param string $joinType JOIN方式 + * @param Closure $closure 闭包条件 + * @param bool $first + * * @return void */ public function eagerly(Query $query, string $relation, $field = true, string $joinType = '', Closure $closure = null, bool $first = false): void @@ -84,26 +90,24 @@ abstract class OneToOne extends Relation } // 预载入封装 - $joinTable = $this->query->getTable(); - $joinAlias = $relation; - $joinType = $joinType ?: $this->joinType; + $joinTable = $this->query->getTable(); + $joinAlias = $relation; + $joinType = $joinType ?: $this->joinType; $query->via($joinAlias); if ($this instanceof BelongsTo) { - $foreignKeyExp = $this->foreignKey; - if (strpos($foreignKeyExp, '.') === false) { + if (!str_contains($foreignKeyExp, '.')) { $foreignKeyExp = $name . '.' . $this->foreignKey; } $joinOn = $foreignKeyExp . '=' . $joinAlias . '.' . $this->localKey; } else { - $foreignKeyExp = $this->foreignKey; - if (strpos($foreignKeyExp, '.') === false) { + if (!str_contains($foreignKeyExp, '.')) { $foreignKeyExp = $joinAlias . '.' . $this->foreignKey; } @@ -112,11 +116,12 @@ abstract class OneToOne extends Relation if ($closure) { // 执行闭包查询 - $closure($this->getClosureType($closure, $query)); + $closure($query); // 使用withField指定获取关联的字段 - if ($this->withField) { - $field = $this->withField; + $withField = $this->query->getOptions('field'); + if ($withField) { + $field = $withField; } } @@ -125,36 +130,39 @@ abstract class OneToOne extends Relation } /** - * 预载入关联查询(数据集) - * @access protected - * @param array $resultSet - * @param string $relation - * @param array $subRelation - * @param Closure $closure + * 预载入关联查询(数据集). + * + * @param array $resultSet + * @param string $relation + * @param array $subRelation + * @param Closure $closure + * * @return mixed */ abstract protected function eagerlySet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null); /** - * 预载入关联查询(数据) - * @access protected - * @param Model $result - * @param string $relation - * @param array $subRelation - * @param Closure $closure + * 预载入关联查询(数据). + * + * @param Model $result + * @param string $relation + * @param array $subRelation + * @param Closure $closure + * * @return mixed */ abstract protected function eagerlyOne(Model $result, string $relation, array $subRelation = [], Closure $closure = null); /** - * 预载入关联查询(数据集) - * @access public - * @param array $resultSet 数据集 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 - * @param bool $join 是否为JOIN方式 + * 预载入关联查询(数据集). + * + * @param array $resultSet 数据集 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $join 是否为JOIN方式 + * * @return void */ public function eagerlyResultSet(array &$resultSet, string $relation, array $subRelation = [], Closure $closure = null, array $cache = [], bool $join = false): void @@ -171,14 +179,15 @@ abstract class OneToOne extends Relation } /** - * 预载入关联查询(数据) - * @access public - * @param Model $result 数据对象 - * @param string $relation 当前关联名 - * @param array $subRelation 子关联名 - * @param Closure $closure 闭包 - * @param array $cache 关联缓存 - * @param bool $join 是否为JOIN方式 + * 预载入关联查询(数据). + * + * @param Model $result 数据对象 + * @param string $relation 当前关联名 + * @param array $subRelation 子关联名 + * @param Closure $closure 闭包 + * @param array $cache 关联缓存 + * @param bool $join 是否为JOIN方式 + * * @return void */ public function eagerlyResult(Model $result, string $relation, array $subRelation = [], Closure $closure = null, array $cache = [], bool $join = false): void @@ -194,28 +203,27 @@ abstract class OneToOne extends Relation /** * 保存(新增)当前关联数据对象 - * @access public - * @param mixed $data 数据 可以使用数组 关联模型对象 - * @param boolean $replace 是否自动识别更新和写入 + * + * @param array|Model $data 数据 可以使用数组 关联模型对象 + * @param bool $replace 是否自动识别更新和写入 + * * @return Model|false */ - public function save($data, bool $replace = true) + public function save(array|Model $data, bool $replace = true) { - if ($data instanceof Model) { - $data = $data->getData(); - } - $model = $this->make(); return $model->replace($replace)->save($data) ? $model : false; } /** - * 创建关联对象实例 + * 创建关联对象实例. + * * @param array|Model $data + * * @return Model */ - public function make($data = []): Model + public function make(array|Model $data = []): Model { if ($data instanceof Model) { $data = $data->getData(); @@ -228,9 +236,10 @@ abstract class OneToOne extends Relation } /** - * 绑定关联表的属性到父模型属性 - * @access public - * @param array $attr 要绑定的属性列表 + * 绑定关联表的属性到父模型属性. + * + * @param array $attr 要绑定的属性列表 + * * @return $this */ public function bind(array $attr) @@ -241,8 +250,8 @@ abstract class OneToOne extends Relation } /** - * 获取绑定属性 - * @access public + * 获取绑定属性. + * * @return array */ public function getBindAttr(): array @@ -251,18 +260,19 @@ abstract class OneToOne extends Relation } /** - * 一对一 关联模型预查询拼装 - * @access public - * @param string $model 模型名称 - * @param string $relation 关联名 - * @param Model $result 模型对象实例 + * 一对一 关联模型预查询拼装. + * + * @param string $model 模型名称 + * @param string $relation 关联名 + * @param Model $result 模型对象实例 + * * @return void */ protected function match(string $model, string $relation, Model $result): void { // 重新组装模型数据 foreach ($result->getData() as $key => $val) { - if (strpos($key, '__')) { + if (str_contains($key, '__')) { [$name, $attr] = explode('__', $key, 2); if ($name == $relation) { $list[$name][$attr] = $val; @@ -293,35 +303,38 @@ abstract class OneToOne extends Relation } /** - * 绑定关联属性到父模型 - * @access protected - * @param Model $result 父模型对象 - * @param Model $model 关联模型对象 - * @return void + * 绑定关联属性到父模型. + * + * @param Model $result 父模型对象 + * @param Model $model 关联模型对象 + * * @throws Exception + * + * @return void */ protected function bindAttr(Model $result, Model $model = null): void { foreach ($this->bindAttr as $key => $attr) { - $key = is_numeric($key) ? $attr : $key; - $value = $result->getOrigin($key); + $key = is_numeric($key) ? $attr : $key; + $value = $result->getOrigin($key); if (!is_null($value)) { throw new Exception('bind attr has exists:' . $key); } - $result->setAttr($key, $model ? $model->$attr : null); + $result->setAttr($key, $model?->$attr); } } /** - * 一对一 关联模型预查询(IN方式) - * @access public - * @param array $where 关联预查询条件 - * @param string $key 关联键名 - * @param array $subRelation 子关联 - * @param Closure $closure - * @param array $cache 关联缓存 + * 一对一 关联模型预查询(IN方式). + * + * @param array $where 关联预查询条件 + * @param string $key 关联键名 + * @param array $subRelation 子关联 + * @param Closure $closure + * @param array $cache 关联缓存 + * * @return array */ protected function eagerlyWhere(array $where, string $key, array $subRelation = [], Closure $closure = null, array $cache = []) @@ -329,13 +342,7 @@ abstract class OneToOne extends Relation // 预载入关联查询 支持嵌套预载入 if ($closure) { $this->baseQuery = true; - $closure($this->getClosureType($closure)); - } - - if ($this->withField) { - $this->query->field($this->withField); - } elseif ($this->withoutField) { - $this->query->withoutField($this->withoutField); + $closure($this->query); } $list = $this->query @@ -355,5 +362,4 @@ abstract class OneToOne extends Relation return $data; } - } diff --git a/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php b/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php index 6d55c39..dec1275 100644 --- a/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php +++ b/vendor/topthink/think-orm/src/paginator/driver/Bootstrap.php @@ -1,8 +1,9 @@ currentPage() <= 1) { return $this->getDisabledTextWrapper($text); } @@ -39,8 +40,10 @@ class Bootstrap extends Paginator } /** - * 下一页按钮 + * 下一页按钮. + * * @param string $text + * * @return string */ protected function getNextButton(string $text = '»'): string @@ -55,7 +58,8 @@ class Bootstrap extends Paginator } /** - * 页码按钮 + * 页码按钮. + * * @return string */ protected function getLinks(): string @@ -70,21 +74,21 @@ class Bootstrap extends Paginator 'last' => null, ]; - $side = 3; + $side = 3; $window = $side * 2; if ($this->lastPage < $window + 6) { $block['first'] = $this->getUrlRange(1, $this->lastPage); } elseif ($this->currentPage <= $window) { $block['first'] = $this->getUrlRange(1, $window + 2); - $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); } elseif ($this->currentPage > ($this->lastPage - $window)) { $block['first'] = $this->getUrlRange(1, 2); - $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage); + $block['last'] = $this->getUrlRange($this->lastPage - ($window + 2), $this->lastPage); } else { - $block['first'] = $this->getUrlRange(1, 2); + $block['first'] = $this->getUrlRange(1, 2); $block['slider'] = $this->getUrlRange($this->currentPage - $side, $this->currentPage + $side); - $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); + $block['last'] = $this->getUrlRange($this->lastPage - 1, $this->lastPage); } $html = ''; @@ -107,7 +111,8 @@ class Bootstrap extends Paginator } /** - * 渲染分页html + * 渲染分页html. + * * @return mixed */ public function render() @@ -131,10 +136,11 @@ class Bootstrap extends Paginator } /** - * 生成一个可点击的按钮 + * 生成一个可点击的按钮. + * + * @param string $url + * @param string $page * - * @param string $url - * @param string $page * @return string */ protected function getAvailablePageWrapper(string $url, string $page): string @@ -143,9 +149,10 @@ class Bootstrap extends Paginator } /** - * 生成一个禁用的按钮 + * 生成一个禁用的按钮. + * + * @param string $text * - * @param string $text * @return string */ protected function getDisabledTextWrapper(string $text): string @@ -154,9 +161,10 @@ class Bootstrap extends Paginator } /** - * 生成一个激活的按钮 + * 生成一个激活的按钮. + * + * @param string $text * - * @param string $text * @return string */ protected function getActivePageWrapper(string $text): string @@ -165,7 +173,7 @@ class Bootstrap extends Paginator } /** - * 生成省略号按钮 + * 生成省略号按钮. * * @return string */ @@ -177,7 +185,8 @@ class Bootstrap extends Paginator /** * 批量生成页码按钮. * - * @param array $urls + * @param array $urls + * * @return string */ protected function getUrlLinks(array $urls): string @@ -192,10 +201,11 @@ class Bootstrap extends Paginator } /** - * 生成普通页码按钮 + * 生成普通页码按钮. + * + * @param string $url + * @param string $page * - * @param string $url - * @param string $page * @return string */ protected function getPageLinkWrapper(string $url, string $page): string diff --git a/vendor/topthink/think-orm/stubs/Exception.php b/vendor/topthink/think-orm/stubs/Exception.php index 0fdba9c..0597f8b 100644 --- a/vendor/topthink/think-orm/stubs/Exception.php +++ b/vendor/topthink/think-orm/stubs/Exception.php @@ -1,4 +1,5 @@ // +---------------------------------------------------------------------- -declare (strict_types=1); +declare(strict_types=1); namespace think; /** - * 异常基础类 - * @package think + * 异常基础类. */ class Exception extends \Exception { /** - * 保存异常页面显示的额外Debug数据 + * 保存异常页面显示的额外Debug数据. + * * @var array */ protected $data = []; /** * 设置异常额外的Debug数据 - * 数据将会显示为下面的格式 + * 数据将会显示为下面的格式. * * Exception Data * -------------------------------------------------- @@ -37,7 +38,6 @@ class Exception extends \Exception * key1 value1 * key2 value2 * - * @access protected * @param string $label 数据分类,用于异常页面显示 * @param array $data 需要显示的数据,必须为关联数组 */ @@ -48,8 +48,8 @@ class Exception extends \Exception /** * 获取异常额外Debug数据 - * 主要用于输出到异常页面便于调试 - * @access public + * 主要用于输出到异常页面便于调试. + * * @return array 由setData设置的Debug数据 */ final public function getData() diff --git a/vendor/topthink/think-orm/stubs/Facade.php b/vendor/topthink/think-orm/stubs/Facade.php index d801d8b..c87ec92 100644 --- a/vendor/topthink/think-orm/stubs/Facade.php +++ b/vendor/topthink/think-orm/stubs/Facade.php @@ -1,4 +1,5 @@ =7.1.0", - "psr/simple-cache": "^1.0" + "php": ">=8.0.0", + "psr/simple-cache": ">=1.0" }, "autoload": { "psr-4": { "think\\": "src" } } -} \ No newline at end of file +} diff --git a/vendor/topthink/think-template/phpunit.xml b/vendor/topthink/think-template/phpunit.xml new file mode 100644 index 0000000..504cc73 --- /dev/null +++ b/vendor/topthink/think-template/phpunit.xml @@ -0,0 +1,12 @@ + + + + tests/think + + + \ No newline at end of file diff --git a/vendor/topthink/think-template/src/Template.php b/vendor/topthink/think-template/src/Template.php index befa114..38e68c7 100644 --- a/vendor/topthink/think-template/src/Template.php +++ b/vendor/topthink/think-template/src/Template.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -14,6 +14,7 @@ namespace think; use Exception; use Psr\SimpleCache\CacheInterface; +use think\template\contract\DriverInterface; /** * ThinkPHP分离出来的模板引擎 @@ -26,13 +27,13 @@ class Template * 模板变量 * @var array */ - protected $data = []; + protected array $data = []; /** * 模板配置参数 * @var array */ - protected $config = [ + protected array $config = [ 'view_path' => '', // 模板路径 'view_suffix' => 'html', // 默认模板文件后缀 'view_depr' => DIRECTORY_SEPARATOR, @@ -66,31 +67,31 @@ class Template * 保留内容信息 * @var array */ - private $literal = []; + private array $literal = []; /** * 扩展解析规则 * @var array */ - private $extend = []; + private array $extend = []; /** * 模板包含信息 * @var array */ - private $includeFile = []; + private array $includeFile = []; /** * 模板存储对象 - * @var object + * @var DriverInterface */ - protected $storage; + protected DriverInterface $storage; /** * 查询缓存对象 - * @var CacheInterface + * @var CacheInterface|null */ - protected $cache; + protected ?CacheInterface $cache; /** * 架构函数 @@ -110,8 +111,8 @@ class Template $this->config['tpl_end'] = preg_quote($this->config['tpl_end'], '/'); // 初始化模板编译存储器 - $type = $this->config['compile_type'] ? $this->config['compile_type'] : 'File'; - $class = false !== strpos($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type); + $type = $this->config['compile_type'] ?: 'File'; + $class = str_contains($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type); $this->storage = new $class(); } @@ -122,7 +123,7 @@ class Template * @param array $vars 模板变量 * @return $this */ - public function assign(array $vars = []) + public function assign(array $vars = []): static { $this->data = array_merge($this->data, $vars); return $this; @@ -131,10 +132,10 @@ class Template /** * 模板引擎参数赋值 * @access public - * @param string $name - * @param mixed $value + * @param string $name + * @param mixed $value */ - public function __set($name, $value) + public function __set(string $name, $value) { $this->config[$name] = $value; } @@ -156,7 +157,7 @@ class Template * @param array $config * @return $this */ - public function config(array $config) + public function config(array $config): static { $this->config = array_merge($this->config, $config); return $this; @@ -202,8 +203,8 @@ class Template /** * 扩展模板解析规则 * @access public - * @param string $rule 解析规则 - * @param callable $callback 解析规则 + * @param string $rule 解析规则 + * @param callable|null $callback 解析规则回调 * @return void */ public function extend(string $rule, callable $callback = null): void @@ -224,12 +225,10 @@ class Template $this->data = array_merge($this->data, $vars); } - if (!empty($this->config['cache_id']) && $this->config['display_cache'] && $this->cache) { + if ($this->isCache($this->config['cache_id'])) { // 读取渲染缓存 - if ($this->cache->has($this->config['cache_id'])) { - echo $this->cache->get($this->config['cache_id']); - return; - } + echo $this->cache->get($this->config['cache_id']); + return; } $template = $this->parseTemplateFile($template); @@ -245,11 +244,7 @@ class Template // 页面缓存 ob_start(); - if (version_compare(PHP_VERSION, '8.0', '>=')) { - ob_implicit_flush(false); - } else { - ob_implicit_flush(0); - } + ob_implicit_flush(false); // 读取编译存储 $this->storage->read($cacheFile, $this->data); @@ -257,7 +252,7 @@ class Template // 获取并清空缓存 $content = ob_get_clean(); - if (!empty($this->config['cache_id']) && $this->config['display_cache'] && $this->cache) { + if (!empty($this->config['cache_id']) && $this->config['display_cache'] && null !== $this->cache) { // 缓存页面输出 $this->cache->set($this->config['cache_id'], $content, $this->config['cache_time']); } @@ -274,7 +269,7 @@ class Template */ public function isCache(string $cacheId): bool { - if ($cacheId && $this->cache && $this->config['display_cache']) { + if ($cacheId && null !== $this->cache && $this->config['display_cache']) { // 缓存页面输出 return $this->cache->has($cacheId); } @@ -309,11 +304,11 @@ class Template /** * 设置布局 * @access public - * @param mixed $name 布局模板名称 false 则关闭布局 - * @param string $replace 布局模板内容替换标识 + * @param bool|string $name 布局模板名称 false 则关闭布局 + * @param string $replace 布局模板内容替换标识 * @return $this */ - public function layout($name, string $replace = '') + public function layout(bool|string $name, string $replace = ''): static { if (false === $name) { // 关闭布局 @@ -336,8 +331,7 @@ class Template } /** - * 检查编译缓存是否有效 - * 如果无效则需要重新编译 + * 检查编译缓存是否有效,如果无效则需要重新编译 * @access private * @param string $cacheFile 缓存文件名 * @return bool @@ -390,7 +384,7 @@ class Template { // 判断是否启用布局 if ($this->config['layout_on']) { - if (false !== strpos($content, '{__NOLAYOUT__}')) { + if (str_contains($content, '{__NOLAYOUT__}')) { // 可以单独定义不使用布局 $content = str_replace('{__NOLAYOUT__}', '', $content); } else { @@ -571,7 +565,7 @@ class Template foreach ($array as $k => $v) { // 以$开头字符串转换成模板变量 - if (0 === strpos($v, '$')) { + if (str_starts_with($v, '$')) { $v = $this->get(substr($v, 1)); } @@ -766,13 +760,12 @@ class Template } /** - * 搜索模板页面中包含的TagLib库 - * 并返回列表 + * 搜索模板页面中包含的 TagLib 库,并返回列表 * @access private * @param string $content 模板内容 - * @return array|null + * @return array */ - private function getIncludeTagLib(string &$content) + private function getIncludeTagLib(string &$content): array { // 搜索是否有TagLib标签 if (preg_match($this->getRegex('taglib'), $content, $matches)) { @@ -781,6 +774,8 @@ class Template return explode(',', $matches['name']); } + + return []; } /** @@ -793,7 +788,7 @@ class Template */ public function parseTagLib(string $tagLib, string &$content, bool $hide = false): void { - if (false !== strpos($tagLib, '\\')) { + if (str_contains($tagLib, '\\')) { // 支持指定标签库的命名空间 $className = $tagLib; $tagLib = substr($tagLib, strrpos($tagLib, '\\') + 1); @@ -809,8 +804,8 @@ class Template /** * 分析标签属性 * @access public - * @param string $str 属性字符串 - * @param string $name 不为空时返回指定的属性名 + * @param string $str 属性字符串 + * @param string|null $name 不为空时返回指定的属性名 * @return array */ public function parseAttr(string $str, string $name = null): array @@ -883,7 +878,6 @@ class Template } } else { if (isset($array[1])) { - $express = true; $this->parseVar($array[2]); $express = $name . $array[1] . $array[2]; } else { @@ -892,7 +886,7 @@ class Template if (in_array($first, ['?', '=', ':'])) { $str = trim(substr($str, 1)); - if ('$' == substr($str, 0, 1)) { + if (str_starts_with($str, '$')) { $str = $this->parseVarFunction($str); } } @@ -916,8 +910,8 @@ class Template // {$varname ? 'a' : 'b'} $varname为真时输出a,否则输出b $array = explode(':', $str, 2); - $array[0] = '$' == substr(trim($array[0]), 0, 1) ? $this->parseVarFunction($array[0]) : $array[0]; - $array[1] = '$' == substr(trim($array[1]), 0, 1) ? $this->parseVarFunction($array[1]) : $array[1]; + $array[0] = str_starts_with(trim($array[0]), '$') ? $this->parseVarFunction($array[0]) : $array[0]; + $array[1] = str_starts_with(trim($array[1]), '$') ? $this->parseVarFunction($array[1]) : $array[1]; $str = implode(' : ', $array); } @@ -951,7 +945,7 @@ class Template case '/': // 注释标签 $flag2 = substr($str, 1, 1); - if ('/' == $flag2 || ('*' == $flag2 && substr(rtrim($str), -2) == '*/')) { + if ('/' == $flag2 || ('*' == $flag2 && str_ends_with(rtrim($str), '*/'))) { $str = ''; } break; @@ -979,7 +973,7 @@ class Template { $varStr = trim($varStr); - if (preg_match_all('/\$[a-zA-Z_](?>\w*)(?:[:\.][0-9a-zA-Z_](?>\w*))+/', $varStr, $matches, PREG_OFFSET_CAPTURE)) { + if (preg_match_all('/\$[a-zA-Z_](?>\w*)(?:[:.][0-9a-zA-Z_](?>\w*))+/', $varStr, $matches, PREG_OFFSET_CAPTURE)) { static $_varParseList = []; while ($matches[0]) { @@ -1037,7 +1031,7 @@ class Template */ public function parseVarFunction(string &$varStr, bool $autoescape = true): string { - if (!$autoescape && false === strpos($varStr, '|')) { + if (!$autoescape && !str_contains($varStr, '|')) { return $varStr; } elseif ($autoescape && !preg_match('/\|(\s)?raw(\||\s)?/i', $varStr)) { $varStr .= '|' . $this->config['default_filter']; @@ -1093,7 +1087,7 @@ class Template $name = 'sprintf(' . $args[1] . ',' . $name . ')'; break; case 'default': // 特殊模板函数 - if (false === strpos($name, '(')) { + if (!str_contains($name, '(')) { $name = '(isset(' . $name . ') && (' . $name . ' !== \'\')?' . $name . ':' . $args[1] . ')'; } else { $name = '(' . $name . ' ?: ' . $args[1] . ')'; @@ -1101,7 +1095,7 @@ class Template break; default: // 通用模板函数 if (isset($args[1])) { - if (strstr($args[1], '###')) { + if (str_contains($args[1], '###')) { $args[1] = str_replace('###', $name, $args[1]); $name = "$fun($args[1])"; } else { @@ -1174,24 +1168,13 @@ class Template $type = strtoupper(trim(array_shift($vars))); $param = implode('.', $vars); - switch ($type) { - case 'CONST': - $parseStr = strtoupper($param); - break; - case 'NOW': - $parseStr = "date('Y-m-d g:i a',time())"; - break; - case 'LDELIM': - $parseStr = '\'' . ltrim($this->config['tpl_begin'], '\\') . '\''; - break; - case 'RDELIM': - $parseStr = '\'' . ltrim($this->config['tpl_end'], '\\') . '\''; - break; - default: - $parseStr = defined($type) ? $type : '\'\''; - } - - return $parseStr; + return match ($type) { + 'CONST' => strtoupper($param), + 'NOW' => "date('Y-m-d g:i a',time())", + 'LDELIM' => '\'' . ltrim($this->config['tpl_begin'], '\\') . '\'', + 'RDELIM' => '\'' . ltrim($this->config['tpl_end'], '\\') . '\'', + default => defined($type) ? $type : '\'\'', + }; } /** @@ -1210,7 +1193,7 @@ class Template continue; } - if (0 === strpos($templateName, '$')) { + if (str_starts_with($templateName, '$')) { //支持加载变量文件名 $templateName = $this->get(substr($templateName, 1)); } @@ -1236,7 +1219,7 @@ class Template { if ('' == pathinfo($template, PATHINFO_EXTENSION)) { - if (0 !== strpos($template, '/')) { + if (!str_starts_with($template, '/')) { $template = str_replace(['/', ':'], $this->config['view_depr'], $template); } else { $template = str_replace(['/', ':'], $this->config['view_depr'], substr($template, 1)); @@ -1276,7 +1259,7 @@ class Template } else { $begin = $this->config['taglib_begin']; $end = $this->config['taglib_end']; - $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1 ? true : false; + $single = strlen(ltrim($begin, '\\')) == 1 && strlen(ltrim($end, '\\')) == 1; switch ($tagName) { case 'block': diff --git a/vendor/topthink/think-template/src/facade/Template.php b/vendor/topthink/think-template/src/facade/Template.php index 665a180..69cf492 100644 --- a/vendor/topthink/think-template/src/facade/Template.php +++ b/vendor/topthink/think-template/src/facade/Template.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- diff --git a/vendor/topthink/think-template/src/template/TagLib.php b/vendor/topthink/think-template/src/template/TagLib.php index f6c8fbb..4203b77 100644 --- a/vendor/topthink/think-template/src/template/TagLib.php +++ b/vendor/topthink/think-template/src/template/TagLib.php @@ -2,7 +2,7 @@ // +---------------------------------------------------------------------- // | ThinkPHP [ WE CAN DO IT JUST THINK ] // +---------------------------------------------------------------------- -// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved. +// | Copyright (c) 2006~2023 http://thinkphp.cn All rights reserved. // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- @@ -59,23 +59,15 @@ class TagLib */ protected $valid = false; - /** - * 当前模板对象 - * @var object - * @access protected - */ - protected $tpl; - protected $comparison = [' nheq ' => ' !== ', ' heq ' => ' === ', ' neq ' => ' != ', ' eq ' => ' == ', ' egt ' => ' >= ', ' gt ' => ' > ', ' elt ' => ' <= ', ' lt ' => ' < ']; /** * 架构函数 * @access public - * @param Template $template 模板引擎对象 + * @param Template $tpl 模板引擎对象 */ - public function __construct(Template $template) + public function __construct(protected Template $tpl) { - $this->tpl = $template; } /** diff --git a/vendor/topthink/think-template/src/template/contract/DriverInterface.php b/vendor/topthink/think-template/src/template/contract/DriverInterface.php new file mode 100644 index 0000000..e1c52da --- /dev/null +++ b/vendor/topthink/think-template/src/template/contract/DriverInterface.php @@ -0,0 +1,35 @@ + ['attr' => 'time,format', 'close' => 0], //闭合标签,默认为不闭合 + 'open' => ['attr' => 'name,type', 'close' => 1], + + ]; + + /** + * 这是一个闭合标签的简单演示 + */ + public function tagClose($tag) + { + $format = empty($tag['format']) ? 'Y-m-d H:i:s' : $tag['format']; + $time = empty($tag['time']) ? time() : $tag['time']; + $parse = ''; + return $parse; + } + + /** + * 这是一个非闭合标签的简单演示 + */ + public function tagOpen($tag, $content) + { + $type = empty($tag['type']) ? 0 : 1; // 这个type目的是为了区分类型,一般来源是数据库 + $name = $tag['name']; // name是必填项,这里不做判断了 + $parse = ''; + $parse .= '{volist name="__LIST__" id="' . $name . '"}'; + $parse .= $content; + $parse .= '{/volist}'; + return $parse; + } + +} \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/extend.html b/vendor/topthink/think-template/tests/template/extend.html new file mode 100644 index 0000000..6a2578f --- /dev/null +++ b/vendor/topthink/think-template/tests/template/extend.html @@ -0,0 +1,2 @@ +{block name="title"}标题{/block} +{block name="main"}主内容{/block} diff --git a/vendor/topthink/think-template/tests/template/fetch.html b/vendor/topthink/think-template/tests/template/fetch.html new file mode 100644 index 0000000..0f0c913 --- /dev/null +++ b/vendor/topthink/think-template/tests/template/fetch.html @@ -0,0 +1 @@ +success \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/include.html b/vendor/topthink/think-template/tests/template/include.html new file mode 100644 index 0000000..2996fba --- /dev/null +++ b/vendor/topthink/think-template/tests/template/include.html @@ -0,0 +1 @@ +include \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/template/layout.html b/vendor/topthink/think-template/tests/template/layout.html new file mode 100644 index 0000000..fb432d7 --- /dev/null +++ b/vendor/topthink/think-template/tests/template/layout.html @@ -0,0 +1 @@ +start{__CONTENT__}end \ No newline at end of file diff --git a/vendor/topthink/think-template/tests/think/TemplateTest.php b/vendor/topthink/think-template/tests/think/TemplateTest.php new file mode 100644 index 0000000..2f58e2a --- /dev/null +++ b/vendor/topthink/think-template/tests/think/TemplateTest.php @@ -0,0 +1,247 @@ + __DIR__ . '/../template' . DIRECTORY_SEPARATOR, + 'cache_path' => __DIR__ . '/../cache' . DIRECTORY_SEPARATOR, + 'tpl_cache' => false, + 'tpl_replace_string' => ['__STATIC__' => '/static'], + 'taglib_pre_load' => Demo::class, + ]; + return new Template($config); + } + + // 直接渲染 + public function testDisplay() + { + $this->expectOutputString('hello-thinkphp'); + + $template = $this->getTemplate(); + $content = '{$name}-{$email}'; + $template->display($content, ['name' => 'hello', 'email' => 'thinkphp']); + } + + // 渲染文件 + public function testFetch() + { + $this->expectOutputString('success'); + + $template = $this->getTemplate(); + $template->fetch('fetch'); + } + + // 布局 + public function testLayout() + { + $this->expectOutputString('startsuccessend'); + + $template = $this->getTemplate(); + $template->layout('layout'); + $template->fetch('fetch'); + $template->layout(false); + } + + // 扩展解析 + public function testExtend() + { + $this->expectOutputString('test.name'); + + $template = $this->getTemplate(); + $template->extend('$Cms', function (array $vars) { + return '\'' . implode('.', $vars) . '\''; + }); + + $content = '{$Cms.test.name}'; + $template->display($content); + } + + // 变量 + public function testParseVar() + { + $this->expectOutputString('e10adc3949ba59abbe56e057f20f883e'); + + $template = $this->getTemplate(); + $content = '{:md5("123456")}'; + $template->display($content, ['password' => '123456']); + } + + // 变量使用函数 + public function testParseVarFunction() + { + $this->expectOutputString('e10adc3949ba59abbe56e057f20f883e-123456-666456'); + + $template = $this->getTemplate(); + $content = '{$password|md5}-{$password|raw}-{$password|str_replace=123,666,###}'; + $template->display($content, ['password' => '123456']); + } + + // 默认值 + public function testParseDefaultFunction() + { + $this->expectOutputString('test'); + + $template = $this->getTemplate(); + $content = '{$default|default="test"}'; + $template->display($content); + } + + // 系统变量 + public function testParseThinkVar() + { + $this->expectOutputString($_SERVER['PHP_SELF'] . '-' . PHP_VERSION . '-' . PHP_VERSION); + + $template = $this->getTemplate(); + $content = '{$Request.server.PHP_SELF}-{$Think.const.PHP_VERSION}-{$Think.PHP_VERSION}'; + $template->display($content); + } + + // 数组 + public function testParseArrayVar() + { + $this->expectOutputString('thinkphp
    thinkphp'); + + $template = $this->getTemplate(); + $content = '{$data.name}
    {$data["name"]}'; + $template->display($content, ['data' => ['name' => 'thinkphp']]); + } + + // 对象 + public function testParseObjectVar() + { + $this->expectOutputString('a-b-c-d'); + + $object = new class { + public string $a = 'a'; + public const b = 'b'; + + public function c($str) { + return $str; + } + + static public function d($str) { + return $str; + } + }; + + $template = $this->getTemplate(); + $content = '{$data->a}-{$data::b}-{$data->c("c")}-{$data::d("d")}'; + $template->display($content, ['data' => $object]); + } + + // 运算符 + public function testParseVarOperator() + { + $this->expectOutputString('2-0-2-0.5-1-1-1-4'); + + $template = $this->getTemplate(); + $content = '{$a+1}-{$a-1}-{$a*$b}-{$a/$b}-{$a%$b}-{$a++}-{--$b}-{$a+$b+abs(-1)}'; + $template->display($content, ['a' => 1, 'b' => 2]); + } + + // 三元运算符 + public function testParseTernaryOperator() + { + $this->expectOutputString('真-默认值-有值-NO'); + + $template = $this->getTemplate(); + $content = '{$true?"真":"假"}-{$null ?? "默认值"}-{$one ?= "有值"}-{$zero ?: "NO"}'; + $template->display($content, ['null' => null, 'zero' => 0, 'true' => true, 'one' => 1]); + } + + // 单行注释 + public function testParseSimpleNote() + { + $this->expectOutputString('123'); + + $template = $this->getTemplate(); + $content = '123{// 注释内容 }'; + $template->display($content); + } + + // 多行注释 + public function testParseMoreNote() + { + $this->expectOutputString('123'); + + $template = $this->getTemplate(); + $content = "123{/* 这是模板\r\n注释内容*/ }"; + $template->display($content); + } + + // 引用标签 + public function testParseInclude() + { + $this->expectOutputString('include'); + + $template = $this->getTemplate(); + $content = '{include file="include"}'; + $template->display($content); + } + + // 继承标签 + public function testParseExtend() + { + $this->expectOutputString("title\r\n主内容main\r\n"); + + $template = $this->getTemplate(); + $content = "{extend name='extend' /}\r\n{block name='title'}title{/block}\r\n{block name='main'}{__block__}main{/block}"; + $template->display($content); + } + + // 输出替换 + public function testParseReplaceString() + { + $this->expectOutputString("start/staticend"); + + $template = $this->getTemplate(); + $content = "start__STATIC__end"; + $template->display($content); + } + + // 标签扩展 + public function testParseDemoTag() + { + $this->expectOutputString(<<<'HTML' +

    闭合标签

    +2022-12-31 16:00:00
    +

    开放标签

    + 0=>1
    + 1=>3
    + 2=>5
    + 3=>7
    + 4=>9
    +
    + 0=>2
    + 1=>4
    + 2=>6
    + 3=>8
    + 4=>10
    + +HTML); + + $template = $this->getTemplate(); + $content = <<<'HTML' +

    闭合标签

    +{demo:close time='$demo_time'/} +
    +

    开放标签

    +{demo:open name='demo_name'} + {$key}=>{$demo_name}
    +{/demo:open} +
    +{demo:open name='demo_name' type='1'} + {$key}=>{$demo_name}
    +{/demo:open} +HTML; + + $template->display($content, ['demo_time' => 1672502400]); + } +} diff --git a/vendor/topthink/think-trace/.gitignore b/vendor/topthink/think-trace/.gitignore deleted file mode 100644 index 485dee6..0000000 --- a/vendor/topthink/think-trace/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/vendor/topthink/think-trace/LICENSE b/vendor/topthink/think-trace/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/vendor/topthink/think-trace/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/topthink/think-trace/README.md b/vendor/topthink/think-trace/README.md deleted file mode 100644 index 6ed63ec..0000000 --- a/vendor/topthink/think-trace/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# think-trace - -用于ThinkPHP6+的页面Trace扩展,支持Html页面和浏览器控制台两种方式输出。 - -## 安装 - -~~~ -composer require topthink/think-trace -~~~ - -## 配置 - -安装后config目录下会自带trace.php配置文件。 - -type参数用于指定trace类型,支持html和console两种方式。 \ No newline at end of file diff --git a/vendor/topthink/think-trace/composer.json b/vendor/topthink/think-trace/composer.json deleted file mode 100644 index e6cd16b..0000000 --- a/vendor/topthink/think-trace/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "topthink/think-trace", - "description": "thinkphp debug trace", - "license": "Apache-2.0", - "authors": [ - { - "name": "liu21st", - "email": "liu21st@gmail.com" - } - ], - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0|^8.0" - }, - "autoload": { - "psr-4": { - "think\\trace\\": "src" - } - }, - "extra": { - "think":{ - "services":[ - "think\\trace\\Service" - ], - "config":{ - "trace": "src/config.php" - } - } - }, - "minimum-stability": "dev" -} diff --git a/vendor/topthink/think-trace/src/Console.php b/vendor/topthink/think-trace/src/Console.php deleted file mode 100644 index c97d1e0..0000000 --- a/vendor/topthink/think-trace/src/Console.php +++ /dev/null @@ -1,173 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); -namespace think\trace; - -use think\App; -use think\Response; - -/** - * 浏览器调试输出 - */ -class Console -{ - protected $config = [ - 'tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], - ]; - - // 实例化并传入参数 - public function __construct(array $config = []) - { - $this->config = array_merge($this->config, $config); - } - - /** - * 调试输出接口 - * @access public - * @param Response $response Response对象 - * @param array $log 日志信息 - * @return string|bool - */ - public function output(App $app, Response $response, array $log = []) - { - $request = $app->request; - $contentType = $response->getHeader('Content-Type'); - - if ($request->isJson() || $request->isAjax()) { - return false; - } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { - return false; - } elseif ($response->getCode() == 204) { - return false; - } - - // 获取基本信息 - $runtime = number_format(microtime(true) - $app->getBeginTime(), 10, '.', ''); - $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; - $mem = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2); - - if ($request->host()) { - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); - } else { - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); - } - - // 页面Trace信息 - $base = [ - '请求信息' => date('Y-m-d H:i:s', $request->time() ?: time()) . ' ' . $uri, - '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), - '查询信息' => $app->db->getQueryTimes() . ' queries', - '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', - ]; - - if (isset($app->session)) { - $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); - } - - $info = $this->getFileInfo(); - - // 页面Trace信息 - $trace = []; - foreach ($this->config['tabs'] as $name => $title) { - $name = strtolower($name); - switch ($name) { - case 'base': // 基本信息 - $trace[$title] = $base; - break; - case 'file': // 文件信息 - $trace[$title] = $info; - break; - default: // 调试信息 - if (strpos($name, '|')) { - // 多组信息 - $names = explode('|', $name); - $result = []; - foreach ($names as $item) { - $result = array_merge($result, $log[$item] ?? []); - } - $trace[$title] = $result; - } else { - $trace[$title] = $log[$name] ?? ''; - } - } - } - - //输出到控制台 - $lines = ''; - foreach ($trace as $type => $msg) { - $lines .= $this->console($type, empty($msg) ? [] : $msg); - } - $js = << -{$lines} - -JS; - return $js; - } - - protected function console(string $type, $msg) - { - $type = strtolower($type); - $trace_tabs = array_values($this->config['tabs']); - $line = []; - $line[] = ($type == $trace_tabs[0] || '调试' == $type || '错误' == $type) - ? "console.group('{$type}');" - : "console.groupCollapsed('{$type}');"; - - foreach ((array) $msg as $key => $m) { - switch ($type) { - case '调试': - $var_type = gettype($m); - if (in_array($var_type, ['array', 'string'])) { - $line[] = "console.log(" . json_encode($m) . ");"; - } else { - $line[] = "console.log(" . json_encode(var_export($m, true)) . ");"; - } - break; - case '错误': - $msg = str_replace("\n", '\n', addslashes(is_scalar($m) ? $m : json_encode($m))); - $style = 'color:#F4006B;font-size:14px;'; - $line[] = "console.error(\"%c{$msg}\", \"{$style}\");"; - break; - case 'sql': - $msg = str_replace("\n", '\n', addslashes($m)); - $style = "color:#009bb4;"; - $line[] = "console.log(\"%c{$msg}\", \"{$style}\");"; - break; - default: - $m = is_string($key) ? $key . ' ' . $m : $key + 1 . ' ' . $m; - $msg = json_encode($m); - $line[] = "console.log({$msg});"; - break; - } - } - $line[] = "console.groupEnd();"; - return implode(PHP_EOL, $line); - } - - /** - * 获取文件加载信息 - * @access protected - * @return integer|array - */ - protected function getFileInfo() - { - $files = get_included_files(); - $info = []; - - foreach ($files as $key => $file) { - $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; - } - - return $info; - } -} diff --git a/vendor/topthink/think-trace/src/Html.php b/vendor/topthink/think-trace/src/Html.php deleted file mode 100644 index 35b3146..0000000 --- a/vendor/topthink/think-trace/src/Html.php +++ /dev/null @@ -1,126 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); -namespace think\trace; - -use think\App; -use think\Response; - -/** - * 页面Trace调试 - */ -class Html -{ - protected $config = [ - 'file' => '', - 'tabs' => ['base' => '基本', 'file' => '文件', 'info' => '流程', 'notice|error' => '错误', 'sql' => 'SQL', 'debug|log' => '调试'], - ]; - - // 实例化并传入参数 - public function __construct(array $config = []) - { - $this->config = array_merge($this->config, $config); - } - - /** - * 调试输出接口 - * @access public - * @param App $app 应用实例 - * @param Response $response Response对象 - * @param array $log 日志信息 - * @return bool|string - */ - public function output(App $app, Response $response, array $log = []) - { - $request = $app->request; - $contentType = $response->getHeader('Content-Type'); - - if ($request->isJson() || $request->isAjax()) { - return false; - } elseif (!empty($contentType) && strpos($contentType, 'html') === false) { - return false; - } elseif ($response->getCode() == 204) { - return false; - } - - // 获取基本信息 - $runtime = number_format(microtime(true) - $app->getBeginTime(), 10, '.', ''); - $reqs = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞'; - $mem = number_format((memory_get_usage() - $app->getBeginMem()) / 1024, 2); - - // 页面Trace信息 - if ($request->host()) { - $uri = $request->protocol() . ' ' . $request->method() . ' : ' . $request->url(true); - } else { - $uri = 'cmd:' . implode(' ', $_SERVER['argv']); - } - - $base = [ - '请求信息' => date('Y-m-d H:i:s', $request->time() ?: time()) . ' ' . $uri, - '运行时间' => number_format((float) $runtime, 6) . 's [ 吞吐率:' . $reqs . 'req/s ] 内存消耗:' . $mem . 'kb 文件加载:' . count(get_included_files()), - '查询信息' => $app->db->getQueryTimes() . ' queries', - '缓存信息' => $app->cache->getReadTimes() . ' reads,' . $app->cache->getWriteTimes() . ' writes', - ]; - - if (isset($app->session)) { - $base['会话信息'] = 'SESSION_ID=' . $app->session->getId(); - } - - $info = $this->getFileInfo(); - - // 页面Trace信息 - $trace = []; - foreach ($this->config['tabs'] as $name => $title) { - $name = strtolower($name); - switch ($name) { - case 'base': // 基本信息 - $trace[$title] = $base; - break; - case 'file': // 文件信息 - $trace[$title] = $info; - break; - default: // 调试信息 - if (strpos($name, '|')) { - // 多组信息 - $names = explode('|', $name); - $result = []; - foreach ($names as $item) { - $result = array_merge($result, $log[$item] ?? []); - } - $trace[$title] = $result; - } else { - $trace[$title] = $log[$name] ?? ''; - } - } - } - // 调用Trace页面模板 - ob_start(); - include $this->config['file'] ?: __DIR__ . '/tpl/page_trace.tpl'; - return ob_get_clean(); - } - - /** - * 获取文件加载信息 - * @access protected - * @return integer|array - */ - protected function getFileInfo() - { - $files = get_included_files(); - $info = []; - - foreach ($files as $key => $file) { - $info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )'; - } - - return $info; - } -} diff --git a/vendor/topthink/think-trace/src/Service.php b/vendor/topthink/think-trace/src/Service.php deleted file mode 100644 index 3e78ecc..0000000 --- a/vendor/topthink/think-trace/src/Service.php +++ /dev/null @@ -1,21 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace think\trace; - -use think\Service as BaseService; - -class Service extends BaseService -{ - public function register() - { - $this->app->middleware->add(TraceDebug::class); - } -} diff --git a/vendor/topthink/think-trace/src/TraceDebug.php b/vendor/topthink/think-trace/src/TraceDebug.php deleted file mode 100644 index 5ed9cbf..0000000 --- a/vendor/topthink/think-trace/src/TraceDebug.php +++ /dev/null @@ -1,109 +0,0 @@ - -// +---------------------------------------------------------------------- -declare (strict_types = 1); - -namespace think\trace; - -use Closure; -use think\App; -use think\Config; -use think\event\LogWrite; -use think\Request; -use think\Response; -use think\response\Redirect; - -/** - * 页面Trace中间件 - */ -class TraceDebug -{ - - /** - * Trace日志 - * @var array - */ - protected $log = []; - - /** - * 配置参数 - * @var array - */ - protected $config = []; - - /** @var App */ - protected $app; - - public function __construct(App $app, Config $config) - { - $this->app = $app; - $this->config = $config->get('trace'); - } - - /** - * 页面Trace调试 - * @access public - * @param Request $request - * @param Closure $next - * @return void - */ - public function handle($request, Closure $next) - { - $debug = $this->app->isDebug(); - - // 注册日志监听 - if ($debug) { - $this->log = []; - $this->app->event->listen(LogWrite::class, function ($event) { - if (empty($this->config['channel']) || $this->config['channel'] == $event->channel) { - $this->log = array_merge_recursive($this->log, $event->log); - } - }); - } - - $response = $next($request); - - // Trace调试注入 - if ($debug) { - $data = $response->getContent(); - $this->traceDebug($response, $data); - $response->content($data); - } - - return $response; - } - - public function traceDebug(Response $response, &$content) - { - $config = $this->config; - $type = $config['type'] ?? 'Html'; - - unset($config['type']); - - $trace = App::factory($type, '\\think\\trace\\', $config); - - if ($response instanceof Redirect) { - //TODO 记录 - } else { - $log = $this->app->log->getLog($config['channel'] ?? ''); - $log = array_merge_recursive($this->log, $log); - $output = $trace->output($this->app, $response, $log); - if (is_string($output)) { - // trace调试信息注入 - $pos = strripos($content, ''); - if (false !== $pos) { - $content = substr($content, 0, $pos) . $output . substr($content, $pos); - } else { - $content = $content . $output; - } - } - } - } -} diff --git a/vendor/topthink/think-trace/src/config.php b/vendor/topthink/think-trace/src/config.php deleted file mode 100644 index fad2392..0000000 --- a/vendor/topthink/think-trace/src/config.php +++ /dev/null @@ -1,10 +0,0 @@ - 'Html', - // 读取的日志通道名 - 'channel' => '', -]; diff --git a/vendor/topthink/think-trace/src/tpl/page_trace.tpl b/vendor/topthink/think-trace/src/tpl/page_trace.tpl deleted file mode 100644 index 6b1b9a1..0000000 --- a/vendor/topthink/think-trace/src/tpl/page_trace.tpl +++ /dev/null @@ -1,71 +0,0 @@ -
    - - -
    -
    -
    - -
    - - diff --git a/vendor/topthink/think-view/README.md b/vendor/topthink/think-view/README.md index 4e52def..fcd7b0e 100644 --- a/vendor/topthink/think-view/README.md +++ b/vendor/topthink/think-view/README.md @@ -1,6 +1,6 @@ # think-view -ThinkPHP6.0 Think-Template模板引擎驱动 +ThinkPHP8.0 Think-Template模板引擎驱动 ## 安装 @@ -11,7 +11,7 @@ composer require topthink/think-view ## 用法示例 -本扩展不能单独使用,依赖ThinkPHP6.0+ +本扩展不能单独使用,依赖ThinkPHP8.0+ 首先配置config目录下的template.php配置文件,然后可以按照下面的用法使用。 diff --git a/vendor/topthink/think-view/composer.json b/vendor/topthink/think-view/composer.json index f4e6431..d9bcca7 100644 --- a/vendor/topthink/think-view/composer.json +++ b/vendor/topthink/think-view/composer.json @@ -9,8 +9,8 @@ } ], "require": { - "php": ">=7.1.0", - "topthink/think-template": "^2.0" + "php": ">=8.0.0", + "topthink/think-template": "^3.0" }, "autoload": { "psr-4": { diff --git a/vendor/topthink/think-view/src/Think.php b/vendor/topthink/think-view/src/Think.php index 562b54a..105b070 100644 --- a/vendor/topthink/think-view/src/Think.php +++ b/vendor/topthink/think-view/src/Think.php @@ -21,7 +21,6 @@ class Think { // 模板引擎实例 private $template; - private $app; // 模板引擎参数 protected $config = [ @@ -39,10 +38,8 @@ class Think 'tpl_cache' => true, ]; - public function __construct(App $app, array $config = []) + public function __construct(private App $app, array $config = []) { - $this->app = $app; - $this->config = array_merge($this->config, (array) $config); if (empty($this->config['cache_path'])) { @@ -55,30 +52,15 @@ class Think $type = strtoupper(trim(array_shift($vars))); $param = implode('.', $vars); - switch ($type) { - case 'CONST': - $parseStr = strtoupper($param); - break; - case 'CONFIG': - $parseStr = 'config(\'' . $param . '\')'; - break; - case 'LANG': - $parseStr = 'lang(\'' . $param . '\')'; - break; - case 'NOW': - $parseStr = "date('Y-m-d g:i a',time())"; - break; - case 'LDELIM': - $parseStr = '\'' . ltrim($this->getConfig('tpl_begin'), '\\') . '\''; - break; - case 'RDELIM': - $parseStr = '\'' . ltrim($this->getConfig('tpl_end'), '\\') . '\''; - break; - default: - $parseStr = defined($type) ? $type : '\'\''; - } - - return $parseStr; + return match ($type) { + 'CONST' => strtoupper($param), + 'CONFIG' => 'config(\'' . $param . '\')', + 'LANG' => 'lang(\'' . $param . '\')', + 'NOW' => "date('Y-m-d g:i a',time())", + 'LDELIM' => '\'' . ltrim($this->getConfig('tpl_begin'), '\\') . '\'', + 'RDELIM' => '\'' . ltrim($this->getConfig('tpl_end'), '\\') . '\'', + default => defined($type) ? $type : '\'\'', + }; }); $this->template->extend('$Request', function (array $vars) { diff --git a/vendor/wamkj/thinkphp6.0-databackup/LICENSE b/vendor/wamkj/thinkphp6.0-databackup/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/vendor/wamkj/thinkphp6.0-databackup/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/wamkj/thinkphp6.0-databackup/README.md b/vendor/wamkj/thinkphp6.0-databackup/README.md deleted file mode 100644 index 3948474..0000000 --- a/vendor/wamkj/thinkphp6.0-databackup/README.md +++ /dev/null @@ -1,58 +0,0 @@ -### 使用composer进行安装 -~~~ -composer require wamkj/thinkphp6.0-databackup -~~~ - -### 引入类文件 -~~~ -use wamkj\thinkphp\Backup; -~~~ - -### 配置文件 -~~~ -$config=array( - 'path' => './Data/',//数据库备份路径 - 'part' => 20971520,//数据库备份卷大小 - 'compress' => 0,//数据库备份文件是否启用压缩 0不压缩 1 压缩 - 'level' => 9 //数据库备份文件压缩级别 1普通 4 一般 9最高 -); -~~~ - -### 实例化 -~~~ - $db= new Backup($config); -~~~ - -### 数据类表列表 -~~~ -return $this->fetch('index',['list'=>$db->dataList()]); -~~~ -### 备份文件列表 -~~~ - return $this->fetch('importlist',['list'=>$db->fileList()]); -~~~ - -### 备份表 -~~~ - $start= $db->setFile($file)->backup($tables[$id], $start); -~~~ - -### 导入表 -~~~ - $start= $db->setFile($file)->import($start); -~~~ - -### 删除备份文件 -~~~ - $db->delFile($time); -~~~ - -### 修复表 -~~~ - $db->repair($tables) -~~~ - -### 优化表 -~~~ - $db->optimize($tables) -~~~ diff --git a/vendor/wamkj/thinkphp6.0-databackup/composer.json b/vendor/wamkj/thinkphp6.0-databackup/composer.json deleted file mode 100644 index a5b4f94..0000000 --- a/vendor/wamkj/thinkphp6.0-databackup/composer.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "wamkj/thinkphp6.0-databackup", - "description": "thinkphp6.0的数据库自动备份扩展", - "keywords": ["think-databackup", "thinkphp"], - "license": "Apache-2.0", - "authors": [ - { - "name": "wamkj", - "email": "1149183529@qq.com" - } - ], - "require": { - "php": ">=7.1.0", - "topthink/framework": "^6.0" - }, - "autoload": { - "psr-4": { - "wamkj\\thinkphp\\": "src/" - } - } -} diff --git a/vendor/wamkj/thinkphp6.0-databackup/src/Backup.php b/vendor/wamkj/thinkphp6.0-databackup/src/Backup.php deleted file mode 100644 index 03f629b..0000000 --- a/vendor/wamkj/thinkphp6.0-databackup/src/Backup.php +++ /dev/null @@ -1,430 +0,0 @@ - './Data/',//数据库备份路径 - 'part' => 20971520,//数据库备份卷大小 - 'compress' => 0,//数据库备份文件是否启用压缩 0不压缩 1 压缩 - 'level' => 9 //数据库备份文件压缩级别 1普通 4 一般 9最高 - ); - /** - * 数据库备份构造方法 - * @param array $file 备份或还原的文件信息 - * @param array $config 备份配置信息 - */ - public function __construct($config=[]){ - $this->config = array_merge($this->config, $config); - //初始化文件名 - $this->setFile(); - //初始化数据库连接参数 - $this->setDbConn(); - //检查文件是否可写 - if(!$this->checkPath($this->config['path'])){ - throw new \Exception("The current directory is not writable"); - } - } - - /** - * 设置数据库连接必备参数 - * @param array $dbconfig 数据库连接配置信息 - * @return object - */ - public function setDbConn($dbconfig=[]) - { - if (empty($dbconfig)) { - $this->dbconfig = Config::get('database'); - }else{ - $this->dbconfig=$dbconfig; - } - return $this; - } - /** - * 设置备份文件名 - * @param String $file 文件名字 - * @return object - */ - public function setFile($file=null) - { - if(is_null($file)){ - $this->file=['name'=>date('Ymd-His'),'part'=>1]; - }else{ - if(!array_key_exists("name",$file) && !array_key_exists("part",$file)){ - $this->file=$file['1']; - }else{ - $this->file=$file; - } - - } - return $this; - } - //数据类连接 - public static function connect() - { - return Db::connect(); - } - - //数据库备份文件列表 - public function fileList() - { - if(!is_dir($this->config['path'])){ - mkdir($this->config['path'], 0755, true); - } - $path = realpath($this->config['path']); - $flag = \FilesystemIterator::KEY_AS_FILENAME; - $glob = new \FilesystemIterator($path, $flag); - $list = array(); - foreach ($glob as $name => $file) { - if(preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)){ - $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d'); - - $date = "{$name[0]}-{$name[1]}-{$name[2]}"; - $time = "{$name[3]}:{$name[4]}:{$name[5]}"; - $part = $name[6]; - - if(isset($list["{$date} {$time}"])){ - $info = $list["{$date} {$time}"]; - $info['part'] = max($info['part'], $part); - $info['size'] = $info['size'] + $file->getSize(); - } else { - $info['part'] = $part; - $info['size'] = $file->getSize(); - } - $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION)); - $info['compress'] = ($extension === 'SQL') ? '-' : $extension; - $info['time'] = strtotime("{$date} {$time}"); - - $list["{$date} {$time}"] = $info; - } - } - - return $list; - } - public function getFile($type='',$time=0) - { // - if(!is_numeric($time) ){ - throw new \Exception("{$time} Illegal data type"); - } - switch ($type) - { - case 'time': - $name = date('Ymd-His', $time) . '-*.sql*'; - $path = realpath($this->config['path']) . DIRECTORY_SEPARATOR . $name; - return glob($path); - break; - case 'timeverif': - $name = date('Ymd-His', $time) . '-*.sql*'; - $path = realpath($this->config['path']) . DIRECTORY_SEPARATOR . $name; - $files = glob($path); - $list = array(); - foreach($files as $name){ - $basename = basename($name); - $match = sscanf($basename, '%4s%2s%2s-%2s%2s%2s-%d'); - $gz = preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql.gz$/', $basename); - $list[$match[6]] = array($match[6], $name, $gz); - } - $last = end($list); - if(count($list) === $last[0]){ - return $list; - } else { - throw new \Exception("File {$files['0']} may be damaged, please check again"); - } - - break; - case 'pathname': - return "{$this->config['path']}{$this->file['name']}-{$this->file['part']}.sql"; - break; - case 'filename': - return "{$this->file['name']}-{$this->file['part']}.sql"; - break; - case 'filepath': - return $this->config['path']; - break; - default: - $arr=array( - 'pathname'=>"{$this->config['path']}{$this->file['name']}-{$this->file['part']}.sql", - 'filename'=>"{$this->file['name']}-{$this->file['part']}.sql", - 'filepath'=>$this->config['path'], - 'file'=>$this->file - ); - return $arr; - } - } - - //删除备份文件 - public function delFile($time) - { - if($time){ - $file=$this->getFile('time',$time); - array_map("unlink", $this->getFile('time',$time)); - if(count( $this->getFile('time',$time) )){ - throw new \Exception("File {$path} deleted failed"); - } else { - return $time; - } - } else { - throw new \Exception("{$time} Time parameter is incorrect"); - } - } - public function import($start){ - //还原数据 - $db = self::connect(); - - if($this->config['compress']){ - $gz = gzopen($this->file[1], 'r'); - $size = 0; - } else { - $size = filesize($this->file[1]); - $gz = fopen($this->file[1], 'r'); - } - - $sql = ''; - if($start){ - $this->config['compress'] ? gzseek($gz, $start) : fseek($gz, $start); - } - for($i = 0; $i < 1000; $i++){ - $sql .= $this->config['compress'] ? gzgets($gz) : fgets($gz); - if(preg_match('/.*;$/', trim($sql))){ - if(false !== $db->execute($sql)){ - $start += strlen($sql); - } else { - return false; - } - $sql = ''; - } elseif ($this->config['compress'] ? gzeof($gz) : feof($gz)) { - return 0; - } - } - - return array($start, $size); - } - - - //数据库表列表 - public function dataList($table=null) - { - $db = self::connect(); - - if(is_null($table)){ - $list = $db->query("SHOW TABLE STATUS"); - }else{ - $list = $db->query("show columns from {$table}"); - } - return array_map('array_change_key_case', $list);//$list; - } - /** - * 写入初始数据 - * @return boolean true - 写入成功,false - 写入失败 - */ - public function Backup_Init(){ - $sql = "-- -----------------------------\n"; - $sql .= "-- Think MySQL Data Transfer \n"; - $sql .= "-- \n"; - $sql .= "-- Host : " .$this->dbconfig['hostname']. "\n"; - $sql .= "-- Port : " .$this->dbconfig['hostport']. "\n"; - $sql .= "-- Database : " .$this->dbconfig['database']. "\n"; - $sql .= "-- \n"; - $sql .= "-- Part : #{$this->file['part']}\n"; - $sql .= "-- Date : " . date("Y-m-d H:i:s") . "\n"; - $sql .= "-- -----------------------------\n\n"; - $sql .= "SET FOREIGN_KEY_CHECKS = 0;\n\n"; - return $this->write($sql); - } - - /** - * 备份表结构 - * @param string $table 表名 - * @param integer $start 起始行数 - * @return boolean false - 备份失败 - */ - public function backup($table, $start){ - - $db = self::connect(); - // 备份表结构 - if(0 == $start){ - $result = $db->query("SHOW CREATE TABLE `{$table}`"); - $sql = "\n"; - $sql .= "-- -----------------------------\n"; - $sql .= "-- Table structure for `{$table}`\n"; - $sql .= "-- -----------------------------\n"; - $sql .= "DROP TABLE IF EXISTS `{$table}`;\n"; - - $sql .= trim($result[0]['Create Table']) . ";\n\n"; - - if(false === $this->write($sql)){ - return false; - } - } - - //数据总数 - $result = $db->query("SELECT COUNT(*) AS count FROM `{$table}`"); - - $count = $result['0']['count']; - - //备份表数据 - if($count){ - //写入数据注释 - if(0 == $start){ - $sql = "-- -----------------------------\n"; - $sql .= "-- Records of `{$table}`\n"; - $sql .= "-- -----------------------------\n"; - $this->write($sql); - } - - //备份数据记录 - $result = $db->query("SELECT * FROM `{$table}` LIMIT {$start}, 1000"); - foreach ($result as $row) { - $row = array_map('addslashes', $row); - $sql = "INSERT INTO `{$table}` VALUES ('" . str_replace(array("\r","\n"),array('\r','\n'),implode("', '", $row)) . "');\n"; - if(false === $this->write($sql)){ - return false; - } - } - - //还有更多数据 - if($count > $start + 1000){ - return array($start + 1000, $count); - } - } - //备份下一表 - return 0; - } - /** - * 优化表 - * @param String $tables 表名 - * @return String $tables - */ - public function optimize($tables = null){ - if($tables) { - $db = self::connect(); - if(is_array($tables)){ - $tables = implode('`,`', $tables); - $list = $db->query("OPTIMIZE TABLE `{$tables}`"); - } else { - $list = $db->query("OPTIMIZE TABLE `{$tables}`"); - } - if($list){ - return $tables; - } else { - throw new \Exception("data sheet'{$tables}'Repair mistakes please try again!"); - } - } else { - throw new \Exception("Please specify the table to be repaired!"); - } - } - /** - * 修复表 - * @param String $tables 表名 - * @return String $tables - */ - public function repair($tables = null){ - if($tables) { - $db = self::connect(); - if(is_array($tables)){ - $tables = implode('`,`', $tables); - $list = $db->query("REPAIR TABLE `{$tables}`"); - } else { - $list = $db->query("REPAIR TABLE `{$tables}`"); - } - if($list){ - return $list; - } else { - throw new \Exception("data sheet'{$tables}'Repair mistakes please try again!"); - } - } else { - throw new \Exception("Please specify the table to be repaired!"); - } - } - - /** - * 写入SQL语句 - * @param string $sql 要写入的SQL语句 - * @return boolean true - 写入成功,false - 写入失败! - */ - private function write($sql){ - $size = strlen($sql); - //由于压缩原因,无法计算出压缩后的长度,这里假设压缩率为50%, - //一般情况压缩率都会高于50%; - $size = $this->config['compress'] ? $size / 2 : $size; - $this->open($size); - return $this->config['compress'] ? @gzwrite($this->fp, $sql) : @fwrite($this->fp, $sql); - } - /** - * 打开一个卷,用于写入数据 - * @param integer $size 写入数据的大小 - */ - private function open($size){ - if($this->fp){ - $this->size += $size; - if($this->size > $this->config['part']){ - $this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp); - $this->fp = null; - $this->file['part']++; - session('backup_file', $this->file); - $this->create(); - } - } else { - $backuppath = $this->config['path']; - $filename = "{$backuppath}{$this->file['name']}-{$this->file['part']}.sql"; - if($this->config['compress']){ - $filename = "{$filename}.gz"; - $this->fp = @gzopen($filename, "a{$this->config['level']}"); - } else { - $this->fp = @fopen($filename, 'a'); - } - $this->size = filesize($filename) + $size; - } - } - /** - * 检查目录是否可写 - * @param string $path 目录 - * @return boolean - */ - protected function checkPath($path) - { - if (is_dir($path)) { - return true; - } - if (mkdir($path, 0755, true)) { - return true; - } else { - return false; - } - } - /** - * 析构方法,用于关闭文件资源 - */ - public function __destruct(){ - $this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp); - } - -} diff --git a/vendor/workerman/channel/README.md b/vendor/workerman/channel/README.md deleted file mode 100644 index 0a4f7d8..0000000 --- a/vendor/workerman/channel/README.md +++ /dev/null @@ -1,101 +0,0 @@ -# Channel -基于订阅的多进程通讯组件,用于workerman进程间通讯或者服务器集群通讯,类似redis订阅发布机制。基于workerman开发。 - -Channel 提供两种通讯形式,分别是发布订阅的事件机制和消息队列机制。 - -它们的主要区别是: -- 事件机制是消息发出后,所有订阅该事件的客户端都能收到消息。 -- 消息队列机制是消息发出后,所有订阅该消息的客户端只有一个会收到消息,如果客户端忙消息会进行排队直到有客户端闲置后重新取到消息。 -- 需要注意的是 Channel 只是提供一种通讯方式,本身并不提供消息确认、重试、延迟、持久化等功能,请根据实际情况合理使用。 - -# 手册地址 -[Channel手册](http://doc.workerman.net/components/channel.html) - -# 服务端 -```php -use Workerman\Worker; - -//Tcp 通讯方式 -$channel_server = new Channel\Server('0.0.0.0', 2206); - -//Unix Domain Socket 通讯方式 -//$channel_server = new Channel\Server('unix:///tmp/workerman-channel.sock'); - -if(!defined('GLOBAL_START')) -{ - Worker::runAll(); -} -``` - -# 客户端 -```php -use Workerman\Worker; - -$worker = new Worker(); -$worker->onWorkerStart = function() -{ - // Channel客户端连接到Channel服务端 - Channel\Client::connect('', 2206); - - // 使用 Unix Domain Socket 通讯 - //Channel\Client::connect('unix:///tmp/workerman-channel.sock'); - - // 要订阅的事件名称(名称可以为任意的数字和字符串组合) - $event_name = 'event_xxxx'; - // 订阅某个自定义事件并注册回调,收到事件后会自动触发此回调 - Channel\Client::on($event_name, function($event_data){ - var_dump($event_data); - }); -}; -$worker->onMessage = function($connection, $data) -{ - // 要发布的事件名称 - $event_name = 'event_xxxx'; - // 事件数据(数据格式可以为数字、字符串、数组),会传递给客户端回调函数作为参数 - $event_data = array('some data.', 'some data..'); - // 发布某个自定义事件,订阅这个事件的客户端会收到事件数据,并触发客户端对应的事件回调 - Channel\Client::publish($event_name, $event_data); -}; - -if(!defined('GLOBAL_START')) -{ - Worker::runAll(); -} -```` - -## 消息队列示例 -```php -use Workerman\Worker; -use Workerman\Timer; - -$worker = new Worker(); -$worker->name = 'Producer'; -$worker->onWorkerStart = function() -{ - Client::connect(); - - $count = 0; - Timer::add(1, function() { - Client::enqueue('queue', 'Hello World '.time()); - }); -}; - -$mq = new Worker(); -$mq->name = 'Consumer'; -$mq->count = 4; -$mq->onWorkerStart = function($worker) { - Client::connect(); - - //订阅消息 queue - Client::watch('queue', function($data) use ($worker) { - echo "Worker {$worker->id} get queue: $data\n"; - }); - - //10 秒后取消订阅该消息 - Timer::add(10, function() { - Client::unwatch('queue'); - }, [], false); -}; - -Worker::runAll(); -``` \ No newline at end of file diff --git a/vendor/workerman/channel/composer.json b/vendor/workerman/channel/composer.json deleted file mode 100644 index df63a66..0000000 --- a/vendor/workerman/channel/composer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name" : "workerman/channel", - "type" : "library", - "homepage": "http://www.workerman.net", - "license" : "MIT", - "require": { - "workerman/workerman" : ">=4.0.12" - }, - "autoload": { - "psr-4": {"Channel\\": "./src"} - } -} diff --git a/vendor/workerman/channel/src/Client.php b/vendor/workerman/channel/src/Client.php deleted file mode 100644 index 1b012f1..0000000 --- a/vendor/workerman/channel/src/Client.php +++ /dev/null @@ -1,392 +0,0 @@ -protocol = Frame::class; - } - - $conn->onClose = [self::class, 'onRemoteClose']; - $conn->onConnect = [self::class, 'onRemoteConnect']; - $conn->onMessage = [self::class , 'onRemoteMessage']; - $conn->connect(); - - if (empty(self::$_pingTimer)) { - self::$_pingTimer = Timer::add(self::$pingInterval, 'Channel\Client::ping'); - } - // Not workerman environment. - } else { - $remote = strpos($ip, 'unix://') === false ? 'tcp://'.self::$_remoteIp.':'.self::$_remotePort : $ip; - $conn = stream_socket_client($remote, $code, $message, 5); - if (!$conn) { - throw new \Exception($message); - } - } - - self::$_remoteConnection = $conn; - } - - /** - * onRemoteMessage. - * @param \Workerman\Connection\TcpConnection $connection - * @param string $data - * @throws \Exception - */ - public static function onRemoteMessage($connection, $data) - { - $data = unserialize($data); - $type = $data['type']; - $event = $data['channel']; - $event_data = $data['data']; - - $callback = null; - - if ($type == 'event') { - if (!empty(self::$_events[$event])) { - call_user_func(self::$_events[$event], $event_data); - } elseif (!empty(Client::$onMessage)) { - call_user_func(Client::$onMessage, $event, $event_data); - } else { - throw new \Exception("event:$event have not callback"); - } - } else { - if (isset(self::$_queues[$event])) { - call_user_func(self::$_queues[$event], $event_data); - } else { - throw new \Exception("queue:$event have not callback"); - } - } - } - - /** - * Ping. - * @return void - */ - public static function ping() - { - if(self::$_remoteConnection) - { - self::$_remoteConnection->send(''); - } - } - - /** - * onRemoteClose. - * @return void - */ - public static function onRemoteClose() - { - echo "Waring channel connection closed and try to reconnect\n"; - self::$_remoteConnection = null; - self::clearTimer(); - self::$_reconnectTimer = Timer::add(1, 'Channel\Client::connect', array(self::$_remoteIp, self::$_remotePort)); - if (self::$onClose) { - call_user_func(Client::$onClose); - } - } - - /** - * onRemoteConnect. - * @return void - */ - public static function onRemoteConnect() - { - $all_event_names = array_keys(self::$_events); - if($all_event_names) - { - self::subscribe($all_event_names); - } - self::clearTimer(); - - if (self::$onConnect) { - call_user_func(Client::$onConnect); - } - } - - /** - * clearTimer. - * @return void - */ - public static function clearTimer() - { - if (!self::$_isWorkermanEnv) { - throw new \Exception('Channel\\Client not support clearTimer method when it is not in the workerman environment.'); - } - if(self::$_reconnectTimer) - { - Timer::del(self::$_reconnectTimer); - self::$_reconnectTimer = null; - } - } - - /** - * On. - * @param string $event - * @param callback $callback - * @throws \Exception - */ - public static function on($event, $callback) - { - if (!is_callable($callback)) { - throw new \Exception('callback is not callable for event.'); - } - self::$_events[$event] = $callback; - self::subscribe($event); - } - - /** - * Subscribe. - * @param string $events - * @return void - */ - public static function subscribe($events) - { - $events = (array)$events; - self::send(array('type' => 'subscribe', 'channels'=>$events)); - foreach ($events as $event) { - if(!isset(self::$_events[$event])) { - self::$_events[$event] = null; - } - } - } - - /** - * Unsubscribe. - * @param string $events - * @return void - */ - public static function unsubscribe($events) - { - $events = (array)$events; - self::send(array('type' => 'unsubscribe', 'channels'=>$events)); - foreach($events as $event) { - unset(self::$_events[$event]); - } - } - - /** - * Publish. - * @param string $events - * @param mixed $data - */ - public static function publish($events, $data , $is_loop = false) - { - $type = $is_loop == true ? 'publishLoop' : 'publish'; - self::sendAnyway(array('type' => $type, 'channels' => (array)$events, 'data' => $data)); - } - - /** - * Watch a channel of queue - * @param string|array $channels - * @param callable $callback - * @param boolean $autoReserve Auto reserve after callback finished. - * But sometime you may don't want reserve immediately, or in some asynchronous job, - * you want reserve in finished callback, so you should set $autoReserve to false - * and call Client::reserve() after watch() and in finish callback manually. - * @throws \Exception - */ - public static function watch($channels, $callback, $autoReserve=true) - { - if (!is_callable($callback)) { - throw new \Exception('callback is not callable for watch.'); - } - - if ($autoReserve) { - $callback = static function($data) use ($callback) { - try { - call_user_func($callback, $data); - } catch (\Exception $e) { - throw $e; - } catch (\Error $e) { - throw $e; - } finally { - self::reserve(); - } - }; - } - - $channels = (array)$channels; - self::send(array('type' => 'watch', 'channels'=>$channels)); - - foreach ($channels as $channel) { - self::$_queues[$channel] = $callback; - } - - if ($autoReserve) { - self::reserve(); - } - } - - /** - * Unwatch a channel of queue - * @param string $channel - * @throws \Exception - */ - public static function unwatch($channels) - { - $channels = (array)$channels; - self::send(array('type' => 'unwatch', 'channels'=>$channels)); - foreach ($channels as $channel) { - if (isset(self::$_queues[$channel])) { - unset(self::$_queues[$channel]); - } - } - } - - /** - * Put data to queue - * @param string|array $channels - * @param mixed $data - * @throws \Exception - */ - public static function enqueue($channels, $data) - { - self::sendAnyway(array('type' => 'enqueue', 'channels' => (array)$channels, 'data' => $data)); - } - - /** - * Start reserve queue manual - * @throws \Exception - */ - public static function reserve() - { - self::send(array('type' => 'reserve')); - } - - /** - * Send through workerman environment - * @param $data - * @throws \Exception - */ - protected static function send($data) - { - if (!self::$_isWorkermanEnv) { - throw new \Exception("Channel\\Client not support {$data['type']} method when it is not in the workerman environment."); - } - self::connect(self::$_remoteIp, self::$_remotePort); - self::$_remoteConnection->send(serialize($data)); - } - - /** - * Send from any environment - * @param $data - * @throws \Exception - */ - protected static function sendAnyway($data) - { - self::connect(self::$_remoteIp, self::$_remotePort); - $body = serialize($data); - if (self::$_isWorkermanEnv) { - self::$_remoteConnection->send($body); - } else { - $buffer = pack('N', 4+strlen($body)) . $body; - fwrite(self::$_remoteConnection, $buffer); - } - } - -} diff --git a/vendor/workerman/channel/src/Queue.php b/vendor/workerman/channel/src/Queue.php deleted file mode 100644 index 3b1b56e..0000000 --- a/vendor/workerman/channel/src/Queue.php +++ /dev/null @@ -1,89 +0,0 @@ -name = $name; - $this->queue = new \SplQueue(); - } - - /** - * @param TcpConnection $connection - */ - public function addWatch($connection) - { - if (!isset($this->watcher[$connection->id])) { - $this->watcher[$connection->id] = $connection; - $connection->watchs[] = $this->name; - } - } - - /** - * @param TcpConnection $connection - */ - public function removeWatch($connection) - { - if (isset($connection->watchs) && in_array($this->name, $connection->watchs)) { - $idx = array_search($this->name, $connection->watchs); - unset($connection->watchs[$idx]); - } - if (isset($this->watcher[$connection->id])) { - unset($this->watcher[$connection->id]); - } - if (isset($this->consumer[$connection->id])) { - unset($this->consumer[$connection->id]); - } - } - - /** - * @param TcpConnection $connection - */ - public function addConsumer($connection) - { - if (isset($this->watcher[$connection->id]) && !isset($this->consumer[$connection->id])) { - $this->consumer[$connection->id] = $connection; - } - $this->dispatch(); - } - - public function enqueue($data) - { - $this->queue->enqueue($data); - $this->dispatch(); - } - - private function dispatch() - { - if ($this->queue->isEmpty() || count($this->consumer) == 0) { - return; - } - - while (!$this->queue->isEmpty()) { - $data = $this->queue->dequeue(); - $idx = key($this->consumer); - $connection = $this->consumer[$idx]; - unset($this->consumer[$idx]); - $connection->send(serialize(array('type'=>'queue', 'channel'=>$this->name, 'data' => $data))); - if (count($this->consumer) == 0) { - break; - } - } - } - - public function isEmpty() - { - return empty($this->watcher) && $this->queue->isEmpty(); - } - -} \ No newline at end of file diff --git a/vendor/workerman/channel/src/Server.php b/vendor/workerman/channel/src/Server.php deleted file mode 100644 index 9b9c5a0..0000000 --- a/vendor/workerman/channel/src/Server.php +++ /dev/null @@ -1,179 +0,0 @@ -protocol = Frame::class; - } - $this->ip = $ip; - $worker->count = 1; - $worker->name = 'ChannelServer'; - $worker->channels = array(); - $worker->onMessage = array($this, 'onMessage') ; - $worker->onClose = array($this, 'onClose'); - $this->_worker = $worker; - } - - /** - * onClose - * @return void - */ - public function onClose($connection) - { - if (!empty($connection->channels)) { - foreach ($connection->channels as $channel) { - unset($this->_worker->channels[$channel][$connection->id]); - if (empty($this->_worker->channels[$channel])) { - unset($this->_worker->channels[$channel]); - } - } - } - - if (!empty($connection->watchs)) { - foreach ($connection->watchs as $channel) { - if (isset($this->_queues[$channel])) { - $this->_queues[$channel]->removeWatch($connection); - if ($this->_queues[$channel]->isEmpty()) { - unset($this->_queues[$channel]); - } - } - } - } - } - - /** - * onMessage. - * @param \Workerman\Connection\TcpConnection $connection - * @param string $data - */ - public function onMessage($connection, $data) - { - if(!$data) - { - return; - } - $worker = $this->_worker; - $data = unserialize($data); - $type = $data['type']; - switch($type) - { - case 'subscribe': - foreach($data['channels'] as $channel) - { - $connection->channels[$channel] = $channel; - $worker->channels[$channel][$connection->id] = $connection; - } - break; - case 'unsubscribe': - foreach($data['channels'] as $channel) { - if (isset($connection->channels[$channel])) { - unset($connection->channels[$channel]); - } - if (isset($worker->channels[$channel][$connection->id])) { - unset($worker->channels[$channel][$connection->id]); - if (empty($worker->channels[$channel])) { - unset($worker->channels[$channel]); - } - } - } - break; - case 'publish': - foreach ($data['channels'] as $channel) { - if (empty($worker->channels[$channel])) { - continue; - } - $buffer = serialize(array('type' => 'event', 'channel' => $channel, 'data' => $data['data']))."\n"; - foreach ($worker->channels[$channel] as $connection) { - $connection->send($buffer); - } - } - break; - case 'publishLoop': - //choose one subscriber from the list - foreach ($data['channels'] as $channel) { - if (empty($worker->channels[$channel])) { - continue; - } - $buffer = serialize(array('type' => 'event', 'channel' => $channel, 'data' => $data['data']))."\n"; - - //这是要点,每次取出一个元素,如果取不到,说明已经到最后,重置到第一个 - $connection = next($worker->channels[$channel]); - if( $connection == false ){ - $connection = reset($worker->channels[$channel]); - } - $connection->send($buffer); - } - break; - case 'watch': - foreach ($data['channels'] as $channel) { - $this->getQueue($channel)->addWatch($connection); - } - break; - case 'unwatch': - foreach ($data['channels'] as $channel) { - if (isset($this->_queues[$channel])) { - $this->_queues[$channel]->removeWatch($connection); - if ($this->_queues[$channel]->isEmpty()) { - unset($this->_queues[$channel]); - } - } - } - break; - case 'enqueue': - foreach ($data['channels'] as $channel) { - $this->getQueue($channel)->enqueue($data['data']); - } - break; - case 'reserve': - if (isset($connection->watchs)) { - foreach ($connection->watchs as $channel) { - if (isset($this->_queues[$channel])) { - $this->_queues[$channel]->addConsumer($connection); - } - } - } - break; - } - } - - private function getQueue($channel) - { - if (isset($this->_queues[$channel])) { - return $this->_queues[$channel]; - } - return ($this->_queues[$channel] = new Queue($channel)); - } - -} diff --git a/vendor/workerman/channel/test/queue.php b/vendor/workerman/channel/test/queue.php deleted file mode 100644 index 72dbb63..0000000 --- a/vendor/workerman/channel/test/queue.php +++ /dev/null @@ -1,53 +0,0 @@ -name = 'Event'; -$worker->onWorkerStart = function() -{ - Client::connect(); - - $count = 0; - $timerId = Timer::add(0.01, function() use (&$timerId, &$count) { - Client::publish('test event', 'some data'); - $count++; - Client::enqueue('task-queue', time()); - if ($count == 1000) { - Timer::del($timerId); - } - }); - - Timer::add(10, function() { - Client::enqueue('task-queue', 'hello every 10 seconds'); - }); -}; - -$mq = new Worker(); -$mq->name = 'Queue'; -$mq->count = 4; -$mq->onWorkerStart = function($worker) { - Client::connect(); - $countDown = 20; - $id = 1; - Client::watch('task-queue', function($data) use ($worker, &$countDown, &$id) { - echo "[$id] Worker {$worker->id} get queue: $data\n"; - sleep(0.2); - $countDown--; - $id++; - if ($worker->id > 1 && $countDown == 0) { - Client::unwatch('task-queue'); - } - Timer::add(1, [Client::class, 'reserve'], [], false); - }); -}; - -Worker::runAll(); diff --git a/vendor/workerman/channel/test/server.php b/vendor/workerman/channel/test/server.php deleted file mode 100644 index dbb9ca5..0000000 --- a/vendor/workerman/channel/test/server.php +++ /dev/null @@ -1,28 +0,0 @@ -onWorkerStart = function() -{ - Client::connect(); - - Client::on('test event', function($event_data){ - echo 'test event triggered event_data :'; - var_dump($event_data); - }); - - Timer::add(2, function(){ - Client::publish('test event', 'some data'); - }); -}; - -Worker::runAll(); diff --git a/vendor/workerman/channel/test/start_channel.php b/vendor/workerman/channel/test/start_channel.php deleted file mode 100644 index 4366dd1..0000000 --- a/vendor/workerman/channel/test/start_channel.php +++ /dev/null @@ -1,23 +0,0 @@ -count = 8; -$processName = "client"; -$worker->name = $processName; -$worker->reusePort = true; //开启均衡负载模式 - -Worker::$pidFile = "var/{$processName}.pid"; -Worker::$logFile = "var/{$processName}_logFile.log"; -Worker::$stdoutFile = "var/{$processName}_stdout.log"; - -$worker->onWorkerStart = function() use($worker){ - usleep(10); - Channel\Client::connect('127.0.0.1' , 2206); - $event_name = "test_channel"; - Channel\Client::on($event_name, function($event_data)use($worker ,$event_name ){ - $log_str = "{$worker->id} on {$event_name}:".json_encode($event_data,320)."\n"; - echo $log_str; - }); -}; - -Worker::runAll(); \ No newline at end of file diff --git a/vendor/workerman/channel/test/start_send.php b/vendor/workerman/channel/test/start_send.php deleted file mode 100644 index 464b756..0000000 --- a/vendor/workerman/channel/test/start_send.php +++ /dev/null @@ -1,35 +0,0 @@ -count = 1; -$processName = "send"; -$worker->name = $processName; -$worker->reusePort = true; //开启均衡负载模式 - -Worker::$pidFile = "var/{$processName}.pid"; -Worker::$logFile = "var/{$processName}_logFile.log"; -Worker::$stdoutFile = "var/{$processName}_stdout.log"; - -$worker->onWorkerStart = function() use($worker){ - Channel\Client::connect('127.0.0.1' , 2206); - Timer::add( 1 , function ()use($worker){ - $data_arr = [ - 'time' => microtime(true), - 'date' => date("Y-m-d H:i:s"), - ]; - $event_name = "test_channel"; - Channel\Client::publish($event_name, $data_arr , true); - }); -}; -Worker::runAll(); \ No newline at end of file diff --git a/vendor/workerman/phpsocket.io/.github/FUNDING.yml b/vendor/workerman/phpsocket.io/.github/FUNDING.yml deleted file mode 100644 index 3d88b8d..0000000 --- a/vendor/workerman/phpsocket.io/.github/FUNDING.yml +++ /dev/null @@ -1,4 +0,0 @@ -# These are supported funding model platforms - -open_collective: walkor -patreon: walkor diff --git a/vendor/workerman/phpsocket.io/.gitignore b/vendor/workerman/phpsocket.io/.gitignore deleted file mode 100644 index afb6dd6..0000000 --- a/vendor/workerman/phpsocket.io/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -.buildpath -.project -.settings/org.eclipse.php.core.prefs -vendor -examples/vendor -composer.lock diff --git a/vendor/workerman/phpsocket.io/README.md b/vendor/workerman/phpsocket.io/README.md deleted file mode 100644 index d54328f..0000000 --- a/vendor/workerman/phpsocket.io/README.md +++ /dev/null @@ -1,184 +0,0 @@ -# phpsocket.io -A server side alternative implementation of [socket.io](https://github.com/socketio/socket.io) in PHP based on [Workerman](https://github.com/walkor/Workerman).
    - -# Notice -Only support socket.io >= v1.3.0 and <= v2.x
    -This project is just translate socket.io by [workerman](https://github.com/walkor/Workerman).
    -More api just see [https://socket.io/docs/v2/server-api/](https://socket.io/docs/v2/server-api/) - -# Install -composer require workerman/phpsocket.io - -# Examples -## Simple chat -start.php -```php - -use Workerman\Worker; -use PHPSocketIO\SocketIO; -require_once __DIR__ . '/vendor/autoload.php'; - -// Listen port 2021 for socket.io client -$io = new SocketIO(2021); -$io->on('connection', function ($socket) use ($io) { - $socket->on('chat message', function ($msg) use ($io) { - $io->emit('chat message', $msg); - }); -}); - -Worker::runAll(); -``` - -## Another chat demo - -https://github.com/walkor/phpsocket.io/blob/master/examples/chat/start_io.php -```php - -use Workerman\Worker; -use PHPSocketIO\SocketIO; -require_once __DIR__ . '/vendor/autoload.php'; - -// Listen port 2020 for socket.io client -$io = new SocketIO(2020); -$io->on('connection', function ($socket) { - $socket->addedUser = false; - - // When the client emits 'new message', this listens and executes - $socket->on('new message', function ($data) use ($socket) { - // We tell the client to execute 'new message' - $socket->broadcast->emit('new message', array( - 'username' => $socket->username, - 'message' => $data - )); - }); - - // When the client emits 'add user', this listens and executes - $socket->on('add user', function ($username) use ($socket) { - global $usernames, $numUsers; - - // We store the username in the socket session for this client - $socket->username = $username; - // Add the client's username to the global list - $usernames[$username] = $username; - ++$numUsers; - - $socket->addedUser = true; - $socket->emit('login', array( - 'numUsers' => $numUsers - )); - - // echo globally (all clients) that a person has connected - $socket->broadcast->emit('user joined', array( - 'username' => $socket->username, - 'numUsers' => $numUsers - )); - }); - - // When the client emits 'typing', we broadcast it to others - $socket->on('typing', function () use ($socket) { - $socket->broadcast->emit('typing', array( - 'username' => $socket->username - )); - }); - - // When the client emits 'stop typing', we broadcast it to others - $socket->on('stop typing', function () use ($socket) { - $socket->broadcast->emit('stop typing', array( - 'username' => $socket->username - )); - }); - - // When the user disconnects, perform this - $socket->on('disconnect', function () use ($socket) { - global $usernames, $numUsers; - - // Remove the username from global usernames list - if ($socket->addedUser) { - unset($usernames[$socket->username]); - --$numUsers; - - // echo globally that this client has left - $socket->broadcast->emit('user left', array( - 'username' => $socket->username, - 'numUsers' => $numUsers - )); - } - }); -}); - -Worker::runAll(); -``` - -## Enable SSL for https -**```(phpsocket.io>=1.1.1 && workerman>=3.3.7 required)```** - -start.php -```php - array( - 'local_cert' => '/your/path/of/server.pem', - 'local_pk' => '/your/path/of/server.key', - 'verify_peer' => false - ) -); -$io = new SocketIO(2021, $context); - -$io->on('connection', function ($connection) use ($io) { - echo "New connection coming\n"; -}); - -Worker::runAll(); -``` - -## Acknowledgement callback -```php - -use Workerman\Worker; -use PHPSocketIO\SocketIO; - -require_once __DIR__ . '/vendor/autoload.php'; - -$io = new SocketIO(2021); - -$io->on('connection', function ($connection) use ($io) { - $socket->on('message with ack', function ($data, $callback) use ($socket, $io) { - // acknowledgement callback - if ($callback && is_callable($callback)) { - $callback(0); - } - }); -}); - -Worker::runAll(); -``` - -# 手册 -[中文手册](https://github.com/walkor/phpsocket.io/tree/master/docs/zh) - -# Livedemo -[chat demo](http://demos.workerman.net/phpsocketio-chat/) - -# Run chat example -cd examples/chat - -## Start -```php start.php start``` for debug mode - -```php start.php start -d ``` for daemon mode - -## Stop -```php start.php stop``` - -## Status -```php start.php status``` - -# License -MIT diff --git a/vendor/workerman/phpsocket.io/composer.json b/vendor/workerman/phpsocket.io/composer.json deleted file mode 100644 index ac6aa39..0000000 --- a/vendor/workerman/phpsocket.io/composer.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name" : "workerman/phpsocket.io", - "type" : "library", - "keywords": ["socket.io"], - "homepage": "http://www.workerman.net", - "license" : "MIT", - "require": { - "workerman/workerman" : "^4.0.0", - "workerman/channel" : ">=1.0.0" - }, - "autoload": { - "psr-4": {"PHPSocketIO\\": "./src"} - } -} diff --git a/vendor/workerman/phpsocket.io/docs/README.md b/vendor/workerman/phpsocket.io/docs/README.md deleted file mode 100644 index 69ba49b..0000000 --- a/vendor/workerman/phpsocket.io/docs/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Documentation - -[中文](./zh/) diff --git a/vendor/workerman/phpsocket.io/docs/zh/README.md b/vendor/workerman/phpsocket.io/docs/zh/README.md deleted file mode 100644 index 5f2776d..0000000 --- a/vendor/workerman/phpsocket.io/docs/zh/README.md +++ /dev/null @@ -1,259 +0,0 @@ -# phpsocket.io手册 - -## 安装 -请使用composer集成phpsocket.io。 - -脚本中引用vendor中的autoload.php实现SocketIO相关类的加载。例如 -```php -require_once '/你的vendor路径/autoload.php'; -``` - -## 服务端和客户端连接 -**创建一个SocketIO服务端** -```php -on('connection', function($socket)use($io){ - echo "new connection coming\n"; -}); - -Worker::runAll(); -``` -**客户端** -```javascript - - -``` - -## 自定义事件 -socket.io主要是通过事件来进行通讯交互的。 - -socket连接除了自带的connect,message,disconnect三个事件以外,在服务端和客户端开发者可以自定义其它事件。 - -服务端和客户端都通过emit方法触发对端的事件。 - -例如下面的代码在服务端定义了一个```chat message```事件,事件参数为```$msg```。 -```php -on('connection', function($socket)use($io){ - // 定义chat message事件回调函数 - $socket->on('chat message', function($msg)use($io){ - // 触发所有客户端定义的chat message from server事件 - $io->emit('chat message from server', $msg); - }); -}); -Worker::runAll(); -``` - -客户端通过下面的方法触发服务端的chat message事件。 -```javascript - - -``` - -## workerStart事件 -phpsocket.io提供了workerStart事件回调,也就是当进程启动后准备好接受客户端链接时触发的回调。 -一个进程生命周期只会触发一次。可以在这里设置一些全局的事情,比如开一个新的Worker端口等等。 -```php -require_once __DIR__ . '/vendor/autoload.php'; -use Workerman\Worker; -use PHPSocketIO\SocketIO; - -$io = new SocketIO(9120); - -// 监听一个http端口,通过http协议访问这个端口可以向所有客户端推送数据(url类似http://ip:9191?msg=xxxx) -$io->on('workerStart', function()use($io) { - $inner_http_worker = new Worker('http://0.0.0.0:9191'); - $inner_http_worker->onMessage = function($http_connection, $data)use($io){ - if(!isset($_GET['msg'])) { - return $http_connection->send('fail, $_GET["msg"] not found'); - } - $io->emit('chat message', $_GET['msg']); - $http_connection->send('ok'); - }; - $inner_http_worker->listen(); -}); - -// 当有客户端连接时 -$io->on('connection', function($socket)use($io){ - // 定义chat message事件回调函数 - $socket->on('chat message', function($msg)use($io){ - // 触发所有客户端定义的chat message from server事件 - $io->emit('chat message from server', $msg); - }); -}); - -Worker::runAll(); -``` -phpsocket.io启动后开内部http端口通过phpsocket.io向客户端推送数据参考 [web-msg-sender](http://www.workerman.net/web-sender)。 - -## 分组 -socket.io提供分组功能,允许向某个分组发送事件,例如向某个房间广播数据。 - -1、加入分组(一个连接可以加入多个分组) -```php -$socket->join('group name'); -``` -2、离开分组(连接断开时会自动从分组中离开) -```php -$socket->leave('group name'); -``` - -## 向客户端发送事件的各种方法 -$io是SocketIO对象。$socket是客户端连接 - -$data可以是数字和字符串,也可以是数组。当$data是数组时,客户端会自动转换为javascript对象。 - -同理如果客户端向服务端emit某个事件传递的是一个javascript对象,在服务端接收时会自动转换为php数组。 - -1、向当前客户端发送事件 -```php -$socket->emit('event name', $data); -``` -2、向所有客户端发送事件 -```php -$io->emit('event name', $data); -``` -3、向所有客户端发送事件,但不包括当前连接。 -```php -$socket->broadcast->emit('event name', $data); -``` - -4、向某个分组的所有客户端发送事件 -```php -$io->to('group name')->emit('event name', $data); -``` - -## 获取客户端ip -```php -$io->on('connection', function($socket)use($io){ - var_dump($socket->conn->remoteAddress); -}); -``` - -## 关闭链接 -```php -$socket->disconnect(); -``` - -## 限制连接域名 -当我们想指定特定域名的页面才能连接,可以用$io->origins方法来设置域名白名单。 -```php -$io = new SocketIO(2020); -$io->origins('http://example.com:8080'); -``` -多个域名时用空格分隔,类似 -```php -$io = new SocketIO(2020); -$io->origins('http://workerman.net http://www.workerman.net'); -``` - -## 支持SSL(https wss) -SSL支持有两种方法,workerman原生和nginx代理 -### workerman原生支持 -SSL 要求workerman>=3.3.7 phpsocket.io>=1.1.1 - -```php - array( - 'local_cert' => '/your/path/of/server.pem', - 'local_pk' => '/your/path/of/server.key', - 'verify_peer' => false, - ) -); -$io = new SocketIO(2120, $context); - -$io->on('connection', function($socket)use($io){ - echo "new connection coming\n"; -}); - -Worker::runAll(); -``` -**注意:**
    -1、证书是要验证域名的,所以客户端链接时要指定域名才能顺利的建立链接。
    -2、客户端连接时不能再用http方式,要改成https类似下面这样。 -```javascript - -``` -### nginx代理SSL - -**前提条件及准备工作:** - -1、已经安装nginx,版本不低于1.3 - -2、假设phpsocket.io监听的是2120端口 - -3、已经申请了证书(pem/crt文件及key文件)放在了/etc/nginx/conf.d/ssl下 - -4、打算利用nginx开启443端口对外提供ssl代理服务(端口可以根据需要修改) - -**nginx配置类似如下:** -``` -server { - listen 443; - - ssl on; - ssl_certificate /etc/ssl/server.pem; - ssl_certificate_key /etc/ssl/server.key; - ssl_session_timeout 5m; - ssl_session_cache shared:SSL:50m; - ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2; - ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; - - location /socket.io - { - proxy_pass http://127.0.0.1:2120; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "Upgrade"; - proxy_set_header X-Real-IP $remote_addr; - } - - # location / {} 站点的其它配置... -} -``` -**注意:**
    -1、证书是要验证域名的,所以客户端链接时要指定域名才能顺利的建立链接。
    -2、客户端连接时不能再用http方式,要改成https类似下面这样。 -```javascript - - - - - diff --git a/vendor/workerman/phpsocket.io/examples/chat/public/jquery.min.js b/vendor/workerman/phpsocket.io/examples/chat/public/jquery.min.js deleted file mode 100644 index ab28a24..0000000 --- a/vendor/workerman/phpsocket.io/examples/chat/public/jquery.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.11.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.1",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b=a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="
    ",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);m.find=s,m.expr=s.selectors,m.expr[":"]=m.expr.pseudos,m.unique=s.uniqueSort,m.text=s.getText,m.isXMLDoc=s.isXML,m.contains=s.contains;var t=m.expr.match.needsContext,u=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,v=/^.[^:#\[\.,]*$/;function w(a,b,c){if(m.isFunction(b))return m.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return m.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(v.test(b))return m.filter(b,a,c);b=m.filter(b,a)}return m.grep(a,function(a){return m.inArray(a,b)>=0!==c})}m.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?m.find.matchesSelector(d,a)?[d]:[]:m.find.matches(a,m.grep(b,function(a){return 1===a.nodeType}))},m.fn.extend({find:function(a){var b,c=[],d=this,e=d.length;if("string"!=typeof a)return this.pushStack(m(a).filter(function(){for(b=0;e>b;b++)if(m.contains(d[b],this))return!0}));for(b=0;e>b;b++)m.find(a,d[b],c);return c=this.pushStack(e>1?m.unique(c):c),c.selector=this.selector?this.selector+" "+a:a,c},filter:function(a){return this.pushStack(w(this,a||[],!1))},not:function(a){return this.pushStack(w(this,a||[],!0))},is:function(a){return!!w(this,"string"==typeof a&&t.test(a)?m(a):a||[],!1).length}});var x,y=a.document,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=m.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||x).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof m?b[0]:b,m.merge(this,m.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:y,!0)),u.test(c[1])&&m.isPlainObject(b))for(c in b)m.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}if(d=y.getElementById(c[2]),d&&d.parentNode){if(d.id!==c[2])return x.find(a);this.length=1,this[0]=d}return this.context=y,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):m.isFunction(a)?"undefined"!=typeof x.ready?x.ready(a):a(m):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),m.makeArray(a,this))};A.prototype=m.fn,x=m(y);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};m.extend({dir:function(a,b,c){var d=[],e=a[b];while(e&&9!==e.nodeType&&(void 0===c||1!==e.nodeType||!m(e).is(c)))1===e.nodeType&&d.push(e),e=e[b];return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),m.fn.extend({has:function(a){var b,c=m(a,this),d=c.length;return this.filter(function(){for(b=0;d>b;b++)if(m.contains(this,c[b]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=t.test(a)||"string"!=typeof a?m(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&m.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?m.unique(f):f)},index:function(a){return a?"string"==typeof a?m.inArray(this[0],m(a)):m.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(m.unique(m.merge(this.get(),m(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}m.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return m.dir(a,"parentNode")},parentsUntil:function(a,b,c){return m.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return m.dir(a,"nextSibling")},prevAll:function(a){return m.dir(a,"previousSibling")},nextUntil:function(a,b,c){return m.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return m.dir(a,"previousSibling",c)},siblings:function(a){return m.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return m.sibling(a.firstChild)},contents:function(a){return m.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:m.merge([],a.childNodes)}},function(a,b){m.fn[a]=function(c,d){var e=m.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=m.filter(d,e)),this.length>1&&(C[a]||(e=m.unique(e)),B.test(a)&&(e=e.reverse())),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return m.each(a.match(E)||[],function(a,c){b[c]=!0}),b}m.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):m.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(c=a.memory&&l,d=!0,f=g||0,g=0,e=h.length,b=!0;h&&e>f;f++)if(h[f].apply(l[0],l[1])===!1&&a.stopOnFalse){c=!1;break}b=!1,h&&(i?i.length&&j(i.shift()):c?h=[]:k.disable())},k={add:function(){if(h){var d=h.length;!function f(b){m.each(b,function(b,c){var d=m.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&f(c)})}(arguments),b?e=h.length:c&&(g=d,j(c))}return this},remove:function(){return h&&m.each(arguments,function(a,c){var d;while((d=m.inArray(c,h,d))>-1)h.splice(d,1),b&&(e>=d&&e--,f>=d&&f--)}),this},has:function(a){return a?m.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],e=0,this},disable:function(){return h=i=c=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,c||k.disable(),this},locked:function(){return!i},fireWith:function(a,c){return!h||d&&!i||(c=c||[],c=[a,c.slice?c.slice():c],b?i.push(c):j(c)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!d}};return k},m.extend({Deferred:function(a){var b=[["resolve","done",m.Callbacks("once memory"),"resolved"],["reject","fail",m.Callbacks("once memory"),"rejected"],["notify","progress",m.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return m.Deferred(function(c){m.each(b,function(b,f){var g=m.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&m.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?m.extend(a,d):d}},e={};return d.pipe=d.then,m.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&m.isFunction(a.promise)?e:0,g=1===f?a:m.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&m.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;m.fn.ready=function(a){return m.ready.promise().done(a),this},m.extend({isReady:!1,readyWait:1,holdReady:function(a){a?m.readyWait++:m.ready(!0)},ready:function(a){if(a===!0?!--m.readyWait:!m.isReady){if(!y.body)return setTimeout(m.ready);m.isReady=!0,a!==!0&&--m.readyWait>0||(H.resolveWith(y,[m]),m.fn.triggerHandler&&(m(y).triggerHandler("ready"),m(y).off("ready")))}}});function I(){y.addEventListener?(y.removeEventListener("DOMContentLoaded",J,!1),a.removeEventListener("load",J,!1)):(y.detachEvent("onreadystatechange",J),a.detachEvent("onload",J))}function J(){(y.addEventListener||"load"===event.type||"complete"===y.readyState)&&(I(),m.ready())}m.ready.promise=function(b){if(!H)if(H=m.Deferred(),"complete"===y.readyState)setTimeout(m.ready);else if(y.addEventListener)y.addEventListener("DOMContentLoaded",J,!1),a.addEventListener("load",J,!1);else{y.attachEvent("onreadystatechange",J),a.attachEvent("onload",J);var c=!1;try{c=null==a.frameElement&&y.documentElement}catch(d){}c&&c.doScroll&&!function e(){if(!m.isReady){try{c.doScroll("left")}catch(a){return setTimeout(e,50)}I(),m.ready()}}()}return H.promise(b)};var K="undefined",L;for(L in m(k))break;k.ownLast="0"!==L,k.inlineBlockNeedsLayout=!1,m(function(){var a,b,c,d;c=y.getElementsByTagName("body")[0],c&&c.style&&(b=y.createElement("div"),d=y.createElement("div"),d.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",c.appendChild(d).appendChild(b),typeof b.style.zoom!==K&&(b.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",k.inlineBlockNeedsLayout=a=3===b.offsetWidth,a&&(c.style.zoom=1)),c.removeChild(d))}),function(){var a=y.createElement("div");if(null==k.deleteExpando){k.deleteExpando=!0;try{delete a.test}catch(b){k.deleteExpando=!1}}a=null}(),m.acceptData=function(a){var b=m.noData[(a.nodeName+" ").toLowerCase()],c=+a.nodeType||1;return 1!==c&&9!==c?!1:!b||b!==!0&&a.getAttribute("classid")===b};var M=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,N=/([A-Z])/g;function O(a,b,c){if(void 0===c&&1===a.nodeType){var d="data-"+b.replace(N,"-$1").toLowerCase();if(c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:M.test(c)?m.parseJSON(c):c}catch(e){}m.data(a,b,c)}else c=void 0}return c}function P(a){var b;for(b in a)if(("data"!==b||!m.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h; -if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthh;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML="
    a",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function ab(){return!0}function bb(){return!1}function cb(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m._data(a);if(r){c.handler&&(i=c,c=i.handler,e=i.selector),c.guid||(c.guid=m.guid++),(g=r.events)||(g=r.events={}),(k=r.handle)||(k=r.handle=function(a){return typeof m===K||a&&m.event.triggered===a.type?void 0:m.event.dispatch.apply(k.elem,arguments)},k.elem=a),b=(b||"").match(E)||[""],h=b.length;while(h--)f=_.exec(b[h])||[],o=q=f[1],p=(f[2]||"").split(".").sort(),o&&(j=m.event.special[o]||{},o=(e?j.delegateType:j.bindType)||o,j=m.event.special[o]||{},l=m.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&m.expr.match.needsContext.test(e),namespace:p.join(".")},i),(n=g[o])||(n=g[o]=[],n.delegateCount=0,j.setup&&j.setup.call(a,d,p,k)!==!1||(a.addEventListener?a.addEventListener(o,k,!1):a.attachEvent&&a.attachEvent("on"+o,k))),j.add&&(j.add.call(a,l),l.handler.guid||(l.handler.guid=c.guid)),e?n.splice(n.delegateCount++,0,l):n.push(l),m.event.global[o]=!0);a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,n,o,p,q,r=m.hasData(a)&&m._data(a);if(r&&(k=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=_.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=m.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,n=k[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=n.length;while(f--)g=n[f],!e&&q!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(n.splice(f,1),g.selector&&n.delegateCount--,l.remove&&l.remove.call(a,g));i&&!n.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||m.removeEvent(a,o,r.handle),delete k[o])}else for(o in k)m.event.remove(a,o+b[j],c,d,!0);m.isEmptyObject(k)&&(delete r.handle,m._removeData(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,o=[d||y],p=j.call(b,"type")?b.type:b,q=j.call(b,"namespace")?b.namespace.split("."):[];if(h=l=d=d||y,3!==d.nodeType&&8!==d.nodeType&&!$.test(p+m.event.triggered)&&(p.indexOf(".")>=0&&(q=p.split("."),p=q.shift(),q.sort()),g=p.indexOf(":")<0&&"on"+p,b=b[m.expando]?b:new m.Event(p,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=q.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+q.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:m.makeArray(c,[b]),k=m.event.special[p]||{},e||!k.trigger||k.trigger.apply(d,c)!==!1)){if(!e&&!k.noBubble&&!m.isWindow(d)){for(i=k.delegateType||p,$.test(i+p)||(h=h.parentNode);h;h=h.parentNode)o.push(h),l=h;l===(d.ownerDocument||y)&&o.push(l.defaultView||l.parentWindow||a)}n=0;while((h=o[n++])&&!b.isPropagationStopped())b.type=n>1?i:k.bindType||p,f=(m._data(h,"events")||{})[b.type]&&m._data(h,"handle"),f&&f.apply(h,c),f=g&&h[g],f&&f.apply&&m.acceptData(h)&&(b.result=f.apply(h,c),b.result===!1&&b.preventDefault());if(b.type=p,!e&&!b.isDefaultPrevented()&&(!k._default||k._default.apply(o.pop(),c)===!1)&&m.acceptData(d)&&g&&d[p]&&!m.isWindow(d)){l=d[g],l&&(d[g]=null),m.event.triggered=p;try{d[p]()}catch(r){}m.event.triggered=void 0,l&&(d[g]=l)}return b.result}},dispatch:function(a){a=m.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(m._data(this,"events")||{})[a.type]||[],k=m.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=m.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,g=0;while((e=f.handlers[g++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(e.namespace))&&(a.handleObj=e,a.data=e.data,c=((m.event.special[e.origType]||{}).handle||e.handler).apply(f.elem,i),void 0!==c&&(a.result=c)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!=this;i=i.parentNode||this)if(1===i.nodeType&&(i.disabled!==!0||"click"!==a.type)){for(e=[],f=0;h>f;f++)d=b[f],c=d.selector+" ",void 0===e[c]&&(e[c]=d.needsContext?m(c,this).index(i)>=0:m.find(c,this,null,[i]).length),e[c]&&e.push(d);e.length&&g.push({elem:i,handlers:e})}return h]","i"),hb=/^\s+/,ib=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,jb=/<([\w:]+)/,kb=/\s*$/g,rb={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:k.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]},sb=db(y),tb=sb.appendChild(y.createElement("div"));rb.optgroup=rb.option,rb.tbody=rb.tfoot=rb.colgroup=rb.caption=rb.thead,rb.th=rb.td;function ub(a,b){var c,d,e=0,f=typeof a.getElementsByTagName!==K?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==K?a.querySelectorAll(b||"*"):void 0;if(!f)for(f=[],c=a.childNodes||a;null!=(d=c[e]);e++)!b||m.nodeName(d,b)?f.push(d):m.merge(f,ub(d,b));return void 0===b||b&&m.nodeName(a,b)?m.merge([a],f):f}function vb(a){W.test(a.type)&&(a.defaultChecked=a.checked)}function wb(a,b){return m.nodeName(a,"table")&&m.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function xb(a){return a.type=(null!==m.find.attr(a,"type"))+"/"+a.type,a}function yb(a){var b=pb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function zb(a,b){for(var c,d=0;null!=(c=a[d]);d++)m._data(c,"globalEval",!b||m._data(b[d],"globalEval"))}function Ab(a,b){if(1===b.nodeType&&m.hasData(a)){var c,d,e,f=m._data(a),g=m._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;e>d;d++)m.event.add(b,c,h[c][d])}g.data&&(g.data=m.extend({},g.data))}}function Bb(a,b){var c,d,e;if(1===b.nodeType){if(c=b.nodeName.toLowerCase(),!k.noCloneEvent&&b[m.expando]){e=m._data(b);for(d in e.events)m.removeEvent(b,d,e.handle);b.removeAttribute(m.expando)}"script"===c&&b.text!==a.text?(xb(b).text=a.text,yb(b)):"object"===c?(b.parentNode&&(b.outerHTML=a.outerHTML),k.html5Clone&&a.innerHTML&&!m.trim(b.innerHTML)&&(b.innerHTML=a.innerHTML)):"input"===c&&W.test(a.type)?(b.defaultChecked=b.checked=a.checked,b.value!==a.value&&(b.value=a.value)):"option"===c?b.defaultSelected=b.selected=a.defaultSelected:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}}m.extend({clone:function(a,b,c){var d,e,f,g,h,i=m.contains(a.ownerDocument,a);if(k.html5Clone||m.isXMLDoc(a)||!gb.test("<"+a.nodeName+">")?f=a.cloneNode(!0):(tb.innerHTML=a.outerHTML,tb.removeChild(f=tb.firstChild)),!(k.noCloneEvent&&k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||m.isXMLDoc(a)))for(d=ub(f),h=ub(a),g=0;null!=(e=h[g]);++g)d[g]&&Bb(e,d[g]);if(b)if(c)for(h=h||ub(a),d=d||ub(f),g=0;null!=(e=h[g]);g++)Ab(e,d[g]);else Ab(a,f);return d=ub(f,"script"),d.length>0&&zb(d,!i&&ub(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,l,n=a.length,o=db(b),p=[],q=0;n>q;q++)if(f=a[q],f||0===f)if("object"===m.type(f))m.merge(p,f.nodeType?[f]:f);else if(lb.test(f)){h=h||o.appendChild(b.createElement("div")),i=(jb.exec(f)||["",""])[1].toLowerCase(),l=rb[i]||rb._default,h.innerHTML=l[1]+f.replace(ib,"<$1>")+l[2],e=l[0];while(e--)h=h.lastChild;if(!k.leadingWhitespace&&hb.test(f)&&p.push(b.createTextNode(hb.exec(f)[0])),!k.tbody){f="table"!==i||kb.test(f)?""!==l[1]||kb.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;while(e--)m.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j)}m.merge(p,h.childNodes),h.textContent="";while(h.firstChild)h.removeChild(h.firstChild);h=o.lastChild}else p.push(b.createTextNode(f));h&&o.removeChild(h),k.appendChecked||m.grep(ub(p,"input"),vb),q=0;while(f=p[q++])if((!d||-1===m.inArray(f,d))&&(g=m.contains(f.ownerDocument,f),h=ub(o.appendChild(f),"script"),g&&zb(h),c)){e=0;while(f=h[e++])ob.test(f.type||"")&&c.push(f)}return h=null,o},cleanData:function(a,b){for(var d,e,f,g,h=0,i=m.expando,j=m.cache,l=k.deleteExpando,n=m.event.special;null!=(d=a[h]);h++)if((b||m.acceptData(d))&&(f=d[i],g=f&&j[f])){if(g.events)for(e in g.events)n[e]?m.event.remove(d,e):m.removeEvent(d,e,g.handle);j[f]&&(delete j[f],l?delete d[i]:typeof d.removeAttribute!==K?d.removeAttribute(i):d[i]=null,c.push(f))}}}),m.fn.extend({text:function(a){return V(this,function(a){return void 0===a?m.text(this):this.empty().append((this[0]&&this[0].ownerDocument||y).createTextNode(a))},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=wb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?m.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||m.cleanData(ub(c)),c.parentNode&&(b&&m.contains(c.ownerDocument,c)&&zb(ub(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){1===a.nodeType&&m.cleanData(ub(a,!1));while(a.firstChild)a.removeChild(a.firstChild);a.options&&m.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return m.clone(this,a,b)})},html:function(a){return V(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a)return 1===b.nodeType?b.innerHTML.replace(fb,""):void 0;if(!("string"!=typeof a||mb.test(a)||!k.htmlSerialize&&gb.test(a)||!k.leadingWhitespace&&hb.test(a)||rb[(jb.exec(a)||["",""])[1].toLowerCase()])){a=a.replace(ib,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(m.cleanData(ub(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,m.cleanData(ub(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,n=this,o=l-1,p=a[0],q=m.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&nb.test(p))return this.each(function(c){var d=n.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(i=m.buildFragment(a,this[0].ownerDocument,!1,this),c=i.firstChild,1===i.childNodes.length&&(i=c),c)){for(g=m.map(ub(i,"script"),xb),f=g.length;l>j;j++)d=i,j!==o&&(d=m.clone(d,!0,!0),f&&m.merge(g,ub(d,"script"))),b.call(this[j],d,j);if(f)for(h=g[g.length-1].ownerDocument,m.map(g,yb),j=0;f>j;j++)d=g[j],ob.test(d.type||"")&&!m._data(d,"globalEval")&&m.contains(h,d)&&(d.src?m._evalUrl&&m._evalUrl(d.src):m.globalEval((d.text||d.textContent||d.innerHTML||"").replace(qb,"")));i=c=null}return this}}),m.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){m.fn[a]=function(a){for(var c,d=0,e=[],g=m(a),h=g.length-1;h>=d;d++)c=d===h?this:this.clone(!0),m(g[d])[b](c),f.apply(e,c.get());return this.pushStack(e)}});var Cb,Db={};function Eb(b,c){var d,e=m(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:m.css(e[0],"display");return e.detach(),f}function Fb(a){var b=y,c=Db[a];return c||(c=Eb(a,b),"none"!==c&&c||(Cb=(Cb||m("