Skip to content
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

基于cli运行且作为单例的情况下,server增加可更换request的方法 #2880

Merged
merged 3 commits into from
Jan 16, 2025

Conversation

kkokk
Copy link
Contributor

@kkokk kkokk commented Jan 16, 2025

基于cli运行且作为单例的情况下,server增加可更换request的方法

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
easywechat ❌ Failed (Inspect) Jan 16, 2025 3:44am

@overtrue
Copy link
Collaborator

要不把构造函数里的 $this->request = $request ?? RequestUtil::createDefaultServerRequest(); 也改用 $this->getRequest()?

@kkokk
Copy link
Contributor Author

kkokk commented Jan 16, 2025

@overtrue
Copy link
Collaborator

我还有一个想法,把所有这些 Server 里的 $this->request 改成 $this->getRequest()

@kkokk
Copy link
Contributor Author

kkokk commented Jan 16, 2025

我也是这么想的,既然你说了,那就可以改了😁

@kkokk
Copy link
Contributor Author

kkokk commented Jan 16, 2025

$this->request = $request ?? $this->getRequest();
是否可替换为
$request ? $this->setRequest($request) : $this->getRequest();

@overtrue
Copy link
Collaborator

  1. 构造函数里那句整句移除
  2. 下面各个使用 $this->request 的地方改成 $this->getRequest()

@kkokk
Copy link
Contributor Author

kkokk commented Jan 16, 2025

那构造函数的入参,以及 new ServerApplication 是否需要修改呢

@overtrue
Copy link
Collaborator

不改,你可以构造的时候就传入 request, 或者后续实例化以后再 setRequest, 但是不传就会触发默认值嘛

@overtrue
Copy link
Collaborator

构造函数里得改写一下:

$this->request = $request;

@kkokk
Copy link
Contributor Author

kkokk commented Jan 16, 2025

@overtrue overtrue merged commit b80a463 into w7corp:6.x Jan 16, 2025
5 of 6 checks passed
@overtrue
Copy link
Collaborator

多谢🙏

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.

2 participants