Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor/
/.phpunit.cache/
/composer.lock
/build/
/coverage.xml
.DS_Store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
85 changes: 0 additions & 85 deletions RELEASE-NOTES-1.0.0-rc1.md

This file was deleted.

25 changes: 7 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
"rize/uri-template": "^0.3 || ^0.4"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8",
"phpunit/phpunit": "^10.5.46",
"squizlabs/php_codesniffer": "^3.8",
"phpstan/phpstan": "^1.10",
"vimeo/psalm": "^5.18 || ^6.0 || ^7.0",
"phpmd/phpmd": "^3.0",
"phpmetrics/phpmetrics": "^2.8",
"phpmd/phpmd": "^2.15"
"phpstan/phpstan": "^2.1",
"phpunit/phpunit": "^11.5",
"squizlabs/php_codesniffer": "^4.0",
"vimeo/psalm": "^6.0 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -53,7 +52,7 @@
"sa": [
"./vendor/bin/psalm --monochrome --show-info=true",
"./vendor/bin/phpstan analyse -c phpstan.neon",
"./vendor/bin/phpmd src text ./phpmd.xml"
"./vendor/bin/phpmd analyze src --format text --ruleset ./phpmd.xml"
],
"test": "./vendor/bin/phpunit",
"tests": [
Expand All @@ -70,16 +69,6 @@
]
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"bamarni/composer-bin-plugin": true
}
},
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
"sort-packages": true
}
}
5 changes: 2 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<coverage/>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Ray.MediaQuery-Web test suite">
<testsuite name="Ray.WebQuery test suite">
<directory>tests</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
Expand Down
18 changes: 18 additions & 0 deletions tests/Fake/FakeMissingEntity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Ray\MediaQuery;

/**
* Supplies a class name that does not exist, typed as class-string, to exercise
* the mapper's guard against entities that cannot be loaded.
*/
final class FakeMissingEntity
{
/** @return class-string */
public static function name(): string
{
return 'NotAnEntity\\Klass';
}
}
2 changes: 1 addition & 1 deletion tests/Fake/web_product.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "../../docs/schema/web_query.json",
"$schema": "../../docs/web_query.json",
"webQuery": [
{"id": "foo_product", "method": "GET", "path": "https://{domain}/products/{id}"}
]
Expand Down
2 changes: 1 addition & 1 deletion tests/Fake/web_query.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "../../docs/schema/web_query.json",
"$schema": "../../docs/web_query.json",
"webQuery": [
{"id": "foo_item", "method": "GET", "path": "https://{domain}/Ray.MediaQuery/schema/{id}.json"}
]
Expand Down
2 changes: 0 additions & 2 deletions tests/WebQueryBdrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public function testRowListWithFactory(): void
$body = '[{"name":"Widget","price":100},{"name":"Gadget","price":200}]';
$this->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);
Expand All @@ -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]);
}
Expand Down
8 changes: 2 additions & 6 deletions tests/WebResponseMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand All @@ -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
Expand Down
Loading