diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..89e99a9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +* text=auto eol=lf + +/.github export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpcs.xml export-ignore +/phpmd.xml export-ignore +/phpstan.neon export-ignore +/phpunit.xml.dist export-ignore +/psalm.xml export-ignore diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 6f162f1..2a62ee6 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -7,4 +7,6 @@ on: jobs: cs: - uses: ray-di/.github/.github/workflows/coding-standards.yml@v2 + uses: ray-di/.github/.github/workflows/coding-standards.yml@v1 + with: + php_version: 8.4 diff --git a/.gitignore b/.gitignore index 6e04c06..737d1bb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /vendor/ /.phpunit.cache/ /composer.lock +/build/ +/coverage.xml .DS_Store \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a0db66f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2025-2026 Akihito Koriyama + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/RELEASE-NOTES-1.0.0-rc1.md b/RELEASE-NOTES-1.0.0-rc1.md deleted file mode 100644 index b80eacf..0000000 --- a/RELEASE-NOTES-1.0.0-rc1.md +++ /dev/null @@ -1,85 +0,0 @@ -# Release Notes - Ray.WebQuery 1.0.0-rc1 - -## ๐Ÿš€ Initial Release - -Ray.WebQuery 1.0.0-rc1 is the first release candidate of our new web API access mapping framework, extracted from Ray.MediaQuery to provide dedicated HTTP client functionality. - -## โœจ Key Features - -### Web API Query System -- **`#[WebQuery]` Annotation**: Mark interface methods for automatic HTTP request mapping -- **Multiple Response Types**: Support for JSON arrays, raw strings, and PSR-7 MessageInterface -- **URI Template Support**: Dynamic URL parameter binding using `{param}` syntax -- **AOP Integration**: Seamless method interception using Ray.Aop - -### Configuration Management -- **JSON Configuration**: Define web APIs in structured JSON files -- **Schema Validation**: Complete JSON schema for web query definitions -- **Template Bindings**: Support for global URI template parameter bindings - -### HTTP Client Integration -- **Guzzle HTTP Client**: Built on the reliable Guzzle HTTP library -- **PSR-7 Compatibility**: Full support for PSR-7 HTTP message interfaces -- **Parameter Injection**: Automatic parameter conversion and injection - -## ๐Ÿ—๏ธ Architecture - -The framework follows a clean separation of concerns: - -- **MediaQueryWebModule**: Dependency injection configuration -- **WebQueryInterceptor**: AOP-based method interception -- **WebQueryConfig**: Configuration loading and validation -- **WebApiQuery**: HTTP request execution - -## ๐Ÿ“‹ Requirements - -- PHP 8.1+ -- Ray.MediaQuery 1.0.0-rc1 -- Guzzle HTTP 7.2+ - -## ๐Ÿ”ง Installation - -```bash -composer require ray/web-query -``` - -## ๐Ÿ“ Basic Usage - -```php - - - + - + tests diff --git a/psalm.xml b/psalm.xml index 84667fd..3f70d09 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,7 +4,7 @@ phpVersion="8.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" - xsi:schemaLocation="https://getpsalm.org/schema/config vendor-bin/tools/vendor/vimeo/psalm/config.xsd" + xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="true" findUnusedCode="false" > diff --git a/tests/Fake/FakeMissingEntity.php b/tests/Fake/FakeMissingEntity.php new file mode 100644 index 0000000..ef70dcd --- /dev/null +++ b/tests/Fake/FakeMissingEntity.php @@ -0,0 +1,18 @@ +fooProduct = $this->buildFooProduct($body); $result = $this->fooProduct->listWithTax('active'); - $this->assertIsArray($result); $this->assertCount(2, $result); $this->assertInstanceOf(FakeProductEntity::class, $result[0]); $this->assertSame(110, $result[0]->price); @@ -82,7 +81,6 @@ public function testRowListWithoutFactory(): void $body = '[{"name":"Widget","price":100},{"name":"Gadget","price":200}]'; $this->fooProduct = $this->buildFooProduct($body); $result = $this->fooProduct->list('active'); - $this->assertIsArray($result); $this->assertCount(2, $result); $this->assertInstanceOf(FakeProductEntity::class, $result[0]); } diff --git a/tests/WebResponseMapperTest.php b/tests/WebResponseMapperTest.php index d32fdfa..7f96914 100644 --- a/tests/WebResponseMapperTest.php +++ b/tests/WebResponseMapperTest.php @@ -103,9 +103,7 @@ public function testEntityWithoutConstructorThrows(): void public function testInvalidFactoryThrows(): void { - /** @var class-string $missing */ - $missing = 'NotAClass\\Factory'; - $webQuery = new WebQuery(id: 'id', factory: $missing); + $webQuery = new WebQuery(id: 'id', factory: 'NotAClass\\Factory'); $this->expectException(InvalidWebFactoryException::class); $this->mapper()->map($webQuery, null, true, ['name' => 'Widget']); } @@ -119,10 +117,8 @@ public function testNonPublicFactoryMethodThrows(): void public function testEntityClassNotFoundThrows(): void { - /** @var class-string $missing */ - $missing = 'NotAnEntity\\Klass'; $this->expectException(InvalidWebEntityException::class); - $this->mapper()->map(new WebQuery('id'), $missing, true, ['name' => 'x']); + $this->mapper()->map(new WebQuery('id'), FakeMissingEntity::name(), true, ['name' => 'x']); } public function testEmptyBodyRowReturnsNull(): void