diff --git a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php index 8173037455..17397800e1 100644 --- a/phpBB/phpbb/textformatter/s9e/bbcode_merger.php +++ b/phpBB/phpbb/textformatter/s9e/bbcode_merger.php @@ -37,8 +37,8 @@ class bbcode_merger * * All of the arrays contain a "usage" element and a "template" element * - * @throws InvalidArgumentException if a definition cannot be interpreted - * @throws RuntimeException if something unexpected occurs + * @throws \InvalidArgumentException if a definition cannot be interpreted + * @throws \RuntimeException if something unexpected occurs * * @param array $without BBCode definition without an attribute * @param array $with BBCode definition with an attribute diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php index 01cc545a72..4256ec85d9 100644 --- a/phpBB/phpbb/textformatter/s9e/factory.php +++ b/phpBB/phpbb/textformatter/s9e/factory.php @@ -226,8 +226,9 @@ class factory implements \phpbb\textformatter\cache_interface * @event core.text_formatter_s9e_configure_before * @var Configurator configurator Configurator instance * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('configurator'); + $vars = ['configurator']; extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_before', compact($vars))); // Reset the list of allowed schemes @@ -375,8 +376,9 @@ class factory implements \phpbb\textformatter\cache_interface * @event core.text_formatter_s9e_configure_after * @var Configurator configurator Configurator instance * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('configurator'); + $vars = ['configurator']; extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_after', compact($vars))); return $configurator; @@ -444,7 +446,7 @@ class factory implements \phpbb\textformatter\cache_interface } catch (\Exception $e) { - $this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); + $this->log->add('critical', ANONYMOUS, '', 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]); } } diff --git a/phpBB/phpbb/textformatter/s9e/parser.php b/phpBB/phpbb/textformatter/s9e/parser.php index cf36879dbe..33f2a0227c 100644 --- a/phpBB/phpbb/textformatter/s9e/parser.php +++ b/phpBB/phpbb/textformatter/s9e/parser.php @@ -65,8 +65,9 @@ class parser implements \phpbb\textformatter\parser_interface * @event core.text_formatter_s9e_parser_setup * @var \phpbb\textformatter\s9e\parser parser This parser service * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('parser'); + $vars = ['parser']; extract($dispatcher->trigger_event('core.text_formatter_s9e_parser_setup', compact($vars))); } diff --git a/phpBB/phpbb/textformatter/s9e/renderer.php b/phpBB/phpbb/textformatter/s9e/renderer.php index 29dbf29afc..855e034b14 100644 --- a/phpBB/phpbb/textformatter/s9e/renderer.php +++ b/phpBB/phpbb/textformatter/s9e/renderer.php @@ -117,8 +117,9 @@ class renderer implements \phpbb\textformatter\renderer_interface * @event core.text_formatter_s9e_renderer_setup * @var \phpbb\textformatter\s9e\renderer renderer This renderer service * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('renderer'); + $vars = ['renderer']; extract($dispatcher->trigger_event('core.text_formatter_s9e_renderer_setup', compact($vars))); } @@ -234,16 +235,16 @@ class renderer implements \phpbb\textformatter\renderer_interface /** * {@inheritdoc} */ - public function render($xml) + public function render($text) { if (isset($this->mention_helper)) { - $xml = $this->mention_helper->inject_metadata($xml); + $text = $this->mention_helper->inject_metadata($text); } if (isset($this->quote_helper)) { - $xml = $this->quote_helper->inject_metadata($xml); + $text = $this->quote_helper->inject_metadata($text); } $renderer = $this; @@ -253,13 +254,14 @@ class renderer implements \phpbb\textformatter\renderer_interface * * @event core.text_formatter_s9e_render_before * @var \phpbb\textformatter\s9e\renderer renderer This renderer service - * @var string xml The parsed text, in its XML form + * @var string text The parsed text, in its XML form * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('renderer', 'xml'); + $vars = ['renderer', 'text']; extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_before', compact($vars))); - $html = $this->renderer->render($xml); + $html = $this->renderer->render($text); if (isset($this->censor) && $this->viewcensors) { $html = $this->censor->censorHtml($html, true); @@ -272,8 +274,9 @@ class renderer implements \phpbb\textformatter\renderer_interface * @var string html The rendered text's HTML * @var \phpbb\textformatter\s9e\renderer renderer This renderer service * @since 3.2.0-a1 + * @psalm-ignore-var */ - $vars = array('html', 'renderer'); + $vars = ['html', 'renderer']; extract($this->dispatcher->trigger_event('core.text_formatter_s9e_render_after', compact($vars))); return $html; diff --git a/phpBB/phpbb/textformatter/s9e/utils.php b/phpBB/phpbb/textformatter/s9e/utils.php index 1c77d89976..9e6e367d24 100644 --- a/phpBB/phpbb/textformatter/s9e/utils.php +++ b/phpBB/phpbb/textformatter/s9e/utils.php @@ -26,15 +26,15 @@ class utils implements \phpbb\textformatter\utils_interface * * NOTE: preserves smilies as text * - * @param string $xml Parsed text + * @param string $text Parsed text * @return string Plain text */ - public function clean_formatting($xml) + public function clean_formatting($text) { // Insert a space before and then remove formatting - $xml = preg_replace('#<[es]>#', ' $0', $xml); + $text = preg_replace('#<[es]>#', ' $0', $text); - return \s9e\TextFormatter\Utils::removeFormatting($xml); + return \s9e\TextFormatter\Utils::removeFormatting($text); } /** @@ -94,19 +94,19 @@ class utils implements \phpbb\textformatter\utils_interface /** * Get a list of quote authors, limited to the outermost quotes * - * @param string $xml Parsed text + * @param string $text Parsed text * @return string[] List of authors */ - public function get_outermost_quote_authors($xml) + public function get_outermost_quote_authors($text) { $authors = array(); - if (strpos($xml, 'loadXML($xml); + $dom->loadXML($text); $xpath = new \DOMXPath($dom); foreach ($xpath->query('//QUOTE[not(ancestor::QUOTE)]/@author') as $author) { @@ -119,25 +119,25 @@ class utils implements \phpbb\textformatter\utils_interface /** * Remove given BBCode and its content, at given nesting depth * - * @param string $xml Parsed text + * @param string $text Parsed text * @param string $bbcode_name BBCode's name * @param integer $depth Minimum nesting depth (number of parents of the same name) * @return string Parsed text */ - public function remove_bbcode($xml, $bbcode_name, $depth = 0) + public function remove_bbcode($text, $bbcode_name, $depth = 0) { - return \s9e\TextFormatter\Utils::removeTag($xml, strtoupper($bbcode_name), $depth); + return \s9e\TextFormatter\Utils::removeTag($text, strtoupper($bbcode_name), $depth); } /** * Return a parsed text to its original form * - * @param string $xml Parsed text + * @param string $text Parsed text * @return string Original plain text */ - public function unparse($xml) + public function unparse($text) { - return \s9e\TextFormatter\Unparser::unparse($xml); + return \s9e\TextFormatter\Unparser::unparse($text); } /** diff --git a/phpBB/phpbb/textreparser/base.php b/phpBB/phpbb/textreparser/base.php index bd7b6c9fc9..c4b344f8db 100644 --- a/phpBB/phpbb/textreparser/base.php +++ b/phpBB/phpbb/textreparser/base.php @@ -243,7 +243,8 @@ abstract class base implements reparser_interface // generate_text_for_edit() and decode_message() actually return the text as HTML. It has to // be decoded to plain text before it can be reparsed $text = html_entity_decode($unparsed['text'], ENT_QUOTES, 'UTF-8'); - $bitfield = $flags = null; + $bitfield = ''; + $flags = 0; generate_text_for_storage( $text, $unparsed['bbcode_uid'], diff --git a/phpBB/phpbb/textreparser/manager.php b/phpBB/phpbb/textreparser/manager.php index 7ca65d708d..9a7663f938 100644 --- a/phpBB/phpbb/textreparser/manager.php +++ b/phpBB/phpbb/textreparser/manager.php @@ -132,9 +132,9 @@ class manager * If there is no reparser with the specified name, null is returned. * * @param string $name Name of the reparser to look up. - * @return string A reparser service name, or null. + * @return string|null A reparser service name, or null. */ - public function find_reparser($name) + public function find_reparser(string $name) { foreach ($this->reparsers as $service => $reparser) { diff --git a/phpBB/phpbb/textreparser/plugins/user_signature.php b/phpBB/phpbb/textreparser/plugins/user_signature.php index 647d3a7b14..79be5c8282 100644 --- a/phpBB/phpbb/textreparser/plugins/user_signature.php +++ b/phpBB/phpbb/textreparser/plugins/user_signature.php @@ -24,21 +24,21 @@ class user_signature extends \phpbb\textreparser\row_based_plugin /** * {@inheritdoc} */ - protected function add_missing_fields(array $row) + protected function add_missing_fields(array $record) { if (!isset($this->keyoptions)) { $this->save_keyoptions(); } - $options = $row['user_options']; - $row += array( + $options = $record['user_options']; + $record += array( 'enable_bbcode' => phpbb_optionget($this->keyoptions['sig_bbcode'], $options), 'enable_smilies' => phpbb_optionget($this->keyoptions['sig_smilies'], $options), 'enable_magic_url' => phpbb_optionget($this->keyoptions['sig_links'], $options), ); - return parent::add_missing_fields($row); + return parent::add_missing_fields($record); } /**