Skip to content

Instantly share code, notes, and snippets.

@thyseus
Created August 16, 2018 12:09
Show Gist options
  • Select an option

  • Save thyseus/837e7f541dd89c4e64a0d4391e79305e to your computer and use it in GitHub Desktop.

Select an option

Save thyseus/837e7f541dd89c4e64a0d4391e79305e to your computer and use it in GitHub Desktop.
In a view file i got:
```php
<?= Yii::t('app', '<i class="fa fa-download text-orange" aria-hidden="true"></i> <span class="productdownloads ml5">' . ($product->download_count > 0 ? $product->download_count : 0) . ' ' . Yii::t('app', 'Downloads') . '</span>'); ?>
```
Of course. This is WRONG. I know. But yii/extract should handle it... - anyway, it leads to this error:
```
Extracting messages from /var/www/html/hydra/views/products/view.php...
PHP Notice 'yii\base\ErrorException' with message 'Uninitialized string offset: 1'
in /var/www/html/hydra/vendor/yiisoft/yii2/console/controllers/MessageController.php:530
Stack trace:
#0 /var/www/html/hydra/vendor/yiisoft/yii2/console/controllers/MessageController.php(302): yii\console\controllers\MessageController->extractMessages()
#1 /var/www/html/hydra/vendor/yiisoft/yii2/base/InlineAction.php(57): yii\console\controllers\MessageController->actionExtract()
#2 /var/www/html/hydra/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/var/www/html/hydra/vendor/yiisoft/yii2/base/InlineAction.php:57}()
#3 /var/www/html/hydra/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams()
#4 /var/www/html/hydra/vendor/yiisoft/yii2/console/Controller.php(148): yii\console\controllers\MessageController->runAction()
#5 /var/www/html/hydra/vendor/yiisoft/yii2/base/Module.php(528): yii\console\controllers\MessageController->runAction()
#6 /var/www/html/hydra/vendor/yiisoft/yii2/console/Application.php(180): yii\console\Application->runAction()
#7 /var/www/html/hydra/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction()
#8 /var/www/html/hydra/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest()
#9 /var/www/html/hydra/yii(27): yii\console\Application->run()
#10 {main}
```
Applying the refactored code of the pull request, the broken Yii::t call gets skipped instead of breaking the whole extraction process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment