承接 sourecode/php-object-model 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sourecode/php-object-model

Composer 安装命令:

composer require sourecode/php-object-model

包简介

README 文档

README

A superset to the PHP Parser library that allows you to parse and manipulate PHP code. The idea is to create a model to manipulate PHP code like in javascript.

Installation

composer require sourecode/php-object-model

Usage

<?php

use SoureCode\PhpObjectModel\File\ClassFile;
use SoureCode\PhpObjectModel\Model\ClassModel;
use SoureCode\PhpObjectModel\Model\PropertyModel;
use SoureCode\PhpObjectModel\Type\StringType;
use SoureCode\PhpObjectModel\ValueObject\NamespaceName;

$classFile = new ClassFile('<?php');
$classFile
    ->setDeclare((new DeclareModel())->setStrictTypes(true))
    ->setNamespace(new NamespaceModel(NamespaceName::fromString('App\\Foo')))
    ->setClass(
        (new ClassModel('Foo'))
            ->addProperty(
                (new PropertyModel('foo'))
                ->setType(new StringType())
                ->setPublic(true)
            )
    );

echo $classFile->getSourceCode();

Generates something like this:

<?php

declare(strict_types=1);

namespace App\Foo;

class Foo
{
    public string $foo;
}

For more examples see the tests.

统计信息

  • 总下载量: 73
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固