Skip to content

strlen(): Passing null #2792

@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)

Activity

KeoChien

KeoChien commented on Jun 16, 2025

@KeoChien
Author

Image

Progi1984

Progi1984 commented on Jun 21, 2025

@Progi1984
Member

@KeoChien Could you send the file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Progi1984@KeoChien

        Issue actions

          strlen(): Passing null · Issue #2792 · PHPOffice/PHPWord