Merge branch 'release/v6.1.0-alpha.1'

This commit is contained in:
James Cole 2023-12-10 07:05:51 +01:00
commit 0b22b056bc
1142 changed files with 12615 additions and 10973 deletions

View File

@ -36,9 +36,15 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
'@PHP83Migration' => true,
'@PhpCsFixer:risky' => true,
'@PSR12:risky' => true,
'declare_strict_types' => true,
'strict_param' => true,
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false, // annoying
'php_unit_data_provider_name' => false, // bloody annoying long test names
'static_lambda' => false, // breaks the Response macro for API's.
])
->setFinder($finder);

View File

@ -226,50 +226,48 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.37.0",
"version": "v3.41.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b"
"reference": "7d8d18e19095a939b8a3b8046f57108feaad6134"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
"reference": "d5ccc3807fd496ac2b448e8e5e57aa0772f0d18b",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7d8d18e19095a939b8a3b8046f57108feaad6134",
"reference": "7d8d18e19095a939b8a3b8046f57108feaad6134",
"shasum": ""
},
"require": {
"composer/semver": "^3.3",
"composer/semver": "^3.4",
"composer/xdebug-handler": "^3.0.3",
"ext-json": "*",
"ext-tokenizer": "*",
"php": "^7.4 || ^8.0",
"sebastian/diff": "^4.0 || ^5.0",
"symfony/console": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/filesystem": "^5.4 || ^6.0",
"symfony/finder": "^5.4 || ^6.0",
"symfony/options-resolver": "^5.4 || ^6.0",
"symfony/polyfill-mbstring": "^1.27",
"symfony/polyfill-php80": "^1.27",
"symfony/polyfill-php81": "^1.27",
"symfony/process": "^5.4 || ^6.0",
"symfony/stopwatch": "^5.4 || ^6.0"
"symfony/console": "^5.4 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.0 || ^7.0",
"symfony/polyfill-mbstring": "^1.28",
"symfony/polyfill-php80": "^1.28",
"symfony/polyfill-php81": "^1.28",
"symfony/process": "^5.4 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"facile-it/paraunit": "^1.3 || ^2.0",
"justinrainbow/json-schema": "^5.2",
"keradus/cli-executor": "^2.0",
"keradus/cli-executor": "^2.1",
"mikey179/vfsstream": "^1.6.11",
"php-coveralls/php-coveralls": "^2.5.3",
"php-coveralls/php-coveralls": "^2.7",
"php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",
"phpspec/prophecy": "^1.16",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.5",
"symfony/phpunit-bridge": "^6.2.3",
"symfony/yaml": "^5.4 || ^6.0"
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
"ext-dom": "For handling output formats in XML",
@ -307,7 +305,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.37.0"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.0"
},
"funding": [
{
@ -315,7 +313,7 @@
"type": "github"
}
],
"time": "2023-10-28T14:49:50+00:00"
"time": "2023-12-08T22:54:33+00:00"
},
{
"name": "psr/container",
@ -539,43 +537,46 @@
},
{
"name": "symfony/console",
"version": "v6.3.4",
"version": "v7.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "eca495f2ee845130855ddf1cf18460c38966c8b6"
"reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/eca495f2ee845130855ddf1cf18460c38966c8b6",
"reference": "eca495f2ee845130855ddf1cf18460c38966c8b6",
"url": "https://api.github.com/repos/symfony/console/zipball/cdce5c684b2f920bb1343deecdfba356ffad83d5",
"reference": "cdce5c684b2f920bb1343deecdfba356ffad83d5",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony/deprecation-contracts": "^2.5|^3",
"php": ">=8.2",
"symfony/polyfill-mbstring": "~1.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/string": "^5.4|^6.0"
"symfony/string": "^6.4|^7.0"
},
"conflict": {
"symfony/dependency-injection": "<5.4",
"symfony/dotenv": "<5.4",
"symfony/event-dispatcher": "<5.4",
"symfony/lock": "<5.4",
"symfony/process": "<5.4"
"symfony/dependency-injection": "<6.4",
"symfony/dotenv": "<6.4",
"symfony/event-dispatcher": "<6.4",
"symfony/lock": "<6.4",
"symfony/process": "<6.4"
},
"provide": {
"psr/log-implementation": "1.0|2.0|3.0"
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/lock": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/var-dumper": "^5.4|^6.0"
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"symfony/lock": "^6.4|^7.0",
"symfony/messenger": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0",
"symfony/stopwatch": "^6.4|^7.0",
"symfony/var-dumper": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -609,7 +610,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v6.3.4"
"source": "https://github.com/symfony/console/tree/v7.0.1"
},
"funding": [
{
@ -625,11 +626,11 @@
"type": "tidelift"
}
],
"time": "2023-08-16T10:10:12+00:00"
"time": "2023-12-01T15:10:06+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
@ -676,7 +677,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
},
"funding": [
{
@ -696,24 +697,24 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v6.3.2",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e"
"reference": "c459b40ffe67c49af6fd392aac374c9edf8a027e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e",
"reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/c459b40ffe67c49af6fd392aac374c9edf8a027e",
"reference": "c459b40ffe67c49af6fd392aac374c9edf8a027e",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/event-dispatcher-contracts": "^2.5|^3"
},
"conflict": {
"symfony/dependency-injection": "<5.4",
"symfony/dependency-injection": "<6.4",
"symfony/service-contracts": "<2.5"
},
"provide": {
@ -722,13 +723,13 @@
},
"require-dev": {
"psr/log": "^1|^2|^3",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/error-handler": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/http-foundation": "^5.4|^6.0",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^6.4|^7.0",
"symfony/error-handler": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/stopwatch": "^5.4|^6.0"
"symfony/stopwatch": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -756,7 +757,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2"
"source": "https://github.com/symfony/event-dispatcher/tree/v7.0.0"
},
"funding": [
{
@ -772,11 +773,11 @@
"type": "tidelift"
}
],
"time": "2023-07-06T06:56:43+00:00"
"time": "2023-07-27T16:29:09+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
@ -832,7 +833,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.4.0"
},
"funding": [
{
@ -852,20 +853,20 @@
},
{
"name": "symfony/filesystem",
"version": "v6.3.1",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae"
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae",
"reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8"
},
@ -895,7 +896,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v6.3.1"
"source": "https://github.com/symfony/filesystem/tree/v7.0.0"
},
"funding": [
{
@ -911,27 +912,27 @@
"type": "tidelift"
}
],
"time": "2023-06-01T08:30:39+00:00"
"time": "2023-07-27T06:33:22+00:00"
},
{
"name": "symfony/finder",
"version": "v6.3.5",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4"
"reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/a1b31d88c0e998168ca7792f222cbecee47428c4",
"reference": "a1b31d88c0e998168ca7792f222cbecee47428c4",
"url": "https://api.github.com/repos/symfony/finder/zipball/6e5688d69f7cfc4ed4a511e96007e06c2d34ce56",
"reference": "6e5688d69f7cfc4ed4a511e96007e06c2d34ce56",
"shasum": ""
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"symfony/filesystem": "^6.0"
"symfony/filesystem": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -959,7 +960,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.3.5"
"source": "https://github.com/symfony/finder/tree/v7.0.0"
},
"funding": [
{
@ -975,24 +976,24 @@
"type": "tidelift"
}
],
"time": "2023-09-26T12:56:25+00:00"
"time": "2023-10-31T17:59:56+00:00"
},
{
"name": "symfony/options-resolver",
"version": "v6.3.0",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "a10f19f5198d589d5c33333cffe98dc9820332dd"
"reference": "700ff4096e346f54cb628ea650767c8130f1001f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd",
"reference": "a10f19f5198d589d5c33333cffe98dc9820332dd",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/700ff4096e346f54cb628ea650767c8130f1001f",
"reference": "700ff4096e346f54cb628ea650767c8130f1001f",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3"
},
"type": "library",
@ -1026,7 +1027,7 @@
"options"
],
"support": {
"source": "https://github.com/symfony/options-resolver/tree/v6.3.0"
"source": "https://github.com/symfony/options-resolver/tree/v7.0.0"
},
"funding": [
{
@ -1042,7 +1043,7 @@
"type": "tidelift"
}
],
"time": "2023-05-12T14:21:09+00:00"
"time": "2023-08-08T10:20:21+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -1538,20 +1539,20 @@
},
{
"name": "symfony/process",
"version": "v6.3.4",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "0b5c29118f2e980d455d2e34a5659f4579847c54"
"reference": "13bdb1670c7f510494e04fcb2bfa29af63db9c0d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/0b5c29118f2e980d455d2e34a5659f4579847c54",
"reference": "0b5c29118f2e980d455d2e34a5659f4579847c54",
"url": "https://api.github.com/repos/symfony/process/zipball/13bdb1670c7f510494e04fcb2bfa29af63db9c0d",
"reference": "13bdb1670c7f510494e04fcb2bfa29af63db9c0d",
"shasum": ""
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"type": "library",
"autoload": {
@ -1579,7 +1580,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v6.3.4"
"source": "https://github.com/symfony/process/tree/v7.0.0"
},
"funding": [
{
@ -1595,20 +1596,20 @@
"type": "tidelift"
}
],
"time": "2023-08-07T10:39:22+00:00"
"time": "2023-11-20T16:43:42+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4"
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"shasum": ""
},
"require": {
@ -1661,7 +1662,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/service-contracts/tree/v3.4.0"
},
"funding": [
{
@ -1677,24 +1678,24 @@
"type": "tidelift"
}
],
"time": "2023-05-23T14:45:45+00:00"
"time": "2023-07-30T20:28:31+00:00"
},
{
"name": "symfony/stopwatch",
"version": "v6.3.0",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2"
"reference": "7bbfa3dd564a0ce12eb4acaaa46823c740f9cb7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2",
"reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/7bbfa3dd564a0ce12eb4acaaa46823c740f9cb7a",
"reference": "7bbfa3dd564a0ce12eb4acaaa46823c740f9cb7a",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/service-contracts": "^2.5|^3"
},
"type": "library",
@ -1723,7 +1724,7 @@
"description": "Provides a way to profile code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/stopwatch/tree/v6.3.0"
"source": "https://github.com/symfony/stopwatch/tree/v7.0.0"
},
"funding": [
{
@ -1739,24 +1740,24 @@
"type": "tidelift"
}
],
"time": "2023-02-16T10:14:28+00:00"
"time": "2023-07-05T13:06:06+00:00"
},
{
"name": "symfony/string",
"version": "v6.3.5",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339"
"reference": "92bd2bfbba476d4a1838e5e12168bef2fd1e6620"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/13d76d0fb049051ed12a04bef4f9de8715bea339",
"reference": "13d76d0fb049051ed12a04bef4f9de8715bea339",
"url": "https://api.github.com/repos/symfony/string/zipball/92bd2bfbba476d4a1838e5e12168bef2fd1e6620",
"reference": "92bd2bfbba476d4a1838e5e12168bef2fd1e6620",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-grapheme": "~1.0",
"symfony/polyfill-intl-normalizer": "~1.0",
@ -1766,11 +1767,11 @@
"symfony/translation-contracts": "<2.5"
},
"require-dev": {
"symfony/error-handler": "^5.4|^6.0",
"symfony/http-client": "^5.4|^6.0",
"symfony/intl": "^6.2",
"symfony/error-handler": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^5.4|^6.0"
"symfony/var-exporter": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -1809,7 +1810,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v6.3.5"
"source": "https://github.com/symfony/string/tree/v7.0.0"
},
"funding": [
{
@ -1825,7 +1826,7 @@
"type": "tidelift"
}
],
"time": "2023-09-18T10:38:32+00:00"
"time": "2023-11-29T08:40:23+00:00"
}
],
"packages-dev": [],
@ -1836,5 +1837,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}

View File

@ -28,11 +28,29 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# enable test .env file.
# cp .ci/.env.ci .env
OUTPUT_FORMAT=txt
EXTRA_PARAMS="-v"
if [[ $GITHUB_ACTIONS = "true" ]]
then
OUTPUT_FORMAT=gitlab
EXTRA_PARAMS="--diff --dry-run"
fi
# clean up php code
cd $SCRIPT_DIR/php-cs-fixer
composer update --quiet
rm -f .php-cs-fixer.cache
PHP_CS_FIXER_IGNORE_ENV=true ./vendor/bin/php-cs-fixer fix --config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php --allow-risky=yes
PHP_CS_FIXER_IGNORE_ENV=true
./vendor/bin/php-cs-fixer fix \
--config $SCRIPT_DIR/php-cs-fixer/.php-cs-fixer.php \
--format=$OUTPUT_FORMAT \
--allow-risky=yes $EXTRA_PARAMS
EXIT_CODE=$?
echo "Exit code for CS fixer is $EXIT_CODE."
cd $SCRIPT_DIR/..
exit 0
exit $EXIT_CODE

18
.ci/phpmd.sh Normal file → Executable file
View File

@ -22,16 +22,30 @@
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
OUTPUT_FORMAT=text
if [[ $GITHUB_ACTIONS = "true" ]]
then
OUTPUT_FORMAT=github
fi
cd $SCRIPT_DIR/phpmd
composer update --quiet
./vendor/bin/phpmd \
$SCRIPT_DIR/../app text phpmd.xml \
$SCRIPT_DIR/../app,$SCRIPT_DIR/../database,$SCRIPT_DIR/../routes,$SCRIPT_DIR/../config \
$OUTPUT_FORMAT phpmd.xml \
--exclude $SCRIPT_DIR/../app/resources/** \
--exclude $SCRIPT_DIR/../app/frontend/** \
--exclude $SCRIPT_DIR/../app/public/** \
--exclude $SCRIPT_DIR/../app/vendor/** \
--exclude $SCRIPT_DIR/../app/vendor/**
EXIT_CODE=$?
cd $SCRIPT_DIR/..
echo "Exit code is $EXIT_CODE, but we ignore this for the time being."
# for the time being, exit 0
#exit $EXIT_CODE
exit 0

181
.ci/phpmd/composer.lock generated
View File

@ -9,16 +9,16 @@
"packages-dev": [
{
"name": "composer/pcre",
"version": "3.1.0",
"version": "3.1.1",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2"
"reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2",
"reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2",
"url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9",
"reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9",
"shasum": ""
},
"require": {
@ -60,7 +60,7 @@
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.1.0"
"source": "https://github.com/composer/pcre/tree/3.1.1"
},
"funding": [
{
@ -76,7 +76,7 @@
"type": "tidelift"
}
],
"time": "2022-11-17T09:50:14+00:00"
"time": "2023-10-11T07:11:09+00:00"
},
{
"name": "composer/xdebug-handler",
@ -146,23 +146,24 @@
},
{
"name": "pdepend/pdepend",
"version": "2.14.0",
"version": "2.16.0",
"source": {
"type": "git",
"url": "https://github.com/pdepend/pdepend.git",
"reference": "1121d4b04af06e33e9659bac3a6741b91cab1de1"
"reference": "8dfc0c46529e2073fa97986552f80646eedac562"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pdepend/pdepend/zipball/1121d4b04af06e33e9659bac3a6741b91cab1de1",
"reference": "1121d4b04af06e33e9659bac3a6741b91cab1de1",
"url": "https://api.github.com/repos/pdepend/pdepend/zipball/8dfc0c46529e2073fa97986552f80646eedac562",
"reference": "8dfc0c46529e2073fa97986552f80646eedac562",
"shasum": ""
},
"require": {
"php": ">=5.3.7",
"symfony/config": "^2.3.0|^3|^4|^5|^6.0",
"symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0",
"symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0"
"symfony/config": "^2.3.0|^3|^4|^5|^6.0|^7.0",
"symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0|^7.0",
"symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0|^7.0",
"symfony/polyfill-mbstring": "^1.19"
},
"require-dev": {
"easy-doc/easy-doc": "0.0.0|^1.2.3",
@ -197,7 +198,7 @@
],
"support": {
"issues": "https://github.com/pdepend/pdepend/issues",
"source": "https://github.com/pdepend/pdepend/tree/2.14.0"
"source": "https://github.com/pdepend/pdepend/tree/2.16.0"
},
"funding": [
{
@ -205,26 +206,26 @@
"type": "tidelift"
}
],
"time": "2023-05-26T13:15:18+00:00"
"time": "2023-11-29T08:52:35+00:00"
},
{
"name": "phpmd/phpmd",
"version": "2.13.0",
"version": "2.14.1",
"source": {
"type": "git",
"url": "https://github.com/phpmd/phpmd.git",
"reference": "dad0228156856b3ad959992f9748514fa943f3e3"
"reference": "442fc2c34edcd5198b442d8647c7f0aec3afabe8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpmd/phpmd/zipball/dad0228156856b3ad959992f9748514fa943f3e3",
"reference": "dad0228156856b3ad959992f9748514fa943f3e3",
"url": "https://api.github.com/repos/phpmd/phpmd/zipball/442fc2c34edcd5198b442d8647c7f0aec3afabe8",
"reference": "442fc2c34edcd5198b442d8647c7f0aec3afabe8",
"shasum": ""
},
"require": {
"composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0",
"ext-xml": "*",
"pdepend/pdepend": "^2.12.1",
"pdepend/pdepend": "^2.15.1",
"php": ">=5.3.9"
},
"require-dev": {
@ -234,7 +235,7 @@
"gregwar/rst": "^1.0",
"mikey179/vfsstream": "^1.6.8",
"phpunit/phpunit": "^4.8.36 || ^5.7.27",
"squizlabs/php_codesniffer": "^2.0"
"squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2"
},
"bin": [
"src/bin/phpmd"
@ -271,6 +272,7 @@
"description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.",
"homepage": "https://phpmd.org/",
"keywords": [
"dev",
"mess detection",
"mess detector",
"pdepend",
@ -280,7 +282,7 @@
"support": {
"irc": "irc://irc.freenode.org/phpmd",
"issues": "https://github.com/phpmd/phpmd/issues",
"source": "https://github.com/phpmd/phpmd/tree/2.13.0"
"source": "https://github.com/phpmd/phpmd/tree/2.14.1"
},
"funding": [
{
@ -288,7 +290,7 @@
"type": "tidelift"
}
],
"time": "2022-09-10T08:44:15+00:00"
"time": "2023-09-28T13:07:44+00:00"
},
{
"name": "psr/container",
@ -395,34 +397,34 @@
},
{
"name": "symfony/config",
"version": "v6.3.0",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "a5e00dec161b08c946a2c16eed02adbeedf827ae"
"reference": "8789646600f4e7e451dde9e1dc81cfa429f3857a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/a5e00dec161b08c946a2c16eed02adbeedf827ae",
"reference": "a5e00dec161b08c946a2c16eed02adbeedf827ae",
"url": "https://api.github.com/repos/symfony/config/zipball/8789646600f4e7e451dde9e1dc81cfa429f3857a",
"reference": "8789646600f4e7e451dde9e1dc81cfa429f3857a",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/filesystem": "^5.4|^6.0",
"symfony/filesystem": "^6.4|^7.0",
"symfony/polyfill-ctype": "~1.8"
},
"conflict": {
"symfony/finder": "<5.4",
"symfony/finder": "<6.4",
"symfony/service-contracts": "<2.5"
},
"require-dev": {
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/finder": "^5.4|^6.0",
"symfony/messenger": "^5.4|^6.0",
"symfony/event-dispatcher": "^6.4|^7.0",
"symfony/finder": "^6.4|^7.0",
"symfony/messenger": "^6.4|^7.0",
"symfony/service-contracts": "^2.5|^3",
"symfony/yaml": "^5.4|^6.0"
"symfony/yaml": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -450,7 +452,7 @@
"description": "Helps you find, load, combine, autofill and validate configuration values of any kind",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/config/tree/v6.3.0"
"source": "https://github.com/symfony/config/tree/v7.0.0"
},
"funding": [
{
@ -466,44 +468,43 @@
"type": "tidelift"
}
],
"time": "2023-04-25T10:46:17+00:00"
"time": "2023-11-09T08:30:23+00:00"
},
{
"name": "symfony/dependency-injection",
"version": "v6.3.1",
"version": "v7.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
"reference": "7abf242af21f196b65f20ab00ff251fdf3889b8d"
"reference": "f6667642954bce638733f254c39e5b5700b47ba4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/7abf242af21f196b65f20ab00ff251fdf3889b8d",
"reference": "7abf242af21f196b65f20ab00ff251fdf3889b8d",
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f6667642954bce638733f254c39e5b5700b47ba4",
"reference": "f6667642954bce638733f254c39e5b5700b47ba4",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"psr/container": "^1.1|^2.0",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/service-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.2.10"
"symfony/service-contracts": "^3.3",
"symfony/var-exporter": "^6.4|^7.0"
},
"conflict": {
"ext-psr": "<1.1|>=2",
"symfony/config": "<6.1",
"symfony/finder": "<5.4",
"symfony/proxy-manager-bridge": "<6.3",
"symfony/yaml": "<5.4"
"symfony/config": "<6.4",
"symfony/finder": "<6.4",
"symfony/yaml": "<6.4"
},
"provide": {
"psr/container-implementation": "1.1|2.0",
"symfony/service-implementation": "1.1|2.0|3.0"
},
"require-dev": {
"symfony/config": "^6.1",
"symfony/expression-language": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0"
"symfony/config": "^6.4|^7.0",
"symfony/expression-language": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -531,7 +532,7 @@
"description": "Allows you to standardize and centralize the way objects are constructed in your application",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dependency-injection/tree/v6.3.1"
"source": "https://github.com/symfony/dependency-injection/tree/v7.0.1"
},
"funding": [
{
@ -547,11 +548,11 @@
"type": "tidelift"
}
],
"time": "2023-06-24T11:51:27+00:00"
"time": "2023-12-01T15:10:06+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
@ -598,7 +599,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0"
},
"funding": [
{
@ -618,20 +619,20 @@
},
{
"name": "symfony/filesystem",
"version": "v6.3.1",
"version": "v7.0.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae"
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae",
"reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"reference": "7da8ea2362a283771478c5f7729cfcb43a76b8b7",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.8"
},
@ -661,7 +662,7 @@
"description": "Provides basic utilities for the filesystem",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/filesystem/tree/v6.3.1"
"source": "https://github.com/symfony/filesystem/tree/v7.0.0"
},
"funding": [
{
@ -677,20 +678,20 @@
"type": "tidelift"
}
],
"time": "2023-06-01T08:30:39+00:00"
"time": "2023-07-27T06:33:22+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.27.0",
"version": "v1.28.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a"
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a",
"reference": "5bbc823adecdae860bb64756d639ecfec17b050a",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
"reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb",
"shasum": ""
},
"require": {
@ -705,7 +706,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
"dev-main": "1.28-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -743,7 +744,7 @@
"portable"
],
"support": {
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0"
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0"
},
"funding": [
{
@ -759,20 +760,20 @@
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
"time": "2023-01-26T09:26:14+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.27.0",
"version": "v1.28.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
"reference": "42292d99c55abe617799667f454222c54c60e229"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229",
"reference": "42292d99c55abe617799667f454222c54c60e229",
"shasum": ""
},
"require": {
@ -787,7 +788,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.27-dev"
"dev-main": "1.28-dev"
},
"thanks": {
"name": "symfony/polyfill",
@ -826,7 +827,7 @@
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0"
},
"funding": [
{
@ -842,20 +843,20 @@
"type": "tidelift"
}
],
"time": "2022-11-03T14:55:06+00:00"
"time": "2023-07-28T09:04:16+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.3.0",
"version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4"
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"reference": "40da9cc13ec349d9e4966ce18b5fbcd724ab10a4",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"reference": "b3313c2dbffaf71c8de2934e2ea56ed2291a3838",
"shasum": ""
},
"require": {
@ -908,7 +909,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.3.0"
"source": "https://github.com/symfony/service-contracts/tree/v3.4.0"
},
"funding": [
{
@ -924,27 +925,27 @@
"type": "tidelift"
}
],
"time": "2023-05-23T14:45:45+00:00"
"time": "2023-07-30T20:28:31+00:00"
},
{
"name": "symfony/var-exporter",
"version": "v6.3.0",
"version": "v7.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-exporter.git",
"reference": "db5416d04269f2827d8c54331ba4cfa42620d350"
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/db5416d04269f2827d8c54331ba4cfa42620d350",
"reference": "db5416d04269f2827d8c54331ba4cfa42620d350",
"url": "https://api.github.com/repos/symfony/var-exporter/zipball/a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
"reference": "a3d7c877414fcd59ab7075ecdc3b8f9c00f7bcc3",
"shasum": ""
},
"require": {
"php": ">=8.1"
"php": ">=8.2"
},
"require-dev": {
"symfony/var-dumper": "^5.4|^6.0"
"symfony/var-dumper": "^6.4|^7.0"
},
"type": "library",
"autoload": {
@ -982,7 +983,7 @@
"serialize"
],
"support": {
"source": "https://github.com/symfony/var-exporter/tree/v6.3.0"
"source": "https://github.com/symfony/var-exporter/tree/v7.0.1"
},
"funding": [
{
@ -998,7 +999,7 @@
"type": "tidelift"
}
],
"time": "2023-04-21T08:48:44+00:00"
"time": "2023-11-30T11:38:21+00:00"
}
],
"aliases": [],
@ -1008,5 +1009,5 @@
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
"plugin-api-version": "2.6.0"
}

View File

@ -24,41 +24,60 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Bla bla</description>
<!--
Commando vanuit firefly directory:
phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/report.html
-->
<description>Firefly III ruleset.</description>
<!-- Import the entire controversial code rule set -->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName"/>
</rule>
<!-- clean code -->
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml" />
<!-- <rule ref="rulesets/codesize.xml" /> -->
<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/design.xml/NumberOfChildren">
<properties>
<!-- TODO we want to be at minimum 15. But we start high, and drop the bar slowly. -->
<property name="minimum" value="256"/>
</properties>
</rule>
<rule ref="rulesets/design.xml/CouplingBetweenObjects">
<properties>
<!-- TODO we want to be at maximum 13. But we start high, and drop the bar slowly. -->
<property name="maximum" value="256"/>
</properties>
</rule>
<rule ref="rulesets/naming.xml/ShortMethodName">
<properties>
<property name="minimum" value="3"/>
</properties>
</rule>
<!-- code size -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="5"/>
<!-- TODO we want to be at report level 5. But we start high, and drop the bar slowly. -->
<property name="reportLevel" value="500"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="128"/>
<!-- TODO we want to be at a value of 128. But we start high, and drop the bar slowly. -->
<property name="minimum" value="24062500"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="40"/>
<!-- TODO we want to be at a value of 40. But we start high, and drop the bar slowly. -->
<property name="minimum" value="100"/>
<property name="ignore-whitespace" value="true"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<!-- 5 is fine. 6 is excessive, but I have just one of those. At the end of the day, I still need all params. -->
<property name="minimum" value="5"/>
</properties>
</rule>
@ -66,7 +85,9 @@ phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/r
<!-- include clean code manually -->
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
<rule ref="rulesets/cleancode.xml/ElseExpression"/>
<!-- no this one -->
<!--<rule ref="rulesets/cleancode.xml/StaticAccess" />-->
<rule ref="rulesets/cleancode.xml/MissingImport"/>
<rule ref="rulesets/cleancode.xml/UndefinedVariable"/>
<rule ref="rulesets/cleancode.xml/IfStatementAssignment"/>
<rule ref="rulesets/cleancode.xml/DuplicatedArrayKey"/>
<rule ref="rulesets/cleancode.xml/ErrorControlOperator"/>
</ruleset>

View File

@ -1,42 +1,33 @@
includes:
- ../vendor/nunomaduro/larastan/extension.neon
- ../vendor/ergebnis/phpstan-rules/rules.neon
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- ../vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
parameters:
universalObjectCratesClasses:
- Illuminate\Database\Eloquent\Model
# TODO: slowly remove these parameters and fix the issues found.
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false # remove this rule when all other issues are solved.
ignoreErrors:
# TODO: slowly remove these exceptions and fix the issues found.
- '#Dynamic call to static method#' # all the Laravel ORM things depend on this.
- '#Control structures using switch should not be used.#' # switch is fine in some cases.
- '#with no value type specified in iterable type array#' # remove this rule when all other issues are solved.
- '#has no value type specified in iterable type array#' # remove this rule when all other issues are solved.
- '#is not allowed to extend#'
- '#switch is forbidden to use#'
- '#is neither abstract nor final#'
- '#has a nullable return type declaration#'
- '#with a nullable type declaration#'
- '#on left side of \?\?\= always exists and is not nullable#'
- '#has a nullable return type declaration#' # perhaps throw errors instead?
- '#with a nullable type declaration#' # decide what action should be if param is null.
- '#with null as default value#'
- '#is not covariant with PHPDoc type array#'
-
message: '#Constructor in [a-zA-Z0-9\\_]+ has parameter \$[a-zA-Z0-9\\_]+ with default value#'
paths:
- ../app/Exceptions/IntervalException.php
- ../app/Support/Navigation.php
-
message: '#but containers should not be injected#'
paths:
- ../app/Support/Authentication/RemoteUserGuard.php
-
message: '#Control structures using switch should not be used.#'
paths:
- ../app/Api/V1/Controllers/Data/DestroyController.php
- ../app/Console/Commands/Correction/FixAccountTypes.php
- ../app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
- ../app/Exceptions/GracefulNotFoundHandler.php
- ../app/Generator/Webhook/StandardMessageGenerator.php
- ../app/Support/Amount.php
- ../app/Support/Navigation.php
- ../app/Support/ParseDateString.php
- ../app/Support/Search/AccountSearch.php
- ../app/Support/Search/OperatorQuerySearch.php
- ../app/Support/Twig/General.php
- ../app/Transformers/RecurrenceTransformer.php
- ../app/Validation/AccountValidator.php
- ../app/Validation/RecurrenceValidation.php
- ../app/Validation/TransactionValidation.php
-
message: '#Function compact\(\) should not be used#'
message: '#Function compact\(\) should not be used#' # too useful in template rendering.
paths:
- ../app/Generator/Report/Account/MonthReportGenerator.php
- ../app/Generator/Report/Audit/MonthReportGenerator.php
@ -57,7 +48,6 @@ parameters:
message: '#Either catch a more specific exception#'
paths:
- ../app/Support/Form/FormSupport.php
paths:
- ../app
- ../database
@ -66,5 +56,6 @@ parameters:
- ../bootstrap/app.php
# The level 8 is the highest level. original was 5
level: 4
# 7 is more than enough, higher just leaves NULL things.
level: 7

View File

@ -29,7 +29,20 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# cp .ci/.env.ci .env
# Do static code analysis.
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress
./vendor/bin/phpstan analyse -c .ci/phpstan.neon --xdebug --error-format=table > phpstan-report.txt
if [[ $GITHUB_ACTIONS = "" ]]
then
./vendor/bin/phpstan analyse -c .ci/phpstan.neon --error-format=table > phpstan-report.txt
EXIT_CODE=$?
echo "The PHPstan report can be found in phpstan-report.txt. Exit code is $EXIT_CODE."
fi
echo 'The PHPstan report can be found in phpstan-report.txt'
if [[ $GITHUB_ACTIONS = "true" ]]
then
./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress --error-format=github
EXIT_CODE=$?
# temporary exit code 0
# EXIT_CODE=0
fi
exit $EXIT_CODE

View File

@ -1,63 +0,0 @@
#!/usr/bin/env bash
#
# phpunit.sh
# Copyright (c) 2021 james@firefly-iii.org
#
# This file is part of Firefly III (https://github.com/firefly-iii).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# enable test .env file.
cp $SCRIPT_DIR/../.env $SCRIPT_DIR/../.env.backup
cp $SCRIPT_DIR/.env.ci $SCRIPT_DIR/../.env
COVERAGE=false
RESET=false
FILE=storage/database/database.sqlite
while getopts "cr" o; do
case "${o}" in
c) COVERAGE=true;;
r) RESET=true;;
esac
done
# reset if necessary.
if [ $RESET = "true" ] ; then
rm -f $FILE
fi
# download test database
if [ -f "$FILE" ]; then
echo 'DB exists, will use it'
else
echo 'Download new DB'
wget --quiet https://github.com/firefly-iii/test-fixtures/raw/main/test-database.sqlite -O $FILE
fi
# run phpunit
if [ $COVERAGE = "true" ] ; then
echo 'Run with coverage'
XDEBUG_MODE=coverage ./vendor/bin/phpunit --configuration phpunit.xml --coverage-html $SCRIPT_DIR/coverage
else
echo 'Run without coverage'
./vendor/bin/phpunit --configuration phpunit.xml
fi
# restore .env file
mv $SCRIPT_DIR/../.env.backup $SCRIPT_DIR/../.env
cd $SCRIPT_DIR/..

26
.env.testing Normal file
View File

@ -0,0 +1,26 @@
APP_ENV=testing
APP_DEBUG=true
SITE_OWNER=mail@example.com
APP_KEY=TestTestTestTestTestTestTestTest
DEFAULT_LANGUAGE=en_US
DEFAULT_LOCALE=equal
TZ=Europe/Amsterdam
LOG_CHANNEL=stdout
APP_LOG_LEVEL=debug
AUDIT_LOG_LEVEL=info
AUDIT_LOG_CHANNEL=audit_stdout
DB_CONNECTION=sqlite
CACHE_DRIVER=array
SESSION_DRIVER=array
MAIL_MAILER=log
SEND_ERROR_MESSAGE=true
ENABLE_EXTERNAL_MAP=false
ENABLE_EXTERNAL_RATES=true
AUTHENTICATION_GUARD=web
ALLOW_WEBHOOKS=true
APP_NAME=FireflyIII
BROADCAST_DRIVER=log
QUEUE_DRIVER=sync
CACHE_PREFIX=firefly
FIREFLY_III_LAYOUT=v1
APP_URL=http://localhost

View File

@ -22,7 +22,7 @@ jobs:
- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: '8.3'
coverage: xdebug
extensions: >-
bcmath
@ -42,15 +42,24 @@ jobs:
xml
xmlwriter
- name: Copy standard configuration
run: cp .env.testing .env
- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts
- name: PHPStan
run: .ci/phpstan.sh
- name: PHPMD
run: .ci/phpmd.sh
- name: PHP CS Fixer
run: .ci/phpcs.sh
- name: "Create database file"
run: touch storage/database/database.sqlite
- name: "Create the database"
run: php artisan firefly-iii:create-database
- name: "Upgrades the database to the latest version"
run: php artisan firefly-iii:upgrade-database

View File

@ -41,6 +41,7 @@ class AccountController extends Controller
{
use AccountFilter;
/** @var array<int, string> */
private array $balanceTypes;
private AccountRepositoryInterface $repository;
@ -117,10 +118,10 @@ class AccountController extends Controller
// custom order.
usort(
$return,
function ($a, $b) {
static function (array $left, array $right) {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posA = array_search($a['type'], $order, true);
$posB = array_search($b['type'], $order, true);
$posA = (int)array_search($left['type'], $order, true);
$posB = (int)array_search($right['type'], $order, true);
return $posA - $posB;
}

View File

@ -30,6 +30,7 @@ use FireflyIII\Api\V1\Requests\Data\DateRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\ApiSupport;
use FireflyIII\User;
@ -90,6 +91,7 @@ class AccountController extends Controller
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
/** @var Preference $frontPage */
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();

View File

@ -27,11 +27,12 @@ namespace FireflyIII\Api\V1\Controllers;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
use League\Fractal\Manager;
use League\Fractal\Serializer\JsonApiSerializer;
use Psr\Container\ContainerExceptionInterface;
@ -50,7 +51,8 @@ abstract class Controller extends BaseController
use DispatchesJobs;
use ValidatesRequests;
protected const CONTENT_TYPE = 'application/vnd.api+json';
protected const string CONTENT_TYPE = 'application/vnd.api+json';
/** @var array<int, string> */
protected array $allowedSort;
protected ParameterBag $parameters;
@ -88,8 +90,8 @@ abstract class Controller extends BaseController
if ($page < 1) {
$page = 1;
}
if ($page > pow(2, 16)) {
$page = pow(2, 16);
if ($page > 2 ** 16) {
$page = 2 ** 16;
}
$bag->set('page', $page);
@ -100,21 +102,21 @@ abstract class Controller extends BaseController
try {
$date = request()->query->get($field);
} catch (BadRequestException $e) {
Log::error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $field));
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
app('log')->error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $field));
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
$value = null;
}
$obj = null;
if (null !== $date) {
try {
$obj = Carbon::parse($date);
$obj = Carbon::parse((string)$date);
} catch (InvalidDateException | InvalidFormatException $e) {
// don't care
app('log')->warning(
sprintf(
'Ignored invalid date "%s" in API controller parameter check: %s',
substr($date, 0, 20),
substr((string)$date, 0, 20),
$e->getMessage()
)
);
@ -129,17 +131,22 @@ abstract class Controller extends BaseController
try {
$value = request()->query->get($integer);
} catch (BadRequestException $e) {
Log::error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $integer));
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
app('log')->error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $integer));
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
$value = null;
}
if (null !== $value) {
$bag->set($integer, (int)$value);
}
if (null === $value && 'limit' === $integer && auth()->check()) {
if (null === $value &&
'limit' === $integer && // @phpstan-ignore-line
auth()->check()) {
// set default for user:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
/** @var User $user */
$user = auth()->user();
/** @var Preference $pageSize */
$pageSize = (int)app('preferences')->getForUser($user, 'listPageSize', 50)->data;
$bag->set($integer, $pageSize);
}
}
@ -159,9 +166,9 @@ abstract class Controller extends BaseController
try {
$param = (string)request()->query->get('sort');
} catch (BadRequestException $e) {
Log::error('Request field "sort" contains a non-scalar value. Value set to NULL.');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
app('log')->error('Request field "sort" contains a non-scalar value. Value set to NULL.');
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
$param = '';
}
if ('' === $param) {

View File

@ -76,7 +76,7 @@ class TransactionController extends Controller
// this deserves better code, but for now a loop of basic if-statements
// to respond to what is in the $query.
// this is OK because only one thing can be in the query at the moment.
if ($this->updatesTransactionAccount($params)) {
if ($this->isUpdateTransactionAccount($params)) {
$original = $this->repository->find((int)$params['where']['account_id']);
$destination = $this->repository->find((int)$params['update']['account_id']);
@ -89,11 +89,11 @@ class TransactionController extends Controller
}
/**
* @param array $params
* @param array $params <array<string, array<string, int|string>>>
*
* @return bool
*/
private function updatesTransactionAccount(array $params): bool
private function isUpdateTransactionAccount(array $params): bool
{
return array_key_exists('account_id', $params['where']) && array_key_exists('account_id', $params['update']);
}

View File

@ -45,7 +45,6 @@ use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/**
* Class DestroyController
@ -67,135 +66,34 @@ class DestroyController extends Controller
{
$objects = $request->getObjects();
$this->unused = $request->boolean('unused', false);
switch ($objects) {
default:
throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects));
case 'budgets':
$this->destroyBudgets();
break;
case 'bills':
$this->destroyBills();
break;
case 'piggy_banks':
$this->destroyPiggyBanks();
break;
case 'rules':
$this->destroyRules();
break;
case 'recurring':
$this->destroyRecurringTransactions();
break;
case 'categories':
$this->destroyCategories();
break;
case 'tags':
$this->destroyTags();
break;
case 'object_groups':
$this->destroyObjectGroups();
break;
case 'not_assets_liabilities':
$this->destroyAccounts(
[
AccountType::BENEFICIARY,
AccountType::CASH,
AccountType::CREDITCARD,
AccountType::DEFAULT,
AccountType::EXPENSE,
AccountType::IMPORT,
AccountType::INITIAL_BALANCE,
AccountType::LIABILITY_CREDIT,
AccountType::RECONCILIATION,
AccountType::REVENUE,
]
);
break;
case 'accounts':
$this->destroyAccounts(
[
AccountType::ASSET,
AccountType::BENEFICIARY,
AccountType::CASH,
AccountType::CREDITCARD,
AccountType::DEBT,
AccountType::DEFAULT,
AccountType::EXPENSE,
AccountType::IMPORT,
AccountType::INITIAL_BALANCE,
AccountType::LIABILITY_CREDIT,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::RECONCILIATION,
AccountType::REVENUE,
]
);
break;
case 'asset_accounts':
$this->destroyAccounts(
[
AccountType::ASSET,
AccountType::DEFAULT,
]
);
break;
case 'expense_accounts':
$this->destroyAccounts(
[
AccountType::BENEFICIARY,
AccountType::EXPENSE,
]
);
break;
case 'revenue_accounts':
$this->destroyAccounts(
[
AccountType::REVENUE,
]
);
break;
case 'liabilities':
$this->destroyAccounts(
[
AccountType::DEBT,
AccountType::LOAN,
AccountType::MORTGAGE,
AccountType::CREDITCARD,
]
);
break;
case 'transactions':
$this->destroyTransactions(
[
TransactionType::WITHDRAWAL,
TransactionType::DEPOSIT,
TransactionType::TRANSFER,
TransactionType::RECONCILIATION,
TransactionType::OPENING_BALANCE,
]
);
break;
case 'withdrawals':
$this->destroyTransactions(
[
TransactionType::WITHDRAWAL,
]
);
break;
case 'deposits':
$this->destroyTransactions(
[
TransactionType::DEPOSIT,
]
);
break;
case 'transfers':
$this->destroyTransactions(
[
TransactionType::TRANSFER,
]
);
break;
}
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE,];
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION,];
$liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
$transactions = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION, TransactionType::OPENING_BALANCE,];
match ($objects) {
'budgets' => $this->destroyBudgets(),
'bills' => $this->destroyBills(),
'piggy_banks' => $this->destroyPiggyBanks(),
'rules' => $this->destroyRules(),
'recurring' => $this->destroyRecurringTransactions(),
'categories' => $this->destroyCategories(),
'tags' => $this->destroyTags(),
'object_groups' => $this->destroyObjectGroups(),
'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets),
'accounts' => $this->destroyAccounts($all),
'asset_accounts' => $this->destroyAccounts([AccountType::ASSET, AccountType::DEFAULT]),
'expense_accounts' => $this->destroyAccounts([AccountType::BENEFICIARY, AccountType::EXPENSE]),
'revenue_accounts' => $this->destroyAccounts([AccountType::REVENUE]),
'liabilities' => $this->destroyAccounts($liabilities),
'transactions' => $this->destroyTransactions($transactions),
'withdrawals' => $this->destroyTransactions([TransactionType::WITHDRAWAL]),
'deposits' => $this->destroyTransactions([TransactionType::DEPOSIT]),
'transfers' => $this->destroyTransactions([TransactionType::TRANSFER]),
default => throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects)),
};
app('preferences')->mark();
return response()->json([], 204);
@ -290,7 +188,7 @@ class DestroyController extends Controller
}
/**
* @param array $types
* @param array $types <int, string>
*/
private function destroyAccounts(array $types): void
{
@ -303,19 +201,19 @@ class DestroyController extends Controller
foreach ($collection as $account) {
$count = $account->transactions()->count();
if (true === $this->unused && 0 === $count) {
Log::info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name));
app('log')->info(sprintf('Deleted unused account #%d "%s"', $account->id, $account->name));
$service->destroy($account, null);
continue;
}
if (false === $this->unused) {
Log::info(sprintf('Deleting account #%d "%s"', $account->id, $account->name));
app('log')->info(sprintf('Deleting account #%d "%s"', $account->id, $account->name));
$service->destroy($account, null);
}
}
}
/**
* @param array $types
* @param array $types <int, string>
*/
private function destroyTransactions(array $types): void
{

View File

@ -62,7 +62,11 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function accounts(ExportRequest $request): LaravelResponse
{
@ -108,7 +112,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function bills(ExportRequest $request): LaravelResponse
{
@ -124,7 +131,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function budgets(ExportRequest $request): LaravelResponse
{
@ -140,7 +150,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function categories(ExportRequest $request): LaravelResponse
{
@ -156,7 +169,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function piggyBanks(ExportRequest $request): LaravelResponse
{
@ -172,7 +188,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function recurring(ExportRequest $request): LaravelResponse
{
@ -188,7 +207,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function rules(ExportRequest $request): LaravelResponse
{
@ -204,7 +226,10 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function tags(ExportRequest $request): LaravelResponse
{
@ -220,7 +245,9 @@ class ExportController extends Controller
* @param ExportRequest $request
*
* @return LaravelResponse
* @throws ContainerExceptionInterface
* @throws FireflyException
* @throws NotFoundExceptionInterface
*/
public function transactions(ExportRequest $request): LaravelResponse
{

View File

@ -35,6 +35,7 @@ use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
/**
@ -51,6 +52,7 @@ class PurgeController extends Controller
*/
public function purge(): JsonResponse
{
/** @var User $user */
$user = auth()->user();
// some manual code, too lazy to call all repositories.

View File

@ -92,7 +92,7 @@ class BillController extends Controller
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$billId,
'name' => $journal['bill_name'],
'difference' => '0',
@ -104,7 +104,7 @@ class BillController extends Controller
$response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignKey] = $response[$foreignKey] ?? [
$response[$foreignKey] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@ -147,7 +147,7 @@ class BillController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -157,7 +157,7 @@ class BillController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@ -83,7 +83,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -93,7 +93,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@ -148,7 +148,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@ -84,7 +84,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -94,7 +94,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@ -152,7 +152,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,

View File

@ -81,7 +81,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
@ -91,7 +91,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
@ -149,7 +149,7 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
$response[$key] ??= [
'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',

View File

@ -33,7 +33,7 @@ use Illuminate\Http\JsonResponse;
*/
class DestroyController extends Controller
{
public const RESOURCE_KEY = 'accounts';
public const string RESOURCE_KEY = 'accounts';
private AccountRepositoryInterface $repository;

View File

@ -47,7 +47,7 @@ class ListController extends Controller
{
use TransactionFilter;
public const RESOURCE_KEY = 'accounts';
public const string RESOURCE_KEY = 'accounts';
private AccountRepositoryInterface $repository;

View File

@ -43,7 +43,7 @@ class ShowController extends Controller
{
use AccountFilter;
public const RESOURCE_KEY = 'accounts';
public const string RESOURCE_KEY = 'accounts';
private AccountRepositoryInterface $repository;

View File

@ -35,7 +35,7 @@ use League\Fractal\Resource\Item;
*/
class StoreController extends Controller
{
public const RESOURCE_KEY = 'accounts';
public const string RESOURCE_KEY = 'accounts';
private AccountRepositoryInterface $repository;

View File

@ -29,16 +29,14 @@ use FireflyIII\Models\Account;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Transformers\AccountTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item;
use Preferences;
/**
* Class UpdateController
*/
class UpdateController extends Controller
{
public const RESOURCE_KEY = 'accounts';
public const string RESOURCE_KEY = 'accounts';
private AccountRepositoryInterface $repository;
@ -73,13 +71,13 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Account $account): JsonResponse
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData();
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account->refresh();
Preferences::mark();
app('preferences')->mark();
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);

View File

@ -34,7 +34,6 @@ use FireflyIII\Transformers\AttachmentTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item;
/**
@ -78,7 +77,7 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$data = $request->getAll();
$attachment = $this->repository->store($data);
$manager = $this->getManager();
@ -107,7 +106,7 @@ class StoreController extends Controller
$helper = app(AttachmentHelperInterface::class);
$body = $request->getContent();
if ('' === $body) {
Log::error('Body of attachment is empty.');
app('log')->error('Body of attachment is empty.');
return response()->json([], 422);
}

View File

@ -28,7 +28,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Support\Http\Api\TransactionFilter;
use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User;
@ -44,28 +43,6 @@ class ListController extends Controller
{
use TransactionFilter;
private BudgetLimitRepositoryInterface $blRepository;
/**
* BudgetLimitController constructor.
*
*/
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
}
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/listTransactionByBudgetLimit

View File

@ -33,7 +33,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\BudgetLimitTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
@ -75,13 +74,11 @@ class ShowController extends Controller
*
* Display a listing of the budget limits for this budget.
*
* @param Request $request
* @param Budget $budget
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Request $request, Budget $budget): JsonResponse
public function index(Budget $budget): JsonResponse
{
$manager = $this->getManager();
$manager->parseIncludes('budget');
@ -111,7 +108,7 @@ class ShowController extends Controller
* @param SameDateRequest $request
*
* @return JsonResponse
* @throws FireflyException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function indexAll(SameDateRequest $request): JsonResponse
{
@ -138,16 +135,15 @@ class ShowController extends Controller
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit
*
* @param Request $request
* @param Budget $budget
* @param BudgetLimit $budgetLimit
*
* @return JsonResponse
* @throws FireflyException
*/
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
public function show(Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
// continue!

View File

@ -78,7 +78,7 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
$data = $request->getAll();

View File

@ -24,13 +24,11 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ObjectGroup;
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
use FireflyIII\Transformers\ObjectGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
@ -69,12 +67,9 @@ class ShowController extends Controller
*
* Display a listing of the resource.
*
* @param Request $request
*
* @return JsonResponse
* @throws FireflyException
*/
public function index(Request $request): JsonResponse
public function index(): JsonResponse
{
$manager = $this->getManager();

View File

@ -33,7 +33,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/**
* Class DestroyController
@ -79,7 +78,7 @@ class DestroyController extends Controller
*/
public function destroy(TransactionGroup $transactionGroup): JsonResponse
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
// grab asset account(s) from group:
$accounts = [];
/** @var TransactionJournal $journal */
@ -100,7 +99,7 @@ class DestroyController extends Controller
/** @var Account $account */
foreach ($accounts as $account) {
Log::debug(sprintf('Now going to trigger updated account event for account #%d', $account->id));
app('log')->debug(sprintf('Now going to trigger updated account event for account #%d', $account->id));
event(new UpdatedAccount($account));
}

View File

@ -83,7 +83,7 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
Log::debug('Now in API StoreController::store()');
app('log')->debug('Now in API StoreController::store()');
$data = $request->getAll();
$data['user'] = auth()->user()->id;
@ -92,19 +92,19 @@ class StoreController extends Controller
try {
$transactionGroup = $this->groupRepository->store($data);
} catch (DuplicateTransactionException $e) {
} catch (DuplicateTransactionException $e) { // @phpstan-ignore-line
app('log')->warning('Caught a duplicate transaction. Return error message.');
$validator = Validator::make(
['transactions' => [['description' => $e->getMessage()]]],
['transactions.0.description' => new IsDuplicateTransaction()]
);
throw new ValidationException($validator, 0, $e);
} catch (FireflyException $e) {
throw new ValidationException($validator); // @phpstan-ignore-line
} catch (FireflyException $e) { // @phpstan-ignore-line
app('log')->warning('Caught an exception. Return error message.');
Log::error($e->getMessage());
app('log')->error($e->getMessage());
$message = sprintf('Internal exception: %s', $e->getMessage());
$validator = Validator::make(['transactions' => [['description' => $message]]], ['transactions.0.description' => new IsDuplicateTransaction()]);
throw new ValidationException($validator, 0, $e);
throw new ValidationException($validator); // @phpstan-ignore-line
}
app('preferences')->mark();
$applyRules = $data['apply_rules'] ?? true;

View File

@ -32,7 +32,6 @@ use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface
use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -77,7 +76,7 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
{
Log::debug('Now in update routine for transaction group!');
app('log')->debug('Now in update routine for transaction group!');
$data = $request->getAll();
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);

View File

@ -255,8 +255,8 @@ class ListController extends Controller
$unfiltered = $recurringRepos->getAll();
// filter selection
$collection = $unfiltered->filter(
static function (Recurrence $recurrence) use ($currency) {
$collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) {
if ($transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id) {
@ -305,8 +305,8 @@ class ListController extends Controller
$ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter(
static function (Rule $rule) use ($currency) {
$collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Rule $rule) use ($currency) { // @phpstan-ignore-line
/** @var RuleTrigger $trigger */
foreach ($rule->ruleTriggers as $trigger) {
if ('currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value) {

View File

@ -32,7 +32,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Log;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
@ -67,7 +66,7 @@ class AccountController extends Controller
*/
public function search(Request $request): JsonResponse | Response
{
Log::debug('Now in account search()');
app('log')->debug('Now in account search()');
$manager = $this->getManager();
$query = trim((string)$request->get('query'));
$field = trim((string)$request->get('field'));

View File

@ -32,7 +32,6 @@ use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Report\NetWorthInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
@ -107,8 +106,8 @@ class BasicController extends Controller
$balanceData = $this->getBalanceInformation($start, $end);
$billData = $this->getBillInformation($start, $end);
$spentData = $this->getLeftToSpendInfo($start, $end);
$networthData = $this->getNetWorthInfo($start, $end);
$total = array_merge($balanceData, $billData, $spentData, $networthData);
$netWorthData = $this->getNetWorthInfo($start, $end);
$total = array_merge($balanceData, $billData, $spentData, $netWorthData);
// give new keys
$return = [];
@ -149,12 +148,12 @@ class BasicController extends Controller
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd(
$incomes[$currencyId],
bcmul($transactionJournal['amount'], '-1')
);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1'));
}
@ -172,9 +171,9 @@ class BasicController extends Controller
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
$expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
$sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], $transactionJournal['amount']);
}
@ -368,30 +367,30 @@ class BasicController extends Controller
}
);
$netWorthSet = $netWorthHelper->getNetWorthByCurrency($filtered, $date);
$netWorthSet = $netWorthHelper->byAccounts($filtered, $date);
$return = [];
foreach ($netWorthSet as $data) {
/** @var TransactionCurrency $currency */
$currency = $data['currency'];
foreach ($netWorthSet as $key => $data) {
if ('native' === $key) {
continue;
}
$amount = $data['balance'];
if (0 === bccomp($amount, '0')) {
continue;
}
// return stuff
$return[] = [
'key' => sprintf('net-worth-in-%s', $currency->code),
'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $currency->symbol]),
'key' => sprintf('net-worth-in-%s', $data['currency_code']),
'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $data['currency_symbol']]),
'monetary_value' => $amount,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'value_parsed' => app('amount')->formatAnything($currency, $data['balance'], false),
'currency_id' => (string)$data['currency_id'],
'currency_code' => $data['currency_code'],
'currency_symbol' => $data['currency_symbol'],
'currency_decimal_places' => $data['currency_decimal_places'],
'value_parsed' => app('amount')->formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false),
'local_icon' => 'line-chart',
'sub_title' => '',
];
}
return $return;
}

View File

@ -29,7 +29,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Binder\EitherConfigKey;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Validator;
@ -70,8 +69,8 @@ class ConfigurationController extends Controller
try {
$dynamicData = $this->getDynamicConfiguration();
} catch (FireflyException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
throw new FireflyException('200030: Could not load config variables.', 0, $e);
}
$staticData = $this->getStaticConfiguration();

View File

@ -27,7 +27,6 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\System\CronRequest;
use FireflyIII\Support\Http\Controllers\CronRunner;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@ -43,18 +42,17 @@ class CronController extends Controller
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/about/getCron
*
* @param CronRequest $request
* @param string $token
*
* @return JsonResponse
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function cron(CronRequest $request, string $token): JsonResponse
public function cron(CronRequest $request): JsonResponse
{
$config = $request->getAll();
Log::debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Date is %s', $config['date']->toIsoString()));
app('log')->debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Date is %s', $config['date']->toIsoString()));
$return = [];
$return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']);
$return['auto_budgets'] = $this->runAutoBudget($config['force'], $config['date']);

View File

@ -33,7 +33,6 @@ use FireflyIII\Transformers\UserTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Log;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
@ -192,7 +191,7 @@ class UserController extends Controller
// can only update 'blocked' when user is admin.
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
Log::debug('Quietly drop fields "blocked" and "blocked_code" from request.');
app('log')->debug('Quietly drop fields "blocked" and "blocked_code" from request.');
unset($data['blocked'], $data['blocked_code']);
}

View File

@ -41,8 +41,8 @@ use League\Fractal\Resource\Item;
*/
class PreferencesController extends Controller
{
public const DATE_FORMAT = 'Y-m-d';
public const RESOURCE_KEY = 'preferences';
public const string DATE_FORMAT = 'Y-m-d';
public const string RESOURCE_KEY = 'preferences';
/**
* This endpoint is documented at:

View File

@ -41,7 +41,7 @@ use League\Fractal\Resource\Item;
*/
class AttemptController extends Controller
{
public const RESOURCE_KEY = 'webhook_attempts';
public const string RESOURCE_KEY = 'webhook_attempts';
private WebhookRepositoryInterface $repository;
/**

View File

@ -40,7 +40,7 @@ use League\Fractal\Resource\Item;
*/
class MessageController extends Controller
{
public const RESOURCE_KEY = 'webhook_messages';
public const string RESOURCE_KEY = 'webhook_messages';
private WebhookRepositoryInterface $repository;
/**

View File

@ -43,7 +43,7 @@ use League\Fractal\Resource\Item;
*/
class ShowController extends Controller
{
public const RESOURCE_KEY = 'webhooks';
public const string RESOURCE_KEY = 'webhooks';
private WebhookRepositoryInterface $repository;
/**

View File

@ -35,7 +35,7 @@ use League\Fractal\Resource\Item;
*/
class StoreController extends Controller
{
public const RESOURCE_KEY = 'webhooks';
public const string RESOURCE_KEY = 'webhooks';
private WebhookRepositoryInterface $repository;
/**

View File

@ -33,8 +33,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class AutocompleteRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array

View File

@ -30,7 +30,6 @@ use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Validation\Api\Data\Bulk\ValidatesBulkTransactionQuery;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
use JsonException;
@ -55,7 +54,7 @@ class TransactionRequest extends FormRequest
];
} catch (JsonException $e) {
// dont really care. the validation should catch invalid json.
Log::error($e->getMessage());
app('log')->error($e->getMessage());
}
return $data;

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class DateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -32,8 +32,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class DestroyRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class SameDateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -42,8 +42,8 @@ use Illuminate\Support\Collection;
*/
class GenericRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
private Collection $accounts;
private Collection $bills;

View File

@ -40,9 +40,9 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use AppendsLocationData;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array
@ -124,7 +124,7 @@ class StoreRequest extends FormRequest
'liability_start_date' => 'required_with:liability_amount|date',
'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit',
'interest' => 'between:0,100|numeric',
'interest_period' => sprintf('nullable|in:%s', join(',', config('firefly.interest_periods'))),
'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))),
'notes' => 'min:0|max:65536',
];

View File

@ -41,9 +41,9 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use AppendsLocationData;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/
class Request extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.
@ -84,7 +84,7 @@ class Request extends FormRequest
public function withValidator(Validator $validator): void
{
$validator->after(
function (Validator $validator) {
static function (Validator $validator) {
// validate start before end only if both are there.
$data = $validator->getData();
if (array_key_exists('start', $data) && array_key_exists('end', $data)) {

View File

@ -28,7 +28,6 @@ use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/**
@ -38,8 +37,8 @@ use Illuminate\Validation\Validator;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.
@ -48,7 +47,7 @@ class StoreRequest extends FormRequest
*/
public function getAll(): array
{
Log::debug('Raw fields in Bill StoreRequest', $this->all());
app('log')->debug('Raw fields in Bill StoreRequest', $this->all());
$fields = [
'name' => ['name', 'convertString'],
'amount_min' => ['amount_min', 'convertString'],

View File

@ -38,8 +38,8 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -37,9 +37,9 @@ use Illuminate\Validation\Validator;
*/
class StoreRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use ValidatesAutoBudgetRequest;
use ChecksLogin;
/**
* Get all data from the request.

View File

@ -38,9 +38,9 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use ValidatesAutoBudgetRequest;
use ChecksLogin;
/**
* Get all data from the request.

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.
@ -84,7 +84,7 @@ class UpdateRequest extends FormRequest
public function withValidator(Validator $validator): void
{
$validator->after(
function (Validator $validator) {
static function (Validator $validator) {
// validate start before end only if both are there.
$data = $validator->getData();
if (array_key_exists('start', $data) && array_key_exists('end', $data)) {

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -37,8 +37,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -39,12 +39,12 @@ use Illuminate\Validation\Validator;
*/
class StoreRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use RecurrenceValidation;
use TransactionValidation;
use CurrencyValidation;
use GetRecurrenceData;
use ChecksLogin;
use RecurrenceValidation;
use TransactionValidation;
/**
* Get all data from the request.

View File

@ -40,12 +40,12 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use RecurrenceValidation;
use TransactionValidation;
use CurrencyValidation;
use GetRecurrenceData;
use ChecksLogin;
use RecurrenceValidation;
use TransactionValidation;
/**
* Get all data from the request.
@ -73,9 +73,7 @@ class UpdateRequest extends FormRequest
if (null !== $reps) {
$return['repetitions'] = $reps;
}
if (null !== $transactions) {
$return['transactions'] = $transactions;
}
return $return;
}
@ -125,16 +123,16 @@ class UpdateRequest extends FormRequest
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
* @return array|null
* @return array
*/
private function getTransactionData(): ?array
private function getTransactionData(): array
{
$return = [];
// transaction data:
/** @var array|null $transactions */
$transactions = $this->get('transactions');
if (null === $transactions) {
return null;
return [];
}
/** @var array $transaction */
foreach ($transactions as $transaction) {

View File

@ -30,16 +30,14 @@ use FireflyIII\Support\Request\GetRuleConfiguration;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
use function is_array;
/**
* Class StoreRequest
*/
class StoreRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use GetRuleConfiguration;
use ChecksLogin;
/**
* Get all data from the request.
@ -200,6 +198,7 @@ class StoreRequest extends FormRequest
protected function atLeastOneActiveTrigger(Validator $validator): void
{
$data = $validator->getData();
/** @var string|int|array|null $triggers */
$triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || 0 === count($triggers)) {
@ -229,6 +228,7 @@ class StoreRequest extends FormRequest
protected function atLeastOneActiveAction(Validator $validator): void
{
$data = $validator->getData();
/** @var string|int|array|null $actions */
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || 0 === count($actions)) {

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class TestRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array
@ -66,7 +66,16 @@ class TestRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result;
}
/**

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class TriggerRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array
@ -56,7 +56,16 @@ class TriggerRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($this->query($field), 0, 10));
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result;
}
/**

View File

@ -31,16 +31,14 @@ use FireflyIII\Support\Request\GetRuleConfiguration;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
use function is_array;
/**
* Class UpdateRequest
*/
class UpdateRequest extends FormRequest
{
use ChecksLogin;
use ConvertsDataTypes;
use GetRuleConfiguration;
use ChecksLogin;
/**
* Get all data from the request.

View File

@ -33,8 +33,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class TestRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array
@ -56,7 +56,16 @@ class TestRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result;
}
/**

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class TriggerRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* @return array
@ -56,7 +56,16 @@ class TriggerRequest extends FormRequest
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
$value = $this->query($field);
if (is_array($value)) {
return null;
}
$value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result;
}
/**

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,9 +36,9 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use AppendsLocationData;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -38,9 +38,9 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use AppendsLocationData;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -35,7 +35,6 @@ use FireflyIII\Validation\CurrencyValidation;
use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/**
@ -43,12 +42,12 @@ use Illuminate\Validation\Validator;
*/
class StoreRequest extends FormRequest
{
use TransactionValidation;
use GroupValidation;
use CurrencyValidation;
use ConvertsDataTypes;
use ChecksLogin;
use AppendsLocationData;
use ChecksLogin;
use ConvertsDataTypes;
use CurrencyValidation;
use GroupValidation;
use TransactionValidation;
/**
* Get all data. Is pretty complex because of all the ??-statements.
@ -57,7 +56,7 @@ class StoreRequest extends FormRequest
*/
public function getAll(): array
{
Log::debug('get all data in TransactionStoreRequest');
app('log')->debug('get all data in TransactionStoreRequest');
return [
'group_title' => $this->convertString('group_title'),
@ -83,75 +82,75 @@ class StoreRequest extends FormRequest
foreach ($this->get('transactions') as $transaction) {
$object = new NullArrayObject($transaction);
$return[] = [
'type' => $this->clearString($object['type'], false),
'type' => $this->clearString($object['type']),
'date' => $this->dateFromValue($object['date']),
'order' => $this->integerFromValue((string)$object['order']),
'currency_id' => $this->integerFromValue((string)$object['currency_id']),
'currency_code' => $this->clearString((string)$object['currency_code'], false),
'currency_code' => $this->clearString((string)$object['currency_code']),
// foreign currency info:
'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),
'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code'], false),
'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
'amount' => $this->clearString((string)$object['amount'], false),
'foreign_amount' => $this->clearString((string)$object['foreign_amount'], false),
'amount' => $this->clearString((string)$object['amount']),
'foreign_amount' => $this->clearString((string)$object['foreign_amount']),
// description.
'description' => $this->clearString($object['description'], false),
'description' => $this->clearString($object['description']),
// source of transaction. If everything is null, assume cash account.
'source_id' => $this->integerFromValue((string)$object['source_id']),
'source_name' => $this->clearString((string)$object['source_name'], false),
'source_iban' => $this->clearString((string)$object['source_iban'], false),
'source_number' => $this->clearString((string)$object['source_number'], false),
'source_bic' => $this->clearString((string)$object['source_bic'], false),
'source_name' => $this->clearString((string)$object['source_name']),
'source_iban' => $this->clearString((string)$object['source_iban']),
'source_number' => $this->clearString((string)$object['source_number']),
'source_bic' => $this->clearString((string)$object['source_bic']),
// destination of transaction. If everything is null, assume cash account.
'destination_id' => $this->integerFromValue((string)$object['destination_id']),
'destination_name' => $this->clearString((string)$object['destination_name'], false),
'destination_iban' => $this->clearString((string)$object['destination_iban'], false),
'destination_number' => $this->clearString((string)$object['destination_number'], false),
'destination_bic' => $this->clearString((string)$object['destination_bic'], false),
'destination_name' => $this->clearString((string)$object['destination_name']),
'destination_iban' => $this->clearString((string)$object['destination_iban']),
'destination_number' => $this->clearString((string)$object['destination_number']),
'destination_bic' => $this->clearString((string)$object['destination_bic']),
// budget info
'budget_id' => $this->integerFromValue((string)$object['budget_id']),
'budget_name' => $this->clearString((string)$object['budget_name'], false),
'budget_name' => $this->clearString((string)$object['budget_name']),
// category info
'category_id' => $this->integerFromValue((string)$object['category_id']),
'category_name' => $this->clearString((string)$object['category_name'], false),
'category_name' => $this->clearString((string)$object['category_name']),
// journal bill reference. Optional. Will only work for withdrawals
'bill_id' => $this->integerFromValue((string)$object['bill_id']),
'bill_name' => $this->clearString((string)$object['bill_name'], false),
'bill_name' => $this->clearString((string)$object['bill_name']),
// piggy bank reference. Optional. Will only work for transfers
'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),
'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name'], false),
'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name']),
// some other interesting properties
'reconciled' => $this->convertBoolean((string)$object['reconciled']),
'notes' => $this->clearString((string)$object['notes']),
'notes' => $this->clearStringKeepNewlines((string)$object['notes']),
'tags' => $this->arrayFromValue($object['tags']),
// all custom fields:
'internal_reference' => $this->clearString((string)$object['internal_reference'], false),
'external_id' => $this->clearString((string)$object['external_id'], false),
'internal_reference' => $this->clearString((string)$object['internal_reference']),
'external_id' => $this->clearString((string)$object['external_id']),
'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id'], false),
'external_url' => $this->clearString((string)$object['external_url'], false),
'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id']),
'external_url' => $this->clearString((string)$object['external_url']),
'sepa_cc' => $this->clearString((string)$object['sepa_cc'], false),
'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op'], false),
'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id'], false),
'sepa_db' => $this->clearString((string)$object['sepa_db'], false),
'sepa_country' => $this->clearString((string)$object['sepa_country'], false),
'sepa_ep' => $this->clearString((string)$object['sepa_ep'], false),
'sepa_ci' => $this->clearString((string)$object['sepa_ci'], false),
'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id'], false),
'sepa_cc' => $this->clearString((string)$object['sepa_cc']),
'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op']),
'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id']),
'sepa_db' => $this->clearString((string)$object['sepa_db']),
'sepa_country' => $this->clearString((string)$object['sepa_country']),
'sepa_ep' => $this->clearString((string)$object['sepa_ep']),
'sepa_ci' => $this->clearString((string)$object['sepa_ci']),
'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id']),
// custom date fields. Must be Carbon objects. Presence is optional.
'interest_date' => $this->dateFromValue($object['interest_date']),
'book_date' => $this->dateFromValue($object['book_date']),
@ -173,7 +172,7 @@ class StoreRequest extends FormRequest
*/
public function rules(): array
{
Log::debug('Collect rules of TransactionStoreRequest');
app('log')->debug('Collect rules of TransactionStoreRequest');
$validProtocols = config('firefly.valid_url_protocols');
return [
// basic fields for group:
@ -270,9 +269,9 @@ class StoreRequest extends FormRequest
$this->validateTransactionArray($validator);
// must submit at least one transaction.
Log::debug('Now going to validateOneTransaction');
app('log')->debug('Now going to validateOneTransaction');
$this->validateOneTransaction($validator);
Log::debug('Now done with validateOneTransaction');
app('log')->debug('Now done with validateOneTransaction');
// all journals must have a description
$this->validateDescriptions($validator);

View File

@ -34,7 +34,6 @@ use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\Validation\GroupValidation;
use FireflyIII\Validation\TransactionValidation;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
/**
@ -42,10 +41,10 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use TransactionValidation;
use GroupValidation;
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
use GroupValidation;
use TransactionValidation;
private array $arrayFields;
private array $booleanFields;
@ -63,7 +62,7 @@ class UpdateRequest extends FormRequest
*/
public function getAll(): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$this->integerFields = [
'order',
'currency_id',
@ -157,15 +156,18 @@ class UpdateRequest extends FormRequest
*/
private function getTransactionData(): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$return = [];
if (!is_countable($this->get('transactions'))) {
/** @var array|null $transactions */
$transactions = $this->get('transactions');
if (!is_countable($transactions)) {
return $return;
}
/** @var array $transaction */
foreach ($this->get('transactions') as $transaction) {
/** @var array|null $transaction */
foreach ($transactions as $transaction) {
if (!is_array($transaction)) {
throw new FireflyException('Invalid data submitted: transaction is not array.');
}
@ -213,7 +215,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->stringFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->clearString((string)$transaction[$fieldName], false);
$current[$fieldName] = $this->clearString((string)$transaction[$fieldName]);
}
}
@ -230,7 +232,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->textareaFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->clearString((string)$transaction[$fieldName]);
$current[$fieldName] = $this->clearStringKeepNewlines((string)$transaction[$fieldName]); // keep newlines
}
}
@ -246,9 +248,9 @@ class UpdateRequest extends FormRequest
private function getDateData(array $current, array $transaction): array
{
foreach ($this->dateFields as $fieldName) {
Log::debug(sprintf('Now at date field %s', $fieldName));
app('log')->debug(sprintf('Now at date field %s', $fieldName));
if (array_key_exists($fieldName, $transaction)) {
Log::debug(sprintf('New value: "%s"', (string)$transaction[$fieldName]));
app('log')->debug(sprintf('New value: "%s"', (string)$transaction[$fieldName]));
$current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);
}
}
@ -320,7 +322,7 @@ class UpdateRequest extends FormRequest
*/
public function rules(): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
app('log')->debug(sprintf('Now in %s', __METHOD__));
$validProtocols = config('firefly.valid_url_protocols');
return [
// basic fields for group:
@ -406,7 +408,7 @@ class UpdateRequest extends FormRequest
*/
public function withValidator(Validator $validator): void
{
Log::debug('Now in withValidator');
app('log')->debug('Now in withValidator');
/** @var TransactionGroup $transactionGroup */
$transactionGroup = $this->route()->parameter('transactionGroup');
$validator->after(

View File

@ -35,8 +35,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class StoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Rule;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -57,9 +57,9 @@ class CreateRequest extends FormRequest
// this is the way.
$return = $this->getAllData($fields);
$return['trigger'] = $triggers[$return['trigger']] ?? intval($return['trigger']);
$return['response'] = $responses[$return['response']] ?? intval($return['response']);
$return['delivery'] = $deliveries[$return['delivery']] ?? intval($return['delivery']);
$return['trigger'] = $triggers[$return['trigger']] ?? (int)($return['trigger']);
$return['response'] = $responses[$return['response']] ?? (int)($return['response']);
$return['delivery'] = $deliveries[$return['delivery']] ?? (int)($return['delivery']);
return $return;
}

View File

@ -36,8 +36,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Get all data from the request.

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/
class UserStoreRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Logged in + owner

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/
class UserUpdateRequest extends FormRequest
{
use ConvertsDataTypes;
use ChecksLogin;
use ConvertsDataTypes;
/**
* Logged in + owner

View File

@ -90,7 +90,7 @@ class AccountController extends Controller
$date = $this->parameters->get('date') ?? today(config('app.timezone'));
$result = $this->adminRepository->searchAccount((string)$query, $types, $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency();
$groupedResult = [];
$allItems = [];
/** @var Account $account */
foreach ($result as $account) {
@ -102,7 +102,7 @@ class AccountController extends Controller
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
}
$type = (string)trans(sprintf('firefly.%s', $account->accountType->type));
$groupedResult[$type] = $groupedResult[$type] ?? [
$groupedResult[$type] ??= [
'group ' => $type,
'items' => [],
];
@ -123,12 +123,12 @@ class AccountController extends Controller
usort(
$allItems,
function (array $a, array $b): int {
static function (array $left, array $right): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$pos_a = array_search($a['type'], $order, true);
$pos_b = array_search($b['type'], $order, true);
$posLeft = (int)array_search($left['type'], $order, true);
$posRight = (int)array_search($right['type'], $order, true);
return $pos_a - $pos_b;
return $posLeft - $posRight;
}
);
return response()->json($allItems);

View File

@ -26,7 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Chart;
use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Api\V2\Request\Chart\DashboardChartRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@ -35,6 +35,7 @@ use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\CleansChartData;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@ -78,14 +79,15 @@ class AccountController extends Controller
*
* TODO validate and set user_group_id from request
*
* @param DateRequest $request
* @param DashboardChartRequest $request
*
* @return JsonResponse
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws FireflyException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function dashboard(DateRequest $request): JsonResponse
public function dashboard(DashboardChartRequest $request): JsonResponse
{
/** @var Carbon $start */
$start = $this->parameters->get('start');
@ -93,18 +95,37 @@ class AccountController extends Controller
$end = $this->parameters->get('end');
$end->endOfDay();
// user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
/** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency();
$accounts = $this->repository->getAccountsById($frontPage->data);
$params = $request->getAll();
/** @var Collection $accounts */
$accounts = $params['accounts'];
$chartData = [];
// user's preferences
if (0 === $accounts->count()) {
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT])->pluck('id')->toArray();
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet;
$frontPage->save();
}
$accounts = $this->repository->getAccountsById($frontPage->data);
}
// both options are overruled by "preselected"
if ('all' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}
if ('assets' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
}
if ('liabilities' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
}
/** @var Account $account */
foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account);
@ -123,7 +144,7 @@ class AccountController extends Controller
'native_id' => (string)$default->id,
'native_code' => $default->code,
'native_symbol' => $default->symbol,
'native_decimal_places' => (int)$default->decimal_places,
'native_decimal_places' => $default->decimal_places,
'start' => $start->toAtomString(),
'end' => $end->toAtomString(),
'period' => '1D',

View File

@ -32,7 +32,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\CleansChartData;
use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use Illuminate\Http\JsonResponse;
@ -45,23 +44,6 @@ class BalanceController extends Controller
{
use CleansChartData;
private AccountRepositoryInterface $repository;
/**
*
*/
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
return $next($request);
}
);
}
/**
* The code is practically a duplicate of ReportController::operations.
*
@ -99,7 +81,7 @@ class BalanceController extends Controller
/** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency();
$converter = new ExchangeRateConverter();
$currencies = [(int)$default->id => $default,]; // currency cache
$currencies = [$default->id => $default,]; // currency cache
$data = [];
$chartData = [];
@ -112,18 +94,18 @@ class BalanceController extends Controller
$journals = $collector->getExtractedJournals();
// set array for default currency (even if unused later on)
$defaultCurrencyId = (int)$default->id;
$defaultCurrencyId = $default->id;
$data[$defaultCurrencyId] = [
'currency_id' => (string)$defaultCurrencyId,
'currency_symbol' => $default->symbol,
'currency_code' => $default->code,
'currency_name' => $default->name,
'currency_decimal_places' => (int)$default->decimal_places,
'currency_decimal_places' => $default->decimal_places,
'native_id' => (string)$defaultCurrencyId,
'native_symbol' => $default->symbol,
'native_code' => $default->code,
'native_name' => $default->name,
'native_decimal_places' => (int)$default->decimal_places,
'native_decimal_places' => $default->decimal_places,
];
@ -139,7 +121,7 @@ class BalanceController extends Controller
$currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
// set the array with monetary info, if it does not exist.
$data[$currencyId] = $data[$currencyId] ?? [
$data[$currencyId] ??= [
'currency_id' => (string)$currencyId,
'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'],
@ -149,11 +131,11 @@ class BalanceController extends Controller
'native_id' => (string)$default->id,
'native_code' => $default->code,
'native_symbol' => $default->symbol,
'native_decimal_places' => (int)$default->decimal_places,
'native_decimal_places' => $default->decimal_places,
];
// set the array (in monetary info) with spent/earned in this $period, if it does not exist.
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [
$data[$currencyId][$period] ??= [
'period' => $period,
'spent' => '0',
'earned' => '0',
@ -186,7 +168,7 @@ class BalanceController extends Controller
$amountConverted = bcmul($amount, $rate);
// perhaps transaction already has the foreign amount in the native currency.
if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
if ((int)$journal['foreign_currency_id'] === $default->id) {
$amountConverted = $journal['foreign_amount'] ?? '0';
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
}

View File

@ -170,9 +170,8 @@ class BudgetController extends Controller
*/
private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
{
$budgetId = (int)$budget->id;
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
return $this->processExpenses($budgetId, $spent, $start, $end);
return $this->processExpenses($budget->id, $spent, $start, $end);
}
/**
@ -199,8 +198,8 @@ class BudgetController extends Controller
* @var array $block
*/
foreach ($array as $currencyId => $block) {
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
$return[$currencyId] = $return[$currencyId] ?? [
$this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
$return[$currencyId] ??= [
'currency_id' => (string)$currencyId,
'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'],
@ -210,7 +209,7 @@ class BudgetController extends Controller
'native_code' => $this->currency->code,
'native_name' => $this->currency->name,
'native_symbol' => $this->currency->symbol,
'native_decimal_places' => (int)$this->currency->decimal_places,
'native_decimal_places' => $this->currency->decimal_places,
'start' => $start->toAtomString(),
'end' => $end->toAtomString(),
'spent' => '0',
@ -275,11 +274,10 @@ class BudgetController extends Controller
*/
private function processLimit(Budget $budget, BudgetLimit $limit): array
{
$budgetId = (int)$budget->id;
$end = clone $limit->end_date;
$end->endOfDay();
$spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget]));
$limitCurrencyId = (int)$limit->transaction_currency_id;
$limitCurrencyId = $limit->transaction_currency_id;
$limitCurrency = $limit->transactionCurrency;
$converter = new ExchangeRateConverter();
$filtered = [];
@ -295,9 +293,9 @@ class BudgetController extends Controller
$filtered[$currencyId] = $entry;
}
}
$result = $this->processExpenses($budgetId, $filtered, $limit->start_date, $end);
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) {
$compare = bccomp((string)$limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
$compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
if (1 === $compare) {
// convert this amount into the native currency:
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);

View File

@ -74,6 +74,7 @@ class CategoryController extends Controller
*
* @return JsonResponse
* @throws FireflyException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function dashboard(DateRequest $request): JsonResponse
{
@ -104,22 +105,22 @@ class CategoryController extends Controller
$amount = app('steam')->positive($journal['amount']);
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
$key = sprintf('%s-%s', $categoryName, $currency->code);
if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
if ((int)$journal['foreign_currency_id'] === $default->id) {
$nativeAmount = app('steam')->positive($journal['foreign_amount']);
}
// create arrays
$return[$key] = $return[$key] ?? [
$return[$key] ??= [
'label' => $categoryName,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int)$currency->decimal_places,
'currency_decimal_places' => $currency->decimal_places,
'native_id' => (string)$default->id,
'native_code' => $default->code,
'native_name' => $default->name,
'native_symbol' => $default->symbol,
'native_decimal_places' => (int)$default->decimal_places,
'native_decimal_places' => $default->decimal_places,
'period' => null,
'start' => $start->toAtomString(),
'end' => $end->toAtomString(),
@ -135,7 +136,7 @@ class CategoryController extends Controller
$return = array_values($return);
// order by native amount
usort($return, function (array $a, array $b) {
usort($return, static function (array $a, array $b) {
return (float)$a['native_amount'] < (float)$b['native_amount'] ? 1 : -1;
});
return response()->json($this->clean($return));

Some files were not shown because too many files have changed in this diff Show More