Skip to content

Style/Cell.php does not accept null values to unset some values #2673

Closed
@SpraxDev

Description

@SpraxDev

Describe the bug and add attachments

Some values like vMerge and vAlign are type-hinted as string (not nullable) although they are initialized as null until explicitly set/parsed.

That means, there is no proper way to unset some values where it would make sense to 'remove' that attribute.
The parameter for setVMerge and setVAlign for example even has a default value of null set, which is not valid according to its type-hint and makes everything even more confusing.

Expected behavior

I think it would make sense to allow null to be set for some attributes and everything to be type-hinted accordingly.

Steps to reproduce

$phpWord = new PhpWord();
$section = $phpWord->addSection();

$table = $section->addTable();
$row = $table->addRow();

$cell = $row->addCell();
$cell->addText('no vAlign');
$cell->getStyle()->setVAlign(VerticalJc::BOTTOM);
$cell->getStyle()->setVAlign();

PHPWord version(s) where the bug happened

master

PHP version(s) where the bug happened

8.3 and all the others

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions