Skip to content

Commit b74e7a6

Browse files
committed
Point to root namespace if handling native functions Webklex#279
1 parent f887669 commit b74e7a6

File tree

6 files changed

+63
-59
lines changed

6 files changed

+63
-59
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ 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

1414
### Affected Classes
15-
- NaN
15+
- [Query::class](src/Query/WhereQuery.php)
16+
- [Attachment::class](src/Attachment.php)
17+
- [Client::class](src/Client.php)
18+
- [Folder::class](src/Folder.php)
19+
- [Message::class](src/Message.php)
1620

1721
## [1.4.5] - 2019-01-23
1822
### Fixed

src/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/Client.php

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

286286
try {
287-
$this->connection = imap_open(
287+
$this->connection = \imap_open(
288288
$this->getAddress(),
289289
$this->username,
290290
$this->password,
@@ -294,7 +294,7 @@ public function connect($attempts = 3) {
294294
);
295295
$this->connected = !!$this->connection;
296296
} catch (\ErrorException $e) {
297-
$errors = imap_errors();
297+
$errors = \imap_errors();
298298
$message = $e->getMessage().'. '.implode("; ", (is_array($errors) ? $errors : array()));
299299

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

317317
return $this;
@@ -361,7 +361,7 @@ public function getFolders($hierarchical = true, $parent_folder = null) {
361361

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

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

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

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

420420
return $status;
@@ -431,7 +431,7 @@ public function createFolder($name, $expunge = true) {
431431
*/
432432
public function renameFolder($old_name, $new_name, $expunge = true) {
433433
$this->checkConnection();
434-
$status = imap_renamemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($old_name), $this->getAddress() . imap_utf7_encode($new_name));
434+
$status = \imap_renamemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($old_name), $this->getAddress() . \imap_utf7_encode($new_name));
435435
if($expunge) $this->expunge();
436436

437437
return $status;
@@ -447,7 +447,7 @@ public function renameFolder($old_name, $new_name, $expunge = true) {
447447
*/
448448
public function deleteFolder($name, $expunge = true) {
449449
$this->checkConnection();
450-
$status = imap_deletemailbox($this->getConnection(), $this->getAddress() . imap_utf7_encode($name));
450+
$status = \imap_deletemailbox($this->getConnection(), $this->getAddress() . \imap_utf7_encode($name));
451451
if($expunge) $this->expunge();
452452

453453
return $status;
@@ -523,7 +523,7 @@ public function searchMessages(array $where, Folder $folder, $fetch_options = nu
523523
}
524524

525525
/**
526-
* Get option for imap_open and imap_reopen.
526+
* Get option for \imap_open and \imap_reopen.
527527
* It supports only isReadOnly feature.
528528
*
529529
* @return int
@@ -561,7 +561,7 @@ protected function getAddress() {
561561
*/
562562
public function getQuota() {
563563
$this->checkConnection();
564-
return imap_get_quota($this->getConnection(), 'user.'.$this->username);
564+
return \imap_get_quota($this->getConnection(), 'user.'.$this->username);
565565
}
566566

567567
/**
@@ -574,7 +574,7 @@ public function getQuota() {
574574
*/
575575
public function getQuotaRoot($quota_root = 'INBOX') {
576576
$this->checkConnection();
577-
return imap_get_quotaroot($this->getConnection(), $quota_root);
577+
return \imap_get_quotaroot($this->getConnection(), $quota_root);
578578
}
579579

580580
/**
@@ -585,7 +585,7 @@ public function getQuotaRoot($quota_root = 'INBOX') {
585585
*/
586586
public function countMessages() {
587587
$this->checkConnection();
588-
return imap_num_msg($this->connection);
588+
return \imap_num_msg($this->connection);
589589
}
590590

591591
/**
@@ -596,7 +596,7 @@ public function countMessages() {
596596
*/
597597
public function countRecentMessages() {
598598
$this->checkConnection();
599-
return imap_num_recent($this->connection);
599+
return \imap_num_recent($this->connection);
600600
}
601601

602602
/**
@@ -605,7 +605,7 @@ public function countRecentMessages() {
605605
* @return array
606606
*/
607607
public function getAlerts() {
608-
return imap_alerts();
608+
return \imap_alerts();
609609
}
610610

611611
/**
@@ -614,7 +614,7 @@ public function getAlerts() {
614614
* @return array
615615
*/
616616
public function getErrors() {
617-
$this->errors = array_merge($this->errors, imap_errors() ?: []);
617+
$this->errors = array_merge($this->errors, \imap_errors() ?: []);
618618

619619
return $this->errors;
620620
}
@@ -625,7 +625,7 @@ public function getErrors() {
625625
* @return string
626626
*/
627627
public function getLastError() {
628-
return imap_last_error();
628+
return \imap_last_error();
629629
}
630630

631631
/**
@@ -636,7 +636,7 @@ public function getLastError() {
636636
*/
637637
public function expunge() {
638638
$this->checkConnection();
639-
return imap_expunge($this->connection);
639+
return \imap_expunge($this->connection);
640640
}
641641

642642
/**
@@ -653,7 +653,7 @@ public function expunge() {
653653
*/
654654
public function checkCurrentMailbox() {
655655
$this->checkConnection();
656-
return imap_check($this->connection);
656+
return \imap_check($this->connection);
657657
}
658658

659659
/**
@@ -666,7 +666,7 @@ public function checkCurrentMailbox() {
666666
*/
667667
public function setTimeout($type, $timeout) {
668668
if(0 <= $type && $type <= 4) {
669-
return imap_timeout($type, $timeout);
669+
return \imap_timeout($type, $timeout);
670670
}
671671

672672
throw new InvalidImapTimeoutTypeException("Invalid imap timeout type provided.");
@@ -681,7 +681,7 @@ public function setTimeout($type, $timeout) {
681681
*/
682682
public function getTimeout($type){
683683
if(0 <= $type && $type <= 4) {
684-
return imap_timeout($type);
684+
return \imap_timeout($type);
685685
}
686686

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

src/Folder.php

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

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

381381
return $status;
@@ -392,7 +392,7 @@ public function delete($expunge = true) {
392392
* @throws Exceptions\ConnectionFailedException
393393
*/
394394
public function move($target_mailbox, $expunge = true) {
395-
$status = imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
395+
$status = \imap_renamemailbox($this->client->getConnection(), $this->path, $target_mailbox);
396396
if($expunge) $this->client->expunge();
397397

398398
return $status;
@@ -413,7 +413,7 @@ public function move($target_mailbox, $expunge = true) {
413413
* @throws Exceptions\ConnectionFailedException
414414
*/
415415
public function getStatus($options) {
416-
return imap_status($this->client->getConnection(), $this->path, $options);
416+
return \imap_status($this->client->getConnection(), $this->path, $options);
417417
}
418418

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

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

446446
/**

0 commit comments

Comments
 (0)