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(); $config = new PhpCsFixer\Config();
return $config->setRules([ return $config->setRules([
'@PSR12' => true, '@PHP83Migration' => true,
'declare_strict_types' => true, '@PhpCsFixer:risky' => true,
'strict_param' => true, '@PSR12:risky' => true,
'array_syntax' => ['syntax' => 'short'], '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); ->setFinder($finder);

View File

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

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

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

View File

@ -20,53 +20,74 @@
--> -->
<ruleset name="pcsg-generated-ruleset" <ruleset name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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: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"> xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Bla bla</description> <description>Firefly III ruleset.</description>
<!-- Import the entire controversial code rule set -->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName"/>
</rule>
<!-- <!-- clean code -->
Commando vanuit firefly directory: <!-- <rule ref="rulesets/codesize.xml" /> -->
phpmd database,app,tests html /gdrive-all/development/phpmd/phpmd.xml > public/report.html <rule ref="rulesets/unusedcode.xml"/>
-->
<!-- Import the entire controversial code rule set -->
<rule ref="rulesets/controversial.xml">
<exclude name="CamelCasePropertyName" />
</rule>
<!-- clean code --> <rule ref="rulesets/design.xml/NumberOfChildren">
<rule ref="rulesets/codesize.xml" /> <properties>
<rule ref="rulesets/design.xml" /> <!-- TODO we want to be at minimum 15. But we start high, and drop the bar slowly. -->
<rule ref="rulesets/naming.xml" /> <property name="minimum" value="256"/>
<rule ref="rulesets/unusedcode.xml" /> </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/codesize.xml/CyclomaticComplexity">
<properties>
<property name="reportLevel" value="5"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/NPathComplexity">
<properties>
<property name="minimum" value="128"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
<properties>
<property name="minimum" value="40"/>
</properties>
</rule>
<rule ref="rulesets/codesize.xml/ExcessiveParameterList">
<properties>
<property name="minimum" value="5"/>
</properties>
</rule>
<!-- include clean code manually --> <rule ref="rulesets/naming.xml/ShortMethodName">
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" /> <properties>
<rule ref="rulesets/cleancode.xml/ElseExpression" /> <property name="minimum" value="3"/>
</properties>
</rule>
<!-- no this one --> <!-- code size -->
<!--<rule ref="rulesets/cleancode.xml/StaticAccess" />--> <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
<properties>
<!-- 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>
<!-- 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>
<!-- 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>
<!-- include clean code manually -->
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
<rule ref="rulesets/cleancode.xml/ElseExpression"/>
<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> </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: 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: 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#' - '#is not allowed to extend#'
- '#switch is forbidden to use#'
- '#is neither abstract nor final#' - '#is neither abstract nor final#'
- '#has a nullable return type declaration#' - '#on left side of \?\?\= always exists and is not nullable#'
- '#with a nullable type declaration#' - '#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#' - '#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#' message: '#but containers should not be injected#'
paths: paths:
- ../app/Support/Authentication/RemoteUserGuard.php - ../app/Support/Authentication/RemoteUserGuard.php
- -
message: '#Control structures using switch should not be used.#' message: '#Function compact\(\) should not be used#' # too useful in template rendering.
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#'
paths: paths:
- ../app/Generator/Report/Account/MonthReportGenerator.php - ../app/Generator/Report/Account/MonthReportGenerator.php
- ../app/Generator/Report/Audit/MonthReportGenerator.php - ../app/Generator/Report/Audit/MonthReportGenerator.php
@ -57,7 +48,6 @@ parameters:
message: '#Either catch a more specific exception#' message: '#Either catch a more specific exception#'
paths: paths:
- ../app/Support/Form/FormSupport.php - ../app/Support/Form/FormSupport.php
paths: paths:
- ../app - ../app
- ../database - ../database
@ -66,5 +56,6 @@ parameters:
- ../bootstrap/app.php - ../bootstrap/app.php
# The level 8 is the highest level. original was 5 # 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 # cp .ci/.env.ci .env
# Do static code analysis. # Do static code analysis.
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress if [[ $GITHUB_ACTIONS = "" ]]
./vendor/bin/phpstan analyse -c .ci/phpstan.neon --xdebug --error-format=table > phpstan-report.txt 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 - name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.2' php-version: '8.3'
coverage: xdebug coverage: xdebug
extensions: >- extensions: >-
bcmath bcmath
@ -42,15 +42,24 @@ jobs:
xml xml
xmlwriter xmlwriter
- name: Copy standard configuration
run: cp .env.testing .env
- name: Install Composer dependencies - name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --no-scripts 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" - name: "Create database file"
run: touch storage/database/database.sqlite 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" - name: "Upgrades the database to the latest version"
run: php artisan firefly-iii:upgrade-database run: php artisan firefly-iii:upgrade-database

View File

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

View File

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

View File

@ -27,11 +27,12 @@ namespace FireflyIII\Api\V1\Controllers;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException; use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
use League\Fractal\Manager; use League\Fractal\Manager;
use League\Fractal\Serializer\JsonApiSerializer; use League\Fractal\Serializer\JsonApiSerializer;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
@ -50,7 +51,8 @@ abstract class Controller extends BaseController
use DispatchesJobs; use DispatchesJobs;
use ValidatesRequests; 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 array $allowedSort;
protected ParameterBag $parameters; protected ParameterBag $parameters;
@ -88,8 +90,8 @@ abstract class Controller extends BaseController
if ($page < 1) { if ($page < 1) {
$page = 1; $page = 1;
} }
if ($page > pow(2, 16)) { if ($page > 2 ** 16) {
$page = pow(2, 16); $page = 2 ** 16;
} }
$bag->set('page', $page); $bag->set('page', $page);
@ -100,21 +102,21 @@ abstract class Controller extends BaseController
try { try {
$date = request()->query->get($field); $date = request()->query->get($field);
} catch (BadRequestException $e) { } catch (BadRequestException $e) {
Log::error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $field)); app('log')->error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $field));
Log::error($e->getMessage()); app('log')->error($e->getMessage());
Log::error($e->getTraceAsString()); app('log')->error($e->getTraceAsString());
$value = null; $value = null;
} }
$obj = null; $obj = null;
if (null !== $date) { if (null !== $date) {
try { try {
$obj = Carbon::parse($date); $obj = Carbon::parse((string)$date);
} catch (InvalidDateException | InvalidFormatException $e) { } catch (InvalidDateException | InvalidFormatException $e) {
// don't care // don't care
app('log')->warning( app('log')->warning(
sprintf( sprintf(
'Ignored invalid date "%s" in API controller parameter check: %s', 'Ignored invalid date "%s" in API controller parameter check: %s',
substr($date, 0, 20), substr((string)$date, 0, 20),
$e->getMessage() $e->getMessage()
) )
); );
@ -129,17 +131,22 @@ abstract class Controller extends BaseController
try { try {
$value = request()->query->get($integer); $value = request()->query->get($integer);
} catch (BadRequestException $e) { } catch (BadRequestException $e) {
Log::error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $integer)); app('log')->error(sprintf('Request field "%s" contains a non-scalar value. Value set to NULL.', $integer));
Log::error($e->getMessage()); app('log')->error($e->getMessage());
Log::error($e->getTraceAsString()); app('log')->error($e->getTraceAsString());
$value = null; $value = null;
} }
if (null !== $value) { if (null !== $value) {
$bag->set($integer, (int)$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: // 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); $bag->set($integer, $pageSize);
} }
} }
@ -159,9 +166,9 @@ abstract class Controller extends BaseController
try { try {
$param = (string)request()->query->get('sort'); $param = (string)request()->query->get('sort');
} catch (BadRequestException $e) { } catch (BadRequestException $e) {
Log::error('Request field "sort" contains a non-scalar value. Value set to NULL.'); app('log')->error('Request field "sort" contains a non-scalar value. Value set to NULL.');
Log::error($e->getMessage()); app('log')->error($e->getMessage());
Log::error($e->getTraceAsString()); app('log')->error($e->getTraceAsString());
$param = ''; $param = '';
} }
if ('' === $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 // this deserves better code, but for now a loop of basic if-statements
// to respond to what is in the $query. // to respond to what is in the $query.
// this is OK because only one thing can be in the query at the moment. // 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']); $original = $this->repository->find((int)$params['where']['account_id']);
$destination = $this->repository->find((int)$params['update']['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 * @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']); 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\AccountDestroyService;
use FireflyIII\Services\Internal\Destroy\JournalDestroyService; use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/** /**
* Class DestroyController * Class DestroyController
@ -67,135 +66,34 @@ class DestroyController extends Controller
{ {
$objects = $request->getObjects(); $objects = $request->getObjects();
$this->unused = $request->boolean('unused', false); $this->unused = $request->boolean('unused', false);
switch ($objects) {
default: $allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE,];
throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects)); $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,];
case 'budgets': $liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD];
$this->destroyBudgets(); $transactions = [TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::TRANSFER, TransactionType::RECONCILIATION, TransactionType::OPENING_BALANCE,];
break;
case 'bills': match ($objects) {
$this->destroyBills(); 'budgets' => $this->destroyBudgets(),
break; 'bills' => $this->destroyBills(),
case 'piggy_banks': 'piggy_banks' => $this->destroyPiggyBanks(),
$this->destroyPiggyBanks(); 'rules' => $this->destroyRules(),
break; 'recurring' => $this->destroyRecurringTransactions(),
case 'rules': 'categories' => $this->destroyCategories(),
$this->destroyRules(); 'tags' => $this->destroyTags(),
break; 'object_groups' => $this->destroyObjectGroups(),
case 'recurring': 'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets),
$this->destroyRecurringTransactions(); 'accounts' => $this->destroyAccounts($all),
break; 'asset_accounts' => $this->destroyAccounts([AccountType::ASSET, AccountType::DEFAULT]),
case 'categories': 'expense_accounts' => $this->destroyAccounts([AccountType::BENEFICIARY, AccountType::EXPENSE]),
$this->destroyCategories(); 'revenue_accounts' => $this->destroyAccounts([AccountType::REVENUE]),
break; 'liabilities' => $this->destroyAccounts($liabilities),
case 'tags': 'transactions' => $this->destroyTransactions($transactions),
$this->destroyTags(); 'withdrawals' => $this->destroyTransactions([TransactionType::WITHDRAWAL]),
break; 'deposits' => $this->destroyTransactions([TransactionType::DEPOSIT]),
case 'object_groups': 'transfers' => $this->destroyTransactions([TransactionType::TRANSFER]),
$this->destroyObjectGroups(); default => throw new FireflyException(sprintf('200033: This endpoint can\'t handle object "%s"', $objects)),
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;
}
app('preferences')->mark(); app('preferences')->mark();
return response()->json([], 204); 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 private function destroyAccounts(array $types): void
{ {
@ -303,19 +201,19 @@ class DestroyController extends Controller
foreach ($collection as $account) { foreach ($collection as $account) {
$count = $account->transactions()->count(); $count = $account->transactions()->count();
if (true === $this->unused && 0 === $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); $service->destroy($account, null);
continue; continue;
} }
if (false === $this->unused) { 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); $service->destroy($account, null);
} }
} }
} }
/** /**
* @param array $types * @param array $types <int, string>
*/ */
private function destroyTransactions(array $types): void private function destroyTransactions(array $types): void
{ {

View File

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

View File

@ -35,6 +35,7 @@ use FireflyIII\Models\RuleGroup;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**
@ -51,6 +52,7 @@ class PurgeController extends Controller
*/ */
public function purge(): JsonResponse public function purge(): JsonResponse
{ {
/** @var User $user */
$user = auth()->user(); $user = auth()->user();
// some manual code, too lazy to call all repositories. // 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); $foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [ $response[$key] ??= [
'id' => (string)$billId, 'id' => (string)$billId,
'name' => $journal['bill_name'], 'name' => $journal['bill_name'],
'difference' => '0', 'difference' => '0',
@ -104,7 +104,7 @@ class BillController extends Controller
$response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignKey] = $response[$foreignKey] ?? [ $response[$foreignKey] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,
@ -147,7 +147,7 @@ class BillController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@ -157,7 +157,7 @@ class BillController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -28,7 +28,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Support\Http\Api\TransactionFilter; use FireflyIII\Support\Http\Api\TransactionFilter;
use FireflyIII\Transformers\TransactionGroupTransformer; use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User; use FireflyIII\User;
@ -44,28 +43,6 @@ class ListController extends Controller
{ {
use TransactionFilter; 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: * This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/listTransactionByBudgetLimit * 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\Transformers\BudgetLimitTransformer;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; 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. * Display a listing of the budget limits for this budget.
* *
* @param Request $request * @param Budget $budget
* @param Budget $budget
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException
*/ */
public function index(Request $request, Budget $budget): JsonResponse public function index(Budget $budget): JsonResponse
{ {
$manager = $this->getManager(); $manager = $this->getManager();
$manager->parseIncludes('budget'); $manager->parseIncludes('budget');
@ -111,7 +108,7 @@ class ShowController extends Controller
* @param SameDateRequest $request * @param SameDateRequest $request
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function indexAll(SameDateRequest $request): JsonResponse public function indexAll(SameDateRequest $request): JsonResponse
{ {
@ -138,16 +135,15 @@ class ShowController extends Controller
* This endpoint is documented at: * This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/budgets/getBudgetLimit
* *
* @param Request $request
* @param Budget $budget * @param Budget $budget
* @param BudgetLimit $budgetLimit * @param BudgetLimit $budgetLimit
* *
* @return JsonResponse * @return JsonResponse
* @throws FireflyException * @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.'); throw new FireflyException('20028: The budget limit does not belong to the budget.');
} }
// continue! // continue!

View File

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

View File

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

View File

@ -33,7 +33,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository; use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepository;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/** /**
* Class DestroyController * Class DestroyController
@ -79,7 +78,7 @@ class DestroyController extends Controller
*/ */
public function destroy(TransactionGroup $transactionGroup): JsonResponse 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: // grab asset account(s) from group:
$accounts = []; $accounts = [];
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
@ -100,7 +99,7 @@ class DestroyController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $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)); event(new UpdatedAccount($account));
} }

View File

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

View File

@ -32,7 +32,6 @@ use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface
use FireflyIII\Transformers\TransactionGroupTransformer; use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -77,7 +76,7 @@ class UpdateController extends Controller
*/ */
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse 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(); $data = $request->getAll();
$transactionGroup = $this->groupRepository->update($transactionGroup, $data); $transactionGroup = $this->groupRepository->update($transactionGroup, $data);

View File

@ -255,8 +255,8 @@ class ListController extends Controller
$unfiltered = $recurringRepos->getAll(); $unfiltered = $recurringRepos->getAll();
// filter selection // filter selection
$collection = $unfiltered->filter( $collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Recurrence $recurrence) use ($currency) { static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) { foreach ($recurrence->recurrenceTransactions as $transaction) {
if ($transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id) { 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); $ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll(); $unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter( $collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Rule $rule) use ($currency) { static function (Rule $rule) use ($currency) { // @phpstan-ignore-line
/** @var RuleTrigger $trigger */ /** @var RuleTrigger $trigger */
foreach ($rule->ruleTriggers as $trigger) { foreach ($rule->ruleTriggers as $trigger) {
if ('currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value) { 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\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Log;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;
@ -67,7 +66,7 @@ class AccountController extends Controller
*/ */
public function search(Request $request): JsonResponse | Response public function search(Request $request): JsonResponse | Response
{ {
Log::debug('Now in account search()'); app('log')->debug('Now in account search()');
$manager = $this->getManager(); $manager = $this->getManager();
$query = trim((string)$request->get('query')); $query = trim((string)$request->get('query'));
$field = trim((string)$request->get('field')); $field = trim((string)$request->get('field'));

View File

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

View File

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

View File

@ -27,7 +27,6 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\System\CronRequest; use FireflyIII\Api\V1\Requests\System\CronRequest;
use FireflyIII\Support\Http\Controllers\CronRunner; use FireflyIII\Support\Http\Controllers\CronRunner;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; 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 * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/about/getCron
* *
* @param CronRequest $request * @param CronRequest $request
* @param string $token
* *
* @return JsonResponse * @return JsonResponse
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function cron(CronRequest $request, string $token): JsonResponse public function cron(CronRequest $request): JsonResponse
{ {
$config = $request->getAll(); $config = $request->getAll();
Log::debug(sprintf('Now in %s', __METHOD__)); app('log')->debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Date is %s', $config['date']->toIsoString())); app('log')->debug(sprintf('Date is %s', $config['date']->toIsoString()));
$return = []; $return = [];
$return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']); $return['recurring_transactions'] = $this->runRecurring($config['force'], $config['date']);
$return['auto_budgets'] = $this->runAutoBudget($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 FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Facades\Log;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
@ -192,7 +191,7 @@ class UserController extends Controller
// can only update 'blocked' when user is admin. // can only update 'blocked' when user is admin.
if (!$this->repository->hasRole(auth()->user(), 'owner')) { 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']); unset($data['blocked'], $data['blocked_code']);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,9 +40,9 @@ use Illuminate\Foundation\Http\FormRequest;
*/ */
class StoreRequest extends FormRequest class StoreRequest extends FormRequest
{ {
use ConvertsDataTypes;
use AppendsLocationData; use AppendsLocationData;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* @return array * @return array
@ -124,7 +124,7 @@ class StoreRequest extends FormRequest
'liability_start_date' => 'required_with:liability_amount|date', 'liability_start_date' => 'required_with:liability_amount|date',
'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit', 'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit',
'interest' => 'between:0,100|numeric', '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', 'notes' => 'min:0|max:65536',
]; ];

View File

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

View File

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

View File

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

View File

@ -36,8 +36,8 @@ use Illuminate\Validation\Validator;
*/ */
class Request extends FormRequest class Request extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* Get all data from the request. * Get all data from the request.
@ -84,7 +84,7 @@ class Request extends FormRequest
public function withValidator(Validator $validator): void public function withValidator(Validator $validator): void
{ {
$validator->after( $validator->after(
function (Validator $validator) { static function (Validator $validator) {
// validate start before end only if both are there. // validate start before end only if both are there.
$data = $validator->getData(); $data = $validator->getData();
if (array_key_exists('start', $data) && array_key_exists('end', $data)) { 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\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
/** /**
@ -38,8 +37,8 @@ use Illuminate\Validation\Validator;
*/ */
class StoreRequest extends FormRequest class StoreRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* Get all data from the request. * Get all data from the request.
@ -48,7 +47,7 @@ class StoreRequest extends FormRequest
*/ */
public function getAll(): array public function getAll(): array
{ {
Log::debug('Raw fields in Bill StoreRequest', $this->all()); app('log')->debug('Raw fields in Bill StoreRequest', $this->all());
$fields = [ $fields = [
'name' => ['name', 'convertString'], 'name' => ['name', 'convertString'],
'amount_min' => ['amount_min', 'convertString'], 'amount_min' => ['amount_min', 'convertString'],

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -40,12 +40,12 @@ use Illuminate\Validation\Validator;
*/ */
class UpdateRequest extends FormRequest class UpdateRequest extends FormRequest
{ {
use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
use RecurrenceValidation;
use TransactionValidation;
use CurrencyValidation; use CurrencyValidation;
use GetRecurrenceData; use GetRecurrenceData;
use ChecksLogin; use RecurrenceValidation;
use TransactionValidation;
/** /**
* Get all data from the request. * Get all data from the request.
@ -73,9 +73,7 @@ class UpdateRequest extends FormRequest
if (null !== $reps) { if (null !== $reps) {
$return['repetitions'] = $reps; $return['repetitions'] = $reps;
} }
if (null !== $transactions) { $return['transactions'] = $transactions;
$return['transactions'] = $transactions;
}
return $return; 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 * 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. * 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 = []; $return = [];
// transaction data: // transaction data:
/** @var array|null $transactions */ /** @var array|null $transactions */
$transactions = $this->get('transactions'); $transactions = $this->get('transactions');
if (null === $transactions) { if (null === $transactions) {
return null; return [];
} }
/** @var array $transaction */ /** @var array $transaction */
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {

View File

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

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/ */
class TestRequest extends FormRequest class TestRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* @return array * @return array
@ -66,7 +66,16 @@ class TestRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon 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 class TriggerRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* @return array * @return array
@ -56,7 +56,16 @@ class TriggerRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon 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\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator; use Illuminate\Validation\Validator;
use function is_array;
/** /**
* Class UpdateRequest * Class UpdateRequest
*/ */
class UpdateRequest extends FormRequest class UpdateRequest extends FormRequest
{ {
use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
use GetRuleConfiguration; use GetRuleConfiguration;
use ChecksLogin;
/** /**
* Get all data from the request. * Get all data from the request.

View File

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

View File

@ -34,8 +34,8 @@ use Illuminate\Foundation\Http\FormRequest;
*/ */
class TestRequest extends FormRequest class TestRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* @return array * @return array
@ -56,7 +56,16 @@ class TestRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon 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 class TriggerRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* @return array * @return array
@ -56,7 +56,16 @@ class TriggerRequest extends FormRequest
*/ */
private function getDate(string $field): ?Carbon 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 class UpdateRequest extends FormRequest
{ {
use ConvertsDataTypes;
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes;
/** /**
* Get all data from the request. * Get all data from the request.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,7 +26,7 @@ namespace FireflyIII\Api\V2\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller; 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\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; 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\CleansChartData;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
@ -78,14 +79,15 @@ class AccountController extends Controller
* *
* TODO validate and set user_group_id from request * TODO validate and set user_group_id from request
* *
* @param DateRequest $request * @param DashboardChartRequest $request
* *
* @return JsonResponse * @return JsonResponse
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
* @throws FireflyException * @throws FireflyException
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function dashboard(DateRequest $request): JsonResponse public function dashboard(DashboardChartRequest $request): JsonResponse
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = $this->parameters->get('start'); $start = $this->parameters->get('start');
@ -93,18 +95,37 @@ class AccountController extends Controller
$end = $this->parameters->get('end'); $end = $this->parameters->get('end');
$end->endOfDay(); $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 */ /** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency(); $default = app('amount')->getDefaultCurrency();
$accounts = $this->repository->getAccountsById($frontPage->data); $params = $request->getAll();
/** @var Collection $accounts */
$accounts = $params['accounts'];
$chartData = []; $chartData = [];
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) { // user's preferences
$frontPage->data = $defaultSet; if (0 === $accounts->count()) {
$frontPage->save(); $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 */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account);
@ -123,7 +144,7 @@ class AccountController extends Controller
'native_id' => (string)$default->id, 'native_id' => (string)$default->id,
'native_code' => $default->code, 'native_code' => $default->code,
'native_symbol' => $default->symbol, 'native_symbol' => $default->symbol,
'native_decimal_places' => (int)$default->decimal_places, 'native_decimal_places' => $default->decimal_places,
'start' => $start->toAtomString(), 'start' => $start->toAtomString(),
'end' => $end->toAtomString(), 'end' => $end->toAtomString(),
'period' => '1D', 'period' => '1D',

View File

@ -32,7 +32,6 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\UserGroups\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\CleansChartData; use FireflyIII\Support\Http\Api\CleansChartData;
use FireflyIII\Support\Http\Api\ExchangeRateConverter; use FireflyIII\Support\Http\Api\ExchangeRateConverter;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
@ -45,23 +44,6 @@ class BalanceController extends Controller
{ {
use CleansChartData; 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. * The code is practically a duplicate of ReportController::operations.
* *
@ -99,7 +81,7 @@ class BalanceController extends Controller
/** @var TransactionCurrency $default */ /** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency(); $default = app('amount')->getDefaultCurrency();
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
$currencies = [(int)$default->id => $default,]; // currency cache $currencies = [$default->id => $default,]; // currency cache
$data = []; $data = [];
$chartData = []; $chartData = [];
@ -112,18 +94,18 @@ class BalanceController extends Controller
$journals = $collector->getExtractedJournals(); $journals = $collector->getExtractedJournals();
// set array for default currency (even if unused later on) // set array for default currency (even if unused later on)
$defaultCurrencyId = (int)$default->id; $defaultCurrencyId = $default->id;
$data[$defaultCurrencyId] = [ $data[$defaultCurrencyId] = [
'currency_id' => (string)$defaultCurrencyId, 'currency_id' => (string)$defaultCurrencyId,
'currency_symbol' => $default->symbol, 'currency_symbol' => $default->symbol,
'currency_code' => $default->code, 'currency_code' => $default->code,
'currency_name' => $default->name, 'currency_name' => $default->name,
'currency_decimal_places' => (int)$default->decimal_places, 'currency_decimal_places' => $default->decimal_places,
'native_id' => (string)$defaultCurrencyId, 'native_id' => (string)$defaultCurrencyId,
'native_symbol' => $default->symbol, 'native_symbol' => $default->symbol,
'native_code' => $default->code, 'native_code' => $default->code,
'native_name' => $default->name, '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. $currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
// set the array with monetary info, if it does not exist. // set the array with monetary info, if it does not exist.
$data[$currencyId] = $data[$currencyId] ?? [ $data[$currencyId] ??= [
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@ -149,11 +131,11 @@ class BalanceController extends Controller
'native_id' => (string)$default->id, 'native_id' => (string)$default->id,
'native_code' => $default->code, 'native_code' => $default->code,
'native_symbol' => $default->symbol, '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. // 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, 'period' => $period,
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
@ -186,7 +168,7 @@ class BalanceController extends Controller
$amountConverted = bcmul($amount, $rate); $amountConverted = bcmul($amount, $rate);
// perhaps transaction already has the foreign amount in the native currency. // 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 = $journal['foreign_amount'] ?? '0';
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted); $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 private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
{ {
$budgetId = (int)$budget->id; $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget])); return $this->processExpenses($budget->id, $spent, $start, $end);
return $this->processExpenses($budgetId, $spent, $start, $end);
} }
/** /**
@ -199,8 +198,8 @@ class BudgetController extends Controller
* @var array $block * @var array $block
*/ */
foreach ($array as $currencyId => $block) { foreach ($array as $currencyId => $block) {
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId); $this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
$return[$currencyId] = $return[$currencyId] ?? [ $return[$currencyId] ??= [
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
'currency_code' => $block['currency_code'], 'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'], 'currency_name' => $block['currency_name'],
@ -210,7 +209,7 @@ class BudgetController extends Controller
'native_code' => $this->currency->code, 'native_code' => $this->currency->code,
'native_name' => $this->currency->name, 'native_name' => $this->currency->name,
'native_symbol' => $this->currency->symbol, 'native_symbol' => $this->currency->symbol,
'native_decimal_places' => (int)$this->currency->decimal_places, 'native_decimal_places' => $this->currency->decimal_places,
'start' => $start->toAtomString(), 'start' => $start->toAtomString(),
'end' => $end->toAtomString(), 'end' => $end->toAtomString(),
'spent' => '0', 'spent' => '0',
@ -275,11 +274,10 @@ class BudgetController extends Controller
*/ */
private function processLimit(Budget $budget, BudgetLimit $limit): array private function processLimit(Budget $budget, BudgetLimit $limit): array
{ {
$budgetId = (int)$budget->id; $end = clone $limit->end_date;
$end = clone $limit->end_date;
$end->endOfDay(); $end->endOfDay();
$spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget])); $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; $limitCurrency = $limit->transactionCurrency;
$converter = new ExchangeRateConverter(); $converter = new ExchangeRateConverter();
$filtered = []; $filtered = [];
@ -295,9 +293,9 @@ class BudgetController extends Controller
$filtered[$currencyId] = $entry; $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)) { 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) { if (1 === $compare) {
// convert this amount into the native currency: // convert this amount into the native currency:
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']); $result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);

View File

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

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