2017 © Pedro Peláez
 

library com_jjcbs_tool

Publish package about jjcbs use some class file on working!

image

ndj888/com_jjcbs_tool

Publish package about jjcbs use some class file on working!

  • Thursday, July 19, 2018
  • by ndj888
  • Repository
  • 1 Watchers
  • 8 Stars
  • 83 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 19 Versions
  • 43 % Grown

The README.md

简介:

个人常用工具类封装phar包, (*1)

Vesion

The Project release version v0.1., (*2)

use composer

composer require ndj888/com_jjcbs_tool, (*3)

注解

为了提高编程效率,开始采用注解模式,解决注入POPO解耦。, (*4)

使用注解

注解方法:

定义注解需实现于com_jjcbs\lib\AnnotationMethodAbstract,例: ex;, (*5)

    namespace com_jjcbs\lib\annotation;


    use com_jjcbs\exceptions\AnnotationException;
    use com_jjcbs\fun\AnnotationFun;
    use com_jjcbs\lib\AnnotationMethodAbstract;

    /**
     * format of type json serialize
     * Class OutPutFormat
     * @package com_jjcbs\lib\annotation
     */
    class OutPutFormat extends AnnotationMethodAbstract
    {
        static protected function parsedMethod($data = null)
        {
            // TODO: Implement parsedMethod() method.
            self::parseMethodExec($data);
        }

        static protected function parsedClass($data = null)
        {
            // TODO: Implement parsedClass() method.
            return 'disable';
        }

        static protected function parsedVar($data = null)
        {
            // TODO: Implement parsedVar() method.
            $getterStr = AnnotationFun::createGetterByVar(self::$argv['varName'] , $data);
            self::$input = str_replace('//{{annotation placeholder}}' , $getterStr , self::$input);
        }

        static protected function do()
        {
            // TODO: Implement do() method.
            switch (self::$param['type']){
                case 'json':
                    if(isset(self::$argv['varName'])) return sprintf('return json_decode($this->%s , true);' , self::$argv['varName']);
                    if(isset(self::$argv['methodName'])) return 'return json_decode(%s , true)';
                    break;
                default:break;

            }
        }

        static protected function exception(AnnotationException $exception)
        {
            // TODO: Implement exception() method.
            // no thing
            return ;
        }


    }

使用注解

```$xslt, (*6)

/**
 * @@OutPutFormat(type="json")
 * @return array
 */
public function getJson(){
    return $this->getArr();
}
所有注解推荐定义以@@注释开始,如@@OutPutFormat()
### 注解的作用范围
1. 作用于成员变量的注解

    ```
            /**
             * @@com_jjcbs\lib\annotation\OutPutFormat(type="json")
             * @var string
             */
            private $type = '123';
    ```

2. 作用于成员方法的注解

    ```
    /**
     * @@OutPutFormat(type="json")
     * @return array
     */
    public function getJson(){
        return $this->getArr();
    }
    ```
3. 作用于类的注解

```$xslt
/**
 * @@Service()
 * Class TestServiceAnnotation
 * @package com_jjcbs\test\resource\scan
 */
class TestServiceAnnotation
{
    public function testGetInfo(){
        return 'hellow world';
    }
}

编译注解

推荐自行实现编译小工具 ex:, (*7)

// 创建以文件试编译注解驱动
$annotationFileCacheDriver = new \com_jjcbs\lib\drivers\AnnotationFileCacheDriverImpl();
//获取配置单例,设置配置
$annotationConfig = \com_jjcbs\lib\ServiceFactory::getInstance(\com_jjcbs\service\AnnotationConfigServiceImpl::class);
\com_jjcbs\lib\conf\AnnotationConfig::setData([
    // the alias map
    // 设置别名映射,方便使用短名称,否则需要使用命名空间全名注解方法
    'alias' => [
        'Service' => Service::class,
        'Rpc' => Rpc::class,
        'OutPutFormat' => OutPutFormat::class
    ],
    // These annotations will be scanning
    // 所有composer psr-4定义的autoload命名空间将被扫描
    // These annotations will be scanning
    'scanNamespace' => [
        "com_jjcbs\\" => "src/com_jjcbs/"
    ],
    // 项目根目录
    'appPath' => COM_JJCBS_ROOT_PATH,
    // build 目录注意 /
    'buildPath' => COM_JJCBS_ROOT_PATH . '/build/'
]);
    // 扫描编译注解
$annotationFileCacheDriver->scanNamespacesFiles();    

编译成完得到build目录,替换原有composer命名空间即可工作。, (*8)

The Versions

19/07 2018

dev-master

9999999-dev

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

19/07 2018

v1.17

1.17.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

13/07 2018

v1.15.2

1.15.2.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

13/07 2018

v1.16

1.16.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

02/12 2017

v1.15

1.15.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

02/12 2017

dev-dev

dev-dev

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

30/11 2017

v1.14

1.14.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

29/11 2017

v1.13

1.13.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

23/11 2017

v1.12

1.12.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

22/11 2017

v1.11

1.11.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

22/11 2017

v1.1

1.1.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

21/11 2017

v1.0

1.0.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

20/11 2017

v0.16

0.16.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

17/11 2017

v0.15

0.15.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

17/11 2017

v0.14

0.14.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

30/09 2017

v0.12

0.12.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

30/09 2017

v0.13

0.13.0.0

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

30/09 2017

v0.1.x-dev

0.1.9999999.9999999-dev

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs

05/09 2017

v0.11.x-dev

0.11.9999999.9999999-dev

Publish package about jjcbs use some class file on working!

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

mytool com_jjcbs