Skip to content

Deprecated: Implicitly nullable parameter $referenceTableName in Audit::addConstraint() #70

@sca1235

Description

@sca1235

Issue Description:

While using vcian/laravel-db-auditor, the following deprecation warning is thrown:

Deprecated: Vcian\LaravelDBAuditor\Traits\Audit::addConstraint(): Implicitly marking parameter $referenceTableName as nullable is deprecated, the explicit nullable type must be used instead in /vendor/vcian/laravel-db-auditor/src/Traits/Audit.php on line 92

This is due to a change in PHP where function parameters with a default value of null must now explicitly be marked as nullable.

File: vendor/vcian/laravel-db-auditor/src/Traits/Audit.php

Line: 92

Current Code:

public function addConstraint(
    string $table,
    string $field,
    string $constraint,
    string $referenceTableName = null,
    string $referenceField = null
): bool

Proposed Fix:

To resolve this deprecation, the $referenceTableName and $referenceField parameters in the addConstraint function should be explicitly declared as nullable by prefixing their type with a question mark (?).

Updated Code:

public function addConstraint(
    string $table,
    string $field,
    string $constraint,
    ?string $referenceTableName = null,
    ?string $referenceField = null
): bool

This change will make the code compliant with the latest PHP standards and remove the deprecation warning.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions