orisai / object-mapper

Raw data mapping to validated objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create without constructor

mabar opened this issue · comments

Support manual creation of objects along with auto mapping

#[CreateWithoutConstructor]
final class ExampleInput extends MappedObject
{

	#[StringValue]
	public string $example;

	public function __construct(string $example)
	{
		$this->example = $example;
	}

}
$input = $processor->process(['example' => 'string'], ExampleInput::class);
$input = new ExampleInput('string');

isInstantiable() check should be probably replaced by checks for string being a class (not interface or enum) and non-abstract. Classes created with constructor should be also checked for public constructor.

Partially solved by e37f84b

isInstantiable() replacement should be still done

Object creator should also hint annotation could be used and which object failed to be created

Finalized by 3ba0c6e and 3c96e57

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.