Skip to content

TypeError : abs(): Argument #1 ($num) must be of type int|float, string given #3128

Closed
@ma-gnesium

Description

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Formatting a number with no run-time error

What is the current behavior?

TypeError : abs(): Argument #1 ($num) must be of type int|float, string given
in PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php:74

What are the steps to reproduce?

Please provide a [Minimal, Complete, and Verifiable example]

As a unit test :

<?php

use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use PHPUnit\Framework\TestCase;

class NumberFormatTest extends TestCase
{
    public function testSmallValueWithComplexFormat(): void
    {
        $result = NumberFormat::toFormattedString(1E-17, '0 000.0');

        self::assertEquals('0 000.0', $result);
    }
}

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

This issue is independent of the spreadsheet file format used

Which versions of PhpSpreadsheet and PHP are affected?

Don't know exactly.
I'm currently using PHPSpreadsheet version 1.25.2 and PHP 8.1.9

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