Skip to content

Commit 5d79675

Browse files
committed
Point to root namespace if handling native functions #279
1 parent ff75c75 commit 5d79675

File tree

6 files changed

+65
-61
lines changed

6 files changed

+65
-61
lines changed

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,21 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
66

77
## [UNRELEASED]
88
### Fixed
9-
- NaN
9+
- Point to root namespace if handling native functions #279
1010

1111
### Added
1212
- NaN
1313

14-
### Affected Classes
15-
- NaN
16-
1714
### Breaking changes
1815
- NaN
1916

17+
### Affected Classes
18+
- [Query::class](src/Query/WhereQuery.php)
19+
- [Attachment::class](src/Attachment.php)
20+
- [Client::class](src/Client.php)
21+
- [Folder::class](src/Folder.php)
22+
- [Message::class](src/Message.php)
23+
2024
## [1.4.5] - 2019-01-23
2125
### Fixed
2226
- Convert encoding of personal data struct #272

src/IMAP/Attachment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function findType() {
201201
*/
202202
protected function fetch() {
203203

204-
$content = imap_fetchbody($this->oMessage->getClient()->getConnection(), $this->oMessage->getUid(), $this->part_number, $this->oMessage->getFetchOptions() | FT_UID);
204+
$content = \imap_fetchbody($this->oMessage->getClient()->getConnection(), $this->oMessage->getUid(), $this->part_number, $this->oMessage->getFetchOptions() | FT_UID);
205205

206206
$this->content_type = $this->type.'/'.strtolower($this->structure->subtype);
207207
$this->content = $this->oMessage->decodeString($content, $this->structure->encoding);
@@ -265,7 +265,7 @@ public function save($path = null, $filename = null) {
265265
*/
266266
public function setName($name) {
267267
if($this->config['decoder']['message']['subject'] === 'utf-8') {
268-
$this->name = imap_utf8($name);
268+
$this->name = \imap_utf8($name);
269269
}else{
270270
$this->name = mb_decode_mimeheader($name);
271271
}

src/IMAP/Client.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function connect($attempts = 3) {
283283
$this->disconnect();
284284

285285
try {
286-
$this->connection = imap_open(
286+
$this->connection = \imap_open(
287287
$this->getAddress(),
288288
$this->username,
289289
$this->password,
@@ -293,7 +293,7 @@ public function connect($attempts = 3) {
293293
);
294294
$this->connected = !!$this->connection;
295295
} catch (\ErrorException $e) {
296-
$errors = imap_errors();
296+
$errors = \imap_errors();
297297
$message = $e->getMessage().'. '.implode("; ", (is_array($errors) ? $errors : array()));
298298

299299
throw new ConnectionFailedException($message);
@@ -309,8 +309,8 @@ public function connect($attempts = 3) {
309309
*/
310310
public function disconnect() {
311311
if ($this->isConnected() && $this->connection !== false && is_integer($this->connection) === false) {
312-
$this->errors = array_merge($this->errors, imap_errors() ?: []);
313-
$this->connected = !imap_close($this->connection, IMAP::CL_EXPUNGE);
312+
$this->errors = array_merge($this->errors, \imap_errors() ?: []);
313+
$this->connected = !\imap_close($this->connection, IMAP::CL_EXPUNGE);
314314
}
315315

316316
return $this;
@@ -360,7 +360,7 @@ public function getFolders($hierarchical = true, $parent_folder = null) {
360360

361361
$pattern = $parent_folder.($hierarchical ? '%' : '*');
362362

363-
$items = imap_getmailboxes($this->connection, $this->getAddress(), $pattern);
363+
$items = \imap_getmailboxes($this->connection, $this->getAddress(), $pattern);
364364
if(is_array($items)){
365365
foreach ($items as $item) {
366366
$folder = new Folder($this, $item);
@@ -399,7 +399,7 @@ public function openFolder($folder_path, $attempts = 3) {
399399
if ($this->active_folder !== $folder_path) {
400400
$this->active_folder = $folder_path;
401401

402-
imap_reopen($this->getConnection(), $folder_path, $this->getOptions(), $attempts);
402+
\imap_reopen($this->getConnection(), $folder_path, $this->getOptions(), $attempts);
403403
}
404404
}
405405

@@ -413,7 +413,7 @@ public function openFolder($folder_path, $attempts = 3) {
413413
*/
414414
public function createFolder($name, $expunge = true) {
415415
$this->checkConnection();
416-
$status = imap_createmailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
416+
$status = \imap_createmailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name));
417417
if($expunge) $this->expunge();
418418

419419
return $status;
@@ -430,7 +430,7 @@ public function createFolder($name, $expunge = true) {
430430
*/
431431
public function renameFolder($old_name, $new_name, $expunge = true) {
432432
$this->checkConnection();
433-
$status = imap_renamemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name));
433+
$status = \imap_renamemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($old_name), $this->getAddress() . \imap_utf7_encode($new_name));
434434
if($expunge) $this->expunge();
435435

436436
return $status;
@@ -446,7 +446,7 @@ public function renameFolder($old_name, $new_name, $expunge = true) {
446446
*/
447447
public function deleteFolder($name, $expunge = true) {
448448
$this->checkConnection();
449-
$status = imap_deletemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
449+
$status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name));
450450
if($expunge) $this->expunge();
451451

452452
return $status;
@@ -522,7 +522,7 @@ public function searchMessages(array $where, Folder $folder, $fetch_options = nu
522522
}
523523

524524
/**
525-
* Get option for imap_open and imap_reopen.
525+
* Get option for \imap_open and \imap_reopen.
526526
* It supports only isReadOnly feature.
527527
*
528528
* @return int
@@ -560,7 +560,7 @@ protected function getAddress() {
560560
*/
561561
public function getQuota() {
562562
$this->checkConnection();
563-
return imap_get_quota($this->getConnection(), 'user.'.$this->username);
563+
return \imap_get_quota($this->getConnection(), 'user.'.$this->username);
564564
}
565565

566566
/**
@@ -573,7 +573,7 @@ public function getQuota() {
573573
*/
574574
public function getQuotaRoot($quota_root = 'INBOX') {
575575
$this->checkConnection();
576-
return imap_get_quotaroot($this->getConnection(), $quota_root);
576+
return \imap_get_quotaroot($this->getConnection(), $quota_root);
577577
}
578578

579579
/**
@@ -584,7 +584,7 @@ public function getQuotaRoot($quota_root = 'INBOX') {
584584
*/
585585
public function countMessages() {
586586
$this->checkConnection();
587-
return imap_num_msg($this->connection);
587+
return \imap_num_msg($this->connection);
588588
}
589589

590590
/**
@@ -595,7 +595,7 @@ public function countMessages() {
595595
*/
596596
public function countRecentMessages() {
597597
$this->checkConnection();
598-
return imap_num_recent($this->connection);
598+
return \imap_num_recent($this->connection);
599599
}
600600

601601
/**
@@ -604,7 +604,7 @@ public function countRecentMessages() {
604604
* @return array
605605
*/
606606
public function getAlerts() {
607-
return imap_alerts();
607+
return \imap_alerts();
608608
}
609609

610610
/**
@@ -613,7 +613,7 @@ public function getAlerts() {
613613
* @return array
614614
*/
615615
public function getErrors() {
616-
$this->errors = array_merge($this->errors, imap_errors() ?: []);
616+
$this->errors = array_merge($this->errors, \imap_errors() ?: []);
617617

618618
return $this->errors;
619619
}
@@ -624,7 +624,7 @@ public function getErrors() {
624624
* @return string
625625
*/
626626
public function getLastError() {
627-
return imap_last_error();
627+
return \imap_last_error();
628628
}
629629

630630
/**
@@ -635,7 +635,7 @@ public function getLastError() {
635635
*/
636636
public function expunge() {
637637
$this->checkConnection();
638-
return imap_expunge($this->connection);
638+
return \imap_expunge($this->connection);
639639
}
640640

641641
/**
@@ -652,7 +652,7 @@ public function expunge() {
652652
*/
653653
public function checkCurrentMailbox() {
654654
$this->checkConnection();
655-
return imap_check($this->connection);
655+
return \imap_check($this->connection);
656656
}
657657

658658
/**
@@ -665,7 +665,7 @@ public function checkCurrentMailbox() {
665665
*/
666666
public function setTimeout($type, $timeout) {
667667
if(0 <= $type && $type <= 4) {
668-
return imap_timeout($type, $timeout);
668+
return \imap_timeout($type, $timeout);
669669
}
670670

671671
throw new InvalidImapTimeoutTypeException("Invalid imap timeout type provided.");
@@ -680,7 +680,7 @@ public function setTimeout($type, $timeout) {
680680
*/
681681
public function getTimeout($type){
682682
if(0 <= $type && $type <= 4) {
683-
return imap_timeout($type);
683+
return \imap_timeout($type);
684684
}
685685

686686
throw new InvalidImapTimeoutTypeException("Invalid imap timeout type provided.");

src/IMAP/Folder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function setChildren($children = []) {
193193
*/
194194
public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = true) {
195195
$this->client->openFolder($this->path);
196-
if (imap_msgno($this->getClient()->getConnection(), $uid) > 0) {
196+
if (\imap_msgno($this->getClient()->getConnection(), $uid) > 0) {
197197
return new Message($uid, $msglist, $this->getClient(), $fetch_options, $fetch_body, $fetch_attachment, $fetch_flags);
198198
}
199199

@@ -279,7 +279,7 @@ public function getUnseenMessages($criteria = 'UNSEEN', $fetch_options = null, $
279279
* @throws GetMessagesFailedException
280280
*
281281
* @doc http://php.net/manual/en/function.imap-search.php
282-
* imap_search() only supports IMAP2 search criterias, because the function mail_criteria() (from c-client lib)
282+
* \imap_search() only supports IMAP2 search criterias, because the function mail_criteria() (from c-client lib)
283283
* is used in ext/imap/php_imap.c for parsing the search string.
284284
* IMAP2 search criteria is defined in RFC 1176, section "tag SEARCH search_criteria".
285285
*
@@ -374,7 +374,7 @@ protected function parseAttributes($attributes) {
374374
* @throws Exceptions\ConnectionFailedException
375375
*/
376376
public function delete($expunge = true) {
377-
$status = imap_deletemailbox($this->client->getConnection(), $this->path);
377+
$status = \imap_deletemailbox($this->client->getConnection(), $this->path);
378378
if($expunge) $this->client->expunge();
379379

380380
return $status;
@@ -391,7 +391,7 @@ public function delete($expunge = true) {
391391
* @throws Exceptions\ConnectionFailedException
392392
*/
393393
public function move($target_mailbox, $expunge = true) {
394-
$status = imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
394+
$status = \imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
395395
if($expunge) $this->client->expunge();
396396

397397
return $status;
@@ -412,7 +412,7 @@ public function move($target_mailbox, $expunge = true) {
412412
* @throws Exceptions\ConnectionFailedException
413413
*/
414414
public function getStatus($options) {
415-
return imap_status($this->client->getConnection(), $this->path, $options);
415+
return \imap_status($this->client->getConnection(), $this->path, $options);
416416
}
417417

418418
/**
@@ -436,10 +436,10 @@ public function appendMessage($message, $options = null, $internal_date = null)
436436
if ($internal_date instanceof \Carbon\Carbon){
437437
$internal_date = $internal_date->format('d-M-Y H:i:s O');
438438
}
439-
return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
439+
return \imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date);
440440
}
441441

442-
return imap_append($this->client->getConnection(), $this->path, $message, $options);
442+
return \imap_append($this->client->getConnection(), $this->path, $message, $options);
443443
}
444444

445445
/**

0 commit comments

Comments
 (0)