for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* AdminUser
* @copyright Copyright (c) 2011 - 2014 Aleksandr Torosh (http://wezoom.com.ua)
* @author Aleksandr Torosh <[email protected]>
*/
namespace Admin\Form;
use Admin\Model\AdminUser;
use Application\Form\Form;
use Phalcon\Forms\Element\Select;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Email;
use Phalcon\Forms\Element\Password;
use Phalcon\Forms\Element\Check;
use Phalcon\Validation\Validator\Email as ValidatorEmail;
use Phalcon\Validation\Validator\PresenceOf;
class AdminUserForm extends Form
{
public function initialize()
$this->add(
(new Text('login', [
(new \Phalcon\Forms\Elem...e)))->setLabel('Login')
null
object<Phalcon\Forms\ElementInterface>
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);
'required' => true,
]))->setLabel('Login')
);
(new Email('email', [
setLabel
(new \Phalcon\Forms\Elem...l format is invalid')))
Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.
]))
->addValidator(new ValidatorEmail([
'message' => 'Email format is invalid',
->setLabel('Email')
(new Text('name'))
(new \Phalcon\Forms\Elem...me'))->setLabel('Name')
->setLabel('Name')
(new Select('role', AdminUser::$roles))
(new \Phalcon\Forms\Elem...les))->setLabel('Role')
->setLabel('Role')
(new Password('password'))
(new \Phalcon\Forms\Elem...)->setLabel('Password')
->setLabel('Password')
(new Check('active'))
(new \Phalcon\Forms\Elem...'))->setLabel('Active')
->setLabel('Active')
}
public function initAdding()
$password = $this->get('password');
$password
$this->get('password')
Phalcon\Forms\Form::get()
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
class A { function getObject() { return null; } } $a = new A(); $object = $a->getObject();
The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
$password->setAttribute('required', true);
setAttribute
$password->addValidator(new PresenceOf([
addValidator
'message' => 'Password is required',
]));
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: