Skip to content

Commit

Permalink
[PSR-2] Remove spaces after and before the parenthesis
Browse files Browse the repository at this point in the history
Fixed with php-cs-fixer and `parenthesis` fixer
  • Loading branch information
julienbourdeau committed Jul 6, 2015
1 parent 14b4db6 commit 74f2deb
Show file tree
Hide file tree
Showing 40 changed files with 244 additions and 244 deletions.
2 changes: 1 addition & 1 deletion Core/Business/Email/Core_Business_Email_EmailLister.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getAvailableMails($dir)
$tmp = explode('.', $mail->getFilename());

// Check for filename existence (left part) and if extension is html (right part)
if ( ($tmp === false || !isset($tmp[0])) || (isset($tmp[1]) && $tmp[1] !== 'html')) {
if (($tmp === false || !isset($tmp[0])) || (isset($tmp[1]) && $tmp[1] !== 'html')) {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion admin-dev/backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
// Check the realpath so we can validate the backup file is under the backup directory
$backupfile = realpath($backupdir.DIRECTORY_SEPARATOR.$backupfile);

if ($backupfile === false or strncmp($backupdir, $backupfile, strlen($backupdir)) != 0 )
if ($backupfile === false or strncmp($backupdir, $backupfile, strlen($backupdir)) != 0)
die (Tools::dieOrLog('The backup file does not exist.'));

if (substr($backupfile, -4) == '.bz2')
Expand Down
82 changes: 41 additions & 41 deletions admin-dev/filemanager/include/php_image_magician.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHe
break;

case 't':
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = 0;
break;

Expand All @@ -497,17 +497,17 @@ private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHe

case 'l':
$cropStartX = 0;
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$cropStartY = ($optimalHeight/ 2) - ($newHeight/2);
break;

case 'm':
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = ($optimalHeight/ 2) - ($newHeight/2);
break;

case 'r':
$cropStartX = $optimalWidth - $newWidth;
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$cropStartY = ($optimalHeight/ 2) - ($newHeight/2);
break;

case 'bl':
Expand All @@ -516,7 +516,7 @@ private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHe
break;

case 'b':
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = $optimalHeight - $newHeight;
break;

Expand All @@ -528,20 +528,20 @@ private function getCropPlacing($optimalWidth, $optimalHeight, $newWidth, $newHe
case 'auto':
// *** If image is a portrait crop from top, not center. v1.5
if ($optimalHeight > $optimalWidth) {
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = ($this->cropFromTopPercent /100) * $optimalHeight;
} else {

// *** Else crop from the center
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = ($optimalHeight/ 2) - ($newHeight/2);
}
break;

default:
// *** Default to center
$cropStartX = ( $optimalWidth / 2) - ( $newWidth /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newHeight/2 );
$cropStartX = ($optimalWidth / 2) - ($newWidth /2);
$cropStartY = ($optimalHeight/ 2) - ($newHeight/2);
break;
}
}
Expand Down Expand Up @@ -769,8 +769,8 @@ private function getOptimalCrop($newWidth, $newHeight)
$optimalRatio = $widthRatio;
}

$optimalHeight = round( $this->height / $optimalRatio );
$optimalWidth = round( $this->width / $optimalRatio );
$optimalHeight = round($this->height / $optimalRatio);
$optimalWidth = round($this->width / $optimalRatio);

return array('optimalWidth' => $optimalWidth, 'optimalHeight' => $optimalHeight);
}
Expand Down Expand Up @@ -1072,13 +1072,13 @@ public function sepia2()
{
if ($this->imageResized) {

$total = imagecolorstotal( $this->imageResized );
for ( $i = 0; $i < $total; $i++ ) {
$index = imagecolorsforindex( $this->imageResized, $i );
$red = ( $index["red"] * 0.393 + $index["green"] * 0.769 + $index["blue"] * 0.189 ) / 1.351;
$green = ( $index["red"] * 0.349 + $index["green"] * 0.686 + $index["blue"] * 0.168 ) / 1.203;
$blue = ( $index["red"] * 0.272 + $index["green"] * 0.534 + $index["blue"] * 0.131 ) / 2.140;
imagecolorset( $this->imageResized, $i, $red, $green, $blue );
$total = imagecolorstotal($this->imageResized);
for ($i = 0; $i < $total; $i++) {
$index = imagecolorsforindex($this->imageResized, $i);
$red = ($index["red"] * 0.393 + $index["green"] * 0.769 + $index["blue"] * 0.189) / 1.351;
$green = ($index["red"] * 0.349 + $index["green"] * 0.686 + $index["blue"] * 0.168) / 1.203;
$blue = ($index["red"] * 0.272 + $index["green"] * 0.534 + $index["blue"] * 0.131) / 2.140;
imagecolorset($this->imageResized, $i, $red, $green, $blue);
}


Expand Down Expand Up @@ -1414,7 +1414,7 @@ public function roundCorners($radius = 5, $bgColor = 'transparent')
imagefill($cornerImg, 0, 0, $imagebgColor);


imagefilledellipse($cornerImg, $radius, $radius, $radius * 2, $radius * 2, $maskColor );
imagefilledellipse($cornerImg, $radius, $radius, $radius * 2, $radius * 2, $maskColor);


// *** Map to top left corner
Expand Down Expand Up @@ -2059,8 +2059,8 @@ private function iptc_maketag($rec,$dat,$val)
chr(0x80).chr(0x04).
chr(($len >> 24) & 0xff).
chr(($len >> 16) & 0xff).
chr(($len >> 8 ) & 0xff).
chr(($len ) & 0xff).
chr(($len >> 8) & 0xff).
chr(($len) & 0xff).
$val;
}

Expand Down Expand Up @@ -2348,7 +2348,7 @@ private function filterOpacity(&$img, $opacity = 75)
$minalpha = 127;
for ($x = 0; $x < $w; $x++)
for ($y = 0; $y < $h; $y++) {
$alpha = ( imagecolorat($img, $x, $y) >> 24 ) & 0xFF;
$alpha = (imagecolorat($img, $x, $y) >> 24) & 0xFF;
if ($alpha < $minalpha) {
$minalpha = $alpha;
}
Expand All @@ -2359,15 +2359,15 @@ private function filterOpacity(&$img, $opacity = 75)
for ($y = 0; $y < $h; $y++) {
//get current alpha value (represents the TANSPARENCY!)
$colorxy = imagecolorat($img, $x, $y);
$alpha = ( $colorxy >> 24 ) & 0xFF;
$alpha = ($colorxy >> 24) & 0xFF;
//calculate new alpha
if ($minalpha !== 127) {
$alpha = 127 + 127 * $opacity * ( $alpha - 127 ) / ( 127 - $minalpha );
$alpha = 127 + 127 * $opacity * ($alpha - 127) / (127 - $minalpha);
} else {
$alpha += 127 * $opacity;
}
//get the color index with new alpha
$alphacolorxy = imagecolorallocatealpha($img, ( $colorxy >> 16 ) & 0xFF, ( $colorxy >> 8 ) & 0xFF, $colorxy & 0xFF, $alpha);
$alphacolorxy = imagecolorallocatealpha($img, ($colorxy >> 16) & 0xFF, ($colorxy >> 8) & 0xFF, $colorxy & 0xFF, $alpha);
//set pixel with the new color + opacity
if (!imagesetpixel($img, $x, $y, $alphacolorxy)) {

Expand Down Expand Up @@ -3032,22 +3032,22 @@ private function GD2BMPstring(&$gd_image)
// BITMAPFILEHEADER [14 bytes] - http://msdn.microsoft.com/library/en-us/gdi/bitmaps_62uq.asp
$BITMAPFILEHEADER = 'BM'; // WORD bfType;
$BITMAPFILEHEADER .= $this->LittleEndian2String($bmpSize, 4); // DWORD bfSize;
$BITMAPFILEHEADER .= $this->LittleEndian2String( 0, 2); // WORD bfReserved1;
$BITMAPFILEHEADER .= $this->LittleEndian2String( 0, 2); // WORD bfReserved2;
$BITMAPFILEHEADER .= $this->LittleEndian2String( 54, 4); // DWORD bfOffBits;
$BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved1;
$BITMAPFILEHEADER .= $this->LittleEndian2String(0, 2); // WORD bfReserved2;
$BITMAPFILEHEADER .= $this->LittleEndian2String(54, 4); // DWORD bfOffBits;

// BITMAPINFOHEADER - [40 bytes] http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1rw2.asp
$BITMAPINFOHEADER = $this->LittleEndian2String( 40, 4); // DWORD biSize;
$BITMAPINFOHEADER .= $this->LittleEndian2String( $imageX, 4); // LONG biWidth;
$BITMAPINFOHEADER .= $this->LittleEndian2String( $imageY, 4); // LONG biHeight;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 1, 2); // WORD biPlanes;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 24, 2); // WORD biBitCount;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 0, 4); // DWORD biCompression;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 0, 4); // DWORD biSizeImage;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 2835, 4); // LONG biXPelsPerMeter;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 2835, 4); // LONG biYPelsPerMeter;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 0, 4); // DWORD biClrUsed;
$BITMAPINFOHEADER .= $this->LittleEndian2String( 0, 4); // DWORD biClrImportant;
$BITMAPINFOHEADER = $this->LittleEndian2String(40, 4); // DWORD biSize;
$BITMAPINFOHEADER .= $this->LittleEndian2String($imageX, 4); // LONG biWidth;
$BITMAPINFOHEADER .= $this->LittleEndian2String($imageY, 4); // LONG biHeight;
$BITMAPINFOHEADER .= $this->LittleEndian2String(1, 2); // WORD biPlanes;
$BITMAPINFOHEADER .= $this->LittleEndian2String(24, 2); // WORD biBitCount;
$BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biCompression;
$BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biSizeImage;
$BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biXPelsPerMeter;
$BITMAPINFOHEADER .= $this->LittleEndian2String(2835, 4); // LONG biYPelsPerMeter;
$BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrUsed;
$BITMAPINFOHEADER .= $this->LittleEndian2String(0, 4); // DWORD biClrImportant;

return $BITMAPFILEHEADER.$BITMAPINFOHEADER.$BMP;
}
Expand Down
34 changes: 17 additions & 17 deletions admin-dev/filemanager/include/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function create_img($imgfile, $imgthumb, $newwidth, $newheight="") {
function makeSize($size) {
$units = array('B','KB','MB','GB','TB');
$u = 0;
while ( (round($size / 1024) > 0) && ($u < 4) ) {
while ((round($size / 1024) > 0) && ($u < 4)) {
$size = $size / 1024;
$u++;
}
Expand Down Expand Up @@ -120,37 +120,37 @@ function check_files_extensions_on_path($path,$ext){
}
}

function check_files_extensions_on_phar( $phar, &$files, $basepath, $ext ) {
foreach( $phar as $file )
function check_files_extensions_on_phar($phar, &$files, $basepath, $ext) {
foreach($phar as $file)
{
if( $file->isFile() )
if($file->isFile())
{
if (function_exists('mb_strtolower'))
if(in_array(mb_strtolower($file->getExtension()),$ext))
$files[] = $basepath.$file->getFileName( );
$files[] = $basepath.$file->getFileName();
elseif(in_array(Tools::strtolower($file->getExtension()),$ext))
$files[] = $basepath.$file->getFileName( );
$files[] = $basepath.$file->getFileName();
}
elseif( $file->isDir() )
elseif($file->isDir())
{
$iterator = new DirectoryIterator( $file );
$iterator = new DirectoryIterator($file);
check_files_extensions_on_phar($iterator, $files, $basepath.$file->getFileName().'/', $ext);
}
}
}

function fix_filename($str,$transliteration){
if($transliteration){
if( function_exists( 'transliterator_transliterate' ) )
if(function_exists('transliterator_transliterate'))
{
$str = transliterator_transliterate( 'Accents-Any', $str );
$str = transliterator_transliterate('Accents-Any', $str);
}
else
{
$str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
}

$str = preg_replace( "/[^a-zA-Z0-9\.\[\]_| -]/", '', $str );
$str = preg_replace("/[^a-zA-Z0-9\.\[\]_| -]/", '', $str);
}

$str=str_replace(array('"',"'","/","\\"),"",$str);
Expand All @@ -159,28 +159,28 @@ function fix_filename($str,$transliteration){
// Empty or incorrectly transliterated filename.
// Here is a point: a good file UNKNOWN_LANGUAGE.jpg could become .jpg in previous code.
// So we add that default 'file' name to fix that issue.
if( strpos( $str, '.' ) === 0 )
if(strpos($str, '.') === 0)
{
$str = 'file'.$str;
}

return trim( $str );
return trim($str);
}

function fix_dirname($str){
return str_replace('~',' ',dirname(str_replace(' ','~',$str)));
}

function fix_strtoupper($str){
if( function_exists( 'mb_strtoupper' ) )
if(function_exists('mb_strtoupper'))
return mb_strtoupper($str);
else
return strtoupper($str);
}


function fix_strtolower($str){
if( function_exists( 'mb_strtoupper' ) )
if(function_exists('mb_strtoupper'))
return mb_strtolower($str);
else
return strtolower($str);
Expand Down Expand Up @@ -234,8 +234,8 @@ function image_check_memory_usage($img, $max_breedte, $max_hoogte){
$image_width = $image_properties[0];
$image_height = $image_properties[1];
$image_bits = $image_properties['bits'];
$image_memory_usage = $K64 + ($image_width * $image_height * ($image_bits ) * 2);
$thumb_memory_usage = $K64 + ($max_breedte * $max_hoogte * ($image_bits ) * 2);
$image_memory_usage = $K64 + ($image_width * $image_height * ($image_bits) * 2);
$thumb_memory_usage = $K64 + ($max_breedte * $max_hoogte * ($image_bits) * 2);
$memory_needed = intval($memory_usage + $image_memory_usage + $thumb_memory_usage);

if($memory_needed > $memory_limit){
Expand Down
6 changes: 3 additions & 3 deletions classes/AdminTab.php
Original file line number Diff line number Diff line change
Expand Up @@ -1450,12 +1450,12 @@ public function displayListHeader($token = null)
<script type="text/javascript">
var token = \''.($token != null ? $token : $this->token).'\';
var come_from = \''.$this->table.'\';
var alternate = \''.($this->_orderWay == 'DESC' ? '1' : '0' ).'\';
var alternate = \''.($this->_orderWay == 'DESC' ? '1' : '0').'\';
</script>
<script type="text/javascript" src="../js/admin/dnd.js"></script>
';
}
echo '<table'.(array_key_exists($this->identifier, $this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? Tools::substr($this->identifier, 3, Tools::strlen($this->identifier)) : '').'"' : '' ).' class="table'.((array_key_exists($this->identifier, $this->identifiersDnd) && ($this->_orderBy != 'position' && $this->_orderWay != 'DESC')) ? ' tableDnD' : '' ).'" cellpadding="0" cellspacing="0">
echo '<table'.(array_key_exists($this->identifier, $this->identifiersDnd) ? ' id="'.(((int)(Tools::getValue($this->identifiersDnd[$this->identifier], 1))) ? Tools::substr($this->identifier, 3, Tools::strlen($this->identifier)) : '').'"' : '').' class="table'.((array_key_exists($this->identifier, $this->identifiersDnd) && ($this->_orderBy != 'position' && $this->_orderWay != 'DESC')) ? ' tableDnD' : '').'" cellpadding="0" cellspacing="0">
<thead>
<tr class="nodrag nodrop">
<th>';
Expand Down Expand Up @@ -2042,7 +2042,7 @@ public function displayOptionTypeImage($key, $field, $value)
echo '<img src="../themes/'.$theme['name'].'/preview.jpg" alt="'.Tools::strtolower($theme['name']).'">';
echo '</label>';
echo '</td>';
if (isset($field['max']) && ($i + 1 ) % $field['max'] == 0)
if (isset($field['max']) && ($i + 1) % $field['max'] == 0)
echo '</tr><tr>';
$i++;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static function getModulesFromHook($id_hook, $id_module = null)
public static function getHookModuleExecList($hook_name = null)
{
$context = Context::getContext();
$cache_id = 'hook_module_exec_list_'.(isset($context->shop->id) ? '_'.$context->shop->id : '' ).((isset($context->customer)) ? '_'.$context->customer->id : '');
$cache_id = 'hook_module_exec_list_'.(isset($context->shop->id) ? '_'.$context->shop->id : '').((isset($context->customer)) ? '_'.$context->customer->id : '');
if (!Cache::isStored($cache_id) || $hook_name == 'displayPayment' || $hook_name == 'displayBackOfficeHeader')
{
$frontend = true;
Expand Down
2 changes: 1 addition & 1 deletion classes/Manufacturer.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static function getManufacturers($get_nb_products = false, $id_lang = 0,
'.Shop::addSqlAssociation('manufacturer', 'm').'
INNER JOIN `'._DB_PREFIX_.'manufacturer_lang` ml ON (m.`id_manufacturer` = ml.`id_manufacturer` AND ml.`id_lang` = '.(int)$id_lang.')
'.($active ? 'WHERE m.`active` = 1' : '')
.($group_by ? ' GROUP BY m.`id_manufacturer`' : '' ).'
.($group_by ? ' GROUP BY m.`id_manufacturer`' : '').'
ORDER BY m.`name` ASC
'.($p ? ' LIMIT '.(((int)$p - 1) * (int)$n).','.(int)$n : ''));
if ($manufacturers === false)
Expand Down
2 changes: 1 addition & 1 deletion classes/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static function getCmsMetas($id_cms, $id_lang, $page_name)
WHERE id_lang = '.(int)$id_lang.'
AND id_cms = '.(int)$id_cms.
((int)Context::getContext()->shop->id ?
' AND id_shop = '.(int)Context::getContext()->shop->id : '' );
' AND id_shop = '.(int)Context::getContext()->shop->id : '');

if ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql))
{
Expand Down
4 changes: 2 additions & 2 deletions classes/PrestaShopBackup.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function add()
$ignore_insert_table = array();

// Generate some random number, to make it extra hard to guess backup file names
$rand = dechex ( mt_rand(0, min(0xffffffff, mt_getrandmax() ) ) );
$rand = dechex (mt_rand(0, min(0xffffffff, mt_getrandmax())));
$date = time();
$backupfile = $this->getRealBackupPath().$date.'-'.$rand.'.sql';

Expand Down Expand Up @@ -303,7 +303,7 @@ public function add()
if ($found == 0)
{
$this->delete();
echo Tools::displayError('No valid tables were found to backup.' );
echo Tools::displayError('No valid tables were found to backup.');
return false;
}

Expand Down
Loading

0 comments on commit 74f2deb

Please sign in to comment.