BaseMax / PHPAS

PHP Auto Style: A tool for format and beautify the style of PHP code with my style.
https://www.phpclasses.org/package/11216-PHP-Beautify-PHP-source-code-fixing-its-style.html
GNU General Public License v3.0
6 stars 3 forks source link

BUG: wrong function formatting #6

Open rozhnev opened 3 years ago

rozhnev commented 3 years ago

When I try to format next code:

function checkifhoused($productname, $supplier)
{
    $db = mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
    $sql = "SELECT * FROM " . TBL_PRODUCTS;
    $result = mysqli_query($db, $sql);
    while ($row = $result->fetch_assoc()) {
        if ($row['supplierid'] == $supplier and $row['name'] == $productname) {
            return true;
        }
    }
    return false;
}

the formater returns

functioncheckifhoused($productname, $supplier)
 {
    $db=mysqli_connect(DB_SERVER, DB_USER, DB_PASS, DB_NAME);
    $sql="SELECT * FROM ".TBL_PRODUCTS;
    $result=mysqli_query($db, $sql);
    while($row=$result->fetch_assoc()) {
        if($row['supplierid']==$supplierand$row['name']==$productname) {
            returntrue;
        }

    }

    returnfalse;
}
BaseMax commented 3 years ago

Hi,

Thanks for your report.

Which parts is wrong?

 {

or new line before while?

Oh... Also return need a space after it!

BaseMax commented 3 years ago

If you are interested in correcting this, please do so. I appreciate. @rozhnev :+1:

BaseMax commented 3 years ago

Hi. Is this issue still the case? Or has it been fixed? Thanks for updating the topic. @rozhnev

rozhnev commented 3 years ago

Yep, the issue still actual. it is complicated, but I have not time now to care it right now.

jasonc3107 commented 1 year ago

Hi, I tried this and I am getting iscorrectly formatted code returned.

I use this

`<? include("presets.php"); include("includes/functions.php"); $_SESSION['currentPage'] = "rules.php"; define('pageTitle', 'rules'); $site_title = "Rules";

docStart($mysqli, $site_title, $metaDescription); ?>

<?php echo($site_title . ' - ' . titleApender); ?> - <?php echo towns; ?>

` and get this return ` <?phpecho($site_title.' - '.titleApender); ?>-<?phpechotowns; ?>