1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Add Psalm, code cleanup!

This commit is contained in:
David Bomba 2020-10-28 17:58:15 +11:00
parent d7930e4c14
commit adeda5526e
10 changed files with 623 additions and 14 deletions

View File

@ -28,7 +28,7 @@ use App\Http\Requests\Invoice\EditInvoiceRequest;
use App\Http\Requests\Invoice\ShowInvoiceRequest;
use App\Http\Requests\Invoice\StoreInvoiceRequest;
use App\Http\Requests\Invoice\UpdateInvoiceRequest;
use App\Jobs\Invoice\EmailInvoice;
use App\Jobs\Entity\EmailEntity;
use App\Jobs\Invoice\StoreInvoice;
use App\Jobs\Invoice\ZipInvoices;
use App\Jobs\Util\UnlinkFile;
@ -716,7 +716,7 @@ class InvoiceController extends BaseController
$invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) {
$email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template);
EmailInvoice::dispatch($email_builder, $invitation, $invoice->company);
EmailEntity::dispatch($invitation, $invoice->company);
});
if (! $bulk) {

View File

@ -15,7 +15,7 @@ use App\DataMapper\Analytics\SendRecurringFailure;
use App\Events\Invoice\InvoiceWasEmailed;
use App\Factory\RecurringInvoiceToInvoiceFactory;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Invoice\EmailInvoice;
use App\Jobs\Entity\EmailEntity;
use App\Models\Invoice;
use App\Models\RecurringInvoice;
use App\Utils\Ninja;
@ -76,7 +76,7 @@ class SendRecurring implements ShouldQueue
$email_builder = (new InvoiceEmail())->build($invitation);
if($invitation->contact && strlen($invitation->contact->email) >=1){
EmailInvoice::dispatch($email_builder, $invitation, $invoice->company);
EmailEntity::dispatch($invitation, $invoice->company);
info("Firing email for invoice {$invoice->number}");
}

View File

@ -12,6 +12,7 @@
namespace App\Jobs\Util;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Entity\EmailEntity;
use App\Jobs\Invoice\EmailInvoice;
use App\Libraries\MultiDB;
use App\Models\SystemLog;
@ -56,9 +57,6 @@ class SendFailedEmails implements ShouldQueue
private function processEmails()
{
//\Log::error('processing emails');
//info("process emails");
//@todo check that the quota is available for the job
$email_jobs = SystemLog::where('event_id', SystemLog::EVENT_MAIL_RETRY_QUEUE)->get();
@ -71,7 +69,7 @@ class SendFailedEmails implements ShouldQueue
$email_builder = (new InvoiceEmail())->build($invitation, $job_meta_array['reminder_template']);
if ($invitation->contact->send_email && $invitation->contact->email) {
EmailInvoice::dispatch($email_builder, $invitation, $invitation->company);
EmailEntity::dispatch($invitation, $invitation->company);
}
}
});

View File

@ -22,6 +22,8 @@ use Illuminate\Support\Str;
*/
class ClientContactRepository extends BaseRepository
{
public $is_primary;
public function save(array $data, Client $client) : void
{
if (isset($data['contacts'])) {

View File

@ -21,6 +21,8 @@ use Illuminate\Support\Str;
*/
class VendorContactRepository extends BaseRepository
{
public $is_primary;
public function save($contacts, Vendor $vendor) : void
{

View File

@ -13,7 +13,6 @@ namespace App\Services\Invoice;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Entity\EmailEntity;
use App\Jobs\Invoice\EmailInvoice;
use App\Models\ClientContact;
use App\Models\Invoice;
use App\Services\AbstractService;
@ -51,7 +50,6 @@ class SendEmail extends AbstractService
$email_builder = (new InvoiceEmail())->build($invitation, $this->reminder_template);
if ($invitation->contact->send_email && $invitation->contact->email) {
// EmailInvoice::dispatch($email_builder, $invitation, $invitation->company);
EmailEntity::dispatchNow($invitation, $invitation->company);
}

View File

@ -15,7 +15,7 @@ use App\Events\Invoice\InvoiceWasEmailed;
use App\Events\Payment\PaymentWasCreated;
use App\Factory\PaymentFactory;
use App\Helpers\Email\InvoiceEmail;
use App\Jobs\Invoice\EmailInvoice;
use App\Jobs\Invoice\EmailEntity;
use App\Models\Client;
use App\Models\Invoice;
use App\Models\Payment;
@ -69,9 +69,8 @@ class TriggeredActions extends AbstractService
$reminder_template = 'payment';
$this->invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($reminder_template) {
$email_builder = (new InvoiceEmail())->build($invitation, $reminder_template);
EmailInvoice::dispatch($email_builder, $invitation, $this->invoice->company);
EmailEntity::dispatch($invitation, $this->invoice->company);
});
if ($this->invoice->invitations->count() > 0) {

View File

@ -74,6 +74,7 @@
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0",
"vimeo/psalm": "^4.0",
"wildbit/postmark-php": "^4.0"
},
"autoload": {

573
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "152c174ecc48f87a2c7fd00335c6fc86",
"content-hash": "5055049d1f5fa8418925b54a94265526",
"packages": [
{
"name": "asgrim/ofxparser",
@ -9801,6 +9801,166 @@
}
],
"packages-dev": [
{
"name": "amphp/amp",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/amp.git",
"reference": "f220a51458bf4dd0dedebb171ac3457813c72bbc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/amp/zipball/f220a51458bf4dd0dedebb171ac3457813c72bbc",
"reference": "f220a51458bf4dd0dedebb171ac3457813c72bbc",
"shasum": ""
},
"require": {
"php": ">=7"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6.0.9 | ^7",
"psalm/phar": "^3.11@dev",
"react/promise": "^2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\": "lib"
},
"files": [
"lib/functions.php",
"lib/Internal/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Daniel Lowrey",
"email": "rdlowrey@php.net"
},
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Bob Weinand",
"email": "bobwei9@hotmail.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A non-blocking concurrency framework for PHP applications.",
"homepage": "http://amphp.org/amp",
"keywords": [
"async",
"asynchronous",
"awaitable",
"concurrency",
"event",
"event-loop",
"future",
"non-blocking",
"promise"
],
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/amp/issues",
"source": "https://github.com/amphp/amp/tree/master"
},
"funding": [
{
"url": "https://github.com/amphp",
"type": "github"
}
],
"time": "2020-07-14T21:47:18+00:00"
},
{
"name": "amphp/byte-stream",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/amphp/byte-stream.git",
"reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/amphp/byte-stream/zipball/f0c20cf598a958ba2aa8c6e5a71c697d652c7088",
"reference": "f0c20cf598a958ba2aa8c6e5a71c697d652c7088",
"shasum": ""
},
"require": {
"amphp/amp": "^2",
"php": ">=7.1"
},
"require-dev": {
"amphp/php-cs-fixer-config": "dev-master",
"amphp/phpunit-util": "^1.4",
"friendsofphp/php-cs-fixer": "^2.3",
"jetbrains/phpstorm-stubs": "^2019.3",
"phpunit/phpunit": "^6 || ^7 || ^8",
"psalm/phar": "^3.11.4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Amp\\ByteStream\\": "lib"
},
"files": [
"lib/functions.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Aaron Piotrowski",
"email": "aaron@trowski.com"
},
{
"name": "Niklas Keller",
"email": "me@kelunik.com"
}
],
"description": "A stream abstraction to make working with non-blocking I/O simple.",
"homepage": "http://amphp.org/byte-stream",
"keywords": [
"amp",
"amphp",
"async",
"io",
"non-blocking",
"stream"
],
"support": {
"irc": "irc://irc.freenode.org/amphp",
"issues": "https://github.com/amphp/byte-stream/issues",
"source": "https://github.com/amphp/byte-stream/tree/master"
},
"time": "2020-06-29T18:35:05+00:00"
},
{
"name": "anahkiasen/former",
"version": "4.5.0",
@ -10503,6 +10663,107 @@
},
"time": "2020-10-16T08:27:54+00:00"
},
{
"name": "felixfbecker/advanced-json-rpc",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/felixfbecker/php-advanced-json-rpc.git",
"reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixfbecker/php-advanced-json-rpc/zipball/0ed363f8de17d284d479ec813c9ad3f6834b5c40",
"reference": "0ed363f8de17d284d479ec813c9ad3f6834b5c40",
"shasum": ""
},
"require": {
"netresearch/jsonmapper": "^1.0 || ^2.0",
"php": ">=7.0",
"phpdocumentor/reflection-docblock": "^4.0.0 || ^5.0.0"
},
"require-dev": {
"phpunit/phpunit": "^6.0.0"
},
"type": "library",
"autoload": {
"psr-4": {
"AdvancedJsonRpc\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Felix Becker",
"email": "felix.b@outlook.com"
}
],
"description": "A more advanced JSONRPC implementation",
"support": {
"issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues",
"source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/master"
},
"time": "2020-03-11T15:21:41+00:00"
},
{
"name": "felixfbecker/language-server-protocol",
"version": "v1.5.0",
"source": {
"type": "git",
"url": "https://github.com/felixfbecker/php-language-server-protocol.git",
"reference": "85e83cacd2ed573238678c6875f8f0d7ec699541"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixfbecker/php-language-server-protocol/zipball/85e83cacd2ed573238678c6875f8f0d7ec699541",
"reference": "85e83cacd2ed573238678c6875f8f0d7ec699541",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpstan/phpstan": "*",
"squizlabs/php_codesniffer": "^3.1",
"vimeo/psalm": "^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"LanguageServerProtocol\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Felix Becker",
"email": "felix.b@outlook.com"
}
],
"description": "PHP classes for the Language Server Protocol",
"keywords": [
"language",
"microsoft",
"php",
"server"
],
"support": {
"issues": "https://github.com/felixfbecker/php-language-server-protocol/issues",
"source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.5.0"
},
"time": "2020-10-23T13:55:30+00:00"
},
{
"name": "filp/whoops",
"version": "2.9.0",
@ -10814,6 +11075,57 @@
],
"time": "2020-06-29T13:22:24+00:00"
},
{
"name": "netresearch/jsonmapper",
"version": "v2.1.0",
"source": {
"type": "git",
"url": "https://github.com/cweiske/jsonmapper.git",
"reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/e0f1e33a71587aca81be5cffbb9746510e1fe04e",
"reference": "e0f1e33a71587aca81be5cffbb9746510e1fe04e",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-pcre": "*",
"ext-reflection": "*",
"ext-spl": "*",
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "~4.8.35 || ~5.7 || ~6.4 || ~7.0",
"squizlabs/php_codesniffer": "~3.5"
},
"type": "library",
"autoload": {
"psr-0": {
"JsonMapper": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
{
"name": "Christian Weiske",
"email": "cweiske@cweiske.de",
"homepage": "http://github.com/cweiske/jsonmapper/",
"role": "Developer"
}
],
"description": "Map nested JSON structures onto PHP classes",
"support": {
"email": "cweiske@cweiske.de",
"issues": "https://github.com/cweiske/jsonmapper/issues",
"source": "https://github.com/cweiske/jsonmapper/tree/master"
},
"time": "2020-04-16T18:48:43+00:00"
},
{
"name": "nunomaduro/collision",
"version": "v5.0.2",
@ -10902,6 +11214,59 @@
],
"time": "2020-08-27T18:58:22+00:00"
},
{
"name": "openlss/lib-array2xml",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/nullivex/lib-array2xml.git",
"reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nullivex/lib-array2xml/zipball/a91f18a8dfc69ffabe5f9b068bc39bb202c81d90",
"reference": "a91f18a8dfc69ffabe5f9b068bc39bb202c81d90",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"type": "library",
"autoload": {
"psr-0": {
"LSS": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Bryan Tong",
"email": "bryan@nullivex.com",
"homepage": "https://www.nullivex.com"
},
{
"name": "Tony Butler",
"email": "spudz76@gmail.com",
"homepage": "https://www.nullivex.com"
}
],
"description": "Array2XML conversion library credit to lalit.org",
"homepage": "https://www.nullivex.com",
"keywords": [
"array",
"array conversion",
"xml",
"xml conversion"
],
"support": {
"issues": "https://github.com/nullivex/lib-array2xml/issues",
"source": "https://github.com/nullivex/lib-array2xml/tree/master"
},
"time": "2019-03-29T20:06:56+00:00"
},
{
"name": "phar-io/manifest",
"version": "2.0.1",
@ -12967,6 +13332,111 @@
],
"time": "2020-07-12T23:59:07+00:00"
},
{
"name": "vimeo/psalm",
"version": "4.0.1",
"source": {
"type": "git",
"url": "https://github.com/vimeo/psalm.git",
"reference": "b1e2e30026936ef8d5bf6a354d1c3959b6231f44"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vimeo/psalm/zipball/b1e2e30026936ef8d5bf6a354d1c3959b6231f44",
"reference": "b1e2e30026936ef8d5bf6a354d1c3959b6231f44",
"shasum": ""
},
"require": {
"amphp/amp": "^2.1",
"amphp/byte-stream": "^1.5",
"composer/package-versions-deprecated": "^1.8.0",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^1.1",
"dnoegel/php-xdg-base-dir": "^0.1.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-tokenizer": "*",
"felixfbecker/advanced-json-rpc": "^3.0.3",
"felixfbecker/language-server-protocol": "^1.4",
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0",
"nikic/php-parser": "^4.10.1",
"openlss/lib-array2xml": "^1.0",
"php": "^7.3|^8",
"sebastian/diff": "^3.0 || ^4.0",
"symfony/console": "^3.4.17 || ^4.1.6 || ^5.0",
"webmozart/glob": "^4.1",
"webmozart/path-util": "^2.3"
},
"provide": {
"psalm/psalm": "self.version"
},
"require-dev": {
"amphp/amp": "^2.4.2",
"bamarni/composer-bin-plugin": "^1.2",
"brianium/paratest": "^4.0.0",
"ext-curl": "*",
"phpdocumentor/reflection-docblock": "^5",
"phpmyadmin/sql-parser": "5.1.0",
"phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-phpunit": "^0.13",
"slevomat/coding-standard": "^5.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3",
"weirdan/prophecy-shim": "^1.0 || ^2.0"
},
"suggest": {
"ext-igbinary": "^2.0.5"
},
"bin": [
"psalm",
"psalm-language-server",
"psalm-plugin",
"psalm-refactor",
"psalter"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.x-dev",
"dev-3.x": "3.x-dev",
"dev-2.x": "2.x-dev",
"dev-1.x": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psalm\\": "src/Psalm/"
},
"files": [
"src/functions.php",
"src/spl_object_id.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Matthew Brown"
}
],
"description": "A static analysis tool for finding errors in PHP applications",
"keywords": [
"code",
"inspection",
"php"
],
"support": {
"issues": "https://github.com/vimeo/psalm/issues",
"source": "https://github.com/vimeo/psalm/tree/4.0.1"
},
"time": "2020-10-20T13:40:17+00:00"
},
{
"name": "webmozart/assert",
"version": "1.9.1",
@ -13020,6 +13490,107 @@
},
"time": "2020-07-08T17:02:28+00:00"
},
{
"name": "webmozart/glob",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/glob.git",
"reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/glob/zipball/3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe",
"reference": "3cbf63d4973cf9d780b93d2da8eec7e4a9e63bbe",
"shasum": ""
},
"require": {
"php": "^5.3.3|^7.0",
"webmozart/path-util": "^2.2"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1",
"symfony/filesystem": "^2.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.1-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\Glob\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A PHP implementation of Ant's glob.",
"support": {
"issues": "https://github.com/webmozart/glob/issues",
"source": "https://github.com/webmozart/glob/tree/master"
},
"time": "2015-12-29T11:14:33+00:00"
},
{
"name": "webmozart/path-util",
"version": "2.3.0",
"source": {
"type": "git",
"url": "https://github.com/webmozart/path-util.git",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/webmozart/path-util/zipball/d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"reference": "d939f7edc24c9a1bb9c0dee5cb05d8e859490725",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"webmozart/assert": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.6",
"sebastian/version": "^1.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"autoload": {
"psr-4": {
"Webmozart\\PathUtil\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bernhard Schussek",
"email": "bschussek@gmail.com"
}
],
"description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.",
"support": {
"issues": "https://github.com/webmozart/path-util/issues",
"source": "https://github.com/webmozart/path-util/tree/2.3.0"
},
"time": "2015-12-17T08:42:14+00:00"
},
{
"name": "wildbit/postmark-php",
"version": "4.0.0",

38
psalm.xml Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="app" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MissingPropertyType errorLevel="suppress" />
<UndefinedFunction>
<errorLevel type="suppress">
<directory name="app" />
</errorLevel>
</UndefinedFunction>
<UndefinedMethod>
<errorLevel type="suppress">
<directory name="app" />
</errorLevel>
</UndefinedMethod>
<UndefinedClass>
<errorLevel type="suppress">
<directory name="app" />
</errorLevel>
</UndefinedClass>
</issueHandlers>
</psalm>