1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 14:30:32 +02:00

[ticket/14972] replace all occurrences of sizeof() with the count()

PHPBB3-14972
This commit is contained in:
rxu
2017-06-28 00:58:03 +07:00
parent 67a65e3788
commit 797234e416
165 changed files with 986 additions and 986 deletions

View File

@@ -116,7 +116,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
$results[] = $row;
}
$this->cache->sql_freeresult($query_id);
$this->assertEquals($query[1], sizeof($results));
$this->assertEquals($query[1], count($results));
}
$this->cache->destroy('sql', $table);

View File

@@ -40,7 +40,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
$this->assertEquals(3, sizeof($tasks));
$this->assertEquals(3, count($tasks));
}
public function test_manager_finds_one_ready_task()

View File

@@ -67,7 +67,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
$this->assertEquals(1, sizeof($rows));
$this->assertEquals(1, count($rows));
$this->assertEquals('config2', $rows[0]['config_name']);
$db->sql_freeresult($result);

View File

@@ -92,7 +92,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
public function test_crawl_eventsmd($file, $min_version, $max_version, $events)
{
$exporter = new \phpbb\event\md_exporter(dirname(__FILE__) . '/fixtures/', null, $min_version, $max_version);
$this->assertSame(sizeof($events), $exporter->crawl_eventsmd($file, 'adm'));
$this->assertSame(count($events), $exporter->crawl_eventsmd($file, 'adm'));
$this->assertEquals($events, $exporter->get_events());
}
@@ -146,7 +146,7 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$exporter->crawl_eventsmd('docs/events.md', $filter);
$events = $exporter->crawl_file_for_events($file);
$this->assertGreaterThanOrEqual(0, sizeof($events));
$this->assertGreaterThanOrEqual(0, count($events));
$this->assertTrue($exporter->validate_events_from_file($file, $events));
}
}

View File

@@ -102,7 +102,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(2000);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
$this->assertTrue(file_exists($file->get('filename')));
$this->assertTrue($file->is_uploaded());
}
@@ -115,7 +115,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
->set_allowed_extensions(array('gif'))
->set_max_filesize(100);
$file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif');
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals(1, count($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
}
}

View File

@@ -58,7 +58,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
$this->assertGreaterThanOrEqual(
2,
sizeof($lines),
count($lines),
'Failed asserting that the version file has at least two lines.'
);

View File

@@ -15,7 +15,7 @@ class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer
{
public function flush()
{
return (sizeof($this->buffer)) ? true : false;
return (count($this->buffer)) ? true : false;
}
public function get_buffer()

View File

@@ -163,7 +163,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'order_dir' => 'ASC',
), $options));
$this->assertEquals(sizeof($expected), $notifications['unread_count']);
$this->assertEquals(count($expected), $notifications['unread_count']);
$i = 0;
foreach ($notifications['notifications'] as $notification)

View File

@@ -229,7 +229,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
// but one array_diff is not enough!
if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
if (count(array_diff($one, $two)) || count(array_diff($two, $one)))
{
// get a nice error message
$this->assertEquals($one, $two);

View File

@@ -621,7 +621,7 @@ class phpbb_database_test_connection_manager
}
// Combine all of the SETVALs into one query
if (sizeof($setval_queries))
if (count($setval_queries))
{
$queries[] = 'SELECT ' . implode(', ', $setval_queries);
}

View File

@@ -425,7 +425,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
while (sizeof($meta_refresh))
while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
$url = $match[1];
@@ -987,7 +987,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->assertEquals(
1,
sizeof($result),
count($result),
$message ?: 'Failed asserting that exactly one checkbox with name' .
" $name exists in crawler scope."
);

View File

@@ -317,7 +317,7 @@ class phpbb_ui_test_case extends phpbb_test_case
$meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
// Wait for extension to be fully enabled
while (sizeof($meta_refresh))
while (count($meta_refresh))
{
preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
$this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));

View File

@@ -173,7 +173,7 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
}
public function test_local_upload()
@@ -184,7 +184,7 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->additional_checks());
$this->assertTrue($file->move_file('../tests/upload/fixture/copies', true));
$file->remove();
@@ -198,10 +198,10 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->get('file_moved'));
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals(1, count($file->error));
}
public function test_move_existent_file_overwrite()
@@ -213,9 +213,9 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
$this->assertEquals(0, sizeof($file->error));
$this->assertEquals(0, count($file->error));
unlink($this->path . 'copies/jpg.jpg');
}

View File

@@ -66,7 +66,7 @@ class phpbb_wrapper_version_compare_test extends phpbb_test_case
'3.2-A1',
);
for ($i = 0, $size = sizeof($releases); $i < $size - 1; ++$i)
for ($i = 0, $size = count($releases); $i < $size - 1; ++$i)
{
$version1 = $releases[$i];
$version2 = $releases[$i + 1];