8000 Update Worker.php by mowangjuanzi · Pull Request #742 · walkor/workerman · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Worker.php #742

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

Merged
merged 2 commits into from
Apr 2, 2022
Merged

Update Worker.php #742

merged 2 commits into from
Apr 2, 2022

Conversation

mowangjuanzi
Copy link
Contributor

常规优化

@@ -589,10 +588,10 @@ protected static function init()
if (empty(static::$logFile)) {
static::$logFile = __DIR__ . '/../../workerman.log';
}
$log_file = (string)static::$logFile;
Copy link
Contributor Author
@mowangjuanzi mowangjuanzi Apr 1, 2022

Choose a reason for hiding this comment

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

@walkor 这里我不知道你为啥要强制转成 string,但是我看现有的代码,赋值都是 string,所以就移除了。你看看,如果有问题,就改呀

Copy link
Owner

Choose a reason for hiding this comment

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

$logFile可能是个支持__toString()方法的对象,__toString()方法里可按照某种规则转换成不同的路径,比如按照日期转换路径。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok。

我编写了这么一条DEMO。

<?php

echo "current PHP version: " . PHP_VERSION . "\r\n";

class Demo {

    public function __toString()
    {
        return "hello.log";
    }
}

$demo = new Demo();

echo "log name: " . $demo . "\r\n";

if (!is_file($demo)) {
    echo "log file is not exists.\r\n";
    \touch($demo);
    \chmod($demo, 0622);
}

然后使用如下命令运行:

$ sudo docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.0-cli php demo1.php
current PHP version: 7.0.33
log name: hello.log
log file is not exists.
$ ll ./hello.log 
-rw--w--w- 1 root root 0  4月  1 23:13 ./hello.log

所以我认为这么修改,即便传入对象,那也是ok的。

@walkor
Copy link
Owner
walkor commented Apr 1, 2022 via email

@walkor walkor merged commit a53d747 into walkor:master Apr 2, 2022
@mowangjuanzi mowangjuanzi deleted the wm-3 branch April 2, 2022 15:20
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
0