New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improves PHP generation. #7513
base: main
Are you sure you want to change the base?
Conversation
zap/src/main/java/org/zaproxy/zap/extension/api/PhpAPIGenerator.java
Outdated
Show resolved
Hide resolved
|
||
if (hasParams) { | ||
out.write(", "); | ||
} | ||
// Always add the API key - we've no way of knowing if it will be required or not | ||
out.write("$" + API.API_KEY_PARAM + "='') {\n"); | ||
out.write("string $" + API.API_KEY_PARAM + " = '') {\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apikey
is always a string.
zap/src/main/java/org/zaproxy/zap/extension/api/PhpAPIGenerator.java
Outdated
Show resolved
Hide resolved
While we can't improve arguments because lack of typing, this is a best effort to improve the code. Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
e2bbe59
to
9a3a395
Compare
The build failed: |
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
afcf10b
to
d856850
Compare
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but I'm no PHP developer 😉
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
|
Signed-off-by: José Carlos Chávez <jcchavezs@gmail.com>
Fixed @psiinon |
Ping @thc202 |
out.write(reqParams.toString()); | ||
out.write(";\n"); | ||
reqParams.replace(0, reqParams.length(), "$params"); | ||
|
||
for (ApiParameter parameter : optionalParameters) { | ||
String name = parameter.getName(); | ||
String varName = name.toLowerCase(Locale.ROOT); | ||
out.write("\t\tif ($" + varName + " !== NULL) {\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched tabs into spaces as that is what is being used by standards. In any case, all the code is reformatted by proper PHP linters in the PHP API client.
@@ -34,6 +34,9 @@ | |||
import java.util.ResourceBundle; | |||
import java.util.stream.Collectors; | |||
|
|||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**
/** | ||
* Generates the API client files of the given API implementors. | ||
* | ||
* @param implementors the implementors | ||
* @throws IOException if an error occurred while generating the APIs. | ||
* @deprecated (2.6.0) Use {@link #generateAPIFiles(List)} instead. | ||
*/ | ||
@Deprecated | ||
public void generatePhpFiles(List<ApiImplementor> implementors) throws IOException { | ||
this.generateAPIFiles(implementors); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be needed.
Commits should be squashed. |
While we can't improve arguments because lack of typing, this is a best effort to improve the code.
Ping @psiinon