yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Error: fwrite(): Passing null to parameter #2 ($data) of type string is deprecated #19712

Closed impayru closed 1 year ago

impayru commented 1 year ago

What steps will reproduce the problem?

yii asset assets.php config/assets-prod.php

What is the expected result?

out js

What do you get instead?

Error: fwrite(): Passing null to parameter #2 ($data) of type string is deprecated

Additional info

In the file vendor\yiisoft\yii2\console\controllers\AssetController.php 518 call is used $this->stdout(shell_exec(strtr($this->jsCompressor, [ '{from}' => escapeshellarg($tmpFile), '{to}' => escapeshellarg($outputFile), ]))); shell_exec returns null for line in assets.php 'jsCompressor' => 'uglifyjs {from} -m -o {to}', this throws an error Error: fwrite(): Passing null to parameter #2 ($data) of type string is deprecated

Q A
Yii version 2.0.47
PHP version 8.1.13
Operating system Windows
impayru commented 1 year ago

patch:

-            $this->stdout(shell_exec(strtr($this->jsCompressor, [
+            $this->stdout((string)shell_exec(strtr($this->jsCompressor, [
samdark commented 1 year ago

Would you please prepare a pull request? Thanks.