Booleans and null should be compared strictly 4

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.strict_boolean_comparison_should_be_used

  1. {
  2. if (!is_array($variables)) {
  3. return $address;
  4. }
  5. $fullName = $this->getFullName($variables);
  6. if (null != $fullName) {

    With booleans and null, only strict comparison (with !== operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Hannes Magnússon
  7. return sprintf('"%s" <%s>', $fullName, $address);
  8. }
  9. return $address;
  10. }
  1. *
  2. * @return mixed
  3. */
  4. public function setSubject($subject = '')
  5. {
  6. if (null == $subject || '' == $subject) {

    With booleans and null, only strict comparison (with === operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Hannes Magnússon
  7. $subject = ' ';
  8. }
  9. $this->message['subject'] = $subject;
  10. return $this->message['subject'];
  1. *
  2. * @return string
  3. */
  4. public function setTextBody($textBody)
  5. {
  6. if (null == $textBody || '' == $textBody) {

    With booleans and null, only strict comparison (with === operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Hannes Magnússon
  7. $textBody = ' ';
  8. }
  9. $this->message['text'] = $textBody;
  10. return $this->message['text'];
  1. *
  2. * @return string
  3. */
  4. public function setHtmlBody($htmlBody)
  5. {
  6. if (null == $htmlBody || '' == $htmlBody) {

    With booleans and null, only strict comparison (with === operator) should be used to lower bug risks and to improve performances.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Hannes Magnússon
  7. $htmlBody = ' ';
  8. }
  9. $this->message['html'] = $htmlBody;
  10. return $this->message['html'];

Unused method, property, variable or parameter 47

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. private $restClient;
  2. /**
  3. * @var string
  4. */
  5. private $workingDomain;

    This workingDomain attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Garcia
  6. /**
  7. * @var array
  8. */
  9. private $messageIds = [];
  1. }
  2. /**
  3. * @param array|\string[] $tags
  4. */
  5. private function setTags($tags)

    This setTags method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->tags = $tags;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $url
  4. */
  5. private function setUrl($url)

    This setUrl method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->url = $url;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $envelope
  4. */
  5. private function setEnvelope($envelope)

    This setEnvelope method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->envelope = $envelope;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $deliveryStatus
  4. */
  5. private function setDeliveryStatus($deliveryStatus)

    This setDeliveryStatus method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->deliveryStatus = $deliveryStatus;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array|\string[] $campaigns
  4. */
  5. private function setCampaigns($campaigns)

    This setCampaigns method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->campaigns = $campaigns;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $ip
  4. */
  5. private function setIp($ip)

    This setIp method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->ip = $ip;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $clientInfo
  4. */
  5. private function setClientInfo($clientInfo)

    This setClientInfo method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->clientInfo = $clientInfo;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $reason
  4. */
  5. private function setReason($reason)

    This setReason method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->reason = $reason;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $userVariables
  4. */
  5. private function setUserVariables($userVariables)

    This setUserVariables method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->userVariables = $userVariables;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $flags
  4. */
  5. private function setFlags($flags)

    This setFlags method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->flags = $flags;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $routes
  4. */
  5. private function setRoutes($routes)

    This setRoutes method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->routes = $routes;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $message
  4. */
  5. private function setMessage($message)

    This setMessage method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->message = $message;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $recipient
  4. */
  5. private function setRecipient($recipient)

    This setRecipient method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->recipient = $recipient;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $geolocation
  4. */
  5. private function setGeolocation($geolocation)

    This setGeolocation method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->geolocation = $geolocation;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $storage
  4. */
  5. private function setStorage($storage)

    This setStorage method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->storage = $storage;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $method
  4. */
  5. private function setMethod($method)

    This setMethod method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->method = $method;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $severity
  4. */
  5. private function setSeverity($severity)

    This setSeverity method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->severity = $severity;
  8. }
  9. }
  1. }
  2. /**
  3. * @param string $recipient
  4. */
  5. private function setRecipient($recipient)

    This setRecipient method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->recipient = $recipient;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $bodyMime
  4. */
  5. private function setBodyMime($bodyMime)

    This setBodyMime method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->bodyMime = $bodyMime;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $recipients
  4. */
  5. private function setRecipients($recipients)

    This setRecipients method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->recipients = $recipients;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $sender
  4. */
  5. private function setSender($sender)

    This setSender method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->sender = $sender;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $from
  4. */
  5. private function setFrom($from)

    This setFrom method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->from = $from;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $subject
  4. */
  5. private function setSubject($subject)

    This setSubject method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->subject = $subject;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $bodyPlain
  4. */
  5. private function setBodyPlain($bodyPlain)

    This setBodyPlain method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->bodyPlain = $bodyPlain;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $strippedText
  4. */
  5. private function setStrippedText($strippedText)

    This setStrippedText method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->strippedText = $strippedText;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $strippedSignature
  4. */
  5. private function setStrippedSignature($strippedSignature)

    This setStrippedSignature method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->strippedSignature = $strippedSignature;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $bodyHtml
  4. */
  5. private function setBodyHtml($bodyHtml)

    This setBodyHtml method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->bodyHtml = $bodyHtml;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $strippedHtml
  4. */
  5. private function setStrippedHtml($strippedHtml)

    This setStrippedHtml method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->strippedHtml = $strippedHtml;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $attachments
  4. */
  5. private function setAttachments($attachments)

    This setAttachments method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->attachments = $attachments;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $messageUrl
  4. */
  5. private function setMessageUrl($messageUrl)

    This setMessageUrl method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->messageUrl = $messageUrl;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $messageHeaders
  4. */
  5. private function setMessageHeaders(array $messageHeaders)

    This setMessageHeaders method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->messageHeaders = $messageHeaders;
  8. }
  9. }
  1. }
  2. /**
  3. * @param string $code
  4. */
  5. private function setCode($code)

    This setCode method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->code = $code;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param string $error
  4. */
  5. private function setError($error)

    This setError method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->error = $error;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param \DateTime $createdAt
  4. */
  5. private function setCreatedAt(\DateTime $createdAt)

    This setCreatedAt method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->createdAt = $createdAt;
  8. }
  9. }
  1. }
  2. /**
  3. * @param \DateTime $createdAt
  4. */
  5. private function setCreatedAt(\DateTime $createdAt)

    This setCreatedAt method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->createdAt = $createdAt;
  8. }
  9. }
  1. }
  2. /**
  3. * @param string $tag
  4. */
  5. private function setTag($tag)

    This setTag method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->tag = $tag;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param \DateTime $createdAt
  4. */
  5. private function setCreatedAt(\DateTime $createdAt)

    This setCreatedAt method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->createdAt = $createdAt;
  8. }
  9. }
  1. private $description;
  2. /**
  3. * @var \DateTime
  4. */
  5. private $firstSeen;

    This firstSeen attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. /**
  7. * @var \DateTime
  8. */
  9. private $lastSeen;
  1. private $firstSeen;
  2. /**
  3. * @var \DateTime
  4. */
  5. private $lastSeen;

    This lastSeen attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. /**
  7. * @param string $tag
  8. * @param string $description
  9. * @param \DateTime $firstSeen
  1. }
  2. /**
  3. * @param array $bounce
  4. */
  5. private function setBounce($bounce)

    This setBounce method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->bounce = $bounce;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $deliver
  4. */
  5. private function setDeliver($deliver)

    This setDeliver method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->deliver = $deliver;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $drop
  4. */
  5. private function setDrop($drop)

    This setDrop method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->drop = $drop;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $spam
  4. */
  5. private function setSpam($spam)

    This setSpam method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->spam = $spam;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $unsubscribe
  4. */
  5. private function setUnsubscribe($unsubscribe)

    This setUnsubscribe method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->unsubscribe = $unsubscribe;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $click
  4. */
  5. private function setClick($click)

    This setClick method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->click = $click;
  8. }
  9. /**
  1. }
  2. /**
  3. * @param array $open
  4. */
  5. private function setOpen($open)

    This setOpen method is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. $this->open = $open;
  8. }
  9. }

Interfaces names should end with "Interface" 3

  • Info
  • Codestyle

More information: https://insight.sensiolabs.com/what-we-analyse/php.interface_has_no_interface_suffix

  1. use Psr\Http\Message\ResponseInterface;
  2. /**
  3. * Deserialize a PSR-7 response to something else.
  4. */
  5. interface Hydrator

    Interface Hydrator should be named HydratorInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. /**
  8. * @param ResponseInterface $response
  9. * @param string $class
  10. *
  1. namespace Mailgun\Model;
  2. /**
  3. * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  4. */
  5. interface ApiResponse

    Interface ApiResponse should be named ApiResponseInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Tobias Nyholm
  6. {
  7. /**
  8. * Create an API response object from the HTTP response from the API server.
  9. *
  10. * @param array $data
  1. namespace Mailgun\Model;
  2. /**
  3. * @author Sean Johnson <sean@mailgun.com>
  4. */
  5. interface PagingProvider

    Interface PagingProvider should be named PagingProviderInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Sean Johnson
  6. {
  7. /**
  8. * Returns the `$paging->next` URL.
  9. *
  10. * @return string

PHP code should follow PSR-1 basic coding standard 3

  • Info
  • Codestyle

More information: https://insight.sensiolabs.com/what-we-analyse/php.psr1

  1. /**
  2. * @return MessageBuilder
  3. *
  4. * @deprecated Will be removed in 3.0
  5. */
  6. public function MessageBuilder()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Garcia
  7. {
  8. return new MessageBuilder();
  9. }
  10. /**
  1. /**
  2. * @return OptInHandler
  3. *
  4. * @deprecated Will be removed in 3.0
  5. */
  6. public function OptInHandler()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Garcia
  7. {
  8. return new OptInHandler();
  9. }
  10. /**
  1. *
  2. * @return BatchMessage
  3. *
  4. * @deprecated Will be removed in 3.0
  5. */
  6. public function BatchMessage($workingDomain, $autoSend = true)

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by David Garcia
  7. {
  8. return new BatchMessage($this->restClient, $workingDomain, $autoSend);
  9. }
  10. /**