Skip to content

Deprecated: Implicit conversion from float 10.5 to int loses precision #2526

Closed
@nudl3s

Description

@nudl3s

Describe the Bug

My PHP version is 8.3. When I am trying to load some file gives me some warnings for deprecated code.

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
$phpWord = IOFactory::load($file, 'MsDoc');

Current Behavior

Deprecated: Implicit conversion from float 10.5 to int loses precision at PhpWord\Reader\MsDoc.php:1868
Deprecated: Creation of dynamic property PhpOffice\PhpWord\Shared\OLERead::$entry is deprecated (For all properties inside this file)

Context

Please fill in your environment information:

  • PHP Version: 8.3
  • PHPWord Version: 1.1.0

Possible solution

In MsDoc.php at line 1868, use (int) to cast the result of the division to an integer explicitly.
$oStylePrl->styleFont['size'] = dechex((int) ($operand / 2));

To fix the second type deprecations, declare the properties in the class instead of dynamically creating it.

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