From acb3924031edfa178c09884d9a1b90e25387f60e Mon Sep 17 00:00:00 2001
From: Frederik Bosch <f.bosch@genkgo.nl>
Date: Mon, 5 Sep 2022 16:06:57 +0200
Subject: [PATCH] 3.x json serialize (#707)

* fix deprecation on jsonSerialize

* upgrade repo checks

Co-authored-by: Massimiliano Arione <garakkio@gmail.com>
---
 .github/workflows/checks.yml |  2 +-
 .github/workflows/ci.yml     | 10 +++++-----
 .github/workflows/static.yml | 12 ++++++------
 composer.json                | 28 ++++++++++++++++------------
 doc/conf.py                  |  5 +++--
 doc/requirements.txt         |  7 ++++---
 doc/spelling_word_list.txt   |  1 +
 src/Currency.php             |  1 +
 src/Money.php                |  1 +
 9 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 856c825b1..693140960 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -13,7 +13,7 @@ jobs:
 
     steps:
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: Install
         uses: docker://composer
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 66de72ca8..c6e8fa2f8 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,7 +13,7 @@ jobs:
 
     steps:
       - name: Set up PHP
-        uses: shivammathur/setup-php@1.7.0
+        uses: shivammathur/setup-php@v2
         with:
           php-version: '5.6'
           extensions: bcmath, gmp, intl, dom, mbstring
@@ -22,7 +22,7 @@ jobs:
         run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
 
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: Set up locales
         run: ./hack/setup-locales.sh
@@ -43,7 +43,7 @@ jobs:
 
     steps:
       - name: Set up PHP
-        uses: shivammathur/setup-php@1.6.2
+        uses: shivammathur/setup-php@v2
         with:
           php-version: ${{ matrix.php }}
           extensions: bcmath, gmp, intl, dom, mbstring
@@ -52,7 +52,7 @@ jobs:
         run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
 
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: Set up locales
         run: ./hack/setup-locales.sh
@@ -74,7 +74,7 @@ jobs:
           architecture: 'x64'
 
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: Install dependencies
         run: |
diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index cec3eb8f9..d65610e9f 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -32,12 +32,12 @@ jobs:
 
     steps:
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: PHP-CS-Fixer
-        uses: docker://oskarstark/php-cs-fixer-ga:2.16.3.1
+        uses: docker://oskarstark/php-cs-fixer-ga:2.19.0
         with:
-          args: --dry-run --diff-format udiff
+          args: src --dry-run --diff-format udiff
 
   psalm:
     name: Psalm
@@ -45,7 +45,7 @@ jobs:
 
     steps:
       - name: Checkout code
-        uses: actions/checkout@v1
+        uses: actions/checkout@v2
 
       - name: Install
         uses: docker://composer
@@ -53,7 +53,7 @@ jobs:
           args: install --ignore-platform-reqs --no-ansi --no-suggest
 
       - name: Psalm
-        uses: docker://vimeo/psalm-github-actions
+        uses: docker://vimeo/psalm-github-actions:3.14.2
         with:
           entrypoint: ./.github/workflows/psalm.entrypoint
-          args: --threads=8 --diff --diff-methods
+          args: --threads=8 --diff
diff --git a/composer.json b/composer.json
index ce480a487..cd522d384 100644
--- a/composer.json
+++ b/composer.json
@@ -1,13 +1,12 @@
 {
     "name": "moneyphp/money",
     "description": "PHP implementation of Fowler's Money pattern",
+    "license": "MIT",
     "keywords": [
         "money",
         "vo",
         "value object"
     ],
-    "homepage": "http://moneyphp.org",
-    "license": "MIT",
     "authors": [
         {
             "name": "Mathias Verraes",
@@ -23,6 +22,7 @@
             "email": "f.bosch@genkgo.nl"
         }
     ],
+    "homepage": "http://moneyphp.org",
     "require": {
         "php": ">=5.6",
         "ext-json": "*"
@@ -52,14 +52,8 @@
         "florianv/swap": "Exchange rates library for PHP",
         "psr/cache-implementation": "Used for Currency caching"
     },
-    "config": {
-        "sort-packages": true
-    },
-    "extra": {
-        "branch-alias": {
-            "dev-master": "3.x-dev"
-        }
-    },
+    "minimum-stability": "dev",
+    "prefer-stable": true,
     "autoload": {
         "psr-4": {
             "Money\\": "src/"
@@ -71,8 +65,18 @@
             "spec\\Money\\": "spec/"
         }
     },
-    "minimum-stability": "dev",
-    "prefer-stable": true,
+    "config": {
+        "allow-plugins": {
+            "dealerdirect/phpcodesniffer-composer-installer": true,
+            "ergebnis/composer-normalize": true
+        },
+        "sort-packages": true
+    },
+    "extra": {
+        "branch-alias": {
+            "dev-master": "3.x-dev"
+        }
+    },
     "scripts": {
         "clean": "rm -rf build/ vendor/",
         "test": [
diff --git a/doc/conf.py b/doc/conf.py
index 744319aeb..13480774d 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -37,6 +37,7 @@
 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
 # ones.
 extensions = [
+    'sphinxcontrib.phpdomain',
     'sphinxcontrib.spelling'
 ]
 
@@ -155,8 +156,8 @@
 html_static_path = ['_static']
 
 def setup(app):
-    app.add_stylesheet('custom.css')
-    app.add_stylesheet('highlight.css')
+    app.add_css_file('custom.css')
+    app.add_css_file('highlight.css')
 
 # Add any extra paths that contain custom files (such as robots.txt or
 # .htaccess) here, relative to this directory. These files are copied
diff --git a/doc/requirements.txt b/doc/requirements.txt
index 8f6d1f5a0..cadd68832 100644
--- a/doc/requirements.txt
+++ b/doc/requirements.txt
@@ -1,5 +1,6 @@
 git+https://github.com/fabpot/sphinx-php.git
-sphinx~=1.3.0
-sphinx-rtd-theme==0.1.6
-sphinxcontrib-spelling==4.2.0
+sphinx~=4.3.1
+sphinx-rtd-theme==1.0.0
+git+https://github.com/markstory/sphinxcontrib-phpdomain.git
+sphinxcontrib-spelling==7.2.1
 pyenchant
diff --git a/doc/spelling_word_list.txt b/doc/spelling_word_list.txt
index 199601d79..788c4f356 100644
--- a/doc/spelling_word_list.txt
+++ b/doc/spelling_word_list.txt
@@ -12,6 +12,7 @@ Formatter
 unprobable
 Instantiation
 instantiation
+Exchanger
 
 Foemmel
 Hieatt
diff --git a/src/Currency.php b/src/Currency.php
index c81f23687..93eb13e30 100644
--- a/src/Currency.php
+++ b/src/Currency.php
@@ -79,6 +79,7 @@ public function __toString()
      *
      * @return string
      */
+    #[\ReturnTypeWillChange]
     public function jsonSerialize()
     {
         return $this->code;
diff --git a/src/Money.php b/src/Money.php
index 891660228..9b408364e 100644
--- a/src/Money.php
+++ b/src/Money.php
@@ -491,6 +491,7 @@ public function isNegative()
      *
      * @return array
      */
+    #[\ReturnTypeWillChange]
     public function jsonSerialize()
     {
         return [