Skip to content

Commit

Permalink
feat(42): Prepare for the next Symfony version
Browse files Browse the repository at this point in the history
Fixing command deprecation requires AsCommand, which breaks support for SF < 5.3
  • Loading branch information
121593 committed Dec 9, 2023
1 parent 8a2e1fe commit 4fefb47
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
"ext-openssl": "*",
"guzzlehttp/guzzle": "~6.0|~7.0",
"minishlink/web-push": "~4.0|~5.0|~6.0|~7.0",
"symfony/http-kernel": "~3.0|~4.0|~5.0|~6.0"
"symfony/http-kernel": "~5.3|~6.0"
},
"require-dev": {
"bentools/doctrine-static": "1.0.x-dev",
"doctrine/dbal": "~2.5 <=2.9",
"doctrine/dbal": ">=2.5|~3",
"nyholm/symfony-bundle-test": "~1.8",
"phpunit/phpunit": "~5.0|~6.0|~7.0|~8.0|~9.0",
"symfony/config": "~4.0|~5.0|~6.0",
"symfony/dependency-injection": "~3.0|~4.0|~5.0|~6.0",
"symfony/framework-bundle": "~3.0|~4.0|~5.0|~6.0",
"symfony/http-foundation": "~3.0|~4.0|~5.0|~6.0",
"symfony/routing": "~3.0|~4.0|~5.0|~6.0",
"symfony/security": "~3.0|~4.0|~5.0|~6.0",
"symfony/var-dumper": "~3.0|~4.0|~5.0|~6.0",
"symfony/yaml": "~3.0|~4.0|~5.0|~6.0",
"symfony/config": "~5.3|~6.0",
"symfony/dependency-injection": "~5.3|~6.0",
"symfony/framework-bundle": "~5.3|~6.0",
"symfony/http-foundation": "~5.3|~6.0",
"symfony/routing": "~5.3|~6.0",
"symfony/security-bundle": "~5.3|~6.0",
"symfony/var-dumper": "~5.3|~6.0",
"symfony/yaml": "~5.3|~6.0",
"twig/twig": "~1.0|~2.0"
},
"autoload": {
Expand Down Expand Up @@ -149,4 +149,4 @@
"chrome",
"firefox"
]
}
}
16 changes: 3 additions & 13 deletions src/Command/WebPushGenerateKeysCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,15 @@

use Minishlink\WebPush\VAPID;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\HttpKernel\Kernel;

#[AsCommand(name:"webpush:generate:keys", description:"Generate your VAPID keys for bentools/webpush.")]
final class WebPushGenerateKeysCommand extends Command
{
protected static $defaultName = 'webpush:generate:keys';

/**
* {@inheritdoc}
*/
protected function configure()
{
$this
->setName('webpush:generate:keys')
->setDescription('Generate your VAPID keys for bentools/webpush.');
}

/**
* {@inheritdoc}
* @throws \ErrorException
Expand All @@ -36,7 +26,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io->writeln(sprintf('Your private key is: <info>%s</info>', $keys['privateKey']));
$io->newLine(2);

if (-1 === version_compare(Kernel::VERSION, 4)) {
if (-1 === version_compare(Kernel::VERSION, '4')) {
$io->writeln('Update <info>app/config/config.yml</info>:');
$io->newLine(1);
$io->writeln('<info># app/config/config.yml</info>');
Expand Down
2 changes: 1 addition & 1 deletion src/Sender/PushMessageSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class PushMessageSender implements PushMessagerSenderInterface
{
/**
* @var Client
* @var ClientInterface
*/
private $client;

Expand Down
6 changes: 3 additions & 3 deletions src/Sender/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function createRequest(
): RequestInterface {
$request = new Request('POST', $subscription->getEndpoint());
$request = $this->withOptionalHeaders($request, $message);
$request = $request->withHeader('TTL', $ttl);
$request = $request->withHeader('TTL', (string) $ttl);

if (null !== $message->getPayload() && null !== $subscription->getPublicKey() && null !== $subscription->getAuthToken()) {
$request = $request
Expand All @@ -57,11 +57,11 @@ public function createRequest(

return $request
->withBody(GuzzleUtils::streamFor($content))
->withHeader('Content-Length', Utils::safeStrlen($content));
->withHeader('Content-Length', (string) Utils::safeStrlen($content));
}

return $request
->withHeader('Content-Length', 0);
->withHeader('Content-Length', '0');
}

/**
Expand Down

0 comments on commit 4fefb47

Please sign in to comment.