Skip to content

Commit 91f56fc

Browse files
committed
types checked and corrected
1 parent 04b560f commit 91f56fc

File tree

4 files changed

+45
-47
lines changed

4 files changed

+45
-47
lines changed

src/IMAP/Client.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ public function createFolder($name) {
327327
/**
328328
* Get messages from folder.
329329
*
330-
* @param Folder $folder
331-
* @param string $criteria
332-
* @param integer $fetch_options
333-
* @param boolean $fetch_body
334-
* @param boolean $fetch_attachment
330+
* @param Folder $folder
331+
* @param string $criteria
332+
* @param int|null $fetch_options
333+
* @param boolean $fetch_body
334+
* @param boolean $fetch_attachment
335335
*
336336
* @return MessageCollection
337337
* @throws ConnectionFailedException
@@ -348,11 +348,11 @@ public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options =
348348
/**
349349
* Get all unseen messages from folder
350350
*
351-
* @param Folder $folder
352-
* @param string $criteria
353-
* @param null $fetch_options
354-
* @param boolean $fetch_body
355-
* @param boolean $fetch_attachment
351+
* @param Folder $folder
352+
* @param string $criteria
353+
* @param int|null $fetch_options
354+
* @param boolean $fetch_body
355+
* @param boolean $fetch_attachment
356356
*
357357
* @return MessageCollection
358358
* @throws ConnectionFailedException
@@ -369,12 +369,12 @@ public function getUnseenMessages(Folder $folder, $criteria = 'UNSEEN', $fetch_o
369369
/**
370370
* Search messages by a given search criteria
371371
*
372-
* @param array $where
373-
* @param Folder $folder
374-
* @param null $fetch_options
375-
* @param boolean $fetch_body
376-
* @param string $charset
377-
* @param boolean $fetch_attachment
372+
* @param array $where
373+
* @param Folder $folder
374+
* @param int|null $fetch_options
375+
* @param boolean $fetch_body
376+
* @param string $charset
377+
* @param boolean $fetch_attachment
378378
*
379379
* @return MessageCollection
380380
* @throws ConnectionFailedException

src/IMAP/Folder.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_
168168
* Get all messages
169169
*
170170
* @param string $criteria
171-
* @param null $fetch_options
171+
* @param int|null $fetch_options
172172
* @param boolean $fetch_body
173173
* @param boolean $fetch_attachment
174174
*
@@ -185,7 +185,7 @@ public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_bod
185185
* Get all unseen messages
186186
*
187187
* @param string $criteria
188-
* @param null $fetch_options
188+
* @param int|null $fetch_options
189189
* @param boolean $fetch_body
190190
* @param boolean $fetch_attachment
191191
*
@@ -216,7 +216,7 @@ public function getUnseenMessages($criteria = 'UNSEEN', $fetch_options = null, $
216216
* The following sample would search for all flagged messages:
217217
* [['FLAGGED']]
218218
* ---------------------------------------------------------------------------------------
219-
* @param null $fetch_options
219+
* @param int|null $fetch_options
220220
* @param boolean $fetch_body
221221
* @param string $charset
222222
* @param boolean $fetch_attachment
@@ -321,12 +321,12 @@ protected function validateWhereStatements($statements) {
321321
'OR', 'AND',
322322
'ALL', 'ANSWERED', 'BCC', 'BEFORE', 'BODY', 'CC', 'DELETED', 'FLAGGED', 'FROM', 'KEYWORD',
323323
'NEW', 'OLD', 'ON', 'RECENT', 'SEEN', 'SINCE', 'SUBJECT', 'TEXT', 'TO',
324-
'UNANSWERED', 'UNDELETED', 'UNFLAGGED', 'UNKEYWORD', 'UNSEEN']) == false) {
324+
'UNANSWERED', 'UNDELETED', 'UNFLAGGED', 'UNKEYWORD', 'UNSEEN']) === false) {
325325
return false;
326326
}
327327
}
328328

329-
return empty($statements) == false;
329+
return empty($statements) === false;
330330
}
331331

332332
/**
@@ -375,7 +375,7 @@ protected function parseAttributes($attributes) {
375375
* @return bool
376376
*/
377377
public function delete() {
378-
$status = imap_deletemailbox($this->client->connection, $this->path);
378+
$status = imap_deletemailbox($this->client->getConnection(), $this->path);
379379
$this->client->expunge();
380380

381381
return $status;
@@ -389,7 +389,7 @@ public function delete() {
389389
* @return bool
390390
*/
391391
public function move($target_mailbox) {
392-
$status = imap_renamemailbox($this->client->connection, $this->path, $target_mailbox);
392+
$status = imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
393393
$this->client->expunge();
394394

395395
return $status;
@@ -409,7 +409,7 @@ public function move($target_mailbox) {
409409
* @return object
410410
*/
411411
public function getStatus($options) {
412-
return imap_status($this->client->connection, $this->path, $options);
412+
return imap_status($this->client->getConnection(), $this->path, $options);
413413
}
414414

415415
/**
@@ -422,7 +422,7 @@ public function getStatus($options) {
422422
* @return bool
423423
*/
424424
public function appendMessage($message, $options = null, $internal_date = null) {
425-
return imap_append($this->client->connection, $this->path, $message, $options, $internal_date);
425+
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
426426
}
427427

428428
/**

src/IMAP/Message.php

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ private function parseHeader() {
314314
$this->message_id = str_replace(['<', '>'], '', $header->message_id);
315315
}
316316
if (property_exists($header, 'Msgno')) {
317-
$this->message_no = ($this->fetch_options == FT_UID) ? trim($header->Msgno) : imap_msgno($this->client->getConnection(), trim($header->Msgno));
317+
$messageNo = (int)trim($header->Msgno);
318+
$this->message_no = ($this->fetch_options == FT_UID) ? $messageNo : imap_msgno($this->client->getConnection(), $messageNo);
318319
} else{
319320
$this->message_no = imap_msgno($this->client->getConnection(), $this->getUid());
320321
}
@@ -454,8 +455,8 @@ protected function fetchAttachment($structure, $partNumber) {
454455

455456
$oAttachment = new Attachment($this, $structure, $partNumber);
456457

457-
if ($oAttachment->getName() != null) {
458-
if ($oAttachment->getId() != null) {
458+
if ($oAttachment->getName() !== null) {
459+
if ($oAttachment->getId() !== null) {
459460
$this->attachments->put($oAttachment->getId(), $oAttachment);
460461
} else {
461462
$this->attachments->push($oAttachment);
@@ -471,9 +472,9 @@ protected function fetchAttachment($structure, $partNumber) {
471472
* @return $this
472473
*/
473474
public function setFetchOption($option) {
474-
if (is_long($option) == true) {
475+
if (is_long($option) === true) {
475476
$this->fetch_options = $option;
476-
} elseif (is_null($option) == true) {
477+
} elseif (is_null($option) === true) {
477478
$config = config('imap.options.fetch', FT_UID);
478479
$this->fetch_options = is_long($config) ? $config : 1;
479480
}
@@ -489,9 +490,9 @@ public function setFetchOption($option) {
489490
* @return $this
490491
*/
491492
public function setFetchBodyOption($option) {
492-
if (is_bool($option) == true) {
493+
if (is_bool($option)) {
493494
$this->fetch_body = $option;
494-
} elseif (is_null($option) == true) {
495+
} elseif (is_null($option)) {
495496
$config = config('imap.options.fetch_body', true);
496497
$this->fetch_body = is_bool($config) ? $config : true;
497498
}
@@ -507,9 +508,9 @@ public function setFetchBodyOption($option) {
507508
* @return $this
508509
*/
509510
public function setFetchAttachmentOption($option) {
510-
if (is_bool($option) == true) {
511+
if (is_bool($option)) {
511512
$this->fetch_attachment = $option;
512-
} elseif (is_null($option) == true) {
513+
} elseif (is_null($option)) {
513514
$config = config('imap.options.fetch_attachment', true);
514515
$this->fetch_attachment = is_bool($config) ? $config : true;
515516
}
@@ -592,10 +593,7 @@ private function getEncoding($structure) {
592593
public function moveToFolder($mailbox = 'INBOX') {
593594
$this->client->createFolder($mailbox);
594595

595-
if (imap_mail_move($this->client->getConnection(), $this->msglist, $mailbox) == true) {
596-
return true;
597-
}
598-
return false;
596+
return imap_mail_move($this->client->getConnection(), $this->msglist, $mailbox);
599597
}
600598

601599
/**
@@ -663,7 +661,7 @@ public function unsetFlag($flag) {
663661
* @return null|object|string
664662
*/
665663
public function getRawBody() {
666-
if ($this->raw_body == null) {
664+
if ($this->raw_body === null) {
667665
$this->raw_body = imap_fetchbody($this->client->getConnection(), $this->getUid(), '');
668666
}
669667

src/IMAP/Support/PaginatedCollection.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class PaginatedCollection extends Collection {
2626
/**
2727
* Paginate the current collection.
2828
*
29-
* @param int $perPage
30-
* @param null $page
31-
* @param string $pageName
29+
* @param int $perPage
30+
* @param int|null $page
31+
* @param string $pageName
3232
*
3333
* @return LengthAwarePaginator
3434
*/
@@ -46,11 +46,11 @@ public function paginate($perPage = 15, $page = null, $pageName = 'page') {
4646
/**
4747
* Create a new length-aware paginator instance.
4848
*
49-
* @param array $items
50-
* @param int $total
51-
* @param int $perPage
52-
* @param int $currentPage
53-
* @param array $options
49+
* @param array $items
50+
* @param int $total
51+
* @param int $perPage
52+
* @param int|null $currentPage
53+
* @param array $options
5454
*
5555
* @return LengthAwarePaginator
5656
*/

0 commit comments

Comments
 (0)