Skip to content

73 fix algorithm middlewares comporeations - #77

Open
AZabolotnikov wants to merge 6 commits into
add-midlewares-prepend-groupfrom
73-fix-algorithm-middlewares-comporeations
Open

73 fix algorithm middlewares comporeations#77
AZabolotnikov wants to merge 6 commits into
add-midlewares-prepend-groupfrom
73-fix-algorithm-middlewares-comporeations

Conversation

@AZabolotnikov

Copy link
Copy Markdown
Contributor

No description provided.

@AZabolotnikov AZabolotnikov self-assigned this Jun 29, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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), [

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@AZabolotnikov
AZabolotnikov changed the base branch from master to add-midlewares-prepend-group July 1, 2026 13:01

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant