diff --git a/composer.json b/composer.json index d88adc9..0041502 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,14 @@ "description": "Generate TypeScript interfaces from Laravel Models", "type": "library", "require": { +<<<<<<< HEAD "php": "^8.0|^8.1", "illuminate/support": "8.*|9.*" +======= + "php": "^8.0", + "illuminate/support": "8.*", + "vinyvicente/doctrine-point-type": "^2.3" +>>>>>>> 70f902a3a4e8a78d762eb6a6c906030b333deed0 }, "license": "MIT", "authors": [ diff --git a/composer.lock b/composer.lock index 76243d2..6cfc001 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,352 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "266436de886e7cf3e61d4e6752e3f21c", + "content-hash": "6aaa8bdb770c785ef3f534903164e725", "packages": [ + { + "name": "doctrine/cache", + "version": "2.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "331b4d5dbaeab3827976273e9356b3b453c300ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/331b4d5dbaeab3827976273e9356b3b453c300ce", + "reference": "331b4d5dbaeab3827976273e9356b3b453c300ce", + "shasum": "" + }, + "require": { + "php": "~7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "cache/integration-tests": "dev-master", + "doctrine/coding-standard": "^8.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "predis/predis": "~1.0", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "symfony/cache": "^4.4 || ^5.2 || ^6.0@dev", + "symfony/var-exporter": "^4.4 || ^5.2 || ^6.0@dev" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/2.1.1" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], + "time": "2021-07-17T14:49:29+00:00" + }, + { + "name": "doctrine/dbal", + "version": "2.13.2", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/8dd39d2ead4409ce652fd4f02621060f009ea5e4", + "reference": "8dd39d2ead4409ce652fd4f02621060f009ea5e4", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0|^2.0", + "doctrine/deprecations": "^0.5.3", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.1 || ^8" + }, + "require-dev": { + "doctrine/coding-standard": "9.0.0", + "jetbrains/phpstorm-stubs": "2020.2", + "phpstan/phpstan": "0.12.81", + "phpunit/phpunit": "^7.5.20|^8.5|9.5.5", + "squizlabs/php_codesniffer": "3.6.0", + "symfony/cache": "^4.4", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", + "vimeo/psalm": "4.6.4" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/doctrine/dbal/issues", + "source": "https://github.com/doctrine/dbal/tree/2.13.2" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fdbal", + "type": "tidelift" + } + ], + "time": "2021-06-18T21:48:39+00:00" + }, + { + "name": "doctrine/deprecations", + "version": "v0.5.3", + "source": { + "type": "git", + "url": "https://github.com/doctrine/deprecations.git", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/9504165960a1f83cc1480e2be1dd0a0478561314", + "reference": "9504165960a1f83cc1480e2be1dd0a0478561314", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0|^7.0|^8.0", + "phpunit/phpunit": "^7.0|^8.0|^9.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Allows logging deprecations via PSR-3 logger implementation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", + "homepage": "https://www.doctrine-project.org/", + "support": { + "issues": "https://github.com/doctrine/deprecations/issues", + "source": "https://github.com/doctrine/deprecations/tree/v0.5.3" + }, + "time": "2021-03-21T12:59:47+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/41370af6a30faa9dc0368c4a6814d596e81aba7f", + "reference": "41370af6a30faa9dc0368c4a6814d596e81aba7f", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/1.1.x" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fevent-manager", + "type": "tidelift" + } + ], + "time": "2020-05-29T18:28:51+00:00" + }, { "name": "doctrine/inflector", "version": "2.0.3", @@ -443,48 +787,176 @@ "homepage": "https://www.php-fig.org/" } ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" - }, - "time": "2021-03-05T17:36:06+00:00" + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.1" + }, + "time": "2021-03-05T17:36:06+00:00" + }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/master" + }, + "time": "2017-10-23T01:57:42+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.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": "2021-03-23T23:28:01+00:00" }, { - "name": "psr/simple-cache", - "version": "1.0.1", + "name": "symfony/polyfill-ctype", + "version": "v1.22.1", "source": { "type": "git", - "url": "https://github.com/php-fig/simple-cache.git", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", - "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-main": "1.22-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { "psr-4": { - "Psr\\SimpleCache\\": "src/" - } + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -492,22 +964,40 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Common interfaces for simple caching", + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", "keywords": [ - "cache", - "caching", - "psr", - "psr-16", - "simple-cache" + "compatibility", + "ctype", + "polyfill", + "portable" ], "support": { - "source": "https://github.com/php-fig/simple-cache/tree/master" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" }, - "time": "2017-10-23T01:57:42+00:00" + "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": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -672,6 +1162,108 @@ ], "time": "2021-01-07T16:49:33+00:00" }, + { + "name": "symfony/serializer", + "version": "v5.3.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/serializer.git", + "reference": "96f6ff6582d1bf1bf08281b563a6c7c917efe6c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/serializer/zipball/96f6ff6582d1bf1bf08281b563a6c7c917efe6c1", + "reference": "96f6ff6582d1bf1bf08281b563a6c7c917efe6c1", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-php80": "^1.15" + }, + "conflict": { + "doctrine/annotations": "<1.12", + "phpdocumentor/reflection-docblock": "<3.2.2", + "phpdocumentor/type-resolver": "<1.4.0", + "symfony/dependency-injection": "<4.4", + "symfony/property-access": "<4.4", + "symfony/property-info": "<5.3", + "symfony/yaml": "<4.4" + }, + "require-dev": { + "doctrine/annotations": "^1.12", + "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0", + "symfony/cache": "^4.4|^5.0", + "symfony/config": "^4.4|^5.0", + "symfony/dependency-injection": "^4.4|^5.0", + "symfony/error-handler": "^4.4|^5.0", + "symfony/filesystem": "^4.4|^5.0", + "symfony/form": "^4.4|^5.0", + "symfony/http-foundation": "^4.4|^5.0", + "symfony/http-kernel": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/property-access": "^4.4.9|^5.0.9", + "symfony/property-info": "^5.3", + "symfony/uid": "^5.1", + "symfony/validator": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0", + "symfony/var-exporter": "^4.4|^5.0", + "symfony/yaml": "^4.4|^5.0" + }, + "suggest": { + "psr/cache-implementation": "For using the metadata cache.", + "symfony/config": "For using the XML mapping loader.", + "symfony/mime": "For using a MIME type guesser within the DataUriNormalizer.", + "symfony/property-access": "For using the ObjectNormalizer.", + "symfony/property-info": "To deserialize relations.", + "symfony/var-exporter": "For using the metadata compiler.", + "symfony/yaml": "For using the default YAML mapping loader." + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Serializer\\": "" + }, + "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": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/serializer/tree/v5.3.2" + }, + "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": "2021-06-10T18:05:39+00:00" + }, { "name": "symfony/translation", "version": "v5.2.8", @@ -843,6 +1435,50 @@ ], "time": "2021-03-23T23:28:01+00:00" }, + { + "name": "vinyvicente/doctrine-point-type", + "version": "v2.3.0", + "source": { + "type": "git", + "url": "https://github.com/vinyvicente/doctrine-point-type.git", + "reference": "b15b10dc589810c7aef153b82a6c193226d29e35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/vinyvicente/doctrine-point-type/zipball/b15b10dc589810c7aef153b82a6c193226d29e35", + "reference": "b15b10dc589810c7aef153b82a6c193226d29e35", + "shasum": "" + }, + "require": { + "doctrine/dbal": "^2.5", + "php": ">=7.2", + "symfony/serializer": "^5.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Viny\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Vinicius", + "email": "vinyvicente@gmail.com" + } + ], + "support": { + "issues": "https://github.com/vinyvicente/doctrine-point-type/issues", + "source": "https://github.com/vinyvicente/doctrine-point-type/tree/v2.3.0" + }, + "time": "2021-04-07T13:49:33+00:00" + }, { "name": "voku/portable-ascii", "version": "1.5.6", @@ -2160,85 +2796,6 @@ ], "time": "2021-05-16T13:07:46+00:00" }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.22.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", - "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.22-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-01-07T16:49:33+00:00" - }, { "name": "symfony/polyfill-iconv", "version": "v1.22.1", diff --git a/readme.md b/readme.md index a87a0bd..d4d6dc8 100644 --- a/readme.md +++ b/readme.md @@ -75,5 +75,61 @@ public function getFirstNameAttribute(): string // <- this } ``` +### Custom Interfaces +If you have custom interfaces you are using for your models you can specify them in a reserved `interfaces` array +For example for a custom `Point` interface in a `Location` model you can put this in the model +```php +public array $interfaces = [ + 'coordinate' => [ + 'name' => 'Point', + 'import' => "@/types/api", + ], +]; +``` + +And it should generate: + +```ts +import { Point } from '@/types/api' + +export interface Location { + // columns + coordinate: Point +} +``` + +This will override all columns, mutators and relationships + +You can also specify an interface is nullable: + +```php + public array $interfaces = [ + 'choices' => [ + 'name' => 'ChoicesWithPivot', + 'import' => '@/types/api', + 'nullable' => true, + ], + ]; +``` + + +### Declare global +Generate your interfaces in a global namespace named `model` +```bash +artisn model:typer --global +``` + +```ts +export {} +declare global { + export namespace models { + + export interface Provider { + // columns + id: number + user_id: number + avatar?: string +... +``` diff --git a/src/Commands/ModelTyper.php b/src/Commands/ModelTyper.php index e3db1ed..bfdf662 100644 --- a/src/Commands/ModelTyper.php +++ b/src/Commands/ModelTyper.php @@ -4,6 +4,7 @@ use FumeApp\ModelTyper\ModelInterface; use Illuminate\Console\Command; +use ReflectionException; class ModelTyper extends Command { @@ -12,7 +13,7 @@ class ModelTyper extends Command * * @var string */ - protected $signature = 'model:typer'; + protected $signature = 'model:typer {--global}'; /** * The console command description. @@ -35,10 +36,11 @@ public function __construct() * Execute the console command. * * @return int + * @throws ReflectionException */ public function handle() { - echo (new ModelInterface())->generate(); + echo (new ModelInterface($this->option('global')))->generate(); return 0; } } diff --git a/src/ModelInterface.php b/src/ModelInterface.php index 1d9796f..c919ee9 100644 --- a/src/ModelInterface.php +++ b/src/ModelInterface.php @@ -5,31 +5,51 @@ use Exception; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use ReflectionClass; use ReflectionMethod; use ReflectionException; use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Types\Type; use Illuminate\Container\Container; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; use Illuminate\Support\Facades\File; +use Viny\PointType; class ModelInterface { - public array $mappings = [ 'bigint' => 'number', 'int' => 'number', 'integer' => 'number', 'text' => 'string', 'string' => 'string', + 'decimal' => 'number', 'datetime' => 'Date', + 'date' => 'Date', 'bool' => 'boolean', 'boolean' => 'boolean', 'json' => '[]', + 'array' => 'string[]', + 'point' => 'Point', ]; + public array $imports = []; + + private string $space = ''; + + + public function __construct( + private bool $global = false, + ) + { + Type::addType('point', PointType::class); + DB::getDoctrineSchemaManager() + ->getDatabasePlatform()->registerDoctrineTypeMapping('point', 'point'); + } + /** * Combine all instances together * @return string @@ -37,13 +57,45 @@ class ModelInterface */ public function generate(): string { - $allCode = ''; $models = $this->getModels(); + $allCode = $this->getImports($models); + + if ($this->global) { + $allCode .= "export {}\ndeclare global {\n export namespace models {\n\n"; + $this->space = ' '; + } + foreach ($models as $model) { $interface = $this->getInterface(new $model()); $allCode .= $this->getCode($interface); } - return $allCode; + if ($this->global) { + $allCode .= " }\n}\n\n"; + } + return substr($allCode, 0, strrpos($allCode, "\n")); + } + + /** + * Generate a list of imports from specified interfaces + * @param Collection $models + * @return string + */ + private function getImports(Collection $models): string { + $code = ''; + $imports = []; + foreach ($models as $model) { + if ($interfaces = (new $model())->interfaces) { + foreach ($interfaces as $interface) { + if (isset($interface['import'])) { + $imports[ $interface[ 'import' ] ][] = $interface[ 'name' ]; + } + } + } + } + foreach ($imports as $import=>$names) { + $code .= "import { " . join(', ', array_unique($names)) . " } from '$import'\n"; + } + return $code; } /** @@ -58,14 +110,17 @@ private function getInterface(Model $model): TypescriptInterface $columns = $this->getColumns($model); $mutators = $this->getMutators($model); $relations = $this->getRelations($model); + $interfaces = $this->getInterfaces($model, $columns, $mutators, $relations); return new TypescriptInterface( name: (new ReflectionClass($model))->getShortName(), columns: $columns, mutators: $mutators, relations: $relations, + interfaces: $interfaces, ); } + /** * Build TS code from an interface * @param TypescriptInterface $interface @@ -73,28 +128,34 @@ private function getInterface(Model $model): TypescriptInterface */ private function getCode(TypescriptInterface $interface): string { - $code = "export interface {$interface->name} {\n"; + $code = "{$this->space}export interface {$interface->name} {\n"; if (count($interface->columns) > 0) { - $code .= " // columns\n"; + $code .= "{$this->space} // columns\n"; foreach ($interface->columns as $key => $value) { - $code .= " {$key}: {$value}\n"; + $code .= "{$this->space} $key: $value\n"; } } if (count($interface->mutators) > 0) { - $code .= " // mutators\n"; + $code .= "{$this->space} // mutators\n"; foreach ($interface->mutators as $key => $value) { - $code .= " {$key}: {$value}\n"; + $code .= "{$this->space} $key: $value\n"; } } if (count($interface->relations) > 0) { - $code .= " // relations\n"; + $code .= "{$this->space} // relations\n"; foreach ($interface->relations as $key => $value) { - $code .= " {$key}: {$value}\n"; + $code .= "{$this->space} $key: $value\n"; } } - $code .= "}\n"; + if (count($interface->interfaces) > 0) { + $code .= "{$this->space} // interfaces\n"; + foreach ($interface->interfaces as $key => $value) { + $code .= "{$this->space} $key: $value\n"; + } + } + $code .= "{$this->space}}\n"; $plural = Str::plural($interface->name); - $code .= "export type $plural = Array<{$interface->name}>\n\n"; + $code .= "{$this->space}export type $plural = Array<{$interface->name}>\n\n"; return $code; } @@ -113,10 +174,21 @@ public function getRelations(Model $model): array foreach ($methods as $method) { $reflection = new ReflectionMethod($model, $method); if ($reflection->hasReturnType()) { + if ($model->interfaces) { + foreach ($model->interfaces as $key => $value) { + if ($key === $method) { + if (isset($value['nullable']) && $value['nullable'] === true) { + $relations[ $key . '?' ] = $value[ 'name' ]; + } else { + $relations[ $key ] = $value[ 'name' ]; + } + continue 2; + } + } + } $type = (string) $reflection->getReturnType(); $code = file($reflection->getFileName())[$reflection->getEndLine()-2]; preg_match('/\((.*?)::class/', $code, $matches); - if (strstr($type, 'or')) ray($type); if ($matches && $matches[1]) { if ($type === 'Illuminate\Database\Eloquent\Relations\BelongsTo' || @@ -158,6 +230,37 @@ public function getRelations(Model $model): array return $relations; } + /** + * Return any other remaining interfaces + * + * @param Model $model + * @param array $columns + * @param array $mutators + * @param array $relations + * @return array + */ + private function getInterfaces(Model $model, array $columns, array $mutators, array $relations): array + { + if (!isset($model->interfaces)) { + return []; + } + $interfaces = []; + foreach ($model->interfaces as $key=>$interface) { + if (array_key_exists($key, $columns) || array_key_exists($key . '?', $columns)) { + continue; + } + if (array_key_exists($key, $mutators) || array_key_exists($key . '?', $mutators)) { + continue; + } + if (array_key_exists($key, $relations) || array_key_exists($key . '?', $relations)) { + continue; + } + $interfaces[$key] = $interface['name']; + } + return $interfaces; + } + + /** * Find and map our get mutators * @param Model $model @@ -169,6 +272,12 @@ public function getMutators(Model $model): array $mutations = []; $mutators = $model->getMutatedAttributes(); foreach ($mutators as $mutator) { + + if (isset($model->interfaces) && isset($model->interfaces[$mutator])) { + $mutations[$mutator] = $model->interfaces[$mutator]['name']; + continue; + } + $method = 'get' . $this->camelize($mutator) . 'Attribute'; $reflection = new ReflectionMethod($model, $method); if (!$reflection->hasReturnType()) { @@ -207,11 +316,19 @@ private function getColumns(Model $model): array { $columns = []; foreach ($this->getColumnList($model) as $columnName) { + try { $column = $this->getColumn($model, $columnName); - + if (isset($model->interfaces) && isset($model->interfaces[$columnName])) { + if ($column->getNotnull()) { + $columns [ $columnName ] = $model->interfaces[ $columnName ][ 'name' ]; + } else { + $columns [ $columnName . '?' ] = $model->interfaces[ $columnName ][ 'name' ]; + } + continue; + } if (!isset($this->mappings[$column->getType()->getName()])) { - throw new Exception('Unknown type found: ' . $column->getType()->getName()); + throw new Exception('Unknown type found: ' . $column->getType()->getName()); } else { if ($column->getNotnull()) { $columns[ $columnName ] = $this->mappings[ $column->getType()->getName() ]; @@ -234,14 +351,11 @@ private function getColumns(Model $model): array */ private function getColumnList(Model $model): array { - try { - return $model->getConnection()->getSchemaBuilder()->getColumnListing($model->getTable()); - } catch (Exception $exception) { - } + return $model->getConnection()->getSchemaBuilder()->getColumnListing($model->getTable()); } -/** - * Get column details + /** + * Get column details * @param Model $model * @param string $column * @return Column diff --git a/src/TypescriptInterface.php b/src/TypescriptInterface.php index d793268..18e277f 100644 --- a/src/TypescriptInterface.php +++ b/src/TypescriptInterface.php @@ -9,6 +9,7 @@ public function __construct( public array $columns, public array $mutators, public array $relations, + public array $interfaces, ) { } }