Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable include rule in php-cs-fixer #14418

Merged
merged 4 commits into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enable include rule in php-cs-fixer config.
  • Loading branch information
rob006 committed Jul 9, 2017
commit 92e2f2419f89ac662bd4a18f700175ef03900af4
4 changes: 2 additions & 2 deletions build/controllers/PhpDocController.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ protected function findFiles($root, $needsInclude = true)
list(, $extension) = $matches;
Yii::setAlias("@yii/$extension", "$root");
if (is_file($autoloadFile = Yii::getAlias("@yii/$extension/vendor/autoload.php"))) {
include($autoloadFile);
include $autoloadFile;
}

if (isset($extensionExcept[$extension])) {
Expand All @@ -201,7 +201,7 @@ protected function findFiles($root, $needsInclude = true)
list(, $appName) = $matches;
Yii::setAlias("@app-$appName", "$root");
if (is_file($autoloadFile = Yii::getAlias("@app-$appName/vendor/autoload.php"))) {
include($autoloadFile);
include $autoloadFile;
}

$except[] = '/runtime/';
Expand Down
2 changes: 1 addition & 1 deletion build/controllers/ReleaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ protected function setAppAliases($app, $path)
break;
case 'advanced':
// setup @frontend, @backend etc...
require("$path/common/config/bootstrap.php");
require "$path/common/config/bootstrap.php";
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cs/src/YiiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct($name = 'yii-cs-config')
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
// 'heredoc_to_nowdoc' => true, // needs more discussion
// 'include' => true, // needs more discussion
'include' => true,
'is_null' => [
'use_yoda_style' => false,
],
Expand Down
2 changes: 1 addition & 1 deletion framework/BaseYii.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public static function autoload($className)
return;
}

include($classFile);
include $classFile;

if (YII_DEBUG && !class_exists($className, false) && !interface_exists($className, false) && !trait_exists($className, false)) {
throw new UnknownClassException("Unable to find '$className' in file: $classFile. Namespace missing?");
Expand Down
4 changes: 2 additions & 2 deletions framework/Yii.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/

require(__DIR__ . '/BaseYii.php');
require __DIR__ . '/BaseYii.php';

/**
* Yii is a helper class serving common framework functionalities.
Expand All @@ -21,5 +21,5 @@ class Yii extends \yii\BaseYii
}

spl_autoload_register(['Yii', 'autoload'], true, true);
Yii::$classMap = require(__DIR__ . '/classes.php');
Yii::$classMap = require __DIR__ . '/classes.php';
Yii::$container = new yii\di\Container();
4 changes: 2 additions & 2 deletions framework/base/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function handleError($code, $message, $file, $line)
// load ErrorException manually here because autoloading them will not work
// when error occurs while autoloading a class
if (!class_exists('yii\\base\\ErrorException', false)) {
require_once(__DIR__ . '/ErrorException.php');
require_once __DIR__ . '/ErrorException.php';
}
$exception = new ErrorException($message, $code, $code, $file, $line);

Expand Down Expand Up @@ -239,7 +239,7 @@ public function handleFatalError()
// load ErrorException manually here because autoloading them will not work
// when error occurs while autoloading a class
if (!class_exists('yii\\base\\ErrorException', false)) {
require_once(__DIR__ . '/ErrorException.php');
require_once __DIR__ . '/ErrorException.php';
}

$error = error_get_last();
Expand Down
2 changes: 1 addition & 1 deletion framework/base/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public function renderPhpFile($_file_, $_params_ = [])
ob_implicit_flush(false);
extract($_params_, EXTR_OVERWRITE);
try {
require($_file_);
require $_file_;
return ob_get_clean();
} catch (\Exception $e) {
while (ob_get_level() > $_obInitialLevel_) {
Expand Down
2 changes: 1 addition & 1 deletion framework/console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function loadConfig($config)
if (strpos($param, $option) !== false) {
$path = substr($param, strlen($option));
if (!empty($path) && is_file($file = Yii::getAlias($path))) {
return require($file);
return require $file;
} else {
exit("The configuration file does not exist: $path\n");
}
Expand Down
4 changes: 2 additions & 2 deletions framework/console/controllers/BaseMigrateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,13 @@ protected function includeMigrationFile($class)
foreach ($this->migrationPath as $path) {
$file = $path . DIRECTORY_SEPARATOR . $class . '.php';
if (is_file($file)) {
require_once($file);
require_once $file;
break;
}
}
} else {
$file = $this->migrationPath . DIRECTORY_SEPARATOR . $class . '.php';
require_once($file);
require_once $file;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions framework/console/controllers/MessageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function actionExtract($configFile = null)
if (!is_file($configFile)) {
throw new Exception("The configuration file does not exist: $configFile");
}
$configFileContent = require($configFile);
$configFileContent = require $configFile;
}

$config = array_merge(
Expand Down Expand Up @@ -538,7 +538,6 @@ protected function extractMessagesFromTokens(array $tokens, array $translatorTok
$category = mb_substr($category, 1, -1);

if (!$this->isCategoryIgnored($category, $ignoreCategories)) {

$fullMessage = mb_substr($buffer[2][1], 1, -1);
$i = 3;
while ($i < count($buffer) - 1 && !is_array($buffer[$i]) && $buffer[$i] === '.') {
Expand Down Expand Up @@ -687,7 +686,7 @@ protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnu
protected function saveMessagesCategoryToPHP($messages, $fileName, $overwrite, $removeUnused, $sort, $category, $markUnused)
{
if (is_file($fileName)) {
$rawExistingMessages = require($fileName);
$rawExistingMessages = require $fileName;
$existingMessages = $rawExistingMessages;
sort($messages);
ksort($existingMessages);
Expand Down
2 changes: 1 addition & 1 deletion framework/helpers/BaseFileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected static function loadMimeTypes($magicFile)
}
$magicFile = Yii::getAlias($magicFile);
if (!isset(self::$_mimeTypes[$magicFile])) {
self::$_mimeTypes[$magicFile] = require($magicFile);
self::$_mimeTypes[$magicFile] = require $magicFile;
}
return self::$_mimeTypes[$magicFile];
}
Expand Down
2 changes: 1 addition & 1 deletion framework/i18n/PhpMessageSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected function getMessageFilePath($category, $language)
protected function loadMessagesFromFile($messageFile)
{
if (is_file($messageFile)) {
$messages = include($messageFile);
$messages = include $messageFile;
if (!is_array($messages)) {
$messages = [];
}
Expand Down
2 changes: 1 addition & 1 deletion framework/rbac/PhpManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ protected function save()
protected function loadFromFile($file)
{
if (is_file($file)) {
return require($file);
return require $file;
} else {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion framework/test/ArrayFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function getData()
}
$dataFile = Yii::getAlias($this->dataFile);
if (is_file($dataFile)) {
return require($dataFile);
return require $dataFile;
} else {
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
}
Expand Down
2 changes: 1 addition & 1 deletion framework/test/BaseActiveFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function getData()
}
$dataFile = Yii::getAlias($this->dataFile);
if (is_file($dataFile)) {
return require($dataFile);
return require $dataFile;
} else {
throw new InvalidConfigException("Fixture data file does not exist: {$this->dataFile}");
}
Expand Down
2 changes: 1 addition & 1 deletion framework/test/InitDbFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function load()
{
$file = Yii::getAlias($this->initScript);
if (is_file($file)) {
require($file);
require $file;
}
}

Expand Down
2 changes: 1 addition & 1 deletion framework/web/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function renderFile($_file_, $_params_)
ob_start();
ob_implicit_flush(false);
extract($_params_, EXTR_OVERWRITE);
require(Yii::getAlias($_file_));
require Yii::getAlias($_file_);

return ob_get_clean();
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static function tearDownAfterClass()
public static function getParam($name, $default = null)
{
if (static::$params === null) {
static::$params = require(__DIR__ . '/data/config.php');
static::$params = require __DIR__ . '/data/config.php';
}

return isset(static::$params[$name]) ? static::$params[$name] : $default;
Expand Down
8 changes: 4 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// require composer autoloader if available
$composerAutoload = __DIR__ . '/../vendor/autoload.php';
if (is_file($composerAutoload)) {
require_once($composerAutoload);
require_once $composerAutoload;
}
require_once(__DIR__ . '/../framework/Yii.php');
require_once __DIR__ . '/../framework/Yii.php';

Yii::setAlias('@yiiunit', __DIR__);

require_once(__DIR__ . '/compatibility.php');
require_once(__DIR__ . '/TestCase.php');
require_once __DIR__ . '/compatibility.php';
require_once __DIR__ . '/TestCase.php';
2 changes: 1 addition & 1 deletion tests/data/config-docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
];

if (is_file(__DIR__ . '/config.local.php')) {
include(__DIR__ . '/config.local.php');
include __DIR__ . '/config.local.php';
}

return $config;
2 changes: 1 addition & 1 deletion tests/data/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
];

if (is_file(__DIR__ . '/config.local.php')) {
include(__DIR__ . '/config.local.php');
include __DIR__ . '/config.local.php';
}

return $config;
6 changes: 3 additions & 3 deletions tests/framework/console/controllers/AssetControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function testActionTemplate()
$configFileName = $this->testFilePath . DIRECTORY_SEPARATOR . 'config.php';
$this->runAssetControllerAction('template', [$configFileName]);
$this->assertFileExists($configFileName, 'Unable to create config file template!');
$config = require($configFileName);
$config = require $configFileName;
$this->assertInternalType('array', $config, 'Invalid config created!');
}

Expand Down Expand Up @@ -303,7 +303,7 @@ public function testActionCompress()

// Then :
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
$compressedBundleConfig = require($bundleFile);
$compressedBundleConfig = require $bundleFile;
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertCount(2, $compressedBundleConfig, 'Output bundle config contains wrong bundle count!');

Expand Down Expand Up @@ -383,7 +383,7 @@ public function testCompressExternalAsset()

// Then :
$this->assertFileExists($bundleFile, 'Unable to create output bundle file!');
$compressedBundleConfig = require($bundleFile);
$compressedBundleConfig = require $bundleFile;
$this->assertInternalType('array', $compressedBundleConfig, 'Output bundle file has incorrect format!');
$this->assertArrayHasKey($externalAssetBundleClassName, $compressedBundleConfig, 'External bundle is lost!');

Expand Down