feat: ability print array in multiline format#76
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8fc6e25ea5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| protected function findMiddlewareGroupIndex(array $stmts): ?int | ||
| { | ||
| return array_find_key($stmts, function (Expression $stmt) { |
There was a problem hiding this comment.
Skip non-expression statements while scanning groups
For bootstraps whose withMiddleware closure contains any non-expression statement, such as an if block for environment-specific middleware or another Nop comment/placeholder that remains after the first statement, array_find_key() passes that Stmt into this callback and PHP throws a TypeError because it is typed as Expression. This prevents addMiddlewarePrependToGroup() from saving otherwise valid bootstrap files; mirror shouldInsertNode() by accepting generic statements and skipping anything that is not an Expression.
Useful? React with 👍 / 👎.
| { | ||
| $middlewareList = $this->getMiddlewareList(); | ||
|
|
||
| $methodCall = new MethodCall(new Variable('middleware'), new Identifier($this->targetMethod), [ |
There was a problem hiding this comment.
Use the closure's middleware parameter name
When the existing withMiddleware closure uses a parameter name other than $middleware and the target group does not already have a prependToGroup call, this inserts $middleware->prependToGroup(...) even though that variable is undefined in the generated closure. This makes the resulting bootstrap fail at runtime for valid Laravel code like function (Middleware $m): void { ... }; build the call from the closure parameter variable instead of hard-coding $middleware.
Useful? React with 👍 / 👎.
💡 Codex ReviewWhen callers chain multiple default larabuilder/src/Visitors/AppBootstrapVisitors/AddMiddlewarePrependToGroup.php Lines 109 to 110 in 5a260ef If an existing group contains an imported short class such as ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
refs: #73