Skip to content

Spanner ValueMapper: PHP 8.5 "null as array/key" deprecations in paramType / isCustomType #9129

@dkkoma

Description

@dkkoma

Two PHP 8.5 deprecation warnings still fire from Spanner/src/ValueMapper.php on every Spanner call that binds parameters.

Locations

On current main (v2.6.1):

1. paramType() — L430

if (isset(self::$typeCodes[$givenType])) {

$givenType defaults to null and callers also pass null, triggering:

Using null as an array offset is deprecated, use an empty string instead

2. isCustomType() — L892

private static function isCustomType(string|null $type): bool
{
    return array_key_exists($type, self::$typeToClassMap);
}

The signature accepts string|null, but null goes straight to array_key_exists():

Using null as the key parameter for array_key_exists() is deprecated, use an empty string instead

Suggested Fix

Add null-guards:

// paramType()
if ($givenType !== null && isset(self::$typeCodes[$givenType])) {
// isCustomType()
return $type !== null && array_key_exists($type, self::$typeToClassMap);

Environment

  • PHP 8.5.5
  • google/cloud-spanner v2.6.1 / main

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