Skip to content

Extending php code builder features #61

@GeorgII-web

Description

@GeorgII-web

Hello, respectful maintainers!

Great tool.
Is it possible to extend the PHP Builder to make classes with a more strict typing?

Trying to generate a class that will validate values not only at the end, but for every property.
The problem is: only in a runtime it will fail on validation, but I would like to have a proper PSALM static analysis and type hinting on IDE, before running any code.

Method setId() should guarantee positive-int value even before code "compiled", and as a bonus, fail on setting an invalid value.

Like this:

    /**
     * @param positive-int $id
     */
    public function setId(int $id): self
    {
        \Webmozart\Assert\Assert::greaterThan($id, 0);
        $this->id = $id;
        return $this;
    }

I may try to add this functionality, but need some help, an entry point.
Thank you anyway

Metadata

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