Skip to content

Commit

Permalink
#
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlin committed Jun 1, 2021
1 parent c71e102 commit bd8e3b1
Show file tree
Hide file tree
Showing 11 changed files with 928 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.idea/
vendor/

.DS_Store
.php_cs.cache
composer.lock
120 changes: 120 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

/**
* 退出码列表
*
* 0 - OK.
* 1 - General error (or PHP minimal requirement not matched).
* 4 - Some files have invalid syntax (only in dry-run mode).
* 8 - Some files need fixing (only in dry-run mode).
* 16 - Configuration error of the application.
* 32 - Configuration error of a Fixer.
* 64 - Exception raised within the application.
*/
return (new Config())->setRules([
'@PhpCsFixer' => true,

'dir_constant' => true, // dirname(__FILE__) 替换为 __DIR__
'ereg_to_preg' => true, // preg 替换 ereg
'no_unset_cast' => false, // 允许使用 unset
'echo_tag_syntax' => ['format' => 'long'], // 允许使用 <?= 来输出

'void_return' => true, // 为无返回添加 void
'strict_param' => true, // 严格的参数
'static_lambda' => false, // 禁止将匿名函数声明为 static
'phpdoc_summary' => false, // phpdoc 摘要结束符不限制
'strict_comparison' => true, // 严格的比较符
'single_line_throw' => true, // 异常抛出只占一行
'heredoc_indentation' => true, // heredoc nowdoc 必须适当缩进
'protected_to_private' => false, // 禁止 protected 转 private
'combine_nested_dirname' => true, // dirname 不能嵌套,而是用 $level
'ternary_to_null_coalescing' => true, // 在需要的地方使用 ?? 合并运算符
'no_superfluous_phpdoc_tags' => false, // 参数注释的规则

// 注释
'phpdoc_line_span' => true, // 注释单行转多行 (const, method, property)
'phpdoc_to_param_type' => true, // 修复注释的参数类型
'phpdoc_to_return_type' => true, // 修复注释的返回类型
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false], // 补全缺失的参数注释

'not_operator_with_space' => false, // 否定 ! 操作符前后不允许有空格
'php_unit_test_class_requires_covers' => false, // 禁止添加 @coversNothing
'nullable_type_declaration_for_default_null_value' => true, // 参数默认值为 null 的,为其声明类型前加上?
// 数组声明使用短语法
'list_syntax' => ['syntax' => 'short'],
'array_syntax' => ['syntax' => 'short'],

// 删除错误抑制符 @
'error_suppression' => ['noise_remaining_usages' => true],

// 多行参数每行一个
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],

// 赋值声明中 = 应该被空格环绕
'declare_equal_normalize' => ['space' => 'single'],

// 在分号之前禁止多行空格或将分号移动到新行
'multiline_whitespace_before_semicolons' =>
[
'strategy' => 'no_multi_line',
],

// 删除多余的空白行
'no_extra_blank_lines' => ['tokens' =>
[
'extra', 'break', 'continue',
]],

// 为原生和全局方法添加反斜杠
'native_function_invocation' =>
[
'include' => ['@all'],
'scope' => 'all',
'strict' => true,
],

// 二进制运算符排列
'binary_operator_spaces' =>
[
'default' => 'align_single_space_minimal',
],

// 花括号的处理
'braces' =>
[
'allow_single_line_closure' => true,
'position_after_control_structures' => 'next',
'position_after_anonymous_constructs' => 'next',
'position_after_functions_and_oop_constructs' => 'next',
],

// 命名空间引入
'global_namespace_import' =>
[
'import_classes' => true,
'import_constants' => false,
'import_functions' => false,
],

// 引入顺序
'ordered_imports' =>
[
'sort_algorithm' => 'length',
'imports_order' => ['const', 'function', 'class'],
],

// 以下语句开始前需要空一行
'blank_line_before_statement' => ['statements' =>
[
'case', 'declare', 'default', 'do', 'for', 'foreach', 'goto', 'if',
'return', 'switch', 'throw', 'try', 'while', 'exit'
]],
])
->setFinder(Finder::create()
->in(__DIR__)
->exclude('vendor')
);
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 lanlin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# phptars-ide-helper
IDE Helper For PHPTars Extension
# PHPTars IDE Helper

[![Packagist Version (including pre-releases)](https://img.shields.io/packagist/v/lanlin/phptars-ide-helper?include_prereleases)](https://packagist.org/packages/lanlin/phptars-ide-helper)
[![Packagist Stars](https://img.shields.io/packagist/stars/lanlin/phptars-ide-helper)](https://packagist.org/packages/lanlin/phptars-ide-helper)
[![Total Downloads](https://img.shields.io/packagist/dt/lanlin/phptars-ide-helper)](https://packagist.org/packages/lanlin/phptars-ide-helper)
[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/lanlin/phptars-ide-helper)](https://packagist.org/packages/lanlin/phptars-ide-helper)
[![License](https://img.shields.io/github/license/lanlin/phptars-ide-helper)](https://github.com/lanlin/phptars-ide-helper#license)

This package contains IDE help files for [PHPTars](https://github.com/lanlin/phptars-php8) Extension.

You may use it in your IDE to provide accurate autocompletion.


## Install

```shell
composer require --dev lanlin/phptars-ide-helper
```


## License

This project is licensed under the MIT license.
19 changes: 19 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "lanlin/phptars-ide-helper",
"description": "IDE Helper For PHPTars Extension",
"license": "MIT",
"authors" : [
{
"name": "lanlin",
"email": "[email protected]"
}
],
"autoload": {
"psr-4": {
"\\": "src/"
}
},
"require": {
"php": ">=7.0"
}
}
31 changes: 31 additions & 0 deletions src/TARS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* ----------------------------------------------------------------------------------
* Tars
* ----------------------------------------------------------------------------------
*
* @author lanlin
* @change 2021/06/01
*/
class TARS
{
// ------------------------------------------------------------------------------

const BOOL = 1;
const CHAR = 2;
const UINT8 = 3;
const SHORT = 4;
const UINT16 = 5;
const FLOAT = 6;
const DOUBLE = 7;
const INT32 = 8;
const UINT32 = 9;
const INT64 = 10;
const STRING = 11;
const VECTOR = 12;
const MAP = 13;
const STRUCT = 14;

// ------------------------------------------------------------------------------
}
58 changes: 58 additions & 0 deletions src/TARS_Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* ----------------------------------------------------------------------------------
* Tars Exception
* ----------------------------------------------------------------------------------
*
* ERR_CANNOT_CONVERT => 10001
* ERR_OUTOF_RANGE => 10002
* ERR_MALLOC_FAILED => 10003
* ERR_CLASS_UNINIT => 10004
* ERR_REQUIRED_FIELD_LOST => 10005
* ERR_DATA_FORMAT_ERROR => 10006
* ERR_TYPE_INVALID => 10007
* ERR_CLASS_MISMATCH => 10008
* ERR_WRONG_PARAMS => 10009
* ERR_STATIC_FIELDS_PARAM_LOST => 10010
* ERR_ARRAY_RETRIEVE => 10011
* ERR_READ_MAP_ERROR => 10012
* ERR_SET_CONTEXT_ERROR => 10013
* ERR_SET_STATUS_ERROR => 10014
* ERR_ENCODE_BUF_ERROR => 10015
* ERR_WRITE_IVERSION_ERROR => 10016
* ERR_WRITE_CPACKETTYPE_ERROR => 10017
* ERR_WRITE_IMESSAGETYPE_ERROR => 10018
* ERR_WRITE_IREQUESTID_ERROR => 10019
* ERR_WRITE_SSERVANTNAME_ERROR => 10020
* ERR_WRITE_SFUNCNAME_ERROR => 10021
* ERR_WRITE_SBUFFER_ERROR => 10022
* ERR_WRITE_ITIMEOUT_ERROR => 10023
* ERR_WRITE_CONTEXT_ERROR => 10024
* ERR_WRITE_STATUS_ERROR => 10025
* ERR_STRUCT_COMPLICATE_NOT_DEFINE => 10026
* ERR_VECOTR_OR_MAP_EXT_PARAM_LOST => 10027
* ERR_STATIC_NAME_NOT_STRING_ERROR => 10028
* ERR_STATIC_REQUIRED_NOT_BOOL_ERROR => 10029
* ERR_STATIC_TYPE_NOT_LONG_ERROR => 10030
*
* @author lanlin
* @change 2021/06/01
*/
class TARS_Exception extends Exception
{
// ------------------------------------------------------------------------------

/**
* TARS_Exception constructor.
*
* @param string $message
* @param int $code
*/
public function __construct(string $message, int $code = 0)
{
parent::__construct($message, $code);
}

// ------------------------------------------------------------------------------
}
52 changes: 52 additions & 0 deletions src/TARS_Map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* ----------------------------------------------------------------------------------
* Tars Map
* ----------------------------------------------------------------------------------
*
* @author lanlin
* @change 2021/06/01
*/
class TARS_Map
{
// ------------------------------------------------------------------------------

/**
* TARS_Map constructor.
*
* @param mixed $first
* @param mixed $second
* @param bool $isComplex
*/
public function __construct(mixed $first, mixed $second, bool $isComplex = false)
{
// ...
}

// ------------------------------------------------------------------------------

/**
* @param array $param
*
* @return self
*/
public function pushBack(array $param): self
{
return $this;
}

// ------------------------------------------------------------------------------

/**
* @param array $param
*
* @return self
*/
public function push_back(array $param): self
{
return $this;
}

// ------------------------------------------------------------------------------
}
27 changes: 27 additions & 0 deletions src/TARS_Struct.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* ----------------------------------------------------------------------------------
* Tars Struct
* ----------------------------------------------------------------------------------
*
* @author lanlin
* @change 2021/06/01
*/
class TARS_Struct
{
// ------------------------------------------------------------------------------

/**
* TARS_Struct constructor.
*
* @param string $name
* @param array $fields
*/
public function __construct(string $name, array $fields)
{
// ...
}

// ------------------------------------------------------------------------------
}
Loading

0 comments on commit bd8e3b1

Please sign in to comment.