-
Notifications
You must be signed in to change notification settings - Fork 121
Allow invokable classes as predicate (solves #270) #272
base: develop
Are you sure you want to change the base?
Changes from all commits
9e228b8
2a7faac
774e9f6
fccc711
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace ZendTest\Db\TestAsset; | ||
|
||
use Zend\Db\Sql\Predicate\Like; | ||
use Zend\Db\Sql\Select; | ||
|
||
class WhereInvokable | ||
{ | ||
/** @var string */ | ||
private $value; | ||
|
||
/** | ||
* WhereInvokable constructor. | ||
* @param $value | ||
*/ | ||
public function __construct($value) | ||
{ | ||
$this->value = $value; | ||
} | ||
|
||
public function __invoke($select) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a type declaration to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class is also used for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @I3ekka I've not read the code but I usually solve 'multi-type' by introducing an interface(with or without methods). If this commends totally misses the point, ignore it :P |
||
{ | ||
$select->where->addPredicate(new Like('foo', $this->value)); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a type declaration to
$value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not add the type declaration because the
composer.json
says this module is still on php 5.5. If this is an outdated information, I'll add the type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, weird that it is still on 5.5.
develop
should be on7.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, also travis runs with an old configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@I3ekka we are going to support PHP 5.6+ with zend-db 2.9.0. We'll move to PHP 7.1 with zend-db 3.0.0