Skip to content

Commit 8e19f1d

Browse files
Fix 'where' in php 7.2 (#301)
* support php 7.2 * update README.md
1 parent d278538 commit 8e19f1d

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ $aMessage = $oFolder->query()->not()->text('hello world')->get();
279279

280280
//Get all messages by custom search criteria
281281
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
282-
$aMessage = $oFolder->query()->where(["CUSTOM_FOOBAR" => "fooBar"]])->get();
282+
$aMessage = $oFolder->query()->where(["CUSTOM_FOOBAR" => "fooBar"])->get();
283283

284284
```
285285

@@ -650,7 +650,6 @@ if you're just wishing a feature ;)
650650
| getMsglist | | integer | Get the current message list |
651651
| getHeaderInfo | | object | Get the current header_info object |
652652
| getHeader | | string | Get the current raw header |
653-
| getMessageId | | string | Get the current message ID |
654653
| getMessageNo | | integer | Get the current message number |
655654
| getPriority | | integer | Get the current message priority |
656655
| getSubject | | string | Get the current subject |

src/IMAP/Query/WhereQuery.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ protected function validate_criteria($criteria) {
118118
*/
119119
public function where($criteria, $value = null) {
120120
if(is_array($criteria)){
121-
foreach($criteria as $arguments){
122-
if(count($arguments) == 1){
123-
$this->where($arguments[0]);
124-
}elseif(count($arguments) == 2){
125-
$this->where($arguments[0], $arguments[1]);
121+
foreach($criteria as $key => $value){
122+
if(is_numeric($key)){
123+
return $this->where($value);
126124
}
125+
return $this->where($key, $value);
127126
}
128127
}else{
129128
$criteria = $this->validate_criteria($criteria);

0 commit comments

Comments
 (0)