Browse Source

SCA with Php Inspections (EA Extended) (#15571)

tags/2.0.14
Vladimir Reznichenko 7 years ago committed by Alexander Makarov
parent
commit
67f67e3a69
  1. 6
      build/controllers/PhpDocController.php
  2. 4
      build/controllers/ReleaseController.php
  3. 4
      tests/data/validators/models/FakedValidationModel.php
  4. 2
      tests/framework/db/ActiveRecordTest.php
  5. 2
      tests/framework/db/CommandTest.php
  6. 4
      tests/framework/db/mysql/connection/DeadLockTest.php

6
build/controllers/PhpDocController.php

@ -176,7 +176,7 @@ class PhpDocController extends Controller
$this->setUpExtensionAliases($extensionPath); $this->setUpExtensionAliases($extensionPath);
list(, $extension) = $matches; list(, $extension) = $matches;
Yii::setAlias("@yii/$extension", "$root"); Yii::setAlias("@yii/$extension", (string)$root);
if (is_file($autoloadFile = Yii::getAlias("@yii/$extension/vendor/autoload.php"))) { if (is_file($autoloadFile = Yii::getAlias("@yii/$extension/vendor/autoload.php"))) {
include $autoloadFile; include $autoloadFile;
} }
@ -199,7 +199,7 @@ class PhpDocController extends Controller
$this->setUpExtensionAliases($extensionPath); $this->setUpExtensionAliases($extensionPath);
list(, $appName) = $matches; list(, $appName) = $matches;
Yii::setAlias("@app-$appName", "$root"); Yii::setAlias("@app-$appName", (string)$root);
if (is_file($autoloadFile = Yii::getAlias("@app-$appName/vendor/autoload.php"))) { if (is_file($autoloadFile = Yii::getAlias("@app-$appName/vendor/autoload.php"))) {
include $autoloadFile; include $autoloadFile;
} }
@ -688,7 +688,7 @@ class PhpDocController extends Controller
$docline = ' * @'; $docline = ' * @';
$docline .= 'property'; // Do not use property-read and property-write as few IDEs support complex syntax. $docline .= 'property'; // Do not use property-read and property-write as few IDEs support complex syntax.
$note = ''; $note = '';
if (isset($prop['get']) && isset($prop['set'])) { if (isset($prop['get'], $prop['set'])) {
if ($prop['get']['type'] != $prop['set']['type']) { if ($prop['get']['type'] != $prop['set']['type']) {
$note = ' Note that the type of this property differs in getter and setter.' $note = ' Note that the type of this property differs in getter and setter.'
. ' See [[get' . ucfirst($propName) . '()]] and [[set' . ucfirst($propName) . '()]] for details.'; . ' See [[get' . ucfirst($propName) . '()]] and [[set' . ucfirst($propName) . '()]] for details.';

4
build/controllers/ReleaseController.php

@ -109,7 +109,7 @@ class ReleaseController extends Controller
foreach ($items as $item) { foreach ($items as $item) {
$this->stdout("fetching tags for $item..."); $this->stdout("fetching tags for $item...");
if ($item === 'framework') { if ($item === 'framework') {
$this->gitFetchTags("{$this->basePath}"); $this->gitFetchTags((string)$this->basePath);
} elseif (strncmp('app-', $item, 4) === 0) { } elseif (strncmp('app-', $item, 4) === 0) {
$this->gitFetchTags("{$this->basePath}/apps/" . substr($item, 4)); $this->gitFetchTags("{$this->basePath}/apps/" . substr($item, 4));
} else { } else {
@ -874,7 +874,7 @@ class ReleaseController extends Controller
$state = 'end'; $state = 'end';
} }
// add continued lines to the last item to keep them together // add continued lines to the last item to keep them together
if (!empty(${$state}) && trim($line !== '') && strpos($line, '- ') !== 0) { if (!empty(${$state}) && trim($line) !== '' && strncmp($line, '- ', 2) !== 0) {
end(${$state}); end(${$state});
${$state}[key(${$state})] .= "\n" . $line; ${$state}[key(${$state})] .= "\n" . $line;
} else { } else {

4
tests/data/validators/models/FakedValidationModel.php

@ -58,7 +58,7 @@ class FakedValidationModel extends Model
public function __get($name) public function __get($name)
{ {
if (stripos($name, 'attr') === 0) { if (strncasecmp($name, 'attr', 4) === 0) {
return isset($this->attr[$name]) ? $this->attr[$name] : null; return isset($this->attr[$name]) ? $this->attr[$name] : null;
} }
@ -67,7 +67,7 @@ class FakedValidationModel extends Model
public function __set($name, $value) public function __set($name, $value)
{ {
if (stripos($name, 'attr') === 0) { if (strncasecmp($name, 'attr', 4) === 0) {
$this->attr[$name] = $value; $this->attr[$name] = $value;
} else { } else {
parent::__set($name, $value); parent::__set($name, $value);

2
tests/framework/db/ActiveRecordTest.php

@ -744,7 +744,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase
// join with ON condition and alias in relation definition // join with ON condition and alias in relation definition
if ($aliasMethod === 'explicit' || $aliasMethod === 'querysyntax') { if ($aliasMethod === 'explicit' || $aliasMethod === 'querysyntax') {
$relationName = 'books' . ucfirst($aliasMethod) . 'A'; $relationName = 'books' . ucfirst($aliasMethod) . 'A';
$orders = Order::find()->joinWith(["$relationName"])->orderBy('order.id')->all(); $orders = Order::find()->joinWith([(string)$relationName])->orderBy('order.id')->all();
$this->assertCount(3, $orders); $this->assertCount(3, $orders);
$this->assertEquals(1, $orders[0]->id); $this->assertEquals(1, $orders[0]->id);
$this->assertEquals(2, $orders[1]->id); $this->assertEquals(2, $orders[1]->id);

2
tests/framework/db/CommandTest.php

@ -307,7 +307,7 @@ SQL;
public function testBatchInsertWithYield() public function testBatchInsertWithYield()
{ {
if (version_compare(PHP_VERSION, '5.5', '<')) { if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('The yield function is only supported with php 5.5 =< version'); $this->markTestSkipped('The yield function is only supported with php 5.5 =< version');
} else { } else {
include __DIR__ . '/testBatchInsertWithYield.php'; include __DIR__ . '/testBatchInsertWithYield.php';

4
tests/framework/db/mysql/connection/DeadLockTest.php

@ -31,7 +31,7 @@ class DeadLockTest extends \yiiunit\framework\db\mysql\ConnectionTest
*/ */
public function testDeadlockException() public function testDeadlockException()
{ {
if (getenv('TRAVIS') && version_compare(PHP_VERSION, '7.0.0', '<')) { if (getenv('TRAVIS') && PHP_VERSION_ID < 70000) {
$this->markTestSkipped('Skipping PHP 5 on Travis since it segfaults with pcntl'); $this->markTestSkipped('Skipping PHP 5 on Travis since it segfaults with pcntl');
} }
@ -272,7 +272,7 @@ class DeadLockTest extends \yiiunit\framework\db\mysql\ConnectionTest
*/ */
private function setErrorHandler() private function setErrorHandler()
{ {
if (version_compare(PHP_VERSION, '7', '<')) { if (PHP_VERSION_ID < 70000) {
set_error_handler(function ($errno, $errstr, $errfile, $errline) { set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new \ErrorException($errstr, $errno, $errno, $errfile, $errline); throw new \ErrorException($errstr, $errno, $errno, $errfile, $errline);
}); });

Loading…
Cancel
Save