| Total Complexity | 6 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | abstract class BaseJob extends BaseObject implements RetryableJobInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * @var string|null The configured job description |
||
| 23 | */ |
||
| 24 | public $description; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var int The current progress |
||
| 28 | */ |
||
| 29 | private $_progress; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @inheritdoc |
||
| 33 | */ |
||
| 34 | public function init() |
||
| 35 | { |
||
| 36 | parent::init(); |
||
| 37 | // Set the default progress |
||
| 38 | $this->_progress = 0; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @inheritdoc |
||
| 43 | */ |
||
| 44 | public function getDescription() |
||
| 47 | } |
||
| 48 | |||
| 49 | // Protected Methods |
||
| 50 | // ========================================================================= |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Returns a default description for [[getDescription()]]. |
||
| 54 | * |
||
| 55 | * @return string|null |
||
| 56 | */ |
||
| 57 | protected function defaultDescription() |
||
| 58 | { |
||
| 59 | return null; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Sets the job progress on the queue. |
||
| 64 | * |
||
| 65 | * @param \yii\queue\Queue|QueueInterface $queue |
||
| 66 | * @param float $progress A number between 0 and 1 |
||
| 67 | */ |
||
| 68 | protected function setProgress($queue, float $progress) |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: