Skip to content

Commit

Permalink
optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyiw2013 committed Aug 19, 2021
1 parent 9bc1c86 commit 29f5263
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/block/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class FunctionBlock extends Block
let arg = args[index];

// `public ?Object&Object|Object &...$vars = value`
let parts = arg.match(/^\s*(?:(?:public|protected|private)\s+(?:readonly)?\s*)?(\?)?\s*([a-z0-9_\\][a-z0-9_\\\|&\s]*)?\s*\&?((?:[.]{3})?\$[a-z0-9_]+)\s*\=?\s*(.*)\s*/im);
let parts = arg.match(/^\s*(?:(?:public|protected|private)\s+(?:readonly)?\s*)?(\?)?\s*([a-z_\\][a-z0-9_\\\|&\s]*)?\s*\&?((?:[.]{3})?\$[a-z0-9_]+)\s*\=?\s*(.*)\s*/im);
if (parts === null) {
// trailing comma
if (arg.trim() === '') {
Expand Down Expand Up @@ -76,7 +76,7 @@ export default class FunctionBlock extends Block
} else if (parts[2] != null) {
type = TypeUtil.instance.getResolvedTypeHints(parts[2], false, head);
} else if (parts[4] != null && parts[4] != "") {
type = TypeUtil.instance.getResolvedTypeHints(TypeUtil.instance.getTypeFromValue(parts[4]), false,head);
type = TypeUtil.instance.getResolvedTypeHints(TypeUtil.instance.getTypeFromValue(parts[4]), false, head);
} else {
type = TypeUtil.instance.getUnknownType();
}
Expand All @@ -85,7 +85,7 @@ export default class FunctionBlock extends Block
}
}

let returnType:Array<string> = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-z0-9_\\][a-z0-9_\\\|&\s]*)\s*$/im);
let returnType:Array<string> = this.signature.match(/.*\)\s*\:\s*(\?)?\s*([a-z_\\][a-z0-9_\\\|&\s]*)\s*$/im);

if (returnType != null) {
let head:string;
Expand Down
2 changes: 1 addition & 1 deletion src/util/TypeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class TypeUtil {
* @param {string} head
* @returns {string}
*/
public getResolvedTypeHints(types:string, nullable:boolean=false, head:string = null): string
public getResolvedTypeHints(types:string, nullable:boolean = false, head:string = null): string
{
let union:string[] = types.split("|");
let result:string[] = [];
Expand Down

0 comments on commit 29f5263

Please sign in to comment.