From 6f0ffd4cf44767d3a04d6737b000c5aa6197a12c Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sat, 17 Apr 2021 09:47:56 +0200 Subject: [PATCH 01/10] Add interfaces WIP --- .idea/php.xml | 4 + .idea/wordpress-interface.iml | 4 + composer.json | 8 +- composer.lock | 410 +++++++++++++++++----- src/Acl/CapableUserInterface.php | 12 + src/Acl/PrivilegeInterface.php | 21 ++ src/Acl/RoleInterface.php | 20 ++ src/Entity/EntityInterface.php | 19 + src/Entity/EntityQueryInterface.php | 20 ++ src/Entity/EntityQueryResultInterface.php | 27 ++ src/Meta/MetaInterface.php | 12 + src/Meta/MetaQueryInterface.php | 131 +++++++ src/Post/PostInterface.php | 115 ++++++ src/Post/PostQueryInterface.php | 37 ++ src/Post/PostQueryResultInterface.php | 16 + src/Taxonomy/TaxonomyInterface.php | 28 ++ src/Taxonomy/TermInterface.php | 24 ++ src/Taxonomy/TermQueryInterface.php | 109 ++++++ src/Taxonomy/TermQueryResultInterface.php | 16 + src/User/UserInterface.php | 35 ++ src/User/UserQueryInterface.php | 42 +++ src/User/UserQueryResultInterface.php | 17 + 22 files changed, 1029 insertions(+), 98 deletions(-) create mode 100644 src/Acl/CapableUserInterface.php create mode 100644 src/Acl/PrivilegeInterface.php create mode 100644 src/Acl/RoleInterface.php create mode 100644 src/Entity/EntityInterface.php create mode 100644 src/Entity/EntityQueryInterface.php create mode 100644 src/Entity/EntityQueryResultInterface.php create mode 100644 src/Meta/MetaInterface.php create mode 100644 src/Meta/MetaQueryInterface.php create mode 100644 src/Post/PostInterface.php create mode 100644 src/Post/PostQueryInterface.php create mode 100644 src/Post/PostQueryResultInterface.php create mode 100644 src/Taxonomy/TaxonomyInterface.php create mode 100644 src/Taxonomy/TermInterface.php create mode 100644 src/Taxonomy/TermQueryInterface.php create mode 100644 src/Taxonomy/TermQueryResultInterface.php create mode 100644 src/User/UserInterface.php create mode 100644 src/User/UserQueryInterface.php create mode 100644 src/User/UserQueryResultInterface.php diff --git a/.idea/php.xml b/.idea/php.xml index d5e9721..f162a2c 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -56,6 +56,10 @@ + + + + diff --git a/.idea/wordpress-interface.iml b/.idea/wordpress-interface.iml index ea0aed4..4dc58d5 100644 --- a/.idea/wordpress-interface.iml +++ b/.idea/wordpress-interface.iml @@ -60,6 +60,10 @@ + + + + diff --git a/composer.json b/composer.json index 114136c..e3bb666 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,13 @@ "require": { "php": "^7.1 | ^8.0", "dhii/package-interface": "^0.1-alpha3", - "dhii/human-readable-interface": "^0.2.0-alpha1" + "dhii/human-readable-interface": "^0.2.0-alpha1", + "dhii/data-key-value-aware-interface": "^0.2", + "dhii/data-identifiable-interface": "^0.1", + "dhii/collections-interface": "^0.3-alpha4", + "psr/http-message": "^1.0", + "psr/container": "^1.0 | ^2.0", + "symfony/polyfill-php80": "^1.19" }, "require-dev": { "phpunit/phpunit": "^7.0 | ^8.0 | ^9.0", diff --git a/composer.lock b/composer.lock index 8858861..f9e862c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,169 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e116cda9dc45826575cbd30d4813241d", + "content-hash": "fe785150e2bf54e04c948c9ec7503f36", "packages": [ + { + "name": "dhii/collections-interface", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/Dhii/collections-interface.git", + "reference": "da334f75f6477ef7eecaf28df1d5253fe05684ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dhii/collections-interface/zipball/da334f75f6477ef7eecaf28df1d5253fe05684ee", + "reference": "da334f75f6477ef7eecaf28df1d5253fe05684ee", + "shasum": "" + }, + "require": { + "php": "^7.1 | ^8.0", + "psr/container": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.0 | ^8.0 | ^9.0", + "slevomat/coding-standard": "^6.0", + "vimeo/psalm": "^3.11.7 | ^4.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Dhii\\Collection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dhii Team", + "email": "development@dhii.co" + }, + { + "name": "Anton Ukhanev", + "email": "xedin.unknown@gmail.com" + } + ], + "description": "A highly ISP-compliant collection of interfaces that represent maps and lists.", + "support": { + "issues": "https://github.com/Dhii/collections-interface/issues", + "source": "https://github.com/Dhii/collections-interface/tree/v0.3.0-alpha4" + }, + "time": "2021-03-09T17:36:34+00:00" + }, + { + "name": "dhii/data-identifiable-interface", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/Dhii/data-identifiable-interface.git", + "reference": "ee063fd2827d9de9e6f92c5abeb759c4f52f5558" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dhii/data-identifiable-interface/zipball/ee063fd2827d9de9e6f92c5abeb759c4f52f5558", + "reference": "ee063fd2827d9de9e6f92c5abeb759c4f52f5558", + "shasum": "" + }, + "require": { + "php": "^5.3 | ^7.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "<=0.3.2", + "dhii/php-cs-fixer-config": "dev-php-5.3", + "phpunit/phpunit": "^4.8", + "ptrofimov/xpmock": "^1.1" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Dhii\\Data\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dhii Team", + "email": "development@dhii.co" + } + ], + "description": "Interfaces for objects that are identifiable.", + "support": { + "issues": "https://github.com/Dhii/data-identifiable-interface/issues", + "source": "https://github.com/Dhii/data-identifiable-interface/tree/v0.1.1-alpha1" + }, + "time": "2018-05-10T15:15:49+00:00" + }, + { + "name": "dhii/data-key-value-aware-interface", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/Dhii/data-key-value-aware-interface.git", + "reference": "f73fcb07995c48db61b1ffb4bfa01bb98b5e9c00" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dhii/data-key-value-aware-interface/zipball/f73fcb07995c48db61b1ffb4bfa01bb98b5e9c00", + "reference": "f73fcb07995c48db61b1ffb4bfa01bb98b5e9c00", + "shasum": "" + }, + "require": { + "php": "^5.3 | ^7.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "<=0.3.2", + "dhii/php-cs-fixer-config": "dev-php-5.3", + "dhii/stringable-interface": "^0.1", + "phpunit/phpunit": "4.*", + "ptrofimov/xpmock": "^1.1" + }, + "default-branch": true, + "type": "library", + "extra": { + "branch-alias": { + "dev-develop": "0.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Dhii\\Data\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Dhii Team", + "email": "development@dhii.co" + } + ], + "description": "Interfaces that aim to increase interoperability of value objects", + "support": { + "issues": "https://github.com/Dhii/data-key-value-aware-interface/issues", + "source": "https://github.com/Dhii/data-key-value-aware-interface/tree/v0.2-alpha2" + }, + "time": "2018-02-11T12:52:01+00:00" + }, { "name": "dhii/human-readable-interface", "version": "0.2.x-dev", @@ -221,6 +382,113 @@ }, "time": "2021-01-14T16:19:20+00:00" }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://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/master" + }, + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "psr/http-message", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "efd67d1dc14a7ef4fc4e518e7dee91c271d524e4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/efd67d1dc14a7ef4fc4e518e7dee91c271d524e4", + "reference": "efd67d1dc14a7ef4fc4e518e7dee91c271d524e4", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "default-branch": true, + "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": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2019-08-29T13:16:46+00:00" + }, { "name": "symfony/polyfill-php80", "version": "dev-main", @@ -403,12 +671,12 @@ "source": { "type": "git", "url": "https://github.com/amphp/byte-stream.git", - "reference": "f813a658f0446192c5e17f96727070ee9342b93a" + "reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/f813a658f0446192c5e17f96727070ee9342b93a", - "reference": "f813a658f0446192c5e17f96727070ee9342b93a", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e", + "reference": "7a64a9ad336fc5e1e70b1c1fc1e9618a7027332e", "shasum": "" }, "require": { @@ -473,7 +741,7 @@ "type": "github" } ], - "time": "2020-08-30T19:23:04+00:00" + "time": "2021-04-05T20:23:22+00:00" }, { "name": "composer/package-versions-deprecated", @@ -633,16 +901,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.5", + "version": "1.4.x-dev", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f28d44c286812c714741478d968104c5e604a1d4" + "reference": "f27e06cd9675801df441b3656569b328e04aa37c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f28d44c286812c714741478d968104c5e604a1d4", - "reference": "f28d44c286812c714741478d968104c5e604a1d4", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", + "reference": "f27e06cd9675801df441b3656569b328e04aa37c", "shasum": "" }, "require": { @@ -650,7 +918,8 @@ "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8" + "phpstan/phpstan": "^0.12.55", + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "autoload": { @@ -676,7 +945,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.5" + "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" }, "funding": [ { @@ -692,7 +961,7 @@ "type": "tidelift" } ], - "time": "2020-11-13T08:04:11+00:00" + "time": "2021-03-25T17:01:18+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -1527,16 +1796,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "0.4.12", + "version": "0.5.4", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "2e17e4a90702d8b7ead58f4e08478a8e819ba6b8" + "reference": "e352d065af1ae9b41c12d1dfd309e90f7b1f55c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/2e17e4a90702d8b7ead58f4e08478a8e819ba6b8", - "reference": "2e17e4a90702d8b7ead58f4e08478a8e819ba6b8", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/e352d065af1ae9b41c12d1dfd309e90f7b1f55c9", + "reference": "e352d065af1ae9b41c12d1dfd309e90f7b1f55c9", "shasum": "" }, "require": { @@ -1554,7 +1823,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "0.4-dev" + "dev-master": "0.5-dev" } }, "autoload": { @@ -1571,9 +1840,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/0.4.12" + "source": "https://github.com/phpstan/phpdoc-parser/tree/0.5.4" }, - "time": "2021-02-28T14:30:10+00:00" + "time": "2021-04-03T14:46:19+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1954,59 +2223,6 @@ }, "time": "2020-01-08T08:45:45+00:00" }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://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/master" - }, - "time": "2017-02-14T16:28:37+00:00" - }, { "name": "psr/log", "version": "dev-master", @@ -2728,28 +2944,28 @@ "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "a3e37268f8ed9f1cd2f74b876996cb2e91f3e1c4" + "reference": "7815b1397bd9ff3e09bac9446ecb680f3fc69844" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/a3e37268f8ed9f1cd2f74b876996cb2e91f3e1c4", - "reference": "a3e37268f8ed9f1cd2f74b876996cb2e91f3e1c4", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7815b1397bd9ff3e09bac9446ecb680f3fc69844", + "reference": "7815b1397bd9ff3e09bac9446ecb680f3fc69844", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.1 || ^8.0", - "phpstan/phpdoc-parser": "0.4.12", - "squizlabs/php_codesniffer": "dev-master" + "phpstan/phpdoc-parser": "0.5.1 - 0.5.4", + "squizlabs/php_codesniffer": "^3.6.0" }, "require-dev": { "phing/phing": "2.16.4", - "php-parallel-lint/php-parallel-lint": "1.2.0", - "phpstan/phpstan": "0.12.80", + "php-parallel-lint/php-parallel-lint": "1.3.0", + "phpstan/phpstan": "0.12.83", "phpstan/phpstan-deprecation-rules": "0.12.6", - "phpstan/phpstan-phpunit": "0.12.17", + "phpstan/phpstan-phpunit": "0.12.18", "phpstan/phpstan-strict-rules": "0.12.9", - "phpunit/phpunit": "7.5.20|8.5.5|9.5.2" + "phpunit/phpunit": "7.5.20|8.5.5|9.5.4" }, "default-branch": true, "type": "phpcodesniffer-standard", @@ -2770,7 +2986,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/master" + "source": "https://github.com/slevomat/coding-standard/tree/7.0.2" }, "funding": [ { @@ -2782,7 +2998,7 @@ "type": "tidelift" } ], - "time": "2021-03-04T08:19:17+00:00" + "time": "2021-04-14T18:15:42+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2790,12 +3006,12 @@ "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "d02296fe420483999d2ad8cd8bdceb43014dc83e" + "reference": "e9a865216c5678d92370c8c56053190b20ab1112" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d02296fe420483999d2ad8cd8bdceb43014dc83e", - "reference": "d02296fe420483999d2ad8cd8bdceb43014dc83e", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e9a865216c5678d92370c8c56053190b20ab1112", + "reference": "e9a865216c5678d92370c8c56053190b20ab1112", "shasum": "" }, "require": { @@ -2839,7 +3055,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-03-05T07:46:22+00:00" + "time": "2021-04-14T23:41:25+00:00" }, { "name": "symfony/console", @@ -2847,12 +3063,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c98349bda966c70d6c08b4cd8658377c94166492" + "reference": "2ac7479be375201150cff3363ee35dfda9c57c7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c98349bda966c70d6c08b4cd8658377c94166492", - "reference": "c98349bda966c70d6c08b4cd8658377c94166492", + "url": "https://api.github.com/repos/symfony/console/zipball/2ac7479be375201150cff3363ee35dfda9c57c7b", + "reference": "2ac7479be375201150cff3363ee35dfda9c57c7b", "shasum": "" }, "require": { @@ -2928,7 +3144,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T18:44:15+00:00" + "time": "2021-04-08T07:40:10+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3300,16 +3516,16 @@ "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "96e0743892f3239f089b13eb978c33d743cfe904" + "reference": "93e9054f98b040bf246c2023201503db3dbf162c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/96e0743892f3239f089b13eb978c33d743cfe904", - "reference": "96e0743892f3239f089b13eb978c33d743cfe904", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/93e9054f98b040bf246c2023201503db3dbf162c", + "reference": "93e9054f98b040bf246c2023201503db3dbf162c", "shasum": "" }, "require": { - "amphp/amp": "^2.1", + "amphp/amp": "^2.4.2", "amphp/byte-stream": "^1.5", "composer/package-versions-deprecated": "^1.8.0", "composer/semver": "^1.4 || ^2.0 || ^3.0", @@ -3335,7 +3551,6 @@ "psalm/psalm": "self.version" }, "require-dev": { - "amphp/amp": "^2.4.2", "bamarni/composer-bin-plugin": "^1.2", "brianium/paratest": "^4.0||^6.0", "ext-curl": "*", @@ -3348,6 +3563,7 @@ "slevomat/coding-standard": "^6.3.11", "squizlabs/php_codesniffer": "^3.5", "symfony/process": "^4.3", + "weirdan/phpunit-appveyor-reporter": "^1.0.0", "weirdan/prophecy-shim": "^1.0 || ^2.0" }, "suggest": { @@ -3398,7 +3614,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm/tree/master" }, - "time": "2021-03-05T05:39:25+00:00" + "time": "2021-04-13T04:02:01+00:00" }, { "name": "webmozart/assert", diff --git a/src/Acl/CapableUserInterface.php b/src/Acl/CapableUserInterface.php new file mode 100644 index 0000000..3f60fc4 --- /dev/null +++ b/src/Acl/CapableUserInterface.php @@ -0,0 +1,12 @@ + + */ + public function getPrivileges(): iterable; + + public function isAllowed(string $resourceKey, string $capability): bool; +} diff --git a/src/Entity/EntityInterface.php b/src/Entity/EntityInterface.php new file mode 100644 index 0000000..14c351f --- /dev/null +++ b/src/Entity/EntityInterface.php @@ -0,0 +1,19 @@ + + */ +interface EntityQueryResultInterface extends Traversable, CountableListInterface +{ + /** + * The total number of items found on all pages. + * + * @return int + */ + public function getTotalCount(): int; + + /** + * @return iterable + */ + public function getIds(): iterable; +} diff --git a/src/Meta/MetaInterface.php b/src/Meta/MetaInterface.php new file mode 100644 index 0000000..b5bad60 --- /dev/null +++ b/src/Meta/MetaInterface.php @@ -0,0 +1,12 @@ + $values + * @return static + */ + public function withIn(string $key, iterable $values): self; + + /** + * @param string $key + * @param iterable $values + * @return static + */ + public function withNotIn(string $key, iterable $values): self; + + /** + * @param string $key + * @param string $lowerBound + * @param string $upperBound + * @return static + */ + public function withBetween(string $key, string $lowerBound, string $upperBound): self; + + /** + * @param string $key + * @param string $lowerBound + * @param string $upperBound + * @return static + */ + public function withNotBetween(string $key, string $lowerBound, string $upperBound): self; + + /** + * @param string $key + * @param string $regexp + * @return static + */ + public function withRegexp(string $key, string $regexp): self; + + /** + * @param string $key + * @return static + */ + public function withExists(string $key): self; + + /** + * @param MetaQueryInterface $query The query to add a relationship with. + * @return static + */ + public function withAnd(MetaQueryInterface $query): self; + + /** + * @param MetaQueryInterface $query The query to add a relationship with. + * @return static + */ + public function withOr(MetaQueryInterface $query): self; + + public function getJoinClause(): string; + + public function getWhereClause(): string; +} diff --git a/src/Post/PostInterface.php b/src/Post/PostInterface.php new file mode 100644 index 0000000..abd831f --- /dev/null +++ b/src/Post/PostInterface.php @@ -0,0 +1,115 @@ + + */ + public function getUrlsToPing(): iterable; + + /** + * @return iterable + */ + public function getUrlsPinged(): iterable; + + public function getGuid(): string; + + public function getMenuOrder(): int; + + public function getType(): string; + + public function getMimeType(): string; +} diff --git a/src/Post/PostQueryInterface.php b/src/Post/PostQueryInterface.php new file mode 100644 index 0000000..014f8e7 --- /dev/null +++ b/src/Post/PostQueryInterface.php @@ -0,0 +1,37 @@ + + */ +interface PostQueryResultInterface extends EntityQueryResultInterface +{ +} diff --git a/src/Taxonomy/TaxonomyInterface.php b/src/Taxonomy/TaxonomyInterface.php new file mode 100644 index 0000000..4e2eb66 --- /dev/null +++ b/src/Taxonomy/TaxonomyInterface.php @@ -0,0 +1,28 @@ + $taxonomyKeys + * @return static + */ + public function withTaxonomyIn(iterable $taxonomyKeys): TermQueryInterface; + + /** + * @param iterable $objectIds + * @return static + */ + public function withObjectIdIn(iterable $objectIds): TermQueryInterface; + + /** + * @param iterable $objectIds + * @return static + */ + public function withObjectIdNotIn(iterable $objectIds): TermQueryInterface; + + /** + * @param iterable $termIds + * @return static + */ + public function withIdIn(iterable $termIds): TermQueryInterface; + + /** + * @param iterable $termIds + * @return static + */ + public function withIdNotIn(iterable $termIds): TermQueryInterface; + + /** + * @param iterable $termIds + * @return static + */ + public function withIdNotInTreesOf(iterable $termIds): TermQueryInterface; + + /** + * @param iterable $keys + * @return static + */ + public function withKeyIn(iterable $keys): TermQueryInterface; + + /** + * @param iterable $labels + * @return static + */ + public function withLabelIn(iterable $labels): TermQueryInterface; + + /** + * @param bool $isHierarchical + * @return static + */ + public function withIsHierarchical(bool $isHierarchical): TermQueryInterface; + + /** + * @param string $keyOrLabelPart The part of the key or label that the terms have to match. + * @return static + */ + public function withKeyOrLabelLike(string $keyOrLabelPart): TermQueryInterface; + + /** + * @param string $labelPart + * @return static + */ + public function withLabelLike(string $labelPart): TermQueryInterface; + + /** + * @param string $descriptionPart + * @return static + */ + public function withDescriptionLike(string $descriptionPart): TermQueryInterface; + + /** + * @param int $termId + * @return static + */ + public function withParentId(int $termId): TermQueryInterface; + + /** + * @param MetaQueryInterface $query + * @return TermQueryInterface + */ + public function withMeta(MetaQueryInterface $query): TermQueryInterface; +} diff --git a/src/Taxonomy/TermQueryResultInterface.php b/src/Taxonomy/TermQueryResultInterface.php new file mode 100644 index 0000000..51b9c28 --- /dev/null +++ b/src/Taxonomy/TermQueryResultInterface.php @@ -0,0 +1,16 @@ + + */ +interface TermQueryResultInterface extends EntityQueryResultInterface +{ +} diff --git a/src/User/UserInterface.php b/src/User/UserInterface.php new file mode 100644 index 0000000..f0ece10 --- /dev/null +++ b/src/User/UserInterface.php @@ -0,0 +1,35 @@ + + */ + public function getRoles(): iterable; +} diff --git a/src/User/UserQueryInterface.php b/src/User/UserQueryInterface.php new file mode 100644 index 0000000..ced4874 --- /dev/null +++ b/src/User/UserQueryInterface.php @@ -0,0 +1,42 @@ + $roleKeys + * @return static + */ + public function withRoleIn(iterable $roleKeys): self; + + /** + * @param iterable $roleKeys + * @return static + */ + public function withRoleNotIn(iterable $roleKeys): self; + + /** + * @param iterable $userIds + * @return static + */ + public function withIdIn(iterable $userIds): self; + + /** + * @param iterable $userIds + * @return static + */ + public function withIdNotIn(iterable $userIds): self; +} diff --git a/src/User/UserQueryResultInterface.php b/src/User/UserQueryResultInterface.php new file mode 100644 index 0000000..c22528b --- /dev/null +++ b/src/User/UserQueryResultInterface.php @@ -0,0 +1,17 @@ + + */ +interface UserQueryResultInterface extends EntityQueryResultInterface +{ + +} From d83ba646dae93123b8374673a62a9e45c75b7452 Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sat, 17 Apr 2021 09:53:52 +0200 Subject: [PATCH 02/10] Fix PHPCS --- src/Acl/CapableUserInterface.php | 1 + src/Acl/PrivilegeInterface.php | 1 + src/Acl/RoleInterface.php | 1 + src/Entity/EntityInterface.php | 1 + src/Entity/EntityQueryInterface.php | 2 +- src/Entity/EntityQueryResultInterface.php | 2 +- src/Meta/MetaInterface.php | 1 + src/Meta/MetaQueryInterface.php | 28 +---------------------- src/Post/PostInterface.php | 10 +------- src/Post/PostQueryInterface.php | 2 +- src/Post/PostQueryResultInterface.php | 1 + src/Taxonomy/TaxonomyInterface.php | 1 + src/Taxonomy/TermInterface.php | 1 + src/Taxonomy/TermQueryInterface.php | 8 +------ src/Taxonomy/TermQueryResultInterface.php | 1 + src/User/UserInterface.php | 1 + src/User/UserQueryInterface.php | 1 + src/User/UserQueryResultInterface.php | 1 + 18 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/Acl/CapableUserInterface.php b/src/Acl/CapableUserInterface.php index 3f60fc4..6c45117 100644 --- a/src/Acl/CapableUserInterface.php +++ b/src/Acl/CapableUserInterface.php @@ -1,4 +1,5 @@ $values * @return static */ public function withIn(string $key, iterable $values): self; /** - * @param string $key * @param iterable $values * @return static */ public function withNotIn(string $key, iterable $values): self; /** - * @param string $key - * @param string $lowerBound - * @param string $upperBound * @return static */ public function withBetween(string $key, string $lowerBound, string $upperBound): self; /** - * @param string $key - * @param string $lowerBound - * @param string $upperBound * @return static */ public function withNotBetween(string $key, string $lowerBound, string $upperBound): self; /** - * @param string $key - * @param string $regexp * @return static */ public function withRegexp(string $key, string $regexp): self; /** - * @param string $key * @return static */ public function withExists(string $key): self; diff --git a/src/Post/PostInterface.php b/src/Post/PostInterface.php index abd831f..576ebf0 100644 --- a/src/Post/PostInterface.php +++ b/src/Post/PostInterface.php @@ -1,6 +1,6 @@ Date: Sun, 18 Apr 2021 00:21:05 +0200 Subject: [PATCH 03/10] More query abstraction --- composer.lock | 48 ++++++------ src/Entity/EntityInterface.php | 2 +- src/Entity/EntityQueryInterface.php | 29 ++++++-- src/Entity/EntityQueryResultInterface.php | 11 +-- src/Meta/MetaQueryInterface.php | 89 ++--------------------- src/Post/PostQueryInterface.php | 8 +- src/Taxonomy/TermQueryInterface.php | 16 +--- src/User/UserQueryInterface.php | 15 +--- 8 files changed, 65 insertions(+), 153 deletions(-) diff --git a/composer.lock b/composer.lock index f9e862c..661055b 100644 --- a/composer.lock +++ b/composer.lock @@ -901,16 +901,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.4.x-dev", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c" + "reference": "31d57697eb1971712a08031cfaff5a846d10bdf5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/f27e06cd9675801df441b3656569b328e04aa37c", - "reference": "f27e06cd9675801df441b3656569b328e04aa37c", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/31d57697eb1971712a08031cfaff5a846d10bdf5", + "reference": "31d57697eb1971712a08031cfaff5a846d10bdf5", "shasum": "" }, "require": { @@ -945,7 +945,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/1.4.6" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.0" }, "funding": [ { @@ -961,7 +961,7 @@ "type": "tidelift" } ], - "time": "2021-03-25T17:01:18+00:00" + "time": "2021-04-09T19:40:06+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -2944,12 +2944,12 @@ "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "7815b1397bd9ff3e09bac9446ecb680f3fc69844" + "reference": "6783711e13ab355e0c872567e0a72a22c71c7b02" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7815b1397bd9ff3e09bac9446ecb680f3fc69844", - "reference": "7815b1397bd9ff3e09bac9446ecb680f3fc69844", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/6783711e13ab355e0c872567e0a72a22c71c7b02", + "reference": "6783711e13ab355e0c872567e0a72a22c71c7b02", "shasum": "" }, "require": { @@ -2986,7 +2986,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.0.2" + "source": "https://github.com/slevomat/coding-standard/tree/master" }, "funding": [ { @@ -2998,7 +2998,7 @@ "type": "tidelift" } ], - "time": "2021-04-14T18:15:42+00:00" + "time": "2021-04-16T18:02:24+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -3006,12 +3006,12 @@ "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "e9a865216c5678d92370c8c56053190b20ab1112" + "reference": "342dbf2481b7a3c0b799fecd7b7c4def3c0408e3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e9a865216c5678d92370c8c56053190b20ab1112", - "reference": "e9a865216c5678d92370c8c56053190b20ab1112", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/342dbf2481b7a3c0b799fecd7b7c4def3c0408e3", + "reference": "342dbf2481b7a3c0b799fecd7b7c4def3c0408e3", "shasum": "" }, "require": { @@ -3055,7 +3055,7 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2021-04-14T23:41:25+00:00" + "time": "2021-04-16T04:22:12+00:00" }, { "name": "symfony/console", @@ -3063,12 +3063,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "2ac7479be375201150cff3363ee35dfda9c57c7b" + "reference": "36bbd079b69b94bcc9c9c9e1e37ca3b1e7971625" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/2ac7479be375201150cff3363ee35dfda9c57c7b", - "reference": "2ac7479be375201150cff3363ee35dfda9c57c7b", + "url": "https://api.github.com/repos/symfony/console/zipball/36bbd079b69b94bcc9c9c9e1e37ca3b1e7971625", + "reference": "36bbd079b69b94bcc9c9c9e1e37ca3b1e7971625", "shasum": "" }, "require": { @@ -3144,7 +3144,7 @@ "type": "tidelift" } ], - "time": "2021-04-08T07:40:10+00:00" + "time": "2021-04-16T17:32:19+00:00" }, { "name": "symfony/polyfill-ctype", @@ -3516,12 +3516,12 @@ "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "93e9054f98b040bf246c2023201503db3dbf162c" + "reference": "ee778e9246ac33451a0f582d60a602288e687f98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/93e9054f98b040bf246c2023201503db3dbf162c", - "reference": "93e9054f98b040bf246c2023201503db3dbf162c", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/ee778e9246ac33451a0f582d60a602288e687f98", + "reference": "ee778e9246ac33451a0f582d60a602288e687f98", "shasum": "" }, "require": { @@ -3529,7 +3529,7 @@ "amphp/byte-stream": "^1.5", "composer/package-versions-deprecated": "^1.8.0", "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.1", + "composer/xdebug-handler": "^1.1 || ^2.0", "dnoegel/php-xdg-base-dir": "^0.1.1", "ext-dom": "*", "ext-json": "*", @@ -3614,7 +3614,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm/tree/master" }, - "time": "2021-04-13T04:02:01+00:00" + "time": "2021-04-16T20:07:47+00:00" }, { "name": "webmozart/assert", diff --git a/src/Entity/EntityInterface.php b/src/Entity/EntityInterface.php index ba55476..5c51f3c 100644 --- a/src/Entity/EntityInterface.php +++ b/src/Entity/EntityInterface.php @@ -10,7 +10,7 @@ /** * Represents a WordPress entity, a.k.a. "object". */ -interface EntityInterface extends IdAwareInterface +interface EntityInterface extends IdAwareInterface, MapInterface { public function getEntityType(): string; diff --git a/src/Entity/EntityQueryInterface.php b/src/Entity/EntityQueryInterface.php index 6e5be7b..3084726 100644 --- a/src/Entity/EntityQueryInterface.php +++ b/src/Entity/EntityQueryInterface.php @@ -4,17 +4,36 @@ namespace WpOop\WordPress\Entity; +use WpOop\WordPress\Meta\MetaQueryInterface; +use WpOop\WordPress\Post\PostQueryInterface; +use WpOop\WordPress\Query\QueryInterface; +use WpOop\WordPress\Query\QueryResultInterface; +use WpOop\WordPress\Taxonomy\TermQueryInterface; + /** - * Represents a generic WordPress query for entities. + * Represents a query for entities. */ -interface EntityQueryInterface +interface EntityQueryInterface extends QueryInterface { - public function query(): EntityQueryResultInterface; + /** + * @return EntityQueryResultInterface + */ + public function query(): QueryResultInterface; + + /** + * @param iterable $termIds + * @return static + */ + public function withIdIn(iterable $termIds): TermQueryInterface; /** + * @param iterable $termIds * @return static */ - public function withLimit(int $limit): self; + public function withIdNotIn(iterable $termIds): TermQueryInterface; - public function withOffset(int $offset): self; + /** + * @return static + */ + public function withMeta(MetaQueryInterface $query): self; } diff --git a/src/Entity/EntityQueryResultInterface.php b/src/Entity/EntityQueryResultInterface.php index bd70188..b9d6666 100644 --- a/src/Entity/EntityQueryResultInterface.php +++ b/src/Entity/EntityQueryResultInterface.php @@ -4,22 +4,15 @@ namespace WpOop\WordPress\Entity; -use Dhii\Collection\CountableListInterface; -use Traversable; +use WpOop\WordPress\Query\QueryResultInterface; /** * Represents a WordPress post query result. * * @extends Traversable */ -interface EntityQueryResultInterface extends Traversable, CountableListInterface +interface EntityQueryResultInterface extends QueryResultInterface { - /** - * The total number of items found on all pages. - * - */ - public function getTotalCount(): int; - /** * @return iterable */ diff --git a/src/Meta/MetaQueryInterface.php b/src/Meta/MetaQueryInterface.php index d8b1aaa..8f11b7d 100644 --- a/src/Meta/MetaQueryInterface.php +++ b/src/Meta/MetaQueryInterface.php @@ -4,102 +4,29 @@ namespace WpOop\WordPress\Meta; -use WpOop\WordPress\Entity\EntityQueryInterface; + +use WpOop\WordPress\Query\ClauseQueryInterface; +use WpOop\WordPress\Query\QueryConfiguratorInterface; /** * Represents a WordPress meta query. */ -interface MetaQueryInterface extends EntityQueryInterface +interface MetaQueryInterface extends ClauseQueryInterface { - /** - * @return static - */ - public function withLt(string $key, string $value): self; - - /** - * @return static - */ - public function withLtEq(string $key, string $value): self; - - /** - * @return static - */ - public function withGt(string $key, string $value): self; - - /** - * @return static - */ - public function withGtEq(string $key, string $value): self; - - /** - * @return static - */ - public function withEq(string $key, string $value): self; - - /** - * @return static - */ - public function withNotEq(string $key, string $value): self; - - /** - * Like - * - * @return static - */ - public function withApprox(string $key, string $value): self; - - /** - * Not like - * - * @return static - */ - public function withNotApprox(string $key, string $value): self; - - /** - * @param iterable $values - * @return static - */ - public function withIn(string $key, iterable $values): self; - - /** - * @param iterable $values - * @return static - */ - public function withNotIn(string $key, iterable $values): self; - - /** - * @return static - */ - public function withBetween(string $key, string $lowerBound, string $upperBound): self; - - /** - * @return static - */ - public function withNotBetween(string $key, string $lowerBound, string $upperBound): self; - - /** - * @return static - */ - public function withRegexp(string $key, string $regexp): self; - /** * @return static */ public function withExists(string $key): self; /** - * @param MetaQueryInterface $query The query to add a relationship with. + * @param self $query * @return static */ - public function withAnd(MetaQueryInterface $query): self; + public function withAnd(QueryConfiguratorInterface $query): QueryConfiguratorInterface; /** - * @param MetaQueryInterface $query The query to add a relationship with. + * @param self $query * @return static */ - public function withOr(MetaQueryInterface $query): self; - - public function getJoinClause(): string; - - public function getWhereClause(): string; + public function withOr(QueryConfiguratorInterface $query): QueryConfiguratorInterface; } diff --git a/src/Post/PostQueryInterface.php b/src/Post/PostQueryInterface.php index 7eaf220..e039a22 100644 --- a/src/Post/PostQueryInterface.php +++ b/src/Post/PostQueryInterface.php @@ -7,6 +7,7 @@ use WpOop\WordPress\Entity\EntityQueryInterface; use WpOop\WordPress\Entity\EntityQueryResultInterface; use WpOop\WordPress\Meta\MetaQueryInterface; +use WpOop\WordPress\Query\QueryResultInterface; /** * Represents a WordPress post query. @@ -16,7 +17,7 @@ interface PostQueryInterface extends EntityQueryInterface /** * @return PostQueryResultInterface */ - public function query(): EntityQueryResultInterface; + public function query(): QueryResultInterface; /** * @param int[] $ids @@ -29,9 +30,4 @@ public function withAuthorIdIn(array $ids): self; * @return static */ public function withAuthorIdNotIn(array $ids): self; - - /** - * @return static - */ - public function withMeta(MetaQueryInterface $query): self; } diff --git a/src/Taxonomy/TermQueryInterface.php b/src/Taxonomy/TermQueryInterface.php index cefc7d5..c0a31c3 100644 --- a/src/Taxonomy/TermQueryInterface.php +++ b/src/Taxonomy/TermQueryInterface.php @@ -4,9 +4,9 @@ namespace WpOop\WordPress\Taxonomy; -use WpOop\WordPress\Entity\EntityQueryResultInterface; use WpOop\WordPress\Meta\MetaQueryInterface; use WpOop\WordPress\Entity\EntityQueryInterface; +use WpOop\WordPress\Query\QueryResultInterface; /** * Represents a query for WordPress terms. @@ -16,7 +16,7 @@ interface TermQueryInterface extends EntityQueryInterface /** * @return TermQueryResultInterface */ - public function query(): EntityQueryResultInterface; + public function query(): QueryResultInterface; /** * @return static @@ -41,18 +41,6 @@ public function withObjectIdIn(iterable $objectIds): TermQueryInterface; */ public function withObjectIdNotIn(iterable $objectIds): TermQueryInterface; - /** - * @param iterable $termIds - * @return static - */ - public function withIdIn(iterable $termIds): TermQueryInterface; - - /** - * @param iterable $termIds - * @return static - */ - public function withIdNotIn(iterable $termIds): TermQueryInterface; - /** * @param iterable $termIds * @return static diff --git a/src/User/UserQueryInterface.php b/src/User/UserQueryInterface.php index bee5929..c3c9de9 100644 --- a/src/User/UserQueryInterface.php +++ b/src/User/UserQueryInterface.php @@ -6,6 +6,7 @@ use WpOop\WordPress\Entity\EntityQueryInterface; use WpOop\WordPress\Entity\EntityQueryResultInterface; +use WpOop\WordPress\Query\QueryResultInterface; /** * Represents a WordPress user query. @@ -15,7 +16,7 @@ interface UserQueryInterface extends EntityQueryInterface /** * @return UserQueryResultInterface */ - public function query(): EntityQueryResultInterface; + public function query(): QueryResultInterface; /** * @param iterable $roleKeys @@ -28,16 +29,4 @@ public function withRoleIn(iterable $roleKeys): self; * @return static */ public function withRoleNotIn(iterable $roleKeys): self; - - /** - * @param iterable $userIds - * @return static - */ - public function withIdIn(iterable $userIds): self; - - /** - * @param iterable $userIds - * @return static - */ - public function withIdNotIn(iterable $userIds): self; } From 9ed3804af07e0bb73eb1c28c2390f314a4bcf1ce Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 00:23:10 +0200 Subject: [PATCH 04/10] More query abstraction --- src/Query/ClauseQueryInterface.php | 13 +++ src/Query/QueryConfiguratorInterface.php | 97 +++++++++++++++++++ src/Query/QueryInterface.php | 23 +++++ src/Query/QueryResultInterface.php | 23 +++++ .../RecordQueryConfiguratorInterface.php | 23 +++++ 5 files changed, 179 insertions(+) create mode 100644 src/Query/ClauseQueryInterface.php create mode 100644 src/Query/QueryConfiguratorInterface.php create mode 100644 src/Query/QueryInterface.php create mode 100644 src/Query/QueryResultInterface.php create mode 100644 src/Query/RecordQueryConfiguratorInterface.php diff --git a/src/Query/ClauseQueryInterface.php b/src/Query/ClauseQueryInterface.php new file mode 100644 index 0000000..4ebb387 --- /dev/null +++ b/src/Query/ClauseQueryInterface.php @@ -0,0 +1,13 @@ + $values + * @return static + */ + public function withIn(string $key, iterable $values): self; + + /** + * @param iterable $values + * @return static + */ + public function withNotIn(string $key, iterable $values): self; + + /** + * @return static + */ + public function withBetween(string $key, string $lowerBound, string $upperBound): self; + + /** + * @return static + */ + public function withNotBetween(string $key, string $lowerBound, string $upperBound): self; + + /** + * @return static + */ + public function withRegexp(string $key, string $regexp): self; + + + /** + * @param self $query The query to add a relationship with. + * @return static + */ + public function withAnd(QueryConfiguratorInterface $query): self; + + /** + * @param self $query The query to add a relationship with. + * @return static + */ + public function withOr(QueryConfiguratorInterface $query): self; +} diff --git a/src/Query/QueryInterface.php b/src/Query/QueryInterface.php new file mode 100644 index 0000000..a906f73 --- /dev/null +++ b/src/Query/QueryInterface.php @@ -0,0 +1,23 @@ + + */ +interface QueryResultInterface extends Traversable, CountableListInterface +{ + /** + * The total number of items found on all pages. + * + */ + public function getTotalCount(): int; +} diff --git a/src/Query/RecordQueryConfiguratorInterface.php b/src/Query/RecordQueryConfiguratorInterface.php new file mode 100644 index 0000000..bf07f8b --- /dev/null +++ b/src/Query/RecordQueryConfiguratorInterface.php @@ -0,0 +1,23 @@ + Date: Sun, 18 Apr 2021 01:04:17 +0200 Subject: [PATCH 05/10] `QueryConfiguratorInterface` now allows more values for "between" --- src/Query/QueryConfiguratorInterface.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Query/QueryConfiguratorInterface.php b/src/Query/QueryConfiguratorInterface.php index ba94b89..784f069 100644 --- a/src/Query/QueryConfiguratorInterface.php +++ b/src/Query/QueryConfiguratorInterface.php @@ -4,6 +4,7 @@ namespace WpOop\WordPress\Query; +use DateTimeInterface; use WpOop\WordPress\Meta\MetaQueryInterface; /** @@ -68,14 +69,18 @@ public function withIn(string $key, iterable $values): self; public function withNotIn(string $key, iterable $values): self; /** + * @param numeric|string|DateTimeInterface $lowerBound + * @param numeric|string|DateTimeInterface $upperBound * @return static */ - public function withBetween(string $key, string $lowerBound, string $upperBound): self; + public function withBetween(string $key, $lowerBound, $upperBound): self; /** + * @param numeric|string|DateTimeInterface $lowerBound + * @param numeric|string|DateTimeInterface $upperBound * @return static */ - public function withNotBetween(string $key, string $lowerBound, string $upperBound): self; + public function withNotBetween(string $key, $lowerBound, $upperBound): self; /** * @return static From 2a281082a12a7b0516d69f0aede1d8410d4818c4 Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 01:20:08 +0200 Subject: [PATCH 06/10] Add `withNotRegexp()` --- src/Query/QueryConfiguratorInterface.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Query/QueryConfiguratorInterface.php b/src/Query/QueryConfiguratorInterface.php index 784f069..32aaf80 100644 --- a/src/Query/QueryConfiguratorInterface.php +++ b/src/Query/QueryConfiguratorInterface.php @@ -87,6 +87,11 @@ public function withNotBetween(string $key, $lowerBound, $upperBound): self; */ public function withRegexp(string $key, string $regexp): self; + /** + * @return static + */ + public function withNotRegexp(string $key, string $regexp): self; + /** * @param self $query The query to add a relationship with. From f319f7bc064c5490890d96c6692d348e74397192 Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 01:54:02 +0200 Subject: [PATCH 07/10] Add `getConfig()` --- src/Meta/MetaQueryInterface.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Meta/MetaQueryInterface.php b/src/Meta/MetaQueryInterface.php index 8f11b7d..b4f3308 100644 --- a/src/Meta/MetaQueryInterface.php +++ b/src/Meta/MetaQueryInterface.php @@ -8,6 +8,10 @@ use WpOop\WordPress\Query\ClauseQueryInterface; use WpOop\WordPress\Query\QueryConfiguratorInterface; +/** + * @psalm-type FieldConfig = array {key: string, value: mixed, compare: string, type: string} + */ + /** * Represents a WordPress meta query. */ @@ -29,4 +33,12 @@ public function withAnd(QueryConfiguratorInterface $query): QueryConfiguratorInt * @return static */ public function withOr(QueryConfiguratorInterface $query): QueryConfiguratorInterface; + + /** + * @return array The configuration for {@see WP_Meta_Query}. + * An array containing the `relation` key, as well as unlimited numeric keys each of which + * contains a {@see FieldConfig}. + * @psalm-return array{relation: string, 0: FieldConfig} + */ + public function getConfig(): array; } From a1a951521662f1bb0c75937c25676e59b62375d2 Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 02:00:27 +0200 Subject: [PATCH 08/10] Add Psalm-specific annotation --- src/Meta/MetaQueryInterface.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Meta/MetaQueryInterface.php b/src/Meta/MetaQueryInterface.php index b4f3308..43372de 100644 --- a/src/Meta/MetaQueryInterface.php +++ b/src/Meta/MetaQueryInterface.php @@ -9,7 +9,8 @@ use WpOop\WordPress\Query\QueryConfiguratorInterface; /** - * @psalm-type FieldConfig = array {key: string, value: mixed, compare: string, type: string} + * @psalm-type FieldConfig = array{key: string, value: mixed, compare: string, type: string} + * @psalm-type MetaQueryConfig = array{relation, ...: FieldConfig|MetaQueryConfig} */ /** @@ -38,7 +39,7 @@ public function withOr(QueryConfiguratorInterface $query): QueryConfiguratorInte * @return array The configuration for {@see WP_Meta_Query}. * An array containing the `relation` key, as well as unlimited numeric keys each of which * contains a {@see FieldConfig}. - * @psalm-return array{relation: string, 0: FieldConfig} + * @psalm-return MetaQueryConfig */ public function getConfig(): array; } From 822f72575f339879760f947099f57074753f1f31 Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 02:41:21 +0200 Subject: [PATCH 09/10] `QueryConfiguratorInterface` now allows relation change The relation is now part of the query itself. --- src/Meta/MetaQueryInterface.php | 12 +++--------- src/Query/QueryConfiguratorInterface.php | 10 ++++++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Meta/MetaQueryInterface.php b/src/Meta/MetaQueryInterface.php index 43372de..71187ae 100644 --- a/src/Meta/MetaQueryInterface.php +++ b/src/Meta/MetaQueryInterface.php @@ -10,7 +10,7 @@ /** * @psalm-type FieldConfig = array{key: string, value: mixed, compare: string, type: string} - * @psalm-type MetaQueryConfig = array{relation, ...: FieldConfig|MetaQueryConfig} + * @psalm-type MetaQueryConfig = array{relation: 'AND'|'OR', ...: FieldConfig|MetaQueryConfig} */ /** @@ -24,16 +24,10 @@ interface MetaQueryInterface extends ClauseQueryInterface public function withExists(string $key): self; /** - * @param self $query + * @param self $query The subquery query to add. * @return static */ - public function withAnd(QueryConfiguratorInterface $query): QueryConfiguratorInterface; - - /** - * @param self $query - * @return static - */ - public function withOr(QueryConfiguratorInterface $query): QueryConfiguratorInterface; + public function withQuery(QueryConfiguratorInterface $query): QueryConfiguratorInterface; /** * @return array The configuration for {@see WP_Meta_Query}. diff --git a/src/Query/QueryConfiguratorInterface.php b/src/Query/QueryConfiguratorInterface.php index 32aaf80..315ccbb 100644 --- a/src/Query/QueryConfiguratorInterface.php +++ b/src/Query/QueryConfiguratorInterface.php @@ -12,6 +12,9 @@ */ interface QueryConfiguratorInterface { + public const RELATION_TYPE_AND = 'AND'; + public const RELATION_TYPE_OR = 'OR'; + /** * @return static */ @@ -92,16 +95,15 @@ public function withRegexp(string $key, string $regexp): self; */ public function withNotRegexp(string $key, string $regexp): self; - /** * @param self $query The query to add a relationship with. * @return static */ - public function withAnd(QueryConfiguratorInterface $query): self; + public function withQuery(QueryConfiguratorInterface $query): self; /** - * @param self $query The query to add a relationship with. + * @param self::RELATION_TYPE_* $relation * @return static */ - public function withOr(QueryConfiguratorInterface $query): self; + public function withRelation(string $relation): self; } From 61d288ad2303310ef0c76a6fa85ed495223f159b Mon Sep 17 00:00:00 2001 From: Anton Ukhanev Date: Sun, 18 Apr 2021 23:49:37 +0200 Subject: [PATCH 10/10] Remove redundant method override --- src/Taxonomy/TermQueryInterface.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Taxonomy/TermQueryInterface.php b/src/Taxonomy/TermQueryInterface.php index c0a31c3..77a3627 100644 --- a/src/Taxonomy/TermQueryInterface.php +++ b/src/Taxonomy/TermQueryInterface.php @@ -84,8 +84,4 @@ public function withDescriptionLike(string $descriptionPart): TermQueryInterface * @return static */ public function withParentId(int $termId): TermQueryInterface; - - /** - */ - public function withMeta(MetaQueryInterface $query): TermQueryInterface; }