blacktools/metabot 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

blacktools/metabot

Composer 安装命令:

composer require blacktools/metabot

包简介

Php code that code php code.

README 文档

README

PhpMetaBot is a very minimal framework that makes easy to write "php code from php code". It can be a lot useful to make CLI commands that generate scaffold codes from different needs. Let your creativity fly. Feel free to fork and do whatever you want. I done it just for fun.

Install

Via Composer

$ composer require blacktools/metabot

Usage

/* or require 'vendor/autoload.php' */
require '../src/Code.php';
require '../src/PhpClass.php';
require '../src/PhpFile.php';
require '../src/PhpFunction.php';
require '../src/PhpMethod.php';

use Blacktools\Metabot\Base\PhpFile;
use Blacktools\Metabot\Base\PhpClass;
use Blacktools\Metabot\Base\PhpMethod;
use Blacktools\Metabot\Base\PhpFunction;

/* Create a PhpFile */
$file = new PhpFile('test.php');

/* Create a PhpClass */
$class = new PhpClass("ClassTest");
/* Set extends to a class: name */
$class->setExtends('ExtendTest');
/* Set implements to a class: name */
$class->setImplements('ImplementTest');
/* Set attribute to a class: scope / name */
$class->setAttribute('private','attributeTest');
/* Set attribute to a class: scope / name */
$class->setAttribute('private static','staticAtribute');

/* Create a PhpMethod: scope / name */
$methodTest = new PhpMethod("public","methodTest");
/* Set a parameter to a method: typehint / name  */
$methodTest->setParameter(null, "foo");
/* Set a parameter to a method: typehint / name / default */
$methodTest->setParameter(null, "bar","'zoo'");
/* Set inner content to a method, using \t for tabs and \n for break lines  */
$methodTest->setInner("\t\treturn null;\n");

/* Create a static PhpMethod: scope / name */
$staticMethod = new PhpMethod("public static","staticMethod");
/* Set a parameter to a method: typehint / name / default */
$staticMethod->setParameter('int', "xoo","'hoo'");
/* Set inner content to a method, using \t for tabs and \n for break lines  */
$staticMethod->setInner("\t\treturn ".'$xoo'.";\n");

/* Add PhpMethod to a PhpClass */
$class->setMethod($methodTest);
/* Add another PhpMethod to a PhpClass */
$class->setMethod($staticMethod);

/* Create PhpFunction: name */
$function = new PhpFunction('hey');

/* Set a namespace to a PhpFile */
$file->setNamespace('Test\Namespace');
/* Set a use keyword to a PhpFile */
$file->setUse('AnotherTest\UseThis');
/* Write a PhpClass in the PhpFile */
$file->setClass($class);
/* Write a PhpFunction in the PhpFile */
$file->setFunction($function);

/* Get the code as string */
echo $file->getBody();

// Returns

// <?php 
//
// namespace Test\Namespace;
//
// use AnotherTest\UseThis;
//
///**
// * Class ClassTest
// */
// class ClassTest extends ExtendTest implements ImplementTest
// {
//
//		private $attributeTest;
//		private static $staticAtribute;
//
//		public function methodTest($foo, $bar = 'default')
//		{
//
//			return null;
//		}
//
//		public static function staticMethod(int $xoo = 'hoo')
//		{
//
//			return $xoo;
//		}
//	
// }
//
///**
// * Function hey
// */
// function hey()
// {
//
// }

Security

If you discover any security related issues, please email hriqueft@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固