N°8851 - Explicit nullable in functions parameters (#857)

This commit is contained in:
Lenaick
2026-03-26 15:52:57 +01:00
committed by GitHub
parent 398b47d5d1
commit aae6d324f9
42 changed files with 52 additions and 52 deletions

View File

@@ -691,7 +691,7 @@ abstract class LogAPI
static::$m_oMockMetaModelConfig = $oMetaModelConfig;
}
public static function Exception(string $sMessage, throwable $oException, string $sChannel = null, array $aContext = []): void
public static function Exception(string $sMessage, throwable $oException, ?string $sChannel = null, array $aContext = []): void
{
$aErrorLogs = [];
$aErrorLogs[] = static::PrepareErrorLog($sMessage, $oException, $aContext);

View File

@@ -14,7 +14,7 @@ class ModuleFileReaderException extends Exception
* @param int $iHttpCode
* @param Exception|null $oPrevious
*/
public function __construct($sMessage, $iHttpCode = 0, Exception $oPrevious = null, $sModuleFile = null)
public function __construct($sMessage, $iHttpCode = 0, ?Exception $oPrevious = null, $sModuleFile = null)
{
$e = new Exception("");

View File

@@ -738,7 +738,7 @@ abstract class Controller extends AbstractController
*
* @param string $sCode Code of the tab
*/
public function AddAjaxTab(string $sCode, string $sURL, bool $bCache = true, string $sLabel = null): void
public function AddAjaxTab(string $sCode, string $sURL, bool $bCache = true, ?string $sLabel = null): void
{
if (is_null($sLabel)) {
$sLabel = Dict::S($sCode);

View File

@@ -22,7 +22,7 @@ class TurboForm extends UIContentBlock
protected ?string $sAction;
private FormView $oFormView;
public function __construct(FormView $oFormView, string $sId = null)
public function __construct(FormView $oFormView, ?string $sId = null)
{
parent::__construct($sId);
$this->oFormView = $oFormView;

View File

@@ -36,7 +36,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm An HTML form in which you can add UIBlocks
*/
public static function MakeStandard(FormView $oFormView, string $sAction = null, string $sId = null): TurboForm
public static function MakeStandard(FormView $oFormView, ?string $sAction = null, ?string $sId = null): TurboForm
{
$oTurboForm = new TurboForm($oFormView, $sId);
if (!is_null($sAction)) {
@@ -57,7 +57,7 @@ class TurboFormUIBlockFactory extends AbstractUIBlockFactory
* @return \Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboForm
* @throws \Combodo\iTop\Forms\Block\FormBlockException
*/
public static function MakeForDashletConfiguration(string $sDashletId, array $aData = [], string $sId = null): TurboForm
public static function MakeForDashletConfiguration(string $sDashletId, array $aData = [], ?string $sId = null): TurboForm
{
$oBlockForm = FormBlockService::GetInstance()->GetFormBlockById($sDashletId, 'Dashlet');
$oController = new FormsController();

View File

@@ -16,7 +16,7 @@ class TurboStream extends UIContentBlock
private string $sTarget;
private string $sAction;
public function __construct(string $sTarget, string $sAction, string $sId = null)
public function __construct(string $sTarget, string $sAction, ?string $sId = null)
{
parent::__construct($sId);
$this->sTarget = $sTarget;

View File

@@ -31,7 +31,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
*/
public static function MakeUpdate(string $sTarget, string $sId = null): TurboStream
public static function MakeUpdate(string $sTarget, ?string $sId = null): TurboStream
{
return new TurboStream($sTarget, 'update', $sId);
}
@@ -44,7 +44,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
*/
public static function MakeReplace(string $sTarget, string $sId = null): TurboStream
public static function MakeReplace(string $sTarget, ?string $sId = null): TurboStream
{
return new TurboStream($sTarget, 'replace', $sId);
}
@@ -57,7 +57,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
*/
public static function MakePrepend(string $sTarget, string $sId = null): TurboStream
public static function MakePrepend(string $sTarget, ?string $sId = null): TurboStream
{
return new TurboStream($sTarget, 'prepend', $sId);
}
@@ -70,7 +70,7 @@ class TurboStreamUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\TurboUpdate\TurboStream An HTML form in which you can add UIBlocks
*/
public static function MakeAppend(string $sTarget, string $sId = null): TurboStream
public static function MakeAppend(string $sTarget, ?string $sId = null): TurboStream
{
return new TurboStream($sTarget, 'append', $sId);
}

View File

@@ -51,7 +51,7 @@ class ErrorPage extends NiceWebPage
$this->log_warning($sText);
}
public function error($sText, \Throwable $oException = null)
public function error($sText, ?\Throwable $oException = null)
{
$this->add("<div class=\"message message-error\">$sText</div>");
if (utils::IsEasterEggAllowed()) {

View File

@@ -67,12 +67,12 @@ class AttributeBlob extends AttributeDefinition
return true;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return new ormDocument('', '', '');
}
public function IsNullAllowed(DBObject $oHostObject = null)
public function IsNullAllowed(?DBObject $oHostObject = null)
{
return $this->GetOptional("is_null_allowed", false);
}

View File

@@ -121,7 +121,7 @@ class AttributeCaseLog extends AttributeLongText
}
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return new ormCaseLog();
}

View File

@@ -32,7 +32,7 @@ class AttributeClass extends AttributeString
parent::__construct($sCode, $aParams);
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
$sDefault = parent::GetDefaultValue($oHostObject);
if (!$this->IsNullAllowed() && $this->IsNull($sDefault)) {

View File

@@ -61,7 +61,7 @@ class AttributeCustomFields extends AttributeDefinition
return false;
} // See ReadValue...
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return new ormCustomFieldsValue($oHostObject, $this->GetCode());
}

View File

@@ -21,7 +21,7 @@ class AttributeDBField extends AttributeDBFieldVoid
return array_merge(parent::ListExpectedParams(), ["default_value", "is_null_allowed"]);
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->MakeRealValue($this->Get("default_value"), $oHostObject);
}

View File

@@ -83,7 +83,7 @@ class AttributeDBFieldVoid extends AttributeDefinition
return $this->Get("sql");
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->MakeRealValue("", $oHostObject);
}

View File

@@ -63,7 +63,7 @@ class AttributeDashboard extends AttributeDefinition
return "";
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return null;
}

View File

@@ -244,7 +244,7 @@ class AttributeDateTime extends AttributeDBField
return $iUnixSeconds;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
$sDefaultValue = $this->Get('default_value');
if (utils::IsNotNullOrEmptyString($sDefaultValue)) {

View File

@@ -875,7 +875,7 @@ abstract class AttributeDefinition
return null;
}
abstract public function GetDefaultValue(DBObject $oHostObject = null);
abstract public function GetDefaultValue(?DBObject $oHostObject = null);
//
// To be overloaded in subclasses

View File

@@ -326,7 +326,7 @@ class AttributeExternalField extends AttributeDefinition
return $oExtAttDef->GetSQLExpr();
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
$oExtAttDef = $this->GetExtAttDef();

View File

@@ -112,7 +112,7 @@ class AttributeExternalKey extends AttributeDBFieldVoid
return $this->GetOptional('display_style', 'select');
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return 0;
}

View File

@@ -50,7 +50,7 @@ class AttributeFinalClass extends AttributeString
$this->m_sValue = $sValue;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->m_sValue;
}

View File

@@ -133,7 +133,7 @@ class AttributeFriendlyName extends AttributeDefinition
$this->m_sValue = $sValue;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->m_sValue;
}

View File

@@ -74,7 +74,7 @@ class AttributeImage extends AttributeBlob
return $oDoc;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return new ormDocument('', '', '');
}

View File

@@ -122,7 +122,7 @@ class AttributeLinkedSet extends AttributeDefinition
* @throws CoreException
* @throws CoreWarning
*/
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
if ($oHostObject === null) {
return null;

View File

@@ -52,7 +52,7 @@ class AttributeObjectKey extends AttributeDBFieldVoid
return "INT(11)".($bFullSpec ? " DEFAULT 0" : "");
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return 0;
}

View File

@@ -109,7 +109,7 @@ class AttributeObsolescenceFlag extends AttributeBoolean
return null;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->MakeRealValue(false, $oHostObject);
}

View File

@@ -64,7 +64,7 @@ class AttributeOneWayPassword extends AttributeDefinition implements iAttributeN
return true;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return "";
}

View File

@@ -93,7 +93,7 @@ class AttributeRedundancySettings extends AttributeDBField
return 20;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
$sRet = 'disabled';
if ($this->Get('enabled')) {

View File

@@ -131,7 +131,7 @@ abstract class AttributeSet extends AttributeDBFieldVoid
return true;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return null;
}

View File

@@ -72,7 +72,7 @@ class AttributeStopWatch extends AttributeDefinition
return true;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return $this->NewStopWatch();
}

View File

@@ -117,7 +117,7 @@ class AttributeSubItem extends AttributeDefinition
return false;
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
return null;
}

View File

@@ -276,7 +276,7 @@ class AttributeTagSet extends AttributeSet
return new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
}
public function GetDefaultValue(DBObject $oHostObject = null)
public function GetDefaultValue(?DBObject $oHostObject = null)
{
$oTagSet = new ormTagSet(MetaModel::GetAttributeOrigin($this->GetHostClass(), $this->GetCode()), $this->GetCode(), $this->GetMaxItems());
$oTagSet->SetValues([]);

View File

@@ -253,7 +253,7 @@ abstract class AbstractFormBlock implements IFormBlock
* @throws FormBlockIOException
* @throws RegisterException
*/
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null): AbstractFormBlock
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null): AbstractFormBlock
{
$this->oIORegister->AddOutput($sName, $sType, $bIsArray, $oConverter);
return $this;
@@ -413,7 +413,7 @@ abstract class AbstractFormBlock implements IFormBlock
*
* @return bool
*/
public function IsInputsDataReady(string $sType = null): bool
public function IsInputsDataReady(?string $sType = null): bool
{
return $this->oIORegister->IsInputsDataReady($sType);
}

View File

@@ -53,7 +53,7 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
* @return bool
* @throws FormBlockException
*/
public function IsVisible(string $sEventType = null): bool
public function IsVisible(?string $sEventType = null): bool
{
$oInput = $this->GetInput(self::INPUT_VISIBLE);
if (!$oInput->IsBound()) {
@@ -68,7 +68,7 @@ abstract class AbstractTypeFormBlock extends AbstractFormBlock
/**
* @return true
*/
public function AllowAdd(string $sEventType = null): bool
public function AllowAdd(?string $sEventType = null): bool
{
return true;
}

View File

@@ -20,12 +20,12 @@ class FormBlockService
{
private static FormBlockService $oInstance;
protected function __construct(ModelReflection $oModelReflection = null)
protected function __construct(?ModelReflection $oModelReflection = null)
{
ServiceLocator::GetInstance()->RegisterService('ModelReflection', $oModelReflection ?? new ModelReflectionRuntime());
}
final public static function GetInstance(ModelReflection $oModelReflection = null): FormBlockService
final public static function GetInstance(?ModelReflection $oModelReflection = null): FormBlockService
{
if (!isset(static::$oInstance)) {
static::$oInstance = new FormBlockService($oModelReflection);

View File

@@ -161,7 +161,7 @@ class DependencyHandler
* @return void
* @throws FormBlockException
*/
private function CheckDependencies(FormInterface|FormBuilderInterface $oForm, string $sOutputBlock = null, string $sEventType = null): void
private function CheckDependencies(FormInterface|FormBuilderInterface $oForm, ?string $sOutputBlock = null, ?string $sEventType = null): void
{
$aImpactedBlocks = $this->aDependentBlocks;
if ($sOutputBlock !== null) {

View File

@@ -171,7 +171,7 @@ class DependencyMap
*
* @return array|null
*/
public function GetBlocksImpactedBy(string $sBlockName, callable $oFilter = null): ?array
public function GetBlocksImpactedBy(string $sBlockName, ?callable $oFilter = null): ?array
{
if (!array_key_exists($sBlockName, $this->aBlocksImpactedBy)) {
return null;

View File

@@ -164,7 +164,7 @@ class AbstractFormIO
*
* @return mixed
*/
public function GetValue(string $sEventType = null): mixed
public function GetValue(?string $sEventType = null): mixed
{
if ($sEventType === null) {
return $this->Value();
@@ -190,7 +190,7 @@ class AbstractFormIO
*
* @return bool
*/
public function HasEventValue(string $sEventType = null): bool
public function HasEventValue(?string $sEventType = null): bool
{
if ($sEventType === null) {
return $this->HasValue();

View File

@@ -28,7 +28,7 @@ class FormInput extends AbstractFormIO
*
* @return bool
*/
public function IsEventDataReady(string $sEventType = null): bool
public function IsEventDataReady(?string $sEventType = null): bool
{
return $this->HasEventValue($sEventType);
}

View File

@@ -34,7 +34,7 @@ class FormOutput extends AbstractFormIO
*
* @throws FormBlockIOException
*/
public function __construct(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null)
public function __construct(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null)
{
parent::__construct($sName, $sType, $bIsArray);
$this->oConverter = $oConverter;

View File

@@ -135,7 +135,7 @@ class IORegister
* @throws FormBlockIOException
* @throws RegisterException
*/
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, AbstractConverter $oConverter = null): void
public function AddOutput(string $sName, string $sType, bool $bIsArray = false, ?AbstractConverter $oConverter = null): void
{
$oFormOutput = new FormOutput($sName, $sType, $bIsArray, $oConverter);
$oFormOutput->SetOwnerBlock($this->oFormBlock);
@@ -349,7 +349,7 @@ class IORegister
*
* @return bool
*/
public function IsInputsDataReady(string $sType = null): bool
public function IsInputsDataReady(?string $sType = null): bool
{
foreach ($this->aInputs as $oFormInput) {
if ($oFormInput->IsBound()) {

View File

@@ -38,7 +38,7 @@ class AttributeExist extends Constraint
* @param array|null $aGroups
* @param mixed|null $oPayload
*/
public function __construct(string $sOqlPropertyPath = null, string $sFilter = null, array $aOptions = [], ?array $aGroups = null, mixed $oPayload = null)
public function __construct(?string $sOqlPropertyPath = null, ?string $sFilter = null, array $aOptions = [], ?array $aGroups = null, mixed $oPayload = null)
{
if ($sOqlPropertyPath === null) {
throw new InvalidArgumentException('The argument "sOqlPropertyPath" must be set.');

View File

@@ -18,7 +18,7 @@ use utils;
*/
class PropertyTypeDesign extends DesignDocument
{
public function __construct(string $sDesignSourceId = null, string $sType = 'Default')
public function __construct(?string $sDesignSourceId = null, string $sType = 'Default')
{
parent::__construct();