Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Nov 20, 2018
1 parent 268300c commit b2f4384
Show file tree
Hide file tree
Showing 38 changed files with 124 additions and 152 deletions.
44 changes: 22 additions & 22 deletions bootstrap/bootstrap.php
Expand Up @@ -58,7 +58,7 @@
// Set a 503 response header so things like Varnish won't cache a bad page.
http_response_code(503);

exit('Tried to create a folder at '.$path.', but could not.' . PHP_EOL);
exit('Tried to create a folder at ' . $path . ', but could not.' . PHP_EOL);
}

// Because setting permission with mkdir is a crapshoot.
Expand All @@ -71,19 +71,19 @@
$realPath = realpath($path);

// !@file_exists('/.') is a workaround for the terrible is_executable()
if ($realPath === false || !is_dir($realPath) || !@file_exists($realPath.'/.')) {
if ($realPath === false || !is_dir($realPath) || !@file_exists($realPath . '/.')) {
// Set a 503 response header so things like Varnish won't cache a bad page.
http_response_code(503);

exit(($realPath !== false ? $realPath : $path).' doesn\'t exist or isn\'t writable by PHP. Please fix that.' . PHP_EOL);
exit(($realPath !== false ? $realPath : $path) . ' doesn\'t exist or isn\'t writable by PHP. Please fix that.' . PHP_EOL);
}

if ($writableToo) {
if (!is_writable($realPath)) {
// Set a 503 response header so things like Varnish won't cache a bad page.
http_response_code(503);

exit($realPath.' isn\'t writable by PHP. Please fix that.' . PHP_EOL);
exit($realPath . ' isn\'t writable by PHP. Please fix that.' . PHP_EOL);
}
}
};
Expand All @@ -98,11 +98,11 @@
$rootPath = $findConfigPath('CRAFT_BASE_PATH', 'basePath') ?: dirname($vendorPath);

// By default the remaining directories will be in the base directory
$configPath = $findConfigPath('CRAFT_CONFIG_PATH', 'configPath') ?: $rootPath.'/config';
$contentMigrationsPath = $findConfigPath('CRAFT_CONTENT_MIGRATIONS_PATH', 'contentMigrationsPath') ?: $rootPath.'/migrations';
$storagePath = $findConfigPath('CRAFT_STORAGE_PATH', 'storagePath') ?: $rootPath.'/storage';
$templatesPath = $findConfigPath('CRAFT_TEMPLATES_PATH', 'templatesPath') ?: $rootPath.'/templates';
$translationsPath = $findConfigPath('CRAFT_TRANSLATIONS_PATH', 'translationsPath') ?: $rootPath.'/translations';
$configPath = $findConfigPath('CRAFT_CONFIG_PATH', 'configPath') ?: $rootPath . '/config';
$contentMigrationsPath = $findConfigPath('CRAFT_CONTENT_MIGRATIONS_PATH', 'contentMigrationsPath') ?: $rootPath . '/migrations';
$storagePath = $findConfigPath('CRAFT_STORAGE_PATH', 'storagePath') ?: $rootPath . '/storage';
$templatesPath = $findConfigPath('CRAFT_TEMPLATES_PATH', 'templatesPath') ?: $rootPath . '/templates';
$translationsPath = $findConfigPath('CRAFT_TRANSLATIONS_PATH', 'translationsPath') ?: $rootPath . '/translations';

// Set the environment
$environment = $findConfig('CRAFT_ENVIRONMENT', 'env') ?: ($_SERVER['SERVER_NAME'] ?? null);
Expand All @@ -128,7 +128,7 @@
$ensureFolderIsReadable($licensePath);

if ($appType === 'web') {
$licenseFullPath = $licensePath.'/'.$licenseKeyName;
$licenseFullPath = $licensePath . '/' . $licenseKeyName;

// If the license key doesn't exist yet, make sure the folder is readable and we can write a temp one.
if (!file_exists($licenseFullPath)) {
Expand All @@ -137,7 +137,7 @@

// See if it worked.
if (!file_exists($licenseFullPath) || (file_exists($licenseFullPath) && file_get_contents($licenseFullPath) !== 'temp')) {
exit($licensePath.' isn\'t writable by PHP. Please fix that.' . PHP_EOL);
exit($licensePath . ' isn\'t writable by PHP. Please fix that.' . PHP_EOL);
}
}
}
Expand All @@ -147,16 +147,16 @@
$ensureFolderIsReadable($storagePath, true);

// Create the storage/runtime/ folder if it doesn't already exist
$createFolder($storagePath.'/runtime');
$ensureFolderIsReadable($storagePath.'/runtime', true);
$createFolder($storagePath . '/runtime');
$ensureFolderIsReadable($storagePath . '/runtime', true);

// Create the storage/logs/ folder if it doesn't already exist
$createFolder($storagePath.'/logs');
$ensureFolderIsReadable($storagePath.'/logs', true);
$createFolder($storagePath . '/logs');
$ensureFolderIsReadable($storagePath . '/logs', true);

// Log errors to storage/logs/phperrors.log
ini_set('log_errors', 1);
ini_set('error_log', $storagePath.'/logs/phperrors.log');
ini_set('error_log', $storagePath . '/logs/phperrors.log');
error_reporting(E_ALL);

// Load the general config
Expand All @@ -165,7 +165,7 @@
$configService = new Config();
$configService->env = $environment;
$configService->configDir = $configPath;
$configService->appDefaultsDir = dirname(__DIR__).DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'defaults';
$configService->appDefaultsDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'defaults';
$generalConfig = $configService->getConfigFromFile('general');

// Determine if Craft is running in Dev Mode
Expand Down Expand Up @@ -196,11 +196,11 @@
defined('CURLOPT_CONNECTTIMEOUT_MS') || define('CURLOPT_CONNECTTIMEOUT_MS', 156);

// Load the files
$cmsPath = $vendorPath.'/craftcms/cms';
$libPath = $cmsPath.'/lib';
$srcPath = $cmsPath.'/src';
require $srcPath.'/Yii.php';
require $srcPath.'/Craft.php';
$cmsPath = $vendorPath . '/craftcms/cms';
$libPath = $cmsPath . '/lib';
$srcPath = $cmsPath . '/src';
require $srcPath . '/Yii.php';
require $srcPath . '/Craft.php';

// Move Yii's autoloader to the end (Composer's is faster when optimized)
spl_autoload_unregister(['Yii', 'autoload']);
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/console.php
Expand Up @@ -28,4 +28,4 @@

$appType = 'console';

return require __DIR__.'/bootstrap.php';
return require __DIR__ . '/bootstrap.php';
2 changes: 1 addition & 1 deletion bootstrap/web.php
Expand Up @@ -39,4 +39,4 @@

$appType = 'web';

return require __DIR__.'/bootstrap.php';
return require __DIR__ . '/bootstrap.php';
1 change: 0 additions & 1 deletion src/base/ApplicationTrait.php
Expand Up @@ -33,7 +33,6 @@
use craft\services\Sites;
use craft\services\Tags;
use craft\services\UserGroups;
use craft\services\UserPermissions;
use craft\services\Users;
use craft\services\Volumes;
use craft\web\Application as WebApplication;
Expand Down
3 changes: 0 additions & 3 deletions src/behaviors/EnvAttributeParserBehavior.php
Expand Up @@ -8,11 +8,8 @@
namespace craft\behaviors;

use Craft;
use craft\base\FieldInterface;
use craft\helpers\StringHelper;
use craft\models\FieldLayout;
use yii\base\Behavior;
use yii\base\InvalidConfigException;
use yii\base\Model;
use yii\validators\UrlValidator;

Expand Down
1 change: 0 additions & 1 deletion src/controllers/BaseElementsController.php
Expand Up @@ -12,7 +12,6 @@
use craft\errors\InvalidTypeException;
use craft\web\Controller;
use yii\web\BadRequestHttpException;
use yii\web\ForbiddenHttpException;

/**
* The BaseElementsController class provides some common methods for [[ElementsController]] and [[ElementIndexesController]].
Expand Down
4 changes: 0 additions & 4 deletions src/controllers/ConfigSyncController.php
Expand Up @@ -7,16 +7,12 @@

namespace craft\controllers;

use Composer\IO\BufferIO;
use Composer\Semver\Comparator;
use Composer\Semver\VersionParser;
use Craft;
use craft\base\Plugin;
use craft\errors\InvalidPluginException;
use craft\helpers\ArrayHelper;
use craft\services\Plugins;
use yii\base\NotSupportedException;
use yii\web\BadRequestHttpException;
use yii\web\Response;

/**
Expand Down
1 change: 0 additions & 1 deletion src/controllers/SystemSettingsController.php
Expand Up @@ -18,7 +18,6 @@
use craft\mail\transportadapters\BaseTransportAdapter;
use craft\mail\transportadapters\Sendmail;
use craft\mail\transportadapters\TransportAdapterInterface;
use craft\models\Info;
use craft\models\MailSettings;
use craft\web\assets\generalsettings\GeneralSettingsAsset;
use craft\web\Controller;
Expand Down
7 changes: 0 additions & 7 deletions src/elements/actions/DeepDuplicate.php
Expand Up @@ -7,13 +7,6 @@

namespace craft\elements\actions;

use Craft;
use craft\base\Element;
use craft\base\ElementAction;
use craft\base\ElementInterface;
use craft\elements\db\ElementQueryInterface;
use craft\helpers\ArrayHelper;

/**
* DeepDuplicate represents a "Duplicate (with descendants)" element action.
*
Expand Down
1 change: 0 additions & 1 deletion src/elements/actions/Duplicate.php
Expand Up @@ -12,7 +12,6 @@
use craft\base\ElementAction;
use craft\base\ElementInterface;
use craft\elements\db\ElementQueryInterface;
use craft\helpers\ArrayHelper;

/**
* Duplicate represents a Duplicate element action.
Expand Down
3 changes: 0 additions & 3 deletions src/events/DeleteElementEvent.php
Expand Up @@ -7,9 +7,6 @@

namespace craft\events;

use craft\base\ElementInterface;
use yii\base\Event;

/**
* Delete element event class.
*
Expand Down
8 changes: 5 additions & 3 deletions src/fields/Assets.php
Expand Up @@ -128,9 +128,11 @@ public function rules()
{
$rules = parent::rules();

$rules[] = [['allowedKinds'], 'required', 'when' => function(self $field): bool {
return (bool)$field->restrictFiles;
}];
$rules[] = [
['allowedKinds'], 'required', 'when' => function(self $field): bool {
return (bool)$field->restrictFiles;
}
];

return $rules;
}
Expand Down
6 changes: 3 additions & 3 deletions src/fields/Matrix.php
Expand Up @@ -924,9 +924,9 @@ private function _createBlocksFromSerializedData($value, ElementInterface $eleme
// Should we ignore disabled blocks?
$request = Craft::$app->getRequest();
$hideDisabledBlocks = !$request->getIsConsoleRequest() && (
$request->getToken() !== null ||
$request->getIsLivePreview()
);
$request->getToken() !== null ||
$request->getIsLivePreview()
);

$blocks = [];
$sortOrder = 0;
Expand Down
1 change: 0 additions & 1 deletion src/migrations/m150617_213829_update_email_settings.php
Expand Up @@ -2,7 +2,6 @@

namespace craft\migrations;

use Craft;
use craft\db\Migration;
use craft\db\Query;
use craft\helpers\Json;
Expand Down
1 change: 0 additions & 1 deletion src/migrations/m180517_173000_user_photo_volume_to_uid.php
Expand Up @@ -49,7 +49,6 @@ public function safeUp()
], [
'category' => 'users'
], [], false);

}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/migrations/m180521_173000_initial_yml_and_snapshot.php
Expand Up @@ -8,9 +8,7 @@
use craft\elements\User;
use craft\helpers\ArrayHelper;
use craft\helpers\DateTimeHelper;
use craft\helpers\FileHelper;
use craft\helpers\Json;
use Symfony\Component\Yaml\Yaml;

/**
* m180521_173000_initial_yml_and_snapshot migration.
Expand Down
1 change: 0 additions & 1 deletion src/migrations/m181112_203955_sequences_table.php
Expand Up @@ -2,7 +2,6 @@

namespace craft\migrations;

use Craft;
use craft\db\Migration;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/services/AssetTransforms.php
Expand Up @@ -280,12 +280,12 @@ public function handleChangedTransform(ConfigEvent $event)
$transformRecord->save(false);

$transaction->commit();

} catch (\Throwable $e) {
$transaction->rollBack();
throw $e;
}
}

/**
* Deletes an asset transform by its ID.
*
Expand Down Expand Up @@ -902,7 +902,7 @@ public function getLocalImageSource(Asset $asset): string
// Fetch a list of existing temp files for this image.
$files = FileHelper::findFiles($tempPath, [
'only' => [
$prefix . '*' . '.' . $extension
$prefix . '*' . '.' . $extension
]
]);

Expand Down
2 changes: 0 additions & 2 deletions src/services/Matrix.php
Expand Up @@ -12,12 +12,10 @@
use craft\base\ElementInterface;
use craft\base\Field;
use craft\db\Query;
use craft\elements\db\ElementQueryInterface;
use craft\elements\db\MatrixBlockQuery;
use craft\elements\MatrixBlock;
use craft\errors\MatrixBlockTypeNotFoundException;
use craft\events\ConfigEvent;
use craft\fields\BaseRelationField;
use craft\fields\Matrix as MatrixField;
use craft\helpers\ArrayHelper;
use craft\helpers\Db;
Expand Down
7 changes: 1 addition & 6 deletions src/services/Routes.php
Expand Up @@ -8,15 +8,10 @@
namespace craft\services;

use Craft;
use craft\db\Query;
use craft\errors\RouteNotFoundException;
use craft\events\DeleteSiteEvent;
use craft\events\RouteEvent;
use craft\helpers\ArrayHelper;
use craft\helpers\Db;
use craft\helpers\Json;
use craft\helpers\StringHelper;
use craft\records\Route as RouteRecord;
use yii\base\Component;

/**
Expand Down Expand Up @@ -307,6 +302,6 @@ private function _getMaxSortOrder(): int
$max = max($max, $route['sortOrder']);
}

return (int) $max + 1;
return (int)$max + 1;
}
}
1 change: 0 additions & 1 deletion src/services/Updates.php
Expand Up @@ -16,7 +16,6 @@
use craft\models\Updates as UpdatesModel;
use yii\base\Component;
use yii\base\ErrorException;
use yii\base\Exception;
use yii\base\InvalidArgumentException;

/**
Expand Down

0 comments on commit b2f4384

Please sign in to comment.