for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @copyright Bluz PHP Team
* @link https://github.com/bluzphp/skeleton
*/
* @namespace
namespace Application\Media;
use Application\Exception;
use Bluz\Proxy\Auth;
* Table
*
* @package Application\Media
* @method static Row findRow($primaryKey)
* @method static Row findRowWhere($whereList)
class Table extends \Bluz\Db\Table
{
* @var string
protected $table = 'media';
* Primary key(s)
* @var array
protected $primary = array('id');
* Get images of current user
* @return Row[]
* @throws Exception
public function getImages()
/** @var Row $user */
if (!$user = Auth::getIdentity()) {
throw new Exception('User not found');
}
return $this->getImagesByUserId($user->id);
id
Bluz\Auth\EntityInterface
instanceof
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Adding an additional type check:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeInterface $object) { if ($object instanceof SomeClass) { $a = $object->a; } }
Changing the type hint:
interface SomeInterface { } class SomeClass implements SomeInterface { public $a; } function someFunction(SomeClass $object) { $a = $object->a; }
* Get images by owner
* @param integer $id
public function getImagesByUserId($id)
return self::select()
->where('type LIKE (?)', 'image/%')
->andWhere('userId = ?', $id)
->execute();
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: