diff --git a/backup/util/structure/base_nested_element.class.php b/backup/util/structure/base_nested_element.class.php index b48defc823533..0067410a21026 100644 --- a/backup/util/structure/base_nested_element.class.php +++ b/backup/util/structure/base_nested_element.class.php @@ -164,8 +164,8 @@ public function add_final_elements($final_elements) { } public function add_child($element) { - if (!($element instanceof base_nested_element)) { // parameter must be a base_nested_element - if (!$found = get_class($element)) { + if (!is_object($element) || !($element instanceof base_nested_element)) { // parameter must be a base_nested_element + if (!is_object($element) || !($found = get_class($element))) { $found = 'non object'; } throw new base_element_struct_exception('nestedelementincorrect', $found); diff --git a/cache/disabledlib.php b/cache/disabledlib.php index 3a83d1fd64377..2bcc1caf8ad0f 100644 --- a/cache/disabledlib.php +++ b/cache/disabledlib.php @@ -125,9 +125,10 @@ public function delete_many(array $keys, $recurse = true) { * Checks if the cache has the requested key. * * @param int|string $key Unused. + * @param bool $tryloadifpossible Unused. * @return bool */ - public function has($key) { + public function has($key, $tryloadifpossible = false) { return false; } diff --git a/filter/urltolink/filter.php b/filter/urltolink/filter.php index 211e149e8376d..b8a333e2952f8 100644 --- a/filter/urltolink/filter.php +++ b/filter/urltolink/filter.php @@ -75,6 +75,7 @@ protected function convert_urls_into_links(&$text) { //<a href="blah"> $filterignoretagsopen = array(']+?>', ']+?class="nolink"[^>]*?>'); $filterignoretagsclose = array('', ''); + $ignoretags = []; filter_save_ignore_tags($text,$filterignoretagsopen,$filterignoretagsclose,$ignoretags); // Check if we support unicode modifiers in regular expressions. Cache it. diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 280b1191be8e7..efb92a95513b6 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -843,7 +843,7 @@ public function action() { * @copyright 2010 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class navigation_node_collection implements IteratorAggregate { +class navigation_node_collection implements IteratorAggregate, Countable { /** * A multidimensional array to where the first key is the type and the second * key is the nodes key. diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index e237ba5a9aad0..fac5c37ab8e8f 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -2640,7 +2640,7 @@ class html_table { * $row2->cells = array($cell2, $cell3); * $t->data = array($row1, $row2); */ - public $data; + public $data = []; /** * @deprecated since Moodle 2.0. Styling should be in the CSS. diff --git a/lib/phpunit/classes/base_testcase.php b/lib/phpunit/classes/base_testcase.php index 231ce1f419859..54eb63fa7ed31 100644 --- a/lib/phpunit/classes/base_testcase.php +++ b/lib/phpunit/classes/base_testcase.php @@ -73,7 +73,7 @@ public static function assertTag($matcher, $actual, $message = '', $ishtml = tru public static function assertNotTag($matcher, $actual, $message = '', $ishtml = true) { $dom = PHPUnit_Util_XML::load($actual, $ishtml); $tags = self::findNodes($dom, $matcher, $ishtml); - $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; + $matched = (is_array($tags) && count($tags) > 0) && $tags[0] instanceof DOMNode; self::assertFalse($matched, $message); } diff --git a/user/tests/userlib_test.php b/user/tests/userlib_test.php index a5a68620db3f4..0168929fcc2a1 100644 --- a/user/tests/userlib_test.php +++ b/user/tests/userlib_test.php @@ -887,8 +887,8 @@ public function test_user_get_participants() { // the group and has the name 'searchforthis' and has also accessed the course in the last day. $userset = user_get_participants($course->id, $group->id, $accesssince + 1, $roleids['student'], 0, -1, 'searchforthis'); - $this->assertEquals(1, sizeof($userset)); $this->assertEquals($student1->id, $userset->current()->id); + $this->assertEquals(1, iterator_count($userset)); } /**