Static code analysis with Php Inspections (EA Extended)
This commit is contained in:
parent
c98832b99b
commit
3feeca74d0
@ -138,7 +138,7 @@ class CodeExtension extends \Twig_Extension
|
|||||||
$code = @highlight_file($file, true);
|
$code = @highlight_file($file, true);
|
||||||
// remove main code/span tags
|
// remove main code/span tags
|
||||||
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
||||||
$content = preg_split('#<br />#', $code);
|
$content = explode('<br />', $code);
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
||||||
|
@ -62,9 +62,7 @@ class HttpKernelExtensionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
|
$context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
|
||||||
|
|
||||||
$renderer = new FragmentHandler(array($strategy), false, $context);
|
return new FragmentHandler(array($strategy), false, $context);
|
||||||
|
|
||||||
return $renderer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}')
|
protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}')
|
||||||
|
@ -132,7 +132,7 @@ class CodeHelper extends Helper
|
|||||||
$code = @highlight_file($file, true);
|
$code = @highlight_file($file, true);
|
||||||
// remove main code/span tags
|
// remove main code/span tags
|
||||||
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
|
||||||
$content = preg_split('#<br />#', $code);
|
$content = explode('<br />', $code);
|
||||||
|
|
||||||
$lines = array();
|
$lines = array();
|
||||||
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
|
||||||
|
@ -46,4 +46,4 @@ EOF
|
|||||||
|
|
||||||
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
|
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
|
||||||
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
|
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
|
||||||
<?php echo $view['translator']->transChoice('msg2', intval(4.5), [], 'not_messages'); ?>
|
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), [], 'not_messages'); ?>
|
||||||
|
@ -77,17 +77,4 @@ class SimpleFormFactory extends FormLoginFactory
|
|||||||
|
|
||||||
return $listenerId;
|
return $listenerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createEntryPoint($container, $id, $config, $defaultEntryPoint)
|
|
||||||
{
|
|
||||||
$entryPointId = 'security.authentication.form_entry_point.'.$id;
|
|
||||||
$container
|
|
||||||
->setDefinition($entryPointId, new DefinitionDecorator('security.authentication.form_entry_point'))
|
|
||||||
->addArgument(new Reference('security.http_utils'))
|
|
||||||
->addArgument($config['login_path'])
|
|
||||||
->addArgument($config['use_forward'])
|
|
||||||
;
|
|
||||||
|
|
||||||
return $entryPointId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class CrossCheckTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$tmp = tempnam(sys_get_temp_dir(), 'sf');
|
$tmp = tempnam(sys_get_temp_dir(), 'sf');
|
||||||
|
|
||||||
file_put_contents($tmp, file_get_contents(self::$fixturesPath.'/'.$type.'/'.$fixture));
|
copy(self::$fixturesPath.'/'.$type.'/'.$fixture, $tmp);
|
||||||
|
|
||||||
$container1 = new ContainerBuilder();
|
$container1 = new ContainerBuilder();
|
||||||
$loader1 = new $loaderClass($container1, new FileLocator());
|
$loader1 = new $loaderClass($container1, new FileLocator());
|
||||||
|
@ -164,7 +164,7 @@ class BinaryFileResponse extends Response
|
|||||||
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
||||||
$encoding = mb_detect_encoding($filename, null, true);
|
$encoding = mb_detect_encoding($filename, null, true);
|
||||||
|
|
||||||
for ($i = 0; $i < mb_strlen($filename, $encoding); ++$i) {
|
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
|
||||||
$char = mb_substr($filename, $i, 1, $encoding);
|
$char = mb_substr($filename, $i, 1, $encoding);
|
||||||
|
|
||||||
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {
|
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {
|
||||||
|
@ -108,7 +108,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
if (phpversion('mongodb')) {
|
if (phpversion('mongodb')) {
|
||||||
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$gte']);
|
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$gte']);
|
||||||
$that->assertGreaterThanOrEqual(round(intval((string) $criteria[$that->options['expiry_field']]['$gte']) / 1000), $testTimeout);
|
$that->assertGreaterThanOrEqual(round(((int) $criteria[$that->options['expiry_field']]['$gte']) / 1000), $testTimeout);
|
||||||
} else {
|
} else {
|
||||||
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$gte']);
|
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$gte']);
|
||||||
$that->assertGreaterThanOrEqual($criteria[$that->options['expiry_field']]['$gte']->sec, $testTimeout);
|
$that->assertGreaterThanOrEqual($criteria[$that->options['expiry_field']]['$gte']->sec, $testTimeout);
|
||||||
@ -167,7 +167,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$that->assertEquals('bar', $data[$that->options['data_field']]->getData());
|
$that->assertEquals('bar', $data[$that->options['data_field']]->getData());
|
||||||
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['time_field']]);
|
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['time_field']]);
|
||||||
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['expiry_field']]);
|
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['expiry_field']]);
|
||||||
$that->assertGreaterThanOrEqual($expectedExpiry, round(intval((string) $data[$that->options['expiry_field']]) / 1000));
|
$that->assertGreaterThanOrEqual($expectedExpiry, round(((int) $data[$that->options['expiry_field']]) / 1000));
|
||||||
} else {
|
} else {
|
||||||
$that->assertEquals('bar', $data[$that->options['data_field']]->bin);
|
$that->assertEquals('bar', $data[$that->options['data_field']]->bin);
|
||||||
$that->assertInstanceOf('MongoDate', $data[$that->options['time_field']]);
|
$that->assertInstanceOf('MongoDate', $data[$that->options['time_field']]);
|
||||||
@ -293,7 +293,7 @@ class MongoDbSessionHandlerTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnCallback(function ($criteria) use ($that) {
|
->will($this->returnCallback(function ($criteria) use ($that) {
|
||||||
if (phpversion('mongodb')) {
|
if (phpversion('mongodb')) {
|
||||||
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$lt']);
|
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$lt']);
|
||||||
$that->assertGreaterThanOrEqual(time() - 1, round(intval((string) $criteria[$that->options['expiry_field']]['$lt']) / 1000));
|
$that->assertGreaterThanOrEqual(time() - 1, round(((int) $criteria[$that->options['expiry_field']]['$lt']) / 1000));
|
||||||
} else {
|
} else {
|
||||||
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$lt']);
|
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$lt']);
|
||||||
$that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['expiry_field']]['$lt']->sec);
|
$that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['expiry_field']]['$lt']->sec);
|
||||||
|
@ -25,6 +25,9 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
* Client simulates a browser and makes requests to a Kernel object.
|
* Client simulates a browser and makes requests to a Kernel object.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* @method Request|null getRequest() A Request instance
|
||||||
|
* @method Response|null getResponse() A Response instance
|
||||||
*/
|
*/
|
||||||
class Client extends BaseClient
|
class Client extends BaseClient
|
||||||
{
|
{
|
||||||
@ -47,26 +50,6 @@ class Client extends BaseClient
|
|||||||
parent::__construct($server, $history, $cookieJar);
|
parent::__construct($server, $history, $cookieJar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return Request|null A Request instance
|
|
||||||
*/
|
|
||||||
public function getRequest()
|
|
||||||
{
|
|
||||||
return parent::getRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @return Response|null A Response instance
|
|
||||||
*/
|
|
||||||
public function getResponse()
|
|
||||||
{
|
|
||||||
return parent::getResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a request.
|
* Makes a request.
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,7 @@ class ValueExporter
|
|||||||
|
|
||||||
if (is_object($value)) {
|
if (is_object($value)) {
|
||||||
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
|
||||||
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601));
|
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf('Object(%s)', get_class($value));
|
return sprintf('Object(%s)', get_class($value));
|
||||||
|
@ -41,7 +41,7 @@ class MemcacheProfilerStorage extends BaseMemcacheProfilerStorage
|
|||||||
$port = $matches[3];
|
$port = $matches[3];
|
||||||
|
|
||||||
$memcache = new \Memcache();
|
$memcache = new \Memcache();
|
||||||
$memcache->addserver($host, $port);
|
$memcache->addServer($host, $port);
|
||||||
|
|
||||||
$this->memcache = $memcache;
|
$this->memcache = $memcache;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class ValueExporterTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDateTime()
|
public function testDateTime()
|
||||||
{
|
{
|
||||||
$dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
$dateTime = new \DateTime('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
||||||
$this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime));
|
$this->assertSame('Object(DateTime) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +37,7 @@ class ValueExporterTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDateTimeImmutable()
|
public function testDateTimeImmutable()
|
||||||
{
|
{
|
||||||
$dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
$dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
|
||||||
$this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime));
|
$this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+00:00', $this->valueExporter->exportValue($dateTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIncompleteClass()
|
public function testIncompleteClass()
|
||||||
|
@ -662,9 +662,8 @@ QUERY;
|
|||||||
protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid)
|
protected function getDeleteSecurityIdentityIdSql(SecurityIdentityInterface $sid)
|
||||||
{
|
{
|
||||||
$select = $this->getSelectSecurityIdentityIdSql($sid);
|
$select = $this->getSelectSecurityIdentityIdSql($sid);
|
||||||
$delete = preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select);
|
|
||||||
|
|
||||||
return $delete;
|
return preg_replace('/^SELECT id FROM/', 'DELETE FROM', $select);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,8 +68,6 @@ class DataCollectorTranslatorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$translator->addResource('array', array('bar' => 'bar (fr)'), 'fr');
|
$translator->addResource('array', array('bar' => 'bar (fr)'), 'fr');
|
||||||
$translator->addResource('array', array('bar_ru' => 'bar (ru)'), 'ru');
|
$translator->addResource('array', array('bar_ru' => 'bar (ru)'), 'ru');
|
||||||
|
|
||||||
$collector = new DataCollectorTranslator($translator);
|
return new DataCollectorTranslator($translator);
|
||||||
|
|
||||||
return $collector;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,7 +610,7 @@ class Parser
|
|||||||
$previousLineIndented = false;
|
$previousLineIndented = false;
|
||||||
$previousLineBlank = false;
|
$previousLineBlank = false;
|
||||||
|
|
||||||
for ($i = 0; $i < count($blockLines); ++$i) {
|
for ($i = 0, $blockLinesCount = count($blockLines); $i < $blockLinesCount; ++$i) {
|
||||||
if ('' === $blockLines[$i]) {
|
if ('' === $blockLines[$i]) {
|
||||||
$text .= "\n";
|
$text .= "\n";
|
||||||
$previousLineIndented = false;
|
$previousLineIndented = false;
|
||||||
|
Reference in New Issue
Block a user