diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c495f..898cc9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/package-lock.json b/package-lock.json index 8d846ac..81ff3ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -203,12 +203,6 @@ "sprintf-js": "~1.0.2" } }, - "argv": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/argv/-/argv-0.0.2.tgz", - "integrity": "sha1-7L0W+JSbFXGDcRsb2jNPN4QBhas=", - "dev": true - }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -352,19 +346,6 @@ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", "dev": true }, - "codecov": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.6.1.tgz", - "integrity": "sha512-IUJB6WG47nWK7o50etF8jBadxdMw7DmoQg05yIljstXFBGB6clOZsIj6iD4P82T2YaIU3qq+FFu8K9pxgkCJDQ==", - "dev": true, - "requires": { - "argv": "^0.0.2", - "ignore-walk": "^3.0.1", - "js-yaml": "^3.13.1", - "teeny-request": "^3.11.3", - "urlgrey": "^0.4.4" - } - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -920,15 +901,6 @@ "debug": "^3.1.0" } }, - "ignore-walk": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.3.tgz", - "integrity": "sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw==", - "dev": true, - "requires": { - "minimatch": "^3.0.4" - } - }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -1624,12 +1596,6 @@ } } }, - "node-fetch": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", - "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==", - "dev": true - }, "normalize-package-data": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", @@ -2226,17 +2192,6 @@ } } }, - "teeny-request": { - "version": "3.11.3", - "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.3.tgz", - "integrity": "sha512-CKncqSF7sH6p4rzCgkb/z/Pcos5efl0DmolzvlqRQUNcpRIruOhY9+T1FsIlyEbfWd7MsFpodROOwHYh2BaXzw==", - "dev": true, - "requires": { - "https-proxy-agent": "^2.2.1", - "node-fetch": "^2.2.0", - "uuid": "^3.3.2" - } - }, "test-exclude": { "version": "5.2.3", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-5.2.3.tgz", @@ -2318,12 +2273,6 @@ "punycode": "^2.1.0" } }, - "urlgrey": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/urlgrey/-/urlgrey-0.4.4.tgz", - "integrity": "sha1-iS/pWWCAXoVRnxzUOJ8stMu3ZS8=", - "dev": true - }, "uuid": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", diff --git a/package.json b/package.json index 11d942c..1a0ba3b 100644 --- a/package.json +++ b/package.json @@ -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 ", diff --git a/src/block/function.ts b/src/block/function.ts index 2a508ac..870d0ab 100644 --- a/src/block/function.ts +++ b/src/block/function.ts @@ -59,7 +59,7 @@ export default class FunctionBlock extends Block } } - let returnType:Array = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-zA-Z\\]+)\s*$/m); + let returnType:Array = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-zA-Z_0-9\\]+)\s*$/m); if (returnType != null) { if (Config.instance.get('qualifyClassNames')) { @@ -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'); } diff --git a/test/fixtures/functions.php b/test/fixtures/functions.php index 44a8b37..639f1fd 100644 --- a/test/fixtures/functions.php +++ b/test/fixtures/functions.php @@ -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 { @@ -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() { diff --git a/test/fixtures/functions.php.json b/test/fixtures/functions.php.json index d5b2597..0ba35b1 100644 --- a/test/fixtures/functions.php.json +++ b/test/fixtures/functions.php.json @@ -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", @@ -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", @@ -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", @@ -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",