Compare commits

...

23 commits

Author SHA1 Message Date
rxu
0066d53c08
[ticket/17496] Fix recently added changes
PHPBB-17496
2025-05-02 22:48:59 +07:00
rxu
1b08a74508
[ticket/17496] Sniffer to support question mark nullable type syntax
PHPBB-17496
2025-05-02 22:48:59 +07:00
rxu
a5113d7cd3
[ticket/17496] Correctly restore willReturn()
PHPBB-17496
2025-05-02 22:48:59 +07:00
rxu
0f94e1cb13
[ticket/17496] Fix tests
PHPBB-17496
2025-05-02 22:48:58 +07:00
rxu
c6dcf474d3
[ticket/17496] Upgrade to the most recent GuzzleHTTP 7.9
PHPBB-17496
2025-05-02 22:48:58 +07:00
rxu
d0cb7d6389
[ticket/17496] Fix tests
PHPUnit will automatically create a test double
of required return type to be returned

PHPBB-17496
2025-05-02 22:48:57 +07:00
rxu
118ab73c37
[ticket/17496] Upgrade to GuzzleHTTP 7.8 as PHP 8.4-compatible
PHPBB-17496
2025-05-02 22:48:57 +07:00
rxu
91aaadbc6d
[ticket/17496] Unused use statements sniffer to check union types
PHPBB-17496
2025-05-02 22:48:57 +07:00
rxu
7d1ae5bf19
[ticket/17496] Fix Implicitly marking parameters as nullable PHP deprecations
Also use union types consistently instead of question marks.
Fixed with php-cs-fixer.

PHPBB-17496
2025-05-02 22:48:46 +07:00
Marc Alexander
bdbd0be548
Merge branch '3.3.x' 2025-05-02 08:32:19 +02:00
Marc Alexander
1b2ac50cfd
Merge pull request #6810 from rxu/ticket/17504
[ticket/17504] Fix tests failure caused by ondrej/php PPA repo label changed
2025-04-28 21:17:23 +02:00
rxu
779bec5fcf
[ticket/17504] Run apt-get update on runner lever rather than in bash scripts
PHPBB-17504
2025-04-28 23:28:05 +07:00
rxu
f512af1823
[ticket/17504] Fix tests
Fix the following apt-get update issue with ondrej/php PPA repo:
Repository 'https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease'
changed its 'Label' value from '***** The main PPA for supported PHP versions
with many PECL extensions *****' to 'PPA for PHP'

Alternative fix might be: sudo apt update && sudo apt full-upgrade -y

PHPBB-17504
2025-04-28 21:17:57 +07:00
Marc Alexander
bc1e1732cf
Merge pull request #6809 from marc1706/ticket/17503
[ticket/17503] Update composer dependencies to latest versions
2025-04-26 08:43:46 +02:00
Marc Alexander
ee889ac98b Merge branch '3.3.x' 2025-04-26 06:34:28 +00:00
Marc Alexander
b7d2243f6c
Merge pull request #6808 from rxu/ticket/16941-master
[ticket/16941] Add sphinx tests - master
2025-04-26 08:34:14 +02:00
Marc Alexander
59e8875fa8
Merge pull request #6807 from rxu/ticket/16941
[ticket/16941] Add sphinx tests to 3.3.x
2025-04-26 08:34:09 +02:00
rxu
f11512b580
Merge branch 'ticket/16941' into ticket/16941-master 2025-04-25 22:12:50 +07:00
rxu
1ae9a49811
[ticket/16941] Remove ending slash from binlog_path
PHPBB3-14401
2025-04-25 21:28:36 +07:00
Marc Alexander
5ef1a40083
[ticket/17503] Update lock to latest composer format
PHPBB-17503
2025-04-24 21:45:53 +02:00
Marc Alexander
d95437682e
[ticket/17503] Update composer to its latest version
PHPBB-17503
2025-04-24 21:45:17 +02:00
Marc Alexander
99ffd9205f
[ticket/17503] Update composer dependencies to their latest versions
PHPBB-17503
2025-04-24 21:44:43 +02:00
rxu
80a08d9c54
[ticket/16941] Add sphinx tests to 3.3.x
Also adjust Sphinx keywords splitting to be consistent with other search
backends when it comes to handling hyphen (like ignoring hyphen when it hasn't
NOT meaning and ignoring hyphen wrapped with "plus" signs)

PHPBB3-16941
2025-04-24 23:17:26 +07:00
80 changed files with 604 additions and 426 deletions

View file

@ -10,5 +10,4 @@
#
set -e
sudo apt-get update
sudo apt-get install -y parallel libimage-exiftool-perl

View file

@ -11,7 +11,6 @@
set -e
set -x
sudo apt-get update
sudo apt-get install -q -y sphinxsearch
DIR=$(dirname "$0")
@ -135,7 +134,7 @@ searchd
read_timeout = 5
max_children = 30
pid_file = $SPHINX_DATA_DIR/searchd.pid
binlog_path = $SPHINX_DATA_DIR/
binlog_path = $SPHINX_DATA_DIR
}
" > $SPHINX_CONF

View file

@ -10,5 +10,4 @@
#
set -e
sudo apt-get update
sudo apt-get install -y expect-dev

View file

@ -11,7 +11,6 @@
set -e
set -x
sudo apt-get update
sudo apt-get install -y nginx coreutils
sudo service nginx stop

View file

@ -28,6 +28,10 @@ jobs:
name: PHP ${{ matrix.php }} - ${{ matrix.db }}
steps:
- name: Update Ubuntu package lists
run: |
sudo apt-get update -y --allow-releaseinfo-change
- name: Checkout repository
uses: actions/checkout@v4
with:
@ -169,6 +173,10 @@ jobs:
- 6379:6379
steps:
- name: Update Ubuntu package lists
run: |
sudo apt-get update -y --allow-releaseinfo-change
- name: Checkout repository
uses: actions/checkout@v4
@ -308,6 +316,10 @@ jobs:
- 6379:6379
steps:
- name: Update Ubuntu package lists
run: |
sudo apt-get update -y --allow-releaseinfo-change
- name: Checkout repository
uses: actions/checkout@v4
@ -412,6 +424,10 @@ jobs:
steps:
- name: Update Ubuntu package lists
run: |
sudo apt-get update -y --allow-releaseinfo-change
- name: Checkout repository
uses: actions/checkout@v4

View file

@ -49,9 +49,20 @@ class phpbb_Sniffs_Namespaces_UnusedUseSniff implements Sniff
$phpcsFile->addError($error, $stack_pointer, 'FullName');
}
if ($found_name === $short_name)
/*
* Check for possible union types (like string|MyType|null)
* and question mark nullable type syntax (like ?MyType)
*/
$types = explode('|', $found_name);
foreach ($types as $type)
{
return true;
// Nullable type syntax
$type = (strpos($type, '?') === 0) ? substr($type, 1) : $type;
if ($short_name === $type)
{
return true;
}
}
return false;

Binary file not shown.

View file

@ -39,7 +39,7 @@
"composer/package-versions-deprecated": "^1.11",
"doctrine/dbal": "~3.3.6",
"google/recaptcha": "~1.1",
"guzzlehttp/guzzle": "~6.3",
"guzzlehttp/guzzle": " ^7.0",
"marc1706/fast-image-size": "^1.1",
"minishlink/web-push": "^8.0",
"s9e/text-formatter": "^2.0",

703
phpBB/composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -130,7 +130,7 @@ function phpbb_gmgetdate($time = false)
*
* @return array|string data array if $string_only is false
*/
function get_formatted_filesize($value, bool $string_only = true, array $allowed_units = null)
function get_formatted_filesize($value, bool $string_only = true, array|null $allowed_units = null)
{
global $user;
@ -253,7 +253,7 @@ function still_on_time($extra_time = 15)
* @return mixed Boolean (true, false) if comparison operator is specified.
* Integer (-1, 0, 1) otherwise.
*/
function phpbb_version_compare(string $version1, string $version2, string $operator = null)
function phpbb_version_compare(string $version1, string $version2, string|null $operator = null)
{
$version1 = strtolower($version1);
$version2 = strtolower($version2);

View file

@ -215,7 +215,7 @@ function adm_back_link($u_action)
*
* @return array
*/
function build_select(array $options_ary, int|string|bool $option_default = false): array
function build_select(array $options_ary, bool|int|string $option_default = false): array
{
global $language;

View file

@ -82,7 +82,7 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
* @param \phpbb\path_helper $path_helper phpBB path helper
* @param \phpbb\cache\driver\driver_interface|null $cache Cache driver
*/
public function __construct(\phpbb\config\config $config, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
public function __construct(\phpbb\config\config $config, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface|null $cache = null)
{
$this->config = $config;
$this->imagesize = $imagesize;

View file

@ -28,7 +28,7 @@ class email extends base
/**
* {@inheritDoc}
*/
public function get_user_column(): ?string
public function get_user_column(): string|null
{
return 'user_email';
}

View file

@ -31,7 +31,7 @@ class ip extends base
/**
* @inheritDoc
*/
public function get_user_column(): ?string
public function get_user_column(): string|null
{
return null;
}

View file

@ -33,7 +33,7 @@ interface type_interface
*
* @return string|null
*/
public function get_user_column(): ?string;
public function get_user_column(): string|null;
/**
* Sets a user object to the ban type to have it excluded

View file

@ -48,7 +48,7 @@ class class_loader
* @param string $php_ext The file extension for PHP files
* @param \phpbb\cache\driver\driver_interface|null $cache An implementation of the phpBB cache interface.
*/
public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null)
public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface|null $cache = null)
{
if ($namespace[0] !== '\\')
{
@ -69,7 +69,7 @@ class class_loader
*
* @param \phpbb\cache\driver\driver_interface|null $cache An implementation of the phpBB cache interface.
*/
public function set_cache(\phpbb\cache\driver\driver_interface $cache = null)
public function set_cache(\phpbb\cache\driver\driver_interface|null $cache = null)
{
if ($cache)
{

View file

@ -29,7 +29,7 @@ class runtime_exception extends base
* @param \Exception|null $previous The previous runtime_exception used for the runtime_exception chaining.
* @param integer $code The Exception code.
*/
public function __construct($prefix, $message = '', array $parameters = [], \Exception $previous = null, $code = 0)
public function __construct($prefix, $message = '', array $parameters = [], \Exception|null $previous = null, $code = 0)
{
parent::__construct($prefix . $message, $parameters, $previous, $code);
}

View file

@ -68,7 +68,7 @@ class extension_manager extends manager
* @param string $root_path phpBB root path
* @param config|null $config Config object
*/
public function __construct(installer $installer, driver_interface $cache, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix, $root_path, config $config = null)
public function __construct(installer $installer, driver_interface $cache, ext_manager $extension_manager, filesystem $filesystem, $package_type, $exception_prefix, $root_path, config|null $config = null)
{
$this->extension_manager = $extension_manager;
$this->filesystem = $filesystem;
@ -86,7 +86,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
public function pre_install(array $packages, IOInterface $io = null)
public function pre_install(array $packages, IOInterface|null $io = null)
{
$installed_manually = array_intersect(array_keys($this->extension_manager->all_available()), array_keys($packages));
if (count($installed_manually) !== 0)
@ -98,7 +98,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
public function post_install(array $packages, IOInterface $io = null)
public function post_install(array $packages, IOInterface|null $io = null)
{
if ($this->enable_on_install)
{
@ -127,7 +127,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
protected function pre_update(array $packages, IOInterface $io = null)
protected function pre_update(array $packages, IOInterface|null $io = null)
{
/** @psalm-suppress InvalidArgument */
$io->writeError([['DISABLING_EXTENSIONS', [], 1]]);
@ -158,7 +158,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
protected function post_update(array $packages, IOInterface $io = null)
protected function post_update(array $packages, IOInterface|null $io = null)
{
/** @psalm-suppress InvalidArgument */
$io->writeError([['ENABLING_EXTENSIONS', [], 1]]);
@ -184,7 +184,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
public function remove(array $packages, IOInterface $io = null)
public function remove(array $packages, IOInterface|null $io = null)
{
$packages = $this->normalize_version($packages);
@ -200,7 +200,7 @@ class extension_manager extends manager
/**
* {@inheritdoc}
*/
public function pre_remove(array $packages, IOInterface $io = null)
public function pre_remove(array $packages, IOInterface|null $io = null)
{
if ($this->purge_on_remove)
{

View file

@ -101,7 +101,7 @@ class installer
* @param request $request phpBB request object
* @param config|null $config Config object
*/
public function __construct($root_path, filesystem $filesystem, request $request, config $config = null)
public function __construct($root_path, filesystem $filesystem, request $request, config|null $config = null)
{
if ($config)
{
@ -135,7 +135,7 @@ class installer
*
* @throws runtime_exception
*/
public function install(array $packages, $whitelist, IOInterface $io = null)
public function install(array $packages, $whitelist, IOInterface|null $io = null)
{
$this->wrap(function() use ($packages, $whitelist, $io) {
$this->do_install($packages, $whitelist, $io);
@ -155,7 +155,7 @@ class installer
* @throws runtime_exception
* @throws JsonValidationException
*/
protected function do_install(array $packages, $whitelist, io\io_interface $io = null)
protected function do_install(array $packages, $whitelist, io\io_interface|null $io = null)
{
if (!$io)
{
@ -232,7 +232,7 @@ class installer
* @return Composer|PartialComposer
* @throws JsonValidationException
*/
protected function get_composer(?string $config_file): PartialComposer
protected function get_composer(string|null $config_file): PartialComposer
{
static $composer_factory;
if (!$composer_factory)

View file

@ -46,7 +46,7 @@ class html_output_formatter extends \Composer\Console\HtmlOutputFormatter
/**
* {@inheritdoc}
*/
public function format(?string $message): ?string
public function format(string|null $message): string|null
{
$formatted = parent::format($message);

View file

@ -28,7 +28,7 @@ class web_io extends BufferIO implements io_interface
* @param int $verbosity Verbosity level
* @param OutputFormatterInterface|null $formatter Output formatter
*/
public function __construct(language $language, $input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
public function __construct(language $language, $input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface|null $formatter = null)
{
$this->language = $language;

View file

@ -74,7 +74,7 @@ class manager implements manager_interface
/**
* {@inheritdoc}
*/
public function install(array $packages, IOInterface $io = null)
public function install(array $packages, IOInterface|null $io = null)
{
$packages = $this->normalize_version($packages);
@ -103,7 +103,7 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function pre_install(array $packages, IOInterface $io = null)
protected function pre_install(array $packages, IOInterface|null $io = null)
{
}
@ -114,14 +114,14 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function post_install(array $packages, IOInterface $io = null)
protected function post_install(array $packages, IOInterface|null $io = null)
{
}
/**
* {@inheritdoc}
*/
public function update(array $packages, IOInterface $io = null)
public function update(array $packages, IOInterface|null $io = null)
{
$packages = $this->normalize_version($packages);
@ -148,7 +148,7 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function pre_update(array $packages, IOInterface $io = null)
protected function pre_update(array $packages, IOInterface|null $io = null)
{
}
@ -159,14 +159,14 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function post_update(array $packages, IOInterface $io = null)
protected function post_update(array $packages, IOInterface|null $io = null)
{
}
/**
* {@inheritdoc}
*/
public function remove(array $packages, IOInterface $io = null)
public function remove(array $packages, IOInterface|null $io = null)
{
$packages = $this->normalize_version($packages);
@ -195,7 +195,7 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function pre_remove(array $packages, IOInterface $io = null)
protected function pre_remove(array $packages, IOInterface|null $io = null)
{
}
@ -206,7 +206,7 @@ class manager implements manager_interface
* Each entry may be a name or an array associating a version constraint to a name
* @param IOInterface|null $io IO object used for the output
*/
protected function post_remove(array $packages, IOInterface $io = null)
protected function post_remove(array $packages, IOInterface|null $io = null)
{
}

View file

@ -30,7 +30,7 @@ interface manager_interface
*
* @throws runtime_exception
*/
public function install(array $packages, IOInterface $io = null);
public function install(array $packages, IOInterface|null $io = null);
/**
* Updates or installs a set of packages
@ -41,7 +41,7 @@ interface manager_interface
*
* @throws runtime_exception
*/
public function update(array $packages, IOInterface $io = null);
public function update(array $packages, IOInterface|null $io = null);
/**
* Removes a set of packages
@ -52,7 +52,7 @@ interface manager_interface
*
* @throws runtime_exception
*/
public function remove(array $packages, IOInterface $io = null);
public function remove(array $packages, IOInterface|null $io = null);
/**
* Tells whether or not a package is managed by Composer.

View file

@ -53,7 +53,7 @@ class resolver implements ControllerResolverInterface
* @param string $phpbb_root_path Relative path to phpBB root
* @param \phpbb\template\template|null $template
*/
public function __construct(ContainerInterface $container, $phpbb_root_path, \phpbb\template\template $template = null)
public function __construct(ContainerInterface $container, $phpbb_root_path, \phpbb\template\template|null $template = null)
{
$this->container = $container;
$this->template = $template;

View file

@ -42,7 +42,7 @@ class datetime extends \DateTime
* @param string $time String in a format accepted by strtotime().
* @param \DateTimeZone|null $timezone Time zone of the time.
*/
public function __construct($user, $time = 'now', \DateTimeZone $timezone = null)
public function __construct($user, $time = 'now', \DateTimeZone|null $timezone = null)
{
$this->user = $user;
$timezone = $timezone ?: $this->user->timezone;

View file

@ -73,10 +73,10 @@ class connection_factory
public static function get_connection_from_params(
string $driver,
string $host,
?string $user = null,
?string $password = null,
?string $name = null,
?string $port = null): Connection
string|null $user = null,
string|null $password = null,
string|null $name = null,
string|null $port = null): Connection
{
$available_drivers = DriverManager::getAvailableDrivers();
if (!in_array($driver, $available_drivers))

View file

@ -37,11 +37,11 @@ class connection_parameter_factory
*/
public static function get_configuration(
string $driver,
?string $host = null,
?string $user = null,
?string $password = null,
?string $name = null,
?string $port = null) : array
string|null $host = null,
string|null $user = null,
string|null $password = null,
string|null $name = null,
string|null $port = null) : array
{
$params = [
'driver' => $driver,
@ -73,11 +73,11 @@ class connection_parameter_factory
*/
private static function build_connection_parameters(
array $params,
?string $host = null,
?string $user = null,
?string $password = null,
?string $name = null,
?string $port = null) : array
string|null $host = null,
string|null $user = null,
string|null $password = null,
string|null $name = null,
string|null $port = null) : array
{
if ($params['driver'] === 'pdo_sqlite')
{
@ -120,7 +120,7 @@ class connection_parameter_factory
*
* @return array Doctrine's DBAL configuration for SQLite.
*/
private static function build_sqlite_parameters(array $params, string $path, ?string $user, ?string $password) : array
private static function build_sqlite_parameters(array $params, string $path, string|null $user, string|null $password) : array
{
$params['path'] = $path;

View file

@ -29,7 +29,7 @@ abstract class container_aware_migration extends migration implements ContainerA
/**
* {@inheritdoc}
*/
public function setContainer(ContainerInterface $container = null)
public function setContainer(ContainerInterface|null $container = null)
{
$this->container = $container;
}

View file

@ -101,7 +101,7 @@ class remove_jabber extends migration
];
}
public function move_jabber_to_email_notifications(?int $start)
public function move_jabber_to_email_notifications(int|null $start)
{
$limit = 1000;

View file

@ -240,7 +240,7 @@ class schema_generator
* @param mixed $data Array of values to be set.
* @param callable|null $value_transform Callback to transform the value being set.
*/
private static function set_all(&$schema, $data, ?callable $value_transform = null)
private static function set_all(&$schema, $data, callable|null $value_transform = null)
{
$data = (!is_array($data)) ? [$data] : $data;
foreach ($data as $key => $change)
@ -317,7 +317,7 @@ class schema_generator
*
* @return Closure|null The value transformation callback or null if it is not needed.
*/
private static function get_value_transform(string $change_type, string $schema_type) : ?Closure
private static function get_value_transform(string $change_type, string $schema_type) : Closure|null
{
if ($change_type !== 'add')
{

View file

@ -24,7 +24,7 @@ class error_handler extends ErrorHandler
/**
* @psalm-suppress MethodSignatureMismatch
*/
public function __construct(BufferingLogger $bootstrappingLogger = null, private readonly bool $debug = false) // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
public function __construct(BufferingLogger|null $bootstrappingLogger = null, private readonly bool $debug = false) // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod.Found
{
parent::__construct($bootstrappingLogger, $debug);
}

View file

@ -52,7 +52,7 @@ class dispatcher extends EventDispatcher implements dispatcher_interface
/**
* {@inheritdoc}
*/
public function dispatch(object $event, string $eventName = null) : object
public function dispatch(object $event, string|null $eventName = null) : object
{
if ($this->disabled)
{

View file

@ -39,7 +39,7 @@ class recursive_event_filter_iterator extends \RecursiveFilterIterator
*
* @return recursive_event_filter_iterator
*/
public function getChildren(): ?\RecursiveFilterIterator
public function getChildren(): \RecursiveFilterIterator|null
{
$inner_iterator = $this->getInnerIterator();
assert($inner_iterator instanceof \RecursiveIterator);

View file

@ -44,7 +44,7 @@ class http_exception extends runtime_exception implements HttpExceptionInterface
* @param array $headers Additional headers to set in the response.
* @param integer $code The Exception code.
*/
public function __construct($status_code, $message = "", array $parameters = array(), \Exception $previous = null, array $headers = array(), $code = 0)
public function __construct($status_code, $message = "", array $parameters = array(), \Exception|null $previous = null, array $headers = array(), $code = 0)
{
$this->status_code = $status_code;
$this->headers = $headers;

View file

@ -35,7 +35,7 @@ class runtime_exception extends \RuntimeException implements exception_interface
* @param \Exception|null $previous The previous runtime_exception used for the runtime_exception chaining.
* @param integer $code The Exception code.
*/
public function __construct($message = "", array $parameters = array(), \Exception $previous = null, $code = 0)
public function __construct($message = "", array $parameters = array(), \Exception|null $previous = null, $code = 0)
{
$this->parameters = $parameters;

View file

@ -47,7 +47,7 @@ class manager
* @param \phpbb\cache\service|null $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext
*/
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, finder_factory $finder_factory, $extension_table, $phpbb_root_path, \phpbb\cache\service $cache = null, $cache_name = '_ext')
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, finder_factory $finder_factory, $extension_table, $phpbb_root_path, \phpbb\cache\service|null $cache = null, $cache_name = '_ext')
{
$this->cache = $cache;
$this->cache_name = $cache_name;

View file

@ -15,7 +15,7 @@ namespace phpbb\feed\exception;
class no_feed_exception extends feed_unavailable_exception
{
public function __construct(\Exception $previous = null, $code = 0)
public function __construct(\Exception|null $previous = null, $code = 0)
{
parent::__construct('NO_FEED', array(), $previous, $code);
}

View file

@ -15,7 +15,7 @@ namespace phpbb\feed\exception;
class no_forum_exception extends feed_unavailable_exception
{
public function __construct($forum_id, \Exception $previous = null, $code = 0)
public function __construct($forum_id, \Exception|null $previous = null, $code = 0)
{
parent::__construct('NO_FORUM', array($forum_id), $previous, $code);
}

View file

@ -15,7 +15,7 @@ namespace phpbb\feed\exception;
class no_topic_exception extends feed_unavailable_exception
{
public function __construct($topic_id, \Exception $previous = null, $code = 0)
public function __construct($topic_id, \Exception|null $previous = null, $code = 0)
{
parent::__construct('NO_TOPIC', array($topic_id), $previous, $code);
}

View file

@ -15,7 +15,7 @@ namespace phpbb\feed\exception;
class unauthorized_forum_exception extends unauthorized_exception
{
public function __construct($forum_id, \Exception $previous = null, $code = 0)
public function __construct($forum_id, \Exception|null $previous = null, $code = 0)
{
parent::__construct('SORRY_AUTH_READ', array($forum_id), $previous, $code);
}

View file

@ -15,7 +15,7 @@ namespace phpbb\feed\exception;
class unauthorized_topic_exception extends unauthorized_exception
{
public function __construct($topic_id, \Exception $previous = null, $code = 0)
public function __construct($topic_id, \Exception|null $previous = null, $code = 0)
{
parent::__construct('SORRY_AUTH_READ_TOPIC', array($topic_id), $previous, $code);
}

View file

@ -103,7 +103,7 @@ class filespec
* @param \phpbb\mimetype\guesser|null $mimetype_guesser Mime type guesser
* @param \phpbb\plupload\plupload|null $plupload Plupload
*/
public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
public function __construct(\phpbb\filesystem\filesystem_interface $phpbb_filesystem, language $language, \bantu\IniGetWrapper\IniGetWrapper $php_ini, \FastImageSize\FastImageSize $imagesize, $phpbb_root_path, \phpbb\mimetype\guesser|null $mimetype_guesser = null, \phpbb\plupload\plupload|null $plupload = null)
{
$this->filesystem = $phpbb_filesystem;
$this->language = $language;

View file

@ -86,7 +86,7 @@ class filespec_storage
* @param \phpbb\mimetype\guesser|null $mimetype_guesser Mime type guesser
* @param \phpbb\plupload\plupload|null $plupload Plupload
*/
public function __construct(language $language, \FastImageSize\FastImageSize $imagesize, \phpbb\mimetype\guesser $mimetype_guesser = null, \phpbb\plupload\plupload $plupload = null)
public function __construct(language $language, \FastImageSize\FastImageSize $imagesize, \phpbb\mimetype\guesser|null $mimetype_guesser = null, \phpbb\plupload\plupload|null $plupload = null)
{
$this->language = $language;
$this->imagesize = $imagesize;

View file

@ -26,7 +26,7 @@ class filesystem_exception extends runtime_exception
* @param \Exception|null $previous The previous runtime_exception used for the runtime_exception chaining.
* @param integer $code The Exception code.
*/
public function __construct($message = '', $filename = '', $parameters = array(), \Exception $previous = null, $code = 0)
public function __construct($message = '', $filename = '', $parameters = array(), \Exception|null $previous = null, $code = 0)
{
parent::__construct($message, array_merge(array('filename' => $filename), $parameters), $previous, $code);
}

View file

@ -293,7 +293,7 @@ class filesystem implements filesystem_interface
/**
* {@inheritdoc}
*/
public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array())
public function mirror($origin_dir, $target_dir, \Traversable|null $iterator = null, $options = array())
{
try
{

View file

@ -190,7 +190,7 @@ interface filesystem_interface
* The filename which triggered the error can be
* retrieved by filesystem_exception::get_filename()
*/
public function mirror($origin_dir, $target_dir, \Traversable $iterator = null, $options = array());
public function mirror($origin_dir, $target_dir, \Traversable|null $iterator = null, $options = array());
/**
* Creates a directory recursively.

View file

@ -33,7 +33,7 @@ class factory
* @param string $phpbb_root_path Path to the phpbb root directory
* @param string $php_ext php file extension
*/
public function __construct(?service $cache, bool $use_cache, string $phpbb_root_path, string $php_ext)
public function __construct(service|null $cache, bool $use_cache, string $phpbb_root_path, string $php_ext)
{
$this->cache = $cache;
$this->use_cache = $use_cache;

View file

@ -58,7 +58,7 @@ class finder
* @param string $cache_name The name of the cache variable, defaults to
* _ext_finder
*/
public function __construct(?service $cache, bool $use_cache, string $phpbb_root_path, string $php_ext, string $cache_name = '_ext_finder')
public function __construct(service|null $cache, bool $use_cache, string $phpbb_root_path, string $php_ext, string $cache_name = '_ext_finder')
{
$this->phpbb_root_path = $phpbb_root_path;
$this->cache = $cache;

View file

@ -52,7 +52,7 @@ class form_helper
*
* @return array Array containing form_token and creation_time of form token
*/
public function get_form_tokens(string $form_name, ?int &$now = 0, ?string &$token_sid = '', ?string &$token = ''): array
public function get_form_tokens(string $form_name, int|null &$now = 0, string|null &$token_sid = '', string|null &$token = ''): array
{
$now = time();
$token_sid = ($this->user->data['user_id'] == ANONYMOUS && !empty($this->config['form_token_sid_guests'])) ? $this->user->session_id : '';
@ -71,7 +71,7 @@ class form_helper
* @param int|null $timespan Lifetime of token or null if default value should be used
* @return bool True if form token is valid, false if not
*/
public function check_form_tokens(string $form_name, ?int $timespan = null): bool
public function check_form_tokens(string $form_name, int|null $timespan = null): bool
{
if ($timespan === null)
{

View file

@ -74,7 +74,7 @@ abstract class database_task extends task_base
*
* @return Result|null Result of the query.
*/
protected function query(string $sql) : ?Result
protected function query(string $sql) : Result|null
{
try
{
@ -95,7 +95,7 @@ abstract class database_task extends task_base
*
* @return Statement|null The prepared statement object or null if preparing failed
*/
protected function create_prepared_stmt(string $sql): ?Statement
protected function create_prepared_stmt(string $sql): Statement|null
{
try
{
@ -155,7 +155,7 @@ abstract class database_task extends task_base
*
* @return int|null The last insert ID.
*/
protected function get_last_insert_id() : ?int
protected function get_last_insert_id() : int|null
{
try
{

View file

@ -38,7 +38,7 @@ trait sequential_task
*
* @throws resource_limit_reached_exception When resources are exhausted.
*/
protected function execute(config $config, array $data, ?string $counter_name = null) : void
protected function execute(config $config, array $data, string|null $counter_name = null) : void
{
if ($counter_name === null)
{

View file

@ -119,8 +119,8 @@ abstract class base implements messenger_interface
user $user,
string $phpbb_root_path,
string $template_cache_path,
?manager $ext_manager = null,
?log_interface $log = null
manager|null $ext_manager = null,
log_interface|null $log = null
)
{
$this->assets_bag = $assets_bag;
@ -469,7 +469,7 @@ abstract class base implements messenger_interface
*
* @return void
*/
protected function set_template_paths(string|array $path_name, string|array $paths): void
protected function set_template_paths(array|string $path_name, array|string $paths): void
{
$this->setup_template();
$this->template->set_custom_style($path_name, $paths);

View file

@ -91,7 +91,7 @@ class email extends messenger_base
* method additionally checks if the type provides an email template.
* @return bool
*/
public function is_available(type_interface $notification_type = null)
public function is_available(type_interface|null $notification_type = null)
{
return parent::is_available($notification_type) && $this->config['email_enable'] && !empty($this->user->data['user_email']);
}

View file

@ -59,7 +59,7 @@ abstract class messenger_base extends \phpbb\notification\method\base
* only if the type is provided and if it doesn't provide an email template.
* @return bool
*/
public function is_available(type_interface $notification_type = null)
public function is_available(type_interface|null $notification_type = null)
{
return $notification_type === null || $notification_type->get_email_template() !== false;
}

View file

@ -101,7 +101,7 @@ class webpush extends base implements extended_method_interface
/**
* {@inheritDoc}
*/
public function is_available(type_interface $notification_type = null): bool
public function is_available(type_interface|null $notification_type = null): bool
{
return $this->config['webpush_enable']
&& $this->config['webpush_vapid_public']

View file

@ -57,7 +57,7 @@ class request implements request_interface
* Initialises the request class, that means it stores all input data in {@link $input input}
* and then calls {@link \phpbb\request\deactivated_super_global \phpbb\request\deactivated_super_global}
*/
public function __construct(\phpbb\request\type_cast_helper_interface $type_cast_helper = null, $disable_super_globals = true)
public function __construct(\phpbb\request\type_cast_helper_interface|null $type_cast_helper = null, $disable_super_globals = true)
{
if ($type_cast_helper)
{

View file

@ -48,7 +48,7 @@ class default_resources_locator implements resources_locator_interface
* @param string $environment Name of the current environment
* @param manager|null $extension_manager Extension manager
*/
public function __construct($phpbb_root_path, $environment, manager $extension_manager = null)
public function __construct($phpbb_root_path, $environment, manager|null $extension_manager = null)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->environment = $environment;

View file

@ -316,7 +316,7 @@ abstract class base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function create_index(int &$post_counter = 0): ?array
public function create_index(int &$post_counter = 0): array|null
{
$max_post_id = $this->get_max_post_id();
$forums_indexing_enabled = $this->forum_ids_with_indexing_enabled();
@ -377,7 +377,7 @@ abstract class base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function delete_index(int &$post_counter = null): ?array
public function delete_index(int|null &$post_counter = null): array|null
{
$max_post_id = $this->get_max_post_id();

View file

@ -912,7 +912,7 @@ class fulltext_mysql extends base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function create_index(int &$post_counter = 0): ?array
public function create_index(int &$post_counter = 0): array|null
{
// Make sure we can actually use MySQL with fulltext indexes
if ($error = $this->init())
@ -984,7 +984,7 @@ class fulltext_mysql extends base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function delete_index(int &$post_counter = null): ?array
public function delete_index(int|null &$post_counter = null): array|null
{
// Make sure we can actually use MySQL with fulltext indexes
if ($error = $this->init())

View file

@ -1621,7 +1621,7 @@ class fulltext_native extends base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function delete_index(int &$post_counter = null): ?array
public function delete_index(int|null &$post_counter = null): array|null
{
$truncate_tables = [
$this->search_wordlist_table,

View file

@ -867,7 +867,7 @@ class fulltext_postgres extends base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function create_index(int &$post_counter = 0): ?array
public function create_index(int &$post_counter = 0): array|null
{
// Make sure we can actually use PostgreSQL with fulltext indexes
if ($error = $this->init())
@ -926,7 +926,7 @@ class fulltext_postgres extends base implements search_backend_interface
/**
* {@inheritdoc}
*/
public function delete_index(int &$post_counter = null): ?array
public function delete_index(int|null &$post_counter = null): array|null
{
// Make sure we can actually use PostgreSQL with fulltext indexes
if ($error = $this->init())

View file

@ -629,7 +629,7 @@ class fulltext_sphinx implements search_backend_interface
/**
* {@inheritdoc}
*/
public function create_index(int &$post_counter = 0): ?array
public function create_index(int &$post_counter = 0): array|null
{
if (!$this->index_created())
{
@ -656,7 +656,7 @@ class fulltext_sphinx implements search_backend_interface
/**
* {@inheritdoc}
*/
public function delete_index(int &$post_counter = null): ?array
public function delete_index(int|null &$post_counter = null): array|null
{
if ($this->index_created())
{
@ -952,7 +952,7 @@ class fulltext_sphinx implements search_backend_interface
array('read_timeout', '5'),
array('max_children', '30'),
array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'),
array('binlog_path', $this->config['fulltext_sphinx_data_path']),
array('binlog_path', rtrim($this->config['fulltext_sphinx_data_path'], '/\\')), // Trim trailing slash
),
);

View file

@ -163,7 +163,7 @@ interface search_backend_interface
* @param int $post_counter
* @return array|null array with current status or null if finished
*/
public function create_index(int &$post_counter = 0): ?array;
public function create_index(int &$post_counter = 0): array|null;
/**
* Drop fulltext index
@ -171,7 +171,7 @@ interface search_backend_interface
* @param int $post_counter
* @return array|null array with current status or null if finished
*/
public function delete_index(int &$post_counter = 0): ?array;
public function delete_index(int &$post_counter = 0): array|null;
/**
* Returns true if both FULLTEXT indexes exist

View file

@ -28,7 +28,7 @@ class config
* @param string $name The name of the section that shall be returned
* @return config_section|null The section object or null if none was found
*/
public function get_section_by_name(string $name): ?config_section
public function get_section_by_name(string $name): config_section|null
{
for ($i = 0, $size = count($this->sections); $i < $size; $i++)
{

View file

@ -60,7 +60,7 @@ class config_section extends config_item
* @return config_variable|null The first variable object from this section with the
* given name or null if none was found
*/
public function get_variable_by_name(string $name): ?config_variable
public function get_variable_by_name(string $name): config_variable|null
{
for ($i = 0, $size = count($this->variables); $i < $size; $i++)
{

View file

@ -26,7 +26,7 @@ class storage_exception extends runtime_exception
* @param \Exception|null $previous The previous runtime_exception used for the runtime_exception chaining
* @param integer $code The Exception code
*/
public function __construct($message = '', $filename = '', $parameters = [], \Exception $previous = null, $code = 0)
public function __construct($message = '', $filename = '', $parameters = [], \Exception|null $previous = null, $code = 0)
{
parent::__construct($message, array_merge(array('filename' => $filename), $parameters), $previous, $code);
}

View file

@ -66,7 +66,7 @@ class environment extends \Twig\Environment
* @param dispatcher_interface|null $phpbb_dispatcher Event dispatcher object
* @param array $options Array of options to pass to Twig
*/
public function __construct(assets_bag $assets_bag, config $phpbb_config, filesystem $filesystem, path_helper $path_helper, $cache_path, manager $extension_manager = null, LoaderInterface $loader = null, dispatcher_interface $phpbb_dispatcher = null, $options = array())
public function __construct(assets_bag $assets_bag, config $phpbb_config, filesystem $filesystem, path_helper $path_helper, $cache_path, manager|null $extension_manager = null, LoaderInterface|null $loader = null, dispatcher_interface|null $phpbb_dispatcher = null, $options = array())
{
$this->phpbb_config = $phpbb_config;
@ -271,7 +271,7 @@ class environment extends \Twig\Environment
* @return \Twig\Template A template instance representing the given template name
* @throws \Twig\Error\LoaderError
*/
public function loadTemplate(string $cls, string $name, int $index = null) : \Twig\Template
public function loadTemplate(string $cls, string $name, int|null $index = null) : \Twig\Template
{
if (strpos($name, '@') === false)
{

View file

@ -70,7 +70,7 @@ class avatar extends AbstractExtension
*
* @return string The avatar HTML for the specified mode
*/
public function get_avatar(environment $environment, string $mode, array $row, ?string $alt, ?bool $ignore_config, ?bool $lazy): string
public function get_avatar(environment $environment, string $mode, array $row, string|null $alt, bool|null $ignore_config, bool|null $lazy): string
{
$alt = $alt ?? false;
$ignore_config = $ignore_config ?? false;

View file

@ -70,9 +70,9 @@ class twig extends \phpbb\template\base
\phpbb\template\context $context,
environment $twig_environment,
$cache_path,
\phpbb\user $user = null,
\phpbb\user|null $user = null,
$extensions = [],
\phpbb\extension\manager $extension_manager = null
\phpbb\extension\manager|null $extension_manager = null
)
{
$this->path_helper = $path_helper;

View file

@ -709,7 +709,7 @@ class user extends \phpbb\session
* @param ?\DateTimeZone $timezone Time zone of the time.
* @return \phpbb\datetime Date time object linked to the current users locale
*/
public function create_datetime(string $time = 'now', ?\DateTimeZone $timezone = null)
public function create_datetime(string $time = 'now', \DateTimeZone|null $timezone = null)
{
$timezone = $timezone ?: $this->create_timezone();
return new $this->datetime($this, $time, $timezone);
@ -723,7 +723,7 @@ class user extends \phpbb\session
* @param ?\DateTimeZone $timezone Timezone of the date/time, falls back to timezone of current user
* @return string|false Returns the unix timestamp or false if date is invalid
*/
public function get_timestamp_from_format($format, $time, ?\DateTimeZone $timezone = null)
public function get_timestamp_from_format($format, $time, \DateTimeZone|null $timezone = null)
{
$timezone = $timezone ?: $this->create_timezone();
$date = \DateTime::createFromFormat($format, $time, $timezone);

View file

@ -24,6 +24,7 @@ use phpbb\template\template;
use phpbb\user;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Utils;
require_once __DIR__ . '/../../phpBB/includes/functions_acp.php';
@ -266,7 +267,7 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
$response_mock = $this->createMock(Response::class);
$client_mock->method('request')->willReturn($response_mock);
$response_mock->method('getBody')->willReturn(json_encode(['success' => true]));
$response_mock->method('getBody')->willReturn(Utils::streamFor(json_encode(['success' => true])));
// Mock config values for secret
$this->config->method('offsetGet')->willReturn('secret_value');
@ -354,7 +355,7 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
$response_mock = $this->createMock(Response::class);
$client_mock->method('request')->willReturn($response_mock);
$response_mock->method('getBody')->willReturn(json_encode(['success' => false]));
$response_mock->method('getBody')->willReturn(Utils::streamFor(json_encode(['success' => false])));
// Mock config values for secret
$this->config->method('offsetGet')->willReturn('secret_value');

View file

@ -263,7 +263,12 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
// Ensure search index has been actually created
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid);
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $search_type) . ' td')->eq(1)->text();
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $search_type) . ' td')->reduce(
function ($node, $i) {
// Find the value of total posts indexed
return (strpos($node->text(), $this->lang('FULLTEXT_MYSQL_TOTAL_POSTS')) !== false || strpos($node->text(), $this->lang('TOTAL_WORDS')) !== false);
})
->nextAll()->eq(0)->text();
$this->assertTrue($posts_indexed > 0);
}
@ -300,7 +305,12 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case
// Ensure search index has been actually removed
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid);
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $this->search_backend) . ' td')->eq(1)->text();
$posts_indexed = (int) $crawler->filter('#acp_search_index_' . str_replace('\\', '-', $this->search_backend) . ' td')->reduce(
function ($node, $i) {
// Find the value of total posts indexed
return (strpos($node->text(), $this->lang('FULLTEXT_MYSQL_TOTAL_POSTS')) !== false || strpos($node->text(), $this->lang('TOTAL_WORDS')) !== false);
})
->nextAll()->eq(0)->text();
$this->assertEquals(0, $posts_indexed);
}
}

View file

@ -27,8 +27,10 @@ class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base
if (!$backend || $this->search_backend == $backend)
{
$output = $retval = null;
// After creating phpBB search index, build Sphinx index
exec('sudo -S service sphinxsearch stop', $output, $retval); // Attemtp to stop sphinxsearch service in case it's running
exec('sudo -S service sphinxsearch stop', $output, $retval); // Attempt to stop sphinxsearch service in case it's running
exec('sudo -S indexer --all', $output, $retval); // Run sphinxsearch indexer
exec('sudo -S service sphinxsearch start', $output, $retval); // Attempt to start sphinxsearch service again
}

View file

@ -601,7 +601,16 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_
// Assert new topic title is indexed as well
$this->add_lang('search');
self::request('GET', "search.php?keywords=bang&sid={$this->sid}");
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
// Sphinx search doesn't apply to unapproved or softdeleted posts
if (strpos($this->get_search_type(), 'fulltext_sphinx'))
{
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][2], 0), self::get_content());
}
else
{
$this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content());
}
}
public function test_move_topic_back()

View file

@ -56,7 +56,7 @@ class phpbb_mock_container_builder implements ContainerInterface
*
* @api
*/
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): ?object
public function get(string $id, int $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE): object|null
{
if ($this->has($id))
{

View file

@ -82,13 +82,13 @@ class search_backend_mock implements search_backend_interface
// Nothing
}
public function create_index(int &$post_counter = 0): ?array
public function create_index(int &$post_counter = 0): array|null
{
$this->index_created = true;
return null;
}
public function delete_index(int &$post_counter = 0): ?array
public function delete_index(int &$post_counter = 0): array|null
{
$this->index_created = true;
return null;

View file

@ -221,7 +221,7 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
return implode('-', func_get_args());
}
public function create_datetime_callback($time = 'now', \DateTimeZone $timezone = null)
public function create_datetime_callback($time = 'now', \DateTimeZone|null $timezone = null)
{
$timezone = $timezone ?: $this->user->timezone;
return new \phpbb\datetime($this->user, $time, $timezone);

View file

@ -895,6 +895,24 @@ class phpbb_functional_test_case extends phpbb_test_case
return $group_id;
}
/**
* Get current board's search type
*
* @return string Current search type setting
*/
protected function get_search_type()
{
$db = $this->get_db();
$sql = 'SELECT config_value as search_type
FROM ' . CONFIG_TABLE . "
WHERE config_name = '" . $db->sql_escape('search_type') . "'";
$result = $db->sql_query($sql);
$search_type = $db->sql_fetchfield('search_type');
$db->sql_freeresult($result);
return $search_type;
}
protected function remove_user_group($group_name, $usernames)
{
global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx;

View file

@ -346,7 +346,7 @@ class phpbb_test_case_helpers
* @param string $styles_path Path to the styles dir
* @return ContainerInterface
*/
public function set_s9e_services(ContainerInterface $container = null, $fixture = null, $styles_path = null)
public function set_s9e_services(ContainerInterface|null $container = null, $fixture = null, $styles_path = null)
{
static $first_run;
global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $request, $user;

View file

@ -13,6 +13,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Psr7\Response;
use phpbb\filesystem\exception\filesystem_exception;
use phpbb\filesystem\filesystem_interface;
use phpbb\update\get_updates;
@ -63,13 +64,14 @@ class phpbb_update_get_updates_test extends phpbb_test_case
public function test_download_success()
{
$response_mock = $this->createMock(Response::class);
$this->http_client->expects($this->once())
->method('request')
->with('GET', 'http://example.com/update.zip', [
'sink' => '/path/to/storage',
'allow_redirects' => false
])
->willReturn(true);
->willReturn($response_mock);
$client_reflection = new \ReflectionProperty($this->update, 'http_client');
$client_reflection->setValue($this->update, $this->http_client);
@ -84,7 +86,7 @@ class phpbb_update_get_updates_test extends phpbb_test_case
->method('request')
->willReturnCallback(function ($method, $url, $options)
{
throw new ClientException('bad client', new \GuzzleHttp\Psr7\Request($method, $url));
throw new ClientException('bad client', new \GuzzleHttp\Psr7\Request($method, $url), new \GuzzleHttp\Psr7\Response());
});
$client_reflection = new \ReflectionProperty($this->update, 'http_client');
$client_reflection->setValue($this->update, $this->http_client);