| Summary: | [Code Assist] hinting suggests the second parameter only, when both are optional | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Roy Ganor <ganoro> | ||||
| Component: | PDT | Assignee: | Zhongwei Zhao <zhaozhongwei> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P1 | CC: | petyo_tanchev, qiangsheng.w | ||||
| Version: | unspecified | Flags: | ganoro:
review-
zhaozhongwei: review? zhaozhongwei: review? (zhaozhongwei) |
||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
fixed in head and branch Tested on 2.2.1.v20100829 Works still the same way as described by Roy: $hb = new Node_Heartbeat($scStatus) Created attachment 178117 [details]
patch
For this use-case:
function foo ($signature = '',
$scStatus = ZwasComponents_SessionClustering_Model::SCD_STATUS_OFF)
{}
foo|
the problem still exists...
Please fix.
one more comment:
in functions and methods if an argument is optional than all arguments after this argument MUST be optional.
My recommendation is to search for the first argument that is not optional and stop looking after it.
so the loop:
+ for (int a = 0; a < args.size(); a++) {
+ Argument arg = (Argument) args.get(a);
+ parameter[a] = arg.getName();
+ if (arg.getInitialization() != null) {
should be updated to a while loop
thanks!
(In reply to comment #5) > one more comment: > > in functions and methods if an argument is optional than all arguments after > this argument MUST be optional. > > My recommendation is to search for the first argument that is not optional and > stop looking after it. > > so the loop: > > + for (int a = 0; a < args.size(); a++) { > + Argument arg = (Argument) args.get(a); > + parameter[a] = arg.getName(); > + if (arg.getInitialization() != null) { > > should be updated to a while loop > > thanks! yes,for this bug we should update for loop to while loop,but the default values are used by other places that need know the value if it is a scalar,right?So we have to go over all the arguments. I'd suggest to change the method public boolean visitMethodDeclaration to private. Or any reason to have it as public method? Another minor thing is that the name is a little confusing. It sounds like vist(method) calls visitMethod() :) (In reply to comment #7) > I'd suggest to change the method > public boolean visitMethodDeclaration > > to private. > > Or any reason to have it as public method? > > Another minor thing is that the name is a little confusing. > > It sounds like > > vist(method) calls visitMethod() :) I do not know how to name it,the code is copied from super.visit,and I will change public to private. fixed Tested on 2.2.1.v20101001 Fixed |
Given: <?php class ZwasComponents_SessionClustering_Model { const SCD_STATUS_OFF = 0; const SCD_STATUS_ON = 1; } class Node_Heartbeat { /** * @param integer $status * @param string $signature * @param integer $scStatus */ public function __construct($signature = '', $scStatus = ZwasComponents_SessionClustering_Model::SCD_STATUS_OFF){ } } Check the code in the additional info section. At the end of it try writing $hb = new Nodes_<CTRL+SPACE> and you get $hb = new Node_Heartbeat($scStatus) Even though $scStatus is the second parameter, and is optional If you delete the end part and try $hb = new Node_Heartbeat(<CTRL+SPACE> Sometime it is completed without the variable, sometimes the cursor jumps between the 'N' and the 'o' characters