Skip to content

Commit

Permalink
Merge pull request #132 from neild3r/v2.1.0
Browse files Browse the repository at this point in the history
Prepare v2.1.0
  • Loading branch information
neild3r committed Nov 19, 2019
2 parents 8612c8c + 07d1c91 commit 709084e
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 56 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,6 +2,11 @@

All notable changes to the "php-docblocker" extension will be documented in this file.

## [2.1.0] - 2019-11-19
- Add should to list of bool return type functions - Thanks @ImClarky
- Fix issue where functions named with a bool return prefix were incorrectly given bool return type - Thanks @ImClarky
- Fix issue with snake case class names in PHP7 return types - Thanks @rmccue

## [2.0.1] - 2019-07-08
- Fix issue in templating system where custom order was not being honored

Expand Down Expand Up @@ -106,7 +111,8 @@ All notable changes to the "php-docblocker" extension will be documented in this
## 0.1.0 - 2017-03-12
- Initial release

[Unreleased]: https://github.com/neild3r/vscode-php-docblocker/compare/v2.0.1...HEAD
[Unreleased]: https://github.com/neild3r/vscode-php-docblocker/compare/v2.1.0...HEAD
[2.1.0]: https://github.com/neild3r/vscode-php-docblocker/compare/v2.0.1...v2.1.0
[2.0.1]: https://github.com/neild3r/vscode-php-docblocker/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/neild3r/vscode-php-docblocker/compare/v1.9.0...v2.0.0
[1.9.0]: https://github.com/neild3r/vscode-php-docblocker/compare/v1.8.0...v1.9.0
Expand Down
51 changes: 0 additions & 51 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "php-docblocker",
"displayName": "PHP DocBlocker",
"description": "A simple, dependency free PHP specific DocBlocking package",
"version": "2.0.1",
"version": "2.1.0",
"license": "MIT",
"publisher": "neilbrayfield",
"author": "Neil Brayfield <dev@brayfield.uk>",
Expand Down
4 changes: 2 additions & 2 deletions src/block/function.ts
Expand Up @@ -59,7 +59,7 @@ export default class FunctionBlock extends Block
}
}

let returnType:Array<string> = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-zA-Z\\]+)\s*$/m);
let returnType:Array<string> = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-zA-Z_0-9\\]+)\s*$/m);

if (returnType != null) {
if (Config.instance.get('qualifyClassNames')) {
Expand All @@ -86,7 +86,7 @@ export default class FunctionBlock extends Block
*/
public getReturnFromName(name:string):string
{
if (/^(is|has|can)/.test(name)) {
if (/^(is|has|can|should)(?:[A-Z0-9_]|$)/.test(name)) {
return TypeUtil.instance.getFormattedTypeByName('bool');
}

Expand Down
51 changes: 50 additions & 1 deletion test/fixtures/functions.php
Expand Up @@ -113,6 +113,10 @@ public function dotArgsTypedLong(int ...$args) {
public function getPHP7Return(): TypeHint {
}

////=> php7-return-snake
public function getPHP7ReturnSnake(): Type_Hint3 {
}

////=> php7-return-alt
public function getPHP7ReturnAlt():float
{
Expand Down Expand Up @@ -162,16 +166,61 @@ public function isSomething()
{
}

////=> is-void
public function isotope()
{
}

////=> is-only
public function is()
{
}

////=> has
public function hasValue()
{
}


////=> has-void
public function hashed()
{
}

////=> has-only
public function has()
{
}

////=> can
public function canValue()
{
}

////=> can-void
public function cancel()
{
}

////=> can-only
public function can()
{
}

////=> should
public function shouldDoSomething()
{
}

////=> should-void
public function shouldasdf()
{
}

////=> should-only
public function should()
{
}

////=> debug-info
public function __debugInfo()
{
Expand Down
80 changes: 80 additions & 0 deletions test/fixtures/functions.php.json
Expand Up @@ -309,6 +309,14 @@
"params": []
}
},
{
"key": "php7-return-snake",
"name": "PHP7 return snake case",
"result": {
"return": "Type_Hint3",
"params": []
}
},
{
"key": "php7-return-alt",
"name": "PHP7 return type alternate",
Expand Down Expand Up @@ -421,6 +429,22 @@
"params": []
}
},
{
"key": "is-void",
"name": "Check is prefix - void",
"result": {
"return": "void",
"params": []
}
},
{
"key": "is-only",
"name": "Check is prefix - only",
"result": {
"return": "boolean",
"params": []
}
},
{
"key": "has",
"name": "Check has prefix",
Expand All @@ -429,6 +453,22 @@
"params": []
}
},
{
"key": "has-void",
"name": "Check has prefix - void",
"result": {
"return": "void",
"params": []
}
},
{
"key": "has-only",
"name": "Check has prefix - only",
"result": {
"return": "boolean",
"params": []
}
},
{
"key": "can",
"name": "Check can prefix",
Expand All @@ -437,6 +477,46 @@
"params": []
}
},
{
"key": "can-void",
"name": "Check can prefix - void",
"result": {
"return": "void",
"params": []
}
},
{
"key": "can-only",
"name": "Check can prefix - only",
"result": {
"return": "boolean",
"params": []
}
},
{
"key": "should",
"name": "Check should prefix",
"result": {
"return": "boolean",
"params": []
}
},
{
"key": "should-void",
"name": "Check should prefix - void",
"result": {
"return": "void",
"params": []
}
},
{
"key": "should-only",
"name": "Check should prefix - only",
"result": {
"return": "boolean",
"params": []
}
},
{
"key": "debug-info",
"name": "Debug info return type",
Expand Down

0 comments on commit 709084e

Please sign in to comment.