N°3129 PHP 8.0 compat : code review modifications

Many thanks @Molkobain & @Hipska !
This commit is contained in:
Pierre Goiffon
2022-01-31 16:39:46 +01:00
parent dbc3da7bc3
commit 45b5c39af7
3 changed files with 13 additions and 14 deletions

View File

@@ -324,8 +324,10 @@ class DisplayBlock
* @throws DictExceptionMissingString * @throws DictExceptionMissingString
* @throws MySQLException * @throws MySQLException
* @throws Exception * @throws Exception
*
* @since 2.7.7 3.0.1 3.1.0 N°3129 add type hinting to $aExtraParams
*/ */
public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId)
{ {
$sHtml = ''; $sHtml = '';
// Add the extra params into the filter if they make sense for such a filter // Add the extra params into the filter if they make sense for such a filter
@@ -1433,9 +1435,10 @@ class HistoryBlock extends DisplayBlock
* @throws \MySQLException * @throws \MySQLException
* @throws \MySQLHasGoneAwayException * @throws \MySQLHasGoneAwayException
* *
* @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (var is unused, and all calls were already made using a default value) * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams and add type hinting for PHP 8.0 compatibility
* (var is unused, and all calls were already made using a default value)
*/ */
public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId)
{ {
$sHtml = ''; $sHtml = '';
$bTruncated = false; $bTruncated = false;
@@ -1575,14 +1578,10 @@ class MenuBlock extends DisplayBlock
* @throws \MissingQueryArgument * @throws \MissingQueryArgument
* @throws \MySQLException * @throws \MySQLException
* *
* @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $aExtraParams for PHP 8.0 compatibility (added a test at function start to handle wrong values) * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value and add type hinting on $aExtraParams for PHP 8.0 compatibility
*/ */
public function GetRenderContent(WebPage $oPage, $aExtraParams, $sId) public function GetRenderContent(WebPage $oPage, array $aExtraParams, $sId)
{ {
if (empty($aExtraParams)) {
$aExtraParams = [];
}
if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility
{ {
$this->m_sStyle = 'list'; $this->m_sStyle = 'list';

View File

@@ -431,7 +431,7 @@ EOF
* @throws CoreException * @throws CoreException
* @throws OQLException * @throws OQLException
* *
* @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility (a null default value is awkward ?!??) * @since 2.7.7 3.0.1 3.1.0 N°3129 Remove default value for $oObj for PHP 8.0 compatibility
*/ */
public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null) public function AutoComplete(WebPage $oP, $sFilter, $oObj, $sContains, $sOutputFormat = self::ENUM_OUTPUT_FORMAT_CSV, $sOperation = null)
{ {

View File

@@ -2161,7 +2161,7 @@ class MFElement extends Combodo\iTop\DesignElement
EOF; EOF;
throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $iLine, $sPath); throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $iLine, $sPath);
} }
$oExisting->MFReplaceWith($oNode); $oExisting->ReplaceWithSingleNode($oNode);
$sFlag = 'replaced'; $sFlag = 'replaced';
} }
else else
@@ -2208,7 +2208,7 @@ EOF;
throw new MFException($sPath." at line $iLine: could not be modified (marked as deleted)", throw new MFException($sPath." at line $iLine: could not be modified (marked as deleted)",
MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $sPath, $iLine); MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $sPath, $iLine);
} }
$oExisting->MFReplaceWith($oNode); $oExisting->ReplaceWithSingleNode($oNode);
if (!$this->IsInDefinition()) if (!$this->IsInDefinition())
{ {
if ($sPrevFlag == '') if ($sPrevFlag == '')
@@ -2253,7 +2253,7 @@ EOF;
{ {
$sFlag = $sPrevFlag; // added, replaced or '' $sFlag = $sPrevFlag; // added, replaced or ''
} }
$oExisting->MFReplaceWith($oNode); $oExisting->ReplaceWithSingleNode($oNode);
} }
else else
{ {
@@ -2298,7 +2298,7 @@ EOF;
* @since 2.7.7 3.0.1 3.1.0 N°3129 rename method (from `ReplaceWith` to `MFReplaceWith`) to avoid collision with parent `\DOMElement::replaceWith` method (different method modifier and parameters : * @since 2.7.7 3.0.1 3.1.0 N°3129 rename method (from `ReplaceWith` to `MFReplaceWith`) to avoid collision with parent `\DOMElement::replaceWith` method (different method modifier and parameters :
* throws fatal error in PHP 8.0) * throws fatal error in PHP 8.0)
*/ */
protected function MFReplaceWith($oNewNode) protected function ReplaceWithSingleNode($oNewNode)
{ {
// Move the classes from the old node into the new one // Move the classes from the old node into the new one
if ($this->IsClassNode()) if ($this->IsClassNode())