From 13bc0bd8f017d17a1fb0c2197cce09050b8f1384 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Tue, 28 Oct 2025 16:22:25 +0100 Subject: [PATCH] feat: switch to new CLI parser --- composer.json | 4 +- composer.lock | 547 +++++++++++++++++++++++----------------- phpdraft | 99 +------- src/PHPDraft/In/CLI.php | 110 ++++++++ 4 files changed, 434 insertions(+), 326 deletions(-) create mode 100644 src/PHPDraft/In/CLI.php diff --git a/composer.json b/composer.json index 393fb2a..3b72aea 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,6 @@ ], "require": { "php": "^8.1", - "vanilla/garden-cli": "~4.0", "michelf/php-markdown": "~2.0", "lukasoppermann/http-status": "~4.0", "ext-json": "*", @@ -27,7 +26,8 @@ "twig/twig": "^3.0", "twig/markdown-extra": "^3.0", "matthiasmullie/minify": "^1.3", - "rize/uri-template": "*" + "rize/uri-template": "*", + "splitbrain/php-cli": "^1.3" }, "require-dev": { "lunr/halo": "~0.11.0", diff --git a/composer.lock b/composer.lock index 491663e..0fd9ae0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e5e970b0aeb650a88b05e939faa17874", + "content-hash": "9e15bc4af7c7e4caf95a3c695199d35f", "packages": [ { "name": "lukasoppermann/http-status", @@ -243,56 +243,6 @@ }, "time": "2022-09-26T12:21:08+00:00" }, - { - "name": "psr/log", - "version": "3.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/3.0.2" - }, - "time": "2024-09-11T13:17:53+00:00" - }, { "name": "rize/uri-template", "version": "0.4.0", @@ -357,6 +307,61 @@ ], "time": "2024-11-27T12:13:42+00:00" }, + { + "name": "splitbrain/php-cli", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/splitbrain/php-cli.git", + "reference": "4e669f38f660b0e9f76ed14dda7f12bff390f94f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/splitbrain/php-cli/zipball/4e669f38f660b0e9f76ed14dda7f12bff390f94f", + "reference": "4e669f38f660b0e9f76ed14dda7f12bff390f94f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "^8" + }, + "suggest": { + "psr/log": "Allows you to make the CLI available as PSR-3 logger" + }, + "type": "library", + "autoload": { + "psr-4": { + "splitbrain\\phpcli\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Gohr", + "email": "andi@splitbrain.org" + } + ], + "description": "Easy command line scripts for PHP with opt parsing and color output. No dependencies", + "keywords": [ + "argparse", + "cli", + "command line", + "console", + "getopt", + "optparse", + "terminal" + ], + "support": { + "issues": "https://github.com/splitbrain/php-cli/issues", + "source": "https://github.com/splitbrain/php-cli/tree/1.3.4" + }, + "time": "2025-03-15T09:02:01+00:00" + }, { "name": "symfony/deprecation-contracts", "version": "v3.6.0", @@ -426,7 +431,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -485,7 +490,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" }, "funding": [ { @@ -496,6 +501,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -505,7 +514,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -566,7 +575,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.33.0" }, "funding": [ { @@ -577,6 +586,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -734,61 +747,6 @@ } ], "time": "2025-05-03T07:21:55+00:00" - }, - { - "name": "vanilla/garden-cli", - "version": "v4.0", - "source": { - "type": "git", - "url": "https://github.com/vanilla/garden-cli.git", - "reference": "e7e2f655b04661e9808ec7d51a381176e9bc981d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/vanilla/garden-cli/zipball/e7e2f655b04661e9808ec7d51a381176e9bc981d", - "reference": "e7e2f655b04661e9808ec7d51a381176e9bc981d", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=8.1", - "psr/log": "^3.0" - }, - "require-dev": { - "ergebnis/composer-normalize": "^2.8", - "phpdocumentor/reflection-docblock": "^5.3", - "phpunit/phpunit": "^8", - "vanilla/garden-container": "^3.0", - "vanilla/standards": "^1.3", - "vimeo/psalm": "^4.0" - }, - "suggest": { - "ext-pdo": "Required for the DbUtils class.", - "phpdocumentor/reflection-docblock": "Required for the CliApplication functionality.", - "vanilla/garden-container": "Required for the CliApplication functionality." - }, - "type": "library", - "autoload": { - "psr-4": { - "Garden\\Cli\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Todd Burry", - "email": "todd@vanillaforums.com" - } - ], - "description": "A full-featured, yet ridiculously simple commandline parser for your next php cli script. Stop fighting with getopt().", - "support": { - "issues": "https://github.com/vanilla/garden-cli/issues", - "source": "https://github.com/vanilla/garden-cli/tree/v4.0" - }, - "time": "2023-01-24T20:33:46+00:00" } ], "packages-dev": [ @@ -840,16 +798,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.3", + "version": "1.13.4", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "faed855a7b5f4d4637717c2b3863e277116beb36" + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/faed855a7b5f4d4637717c2b3863e277116beb36", - "reference": "faed855a7b5f4d4637717c2b3863e277116beb36", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", "shasum": "" }, "require": { @@ -888,7 +846,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.3" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" }, "funding": [ { @@ -896,20 +854,20 @@ "type": "tidelift" } ], - "time": "2025-07-05T12:25:42+00:00" + "time": "2025-08-01T08:46:24+00:00" }, { "name": "nikic/php-parser", - "version": "v5.5.0", + "version": "v5.6.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "ae59794362fe85e051a58ad36b289443f57be7a9" + "reference": "3a454ca033b9e06b63282ce19562e892747449bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ae59794362fe85e051a58ad36b289443f57be7a9", - "reference": "ae59794362fe85e051a58ad36b289443f57be7a9", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3a454ca033b9e06b63282ce19562e892747449bb", + "reference": "3a454ca033b9e06b63282ce19562e892747449bb", "shasum": "" }, "require": { @@ -928,7 +886,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.0-dev" + "dev-master": "5.x-dev" } }, "autoload": { @@ -952,9 +910,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v5.5.0" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.2" }, - "time": "2025-05-31T08:24:38+00:00" + "time": "2025-10-21T19:32:17+00:00" }, { "name": "phar-io/manifest", @@ -1076,16 +1034,16 @@ }, { "name": "phing/phing", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/phingofficial/phing.git", - "reference": "96d3b6f37b6b63a710ae7daf1c50b5c28151e695" + "reference": "816739d12a48e1b630a159d1885e04dd54bf80b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/96d3b6f37b6b63a710ae7daf1c50b5c28151e695", - "reference": "96d3b6f37b6b63a710ae7daf1c50b5c28151e695", + "url": "https://api.github.com/repos/phingofficial/phing/zipball/816739d12a48e1b630a159d1885e04dd54bf80b6", + "reference": "816739d12a48e1b630a159d1885e04dd54bf80b6", "shasum": "" }, "require": { @@ -1094,10 +1052,12 @@ "ext-libxml": "*", "ext-simplexml": "*", "ext-xml": "*", - "php": ">= 7.4", - "sebastian/version": "^3.0|^4.0|^5.0", - "symfony/console": "^5.3.10|^6.0|^7.0", - "symfony/yaml": "^5.0|^6.0|^7.0" + "php": ">= 8.1", + "sebastian/version": "^3.0|^4.0|^5.0|^6.0", + "symfony/console": "^6.4.22|^7.0", + "symfony/filesystem": "^5.4.45|^6.4", + "symfony/string": "^6.3.12", + "symfony/yaml": "^6.3.12" }, "replace": { "phing/task-analyzers": "self.version", @@ -1138,12 +1098,13 @@ "ext-xsl": "*", "ext-zip": "*", "friendsofphp/php-cs-fixer": "^3.0", - "guzzlehttp/guzzle": "^7.2", + "guzzlehttp/guzzle": "^7.9", + "guzzlehttp/promises": "^2.0.3", "jawira/plantuml-client": "^1.0", "jawira/plantuml-encoding": "^1.0", "mehr-als-nix/parallel": "^v1.0", "mikey179/vfsstream": "2.0.x-dev", - "monolog/monolog": "^2.2", + "monolog/monolog": "^3.9", "pdepend/pdepend": "^2.9", "pear/archive_tar": "^1.4", "pear/console_getopt": "^v1.4.3", @@ -1157,13 +1118,13 @@ "pear/versioncontrol_svn": "^0.7.0", "phing/phing-composer-configurator": "dev-master", "phpmd/phpmd": "^2.14", - "phpstan/phpstan": "^0.12.87 || ^1.0", - "phpunit/phpunit": "^9.5.10", + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^9.6.21", "psr/http-message": "^2.0", "roave/security-advisories": "dev-master", - "scssphp/scssphp": "^1.13", + "scssphp/scssphp": "^2.0", "siad007/versioncontrol_hg": "^1.0", - "smarty/smarty": "^5.0", + "smarty/smarty": "^5.4.2", "squizlabs/php_codesniffer": "^3.5", "symfony/config": "^5.2|^6.0", "symfony/dependency-injection": "^5.2|^6.0", @@ -1354,7 +1315,7 @@ "type": "patreon" } ], - "time": "2024-12-04T19:56:50+00:00" + "time": "2025-07-25T18:55:19+00:00" }, { "name": "phpstan/extension-installer", @@ -1406,16 +1367,11 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.27", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpstan.git", - "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162" - }, + "version": "1.12.32", "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a6e423c076ab39dfedc307e2ac627ef579db162", - "reference": "3a6e423c076ab39dfedc307e2ac627ef579db162", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/2770dcdf5078d0b0d53f94317e06affe88419aa8", + "reference": "2770dcdf5078d0b0d53f94317e06affe88419aa8", "shasum": "" }, "require": { @@ -1460,7 +1416,7 @@ "type": "github" } ], - "time": "2025-05-21T20:51:45+00:00" + "time": "2025-09-30T10:16:31+00:00" }, { "name": "phpstan/phpstan-deprecation-rules", @@ -1612,16 +1568,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "11.0.10", + "version": "11.0.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1a800a7446add2d79cc6b3c01c45381810367d76" + "reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1a800a7446add2d79cc6b3c01c45381810367d76", - "reference": "1a800a7446add2d79cc6b3c01c45381810367d76", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4", + "reference": "4f7722aa9a7b76aa775e2d9d4e95d1ea16eeeef4", "shasum": "" }, "require": { @@ -1678,7 +1634,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/show" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/11.0.11" }, "funding": [ { @@ -1698,7 +1654,7 @@ "type": "tidelift" } ], - "time": "2025-06-18T08:56:18+00:00" + "time": "2025-08-27T14:37:49+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1947,16 +1903,16 @@ }, { "name": "phpunit/phpunit", - "version": "11.5.27", + "version": "11.5.42", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "446d43867314781df7e9adf79c3ec7464956fd8f" + "reference": "1c6cb5dfe412af3d0dfd414cfd110e3b9cfdbc3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/446d43867314781df7e9adf79c3ec7464956fd8f", - "reference": "446d43867314781df7e9adf79c3ec7464956fd8f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1c6cb5dfe412af3d0dfd414cfd110e3b9cfdbc3c", + "reference": "1c6cb5dfe412af3d0dfd414cfd110e3b9cfdbc3c", "shasum": "" }, "require": { @@ -1966,24 +1922,24 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.13.3", + "myclabs/deep-copy": "^1.13.4", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.2", - "phpunit/php-code-coverage": "^11.0.10", + "phpunit/php-code-coverage": "^11.0.11", "phpunit/php-file-iterator": "^5.1.0", "phpunit/php-invoker": "^5.0.1", "phpunit/php-text-template": "^4.0.1", "phpunit/php-timer": "^7.0.1", "sebastian/cli-parser": "^3.0.2", "sebastian/code-unit": "^3.0.3", - "sebastian/comparator": "^6.3.1", + "sebastian/comparator": "^6.3.2", "sebastian/diff": "^6.0.2", "sebastian/environment": "^7.2.1", - "sebastian/exporter": "^6.3.0", + "sebastian/exporter": "^6.3.2", "sebastian/global-state": "^7.0.2", "sebastian/object-enumerator": "^6.0.1", - "sebastian/type": "^5.1.2", + "sebastian/type": "^5.1.3", "sebastian/version": "^5.0.2", "staabm/side-effects-detector": "^1.0.5" }, @@ -2028,7 +1984,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.27" + "source": "https://github.com/sebastianbergmann/phpunit/tree/11.5.42" }, "funding": [ { @@ -2052,7 +2008,7 @@ "type": "tidelift" } ], - "time": "2025-07-11T04:10:06+00:00" + "time": "2025-09-28T12:09:13+00:00" }, { "name": "psr/container", @@ -2279,16 +2235,16 @@ }, { "name": "sebastian/comparator", - "version": "6.3.1", + "version": "6.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959" + "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/24b8fbc2c8e201bb1308e7b05148d6ab393b6959", - "reference": "24b8fbc2c8e201bb1308e7b05148d6ab393b6959", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/85c77556683e6eee4323e4c5468641ca0237e2e8", + "reference": "85c77556683e6eee4323e4c5468641ca0237e2e8", "shasum": "" }, "require": { @@ -2347,15 +2303,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", "security": "https://github.com/sebastianbergmann/comparator/security/policy", - "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.1" + "source": "https://github.com/sebastianbergmann/comparator/tree/6.3.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" } ], - "time": "2025-03-07T06:57:01+00:00" + "time": "2025-08-10T08:07:46+00:00" }, { "name": "sebastian/complexity", @@ -2560,16 +2528,16 @@ }, { "name": "sebastian/exporter", - "version": "6.3.0", + "version": "6.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3" + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/3473f61172093b2da7de1fb5782e1f24cc036dc3", - "reference": "3473f61172093b2da7de1fb5782e1f24cc036dc3", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74", + "reference": "70a298763b40b213ec087c51c739efcaa90bcd74", "shasum": "" }, "require": { @@ -2583,7 +2551,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "6.1-dev" + "dev-main": "6.3-dev" } }, "autoload": { @@ -2626,15 +2594,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.0" + "source": "https://github.com/sebastianbergmann/exporter/tree/6.3.2" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/exporter", + "type": "tidelift" } ], - "time": "2024-12-05T09:17:50+00:00" + "time": "2025-09-24T06:12:51+00:00" }, { "name": "sebastian/global-state", @@ -2872,23 +2852,23 @@ }, { "name": "sebastian/recursion-context", - "version": "6.0.2", + "version": "6.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "694d156164372abbd149a4b85ccda2e4670c0e16" + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/694d156164372abbd149a4b85ccda2e4670c0e16", - "reference": "694d156164372abbd149a4b85ccda2e4670c0e16", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc", + "reference": "f6458abbf32a6c8174f8f26261475dc133b3d9dc", "shasum": "" }, "require": { "php": ">=8.2" }, "require-dev": { - "phpunit/phpunit": "^11.0" + "phpunit/phpunit": "^11.3" }, "type": "library", "extra": { @@ -2924,28 +2904,40 @@ "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", "security": "https://github.com/sebastianbergmann/recursion-context/security/policy", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.2" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/6.0.3" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" } ], - "time": "2024-07-03T05:10:34+00:00" + "time": "2025-08-13T04:42:22+00:00" }, { "name": "sebastian/type", - "version": "5.1.2", + "version": "5.1.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "a8a7e30534b0eb0c77cd9d07e82de1a114389f5e" + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/a8a7e30534b0eb0c77cd9d07e82de1a114389f5e", - "reference": "a8a7e30534b0eb0c77cd9d07e82de1a114389f5e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449", + "reference": "f77d2d4e78738c98d9a68d2596fe5e8fa380f449", "shasum": "" }, "require": { @@ -2981,15 +2973,27 @@ "support": { "issues": "https://github.com/sebastianbergmann/type/issues", "security": "https://github.com/sebastianbergmann/type/security/policy", - "source": "https://github.com/sebastianbergmann/type/tree/5.1.2" + "source": "https://github.com/sebastianbergmann/type/tree/5.1.3" }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/type", + "type": "tidelift" } ], - "time": "2025-03-18T13:35:50+00:00" + "time": "2025-08-09T06:55:48+00:00" }, { "name": "sebastian/version", @@ -3099,24 +3103,23 @@ }, { "name": "symfony/console", - "version": "v7.3.1", + "version": "v7.2.9", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "9e27aecde8f506ba0fd1d9989620c04a87697101" + "reference": "93518c2ff7ce9c1818224c6effed3cf2429c63d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/9e27aecde8f506ba0fd1d9989620c04a87697101", - "reference": "9e27aecde8f506ba0fd1d9989620c04a87697101", + "url": "https://api.github.com/repos/symfony/console/zipball/93518c2ff7ce9c1818224c6effed3cf2429c63d7", + "reference": "93518c2ff7ce9c1818224c6effed3cf2429c63d7", "shasum": "" }, "require": { "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-mbstring": "~1.0", "symfony/service-contracts": "^2.5|^3", - "symfony/string": "^7.2" + "symfony/string": "^6.4|^7.0" }, "conflict": { "symfony/dependency-injection": "<6.4", @@ -3173,7 +3176,77 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v7.3.1" + "source": "https://github.com/symfony/console/tree/v7.2.9" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-07-30T17:03:27+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v6.4.24", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "75ae2edb7cdcc0c53766c30b0a2512b8df574bd8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/75ae2edb7cdcc0c53766c30b0a2512b8df574bd8", + "reference": "75ae2edb7cdcc0c53766c30b0a2512b8df574bd8", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.8" + }, + "require-dev": { + "symfony/process": "^5.4|^6.4|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides basic utilities for the filesystem", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/filesystem/tree/v6.4.24" }, "funding": [ { @@ -3184,25 +3257,29 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-06-27T19:55:54+00:00" + "time": "2025-07-10T08:14:14+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", - "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70", + "reference": "380872130d3a5dd3ace2f4010d95125fde5d5c70", "shasum": "" }, "require": { @@ -3251,7 +3328,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.33.0" }, "funding": [ { @@ -3262,16 +3339,20 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-06-27T09:58:17+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -3332,7 +3413,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.32.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.33.0" }, "funding": [ { @@ -3343,6 +3424,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -3435,20 +3520,20 @@ }, { "name": "symfony/string", - "version": "v7.3.0", + "version": "v6.4.26", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "f3570b8c61ca887a9e2938e85cb6458515d2b125" + "reference": "5621f039a71a11c87c106c1c598bdcd04a19aeea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/f3570b8c61ca887a9e2938e85cb6458515d2b125", - "reference": "f3570b8c61ca887a9e2938e85cb6458515d2b125", + "url": "https://api.github.com/repos/symfony/string/zipball/5621f039a71a11c87c106c1c598bdcd04a19aeea", + "reference": "5621f039a71a11c87c106c1c598bdcd04a19aeea", "shasum": "" }, "require": { - "php": ">=8.2", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-intl-grapheme": "~1.0", "symfony/polyfill-intl-normalizer": "~1.0", @@ -3458,12 +3543,10 @@ "symfony/translation-contracts": "<2.5" }, "require-dev": { - "symfony/emoji": "^7.1", - "symfony/error-handler": "^6.4|^7.0", - "symfony/http-client": "^6.4|^7.0", - "symfony/intl": "^6.4|^7.0", + "symfony/http-client": "^5.4|^6.0|^7.0", + "symfony/intl": "^6.2|^7.0", "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^6.4|^7.0" + "symfony/var-exporter": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -3502,7 +3585,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.3.0" + "source": "https://github.com/symfony/string/tree/v6.4.26" }, "funding": [ { @@ -3513,37 +3596,41 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-04-20T20:19:01+00:00" + "time": "2025-09-11T14:32:46+00:00" }, { "name": "symfony/yaml", - "version": "v7.3.1", + "version": "v6.4.26", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0c3555045a46ab3cd4cc5a69d161225195230edb" + "reference": "0fc8b966fd0dcaab544ae59bfc3a433f048c17b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0c3555045a46ab3cd4cc5a69d161225195230edb", - "reference": "0c3555045a46ab3cd4cc5a69d161225195230edb", + "url": "https://api.github.com/repos/symfony/yaml/zipball/0fc8b966fd0dcaab544ae59bfc3a433f048c17b0", + "reference": "0fc8b966fd0dcaab544ae59bfc3a433f048c17b0", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/deprecation-contracts": "^2.5|^3.0", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "symfony/console": "<6.4" + "symfony/console": "<5.4" }, "require-dev": { - "symfony/console": "^6.4|^7.0" + "symfony/console": "^5.4|^6.0|^7.0" }, "bin": [ "Resources/bin/yaml-lint" @@ -3574,7 +3661,7 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.3.1" + "source": "https://github.com/symfony/yaml/tree/v6.4.26" }, "funding": [ { @@ -3585,12 +3672,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2025-06-03T06:57:57+00:00" + "time": "2025-09-26T15:07:38+00:00" }, { "name": "theseer/autoload", diff --git a/phpdraft b/phpdraft index a146899..6c9afd0 100755 --- a/phpdraft +++ b/phpdraft @@ -10,109 +10,16 @@ set_include_path(get_include_path() . ":" . __DIR__ . '/src/'); */ require_once 'vendor/autoload.php'; -use Garden\Cli\Cli; -use PHPDraft\In\ApibFileParser; -use PHPDraft\Out\Sorting; -use PHPDraft\Out\Version; -use PHPDraft\Parse\ExecutionException; -use PHPDraft\Parse\ParserFactory; -use PHPDraft\Parse\ResourceException; +use PHPDraft\In\CLI; define('VERSION', '0'); //define('ID_STATIC', 'SOME_ID'); try { - // Define the cli options. $cli = new Cli(); - $cli->description('Parse API Blueprint files.') - ->opt('help:h', 'This help text', false) - ->opt('version:v', 'Print the version for PHPDraft.', false) - ->opt('file:f', 'Specifies the file to parse.', false) - ->opt('openapi:a', 'Output location for an OpenAPI file.', false) - ->opt('yes:y', 'Always accept using the online mode.', false, 'bool') - ->opt('online:o', 'Always use the online mode.', false, 'bool') - ->opt('template:t', 'Specifies the template to use. (defaults to \'default\').', false) - ->opt('sort:s', 'Sort displayed values [All|None|Structures|Webservices] (defaults to the way the objects are in the file).', false) - ->opt('header_image:i', 'Specifies an image to display in the header.', false) - ->opt('css:c', 'Specifies a CSS file to include (value is put in a link element without checking).', false) - ->opt('javascript:j', 'Specifies a JS file to include (value is put in a script element without checking).', false) - ->opt('debug-json-file', 'Input a rendered JSON file for debugging.', false) - ->opt('debug-json', 'Input a rendered JSON text for debugging.', false); - - // Parse and return cli args. - $args = $cli->parse($argv, FALSE); - if (isset($args['help']) || empty($args->getOpts())) { - $cli->writeHelp(); - throw new ExecutionException('', 0); - } - if (isset($args['version'])) { - Version::version(); - throw new ExecutionException('', 0); - } - - stream_set_blocking(STDIN, false); - $stdin = stream_get_contents(STDIN); - $file = $args->getOpt('file'); - if (!empty($stdin) && $file !== NULL) { - throw new ExecutionException('ERROR: Passed data in both file and stdin', 2); - } elseif (!empty($stdin) && $file === NULL) { - $file = tempnam(sys_get_temp_dir(), 'phpdraft'); - file_put_contents($file, $stdin); - } - if ($file === NULL || $file === '') - { - throw new ExecutionException('ERROR: File does not exist', 200); - } - - if (!($file !== NULL || isset($args['debug-json-file']) || isset($args['debug-json']))) { - throw new ExecutionException('Missing required option: file', 1); - } - - define('THIRD_PARTY_ALLOWED', getenv('PHPDRAFT_THIRD_PARTY') !== '0'); - if ((isset($args['y']) || isset($args['o'])) && THIRD_PARTY_ALLOWED) { - define('DRAFTER_ONLINE_MODE', 1); - } - - if (!isset($args['debug-json-file']) && !isset($args['debug-json'])) { - $apib_parser = new ApibFileParser($file); - $apib = $apib_parser->parse(); - $offline = FALSE; - $online = FALSE; - - try { - $parser = ParserFactory::getDrafter(); - $parser = $parser->init($apib); - $data = $parser->parseToJson(); - } catch (ResourceException $exception) { - throw new ExecutionException('No drafter available', 255); - } - } else { - $json_string = $args['debug-json'] ?? file_get_contents($args['debug-json-file']); - $data = json_decode($json_string); - } - - if (isset($args['openapi'])) { - $openapi = ParserFactory::getOpenAPI()->init($data); - $openapi->write($args['openapi']); - } - - $html = ParserFactory::getJson()->init($data); - $name = 'PHPD_SORT_' . strtoupper($args->getOpt('sort', '')); - $html->sorting = Sorting::${$name} ?? Sorting::PHPD_SORT_NONE->value; - - $color1 = getenv('COLOR_PRIMARY') === FALSE ? NULL : getenv('COLOR_PRIMARY'); - $color2 = getenv('COLOR_SECONDARY') === FALSE ? NULL : getenv('COLOR_SECONDARY'); - $colors = (is_null($color1) || is_null($color2)) ? '' : '__' . $color1 . '__' . $color2; - $html->build_html( - $args->getOpt('template', 'default') . $colors, - $args['header_image'], - $args['css'], - $args['javascript'] - ); - - echo $html; + $cli->run(); } -catch (ExecutionException|Exception $exception) +catch (Exception $exception) { file_put_contents('php://stderr', $exception->getMessage() . PHP_EOL); exit($exception->getCode()); diff --git a/src/PHPDraft/In/CLI.php b/src/PHPDraft/In/CLI.php new file mode 100644 index 0000000..a672ee7 --- /dev/null +++ b/src/PHPDraft/In/CLI.php @@ -0,0 +1,110 @@ +setHelp('Usage: phpdraft [options]'); + $options->registerOption('version', 'Print the version for PHPDraft.', 'v', false); + $options->registerOption('file', 'Specifies the file to parse.', 'f', true); + $options->registerOption('openapi', 'Output location for an OpenAPI file.', 'a', true); + $options->registerOption('html', 'Output location for the rendered HTML.', 'r', true); + $options->registerOption('yes', 'Always accept using the online mode.', 'y', true); + $options->registerOption('online', 'Always use the online mode.', 'o', false); + $options->registerOption('template', 'Specifies the template to use. (defaults to \'default\').', 't', true); + $options->registerOption('sort', 'Sort displayed values [All|None|Structures|Webservices] (defaults to the way the objects are in the file).', 's', true); + $options->registerOption('header-image', 'Specifies an image to display in the header.', 'i', true); + $options->registerOption('css', 'Specifies a CSS file to include (value is put in a link element without checking).', 'c', true); + $options->registerOption('javascript', 'Specifies a JS file to include (value is put in a script element without checking).', 'j', true); + $options->registerOption('debug-json-file', 'Input a rendered JSON file for debugging.', '', true); + $options->registerOption('debug-json', 'Input a rendered JSON text for debugging.', '', true); + } + + /** + * @throws ExecutionException + */ + protected function main(Options $options): void + { + $args = $options->getOpt(); + if ($options->getOpt('version', NULL) !== NULL) { + Version::version(); + throw new ExecutionException('', 0); + } + + stream_set_blocking(STDIN, false); + $stdin = stream_get_contents(STDIN); + $file = $options->getOpt('file', NULL); + if (!empty($stdin) && $file !== NULL) { + throw new ExecutionException('ERROR: Passed data in both file and stdin', 2); + } elseif (!empty($stdin) && $file === NULL) { + $file = tempnam(sys_get_temp_dir(), 'phpdraft'); + file_put_contents($file, $stdin); + } + if ($file === NULL || $file === '') + { + throw new ExecutionException('ERROR: File does not exist', 200); + } + + if (!($file !== NULL || $options->getOpt('debug-json-file') === FALSE || $options->getOpt('debug-json') === FALSE)) { + throw new ExecutionException('Missing required option: file', 1); + } + + define('THIRD_PARTY_ALLOWED', getenv('PHPDRAFT_THIRD_PARTY') !== '0'); + if ((isset($args['yes']) || isset($args['online'])) && THIRD_PARTY_ALLOWED) { + define('DRAFTER_ONLINE_MODE', 1); + } + + if (!isset($args['debug-json-file']) && !isset($args['debug-json'])) { + $apib_parser = new ApibFileParser($file); + $apib = $apib_parser->parse(); + + try { + $parser = ParserFactory::getDrafter(); + $parser = $parser->init($apib); + $data = $parser->parseToJson(); + } catch (ResourceException $exception) { + throw new ExecutionException('No drafter available', 255, $exception); + } + } else { + $json_string = $args['debug-json'] ?? file_get_contents($args['debug-json-file']); + $data = json_decode($json_string); + } + + if (isset($args['openapi'])) { + $openapi = ParserFactory::getOpenAPI()->init($data); + $openapi->write($args['openapi']); + } + + $html = ParserFactory::getJson()->init($data); + $name = 'PHPD_SORT_' . strtoupper($options->getOpt('sort', '')); + $html->sorting = Sorting::${$name} ?? Sorting::PHPD_SORT_NONE->value; + + $color1 = getenv('COLOR_PRIMARY') === FALSE ? NULL : getenv('COLOR_PRIMARY'); + $color2 = getenv('COLOR_SECONDARY') === FALSE ? NULL : getenv('COLOR_SECONDARY'); + $colors = (is_null($color1) || is_null($color2)) ? '' : '__' . $color1 . '__' . $color2; + $html->build_html( + $options->getOpt('template', 'default') . $colors, + $args['header-image'] ?? NULL, + $args['css'] ?? NULL, + $args['javascript'] ?? NULL, + ); + + if (isset($args['html'])) { + file_put_contents($args['html'], $html); + return; + } + + echo $html; + } +} \ No newline at end of file