Your project must not contain invalid function or method calls 6
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_call
- {
- $isValidInstance = $this instanceof Mailable || $this instanceof MailMessage;
- if ($isValidInstance && $this->mailDriver() === 'sendgrid') {
- $this->withSymfonyMessage(function (Email $email) use ($params) {
- $email->embed(static::sgEncode($params), SendgridTransport::REQUEST_BODY_PARAMETER);
- });
- }
- return $this;
- }
- public function register()
- {
- $this->app->afterResolving(MailManager::class, function (MailManager $mail_manager) {
- $mail_manager->extend('sendgrid', function ($config) {
- if (! isset($config['api_key'])) {
- $config = $this->app['config']->get('services.sendgrid', []);
- }
- $client = new HttpClient(Arr::get($config, 'guzzle', []));
- $endpoint = $config['endpoint'] ?? null;
- return new SendgridTransport($client, $config['api_key'], $endpoint);
- $this->app->afterResolving(MailManager::class, function (MailManager $mail_manager) {
- $mail_manager->extend('sendgrid', function ($config) {
- if (! isset($config['api_key'])) {
- $config = $this->app['config']->get('services.sendgrid', []);
- }
- $client = new HttpClient(Arr::get($config, 'guzzle', []));
- $endpoint = $config['endpoint'] ?? null;
- return new SendgridTransport($client, $config['api_key'], $endpoint);
- });
- case 'api_key':
- $this->apiKey = $val;
- continue 2;
- case 'personalizations':
- $this->setPersonalizations($data, $val);
- continue 2;
- case 'attachments':
- $val = array_merge($this->attachments, $val);
- break;
- case 'personalizations':
- $this->setPersonalizations($data, $val);
- continue 2;
- case 'attachments':
- $val = array_merge($this->attachments, $val);
- break;
- }
- Arr::set($data, $key, $val);
- }
- *
- * @throws ClientException
- */
- protected function post(array $payload): ResponseInterface
- {
- return $this->client->request('POST', $this->endpoint, $payload);
- }
- public function __toString(): string
- {
- return 'sendgrid';
Your project should not use invalid return types 5
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_return_typehint
- /**
- * @return string
- */
- private function mailDriver()
- {
- return function_exists('config') ? config('mail.default', config('mail.driver')) : env('MAIL_MAILER', env('MAIL_DRIVER'));
- }
- /**
- * @param array<string, mixed>|string $params
- * @return string
- {
- if (is_string($params)) {
- return $params;
- }
- return json_encode($params);
- }
- /**
- * @param string|array<string, mixed> $strParams
- * @return array<string, mixed>
- if (! is_string($strParams)) {
- return $strParams;
- }
- $params = json_decode($strParams, true);
- return is_array($params) ? $params : [];
- }
- }
- 'type' => 'text/html',
- 'value' => $email->getHtmlBody(),
- ];
- }
- return $contents;
- }
- /**
- * @return array<string, string>|null
- */
- return $attachments;
- }
- private function getAttachmentName(DataPart $dataPart): string
- {
- return $dataPart->getPreparedHeaders()->getHeaderParameter('Content-Disposition', 'filename');
- }
- private function getAttachmentContentType(DataPart $dataPart): string
- {
- return $dataPart->getMediaType().'/'.$dataPart->getMediaSubtype();
Your project must not contain invalid instantiations 3
- Read doc
- Reliability
- Major
More information: https://insight.symfony.com/what-we-analyse/php.invalid_instantiation
- $this->app->afterResolving(MailManager::class, function (MailManager $mail_manager) {
- $mail_manager->extend('sendgrid', function ($config) {
- if (! isset($config['api_key'])) {
- $config = $this->app['config']->get('services.sendgrid', []);
- }
- $client = new HttpClient(Arr::get($config, 'guzzle', []));
- $endpoint = $config['endpoint'] ?? null;
- return new SendgridTransport($client, $config['api_key'], $endpoint);
- });
- $config = $this->app['config']->get('services.sendgrid', []);
- }
- $client = new HttpClient(Arr::get($config, 'guzzle', []));
- $endpoint = $config['endpoint'] ?? null;
- return new SendgridTransport($client, $config['api_key'], $endpoint);
- });
- });
- }
- }
- $config = $this->app['config']->get('services.sendgrid', []);
- }
- $client = new HttpClient(Arr::get($config, 'guzzle', []));
- $endpoint = $config['endpoint'] ?? null;
- return new SendgridTransport($client, $config['api_key'], $endpoint);
- });
- });
- }
- }