Phpro\SoapClient\CodeGenerator\Assembler\PropertyAssembler::assemble PHP Метод

assemble() публичный Метод

public assemble ( Phpro\SoapClient\CodeGenerator\Context\ContextInterface $context )
$context Phpro\SoapClient\CodeGenerator\Context\ContextInterface
    public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $property = $context->getProperty();
        try {
            // It's not possible to overwrite a property in zend-code yet!
            if ($class->hasProperty($property->getName())) {
                return;
            }
            $class->addPropertyFromGenerator(PropertyGenerator::fromArray(['name' => $property->getName(), 'visibility' => PropertyGenerator::VISIBILITY_PROTECTED, 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'var', 'description' => $property->getType()]]])]));
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }

Usage Example

Пример #1
0
    /**
     * @test
     */
    function it_assembles_a_property()
    {
        $assembler = new PropertyAssembler();
        $context = $this->createContext();
        $assembler->assemble($context);
        $code = $context->getClass()->generate();
        $expected = <<<CODE
namespace MyNamespace;

class MyType
{

    /**
     * @var string
     */
    protected \$prop1 = null;


}

CODE;
        $this->assertEquals($expected, $code);
    }
PropertyAssembler