73 fix algorithm middlewares comporeations - #77
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a052ba834c
ℹ️ 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.
Guard non-expression middleware statements
When the withMiddleware closure contains any non-expression statement, such as an if block or a standalone comment after the first statement, array_find_key() invokes this callback with a Stmt\If_/Nop node and PHP raises a TypeError because the parameter is typed as Expression. That prevents adding middleware to otherwise valid bootstrap files; accept a generic statement node here and return false unless it is the expected method-call 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 actual middleware closure parameter
In bootstrap files where the withMiddleware closure parameter is renamed, for example function (Middleware $middlewares), appending a new group always emits $middleware->prependToGroup(...) even though that variable does not exist. The generated bootstrap/app.php then has an undefined variable and the new group is not configured; build the call from the closure's first parameter name instead of hard-coding middleware.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bed87d2f6d
ℹ️ 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".
| || $middleware->value->class->name === $namespace['alias']; | ||
| }); | ||
|
|
||
| return $found['namespace'] ?? null; |
There was a problem hiding this comment.
Avoid duplicating class middleware in chained calls
When the same FQCN middleware is added by two addMiddlewarePrependToGroup() calls in one builder run and that class was not already imported in the original file, the first visitor leaves a short Foo::class in the group but AddImports only creates the use statement in afterTraverse(). This resolver therefore has no matching entry in $importedNamespaces, returns null, and the later visitor treats the just-added class as missing and appends a duplicate; keep a basename fallback or account for pending imports so chained calls remain idempotent.
Useful? React with 👍 / 👎.
No description provided.