Skip to content

strlen(): Passing null #2792

Open
Open
@KeoChien

Description

@KeoChien

Describe the bug and add attachments

phpword 1.4.0 + PHP 8.2
\PhpOffice\PhpWord\IOFactory::load($path);
【strlen(): Passing null to parameter #1 ($string) of type string is deprecated】

Expected behavior

找到 Language.php 文件中的 validateLocale() 方法(第 235 行附近),添加对 null 值的检查

public function validateLocale($locale)
{
if ($locale === null) {
// 处理 null 值的情况,例如返回默认值或抛出异常
return $this->locale;
}

Steps to reproduce

\PhpOffice\PhpWord\IOFactory::load($path);

PHPWord version(s) where the bug happened

1.4.0

PHP version(s) where the bug happened

8.1/8.2

Priority

  • I want to crowdfund the bug fix (with @algora-io) and fund a community developer.
  • I want to pay the bug fix and fund a maintainer for that. (Contact @Progi1984)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions