for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the PPI Framework.
*
* @copyright Copyright (c) 2011-2016 Paul Dragoonis <[email protected]>
* @license http://opensource.org/licenses/mit-license.php MIT
* @link http://www.ppi.io
*/
namespace PPI\Framework\ServiceManager\Factory;
use Symfony\Component\Routing\RequestContext;
use Zend\ServiceManager\ServiceLocatorInterface;
* RouterRequestContext Factory.
* @author Vítor Brandão <[email protected]>
class RouterRequestContextFactory extends AbstractFactory
{
* Create and return the router.
* @param ServiceLocatorInterface $serviceLocator
* @return \PPI\Framework\Router\RouterListener
public function createService(ServiceLocatorInterface $serviceLocator)
$context = new RequestContext();
$context->fromRequest($serviceLocator->get('Request'));
$serviceLocator->get('Request')
object|array
object<Symfony\Component\HttpFoundation\Request>
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);
return $context;
}
* {@inheritDoc}
public function getConfigurationDefaults()
return array('framework' => array(
'router' => array(
// request_context
'host' => 'localhost',
'scheme' => 'http',
// request_listener
'http_port' => '80',
'https_port' => '443',
),
));
protected function processConfiguration(array $config, ServiceLocatorInterface $serviceLocator = null)
$defaults = $this->getConfigurationDefaults();
$defaults = $defaults['framework']['router'];
return isset($config['framework']['router']) ?
$this->mergeConfiguration($defaults, $config['framework']['router']) :
$defaults;
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: