Skip to content

Commit 3feeca7

Browse files
kalessilfabpot
authored andcommitted
Static code analysis with Php Inspections (EA Extended)
1 parent c98832b commit 3feeca7

File tree

15 files changed

+19
-54
lines changed

15 files changed

+19
-54
lines changed

src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function fileExcerpt($file, $line)
138138
$code = @highlight_file($file, true);
139139
// remove main code/span tags
140140
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
141-
$content = preg_split('#<br />#', $code);
141+
$content = explode('<br />', $code);
142142

143143
$lines = array();
144144
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {

src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ protected function getFragmentHandler($return)
6262

6363
$context->expects($this->any())->method('getCurrentRequest')->will($this->returnValue(Request::create('/')));
6464

65-
$renderer = new FragmentHandler(array($strategy), false, $context);
66-
67-
return $renderer;
65+
return new FragmentHandler(array($strategy), false, $context);
6866
}
6967

7068
protected function renderTemplate(FragmentHandler $renderer, $template = '{{ render("foo") }}')

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function fileExcerpt($file, $line)
132132
$code = @highlight_file($file, true);
133133
// remove main code/span tags
134134
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
135-
$content = preg_split('#<br />#', $code);
135+
$content = explode('<br />', $code);
136136

137137
$lines = array();
138138
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {

src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Resources/views/translation.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646

4747
<?php echo $view['translator']->trans('typecast', ['a' => (int) '123'], 'not_messages'); ?>
4848
<?php echo $view['translator']->transChoice('msg1', 10 + 1, [], 'not_messages'); ?>
49-
<?php echo $view['translator']->transChoice('msg2', intval(4.5), [], 'not_messages'); ?>
49+
<?php echo $view['translator']->transChoice('msg2', ceil(4.5), [], 'not_messages'); ?>

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/SimpleFormFactory.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,4 @@ protected function createListener($container, $id, $config, $userProvider)
7777

7878
return $listenerId;
7979
}
80-
81-
protected function createEntryPoint($container, $id, $config, $defaultEntryPoint)
82-
{
83-
$entryPointId = 'security.authentication.form_entry_point.'.$id;
84-
$container
85-
->setDefinition($entryPointId, new DefinitionDecorator('security.authentication.form_entry_point'))
86-
->addArgument(new Reference('security.http_utils'))
87-
->addArgument($config['login_path'])
88-
->addArgument($config['use_forward'])
89-
;
90-
91-
return $entryPointId;
92-
}
9380
}

src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testCrossCheck($fixture, $type)
3636

3737
$tmp = tempnam(sys_get_temp_dir(), 'sf');
3838

39-
file_put_contents($tmp, file_get_contents(self::$fixturesPath.'/'.$type.'/'.$fixture));
39+
copy(self::$fixturesPath.'/'.$type.'/'.$fixture, $tmp);
4040

4141
$container1 = new ContainerBuilder();
4242
$loader1 = new $loaderClass($container1, new FileLocator());

src/Symfony/Component/HttpFoundation/BinaryFileResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function setContentDisposition($disposition, $filename = '', $filenameFal
164164
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
165165
$encoding = mb_detect_encoding($filename, null, true);
166166

167-
for ($i = 0; $i < mb_strlen($filename, $encoding); ++$i) {
167+
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
168168
$char = mb_substr($filename, $i, 1, $encoding);
169169

170170
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MongoDbSessionHandlerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testRead()
108108

109109
if (phpversion('mongodb')) {
110110
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$gte']);
111-
$that->assertGreaterThanOrEqual(round(intval((string) $criteria[$that->options['expiry_field']]['$gte']) / 1000), $testTimeout);
111+
$that->assertGreaterThanOrEqual(round(((int) $criteria[$that->options['expiry_field']]['$gte']) / 1000), $testTimeout);
112112
} else {
113113
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$gte']);
114114
$that->assertGreaterThanOrEqual($criteria[$that->options['expiry_field']]['$gte']->sec, $testTimeout);
@@ -167,7 +167,7 @@ public function testWrite()
167167
$that->assertEquals('bar', $data[$that->options['data_field']]->getData());
168168
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['time_field']]);
169169
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $data[$that->options['expiry_field']]);
170-
$that->assertGreaterThanOrEqual($expectedExpiry, round(intval((string) $data[$that->options['expiry_field']]) / 1000));
170+
$that->assertGreaterThanOrEqual($expectedExpiry, round(((int) $data[$that->options['expiry_field']]) / 1000));
171171
} else {
172172
$that->assertEquals('bar', $data[$that->options['data_field']]->bin);
173173
$that->assertInstanceOf('MongoDate', $data[$that->options['time_field']]);
@@ -293,7 +293,7 @@ public function testGc()
293293
->will($this->returnCallback(function ($criteria) use ($that) {
294294
if (phpversion('mongodb')) {
295295
$that->assertInstanceOf('MongoDB\BSON\UTCDateTime', $criteria[$that->options['expiry_field']]['$lt']);
296-
$that->assertGreaterThanOrEqual(time() - 1, round(intval((string) $criteria[$that->options['expiry_field']]['$lt']) / 1000));
296+
$that->assertGreaterThanOrEqual(time() - 1, round(((int) $criteria[$that->options['expiry_field']]['$lt']) / 1000));
297297
} else {
298298
$that->assertInstanceOf('MongoDate', $criteria[$that->options['expiry_field']]['$lt']);
299299
$that->assertGreaterThanOrEqual(time() - 1, $criteria[$that->options['expiry_field']]['$lt']->sec);

src/Symfony/Component/HttpKernel/Client.php

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
* Client simulates a browser and makes requests to a Kernel object.
2626
*
2727
* @author Fabien Potencier <fabien@symfony.com>
28+
*
29+
* @method Request|null getRequest() A Request instance
30+
* @method Response|null getResponse() A Response instance
2831
*/
2932
class Client extends BaseClient
3033
{
@@ -47,26 +50,6 @@ public function __construct(HttpKernelInterface $kernel, array $server = array()
4750
parent::__construct($server, $history, $cookieJar);
4851
}
4952

50-
/**
51-
* {@inheritdoc}
52-
*
53-
* @return Request|null A Request instance
54-
*/
55-
public function getRequest()
56-
{
57-
return parent::getRequest();
58-
}
59-
60-
/**
61-
* {@inheritdoc}
62-
*
63-
* @return Response|null A Response instance
64-
*/
65-
public function getResponse()
66-
{
67-
return parent::getResponse();
68-
}
69-
7053
/**
7154
* Makes a request.
7255
*

src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function exportValue($value, $depth = 1, $deep = false)
3333

3434
if (is_object($value)) {
3535
if ($value instanceof \DateTime || $value instanceof \DateTimeInterface) {
36-
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ISO8601));
36+
return sprintf('Object(%s) - %s', get_class($value), $value->format(\DateTime::ATOM));
3737
}
3838

3939
return sprintf('Object(%s)', get_class($value));

0 commit comments

Comments
 (0)