-
Notifications
You must be signed in to change notification settings - Fork 114
Allow invokable classes as predicate (solves #270) #272
base: develop
Are you sure you want to change the base?
Changes from 2 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 | ||
| { | ||
| private $value; | ||
|
Member
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. Docblock |
||
|
|
||
| /** | ||
| * WhereInvokable constructor. | ||
| * @param $value | ||
| */ | ||
| public function __construct($value) | ||
|
Member
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
Author
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. I did not add the type declaration because the
Member
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. Hmm, weird that it is still on 5.5.
Author
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. yeah, also travis runs with an old configuration
Contributor
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 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 |
||
| { | ||
| $this->value = $value; | ||
| } | ||
|
|
||
| public function __invoke($select) | ||
|
Member
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
Author
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 |
||
| { | ||
| /** @var Select $select */ | ||
| $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.
Can be simplified to
\is_callable($predicates)