Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Art4/json-api-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.4
Choose a base ref
...
head repository: Art4/json-api-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.x
Choose a head ref
Loading
Showing with 20,910 additions and 7,686 deletions.
  1. +54 −0 .docker/PHP83-Dockerfile
  2. +6 −0 .docker/build/php/custom.ini
  3. +93 −0 .docker/build/php/opcache.ini
  4. +8 −3 .gitattributes
  5. +37 −0 .github/workflows/code-style.yml
  6. +36 −0 .github/workflows/phpstan.yml
  7. +58 −0 .github/workflows/unit-tests.yml
  8. +2 −1 .gitignore
  9. +23 −0 .php-cs-fixer.dist.php
  10. +90 −0 .phpstan.neon
  11. +65 −0 .reuse/dep5
  12. +0 −24 .travis.yml
  13. +343 −6 CHANGELOG.md
  14. +620 −286 LICENSE
  15. +232 −0 LICENSES/GPL-3.0-or-later.txt
  16. +122 −36 README.md
  17. +30 −6 composer.json
  18. +22 −0 docker-compose.yml
  19. +11 −8 docs/README.md
  20. +48 −25 docs/exception-introduction.md
  21. +140 −0 docs/factory.md
  22. +86 −0 docs/helper-parser.md
  23. +86 −0 docs/manager.md
  24. +13 −10 docs/objects-attributes.md
  25. +15 −8 docs/objects-document-link.md
  26. +21 −18 docs/objects-document.md
  27. +9 −6 docs/objects-error-collection.md
  28. +10 −6 docs/objects-error-link.md
  29. +10 −7 docs/objects-error-source.md
  30. +16 −13 docs/objects-error.md
  31. +30 −35 docs/objects-introduction.md
  32. +10 −7 docs/objects-jsonapi.md
  33. +13 −15 docs/objects-link.md
  34. +14 −12 docs/objects-meta.md
  35. +0 −23 docs/objects-pagination-link.md
  36. +11 −8 docs/objects-relationship-collection.md
  37. +15 −8 docs/objects-relationship-link.md
  38. +11 −8 docs/objects-relationship.md
  39. +11 −8 docs/objects-resource-collection.md
  40. +11 −8 docs/objects-resource-identifier-collection.md
  41. +15 −12 docs/objects-resource-identifier.md
  42. +23 −0 docs/objects-resource-item-link.md
  43. +17 −10 docs/objects-resource-item.md
  44. +22 −0 docs/objects-resource-null.md
  45. +0 −20 docs/objects-resource-nullresource.md
  46. +47 −0 docs/serializer.md
  47. +0 −72 docs/utils-factory.md
  48. +0 −39 docs/utils-helper.md
  49. +0 −40 docs/utils-manager.md
  50. +24 −30 phpunit.xml
  51. +0 −17 src/AccessInterface.php
  52. +44 −0 src/Accessable.php
  53. +0 −41 src/Attributes.php
  54. +0 −310 src/Document.php
  55. +0 −69 src/DocumentLink.php
  56. +22 −0 src/Element.php
  57. +0 −276 src/Error.php
  58. +0 −134 src/ErrorCollection.php
  59. +0 −47 src/ErrorLink.php
  60. +0 −129 src/ErrorSource.php
  61. +6 −1 src/Exception/AccessException.php
  62. +11 −2 src/Exception/Exception.php
  63. +6 −0 src/Exception/FactoryException.php
  64. +11 −0 src/Exception/InputException.php
  65. +6 −1 src/Exception/ValidationException.php
  66. +26 −0 src/Factory.php
  67. +72 −0 src/Helper/AbstractElement.php
  68. +53 −0 src/Helper/AccessKey.php
  69. +153 −0 src/Helper/AccessableTrait.php
  70. +72 −0 src/Helper/Parser.php
  71. +21 −0 src/Helper/RootAccessable.php
  72. +29 −0 src/Input/Input.php
  73. +14 −0 src/Input/RequestInput.php
  74. +52 −0 src/Input/RequestStringInput.php
  75. +52 −0 src/Input/ResponseStringInput.php
  76. +74 −0 src/Input/StringInputTrait.php
  77. +0 −131 src/Jsonapi.php
  78. +0 −167 src/Link.php
  79. +47 −0 src/Manager.php
  80. +90 −0 src/Manager/ErrorAbortManager.php
  81. +0 −110 src/Meta.php
  82. +0 −76 src/PaginationLink.php
  83. +0 −203 src/Relationship.php
  84. +0 −124 src/RelationshipCollection.php
  85. +0 −78 src/RelationshipLink.php
  86. +0 −212 src/Resource/Collection.php
  87. +0 −198 src/Resource/Identifier.php
  88. +0 −29 src/Resource/IdentifierCollection.php
  89. +0 −193 src/Resource/Item.php
  90. +0 −99 src/Resource/NullResource.php
  91. +0 −17 src/Resource/ResourceInterface.php
  92. +79 −0 src/Serializer/ArraySerializer.php
  93. +23 −0 src/Serializer/Serializer.php
  94. +0 −61 src/Utils/AccessTrait.php
  95. +0 −63 src/Utils/Factory.php
  96. +0 −18 src/Utils/FactoryInterface.php
  97. +0 −24 src/Utils/FactoryManagerInterface.php
  98. +0 −73 src/Utils/Helper.php
  99. +0 −44 src/Utils/LinksTrait.php
  100. +0 −69 src/Utils/Manager.php
  101. +0 −20 src/Utils/ManagerInterface.php
  102. +0 −50 src/Utils/MetaTrait.php
  103. +62 −0 src/V1/Attributes.php
  104. +122 −0 src/V1/Document.php
  105. +162 −0 src/V1/DocumentLink.php
  106. +119 −0 src/V1/Error.php
  107. +56 −0 src/V1/ErrorCollection.php
  108. +97 −0 src/V1/ErrorLink.php
  109. +64 −0 src/V1/ErrorSource.php
  110. +80 −0 src/V1/Factory.php
  111. +60 −0 src/V1/Jsonapi.php
  112. +75 −0 src/V1/Link.php
  113. +58 −0 src/V1/Meta.php
  114. +71 −0 src/V1/Relationship.php
  115. +66 −0 src/V1/RelationshipCollection.php
  116. +155 −0 src/V1/RelationshipLink.php
  117. +77 −0 src/V1/ResourceCollection.php
  118. +71 −0 src/V1/ResourceIdentifier.php
  119. +54 −0 src/V1/ResourceIdentifierCollection.php
  120. +89 −0 src/V1/ResourceItem.php
  121. +76 −0 src/V1/ResourceItemLink.php
  122. +68 −0 src/V1/ResourceNull.php
  123. +64 −0 tests/BC/AccessableTest.php
  124. +43 −0 tests/BC/ElementTest.php
  125. +30 −0 tests/BC/Exception/ExceptionTest.php
  126. +43 −0 tests/BC/FactoryTest.php
  127. +45 −0 tests/BC/Input/InputTest.php
  128. +30 −0 tests/BC/Input/RequestInputTest.php
  129. +69 −0 tests/BC/ManagerTest.php
  130. +43 −0 tests/BC/Serializer/SerializerTest.php
  131. +0 −23 tests/Bootstrap.php
  132. +17 −0 tests/Fixtures/AccessableElement.php
  133. +17 −0 tests/Fixtures/AccessableTraitMock.php
  134. +0 −28 tests/Fixtures/Factory.php
  135. +174 −39 tests/Fixtures/HelperTrait.php
  136. +43 −0 tests/Fixtures/V1Factory.php
  137. +212 −0 tests/Functional/DotNotationTest.php
  138. +144 −0 tests/Functional/ErrorParsingTest.php
  139. +652 −0 tests/Functional/ParsingTest.php
  140. +94 −0 tests/Functional/SerializerTest.php
  141. +68 −0 tests/Unit/Helper/AccessableTraitTest.php
  142. +157 −0 tests/Unit/Helper/ParserTest.php
  143. +50 −0 tests/Unit/Input/RequestStringInputTest.php
  144. +50 −0 tests/Unit/Input/ResponseStringInputTest.php
  145. +32 −0 tests/Unit/Manager/ErrorAbortManagerTest.php
  146. +107 −0 tests/Unit/Serializer/ArraySerializerTest.php
  147. +208 −0 tests/Unit/V1/AttributesTest.php
  148. +374 −0 tests/Unit/V1/DocumentLinkTest.php
  149. +425 −0 tests/Unit/V1/DocumentTest.php
  150. +108 −0 tests/Unit/V1/ErrorCollectionTest.php
  151. +168 −0 tests/Unit/V1/ErrorLinkTest.php
  152. +118 −0 tests/Unit/V1/ErrorSourceTest.php
  153. +164 −0 tests/Unit/V1/ErrorTest.php
  154. +66 −0 tests/Unit/V1/FactoryTest.php
  155. +116 −0 tests/Unit/V1/JsonapiTest.php
  156. +140 −0 tests/Unit/V1/LinkTest.php
  157. +107 −0 tests/Unit/V1/MetaTest.php
  158. +172 −0 tests/Unit/V1/RelationshipCollectionTest.php
  159. +456 −0 tests/Unit/V1/RelationshipLinkTest.php
  160. +218 −0 tests/Unit/V1/RelationshipTest.php
  161. +177 −0 tests/Unit/V1/ResourceCollectionTest.php
  162. +128 −0 tests/Unit/V1/ResourceIdentifierCollectionTest.php
  163. +180 −0 tests/Unit/V1/ResourceIdentifierTest.php
  164. +105 −0 tests/Unit/V1/ResourceItemLinkTest.php
  165. +181 −0 tests/Unit/V1/ResourceItemTest.php
  166. +114 −0 tests/Unit/V1/ResourceNullTest.php
  167. +5 −2 tests/files/03_resource_object.json
  168. +16 −0 tests/files/05_simple_meta_object.json
  169. +24 −0 tests/files/06_pagination_example.json
  170. +30 −0 tests/files/07_relationship_example_without_data.json
  171. +51 −0 tests/files/08_object_links.json
  172. +27 −0 tests/files/09_errors.json
  173. +26 −0 tests/files/10_error_with_links.json
  174. +9 −0 tests/files/11_resource_identifier_with_meta.json
  175. +3 −0 tests/files/12_null_resource.json
  176. +15 −0 tests/files/13_collection_with_resource_identifier_with_meta.json
  177. +14 −0 tests/files/14_create_resource_without_id.json
  178. +9 −0 tests/files/15_create_resource_without_id.json
  179. +10 −0 tests/files/16_type_and_id_as_integer.json
  180. +27 −0 tests/files/17_relationship_links.json
  181. +13 −0 tests/files/18_jsonapi_object_with_ext_profile.json
  182. +5 −0 tests/files/format_1.0/README.md
  183. +1,822 −0 tests/files/format_1.0/index.md
  184. +2,681 −0 tests/files/format_1.0/normative-statements.json
  185. +5 −0 tests/files/format_1.1/README.md
  186. +2,247 −0 tests/files/format_1.1/index.md
  187. +2,737 −0 tests/files/format_1.1/normative-statements.json
  188. +0 −316 tests/integration/IntegrationTest.php
  189. +0 −173 tests/unit/AttributesTest.php
  190. +0 −133 tests/unit/DocumentLinkTest.php
  191. +0 −444 tests/unit/DocumentTest.php
  192. +0 −110 tests/unit/ErrorCollectionTest.php
  193. +0 −116 tests/unit/ErrorLinkTest.php
  194. +0 −136 tests/unit/ErrorSourceTest.php
  195. +0 −221 tests/unit/ErrorTest.php
  196. +0 −122 tests/unit/JsonapiTest.php
  197. +0 −118 tests/unit/LinkTest.php
  198. +0 −125 tests/unit/MetaTest.php
  199. +0 −241 tests/unit/PaginationLinkTest.php
  200. +0 −197 tests/unit/RelationshipCollectionTest.php
  201. +0 −153 tests/unit/RelationshipLinkTest.php
  202. +0 −215 tests/unit/RelationshipTest.php
  203. +0 −210 tests/unit/Resource/CollectionTest.php
  204. +0 −144 tests/unit/Resource/IdentifierCollectionTest.php
  205. +0 −191 tests/unit/Resource/IdentifierTest.php
  206. +0 −107 tests/unit/Resource/ItemTest.php
  207. +0 −58 tests/unit/Resource/NullResourceTest.php
  208. +0 −35 tests/unit/Utils/FactoryTest.php
  209. +0 −42 tests/unit/Utils/HelperTest.php
  210. +0 −83 tests/unit/Utils/ManagerTest.php
54 changes: 54 additions & 0 deletions .docker/PHP83-Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM php:8.3-fpm

RUN apt-get update
RUN apt-get --yes --no-install-recommends install \
apt-utils
RUN apt-get --yes --no-install-recommends install \
git \
vim \
curl \
build-essential \
pipx \
locales \
zip unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmagickwand-dev \
libpng-dev \
libzip-dev
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg
RUN docker-php-ext-install -j$(nproc) \
pdo \
pdo_mysql \
mysqli \
zip \
exif \
intl \
sockets \
gd \
bcmath \
opcache

COPY build/php/opcache.ini /usr/local/etc/php/conf.d/
COPY build/php/custom.ini /usr/local/etc/php/conf.d/

RUN pecl install xdebug-3.3.0alpha3 && docker-php-ext-enable xdebug

RUN php --version

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

RUN composer --version

RUN usermod -u 1000 www-data
RUN usermod -a -G www-data root
RUN mkdir -p /var/www
RUN chown -R www-data:www-data /var/www
RUN mkdir -p /var/www/.composer
RUN chown -R www-data:www-data /var/www/.composer

WORKDIR /var/www/project/
6 changes: 6 additions & 0 deletions .docker/build/php/custom.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
date.timezone = "Europe/Berlin"
memory_limit = 4096M
upload_max_filesize = 200M
post_max_size = 200M

xdebug.mode = "develop,coverage"
93 changes: 93 additions & 0 deletions .docker/build/php/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
opcache.enable=1

; Determines if Zend OPCache is enabled for the CLI version of PHP
opcache.enable_cli=0

; The OPcache shared memory storage size.
opcache.memory_consumption=256

; The amount of memory for interned strings in Mbytes.
;opcache.interned_strings_buffer=4

; The maximum number of keys (scripts) in the OPcache hash table.
; Only numbers between 200 and 100000 are allowed.
opcache.max_accelerated_files=100000

; The maximum percentage of "wasted" memory until a restart is scheduled.
;opcache.max_wasted_percentage=5

; When this directive is enabled, the OPcache appends the current working
; directory to the script key, thus eliminating possible collisions between
; files with the same name (basename). Disabling the directive improves
; performance, but may break existing applications.
;opcache.use_cwd=1

; When disabled, you must reset the OPcache manually or restart the
; webserver for changes to the filesystem to take effect.
;opcache.validate_timestamps=1

; How often (in seconds) to check file timestamps for changes to the shared
; memory storage allocation. ("1" means validate once per second, but only
; once per request. "0" means always validate)
;opcache.revalidate_freq=2

; Enables or disables file search in include_path optimization
;opcache.revalidate_path=0

; If disabled, all PHPDoc comments are dropped from the code to reduce the
; size of the optimized code.
;opcache.save_comments=1

; If disabled, PHPDoc comments are not loaded from SHM, so "Doc Comments"
; may be always stored (save_comments=1), but not loaded by applications
; that don't need them anyway.
;opcache.load_comments=1

; If enabled, a fast shutdown sequence is used for the accelerated code
;opcache.fast_shutdown=0

; Allow file existence override (file_exists, etc.) performance feature.
;opcache.enable_file_override=0

; A bitmask, where each bit enables or disables the appropriate OPcache
; passes
;opcache.optimization_level=0xffffffff

;opcache.inherited_hack=1
;opcache.dups_fix=0

; The location of the OPcache blacklist file (wildcards allowed).
; Each OPcache blacklist file is a text file that holds the names of files
; that should not be accelerated. The file format is to add each filename
; to a new line. The filename may be a full path or just a file prefix
; (i.e., /var/www/x blacklists all the files and directories in /var/www
; that start with 'x'). Line starting with a ; are ignored (comments).
;opcache.blacklist_filename=

; Allows exclusion of large files from being cached. By default all files
; are cached.
;opcache.max_file_size=0

; Check the cache checksum each N requests.
; The default value of "0" means that the checks are disabled.
;opcache.consistency_checks=0

; How long to wait (in seconds) for a scheduled restart to begin if the cache
; is not being accessed.
;opcache.force_restart_timeout=180

; OPcache error_log file name. Empty string assumes "stderr".
;opcache.error_log=

; All OPcache errors go to the Web server log.
; By default, only fatal errors (level 0) or errors (level 1) are logged.
; You can also enable warnings (level 2), info messages (level 3) or
; debug messages (level 4).
;opcache.log_verbosity_level=1

; Preferred Shared Memory back-end. Leave empty and let the system decide.
;opcache.preferred_memory_model=

; Protect the shared memory from unexpected writing during script execution.
; Useful for internal debugging only.
;opcache.protect_memory=0
11 changes: 8 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/docs export-ignore
/tests export-ignore
# SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
# SPDX-License-Identifier: GPL-3.0-or-later

/.docker export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.phpstan.neon export-ignore
/docker-compose.yml export-ignore
/docs export-ignore
/phpunit.xml export-ignore
/tests export-ignore
37 changes: 37 additions & 0 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Code style

on:
push:
pull_request:

jobs:

check-code-style:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: ['8.3']

name: "Check code style | PHP ${{ matrix.php }}"

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install PHP with latest composer
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=-1, display_errors=On, log_errors_max_len=0
coverage: none
tools: none

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: "Install Composer dependencies"
uses: "ramsey/composer-install@v2"

- name: "Check code style"
run: composer run codestyle -- --dry-run
36 changes: 36 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PHPStan

on:
push:
pull_request:

jobs:

tests:
name: Run PHPStan with PHP ${{ matrix.php }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php: ['8.3']

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup PHP with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: none

- name: Install Composer dependencies
uses: "ramsey/composer-install@v2"

- name: Run PHPStan
run: composer run phpstan
58 changes: 58 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: PHPUnit

on:
push:
pull_request:

jobs:

tests:
name: Tests (PHP ${{ matrix.php }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php:
- '8.5'
- '8.4'
- '8.3'
- '8.2'
- '8.1'

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Setup PHP with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: none

- name: "Install Composer dependencies"
if: ${{ matrix.php <= '8.4' }}
uses: "ramsey/composer-install@v2"

- name: "Install Composer dependencies (PHP 8.5)"
if: ${{ matrix.php >= '8.5' }}
uses: "ramsey/composer-install@v2"
with:
composer-options: --ignore-platform-reqs

- name: Run tests
run: composer run phpunit -- --coverage-clover .phpunit.cache/clover.xml

- name: Upload coverage reports to Codecov
if: ${{ success() && matrix.php == '8.4' }}
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./.phpunit.cache/clover.xml
fail_ci_if_error: true
verbose: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
composer.phar
.php-cs-fixer.cache
.phpunit.cache
composer.lock
vendor
23 changes: 23 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt
//
// SPDX-License-Identifier: GPL-3.0-or-later

$finder = (new PhpCsFixer\Finder())
->in('src')
->in('tests')
;

return (new PhpCsFixer\Config())
->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'@PHP81Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit84Migration:risky' => true,
'no_alias_functions' => true,
])
->setFinder($finder)
->setRiskyAllowed(true)
;
Loading