for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* @package Jam
* @category Behavior
* @author Ivan Kerin
* @copyright (c) 2011-2012 Despark Ltd.
* @license http://www.opensource.org/licenses/isc-license.txt
*/
class Kohana_Jam_Behavior_Username extends Jam_Behavior {
public function initialize(Jam_Meta $meta, $name)
{
parent::initialize($meta, $name);
$meta
name_key
$meta->unique_key(array($this, 'username_key'))
string
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.
->unique_key(array($this, 'username_key'))
array($this, 'username_key')
array<integer,this<Kohan...ername>","1":"string"}>
string|null
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);
->name_key('username')
->fields([
'username' => Jam::field('string'),
])
->validator('username', array(
'length' => array('minimum' => 3, 'maximum' => 32),
'present' => TRUE,
'format' => array('regex' => '/^[a-zA-Z0-9\_\-]+$/')
));
}
public function username_key($value)
return Valid::email($value) ? 'email' : ((is_numeric($value) OR $value === NULL) ? 'id' : 'username');
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.