PHPStorm refactoring.

This commit is contained in:
Andrés Montañez 2014-08-06 14:01:39 -03:00
parent 4c584b2634
commit fddeebe59a
48 changed files with 2011 additions and 1996 deletions

View file

@ -30,8 +30,7 @@ class Autoload
//Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar
$baseDir = dirname(dirname(__FILE__));
$classFileWithinPhar = $baseDir . $postfix;
if($this->isReadable($classFileWithinPhar))
{
if ($this->isReadable($classFileWithinPhar)) {
/** @noinspection PhpIncludeInspection */
require_once $classFileWithinPhar;
return true;

View file

@ -55,7 +55,8 @@ class InstallCommand extends AbstractCommand
// Check if there is already a symlink
if (file_exists($destinationDir . '/' . 'latest')
&& is_link($destinationDir . '/' . 'latest')) {
&& is_link($destinationDir . '/' . 'latest')
) {
unlink($destinationDir . '/' . 'latest');
}

View file

@ -116,7 +116,8 @@ class Config
* @return array
* @throws Config\ConfigNotFoundException
*/
protected function loadGeneral($filePath){
protected function loadGeneral($filePath)
{
return $this->parseConfigFile($filePath);
}
@ -142,6 +143,7 @@ class Config
return $settings;
}
/**
* Loads the Environment configuration
* @param $filePath string
@ -171,8 +173,7 @@ class Config
{
$environment = $this->getEnvironment();
if(!empty($environment))
{
if (!empty($environment)) {
$configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml';
try {
@ -193,16 +194,15 @@ class Config
{
if (empty($parameters))
return true;
foreach($parameters as $parameter)
{
if(isset(Console::$paramsNotRequiringEnvironment[$parameter]))
{
foreach ($parameters as $parameter) {
if (isset(Console::$paramsNotRequiringEnvironment[$parameter])) {
return true;
}
}
return false;
}
/**
* Load the Configuration and parses the Arguments
*
@ -575,13 +575,13 @@ class Config
*/
public function parseConfigFile($filePath)
{
if(!file_exists($filePath))
{
if (!file_exists($filePath)) {
throw new ConfigNotFoundException("Cannot find the file at path $filePath");
}
return $this->parseConfigText(file_get_contents($filePath));
}
public function parseConfigText($input)
{
return Yaml::parse($input);

View file

@ -66,8 +66,7 @@ class Mailer
array('{project}', '{environment}', '{result}'),
array($this->project, $this->environment, $result ? 'SUCCESS' : 'FAILURE'),
self::SUBJECT
)
;
);
$attachment = chunk_split(base64_encode(file_get_contents($this->logFile)));
$message = 'This is a multi-part message in MIME format.' . self::EOL
@ -83,8 +82,7 @@ class Mailer
. 'Content-Disposition: attachment' . self::EOL
. self::EOL
. $attachment . self::EOL
. '--Mage-mixed-' . $boundary . '--' . self::EOL
;
. '--Mage-mixed-' . $boundary . '--' . self::EOL;
@mail($this->address, $subject, $message, $headers);
}

View file

@ -171,7 +171,8 @@ class EncryptTask extends AbstractTask
*
* @see \Mage\Task\AbstractTask::getName()
*/
public function getName() {
public function getName()
{
return $this->name;
}
@ -180,7 +181,8 @@ class EncryptTask extends AbstractTask
*
* @see \Mage\Task\AbstractTask::init()
*/
public function init() {
public function init()
{
// Set the default extensions to ignore
$this->checkIgnoreExtens = array(
'jpg',
@ -324,7 +326,8 @@ class EncryptTask extends AbstractTask
* @return bool
* @throws \Mage\Task\ErrorWithMessageException
*/
public function run() {
public function run()
{
$this->switchSrcToTmp();
$this->writeProjectFile();
$result = $this->runIonCube();
@ -351,7 +354,8 @@ class EncryptTask extends AbstractTask
*
* @return bool
*/
private function checkEncoding() {
private function checkEncoding()
{
$src = $this->source;
// $ask holds flag to indicate we need to prompt the end user
$ask = false;
@ -407,7 +411,8 @@ class EncryptTask extends AbstractTask
*
* @return bool True if 'y' pressed
*/
private function promptYn() {
private function promptYn()
{
$handle = fopen("php://stdin", "r");
$line = strtolower(fgets($handle));
if (trim($line) != 'y') {
@ -428,7 +433,8 @@ class EncryptTask extends AbstractTask
*
* @return boolean True if file was encoded/encrypted
*/
private function checkFileCoding($filename) {
private function checkFileCoding($filename)
{
// check to see if this is an encrypted file
$ioncube = ioncube_read_file($filename, $ioncubeType);
if (is_int($ioncube)) {
@ -461,7 +467,8 @@ class EncryptTask extends AbstractTask
*
* @return void
*/
private function deleteTmpFiles() {
private function deleteTmpFiles()
{
if (isset ($this->mageConfig ['keeptemp'])) {
return;
}
@ -480,7 +487,8 @@ class EncryptTask extends AbstractTask
*
* @return bool
*/
private function runIonCube() {
private function runIonCube()
{
$cli = $this->encoder . ' --project-file ' . $this->projectFile . ' ' . $this->ionSource . DIRECTORY_SEPARATOR . '*';
$ret = Console::executeCommand($cli, $out);
return $ret;
@ -495,7 +503,8 @@ class EncryptTask extends AbstractTask
*
* @return void
*/
private function writeProjectFile() {
private function writeProjectFile()
{
// array used to build config file into
$out = array();
// set the project destination
@ -535,7 +544,8 @@ class EncryptTask extends AbstractTask
*
* @return array Final config array
*/
private function mergeConfigFiles() {
private function mergeConfigFiles()
{
/*
* Options are the order the arrays are in
* F - Project File
@ -591,7 +601,8 @@ class EncryptTask extends AbstractTask
*
* @return bool
*/
private function switchSrcToTmp() {
private function switchSrcToTmp()
{
$ret = Console::executeCommand('mv ' . $this->source . ' ' . $this->ionSource, $out);
if (!$ret) {
throw new ErrorWithMessageException ('Cant create tmp dir :' . $out, $ret);
@ -611,7 +622,8 @@ class EncryptTask extends AbstractTask
*
* return array
*/
private function getOptionsFromYaml($options) {
private function getOptionsFromYaml($options)
{
$s = array();
$p = array();
foreach ($options as $key => $value) {
@ -635,7 +647,8 @@ class EncryptTask extends AbstractTask
* @param $fileName
* @return array
*/
private function getOptionsFromFile($fileName) {
private function getOptionsFromFile($fileName)
{
$s = array();
$p = array();
$fileContents = file_get_contents($fileName);
@ -693,7 +706,8 @@ class EncryptTask extends AbstractTask
*
* @return mixed
*/
private function splitParam($string) {
private function splitParam($string)
{
$split = explode(PHP_EOL, $string);
if ($split === false) {
// nothing found, so return a blank string
@ -715,7 +729,8 @@ class EncryptTask extends AbstractTask
*
* @return array
*/
private function getOptionsDefault() {
private function getOptionsDefault()
{
$s = array();
$p = array();
// Set the switches

View file

@ -166,7 +166,9 @@ class Inline
// array
$keys = array_keys($value);
if ((1 == count($keys) && '0' == $keys[0])
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) {
return (int)$v + $w;
}, 0) == count($keys) * (count($keys) - 1) / 2)
) {
$output = array();
foreach ($value as $val) {