for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Finance module for HiPanel
*
* @link https://github.com/hiqdev/hipanel-module-finance
* @package hipanel-module-finance
* @license BSD-3-Clause
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
*/
namespace hipanel\modules\finance\models\decorators\server;
use Yii;
class CpuResourceDecorator extends AbstractServerResourceDecorator
{
const UNIT_CORE = 0;
const UNIT_MHZ = 1;
public function displayTitle()
return Yii::t('hipanel:server:order', 'CPU');
}
public function displayPrepaidAmount()
if ($this->getCpuUnit() === self::UNIT_CORE) {
return Yii::t('hipanel:server:order', '{0, plural, one{# core} other{# cores}}',
$this->getPrepaidQuantity());
$this->getPrepaidQuantity()
integer|string
array
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
return Yii::t('hipanel:server:order', '{0} MHz', Yii::$app->formatter->asInteger($this->getPrepaidQuantity()));
public function getPrepaidQuantity()
preg_match('/((\d+) cores?)$/i', $this->resource->part->partno, $matches);
} else {
preg_match('/((\d+) MHz)$/i', $this->resource->part->partno, $matches);
return $matches[2] === null ? 0 : $matches[2];
private function getCpuUnit()
if (strpos($this->resource->part->partno, 'core') !== false) {
return self::UNIT_CORE;
return self::UNIT_MHZ;
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: