From ae0e85589ba22f11447d35b8620fc124a16bcafb Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Fri, 14 Oct 2022 16:20:35 +0530 Subject: [PATCH 01/24] Added code analyzer --- .github/workflows/codeql-analysis.yml | 20 +++ composer.json | 7 +- composer.lock | 180 ++++++++------------------ 3 files changed, 82 insertions(+), 125 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..734db04c --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,20 @@ +name: "CodeQL" + +on: [pull_request] +jobs: + lint: + name: CodeQL + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - run: git checkout HEAD^2 + + - name: Run CodeQL + run: | + docker run --rm -v $PWD:/app composer sh -c \ + "composer install --profile --ignore-platform-reqs && composer check" \ No newline at end of file diff --git a/composer.json b/composer.json index e94220b3..51d51fe9 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,8 @@ "scripts": { "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", - "format": "vendor/bin/phpcbf" + "format": "vendor/bin/phpcbf", + "check": "./vendor/bin/phpstan analyse --level max src tests" }, "authors": [ { @@ -34,7 +35,9 @@ "require-dev": { "phpunit/phpunit": "9.5.*", "phpmailer/phpmailer": "6.6.*", - "squizlabs/php_codesniffer": "^3.6" + "squizlabs/php_codesniffer": "^3.6", + "vimeo/psalm": "4.0.1", + "phpstan/phpstan": "1.9.x-dev" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index 88f16b81..1d688951 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "e33a07c2dd4a4d32669369f3e04a7a21", + "content-hash": "687eb9ecd82ac2dca4a911f78d8dc516", "packages": [], "packages-dev": [ { @@ -57,10 +57,6 @@ "constructor", "instantiate" ], - "support": { - "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.4.1" - }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -124,10 +120,6 @@ "object", "object graph" ], - "support": { - "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" - }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -186,10 +178,6 @@ "parser", "php" ], - "support": { - "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" - }, "time": "2022-09-04T07:30:47+00:00" }, { @@ -246,10 +234,6 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "support": { - "issues": "https://github.com/phar-io/manifest/issues", - "source": "https://github.com/phar-io/manifest/tree/2.0.3" - }, "time": "2021-07-20T11:28:43+00:00" }, { @@ -297,10 +281,6 @@ } ], "description": "Library for handling version information and constraints", - "support": { - "issues": "https://github.com/phar-io/version/issues", - "source": "https://github.com/phar-io/version/tree/3.2.1" - }, "time": "2022-02-21T01:04:05+00:00" }, { @@ -369,10 +349,6 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", - "support": { - "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.4" - }, "funding": [ { "url": "https://github.com/Synchro", @@ -381,6 +357,61 @@ ], "time": "2022-08-22T09:22:00+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.8.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2", + "reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-10-13T13:40:18+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.17", @@ -446,10 +477,6 @@ "testing", "xunit" ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -506,10 +533,6 @@ "filesystem", "iterator" ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -569,10 +592,6 @@ "keywords": [ "process" ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-invoker/issues", - "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -628,10 +647,6 @@ "keywords": [ "template" ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -687,10 +702,6 @@ "keywords": [ "timer" ], - "support": { - "issues": "https://github.com/sebastianbergmann/php-timer/issues", - "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -781,10 +792,6 @@ "testing", "xunit" ], - "support": { - "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.25" - }, "funding": [ { "url": "https://phpunit.de/sponsors.html", @@ -845,10 +852,6 @@ ], "description": "Library for parsing CLI options", "homepage": "https://github.com/sebastianbergmann/cli-parser", - "support": { - "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -901,10 +904,6 @@ ], "description": "Collection of value objects that represent the PHP code units", "homepage": "https://github.com/sebastianbergmann/code-unit", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit/issues", - "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -956,10 +955,6 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "support": { - "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", - "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1030,10 +1025,6 @@ "compare", "equality" ], - "support": { - "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1087,10 +1078,6 @@ ], "description": "Library for calculating the complexity of PHP code units", "homepage": "https://github.com/sebastianbergmann/complexity", - "support": { - "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1153,10 +1140,6 @@ "unidiff", "unified diff" ], - "support": { - "issues": "https://github.com/sebastianbergmann/diff/issues", - "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1216,10 +1199,6 @@ "environment", "hhvm" ], - "support": { - "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1293,10 +1272,6 @@ "export", "exporter" ], - "support": { - "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1357,10 +1332,6 @@ "keywords": [ "global state" ], - "support": { - "issues": "https://github.com/sebastianbergmann/global-state/issues", - "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1414,10 +1385,6 @@ ], "description": "Library for counting the lines of code in PHP source code", "homepage": "https://github.com/sebastianbergmann/lines-of-code", - "support": { - "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", - "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1471,10 +1438,6 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", - "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1526,10 +1489,6 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "support": { - "issues": "https://github.com/sebastianbergmann/object-reflector/issues", - "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1589,10 +1548,6 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "support": { - "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1644,10 +1599,6 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "support": { - "issues": "https://github.com/sebastianbergmann/resource-operations/issues", - "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1700,10 +1651,6 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", - "support": { - "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1753,10 +1700,6 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "support": { - "issues": "https://github.com/sebastianbergmann/version/issues", - "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" - }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1814,11 +1757,6 @@ "phpcs", "standards" ], - "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" - }, "time": "2022-06-18T07:21:10+00:00" }, { @@ -1859,10 +1797,6 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "support": { - "issues": "https://github.com/theseer/tokenizer/issues", - "source": "https://github.com/theseer/tokenizer/tree/1.2.1" - }, "funding": [ { "url": "https://github.com/theseer", @@ -1885,5 +1819,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "1.1.0" } From 3f7dcc14899a6d17db7ad028e4c2e03846b89d1b Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Tue, 25 Oct 2022 19:19:11 +0530 Subject: [PATCH 02/24] code fix till level 4 --- composer.json | 3 +-- src/Utopia/Messaging/Adapters/Email.php | 2 +- src/Utopia/Messaging/Adapters/Email/Mock.php | 5 +++-- src/Utopia/Messaging/Adapters/Push.php | 3 ++- src/Utopia/Messaging/Adapters/SMS.php | 2 +- tests/e2e/Email/EmailTest.php | 2 +- tests/e2e/SMS/SMSTest.php | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 51d51fe9..19fd499b 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", "format": "vendor/bin/phpcbf", - "check": "./vendor/bin/phpstan analyse --level max src tests" + "check": "./vendor/bin/phpstan analyse --level 4 src tests" }, "authors": [ { @@ -36,7 +36,6 @@ "phpunit/phpunit": "9.5.*", "phpmailer/phpmailer": "6.6.*", "squizlabs/php_codesniffer": "^3.6", - "vimeo/psalm": "4.0.1", "phpstan/phpstan": "1.9.x-dev" }, "config": { diff --git a/src/Utopia/Messaging/Adapters/Email.php b/src/Utopia/Messaging/Adapters/Email.php index 4cfff3fc..db8b1c70 100644 --- a/src/Utopia/Messaging/Adapters/Email.php +++ b/src/Utopia/Messaging/Adapters/Email.php @@ -27,7 +27,7 @@ public function send(Message $message): string if (!\is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } return $this->process($message); diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index c13a43fa..c4e84224 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -22,6 +22,7 @@ public function getMaxMessagesPerRequest(): int /** * @inheritdoc + * @return string * @throws Exception * @throws \Exception */ @@ -35,7 +36,7 @@ protected function process(Email $message): string $mail->SMTPAuth = false; $mail->Username = ''; $mail->Password = ''; - $mail->SMTPSecure = false; + $mail->SMTPSecure = 'false'; $mail->SMTPAutoTLS = false; $mail->CharSet = 'UTF-8'; $mail->Subject = $message->getSubject(); @@ -53,6 +54,6 @@ protected function process(Email $message): string throw new \Exception($mail->ErrorInfo); } - return true; + return 'true'; } } diff --git a/src/Utopia/Messaging/Adapters/Push.php b/src/Utopia/Messaging/Adapters/Push.php index 419fc987..b63548fa 100644 --- a/src/Utopia/Messaging/Adapters/Push.php +++ b/src/Utopia/Messaging/Adapters/Push.php @@ -5,6 +5,7 @@ use Utopia\Messaging\Adapter; use Utopia\Messaging\Message; use Utopia\Messaging\Messages\Push as PushMessage; +use PHPStan\Type\VerbosityLevel; abstract class Push extends Adapter { @@ -27,7 +28,7 @@ public function send(Message $message): string if (!\is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } return $this->process($message); diff --git a/src/Utopia/Messaging/Adapters/SMS.php b/src/Utopia/Messaging/Adapters/SMS.php index 7b28dff8..8bd62355 100644 --- a/src/Utopia/Messaging/Adapters/SMS.php +++ b/src/Utopia/Messaging/Adapters/SMS.php @@ -27,7 +27,7 @@ public function send(Message $message): string if (!\is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } return $this->process($message); diff --git a/tests/e2e/Email/EmailTest.php b/tests/e2e/Email/EmailTest.php index 40606255..b798c2d3 100644 --- a/tests/e2e/Email/EmailTest.php +++ b/tests/e2e/Email/EmailTest.php @@ -10,7 +10,7 @@ class EmailTest extends Base /** * @throws \Exception */ - public function testSendEmail() + public function testSendEmail(): void { $sender = new Mock(); diff --git a/tests/e2e/SMS/SMSTest.php b/tests/e2e/SMS/SMSTest.php index b7cdb8be..4c7959d7 100644 --- a/tests/e2e/SMS/SMSTest.php +++ b/tests/e2e/SMS/SMSTest.php @@ -10,7 +10,7 @@ class SMSTest extends Base /** * @throws \Exception */ - public function testSendSMS() + public function testSendSMS(): void { $sender = new Mock('username', 'password'); From b8e9e0b715e8f0383ccf66b335bb437c2293dc9a Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Wed, 26 Oct 2022 13:57:40 +0530 Subject: [PATCH 03/24] level 5 checks fixed --- composer.json | 2 +- src/Utopia/Messaging/Adapter.php | 1 - src/Utopia/Messaging/Adapters/Email.php | 2 +- src/Utopia/Messaging/Adapters/Push.php | 1 + src/Utopia/Messaging/Adapters/SMS.php | 1 + 5 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 19fd499b..b1c4c7d2 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", "format": "vendor/bin/phpcbf", - "check": "./vendor/bin/phpstan analyse --level 4 src tests" + "check": "./vendor/bin/phpstan analyse --level 5 src tests" }, "authors": [ { diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 83422709..22def32b 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -46,7 +46,6 @@ abstract public function send(Message $message): string; * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $headers An array of headers to send with the request. - * @param string|null $body The body of the request. * @return string The response body. * @throws \Exception If the request fails. */ diff --git a/src/Utopia/Messaging/Adapters/Email.php b/src/Utopia/Messaging/Adapters/Email.php index db8b1c70..cadb35ed 100644 --- a/src/Utopia/Messaging/Adapters/Email.php +++ b/src/Utopia/Messaging/Adapters/Email.php @@ -20,6 +20,7 @@ public function getMessageType(): string /** * @inheritdoc + * @param EmailMessage $message Message to send. * @throws \Exception */ public function send(Message $message): string @@ -35,7 +36,6 @@ public function send(Message $message): string /** * Process an email message. - * * @param EmailMessage $message Message to process. * @return string The response body. */ diff --git a/src/Utopia/Messaging/Adapters/Push.php b/src/Utopia/Messaging/Adapters/Push.php index b63548fa..f1f043c7 100644 --- a/src/Utopia/Messaging/Adapters/Push.php +++ b/src/Utopia/Messaging/Adapters/Push.php @@ -21,6 +21,7 @@ public function getMessageType(): string /** * @inheritdoc + * @param PushMessage $message Message to send. * @throws \Exception */ public function send(Message $message): string diff --git a/src/Utopia/Messaging/Adapters/SMS.php b/src/Utopia/Messaging/Adapters/SMS.php index 8bd62355..3f2dc4f5 100644 --- a/src/Utopia/Messaging/Adapters/SMS.php +++ b/src/Utopia/Messaging/Adapters/SMS.php @@ -20,6 +20,7 @@ public function getMessageType(): string /** * @inheritdoc + * @param SMSMessage $message Message to send. * @throws \Exception */ public function send(Message $message): string From 390e1409ddeacfbb15ade8fa0d8314034162a7ea Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Wed, 26 Oct 2022 16:00:36 +0530 Subject: [PATCH 04/24] level 6 checks fixed --- composer.json | 2 +- src/Utopia/Messaging/Adapter.php | 2 +- src/Utopia/Messaging/Messages/Email.php | 8 ++++---- src/Utopia/Messaging/Messages/Push.php | 8 ++++---- src/Utopia/Messaging/Messages/SMS.php | 8 ++++++-- tests/e2e/Base.php | 12 +++++++++--- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index b1c4c7d2..273bf6ce 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", "format": "vendor/bin/phpcbf", - "check": "./vendor/bin/phpstan analyse --level 5 src tests" + "check": "./vendor/bin/phpstan analyse --level 6 src tests" }, "authors": [ { diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 22def32b..9f370ac6 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -45,7 +45,7 @@ abstract public function send(Message $message): string; * * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. - * @param array $headers An array of headers to send with the request. + * @param array $headers An array of headers to send with the request. * @return string The response body. * @throws \Exception If the request fails. */ diff --git a/src/Utopia/Messaging/Messages/Email.php b/src/Utopia/Messaging/Messages/Email.php index e13ab30a..a318cb42 100644 --- a/src/Utopia/Messaging/Messages/Email.php +++ b/src/Utopia/Messaging/Messages/Email.php @@ -7,11 +7,11 @@ class Email implements Message { /** - * @param array $to The recipients of the email. + * @param array $to The recipients of the email. * @param string $subject The subject of the email. * @param string $content The content of the email. * @param string|null $from The sender of the email. - * @param array|null $attachments The attachments of the email. + * @param array|null $attachments The attachments of the email. * @param bool $html Whether the message is HTML or not. */ public function __construct( @@ -25,7 +25,7 @@ public function __construct( } /** - * @return array + * @return array */ public function getTo(): array { @@ -57,7 +57,7 @@ public function getFrom(): ?string } /** - * @return array|null + * @return array|null */ public function getAttachments(): ?array { diff --git a/src/Utopia/Messaging/Messages/Push.php b/src/Utopia/Messaging/Messages/Push.php index 4a86a05e..5739509d 100644 --- a/src/Utopia/Messaging/Messages/Push.php +++ b/src/Utopia/Messaging/Messages/Push.php @@ -7,10 +7,10 @@ class Push implements Message { /** - * @param array $to The recipients of the push notification. + * @param array $to The recipients of the push notification. * @param string $title The title of the push notification. * @param string $body The body of the push notification. - * @param array|null $data This parameter specifies the custom key-value pairs of the message's payload. For example, with data:{"score":"3x1"}:

On Apple platforms, if the message is sent via APNs, it represents the custom data fields. If it is sent via FCM, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

On Android, this would result in an intent extra named score with the string value 3x1.

The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string. + * @param array|null $data This parameter specifies the custom key-value pairs of the message's payload. For example, with data:{"score":"3x1"}:

On Apple platforms, if the message is sent via APNs, it represents the custom data fields. If it is sent via FCM, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

On Android, this would result in an intent extra named score with the string value 3x1.

The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string. * @param string|null $sound The sound to play when the device receives the notification.

On Android, sound files must reside in /res/raw/.

On iOS, sounds files must reside in the main bundle of the client app or in the Library/Sounds folder of the app's data container. * @param string|null $action The action associated with a user click on the notification.

On Android, this is the activity to launch.

On iOS, this is the category to launch. * @param string|null $icon Android only. The icon of the push notification. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest. @@ -33,7 +33,7 @@ public function __construct( } /** - * @return array + * @return array */ public function getTo(): array { @@ -57,7 +57,7 @@ public function getBody(): string } /** - * @return array|null + * @return array|null */ public function getData(): ?array { diff --git a/src/Utopia/Messaging/Messages/SMS.php b/src/Utopia/Messaging/Messages/SMS.php index bcb913c0..b17231d4 100644 --- a/src/Utopia/Messaging/Messages/SMS.php +++ b/src/Utopia/Messaging/Messages/SMS.php @@ -6,6 +6,10 @@ class SMS implements Message { + /** + * @param array $to The recipients of the push notification. + * @param array $attachments The recipients of the push notification. + */ public function __construct( private array $to, private string $content, @@ -15,7 +19,7 @@ public function __construct( } /** - * @return array + * @return array */ public function getTo(): array { @@ -39,7 +43,7 @@ public function getFrom(): ?string } /** - * @return array|null + * @return array|null */ public function getAttachments(): ?array { diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index 14970e51..51663fd5 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -6,7 +6,10 @@ class Base extends TestCase { - protected function getLastRequest(): array + /** + * @return mixed + */ + protected function getLastRequest(): mixed { \sleep(2); @@ -15,8 +18,11 @@ protected function getLastRequest(): array return $request; } - - protected function getLastEmail(): array + + /** + * @return mixed + */ + protected function getLastEmail(): mixed { sleep(3); From 4d91ca25e2b6ef0071c2cb4719941a696ed79d64 Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Wed, 26 Oct 2022 16:41:47 +0530 Subject: [PATCH 05/24] level 7 checks fixed --- composer.json | 2 +- src/Utopia/Messaging/Adapter.php | 3 ++- tests/e2e/Base.php | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 273bf6ce..7b9ce82c 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", "format": "vendor/bin/phpcbf", - "check": "./vendor/bin/phpstan analyse --level 6 src tests" + "check": "./vendor/bin/phpstan analyse --level 7 src tests" }, "authors": [ { diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 9f370ac6..6c9f75d7 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -75,11 +75,12 @@ protected function request( throw new \Exception('Error:' . \curl_error($ch)); } if (\curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) { + // @phpstan-ignore-next-line throw new \Exception($response); } \curl_close($ch); - + // @phpstan-ignore-next-line return $response; } } diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index 51663fd5..e15abea5 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -8,11 +8,12 @@ class Base extends TestCase { /** * @return mixed + * @throws \Exception If the request fails. */ protected function getLastRequest(): mixed { \sleep(2); - + // @phpstan-ignore-next-line $request = \json_decode(\file_get_contents('http://request-catcher:5000/__last_request__'), true); $request['data'] = \json_decode($request['data'], true); @@ -25,7 +26,7 @@ protected function getLastRequest(): mixed protected function getLastEmail(): mixed { sleep(3); - + // @phpstan-ignore-next-line $emails = \json_decode(\file_get_contents('http://maildev:1080/email'), true); if ($emails && \is_array($emails)) { From 09e361ef6c248a204bc7355e84c4cf9fb6d7886f Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Wed, 26 Oct 2022 16:47:28 +0530 Subject: [PATCH 06/24] level 8 checks fixed --- composer.json | 2 +- src/Utopia/Messaging/Adapters/Email/Mock.php | 2 ++ src/Utopia/Messaging/Adapters/SMS/TextMagic.php | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7b9ce82c..d54d4915 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "test": "vendor/bin/phpunit", "lint": "vendor/bin/phpcs", "format": "vendor/bin/phpcbf", - "check": "./vendor/bin/phpstan analyse --level 7 src tests" + "check": "./vendor/bin/phpstan analyse --level 8 src tests" }, "authors": [ { diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index c4e84224..6ba9475c 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -42,7 +42,9 @@ protected function process(Email $message): string $mail->Subject = $message->getSubject(); $mail->Body = $message->getContent(); $mail->AltBody = \strip_tags($message->getContent()); + // @phpstan-ignore-next-line $mail->setFrom($message->getFrom(), 'Utopia'); + // @phpstan-ignore-next-line $mail->addReplyTo($message->getFrom(), 'Utopia'); $mail->isHTML($message->isHtml()); diff --git a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php index a78a97dc..0f372e27 100644 --- a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php @@ -50,6 +50,7 @@ protected function process(SMS $message): string ], body: [ 'text' => $message->getContent(), + // @phpstan-ignore-next-line 'from' => \ltrim($message->getFrom(), '+'), 'phones' => \implode(',', $to), ], From 085fede20f2b88f7f5c7e5a400288c4b47e21566 Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Sun, 30 Oct 2022 18:42:44 +0530 Subject: [PATCH 07/24] level 7 ignored checks FIX --- src/Utopia/Messaging/Adapter.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 6c9f75d7..ba410dc1 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -46,7 +46,7 @@ abstract public function send(Message $message): string; * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $headers An array of headers to send with the request. - * @return string The response body. + * @return string,bool The response body. * @throws \Exception If the request fails. */ protected function request( @@ -75,12 +75,10 @@ protected function request( throw new \Exception('Error:' . \curl_error($ch)); } if (\curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) { - // @phpstan-ignore-next-line - throw new \Exception($response); + throw new \Exception($this->$response); } \curl_close($ch); - // @phpstan-ignore-next-line - return $response; + return $this->$response; } } From b6278e977617c3c4d63898271c7075feec9ba82d Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Sun, 30 Oct 2022 18:58:13 +0530 Subject: [PATCH 08/24] level 8 ignored checks FIX --- src/Utopia/Messaging/Adapters/Email/Mock.php | 6 ++---- src/Utopia/Messaging/Adapters/SMS/TextMagic.php | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index 6ba9475c..fa1d8f7e 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -42,10 +42,8 @@ protected function process(Email $message): string $mail->Subject = $message->getSubject(); $mail->Body = $message->getContent(); $mail->AltBody = \strip_tags($message->getContent()); - // @phpstan-ignore-next-line - $mail->setFrom($message->getFrom(), 'Utopia'); - // @phpstan-ignore-next-line - $mail->addReplyTo($message->getFrom(), 'Utopia'); + $mail->setFrom($this->$message->getFrom(), 'Utopia'); + $mail->addReplyTo($this->$message->getFrom(), 'Utopia'); $mail->isHTML($message->isHtml()); foreach ($message->getTo() as $to) { diff --git a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php index 0f372e27..8078ee7d 100644 --- a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php @@ -50,8 +50,7 @@ protected function process(SMS $message): string ], body: [ 'text' => $message->getContent(), - // @phpstan-ignore-next-line - 'from' => \ltrim($message->getFrom(), '+'), + 'from' => \ltrim($this->$message->getFrom(), '+'), 'phones' => \implode(',', $to), ], ); From 507f86e36a547aa29546fb6219a7dedc6f7109b4 Mon Sep 17 00:00:00 2001 From: Ambareen09 Date: Thu, 26 Jan 2023 14:27:37 +0530 Subject: [PATCH 09/24] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 09c1c330..828be6c6 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "phpunit/phpunit": "9.5.*", "phpmailer/phpmailer": "6.6.*", "squizlabs/php_codesniffer": "^3.6", - "phpstan/phpstan": "1.9.x-dev" + "phpstan/phpstan": "^1.9" }, "config": { "platform": { From 29ef96d706a5238965415d96b8e687b3cca6bc47 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 27 Jan 2023 22:22:57 +0000 Subject: [PATCH 10/24] chore: linter fixes --- composer.json | 8 +- composer.lock | 275 ++++++++++++------- src/Utopia/Messaging/Adapter.php | 8 +- src/Utopia/Messaging/Adapters/Email.php | 9 +- src/Utopia/Messaging/Adapters/Email/Mock.php | 4 +- src/Utopia/Messaging/Adapters/Push.php | 7 +- src/Utopia/Messaging/Adapters/SMS.php | 6 +- src/Utopia/Messaging/Messages/Email.php | 12 +- src/Utopia/Messaging/Messages/Push.php | 20 +- src/Utopia/Messaging/Messages/SMS.php | 4 +- tests/e2e/Base.php | 3 +- tests/e2e/Email/EmailTest.php | 2 +- tests/e2e/SMS/SMSTest.php | 2 +- 13 files changed, 220 insertions(+), 140 deletions(-) diff --git a/composer.json b/composer.json index 828be6c6..4d3b8475 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ "license": "MIT", "minimum-stability": "stable", "scripts": { - "test": "vendor/bin/phpunit", - "lint": "vendor/bin/phpcs", - "format": "vendor/bin/phpcbf", + "test": "./vendor/bin/phpunit", + "lint": "./vendor/bin/pint --test", + "format": "./vendor/bin/pint", "check": "./vendor/bin/phpstan analyse --level 8 src tests" }, "autoload": { @@ -29,7 +29,7 @@ "require-dev": { "phpunit/phpunit": "9.5.*", "phpmailer/phpmailer": "6.6.*", - "squizlabs/php_codesniffer": "^3.6", + "laravel/pint": "^1.2", "phpstan/phpstan": "^1.9" }, "config": { diff --git a/composer.lock b/composer.lock index dbb18a54..f78e3a11 100644 --- a/composer.lock +++ b/composer.lock @@ -4,35 +4,35 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "687eb9ecd82ac2dca4a911f78d8dc516", + "content-hash": "05988be0318fcccd8354a439b6103139", "packages": [], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.4.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/10dcfce151b967d20fde1b34ae6640712c3891bc", - "reference": "10dcfce151b967d20fde1b34ae6640712c3891bc", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.22" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -57,6 +57,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -71,20 +75,20 @@ "type": "tidelift" } ], - "time": "2022-03-03T08:28:38+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "laravel/pint", - "version": "v1.2.0", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "1d276e4c803397a26cc337df908f55c2a4e90d86" + "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/1d276e4c803397a26cc337df908f55c2a4e90d86", - "reference": "1d276e4c803397a26cc337df908f55c2a4e90d86", + "url": "https://api.github.com/repos/laravel/pint/zipball/0e7ffdb0af871be10d798e234772ea5d4020ae4a", + "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a", "shasum": "" }, "require": { @@ -95,11 +99,11 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.11.0", - "illuminate/view": "^9.27", - "laravel-zero/framework": "^9.1.3", - "mockery/mockery": "^1.5.0", - "nunomaduro/larastan": "^2.2", + "friendsofphp/php-cs-fixer": "~3.13.1", + "illuminate/view": "^9.32.0", + "laravel-zero/framework": "^9.2.0", + "mockery/mockery": "^1.5.1", + "nunomaduro/larastan": "^2.2.0", "nunomaduro/termwind": "^1.14.0", "pestphp/pest": "^1.22.1" }, @@ -137,7 +141,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2022-09-13T15:07:15+00:00" + "time": "2023-01-10T20:03:42+00:00" }, { "name": "myclabs/deep-copy", @@ -186,6 +190,10 @@ "object", "object graph" ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.0" + }, "funding": [ { "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", @@ -196,16 +204,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.1", + "version": "v4.15.3", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" + "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", - "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/570e980a201d8ed0236b0a62ddf2c9cbb2034039", + "reference": "570e980a201d8ed0236b0a62ddf2c9cbb2034039", "shasum": "" }, "require": { @@ -244,7 +252,11 @@ "parser", "php" ], - "time": "2022-09-04T07:30:47+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.3" + }, + "time": "2023-01-16T22:05:37+00:00" }, { "name": "phar-io/manifest", @@ -300,6 +312,10 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, "time": "2021-07-20T11:28:43+00:00" }, { @@ -347,20 +363,24 @@ } ], "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, "time": "2022-02-21T01:04:05+00:00" }, { "name": "phpmailer/phpmailer", - "version": "v6.6.4", + "version": "v6.6.5", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b" + "reference": "8b6386d7417526d1ea4da9edb70b8352f7543627" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a94fdebaea6bd17f51be0c2373ab80d3d681269b", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/8b6386d7417526d1ea4da9edb70b8352f7543627", + "reference": "8b6386d7417526d1ea4da9edb70b8352f7543627", "shasum": "" }, "require": { @@ -384,8 +404,8 @@ "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", "league/oauth2-google": "Needed for Google XOAUTH2 authentication", "psr/log": "For optional PSR-3 debug logging", - "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", - "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", + "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, "type": "library", "autoload": { @@ -415,26 +435,30 @@ } ], "description": "PHPMailer is a full-featured email creation and transfer class for PHP", + "support": { + "issues": "https://github.com/PHPMailer/PHPMailer/issues", + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.5" + }, "funding": [ { "url": "https://github.com/Synchro", "type": "github" } ], - "time": "2022-08-22T09:22:00+00:00" + "time": "2022-10-07T12:23:10+00:00" }, { "name": "phpstan/phpstan", - "version": "1.8.9", + "version": "1.9.14", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2" + "reference": "e5fcc96289cf737304286a9b505fbed091f02e58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2", - "reference": "3a72d9d9f2528fbd50c2d8fcf155fd9f74ade3f2", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58", + "reference": "e5fcc96289cf737304286a9b505fbed091f02e58", "shasum": "" }, "require": { @@ -462,6 +486,10 @@ "dev", "static analysis" ], + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.9.14" + }, "funding": [ { "url": "https://github.com/ondrejmirtes", @@ -476,20 +504,20 @@ "type": "tidelift" } ], - "time": "2022-10-13T13:40:18+00:00" + "time": "2023-01-19T10:47:09+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.17", + "version": "9.2.24", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8" + "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8", - "reference": "aa94dc41e8661fe90c7316849907cba3007b10d8", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2cf940ebc6355a9d430462811b5aaa308b174bed", + "reference": "2cf940ebc6355a9d430462811b5aaa308b174bed", "shasum": "" }, "require": { @@ -543,13 +571,17 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.24" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2022-08-30T12:24:04+00:00" + "time": "2023-01-26T08:26:55+00:00" }, { "name": "phpunit/php-file-iterator", @@ -599,6 +631,10 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -658,6 +694,10 @@ "keywords": [ "process" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -713,6 +753,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -768,6 +812,10 @@ "keywords": [ "timer" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -778,20 +826,20 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.25", + "version": "9.5.28", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d" + "reference": "954ca3113a03bf780d22f07bf055d883ee04b65e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", - "reference": "3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/954ca3113a03bf780d22f07bf055d883ee04b65e", + "reference": "954ca3113a03bf780d22f07bf055d883ee04b65e", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.3.1 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", @@ -858,6 +906,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.28" + }, "funding": [ { "url": "https://phpunit.de/sponsors.html", @@ -872,7 +924,7 @@ "type": "tidelift" } ], - "time": "2022-09-25T03:44:45+00:00" + "time": "2023-01-14T12:32:24+00:00" }, { "name": "sebastian/cli-parser", @@ -918,6 +970,10 @@ ], "description": "Library for parsing CLI options", "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -970,6 +1026,10 @@ ], "description": "Collection of value objects that represent the PHP code units", "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1021,6 +1081,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1091,6 +1155,10 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1144,6 +1212,10 @@ ], "description": "Library for calculating the complexity of PHP code units", "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1206,6 +1278,10 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1265,6 +1341,10 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1338,6 +1418,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1398,6 +1482,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1451,6 +1539,10 @@ ], "description": "Library for counting the lines of code in PHP source code", "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1504,6 +1596,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1555,6 +1651,10 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1614,6 +1714,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1665,6 +1769,10 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1717,6 +1825,10 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1766,6 +1878,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", @@ -1774,57 +1890,6 @@ ], "time": "2020-09-28T06:39:44+00:00" }, - { - "name": "squizlabs/php_codesniffer", - "version": "3.7.1", - "source": { - "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", - "shasum": "" - }, - "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" - }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Greg Sherwood", - "role": "lead" - } - ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", - "keywords": [ - "phpcs", - "standards" - ], - "time": "2022-06-18T07:21:10+00:00" - }, { "name": "theseer/tokenizer", "version": "1.2.1", @@ -1863,6 +1928,10 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, "funding": [ { "url": "https://github.com/theseer", @@ -1885,5 +1954,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.3.0" } diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index b1022b45..ac02c08f 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -43,10 +43,11 @@ abstract public function send(Message $message): string; /** * Send an HTTP request. * - * @param string $method The HTTP method to use. - * @param string $url The URL to send the request to. - * @param array $headers An array of headers to send with the request. + * @param string $method The HTTP method to use. + * @param string $url The URL to send the request to. + * @param array $headers An array of headers to send with the request. * @return string,bool The response body. + * * @throws \Exception If the request fails. */ protected function request( @@ -79,6 +80,7 @@ protected function request( } \curl_close($ch); + return $this->$response; } } diff --git a/src/Utopia/Messaging/Adapters/Email.php b/src/Utopia/Messaging/Adapters/Email.php index 32a56a60..e4dab9e4 100644 --- a/src/Utopia/Messaging/Adapters/Email.php +++ b/src/Utopia/Messaging/Adapters/Email.php @@ -19,8 +19,10 @@ public function getMessageType(): string } /** - * @inheritdoc - * @param EmailMessage $message Message to send. + * {@inheritdoc} + * + * @param EmailMessage $message Message to send. + * * @throws \Exception */ public function send(Message $message): string @@ -37,7 +39,8 @@ public function send(Message $message): string /** * Process an email message. - * @param EmailMessage $message Message to process. + * + * @param EmailMessage $message Message to process. * @return string The response body. */ abstract protected function process(EmailMessage $message): string; diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index d01aaa1d..0ae4f11f 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -21,8 +21,10 @@ public function getMaxMessagesPerRequest(): int } /** - * @inheritdoc + * {@inheritdoc} + * * @return string + * * @throws Exception * @throws \Exception */ diff --git a/src/Utopia/Messaging/Adapters/Push.php b/src/Utopia/Messaging/Adapters/Push.php index f1297542..a0bd4ae2 100644 --- a/src/Utopia/Messaging/Adapters/Push.php +++ b/src/Utopia/Messaging/Adapters/Push.php @@ -5,7 +5,6 @@ use Utopia\Messaging\Adapter; use Utopia\Messaging\Message; use Utopia\Messaging\Messages\Push as PushMessage; -use PHPStan\Type\VerbosityLevel; abstract class Push extends Adapter { @@ -20,8 +19,10 @@ public function getMessageType(): string } /** - * @inheritdoc - * @param PushMessage $message Message to send. + * {@inheritdoc} + * + * @param PushMessage $message Message to send. + * * @throws \Exception */ public function send(Message $message): string diff --git a/src/Utopia/Messaging/Adapters/SMS.php b/src/Utopia/Messaging/Adapters/SMS.php index d66966c6..6764b779 100644 --- a/src/Utopia/Messaging/Adapters/SMS.php +++ b/src/Utopia/Messaging/Adapters/SMS.php @@ -19,8 +19,10 @@ public function getMessageType(): string } /** - * @inheritdoc - * @param SMSMessage $message Message to send. + * {@inheritdoc} + * + * @param SMSMessage $message Message to send. + * * @throws \Exception */ public function send(Message $message): string diff --git a/src/Utopia/Messaging/Messages/Email.php b/src/Utopia/Messaging/Messages/Email.php index a318cb42..0cb1d166 100644 --- a/src/Utopia/Messaging/Messages/Email.php +++ b/src/Utopia/Messaging/Messages/Email.php @@ -7,12 +7,12 @@ class Email implements Message { /** - * @param array $to The recipients of the email. - * @param string $subject The subject of the email. - * @param string $content The content of the email. - * @param string|null $from The sender of the email. - * @param array|null $attachments The attachments of the email. - * @param bool $html Whether the message is HTML or not. + * @param array $to The recipients of the email. + * @param string $subject The subject of the email. + * @param string $content The content of the email. + * @param string|null $from The sender of the email. + * @param array|null $attachments The attachments of the email. + * @param bool $html Whether the message is HTML or not. */ public function __construct( private array $to, diff --git a/src/Utopia/Messaging/Messages/Push.php b/src/Utopia/Messaging/Messages/Push.php index 5739509d..c227d968 100644 --- a/src/Utopia/Messaging/Messages/Push.php +++ b/src/Utopia/Messaging/Messages/Push.php @@ -7,16 +7,16 @@ class Push implements Message { /** - * @param array $to The recipients of the push notification. - * @param string $title The title of the push notification. - * @param string $body The body of the push notification. - * @param array|null $data This parameter specifies the custom key-value pairs of the message's payload. For example, with data:{"score":"3x1"}:

On Apple platforms, if the message is sent via APNs, it represents the custom data fields. If it is sent via FCM, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

On Android, this would result in an intent extra named score with the string value 3x1.

The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string. - * @param string|null $sound The sound to play when the device receives the notification.

On Android, sound files must reside in /res/raw/.

On iOS, sounds files must reside in the main bundle of the client app or in the Library/Sounds folder of the app's data container. - * @param string|null $action The action associated with a user click on the notification.

On Android, this is the activity to launch.

On iOS, this is the category to launch. - * @param string|null $icon Android only. The icon of the push notification. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest. - * @param string|null $color Android only. The icon color of the push notification, expressed in #rrggbb format. - * @param string|null $tag Android only. Identifier used to replace existing notifications in the notification drawer.

If not specified, each request creates a new notification.

If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer. - * @param string|null $badge iOS only. The value of the badge on the home screen app icon. If not specified, the badge is not changed. If set to 0, the badge is removed. + * @param array $to The recipients of the push notification. + * @param string $title The title of the push notification. + * @param string $body The body of the push notification. + * @param array|null $data This parameter specifies the custom key-value pairs of the message's payload. For example, with data:{"score":"3x1"}:

On Apple platforms, if the message is sent via APNs, it represents the custom data fields. If it is sent via FCM, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

On Android, this would result in an intent extra named score with the string value 3x1.

The key should not be a reserved word ("from", "message_type", or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string. + * @param string|null $sound The sound to play when the device receives the notification.

On Android, sound files must reside in /res/raw/.

On iOS, sounds files must reside in the main bundle of the client app or in the Library/Sounds folder of the app's data container. + * @param string|null $action The action associated with a user click on the notification.

On Android, this is the activity to launch.

On iOS, this is the category to launch. + * @param string|null $icon Android only. The icon of the push notification. Sets the notification icon to myicon for drawable resource myicon. If you don't send this key in the request, FCM displays the launcher icon specified in your app manifest. + * @param string|null $color Android only. The icon color of the push notification, expressed in #rrggbb format. + * @param string|null $tag Android only. Identifier used to replace existing notifications in the notification drawer.

If not specified, each request creates a new notification.

If specified and a notification with the same tag is already being shown, the new notification replaces the existing one in the notification drawer. + * @param string|null $badge iOS only. The value of the badge on the home screen app icon. If not specified, the badge is not changed. If set to 0, the badge is removed. */ public function __construct( private array $to, diff --git a/src/Utopia/Messaging/Messages/SMS.php b/src/Utopia/Messaging/Messages/SMS.php index b17231d4..9d1f91fb 100644 --- a/src/Utopia/Messaging/Messages/SMS.php +++ b/src/Utopia/Messaging/Messages/SMS.php @@ -7,8 +7,8 @@ class SMS implements Message { /** - * @param array $to The recipients of the push notification. - * @param array $attachments The recipients of the push notification. + * @param array $to The recipients of the push notification. + * @param array $attachments The recipients of the push notification. */ public function __construct( private array $to, diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index e15abea5..ad676a14 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -8,6 +8,7 @@ class Base extends TestCase { /** * @return mixed + * * @throws \Exception If the request fails. */ protected function getLastRequest(): mixed @@ -19,7 +20,7 @@ protected function getLastRequest(): mixed return $request; } - + /** * @return mixed */ diff --git a/tests/e2e/Email/EmailTest.php b/tests/e2e/Email/EmailTest.php index b798c2d3..7db84dd5 100644 --- a/tests/e2e/Email/EmailTest.php +++ b/tests/e2e/Email/EmailTest.php @@ -1,6 +1,6 @@ Date: Fri, 27 Jan 2023 22:26:20 +0000 Subject: [PATCH 11/24] feat: phpstan fixes --- tests/e2e/Email/EmailTest.php | 2 ++ tests/e2e/SMS/SMSTest.php | 1 + 2 files changed, 3 insertions(+) diff --git a/tests/e2e/Email/EmailTest.php b/tests/e2e/Email/EmailTest.php index 7db84dd5..9288e3ac 100644 --- a/tests/e2e/Email/EmailTest.php +++ b/tests/e2e/Email/EmailTest.php @@ -2,9 +2,11 @@ namespace Tests\E2E\Email; +use Tests\E2E\Base; use Utopia\Messaging\Adapters\Email\Mock; use Utopia\Messaging\Messages\Email; + class EmailTest extends Base { /** diff --git a/tests/e2e/SMS/SMSTest.php b/tests/e2e/SMS/SMSTest.php index 432b430d..5bff0b26 100644 --- a/tests/e2e/SMS/SMSTest.php +++ b/tests/e2e/SMS/SMSTest.php @@ -2,6 +2,7 @@ namespace Tests\E2E\SMS; +use Tests\E2E\Base; use Utopia\Messaging\Adapters\SMS\Mock; use Utopia\Messaging\Messages\SMS; From 0676dd6b01b5d6f2ab50d3966ea7cbc281b4bb25 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 27 Jan 2023 22:27:58 +0000 Subject: [PATCH 12/24] chore: linter fixes --- tests/e2e/Email/EmailTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/Email/EmailTest.php b/tests/e2e/Email/EmailTest.php index 9288e3ac..186afa64 100644 --- a/tests/e2e/Email/EmailTest.php +++ b/tests/e2e/Email/EmailTest.php @@ -6,7 +6,6 @@ use Utopia\Messaging\Adapters\Email\Mock; use Utopia\Messaging\Messages\Email; - class EmailTest extends Base { /** From f389c9f7a5e343e21d764aa697d84194ec27b994 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 03:59:01 +0530 Subject: [PATCH 13/24] Update src/Utopia/Messaging/Adapter.php --- src/Utopia/Messaging/Adapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index ac02c08f..52ce0783 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -76,7 +76,7 @@ protected function request( throw new \Exception('Error:'.\curl_error($ch)); } if (\curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) { - throw new \Exception($this->$response); + throw new \Exception($response); } \curl_close($ch); From a9d83b0b8243c830a6491ece5b17e7a9e2179ae8 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 03:59:07 +0530 Subject: [PATCH 14/24] Update src/Utopia/Messaging/Adapter.php --- src/Utopia/Messaging/Adapter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 52ce0783..0dcbe362 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -81,6 +81,6 @@ protected function request( \curl_close($ch); - return $this->$response; + return $response; } } From 305785d835eeb4e4af9cf767f7c1504c67f38223 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 03:59:51 +0530 Subject: [PATCH 15/24] Apply suggestions from code review --- src/Utopia/Messaging/Adapters/Email.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utopia/Messaging/Adapters/Email.php b/src/Utopia/Messaging/Adapters/Email.php index e4dab9e4..0a8bc2ee 100644 --- a/src/Utopia/Messaging/Adapters/Email.php +++ b/src/Utopia/Messaging/Adapters/Email.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param EmailMessage $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ @@ -30,7 +30,7 @@ public function send(Message $message): string if (! \is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } From a85971c40b0bbece524fb786579ae8d26a3059c2 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 04:00:51 +0530 Subject: [PATCH 16/24] Apply suggestions from code review --- src/Utopia/Messaging/Adapters/Email/Mock.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index 0ae4f11f..1ce64b24 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -38,14 +38,14 @@ protected function process(Email $message): string $mail->SMTPAuth = false; $mail->Username = ''; $mail->Password = ''; - $mail->SMTPSecure = 'false'; + $mail->SMTPSecure = false; $mail->SMTPAutoTLS = false; $mail->CharSet = 'UTF-8'; $mail->Subject = $message->getSubject(); $mail->Body = $message->getContent(); $mail->AltBody = \strip_tags($message->getContent()); - $mail->setFrom($this->$message->getFrom(), 'Utopia'); - $mail->addReplyTo($this->$message->getFrom(), 'Utopia'); + $mail->setFrom($this->getFrom(), 'Utopia'); + $mail->addReplyTo($this->getFrom(), 'Utopia'); $mail->isHTML($message->isHtml()); foreach ($message->getTo() as $to) { @@ -56,6 +56,6 @@ protected function process(Email $message): string throw new \Exception($mail->ErrorInfo); } - return 'true'; + return true; } } From 8a2cbda671297b6f4ce017f408557e0aa0a1289b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 04:02:01 +0530 Subject: [PATCH 17/24] Apply suggestions from code review --- src/Utopia/Messaging/Adapters/Email/Mock.php | 4 ++-- src/Utopia/Messaging/Adapters/Push.php | 4 ++-- src/Utopia/Messaging/Adapters/SMS.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index 1ce64b24..35a92522 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -44,8 +44,8 @@ protected function process(Email $message): string $mail->Subject = $message->getSubject(); $mail->Body = $message->getContent(); $mail->AltBody = \strip_tags($message->getContent()); - $mail->setFrom($this->getFrom(), 'Utopia'); - $mail->addReplyTo($this->getFrom(), 'Utopia'); + $mail->setFrom($message->getFrom(), 'Utopia'); + $mail->addReplyTo($message->getFrom(), 'Utopia'); $mail->isHTML($message->isHtml()); foreach ($message->getTo() as $to) { diff --git a/src/Utopia/Messaging/Adapters/Push.php b/src/Utopia/Messaging/Adapters/Push.php index a0bd4ae2..3e561c52 100644 --- a/src/Utopia/Messaging/Adapters/Push.php +++ b/src/Utopia/Messaging/Adapters/Push.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param PushMessage $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ @@ -30,7 +30,7 @@ public function send(Message $message): string if (! \is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } diff --git a/src/Utopia/Messaging/Adapters/SMS.php b/src/Utopia/Messaging/Adapters/SMS.php index 6764b779..67c75dcd 100644 --- a/src/Utopia/Messaging/Adapters/SMS.php +++ b/src/Utopia/Messaging/Adapters/SMS.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param SMSMessage $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ @@ -30,7 +30,7 @@ public function send(Message $message): string if (! \is_a($message, $this->getMessageType())) { throw new \Exception('Invalid message type.'); } - if (\count($message->$this->getTo()) > $this->getMaxMessagesPerRequest()) { + if (\count($message->getTo()) > $this->getMaxMessagesPerRequest()) { throw new \Exception("{$this->getName()} can only send {$this->getMaxMessagesPerRequest()} messages per request."); } From 6ff6b35228127c6af685cd24329e66fd6482e9f1 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 04:03:42 +0530 Subject: [PATCH 18/24] Update src/Utopia/Messaging/Adapters/SMS/TextMagic.php --- src/Utopia/Messaging/Adapters/SMS/TextMagic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php index db4c7b29..e941f3a5 100644 --- a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php @@ -51,7 +51,7 @@ protected function process(SMS $message): string ], body: [ 'text' => $message->getContent(), - 'from' => \ltrim($this->$message->getFrom(), '+'), + 'from' => \ltrim($message->getFrom(), '+'), 'phones' => \implode(',', $to), ], ); From 2f0c21cd678b234ed9a25b8ea6de197b966cd23d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 04:05:12 +0530 Subject: [PATCH 19/24] Update tests/e2e/Base.php --- tests/e2e/Base.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index ad676a14..436fb5b1 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -14,7 +14,6 @@ class Base extends TestCase protected function getLastRequest(): mixed { \sleep(2); - // @phpstan-ignore-next-line $request = \json_decode(\file_get_contents('http://request-catcher:5000/__last_request__'), true); $request['data'] = \json_decode($request['data'], true); From ad3b567dda150c60e3edfacee0dc14df42a4c013 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sat, 28 Jan 2023 04:05:18 +0530 Subject: [PATCH 20/24] Update tests/e2e/Base.php --- tests/e2e/Base.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index 436fb5b1..89ad6ba1 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -26,7 +26,6 @@ protected function getLastRequest(): mixed protected function getLastEmail(): mixed { sleep(3); - // @phpstan-ignore-next-line $emails = \json_decode(\file_get_contents('http://maildev:1080/email'), true); if ($emails && \is_array($emails)) { From 4b75940ac167706072c39ca42b0496427568b58e Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 19 Feb 2023 09:19:23 +0000 Subject: [PATCH 21/24] feat: fix code quality issues --- composer.lock | 70 +++++++++---------- src/Utopia/Messaging/Adapter.php | 5 +- .../Messaging/Adapters/SMS/TextMagic.php | 2 +- tests/e2e/Base.php | 4 +- 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/composer.lock b/composer.lock index f78e3a11..4902d1fb 100644 --- a/composer.lock +++ b/composer.lock @@ -79,16 +79,16 @@ }, { "name": "laravel/pint", - "version": "v1.4.0", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a" + "reference": "e0a8cef58b74662f27355be9cdea0e726bbac362" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/0e7ffdb0af871be10d798e234772ea5d4020ae4a", - "reference": "0e7ffdb0af871be10d798e234772ea5d4020ae4a", + "url": "https://api.github.com/repos/laravel/pint/zipball/e0a8cef58b74662f27355be9cdea0e726bbac362", + "reference": "e0a8cef58b74662f27355be9cdea0e726bbac362", "shasum": "" }, "require": { @@ -99,13 +99,13 @@ "php": "^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "~3.13.1", - "illuminate/view": "^9.32.0", + "friendsofphp/php-cs-fixer": "^3.14.4", + "illuminate/view": "^9.51.0", "laravel-zero/framework": "^9.2.0", "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.2.0", - "nunomaduro/termwind": "^1.14.0", - "pestphp/pest": "^1.22.1" + "nunomaduro/larastan": "^2.4.0", + "nunomaduro/termwind": "^1.15.1", + "pestphp/pest": "^1.22.4" }, "bin": [ "builds/pint" @@ -141,7 +141,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-01-10T20:03:42+00:00" + "time": "2023-02-14T16:31:02+00:00" }, { "name": "myclabs/deep-copy", @@ -449,16 +449,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.9.14", + "version": "1.9.18", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "e5fcc96289cf737304286a9b505fbed091f02e58" + "reference": "f2d5cf71be91172a57c649770b73c20ebcffb0bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/e5fcc96289cf737304286a9b505fbed091f02e58", - "reference": "e5fcc96289cf737304286a9b505fbed091f02e58", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/f2d5cf71be91172a57c649770b73c20ebcffb0bf", + "reference": "f2d5cf71be91172a57c649770b73c20ebcffb0bf", "shasum": "" }, "require": { @@ -488,7 +488,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.9.14" + "source": "https://github.com/phpstan/phpstan/tree/1.9.18" }, "funding": [ { @@ -504,7 +504,7 @@ "type": "tidelift" } ], - "time": "2023-01-19T10:47:09+00:00" + "time": "2023-02-17T15:01:27+00:00" }, { "name": "phpunit/php-code-coverage", @@ -1292,16 +1292,16 @@ }, { "name": "sebastian/environment", - "version": "5.1.4", + "version": "5.1.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", - "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", "shasum": "" }, "require": { @@ -1343,7 +1343,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" }, "funding": [ { @@ -1351,7 +1351,7 @@ "type": "github" } ], - "time": "2022-04-03T09:37:03+00:00" + "time": "2023-02-03T06:03:51+00:00" }, { "name": "sebastian/exporter", @@ -1665,16 +1665,16 @@ }, { "name": "sebastian/recursion-context", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", - "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", "shasum": "" }, "require": { @@ -1713,10 +1713,10 @@ } ], "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "homepage": "https://github.com/sebastianbergmann/recursion-context", "support": { "issues": "https://github.com/sebastianbergmann/recursion-context/issues", - "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" }, "funding": [ { @@ -1724,7 +1724,7 @@ "type": "github" } ], - "time": "2020-10-26T13:17:30+00:00" + "time": "2023-02-03T06:07:39+00:00" }, { "name": "sebastian/resource-operations", @@ -1783,16 +1783,16 @@ }, { "name": "sebastian/type", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", - "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", "shasum": "" }, "require": { @@ -1827,7 +1827,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" }, "funding": [ { @@ -1835,7 +1835,7 @@ "type": "github" } ], - "time": "2022-09-12T14:47:03+00:00" + "time": "2023-02-03T06:13:03+00:00" }, { "name": "sebastian/version", diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 0dcbe362..2af941c2 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -46,7 +46,7 @@ abstract public function send(Message $message): string; * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $headers An array of headers to send with the request. - * @return string,bool The response body. + * @return string The response body. * * @throws \Exception If the request fails. */ @@ -70,11 +70,12 @@ protected function request( \curl_setopt($ch, CURLOPT_POSTFIELDS, $body); } - $response = \curl_exec($ch); + $response = strval(\curl_exec($ch)); if (\curl_errno($ch)) { throw new \Exception('Error:'.\curl_error($ch)); } + if (\curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) { throw new \Exception($response); } diff --git a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php index e941f3a5..eda15aba 100644 --- a/src/Utopia/Messaging/Adapters/SMS/TextMagic.php +++ b/src/Utopia/Messaging/Adapters/SMS/TextMagic.php @@ -51,7 +51,7 @@ protected function process(SMS $message): string ], body: [ 'text' => $message->getContent(), - 'from' => \ltrim($message->getFrom(), '+'), + 'from' => \ltrim($message->getFrom() ?? '', '+'), 'phones' => \implode(',', $to), ], ); diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index 89ad6ba1..dd1fcd4f 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -14,7 +14,7 @@ class Base extends TestCase protected function getLastRequest(): mixed { \sleep(2); - $request = \json_decode(\file_get_contents('http://request-catcher:5000/__last_request__'), true); + $request = \json_decode(\file_get_contents('http://request-catcher:5000/__last_request__') ?: '', true); $request['data'] = \json_decode($request['data'], true); return $request; @@ -26,7 +26,7 @@ protected function getLastRequest(): mixed protected function getLastEmail(): mixed { sleep(3); - $emails = \json_decode(\file_get_contents('http://maildev:1080/email'), true); + $emails = \json_decode(\file_get_contents('http://maildev:1080/email') ?: '', true); if ($emails && \is_array($emails)) { return \end($emails); From b646039fc2d0d3a8d3a6ed24064b72fe31ace1bb Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 19 Feb 2023 21:50:44 +0000 Subject: [PATCH 22/24] feat: linter --- src/Utopia/Messaging/Adapter.php | 8 ------- src/Utopia/Messaging/Adapters/Email.php | 2 +- src/Utopia/Messaging/Adapters/Email/Mock.php | 1 - src/Utopia/Messaging/Adapters/Push.php | 2 +- src/Utopia/Messaging/Adapters/SMS.php | 2 +- src/Utopia/Messaging/Messages/Email.php | 12 ---------- src/Utopia/Messaging/Messages/Push.php | 24 -------------------- src/Utopia/Messaging/Messages/SMS.php | 6 ----- tests/e2e/Base.php | 5 ---- 9 files changed, 3 insertions(+), 59 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index d6c344f3..a10c7eab 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -6,29 +6,21 @@ abstract class Adapter { /** * Get the name of the adapter. - * - * @return string */ abstract public function getName(): string; /** * Get the type of the adapter. - * - * @return string */ abstract public function getType(): string; /** * Get the type of the message the adapter can send. - * - * @return string */ abstract public function getMessageType(): string; /** * Get the maximum number of messages that can be sent in a single request. - * - * @return int */ abstract public function getMaxMessagesPerRequest(): int; diff --git a/src/Utopia/Messaging/Adapters/Email.php b/src/Utopia/Messaging/Adapters/Email.php index 0a8bc2ee..04f42a25 100644 --- a/src/Utopia/Messaging/Adapters/Email.php +++ b/src/Utopia/Messaging/Adapters/Email.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param Message $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ diff --git a/src/Utopia/Messaging/Adapters/Email/Mock.php b/src/Utopia/Messaging/Adapters/Email/Mock.php index 35a92522..35f65a14 100644 --- a/src/Utopia/Messaging/Adapters/Email/Mock.php +++ b/src/Utopia/Messaging/Adapters/Email/Mock.php @@ -23,7 +23,6 @@ public function getMaxMessagesPerRequest(): int /** * {@inheritdoc} * - * @return string * * @throws Exception * @throws \Exception diff --git a/src/Utopia/Messaging/Adapters/Push.php b/src/Utopia/Messaging/Adapters/Push.php index 3e561c52..3b37513f 100644 --- a/src/Utopia/Messaging/Adapters/Push.php +++ b/src/Utopia/Messaging/Adapters/Push.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param Message $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ diff --git a/src/Utopia/Messaging/Adapters/SMS.php b/src/Utopia/Messaging/Adapters/SMS.php index 67c75dcd..6843d635 100644 --- a/src/Utopia/Messaging/Adapters/SMS.php +++ b/src/Utopia/Messaging/Adapters/SMS.php @@ -21,7 +21,7 @@ public function getMessageType(): string /** * {@inheritdoc} * - * @param Message $message Message to send. + * @param Message $message Message to send. * * @throws \Exception */ diff --git a/src/Utopia/Messaging/Messages/Email.php b/src/Utopia/Messaging/Messages/Email.php index 0cb1d166..8533eb39 100644 --- a/src/Utopia/Messaging/Messages/Email.php +++ b/src/Utopia/Messaging/Messages/Email.php @@ -32,25 +32,16 @@ public function getTo(): array return $this->to; } - /** - * @return string - */ public function getSubject(): string { return $this->subject; } - /** - * @return string - */ public function getContent(): string { return $this->content; } - /** - * @return string|null - */ public function getFrom(): ?string { return $this->from; @@ -64,9 +55,6 @@ public function getAttachments(): ?array return $this->attachments; } - /** - * @return bool - */ public function isHtml(): bool { return $this->html; diff --git a/src/Utopia/Messaging/Messages/Push.php b/src/Utopia/Messaging/Messages/Push.php index c227d968..91ebdbd7 100644 --- a/src/Utopia/Messaging/Messages/Push.php +++ b/src/Utopia/Messaging/Messages/Push.php @@ -40,17 +40,11 @@ public function getTo(): array return $this->to; } - /** - * @return string - */ public function getTitle(): string { return $this->title; } - /** - * @return string - */ public function getBody(): string { return $this->body; @@ -64,49 +58,31 @@ public function getData(): ?array return $this->data; } - /** - * @return string|null - */ public function getAction(): ?string { return $this->action; } - /** - * @return string|null - */ public function getSound(): ?string { return $this->sound; } - /** - * @return string|null - */ public function getIcon(): ?string { return $this->icon; } - /** - * @return string|null - */ public function getColor(): ?string { return $this->color; } - /** - * @return string|null - */ public function getTag(): ?string { return $this->tag; } - /** - * @return string|null - */ public function getBadge(): ?string { return $this->badge; diff --git a/src/Utopia/Messaging/Messages/SMS.php b/src/Utopia/Messaging/Messages/SMS.php index 9d1f91fb..5e2f1023 100644 --- a/src/Utopia/Messaging/Messages/SMS.php +++ b/src/Utopia/Messaging/Messages/SMS.php @@ -26,17 +26,11 @@ public function getTo(): array return $this->to; } - /** - * @return string - */ public function getContent(): string { return $this->content; } - /** - * @return string|null - */ public function getFrom(): ?string { return $this->from; diff --git a/tests/e2e/Base.php b/tests/e2e/Base.php index dd1fcd4f..fb29fb05 100644 --- a/tests/e2e/Base.php +++ b/tests/e2e/Base.php @@ -7,8 +7,6 @@ class Base extends TestCase { /** - * @return mixed - * * @throws \Exception If the request fails. */ protected function getLastRequest(): mixed @@ -20,9 +18,6 @@ protected function getLastRequest(): mixed return $request; } - /** - * @return mixed - */ protected function getLastEmail(): mixed { sleep(3); From 67d0887247326949186101720fb4069f6e5e7b8b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 19 Feb 2023 22:00:00 +0000 Subject: [PATCH 23/24] fix: code quality issues --- src/Utopia/Messaging/Adapter.php | 4 +++- src/Utopia/Messaging/Adapters/Email/Sendgrid.php | 2 +- src/Utopia/Messaging/Adapters/Push/FCM.php | 2 +- src/Utopia/Messaging/Adapters/SMS/Mock.php | 2 +- src/Utopia/Messaging/Adapters/SMS/Msg91.php | 2 +- src/Utopia/Messaging/Adapters/SMS/Telnyx.php | 2 +- src/Utopia/Messaging/Message.php | 4 ++++ 7 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index a10c7eab..7ef8bc75 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -38,6 +38,8 @@ abstract public function send(Message $message): string; * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $headers An array of headers to send with the request. + * @param ?string $body The body of the request + * * @return string The response body. * * @throws \Exception If the request fails. @@ -61,7 +63,7 @@ protected function request( \curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); \curl_setopt($ch, CURLOPT_USERAGENT, "Appwrite {$this->getName()} Message Sender"); - $response = \curl_exec($ch); + $response = strval(\curl_exec($ch)); if (\curl_errno($ch)) { throw new \Exception('Error: '.\curl_error($ch)); diff --git a/src/Utopia/Messaging/Adapters/Email/Sendgrid.php b/src/Utopia/Messaging/Adapters/Email/Sendgrid.php index 17745c48..c3914eee 100644 --- a/src/Utopia/Messaging/Adapters/Email/Sendgrid.php +++ b/src/Utopia/Messaging/Adapters/Email/Sendgrid.php @@ -50,7 +50,7 @@ protected function process(Email $message): string 'value' => $message->getContent(), ], ], - ]), + ])?: null, ); } } diff --git a/src/Utopia/Messaging/Adapters/Push/FCM.php b/src/Utopia/Messaging/Adapters/Push/FCM.php index 3734b16d..021af043 100644 --- a/src/Utopia/Messaging/Adapters/Push/FCM.php +++ b/src/Utopia/Messaging/Adapters/Push/FCM.php @@ -52,7 +52,7 @@ protected function process(Push $message): string 'tag' => $message->getTag(), ], 'data' => $message->getData(), - ]) + ]) ?: null ); } } diff --git a/src/Utopia/Messaging/Adapters/SMS/Mock.php b/src/Utopia/Messaging/Adapters/SMS/Mock.php index a9cd0eb8..115cb62c 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Mock.php +++ b/src/Utopia/Messaging/Adapters/SMS/Mock.php @@ -46,7 +46,7 @@ protected function process(SMS $message): string 'message' => $message->getContent(), 'from' => $message->getFrom(), 'to' => \implode(',', $message->getTo()), - ]), + ]) ?: null, ); } } diff --git a/src/Utopia/Messaging/Adapters/SMS/Msg91.php b/src/Utopia/Messaging/Adapters/SMS/Msg91.php index 82b2527d..0154c623 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Msg91.php +++ b/src/Utopia/Messaging/Adapters/SMS/Msg91.php @@ -55,7 +55,7 @@ protected function process(SMS $message): string 'otp' => $message->getContent(), 'flow_id' => $message->getFrom(), 'recipients' => [$to], - ]), + ]) ?: null, ); } } diff --git a/src/Utopia/Messaging/Adapters/SMS/Telnyx.php b/src/Utopia/Messaging/Adapters/SMS/Telnyx.php index 431736b5..3d72b5c3 100644 --- a/src/Utopia/Messaging/Adapters/SMS/Telnyx.php +++ b/src/Utopia/Messaging/Adapters/SMS/Telnyx.php @@ -43,7 +43,7 @@ protected function process(SMS $message): string 'text' => $message->getContent(), 'from' => $message->getFrom(), 'to' => $message->getTo()[0], - ]), + ]) ?: null, ); } } diff --git a/src/Utopia/Messaging/Message.php b/src/Utopia/Messaging/Message.php index 3b5e21ae..ba76eee5 100644 --- a/src/Utopia/Messaging/Message.php +++ b/src/Utopia/Messaging/Message.php @@ -7,4 +7,8 @@ */ interface Message { + /** + * @return array + */ + public function getTo(): array; } From dc02f71dbe6ee2be9c45dfffa8226df1bd82dc0d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Sun, 19 Feb 2023 22:17:27 +0000 Subject: [PATCH 24/24] fear: linter --- src/Utopia/Messaging/Adapter.php | 3 +-- src/Utopia/Messaging/Adapters/Email/Sendgrid.php | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Utopia/Messaging/Adapter.php b/src/Utopia/Messaging/Adapter.php index 7ef8bc75..9e1d5195 100644 --- a/src/Utopia/Messaging/Adapter.php +++ b/src/Utopia/Messaging/Adapter.php @@ -38,8 +38,7 @@ abstract public function send(Message $message): string; * @param string $method The HTTP method to use. * @param string $url The URL to send the request to. * @param array $headers An array of headers to send with the request. - * @param ?string $body The body of the request - * + * @param ?string $body The body of the request * @return string The response body. * * @throws \Exception If the request fails. diff --git a/src/Utopia/Messaging/Adapters/Email/Sendgrid.php b/src/Utopia/Messaging/Adapters/Email/Sendgrid.php index c3914eee..61c853de 100644 --- a/src/Utopia/Messaging/Adapters/Email/Sendgrid.php +++ b/src/Utopia/Messaging/Adapters/Email/Sendgrid.php @@ -50,7 +50,7 @@ protected function process(Email $message): string 'value' => $message->getContent(), ], ], - ])?: null, + ]) ?: null, ); } }