for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
trait HasPremieredTrait
{
/**
* @var string the date the movie premiered
*/
public $premiered;
* @return string|int
public function getRenderedYear()
// If premiered is available we use the year from that
if ($this->premiered !== '')
$premiereDate = DateTime::createFromFormat('Y-m-d', $this->premiered);
if ($premiereDate !== false)
return $premiereDate->format('Y');
}
// Year is usually zero or 1601 when it's not available
if ($this->year !== 0 && $this->year !== 1601)
return $this->year;
year
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
// If nothing is available
return Yii::t('Misc', 'Not available');
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: