diff --git a/.gitignore b/.gitignore index ddd550415..8a16021d4 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor/* composer.lock phpunit.xml +.idea \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index ab112fc18..094bbb2ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,15 +7,17 @@ env: PHPAR_MYSQL=mysql://root@127.0.0.1/phpar_test PHPAR_PGSQL=pgsql://postgres@ language: php php: - - 5.3 - 5.4 - 5.5 - 7.0 - 7.1 + - 7.2 - nightly matrix: include: + - php: 5.3 + dist: precise - php: hhvm dist: trusty allow_failures: diff --git a/lib/Model.php b/lib/Model.php index 99667b41f..b16b14960 100644 --- a/lib/Model.php +++ b/lib/Model.php @@ -1667,11 +1667,13 @@ public static function find_by_pk($values, $options) } $results = count($list); + if (!is_array($values)) + $values = array($values); + if ($results != ($expected = count($values))) { $class = get_called_class(); - if (is_array($values)) - $values = join(',',$values); + $values = join(',',$values); if ($expected == 1) { diff --git a/lib/SQLBuilder.php b/lib/SQLBuilder.php index ef239ed87..aa85ef66e 100644 --- a/lib/SQLBuilder.php +++ b/lib/SQLBuilder.php @@ -217,7 +217,7 @@ public static function create_conditions_from_underscored_string(Connection $con return null; $parts = preg_split('/(_and_|_or_)/i',$name,-1,PREG_SPLIT_DELIM_CAPTURE); - $num_values = count($values); + $num_values = is_null($values) ? 0 : count($values); $conditions = array(''); for ($i=0,$j=0,$n=count($parts); $i<$n; $i+=2,++$j) diff --git a/test/ModelCallbackTest.php b/test/ModelCallbackTest.php index 949706385..0e2c0adf8 100644 --- a/test/ModelCallbackTest.php +++ b/test/ModelCallbackTest.php @@ -26,6 +26,9 @@ public function register_and_invoke_callbacks($callbacks, $return, $closure) public function assert_fires($callbacks, $closure) { + if (!is_array($callbacks)) + $callbacks = array($callbacks); + $executed = $this->register_and_invoke_callbacks($callbacks,true,$closure); $this->assert_equals(count($callbacks),count($executed)); } diff --git a/test/helpers/AdapterTest.php b/test/helpers/AdapterTest.php index 97685f6bc..50f5d3f51 100644 --- a/test/helpers/AdapterTest.php +++ b/test/helpers/AdapterTest.php @@ -339,12 +339,12 @@ public function test_tables() public function test_query_column_info() { - $this->assert_greater_than(0,count($this->conn->query_column_info("authors"))); + $this->assert_greater_than(0,count((array) $this->conn->query_column_info("authors"))); } public function test_query_table_info() { - $this->assert_greater_than(0,count($this->conn->query_for_tables())); + $this->assert_greater_than(0,count((array) $this->conn->query_for_tables())); } public function test_query_table_info_must_return_one_field()