for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: Clayton Daley
* Date: 3/10/2015
* Time: 9:34 AM
*/
namespace ZfcUser\Factory\Form;
use Zend\Form\FormElementManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZfcUser\Form;
use ZfcUser\Validator;
class ChangeEmail implements FactoryInterface
{
public function createService(ServiceLocatorInterface $formElementManager)
if ($formElementManager instanceof FormElementManager) {
$sm = $formElementManager->getServiceLocator();
$fem = $formElementManager;
} else {
$sm = $formElementManager;
$fem = $sm->get('FormElementManager');
}
$options = $sm->get('zfcuser_module_options');
$form = new Form\ChangeEmail(null, $options);
// Inject the FormElementManager to support custom FormElements
$form->getFormFactory()->setFormElementManager($fem);
$fem
object|array
object<Zend\Form\FormElementManager>
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);
$form->setInputFilter(new Form\ChangeEmailFilter(
$options,
new Validator\NoRecordExists(array(
'mapper' => $sm->get('zfcuser_user_mapper'),
'key' => 'email'
))
));
return $form;
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: