From 0ec6455c166534299e37561cc529d44a35aa54a9 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:29:06 -0500 Subject: [PATCH 01/23] feat: add Pusher symfony notifier bridge --- .../Notifier/Bridge/Pusher/.gitattributes | 4 ++ .../Notifier/Bridge/Pusher/.gitignore | 8 +++ .../Notifier/Bridge/Pusher/CHANGELOG.md | 7 ++ .../Component/Notifier/Bridge/Pusher/LICENSE | 19 ++++++ .../Bridge/Pusher/PusherNotification.php | 18 +++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 35 ++++++++++ .../Bridge/Pusher/PusherRecipient.php | 22 +++++++ .../Bridge/Pusher/PusherTransport.php | 66 +++++++++++++++++++ .../Bridge/Pusher/PusherTransportFactory.php | 44 +++++++++++++ .../Notifier/Bridge/Pusher/README.md | 32 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 44 +++++++++++++ .../Tests/PusherTransportFactoryTest.php | 55 ++++++++++++++++ .../Pusher/Tests/PusherTransportTest.php | 62 +++++++++++++++++ .../Notifier/Bridge/Pusher/composer.json | 56 ++++++++++++++++ .../Notifier/Bridge/Pusher/phpunit.xml.dist | 31 +++++++++ 15 files changed, 503 insertions(+) create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php create mode 100755 src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/README.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/composer.json create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes new file mode 100644 index 0000000000000..84c7add058fb5 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitattributes @@ -0,0 +1,4 @@ +/Tests export-ignore +/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore new file mode 100644 index 0000000000000..ad99719aaed4c --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore @@ -0,0 +1,8 @@ +vendor/ +composer.lock +phpunit.xml +.phpunit.result.cache +.php-cs-fixer +.php-cs-fixer.cache +.phpcs-cache +phpcs.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md new file mode 100644 index 0000000000000..f19f06f2721c4 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +6.1.0 +----- + + * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE new file mode 100644 index 0000000000000..7e53e00d06058 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2019-2022 Metises LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php new file mode 100644 index 0000000000000..ced209e51a6d9 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -0,0 +1,18 @@ +getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php new file mode 100755 index 0000000000000..571b6defcda95 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -0,0 +1,35 @@ + + */ +final class PusherOptions implements MessageOptionsInterface +{ + private array $channels; + + public function __construct(array $channels) + { + $this->channels = $channels; + } + + public function toArray(): array + { + return $this->channels; + } + + public function getRecipientId(): ?string + { + return null; + } + + public function getChannels(): array + { + return $this->channels; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php new file mode 100644 index 0000000000000..dcc2c6d069430 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -0,0 +1,22 @@ +channels = $channels; + } + + public function getChannels(): array + { + return $this->channels; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php new file mode 100755 index 0000000000000..2832da1916876 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -0,0 +1,66 @@ + + */ +final class PusherTransport extends AbstractTransport +{ + private $pusherClient; + + public function __construct(Pusher $pusherClient, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) + { + $this->pusherClient = $pusherClient; + + parent::__construct($client, $dispatcher); + } + + public function __toString(): string + { + $settings = $this->pusherClient->getSettings(); + preg_match('/api-([\w]+)\.pusher\.com$/m', $settings['host'], $server); + + return sprintf('pusher://%s:%s@%s?server=%s', $settings['auth_key'], $settings['secret'], $settings['app_id'], $server[1]); + } + + public function supports(MessageInterface $message): bool + { + return $message instanceof PushMessage && (null === $message->getOptions() || $message->getOptions() instanceof PusherOptions); + } + + protected function doSend(MessageInterface $message): SentMessage + { + if (!$message instanceof PushMessage) { + throw new UnsupportedMessageTypeException(__CLASS__, PushMessage::class, $message); + } + + $options = $message->getOptions(); + + if (!$options instanceof PusherOptions) { + throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" for options.', __CLASS__, PusherOptions::class)); + } + + try { + $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); + } catch (Throwable) { + throw new RuntimeException('An error occurred at Pusher Notifier Transport'); + } + + return new SentMessage($message, $this->__toString()); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php new file mode 100755 index 0000000000000..e21e77535033d --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -0,0 +1,44 @@ + + */ +#[Autoconfigure(tags: ['texter.transport_factory'])] +final class PusherTransportFactory extends AbstractTransportFactory +{ + public function create(Dsn $dsn): TransportInterface + { + if ('pusher' !== $dsn->getScheme()) { + throw new UnsupportedSchemeException($dsn, 'pusher', $this->getSupportedSchemes()); + } + + if (null === $dsn->getUser() || null === $dsn->getPassword() || null === $dsn->getOption('server')) { + throw new MissingRequiredOptionException('Pusher needs a APP_KEY, APP_SECRET AND SERVER specified.'); + } + + $options = [ + 'cluster' => $dsn->getOption('server', 'mt1'), + ]; + + $pusherClient = new Pusher($dsn->getUser(), $dsn->getPassword(), $dsn->getHost(), $options); + + return new PusherTransport($pusherClient, $this->client, $this->dispatcher); + } + + protected function getSupportedSchemes(): array + { + return ['pusher']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md new file mode 100644 index 0000000000000..c8f4fb1f0c2bc --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md @@ -0,0 +1,32 @@ +Pusher Notifier +============== + +Provides [Pusher](https://pusher.com) integration for Symfony Notifier. + +DSN example +----------- + +``` +PUSHER_DSN=pusher://APP_KEY:APP_SECRET@APP_ID?server=SERVER +``` + +where: + +- `APP_KEY` is your app unique key +- `APP_SECRET` is your app unique and secret password +- `APP_ID` is your app unique id +- `SERVER` is your app server + +valid DSN's are: + +``` +PUSHER_DSN=pusher://as8d09a0ds8:as8d09a8sd0a8sd0@123123123?server=mt1 +``` + +invalid DSN's are: + +``` +PUSHER_DSN=pusher://asdasdasd@asdasdasd?server=invalid-server +PUSHER_DSN=pusher://:asdasdasd@asdasdasd?server=invalid-server +PUSHER_DSN=pusher://asdadasdasd:asdasdasd@asdasdasd?server=invalid-server +``` diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php new file mode 100644 index 0000000000000..871fbdebf34b6 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -0,0 +1,44 @@ + + * + * @internal + * @coversNothing + */ +final class PusherOptionsTest extends TestCase +{ + /** + * @dataProvider toArrayProvider + * @dataProvider toArraySimpleOptionsProvider + */ + public function testToArray(array $options, array $expected = null): void + { + static::assertSame($expected ?? $options, (new PusherOptions($options))->toArray()); + } + + public function toArrayProvider(): iterable + { + yield 'empty is allowed' => [ + [], + [], + ]; + } + + public function toArraySimpleOptionsProvider(): iterable + { + yield [[]]; + } + + public function setProvider(): iterable + { + yield ['async', 'async', true]; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php new file mode 100644 index 0000000000000..fabe60bc0011f --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -0,0 +1,55 @@ + + * + * @internal + * @coversNothing + */ +final class PusherTransportFactoryTest extends TransportFactoryTestCase +{ + /** + * @return PusherTransportFactory + */ + public function createFactory(): TransportFactoryInterface + { + return new PusherTransportFactory(); + } + + public function createProvider(): iterable + { + yield [ + 'pusher://key:secret@id?server=mt1', + 'pusher://key:secret@id?server=mt1', + ]; + } + + public function supportsProvider(): iterable + { + yield [true, 'pusher://key:secret@id?server=mt1']; + yield [false, 'somethingElse://xoxb-TestToken@host?server=testChannel']; + } + + public function incompleteDsnProvider(): iterable + { + yield 'missing secret' => ['pusher://key@id?server=mt1']; + } + + public function unsupportedSchemeProvider(): iterable + { + yield ['somethingElse://something@else']; + } + + public function missingRequiredOptionProvider(): iterable + { + yield ['pusher://key:secret@id']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php new file mode 100644 index 0000000000000..dfb3644f7d807 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -0,0 +1,62 @@ + + * + * @internal + * @coversNothing + */ +final class PusherTransportTest extends TransportTestCase +{ + public function toStringProvider(): iterable + { + yield ['pusher://key:secret@app?server=mt1', $this->createTransport()]; + } + + /** + * @return PusherTransport + */ + public function createTransport(HttpClientInterface $client = null): TransportInterface + { + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? $this->createMock(HttpClientInterface::class)); + } + + public function supportedMessagesProvider(): iterable + { + yield [new PushMessage('event', 'data')]; + } + + public function unsupportedMessagesProvider(): iterable + { + yield [new SmsMessage('0611223344', 'Hello!')]; + yield [$this->createMock(MessageInterface::class)]; + } + + public function testCanSetCustomHost(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } + + public function testCanSetCustomPort(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } + + public function testCanSetCustomHostAndPort(): void + { + static::markTestSkipped('Does not apply for this provider.'); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json new file mode 100644 index 0000000000000..dce2a2a86a75d --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -0,0 +1,56 @@ +{ + "name": "metises/pusher-notifier", + "type": "symfony-notifier-bridge", + "description": "Symfony Pusher Notifier Bridge", + "keywords": [ + "pusher", + "notifier" + ], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Yasmany Cubela Medina", + "email": "yasmanycm@gmail.com" + } + ], + "require": { + "php": ">=8.0", + "pusher/pusher-php-server": "^7.0", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/http-client": "^4.3|^5.0|^6.0", + "symfony/notifier": "^5.3|^6.0", + "symfony/dependency-injection": "^5.3|^6.0" + }, + "require-dev": { + "roave/security-advisories": "dev-latest", + "symfony/event-dispatcher": "^4.3|^5.0|^6.0", + "phpunit/phpunit": "^9.5", + "friendsofphp/php-cs-fixer": "v3.4" + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "scripts": { + "csf": "./vendor/bin/php-cs-fixer fix", + "post-install-cmd": [ + "@auto-scripts" + ], + "post-update-cmd": [ + "@auto-scripts" + ] + }, + "minimum-stability": "dev", + "config": { + "allow-plugins": { + "phpstan/extension-installer": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "symfony/thanks": true + } + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist new file mode 100644 index 0000000000000..9d948b7dd3cd3 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + From a8a7775130752d2bd6603269a3e9d6594941a94f Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:37:42 -0500 Subject: [PATCH 02/23] fix: composer.json package name --- .../Notifier/Bridge/Pusher/composer.json | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json index dce2a2a86a75d..e618f6a0d21a3 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -1,5 +1,5 @@ { - "name": "metises/pusher-notifier", + "name": "symfony/pusher-notifier", "type": "symfony-notifier-bridge", "description": "Symfony Pusher Notifier Bridge", "keywords": [ @@ -12,21 +12,17 @@ { "name": "Yasmany Cubela Medina", "email": "yasmanycm@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "require": { - "php": ">=8.0", + "php": ">=8.1", "pusher/pusher-php-server": "^7.0", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/http-client": "^4.3|^5.0|^6.0", - "symfony/notifier": "^5.3|^6.0", - "symfony/dependency-injection": "^5.3|^6.0" - }, - "require-dev": { - "roave/security-advisories": "dev-latest", - "symfony/event-dispatcher": "^4.3|^5.0|^6.0", - "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "v3.4" + "symfony/http-client": "^5.4|^6.0", + "symfony/notifier": "^5.4|^6.0" }, "autoload": { "psr-4": { @@ -36,21 +32,5 @@ "/Tests/" ] }, - "scripts": { - "csf": "./vendor/bin/php-cs-fixer fix", - "post-install-cmd": [ - "@auto-scripts" - ], - "post-update-cmd": [ - "@auto-scripts" - ] - }, - "minimum-stability": "dev", - "config": { - "allow-plugins": { - "phpstan/extension-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true, - "symfony/thanks": true - } - } + "minimum-stability": "dev" } From 0d18b4891dde8803ca0bb7e91048959ba7375cf9 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:39:42 -0500 Subject: [PATCH 03/23] fix: LICENSE and CHANGELOG.md --- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index f19f06f2721c4..42bafa26795fb 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -6.1.0 +6.2.0 ----- * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 7e53e00d06058..9c907a46a6218 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Metises LLC +Copyright (c) 2019-2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 1fbbcfeaadabd547b87fe4972af6b3947bda9969 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:44:32 -0500 Subject: [PATCH 04/23] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherRecipient.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherTransport.php | 11 ++++++++++- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 9 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 10 ++++++++++ .../Pusher/Tests/PusherTransportFactoryTest.php | 10 ++++++++++ .../Bridge/Pusher/Tests/PusherTransportTest.php | 10 ++++++++++ 8 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index ced209e51a6d9..cbc482f68a907 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Message\PushMessage; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 571b6defcda95..4ac5858cd5231 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Message\MessageOptionsInterface; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index dcc2c6d069430..1c94c3588807c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Symfony\Component\Notifier\Recipient\RecipientInterface; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 2832da1916876..b32a83ccd7ed6 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; @@ -23,7 +32,7 @@ final class PusherTransport extends AbstractTransport { private $pusherClient; - public function __construct(Pusher $pusherClient, ?HttpClientInterface $client = null, ?EventDispatcherInterface $dispatcher = null) + public function __construct(Pusher $pusherClient, HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null) { $this->pusherClient = $pusherClient; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index e21e77535033d..e6c0344db07c7 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 871fbdebf34b6..3e97e740fd571 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use PHPUnit\Framework\TestCase; @@ -11,6 +20,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherOptionsTest extends TestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php index fabe60bc0011f..245ea1dae212d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use Symfony\Component\Notifier\Bridge\Pusher\PusherTransportFactory; @@ -12,6 +21,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherTransportFactoryTest extends TransportFactoryTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index dfb3644f7d807..fffa888748980 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -2,6 +2,15 @@ declare(strict_types=1); +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Notifier\Bridge\Pusher\Tests; use Pusher\Pusher; @@ -17,6 +26,7 @@ * @author Yasmany Cubela Medina * * @internal + * * @coversNothing */ final class PusherTransportTest extends TransportTestCase From c582df82b1d4cf7a6c8d6f62f58f719de56bd3e3 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:46:24 -0500 Subject: [PATCH 05/23] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherOptions.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherRecipient.php | 9 +++++++++ .../Notifier/Bridge/Pusher/PusherTransport.php | 11 ++++++++++- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 9 +++++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 2 +- .../Bridge/Pusher/Tests/PusherTransportTest.php | 6 +++--- 7 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index cbc482f68a907..ae65eb79b1456 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 4ac5858cd5231..f220294d7e71f 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index 1c94c3588807c..e772e2083bf8e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index b32a83ccd7ed6..4683526f5eb8f 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* @@ -67,7 +76,7 @@ protected function doSend(MessageInterface $message): SentMessage try { $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); } catch (Throwable) { - throw new RuntimeException('An error occurred at Pusher Notifier Transport'); + throw new RuntimeException('An error occurred at Pusher Notifier Transport.'); } return new SentMessage($message, $this->__toString()); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index e6c0344db07c7..c1eac38d48723 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + declare(strict_types=1); /* diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 3e97e740fd571..208a222eaa91d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -29,7 +29,7 @@ final class PusherOptionsTest extends TestCase * @dataProvider toArrayProvider * @dataProvider toArraySimpleOptionsProvider */ - public function testToArray(array $options, array $expected = null): void + public function testToArray(array $options, array $expected = null) { static::assertSame($expected ?? $options, (new PusherOptions($options))->toArray()); } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index fffa888748980..92514c8121c35 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -55,17 +55,17 @@ public function unsupportedMessagesProvider(): iterable yield [$this->createMock(MessageInterface::class)]; } - public function testCanSetCustomHost(): void + public function testCanSetCustomHost() { static::markTestSkipped('Does not apply for this provider.'); } - public function testCanSetCustomPort(): void + public function testCanSetCustomPort() { static::markTestSkipped('Does not apply for this provider.'); } - public function testCanSetCustomHostAndPort(): void + public function testCanSetCustomHostAndPort() { static::markTestSkipped('Does not apply for this provider.'); } From 8c00bad5d23cf559d57caaf4d9e645e761903315 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Sat, 12 Nov 2022 07:47:15 -0500 Subject: [PATCH 06/23] chore: apply fabbot --- .../Notifier/Bridge/Pusher/PusherNotification.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherOptions.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 8 -------- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 8 -------- .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 8 -------- 5 files changed, 40 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index ae65eb79b1456..b49323850803e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index f220294d7e71f..5f18b140429eb 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index e772e2083bf8e..73d28626f18f2 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 4683526f5eb8f..c410e9632bc28 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index c1eac38d48723..86185ac2e1a8c 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -1,13 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ declare(strict_types=1); From 073986f80d049229fe2f434fc459ef3402833612 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 14 Nov 2022 07:52:56 -0500 Subject: [PATCH 07/23] chore: work on PR comments --- src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore | 5 ----- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 4 +++- .../Component/Notifier/Bridge/Pusher/PusherOptions.php | 1 - .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 4 +++- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 1 - .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 1 - 8 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore index ad99719aaed4c..c49a5d8df5c65 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/.gitignore @@ -1,8 +1,3 @@ vendor/ composer.lock phpunit.xml -.phpunit.result.cache -.php-cs-fixer -.php-cs-fixer.cache -.phpcs-cache -phpcs.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index 42bafa26795fb..db56b7a479885 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -1,7 +1,7 @@ CHANGELOG ========= -6.2.0 +6.3 ----- * Added the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 9c907a46a6218..0ece8964f767d 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2022 Fabien Potencier +Copyright (c) 2022 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index b49323850803e..27e9959bed7ef 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,6 +1,5 @@ + */ class PusherNotification extends Notification implements PushNotificationInterface { public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php index 5f18b140429eb..4ac5858cd5231 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php @@ -1,6 +1,5 @@ + */ class PusherRecipient implements RecipientInterface { private array $channels; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index c410e9632bc28..70dc25d046337 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -1,6 +1,5 @@ Date: Mon, 14 Nov 2022 08:12:31 -0500 Subject: [PATCH 08/23] chore: drop declare strict types --- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 2 -- src/Symfony/Component/Notifier/Bridge/Pusher/PusherOptions.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherRecipient.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 2 -- .../Component/Notifier/Bridge/Pusher/PusherTransportFactory.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php | 2 -- .../Notifier/Bridge/Pusher/Tests/PusherTransportTest.php | 2 -- 8 files changed, 16 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index 27e9959bed7ef..a9cccf0e21aa6 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -1,7 +1,5 @@ Date: Mon, 14 Nov 2022 10:35:15 -0500 Subject: [PATCH 09/23] chore: small format changes --- .../Component/Notifier/Bridge/Pusher/composer.json | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json index e618f6a0d21a3..1a27f2904cb74 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/composer.json @@ -2,10 +2,7 @@ "name": "symfony/pusher-notifier", "type": "symfony-notifier-bridge", "description": "Symfony Pusher Notifier Bridge", - "keywords": [ - "pusher", - "notifier" - ], + "keywords": ["pusher", "notifier"], "homepage": "https://symfony.com", "license": "MIT", "authors": [ @@ -22,12 +19,13 @@ "php": ">=8.1", "pusher/pusher-php-server": "^7.0", "symfony/http-client": "^5.4|^6.0", - "symfony/notifier": "^5.4|^6.0" + "symfony/notifier": "^6.2" + }, + "require-dev": { + "symfony/event-dispatcher": "^5.4|^6.0" }, "autoload": { - "psr-4": { - "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" - }, + "psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Pusher\\": "" }, "exclude-from-classmap": [ "/Tests/" ] From dcd029fcf760171a095d3fe9386ffe7605f209f8 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 14 Nov 2022 10:54:54 -0500 Subject: [PATCH 10/23] fix: add pusher package to main composer.json to fix tests --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index d03652cee8f6f..2cb40c768618c 100644 --- a/composer.json +++ b/composer.json @@ -142,6 +142,7 @@ "predis/predis": "~1.1", "psr/http-client": "^1.0", "psr/simple-cache": "^1.0|^2.0|^3.0", + "pusher/pusher-php-server": "^7.0", "symfony/mercure-bundle": "^0.3", "symfony/phpunit-bridge": "^5.4|^6.0", "symfony/runtime": "self.version", From 88bad27e3577dfe9312709e60d86fb5f5e65ddba Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Fri, 2 Dec 2022 10:55:29 -0500 Subject: [PATCH 11/23] chore: set PusherRecipientInterface as typehint of asPushMessage method chore: remove @internal annotation from tests chore: add footer to README.md chore: apply PR comments --- .../Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- .../Bridge/Pusher/PusherNotification.php | 3 +-- .../Bridge/Pusher/PusherRecipient.php | 4 +--- .../Pusher/PusherRecipientInterface.php | 22 +++++++++++++++++++ .../Notifier/Bridge/Pusher/README.md | 8 +++++++ .../Bridge/Pusher/Tests/PusherOptionsTest.php | 2 -- .../Tests/PusherTransportFactoryTest.php | 2 -- .../Pusher/Tests/PusherTransportTest.php | 2 -- .../Notifier/Bridge/Pusher/phpunit.xml.dist | 20 ++++++++--------- 9 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index db56b7a479885..9dec118b3f6fe 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -4,4 +4,4 @@ CHANGELOG 6.3 ----- - * Added the bridge + * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index a9cccf0e21aa6..516d86c0590e9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -14,14 +14,13 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Notification\PushNotificationInterface; -use Symfony\Component\Notifier\Recipient\RecipientInterface; /** * @author Yasmany Cubela Medina */ class PusherNotification extends Notification implements PushNotificationInterface { - public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage + public function asPushMessage(PusherRecipientInterface $recipient, string $transport = null): ?PushMessage { return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); } diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php index 60b6e820cb866..5ce14e6a1799e 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipient.php @@ -11,12 +11,10 @@ namespace Symfony\Component\Notifier\Bridge\Pusher; -use Symfony\Component\Notifier\Recipient\RecipientInterface; - /** * @author Yasmany Cubela Medina */ -class PusherRecipient implements RecipientInterface +class PusherRecipient implements PusherRecipientInterface { private array $channels; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php new file mode 100644 index 0000000000000..59e9c914cea4f --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherRecipientInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Pusher; + +use Symfony\Component\Notifier\Recipient\RecipientInterface; + +/** + * @author Yasmany Cubela Medina + */ +interface PusherRecipientInterface extends RecipientInterface +{ + public function getChannels(): array; +} diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md index c8f4fb1f0c2bc..79b4d760c194b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/README.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/README.md @@ -30,3 +30,11 @@ PUSHER_DSN=pusher://asdasdasd@asdasdasd?server=invalid-server PUSHER_DSN=pusher://:asdasdasd@asdasdasd?server=invalid-server PUSHER_DSN=pusher://asdadasdasd:asdasdasd@asdasdasd?server=invalid-server ``` + +Resources +--------- + +* [Contributing](https://symfony.com/doc/current/contributing/index.html) +* [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php index 5e7ddd5e45df9..f93b58fb29630 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherOptionsTest.php @@ -17,8 +17,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherOptionsTest extends TestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php index 2695445e7d97d..1bd9a688fe8c9 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportFactoryTest.php @@ -18,8 +18,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherTransportFactoryTest extends TransportFactoryTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index 6477c6434c21a..e8f4c1b3e6084 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -23,8 +23,6 @@ /** * @author Yasmany Cubela Medina * - * @internal - * * @coversNothing */ final class PusherTransportTest extends TransportTestCase diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist index 9d948b7dd3cd3..27ba9f69b7dfd 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/phpunit.xml.dist @@ -9,7 +9,7 @@ failOnWarning="true" > - + @@ -18,14 +18,14 @@ - - + + ./ - - ./Resources - ./Tests - ./vendor - - - + + + ./Resources + ./Tests + ./vendor + + From dee00b680ead8868ec2c5513051ee0c7e8879e78 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Fri, 2 Dec 2022 12:50:51 -0500 Subject: [PATCH 12/23] chore: set RecipientInterface as typehint of asPushMessage method --- .../Component/Notifier/Bridge/Pusher/PusherNotification.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php index 516d86c0590e9..2bd8f67067d2b 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherNotification.php @@ -14,14 +14,15 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\Notification\PushNotificationInterface; +use Symfony\Component\Notifier\Recipient\RecipientInterface; /** * @author Yasmany Cubela Medina */ class PusherNotification extends Notification implements PushNotificationInterface { - public function asPushMessage(PusherRecipientInterface $recipient, string $transport = null): ?PushMessage + public function asPushMessage(RecipientInterface $recipient, string $transport = null): ?PushMessage { - return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient->getChannels())); + return new PushMessage($this->getSubject(), $this->getContent(), new PusherOptions($recipient instanceof PusherRecipientInterface ? $recipient->getChannels() : [])); } } From 45ad1c6f6773f3b9da1f3067692f0a29b6fafc1a Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 20 Dec 2022 20:08:50 +0100 Subject: [PATCH 13/23] Remove calls to AnnotationRegistry::registerLoader() --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 --------- src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 --------- src/Symfony/Bridge/PhpUnit/composer.json | 1 + 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 3652c3bb388c4..9cfa36d84f159 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\PhpUnit\Legacy; -use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -130,14 +129,6 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; - if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } - } - if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index f2064368f41a3..c81c828770dbc 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ -use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -27,14 +26,6 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); -if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } -} - if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 75fce743284aa..b4dc2760fbb24 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,6 +29,7 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { + "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { From 6cd8b6ecbf941108635311021ff12cad18ab28b5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 28 Dec 2022 14:45:14 +0100 Subject: [PATCH 14/23] [PhpUnitBridge] Revert "minor #48725 Remove calls to `AnnotationRegistry::registerLoader()`" --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/composer.json | 1 - 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 9cfa36d84f159..3652c3bb388c4 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy; +use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -129,6 +130,14 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; + if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } + } + if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index c81c828770dbc..f2064368f41a3 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -26,6 +27,14 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); +if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } +} + if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index b4dc2760fbb24..75fce743284aa 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,7 +29,6 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { From 0d251c5e47e7b76e89ac15d65dc8fb418c5ae4b4 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 20 Dec 2022 20:08:50 +0100 Subject: [PATCH 15/23] Remove calls to AnnotationRegistry::registerLoader() --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 --------- src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 --------- src/Symfony/Bridge/PhpUnit/composer.json | 1 + 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 3652c3bb388c4..9cfa36d84f159 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\PhpUnit\Legacy; -use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -130,14 +129,6 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; - if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } - } - if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index f2064368f41a3..c81c828770dbc 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ -use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -27,14 +26,6 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); -if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } -} - if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 75fce743284aa..b4dc2760fbb24 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,6 +29,7 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { + "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { From f7165d78e2926ed62f4985531f07287f9a276d3a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 28 Dec 2022 14:45:14 +0100 Subject: [PATCH 16/23] [PhpUnitBridge] Revert "minor #48725 Remove calls to `AnnotationRegistry::registerLoader()`" --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/composer.json | 1 - 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 9cfa36d84f159..3652c3bb388c4 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy; +use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -129,6 +130,14 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; + if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } + } + if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index c81c828770dbc..f2064368f41a3 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -26,6 +27,14 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); +if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } +} + if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index b4dc2760fbb24..75fce743284aa 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,7 +29,6 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { From a17252aa3d4dc0d1fdf016d7a6bc05884a73e9eb Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 20 Dec 2022 20:08:50 +0100 Subject: [PATCH 17/23] Remove calls to AnnotationRegistry::registerLoader() --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 --------- src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 --------- src/Symfony/Bridge/PhpUnit/composer.json | 1 + 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 3652c3bb388c4..9cfa36d84f159 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,7 +11,6 @@ namespace Symfony\Bridge\PhpUnit\Legacy; -use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -130,14 +129,6 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; - if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } - } - if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index f2064368f41a3..c81c828770dbc 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ -use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -27,14 +26,6 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); -if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { - if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { - AnnotationRegistry::registerUniqueLoader('class_exists'); - } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { - AnnotationRegistry::registerLoader('class_exists'); - } -} - if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index 75fce743284aa..b4dc2760fbb24 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,6 +29,7 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { + "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { From dc3e77db13fb90c79de97b0b28d6913a519eb09f Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 9 Jan 2023 11:28:43 -0500 Subject: [PATCH 18/23] chore: fabbot --- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 10416271ebe63..6d019e07ef707 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -12,7 +12,6 @@ namespace Symfony\Component\Notifier\Bridge\Pusher; use Pusher\Pusher; -use RuntimeException; use Symfony\Component\Notifier\Exception\LogicException; use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; use Symfony\Component\Notifier\Message\MessageInterface; @@ -65,7 +64,7 @@ protected function doSend(MessageInterface $message): SentMessage try { $this->pusherClient->trigger($options->getChannels(), $message->getSubject(), $message->getContent(), [], true); } catch (Throwable) { - throw new RuntimeException('An error occurred at Pusher Notifier Transport.'); + throw new \RuntimeException('An error occurred at Pusher Notifier Transport.'); } return new SentMessage($message, $this->__toString()); From 4771f05df335f2f63a49d30ff142e58a7e9862ee Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Mon, 9 Jan 2023 11:31:30 -0500 Subject: [PATCH 19/23] fix: LICENSE --- src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE index 0ece8964f767d..f961401699b27 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2022 Fabien Potencier +Copyright (c) 2023 Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 60ec41e4363b2ad11b687438417b7aee41a4a163 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 11:27:00 -0500 Subject: [PATCH 20/23] chore: rebase for #49385 --- .../Bridge/Pusher/Tests/PusherTransportTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index e8f4c1b3e6084..2a64c3365c16f 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -13,10 +13,10 @@ use Pusher\Pusher; use Symfony\Component\Notifier\Bridge\Pusher\PusherTransport; -use Symfony\Component\Notifier\Message\MessageInterface; use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Fixtures\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -35,20 +35,20 @@ public function toStringProvider(): iterable /** * @return PusherTransport */ - public function createTransport(HttpClientInterface $client = null): TransportInterface + public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? $this->createMock(HttpClientInterface::class)); + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client); } - public function supportedMessagesProvider(): iterable + public static function supportedMessagesProvider(): iterable { yield [new PushMessage('event', 'data')]; } - public function unsupportedMessagesProvider(): iterable + public static function unsupportedMessagesProvider(): iterable { yield [new SmsMessage('0611223344', 'Hello!')]; - yield [$this->createMock(MessageInterface::class)]; + yield [new DummyMessage()]; } public function testCanSetCustomHost() From a4c4401aead571a71b7789878b359b32bf19d099 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 13:43:01 -0500 Subject: [PATCH 21/23] chore: apply comments from #49385 --- .../Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/bootstrap.php | 9 +++++++++ src/Symfony/Bridge/PhpUnit/composer.json | 1 - .../Notifier/Bridge/Pusher/Tests/PusherTransportTest.php | 3 ++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 9cfa36d84f159..3652c3bb388c4 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -11,6 +11,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy; +use Doctrine\Common\Annotations\AnnotationRegistry; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\RiskyTestError; use PHPUnit\Framework\TestCase; @@ -129,6 +130,14 @@ public function startTestSuite($suite): void echo "Testing $suiteName\n"; $this->state = 0; + if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } + } + if ($this->skippedFile = getenv('SYMFONY_PHPUNIT_SKIPPED_TESTS')) { $this->state = 1; diff --git a/src/Symfony/Bridge/PhpUnit/bootstrap.php b/src/Symfony/Bridge/PhpUnit/bootstrap.php index c81c828770dbc..f2064368f41a3 100644 --- a/src/Symfony/Bridge/PhpUnit/bootstrap.php +++ b/src/Symfony/Bridge/PhpUnit/bootstrap.php @@ -9,6 +9,7 @@ * file that was distributed with this source code. */ +use Doctrine\Common\Annotations\AnnotationRegistry; use Symfony\Bridge\PhpUnit\DeprecationErrorHandler; // Detect if we need to serialize deprecations to a file. @@ -26,6 +27,14 @@ // Enforce a consistent locale setlocale(\LC_ALL, 'C'); +if (!class_exists(AnnotationRegistry::class, false) && class_exists(AnnotationRegistry::class)) { + if (method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) { + AnnotationRegistry::registerUniqueLoader('class_exists'); + } elseif (method_exists(AnnotationRegistry::class, 'registerLoader')) { + AnnotationRegistry::registerLoader('class_exists'); + } +} + if ('disabled' !== getenv('SYMFONY_DEPRECATIONS_HELPER')) { DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER')); } diff --git a/src/Symfony/Bridge/PhpUnit/composer.json b/src/Symfony/Bridge/PhpUnit/composer.json index b4dc2760fbb24..75fce743284aa 100644 --- a/src/Symfony/Bridge/PhpUnit/composer.json +++ b/src/Symfony/Bridge/PhpUnit/composer.json @@ -29,7 +29,6 @@ "symfony/error-handler": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" }, "conflict": { - "doctrine/annotations": "<1.10", "phpunit/phpunit": "<7.5|9.1.2" }, "autoload": { diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php index 2a64c3365c16f..897ba189ac74c 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/Tests/PusherTransportTest.php @@ -16,6 +16,7 @@ use Symfony\Component\Notifier\Message\PushMessage; use Symfony\Component\Notifier\Message\SmsMessage; use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Component\Notifier\Tests\Fixtures\DummyHttpClient; use Symfony\Component\Notifier\Tests\Fixtures\DummyMessage; use Symfony\Component\Notifier\Transport\TransportInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; @@ -37,7 +38,7 @@ public function toStringProvider(): iterable */ public static function createTransport(HttpClientInterface $client = null): TransportInterface { - return new PusherTransport(new Pusher('key', 'secret', 'app'), $client); + return new PusherTransport(new Pusher('key', 'secret', 'app'), $client ?? new DummyHttpClient()); } public static function supportedMessagesProvider(): iterable From 7429e4d8b087e51cedac782cdbc43cee39e68ee7 Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Wed, 15 Feb 2023 20:59:12 -0500 Subject: [PATCH 22/23] feat: drop autoconfigure tag from transport factory feat: configure pusher notifier on framework bundle --- .../FrameworkBundle/Resources/config/notifier_transports.php | 5 +++++ .../Notifier/Bridge/Pusher/PusherTransportFactory.php | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index c5e0371d933ba..0124c36dae652 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -50,6 +50,7 @@ use Symfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransportFactory; use Symfony\Component\Notifier\Bridge\PagerDuty\PagerDutyTransportFactory; use Symfony\Component\Notifier\Bridge\Plivo\PlivoTransportFactory; +use Symfony\Component\Notifier\Bridge\Pusher\PusherTransportFactory; use Symfony\Component\Notifier\Bridge\RingCentral\RingCentralTransportFactory; use Symfony\Component\Notifier\Bridge\RocketChat\RocketChatTransportFactory; use Symfony\Component\Notifier\Bridge\Sendberry\SendberryTransportFactory; @@ -331,5 +332,9 @@ ->set('notifier.transport_factory.pager-duty', PagerDutyTransportFactory::class) ->parent('notifier.transport_factory.abstract') ->tag('chatter.transport_factory') + + ->set('notifier.transport_factory.slack', PusherTransportFactory::class) + ->parent('notifier.transport_factory.abstract') + ->tag('chatter.transport_factory') ; }; diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php index f58979b4f9e72..dfbe4a7698ba6 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransportFactory.php @@ -22,7 +22,6 @@ /** * @author Yasmany Cubela Medina */ -#[Autoconfigure(tags: ['texter.transport_factory'])] final class PusherTransportFactory extends AbstractTransportFactory { public function create(Dsn $dsn): TransportInterface From 2787214b69e03143fe68ff2ad3aad2d67f82527c Mon Sep 17 00:00:00 2001 From: Yasmany Cubela Medina Date: Thu, 16 Feb 2023 06:30:04 -0500 Subject: [PATCH 23/23] chore: drop extra - on CHANGELOG.md fix: drop sensitive information from toString method on transport --- src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md | 2 +- .../Component/Notifier/Bridge/Pusher/PusherTransport.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md index 9dec118b3f6fe..c7d6080bb1103 100644 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/CHANGELOG.md @@ -2,6 +2,6 @@ CHANGELOG ========= 6.3 ------ +---- * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php index 6d019e07ef707..b99af8154339b 100755 --- a/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Pusher/PusherTransport.php @@ -41,7 +41,7 @@ public function __toString(): string $settings = $this->pusherClient->getSettings(); preg_match('/api-([\w]+)\.pusher\.com$/m', $settings['host'], $server); - return sprintf('pusher://%s:%s@%s?server=%s', $settings['auth_key'], $settings['secret'], $settings['app_id'], $server[1]); + return sprintf('pusher://%s?server=%s', $settings['app_id'], $server[1]); } public function supports(MessageInterface $message): bool