PHPOffice / PHPWord

A pure PHP library for reading and writing word processing documents

Home Page:https://phpoffice.github.io/PHPWord/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deprecated: Implicit conversion from float 10.5 to int loses precision

nudl3s opened this issue · comments

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.

The missing properties were defined in PR #2440, which has been merged but which is not yet part of a release (there is a beta release available which includes it).