Skip to content

Commit

Permalink
Tests that callable is not a string
Browse files Browse the repository at this point in the history
  • Loading branch information
Walther Lalk committed Jul 22, 2014
1 parent 7b0db0b commit 130ad7e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Database/Expression/QueryExpression.php
Expand Up @@ -293,7 +293,7 @@ public function notIn($field, $values, $type = null) {
* @return \Cake\Database\Expression\QueryExpression
*/
public function and_($conditions, $types = []) {
if (is_callable($conditions)) {
if (!is_string($conditions) && is_callable($conditions)) {
return $conditions(new self([], $this->typeMap()->types($types)));
}
return new self($conditions, $this->typeMap()->types($types));
Expand All @@ -309,7 +309,7 @@ public function and_($conditions, $types = []) {
* @return \Cake\Database\Expression\QueryExpression
*/
public function or_($conditions, $types = []) {
if (is_callable($conditions)) {
if (!is_string($conditions) && is_callable($conditions)) {
return $conditions(new self([], $this->typeMap()->types($types), 'OR'));
}
return new self($conditions, $this->typeMap()->types($types), 'OR');
Expand Down
6 changes: 3 additions & 3 deletions src/Database/Query.php
Expand Up @@ -245,7 +245,7 @@ public function traverse(callable $visitor, array $parts = []) {
* @return $this
*/
public function select($fields = [], $overwrite = false) {
if (is_callable($fields)) {
if (!is_string($fields) && is_callable($fields)) {
$fields = $fields($this);
}

Expand Down Expand Up @@ -486,7 +486,7 @@ public function join($tables = null, $types = [], $overwrite = false) {
$t = ['table' => $t, 'conditions' => $this->newExpr()];
}

if (is_callable($t['conditions'])) {
if (!is_string($t['conditions']) && is_callable($t['conditions'])) {
$t['conditions'] = $t['conditions']($this->newExpr(), $this);
}

Expand Down Expand Up @@ -1557,7 +1557,7 @@ protected function _decorateStatement($statement) {
protected function _conjugate($part, $append, $conjunction, $types) {
$expression = $this->_parts[$part] ?: $this->newExpr();

if (is_callable($append)) {
if (!is_string($append) && is_callable($append)) {
$append = $append($this->newExpr(), $this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Model/Behavior/CounterCacheBehavior.php
Expand Up @@ -159,7 +159,7 @@ protected function _processAssociation(Event $event, Entity $entity, Association
$config = [];
}

if (is_callable($config)) {
if (!is_string($config) && is_callable($config)) {
$count = $config($event, $entity, $this->_table);
} else {
$count = $this->_getCount($config, $countConditions);
Expand Down
2 changes: 1 addition & 1 deletion src/Validation/ValidationRule.php
Expand Up @@ -155,7 +155,7 @@ public function process($value, array $providers, array $context = []) {
* @return bool True if the ValidationRule should be skipped
*/
protected function _skip($context) {
if (is_callable($this->_on)) {
if (!is_string($this->_on) && is_callable($this->_on)) {
$function = $this->_on;
return !$function($context);
}
Expand Down

0 comments on commit 130ad7e

Please sign in to comment.