1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-07 16:15:22 +02:00

[ticket/17176] Update implementations to be compatible with Symfony 6.3

PHPBB3-17176
This commit is contained in:
Marc Alexander 2023-08-19 13:04:25 +02:00
parent 08160b3bc3
commit cef8aaf1a4
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
16 changed files with 40 additions and 34 deletions

@ -65,10 +65,10 @@ class resolver implements ControllerResolverInterface
* Load a controller callable
*
* @param Request $request Symfony Request object
* @return false|Callable Callable or false (fixme: method is returning an array)
* @return callable|false Callable or false
* @throws \phpbb\controller\exception
*/
public function getController(Request $request)
public function getController(Request $request): callable|false
{
$controller = $request->attributes->get('_controller');

@ -60,7 +60,7 @@ class config extends Extension
*
* @return string The alias
*/
public function getAlias()
public function getAlias(): string
{
return 'config';
}

@ -144,7 +144,7 @@ class core extends Extension
*
* @return string The alias
*/
public function getAlias()
public function getAlias(): string
{
return 'core';
}

@ -52,7 +52,7 @@ class tables extends Extension
*
* @return string The alias
*/
public function getAlias()
public function getAlias(): string
{
return 'tables';
}

@ -25,14 +25,14 @@ class http_exception extends runtime_exception implements HttpExceptionInterface
*
* @var integer
*/
private $status_code;
private int $status_code;
/**
* Additional headers to set in the response.
*
* @var array
*/
private $headers;
private array $headers;
/**
* Constructor
@ -55,7 +55,7 @@ class http_exception extends runtime_exception implements HttpExceptionInterface
/**
* {@inheritdoc}
*/
public function getStatusCode()
public function getStatusCode(): int
{
return $this->status_code;
}
@ -63,7 +63,7 @@ class http_exception extends runtime_exception implements HttpExceptionInterface
/**
* {@inheritdoc}
*/
public function getHeaders()
public function getHeaders(): array
{
return $this->headers;
}

@ -132,7 +132,7 @@ class extension_base extends Extension
*
* @return string The alias
*/
public function getAlias()
public function getAlias(): string
{
return str_replace('/', '_', $this->extension_name);
}

@ -33,7 +33,7 @@ class loader_resolver implements LoaderResolverInterface
/**
* {@inheritdoc}
*/
public function resolve($resource, $type = null)
public function resolve($resource, $type = null): false|\Symfony\Component\Config\Loader\LoaderInterface
{
/** @var \Symfony\Component\Config\Loader\LoaderInterface $loader */
foreach ($this->loaders as $loader)

@ -171,7 +171,7 @@ class router implements RouterInterface
/**
* {@inheritdoc}
*/
public function getContext()
public function getContext(): RequestContext
{
return $this->context;
}
@ -179,7 +179,7 @@ class router implements RouterInterface
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
return $this->get_generator()->generate($name, $parameters, $referenceType);
}
@ -187,7 +187,7 @@ class router implements RouterInterface
/**
* {@inheritdoc}
*/
public function match($pathinfo)
public function match(string $pathinfo): array
{
return $this->get_matcher()->match($pathinfo);
}

@ -97,7 +97,8 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
);
$mock_container = new phpbb_mock_container_builder();
$mock_container->set('cron.task_collection', []);
$task_collection = new \phpbb\di\service_collection($mock_container);
$mock_container->set('cron.task_collection', $task_collection);
$this->cron_manager = new \phpbb\cron\manager($mock_container, $routing_helper, $phpbb_root_path, $pathEx, null);
$this->cron_manager->load_tasks($tasks);

@ -74,7 +74,8 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
);
$mock_container = new phpbb_mock_container_builder();
$mock_container->set('cron.task_collection', []);
$task_collection = new \phpbb\di\service_collection($mock_container);
$mock_container->set('cron.task_collection', $task_collection);
$this->cron_manager = new \phpbb\cron\manager($mock_container, $routing_helper, $phpbb_root_path, $phpEx, null);
$this->cron_manager->load_tasks($tasks);
@ -152,7 +153,8 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
);
$mock_container = new phpbb_mock_container_builder();
$mock_container->set('cron.task_collection', []);
$task_collection = new \phpbb\di\service_collection($mock_container);
$mock_container->set('cron.task_collection', $task_collection);
$this->cron_manager = new \phpbb\cron\manager($mock_container, $routing_helper, $phpbb_root_path, $phpEx, null);
$this->cron_manager->load_tasks($tasks);
@ -199,7 +201,8 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
);
$mock_container = new phpbb_mock_container_builder();
$mock_container->set('cron.task_collection', []);
$task_collection = new \phpbb\di\service_collection($mock_container);
$mock_container->set('cron.task_collection', $task_collection);
$this->cron_manager = new \phpbb\cron\manager($mock_container, $routing_helper, $phpbb_root_path, $phpEx, null);
$this->cron_manager->load_tasks($tasks);

@ -105,7 +105,8 @@ class phpbb_cron_manager_test extends \phpbb_test_case
);
$mock_container = new phpbb_mock_container_builder();
$mock_container->set('cron.task_collection', []);
$task_collection = new \phpbb\di\service_collection($mock_container);
$mock_container->set('cron.task_collection', $task_collection);
$cron_manager = new \phpbb\cron\manager($mock_container, $routing_helper, $phpbb_root_path, $phpEx, null);
$cron_manager->load_tasks($tasks);

@ -38,6 +38,6 @@ class phpbb_functional_acp_smilies_test extends phpbb_functional_test_case
$crawler = self::submit($form);
$html = $crawler->filter('#preview')->html();
$this->assertRegexp('(<img [^>]+ alt="&gt;:D" title="&gt;:D"[^>]*>)', $html);
$this->assertRegexp('(<img [^>]+ alt=">:D" title=">:D"[^>]*>)', $html);
}
}

@ -106,6 +106,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$crawler = self::request('GET', 'app.php/foo/baz', array(), false);
$this->assert_response_html(500);
$this->assertStringContainsString('Controller "foo\bar\controller\controller::baz()" requires that you provide a value for the "$test" argument', $crawler->filter('body')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
/**

@ -134,7 +134,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
$attachment_filename = $crawler->filter('.attachment-filename');
$this->assertEquals('valid.jpg', $attachment_filename->attr('title'));
$this->assertStringContainsString('app.php/download/attachment/' . $attach_id . '/valid.jpg', $attachment_filename->attr('href'));
$this->assertEquals('', $crawler->filter('[name="attachment[' . $attach_id . ']"]')->attr('disabled'));
$this->assertFalse($crawler->filter('[name="attachment[' . $attach_id . ']"]')->getNode(0)->hasAttribute('disabled'));
}
public function test_ucp_delete_expired_attachment()
@ -219,7 +219,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
$this->assertEquals('valid.jpg', $attachment_node->attr('title'));
$this->assertStringContainsString('download/attachment/' . $attach_id . '/valid.jpg', $attachment_node->attr('href'));
$this->assertEquals('disabled', $crawler->filter('[name="attachment[' . $attach_id . ']"]')->attr('disabled'));
$this->assertTrue($crawler->filter('[name="attachment[' . $attach_id . ']"]')->getNode(0)->hasAttribute('disabled'));
// It should not be possible to delete the attachment
$crawler = self::request('POST', 'ucp.php?i=ucp_attachments&mode=attachments&sid=' . $this->sid, [
@ -238,7 +238,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
});
$this->assertEquals('valid.jpg', $attachment_node->attr('title'));
$this->assertStringContainsString('download/attachment/' . $attach_id . '/valid.jpg', $attachment_node->attr('href'));
$this->assertEquals('disabled', $crawler->filter('[name="attachment[' . $attach_id . ']"]')->attr('disabled'));
$this->assertTrue($crawler->filter('[name="attachment[' . $attach_id . ']"]')->getNode(0)->hasAttribute('disabled'));
$this->logout();
@ -327,7 +327,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
$this->assertEquals('valid.jpg', $attachment_node->attr('title'));
$this->assertStringContainsString('download/attachment/' . $attach_id . '/valid.jpg', $attachment_node->attr('href'));
$this->assertEquals('', $crawler->filter('[name="attachment[' . $attach_id . ']"]')->attr('disabled'));
$this->assertFalse($crawler->filter('[name="attachment[' . $attach_id . ']"]')->getNode(0)->hasAttribute('disabled'));
// Update message time to 60 minutes later
$sql = 'UPDATE ' . PRIVMSGS_TABLE . '
@ -347,7 +347,7 @@ class phpbb_functional_ucp_attachments_test extends phpbb_functional_test_case
$this->assertEquals('valid.jpg', $attachment_node->attr('title'));
$this->assertStringContainsString('download/attachment/' . $attach_id . '/valid.jpg', $attachment_node->attr('href'));
$this->assertEquals('disabled', $crawler->filter('[name="attachment[' . $attach_id . ']"]')->attr('disabled'));
$this->assertTrue($crawler->filter('[name="attachment[' . $attach_id . ']"]')->getNode(0)->hasAttribute('disabled'));
$this->set_flood_interval(15);

@ -56,7 +56,7 @@ class phpbb_mock_container_builder implements ContainerInterface
*
* @api
*/
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
{
if ($this->has($id))
{
@ -79,11 +79,11 @@ class phpbb_mock_container_builder implements ContainerInterface
*
* @param string $id The service identifier
*
* @return Boolean true if the service is defined, false otherwise
* @return bool true if the service is defined, false otherwise
*
* @api
*/
public function has($id)
public function has(string $id): bool
{
return isset($this->services[$id]);
}
@ -99,7 +99,7 @@ class phpbb_mock_container_builder implements ContainerInterface
*
* @api
*/
public function getParameter($name)
public function getParameter(string $name): mixed
{
if ($this->hasParameter($name))
{
@ -114,11 +114,11 @@ class phpbb_mock_container_builder implements ContainerInterface
*
* @param string $name The parameter name
*
* @return Boolean The presence of parameter in container
* @return bool The presence of parameter in container
*
* @api
*/
public function hasParameter($name)
public function hasParameter(string $name): bool
{
return isset($this->parameters[$name]);
}
@ -202,7 +202,7 @@ class phpbb_mock_container_builder implements ContainerInterface
return false;
}
public function initialized($id)
public function initialized($id): bool
{
return true;
}

@ -127,8 +127,8 @@ class phpbb_path_helper_test extends phpbb_test_case
array(
$this->phpbb_root_path . 'test.php',
'/',
null,
null,
'',
'',
'',
),
array(