|
From: <var...@us...> - 2023-07-14 11:37:06
|
Revision: 11056
http://sourceforge.net/p/phpwiki/code/11056
Author: vargenau
Date: 2023-07-14 11:37:03 +0000 (Fri, 14 Jul 2023)
Log Message:
-----------
lib/BlockParser.php: PHP 7: add types for function arguments and return
Modified Paths:
--------------
trunk/lib/BlockParser.php
trunk/lib/PageList.php
trunk/lib/Template.php
trunk/lib/WysiwygEdit/Wikiwyg.php
trunk/lib/editpage.php
trunk/lib/stdlib.php
Modified: trunk/lib/BlockParser.php
===================================================================
--- trunk/lib/BlockParser.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/BlockParser.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -83,7 +83,7 @@
* "(...)". (Anonymous groups, like "(?:...)", as well as
* look-ahead and look-behind assertions are fine.)
*/
- public function __construct($regexps)
+ public function __construct(array $regexps)
{
$this->_regexps = $regexps;
$this->_re = "/((" . join(")|(", $regexps) . "))/Ax";
@@ -130,7 +130,7 @@
*
* @return AnchoredRegexpSet_match|bool An AnchoredRegexpSet_match object, or false if no match.
*/
- public function nextMatch($text, $prevMatch)
+ public function nextMatch(string $text, $prevMatch)
{
// Try to find match at same position.
$regexps = array_slice($this->_regexps, $prevMatch->regexp_ind + 1);
@@ -175,7 +175,7 @@
$this->_atSpace = false;
}
- public function skipSpace()
+ public function skipSpace(): bool
{
$nlines = count($this->_lines);
while (1) {
@@ -215,7 +215,7 @@
$this->_pos++;
}
- public function getPos()
+ public function getPos(): array
{
return array($this->_pos, $this->_atSpace);
}
@@ -225,12 +225,12 @@
list($this->_pos, $this->_atSpace) = $pos;
}
- public function getPrefix()
+ public function getPrefix(): string
{
return '';
}
- public function getDepth()
+ public function getDepth(): int
{
return 0;
}
@@ -265,7 +265,7 @@
* @param string $prefix_re
* @param string $initial_prefix
*/
- public function __construct(&$input, $prefix_re, $initial_prefix = '')
+ public function __construct(&$input, string $prefix_re, string $initial_prefix = '')
{
$this->_input = &$input;
$this->_prefix_pat = "/$prefix_re|\\s*\$/Ax";
@@ -285,7 +285,7 @@
}
}
- public function skipSpace()
+ public function skipSpace(): bool
{
// In contrast to the case for top-level blocks,
// for sub-blocks, there never appears to be any trailing space.
@@ -330,7 +330,7 @@
$this->nextLine();
}
- public function getPos()
+ public function getPos(): array
{
return array($this->_line, $this->_atSpace, $this->_input->getPos());
}
@@ -342,7 +342,7 @@
$this->_input->setPos($pos[2]);
}
- public function getPrefix()
+ public function getPrefix(): string
{
assert($this->_line !== false);
$line = $this->_input->currentLine();
@@ -350,7 +350,7 @@
return substr($line, 0, strlen($line) - strlen($this->_line));
}
- public function getDepth()
+ public function getDepth(): int
{
return $this->_input->getDepth() + 1;
}
@@ -511,7 +511,7 @@
*
* We go to this trouble so that "tight" lists look somewhat reasonable
* in older (non-CSS) browsers. (If you don't do this, then, without
- * CSS, you only get "loose" lists.
+ * CSS, you only get "loose" lists).
*/
class TightSubBlock extends SubBlock
{
@@ -563,7 +563,7 @@
public $_re = '\ +(?=\S)';
protected $_element;
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$this->_depth = strlen($m->match);
$indent = sprintf("\\ {%d}", $this->_depth);
@@ -602,7 +602,7 @@
public $_content = array();
public $_tag; //'ol' or 'ul'
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
// A list as the first content in a list is not allowed.
// E.g.:
@@ -659,7 +659,7 @@
$this->_re = '\ {0,4}\S.*(?<!' . ESCAPE_CHAR . '):\s*$';
}
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
if (!($p = $this->_do_match($input, $m))) {
return false;
@@ -807,7 +807,7 @@
return $ncols;
}
- private function IsASubtable($item)
+ private function IsASubtable($item): bool
{
return is_a($item, 'HtmlElement')
&& $item->getTag() == 'table'
@@ -825,7 +825,7 @@
return $this->_ncols;
}
- public function nrows()
+ public function nrows(): int
{
return $this->_nrows;
}
@@ -879,7 +879,7 @@
$this->_re = '\ {0,4} (?:\S.*)? (?<!' . ESCAPE_CHAR . ') \| \s* $';
}
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
if (!($p = $this->_do_match($input, $m))) {
return false;
@@ -920,7 +920,7 @@
| ; .*? :
) .*? (?=\S)';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
// FIXME:
if (!preg_match('/[*#;]*$/A', $input->getPrefix())) {
@@ -975,7 +975,7 @@
{
public $_re = '<(?:pre|verbatim|nowiki|noinclude|includeonly)>';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$endtag = '</' . substr($m->match, 1);
$text = array();
@@ -1021,7 +1021,7 @@
{
public $_re = '<<<';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$endtag = '>>>';
$text = array();
@@ -1048,7 +1048,7 @@
{
public $_re = '{{{';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$endtag = '}}}';
$text = array();
@@ -1082,7 +1082,7 @@
*
* should all work.
*/
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$pos = $input->getPos();
$pi = $m->match . $m->postmatch;
@@ -1105,7 +1105,7 @@
// public $_re = '<<(?!\S)';
public $_re = '<<';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$pos = $input->getPos();
$pi = $m->postmatch;
@@ -1133,7 +1133,7 @@
{
public $_re = '\s*\|';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$pos = $input->getPos();
$pi = "|" . $m->postmatch;
@@ -1174,7 +1174,7 @@
{
public $_re = '{\|';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$pos = $input->getPos();
$pi = $m->postmatch;
@@ -1209,7 +1209,7 @@
{
public $_re = '{{';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
// If we find "}}", this is an inline template.
if (strpos($m->postmatch, "}}") !== false) {
@@ -1294,7 +1294,7 @@
public $_attr = array('class' => 'mail-style-quote');
public $_re = '>\ ?';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
//$indent = str_replace(' ', '\\ ', $m->match) . '|>$';
$indent = $this->_re;
@@ -1308,7 +1308,7 @@
public $_attr = array('style' => 'margin-left:2em');
public $_re = ':\ ?';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$indent = $this->_re;
$this->_element = new SubBlock(
@@ -1326,7 +1326,7 @@
{
public $_re = '-{4,}\s*$';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$input->advance();
$this->_element = new Block_HtmlElement('hr');
@@ -1338,7 +1338,7 @@
{
public $_re = '!{1,3}';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$tag = "h" . (5 - strlen($m->match));
$text = TransformInline(trim($m->postmatch));
@@ -1354,7 +1354,7 @@
{
public $_re = '={2,6}';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$tag = "h" . strlen($m->match);
// Remove spaces
@@ -1378,7 +1378,7 @@
private $_tight_bot;
private $_tight_top;
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
$this->_text = $m->match;
$input->advance();
@@ -1415,7 +1415,7 @@
{
public $_re = '<(?im)(?: div|span)(?:[^>]*)?>';
- public function _match(&$input, $m)
+ public function _match(&$input, $m): bool
{
if (substr($m->match, 1, 4) == 'span') {
$tag = 'span';
Modified: trunk/lib/PageList.php
===================================================================
--- trunk/lib/PageList.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/PageList.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -54,7 +54,7 @@
*/
class _PageList_Column_base
{
- public $_tdattr = array();
+ public array $_tdattr = array();
public $_field;
public function __construct($default_heading, $align = false)
@@ -85,7 +85,7 @@
}
// old-style heading
- public function heading()
+ public function heading(): HTML
{
global $request;
// allow sorting?
@@ -110,7 +110,7 @@
// new grid-style sortable heading
// TODO: via activeui.js ? (fast dhtml sorting)
- public function button_heading($pagelist, $colNum)
+ public function button_heading($pagelist, $colNum): HTML
{
global $WikiTheme, $request;
// allow sorting?
@@ -172,7 +172,7 @@
*
* @return int -1 if $a < $b, 1 if $a > $b, 0 otherwise.
*/
- public function _compare($colvala, $colvalb)
+ public function _compare($colvala, $colvalb): int
{
if (is_string($colvala)) {
return strcmp($colvala, $colvalb);
@@ -209,7 +209,7 @@
* @param WikiDB_PageRevision $revision_handle
* @return mixed
*/
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
if ($this->_need_rev) {
if (!$revision_handle) {
@@ -227,7 +227,7 @@
* @param WikiDB_PageRevision $revision_handle
* @return int|string
*/
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$val = $this->_getValue($page_handle, $revision_handle);
if ($this->_field == 'hits') {
@@ -256,7 +256,7 @@
class _PageList_Column_size extends _PageList_Column
{
- public function format($pagelist, $page_handle, $revision_handle)
+ public function format($pagelist, $page_handle, $revision_handle): HTML
{
return HTML::td(
$this->_tdattr,
@@ -264,7 +264,7 @@
);
}
- public function _getValuePageList($pagelist, $page_handle, $revision_handle)
+ public function _getValuePageList($pagelist, $page_handle, $revision_handle): FormattedText
{
if (!$revision_handle or (!$revision_handle->_data['%content']
or $revision_handle->_data['%content'] === true)
@@ -280,7 +280,7 @@
return $size;
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
if (!$revision_handle) {
$revision_handle = $page_handle->getCurrentRevision();
@@ -289,7 +289,7 @@
? 0 : strlen($revision_handle->_data['%content']);
}
- public function _getSize($revision_handle)
+ public function _getSize($revision_handle): FormattedText
{
$bytes = @strlen($revision_handle->_data['%content']);
return ByteFormatter($bytes);
@@ -305,7 +305,7 @@
$this->_textIfFalse = new RawXml('—'); //mdash
}
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
//FIXME: check if $this is available in the parent (->need_rev)
$val = parent::_getValue($page_handle, $revision_handle);
@@ -327,7 +327,7 @@
parent::__construct($field, $heading, 'center');
}
- public function _getValuePageList($pagelist, $page_handle, $revision_handle)
+ public function _getValuePageList($pagelist, $page_handle, $revision_handle): HTML
{
$pagename = $page_handle->getName();
$selected = !empty($pagelist->_selected[$pagename]);
@@ -346,7 +346,7 @@
}
}
- public function format($pagelist, $page_handle, $revision_handle)
+ public function format($pagelist, $page_handle, $revision_handle): HTML
{
return HTML::td(
$this->_tdattr,
@@ -355,7 +355,7 @@
}
// don't sort this javascript button
- public function button_heading($pagelist, $colNum)
+ public function button_heading($pagelist, $colNum): HTML
{
$s = HTML($this->_heading);
return HTML::th(array('class' => 'gridbutton'), $s);
@@ -371,13 +371,13 @@
$this->WikiTheme = &$WikiTheme;
}
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$time = parent::_getValue($page_handle, $revision_handle);
return $this->WikiTheme->formatDateTime($time);
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
return parent::_getValue($page_handle, $revision_handle);
}
@@ -385,7 +385,7 @@
class _PageList_Column_version extends _PageList_Column
{
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
if (!$revision_handle) {
$revision_handle = $page_handle->getCurrentRevision();
@@ -425,7 +425,7 @@
}
}
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
if (!$revision_handle or (!$revision_handle->_data['%content']
or $revision_handle->_data['%content'] === true)
@@ -510,7 +510,7 @@
);
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
if (is_object($page_handle) and !empty($page_handle->score)) {
return $page_handle->score;
@@ -535,7 +535,7 @@
$this->dbi =& $request->getDbh();
}
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$author = parent::_getValue($page_handle, $revision_handle);
if ($this->dbi->isWikiPage($author)) {
@@ -545,7 +545,7 @@
}
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
return parent::_getValue($page_handle, $revision_handle);
}
@@ -553,7 +553,7 @@
class _PageList_Column_owner extends _PageList_Column_author
{
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$author = $page_handle->getOwner();
if ($this->dbi->isWikiPage($author)) {
@@ -563,7 +563,7 @@
}
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
return parent::_getValue($page_handle, $revision_handle);
}
@@ -571,7 +571,7 @@
class _PageList_Column_creator extends _PageList_Column_author
{
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$author = $page_handle->getCreator();
if ($this->dbi->isWikiPage($author)) {
@@ -581,7 +581,7 @@
}
}
- public function _getSortableValue($page_handle, $revision_handle)
+ public function _getSortableValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
return parent::_getValue($page_handle, $revision_handle);
}
@@ -598,7 +598,7 @@
$this->dbi = &$request->getDbh();
}
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue($page_handle, $revision_handle): XmlContent
{
if ($this->dbi->isWikiPage($page_handle->getName())) {
return WikiLink($page_handle);
@@ -615,7 +615,7 @@
/**
* Compare two pagenames for sorting. See _PageList_Column::_compare.
**/
- public function _compare($colvala, $colvalb)
+ public function _compare($colvala, $colvalb): int
{
return strcmp($colvala, $colvalb);
}
@@ -623,7 +623,7 @@
class _PageList_Column_perm extends _PageList_Column
{
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$perm_array = pagePermissions($page_handle->_pagename);
return pagePermissionsSimpleFormat(
@@ -636,7 +636,7 @@
class _PageList_Column_acl extends _PageList_Column
{
- public function _getValue($page_handle, $revision_handle)
+ public function _getValue(WikiDB_Page $page_handle, WikiDB_PageRevision $revision_handle)
{
$perm_tree = pagePermissions($page_handle->_pagename);
@@ -658,19 +658,19 @@
class PageList
{
- public $_group_rows = 3;
- public $_columns = array();
- private $_columnsMap = array(); // Maps column name to column number.
+ public int $_group_rows = 3;
+ public array $_columns = array();
+ private array $_columnsMap = array(); // Maps column name to column number.
private $_excluded_pages = array();
- public $_pages = array();
- public $_caption = "";
- public $_types = array();
+ public array $_pages = array();
+ public string $_caption = "";
+ public array $_types = array();
public $_options = array();
- public $_selected = array();
- public $_sortby = array();
- public $_maxlen = 0;
- private $_messageIfEmpty = '';
- public $_columns_seen = array();
+ public array $_selected = array();
+ public array $_sortby = array();
+ public int $_maxlen = 0;
+ private string $_messageIfEmpty = '';
+ public array $_columns_seen = array();
private $_stack;
public function __construct($columns = array(), $exclude = array(), $options = array())
@@ -802,7 +802,7 @@
// 1: info, 2: exclude, 3: hash of options
// Here we declare which options are supported, so that
// the calling plugin may simply merge this with its own default arguments
- public static function supportedArgs()
+ public static function supportedArgs(): array
{
// Todo: add all supported Columns, like locked, minor, ...
return array( // Currently supported options:
@@ -855,7 +855,7 @@
);
}
- private function pagingArgs()
+ private function pagingArgs(): array
{
return array('sortby', 'limit', 'paging', 'count', 'dosort');
}
@@ -876,7 +876,7 @@
$this->_caption = HTML($this->_caption, " ", $caption);
}
- private function getCaption()
+ private function getCaption(): string
{
// put the total into the caption if needed
if (is_string($this->_caption) && strstr($this->_caption, '%d')) {
@@ -885,13 +885,13 @@
return $this->_caption;
}
- public function getTotal()
+ public function getTotal(): int
{
return !empty($this->_options['count'])
? (int)$this->_options['count'] : count($this->_pages);
}
- public function isEmpty()
+ public function isEmpty(): bool
{
return empty($this->_pages);
}
@@ -911,7 +911,7 @@
}
}
- public function pageNames()
+ public function pageNames(): array
{
$pages = array();
$limit = @$this->_options['limit'];
@@ -1212,7 +1212,7 @@
$sortby = '',
$limit = '',
$exclude = ''
- )
+ ): array
{
/**
* @var WikiRequest $request
@@ -1253,7 +1253,7 @@
$sortby = '',
$limit = '',
$exclude = ''
- )
+ ): array
{
/**
* @var WikiRequest $request
@@ -1293,7 +1293,7 @@
$sortby = '',
$limit = '',
$exclude = ''
- )
+ ): array
{
/**
* @var WikiRequest $request
@@ -1332,7 +1332,7 @@
$sortby = '',
$limit = '',
$exclude = ''
- )
+ ): array
{
/**
* @var WikiRequest $request
@@ -1371,7 +1371,7 @@
$sortby = '',
$limit = '',
$exclude = ''
- )
+ ): array
{
/**
* @var WikiRequest $request
@@ -1510,7 +1510,7 @@
* @param string $column column name
* @return bool true if column is added, false otherwise
*/
- public function _addColumn($column)
+ public function _addColumn(string $column): bool
{
global $request;
@@ -1642,7 +1642,7 @@
}
}
- public function limit($limit)
+ public function limit($limit): array
{
if (is_array($limit)) {
list($from, $count) = $limit;
@@ -1738,7 +1738,7 @@
}
// make a table given the caption
- public function _generateTable($caption = '')
+ public function _generateTable($caption = ''): HTML
{
if (count($this->_sortby) > 0) {
$this->sortPages();
@@ -2010,7 +2010,7 @@
// comma=1
// Condense list without a href links: "Page1, Page2, ..."
// FIXME: only unique list entries, esp. with nopage
- private function generateCommaListAsString()
+ private function generateCommaListAsString(): XmlContent
{
if (defined($this->_options['commasep'])) {
$separator = $this->_options['commasep'];
@@ -2031,7 +2031,7 @@
// Future: 1 = reserved for plain string (see above)
// 2 and more => HTML link specialization?
// FIXME: only unique list entries, esp. with nopage
- private function generateCommaList()
+ private function generateCommaList(): XmlContent
{
if (defined($this->_options['commasep'])) {
$separator = HTML::raw($this->_options['commasep']);
@@ -2049,7 +2049,7 @@
return $html;
}
- public function _emptyList($caption)
+ public function _emptyList($caption): XmlContent
{
$html = HTML();
if ($caption) {
Modified: trunk/lib/Template.php
===================================================================
--- trunk/lib/Template.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/Template.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -37,7 +37,7 @@
* @param WikiRequest $request
* @param array $args
*/
- public function __construct($name, &$request, $args = array())
+ public function __construct(string $name, WikiRequest &$request, array $args = array())
{
global $WikiTheme;
@@ -138,7 +138,7 @@
* @param string $varname Name of token to substitute for.
* @param string $value Replacement HTML text.
*/
- public function replace($varname, $value)
+ public function replace(string $varname, string $value)
{
$this->_locals[$varname] = $value;
}
@@ -235,13 +235,13 @@
* new Template(...)
* </pre>
*/
-function Template($name, $args = array())
+function Template($name, $args = array()): Template
{
global $request;
return new Template($name, $request, $args);
}
-function alreadyTemplateProcessed($name)
+function alreadyTemplateProcessed($name): bool
{
global $request;
return !empty($request->_TemplatesProcessed[$name]) ? true : false;
@@ -256,7 +256,7 @@
* @param object|bool $page_revision A WikiDB_PageRevision object or false
* @param array $args hash Extract args for top-level template
*/
-function GeneratePage($content, $title, $page_revision = false, $args = array())
+function GeneratePage($content, string $title, $page_revision = false, array $args = array())
{
global $request;
Modified: trunk/lib/WysiwygEdit/Wikiwyg.php
===================================================================
--- trunk/lib/WysiwygEdit/Wikiwyg.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/WysiwygEdit/Wikiwyg.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -157,7 +157,7 @@
* @param string $text
* @return string
*/
- public function ConvertBefore($text)
+ public function ConvertBefore($text): string
{
return $text;
}
@@ -169,7 +169,7 @@
* @param string $text
* @return string
*/
- public function ConvertAfter($text)
+ public function ConvertAfter($text): string
{
return TransformInline($text);
}
@@ -321,7 +321,7 @@
// This is called to replace the RichTable plugin by an html table
// $matched contains html <p> tags so
// they are deleted before the conversion.
-function replace_rich_table($matched)
+function replace_rich_table($matched): string
{
/**
* @var WikiRequest $request
Modified: trunk/lib/editpage.php
===================================================================
--- trunk/lib/editpage.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/editpage.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -57,7 +57,7 @@
/**
* @param WikiRequest $request
*/
- public function __construct(&$request)
+ public function __construct(WikiRequest &$request)
{
$this->request = &$request;
@@ -123,7 +123,7 @@
}
}
- public function editPage()
+ public function editPage(): ?bool
{
$saveFailed = false;
$tokens = &$this->tokens;
@@ -240,7 +240,7 @@
return $this->output('editpage', _("Edit: %s"));
}
- public function output($template, $title_fs)
+ public function output($template, $title_fs): bool
{
global $WikiTheme;
$selected = &$this->selected;
@@ -279,7 +279,7 @@
return $this->output('viewsource', _("View Source: %s"));
}
- private function updateLock()
+ private function updateLock(): bool
{
$changed = false;
if (!ENABLE_PAGE_PUBLIC && !ENABLE_EXTERNAL_PAGES) {
@@ -322,7 +322,7 @@
return $changed; // lock changed.
}
- public function savePage()
+ public function savePage(): bool
{
$request = &$this->request;
@@ -418,17 +418,17 @@
return $this->current->getVersion() != $this->_currentVersion;
}
- protected function canEdit()
+ protected function canEdit(): bool
{
return !$this->page->get('locked') || $this->user->isAdmin();
}
- protected function isInitialEdit()
+ protected function isInitialEdit(): bool
{
return $this->_initialEdit;
}
- private function isUnchanged()
+ private function isUnchanged(): bool
{
$current = &$this->current;
return $this->_content == $current->getPackedContent();
@@ -444,7 +444,7 @@
* ENABLE_SPAMASSASSIN: content patterns by babycart (only php >= 4.3 for now)
* ENABLE_SPAMBLOCKLIST: content domain blacklist
*/
- private function isSpam()
+ private function isSpam(): bool
{
$current = &$this->current;
$request = &$this->request;
@@ -533,7 +533,7 @@
/** Number of external links in the wikitext
*/
- private function numLinks(&$text)
+ private function numLinks(&$text): int
{
return substr_count($text, "http://") + substr_count($text, "https://");
}
@@ -540,7 +540,7 @@
/** Header of the Anti Spam message
*/
- private function getSpamMessage()
+ private function getSpamMessage(): XmlContent
{
return
HTML(
@@ -554,7 +554,7 @@
);
}
- protected function getPreview()
+ protected function getPreview(): TransformedText
{
require_once 'lib/PageType.php';
$this->_content = $this->getContent();
@@ -561,7 +561,7 @@
return new TransformedText($this->page, $this->_content, $this->meta);
}
- protected function getConvertedPreview()
+ protected function getConvertedPreview(): TransformedText
{
require_once 'lib/PageType.php';
$this->_content = $this->getContent();
@@ -568,7 +568,7 @@
return new TransformedText($this->page, $this->_content, $this->meta);
}
- private function getDiff()
+ private function getDiff(): XmlContent
{
require_once 'lib/diff.php';
$html = HTML();
@@ -611,7 +611,7 @@
}
}
- protected function getLockedMessage()
+ protected function getLockedMessage(): XmlContent
{
return
HTML(
@@ -627,7 +627,7 @@
return $this->page->get('moderation');
}
- private function getModeratedMessage()
+ private function getModeratedMessage(): XmlContent
{
return
HTML(
@@ -640,7 +640,7 @@
);
}
- protected function getConflictMessage($unresolved = false)
+ protected function getConflictMessage($unresolved = false): XmlContent
{
/*
xgettext only knows about c/c++ line-continuation strings
@@ -1156,7 +1156,7 @@
$this->request->redirect(WikiURL($this->page, array(), 'absolute_url'));
}
- private function _restoreState()
+ private function _restoreState(): bool
{
$request = &$this->request;
@@ -1255,7 +1255,7 @@
class LoadFileConflictPageEditor extends PageEditor
{
- public function editPage($saveFailed = true)
+ public function editPage($saveFailed = true): ?bool
{
$tokens = &$this->tokens;
@@ -1342,7 +1342,7 @@
return $this->output('editpage', _("Merge and Edit: %s"));
}
- public function output($template, $title_fs)
+ public function output($template, $title_fs): bool
{
$selected = &$this->selected;
$current = &$this->current;
@@ -1371,7 +1371,7 @@
return true;
}
- protected function getConflictMessage($unresolved = false)
+ protected function getConflictMessage($unresolved = false): XmlContent
{
return HTML(HTML::p(
fmt(
Modified: trunk/lib/stdlib.php
===================================================================
--- trunk/lib/stdlib.php 2023-07-14 11:23:14 UTC (rev 11055)
+++ trunk/lib/stdlib.php 2023-07-14 11:37:03 UTC (rev 11056)
@@ -125,7 +125,7 @@
* @param string $str
* @return string
*/
-function MangleXmlIdentifier($str)
+function MangleXmlIdentifier(string $str): string
{
if (!$str) {
return 'empty.';
@@ -145,7 +145,7 @@
* configuration file.
* @return string The name of the WIKI_ID cookie to use for this wiki.
*/
-function getCookieName()
+function getCookieName(): string
{
return preg_replace("/[^\d\w]/", "_", WIKI_NAME) . "_WIKI_ID";
}
@@ -244,7 +244,7 @@
* @param string $url
* @return string Absolute URL
*/
-function AbsoluteURL($url)
+function AbsoluteURL(string $url): string
{
if (preg_match('/^https?:/', $url)) {
return $url;
@@ -308,7 +308,7 @@
* @param string $text The text.
* @return XmlContent.
*/
-function PossiblyGlueIconToText($proto_or_url, $text)
+function PossiblyGlueIconToText(string $proto_or_url, string $text): XmlContent
{
global $request, $WikiTheme;
if ($request->getPref('noLinkIcons')) {
@@ -379,7 +379,7 @@
* @param bool $http_only if true, accept only http and https URLs
* @return bool true if safe, false else.
*/
-function IsSafeURL($url, $http_only = false)
+function IsSafeURL(string $url, bool $http_only = false): bool
{
if (preg_match('/([<>"])|(%3C)|(%3E)|(%22)/', $url)) {
return false;
@@ -402,7 +402,7 @@
* @param string $linktext Text to be displayed as link.
* @return HtmlElement HtmlElement object that contains data to construct an html link.
*/
-function LinkURL($url, $linktext = '')
+function LinkURL(string $url, string $linktext = ''): HtmlElement
{
// FIXME: Is this needed (or sufficient?)
if (!IsSafeURL($url)) {
@@ -430,7 +430,7 @@
*
* Handle embeddable objects, like svg, class, vrml, svgz, pdf, avi, wmv especially.
*/
-function LinkImage($url, $alt = "")
+function LinkImage(string $url, string $alt = "")
{
$force_img = "png|jpg|gif|jpeg|bmp|pl|cgi";
// Disallow tags in img src urls. Typical CSS attacks.
@@ -766,7 +766,7 @@
// end class definition
-function SplitQueryArgs($query_args = '')
+function SplitQueryArgs(string $query_args = ''): array
{
// FIXME: use the arg-separator which might not be &
$split_args = explode('&', $query_args);
@@ -779,7 +779,7 @@
return $args;
}
-function LinkPhpwikiURL($url, $text = '', $basepage = false)
+function LinkPhpwikiURL(string $url, string $text = '', bool $basepage = false)
{
/**
* @var WikiRequest $request
@@ -949,7 +949,7 @@
return substr($name, 0, -strlen($tail));
}
- public function isValid($strict = false)
+ public function isValid(bool $strict = false)
{
if ($strict) {
return !isset($this->_errors);
@@ -1064,7 +1064,7 @@
* @param int $tab_width
* @return string
*/
-function expand_tabs($str, $tab_width = 8)
+function expand_tabs(string $str, int $tab_width = 8)
{
$split = explode("\t", $str);
$tail = array_pop($split);
@@ -1088,7 +1088,7 @@
*
* @return string The split name.
*/
-function SplitPagename($page)
+function SplitPagename(string $page): string
{
if (preg_match("/\s/", $page)) {
return $page;
@@ -1184,7 +1184,7 @@
* @param int $time Unix timestamp (defaults to current time).
* @return string Formatted date & time.
*/
-function ncsa_time($time = 0)
+function ncsa_time(int $time = 0)
{
if (!$time) {
$time = time();
@@ -1199,7 +1199,7 @@
* @param bool $no_colon Don't put colon between hours and minutes.
* @return string Offset as a string in the format +HH:MM.
*/
-function TimezoneOffset($time = 0, $no_colon = false)
+function TimezoneOffset(int $time = 0, bool $no_colon = false)
{
if ($time == 0) {
$time = time();
@@ -1229,7 +1229,7 @@
* @param int $time Time. Default: now.
* @return string Date and time in ISO-8601 format.
*/
-function Iso8601DateTime($time = 0)
+function Iso8601DateTime(int $time = 0): string
{
if ($time == 0) {
$time = time();
@@ -1246,7 +1246,7 @@
* @param int $time Time. Default: now.
* @return string Date and time in RFC-2822 format.
*/
-function Rfc2822DateTime($time = 0)
+function Rfc2822DateTime(int $time = 0): string
{
if ($time == 0) {
$time = time();
@@ -1260,7 +1260,7 @@
* @param int $time Time. Default: now.
* @return string Date and time in RFC-1123 format.
*/
-function Rfc1123DateTime($time = 0)
+function Rfc1123DateTime(int $time = 0): string
{
if ($time == 0) {
$time = time();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|