Giter Site home page Giter Site logo

phpcf's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpcf's Issues

do {} while conversion problem

If you have a code like and use phpcbf
do
....
while( $condition == true );

it will be converted to

do {
....
} while( $condition == true ) {
}

Always provide column number in issues

The following code makes phpcf produce issues about wrong indent like

        Expected no indent, got indent of 2 spaces on line 4

It would be nice if column number is also provided like in other issue types:

        Expected one space after class/interface/trait name on line 3 column 8

For ease of using vim quickfix window

<?php

  class   Ololo {



  var
   $m   =
          NULL;

  FUNCTION
   do_something_marvelous
   (
       $arg1
    ,  $arg2
   )

  {

  }

  }

Compatibility with phpcs output format for phpstorm integration

In phpstorm there is ability to use phpcs (PHP CodeSniffer) to check php code style and highlight statements that does not meet code style rules. Phpstorm has full integration with phpcs (Settings > Language & Frameworks > PHP > Code Sniffer). Can you please make compatible output format of phpcf with phpcs tool to make it possible to use phpcf tool in phpstorm instead of phpcs.

Details:

phpcf-php7 make error

Во время сборки получаю ошибку /Users/nikita/Desktop/phpcf-php7/phpcf-src/ext/phpcf.c:11:10: fatal error: 'ext/standard/php_smart_str.h' file not found

ОС: os x el capitan 10.11.15
PHP: 7.07

Support for __halt_compiler() PHP function

Было бы здорово чтобы оно обрабатывалось также как в PHP - можно было после __halt_compiler(); писать что-то, к чему бы не применялось форматирование.

?? operator leads to Internal formatter error

PHP7 null coalescing operator (??) - stuck in "CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN" state:

cat ternary.php
<?php

$a = $b ?? $c;
$a = 0;

?>

phpcf check -d ternary.php
         1                         T_OPEN_TAG     <?php                              CTX_PHP
         3                       T_WHITESPACE     \n\n                               CTX_PHP
         3                         T_VARIABLE     $a                                 CTX_PHP
         3                       T_WHITESPACE                                        CTX_PHP
         3                                  =     =                                  CTX_PHP
         3                       T_WHITESPACE                                        CTX_PHP
         3                         T_VARIABLE     $b                                 CTX_PHP
         3                       T_WHITESPACE                                        CTX_PHP
         3                                  ?     ?                                  CTX_PHP / CTX_TERNARY_BEGIN
         3                                  ?     ?                                  CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         3                       T_WHITESPACE                                        CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         3                         T_VARIABLE     $c                                 CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         3                                  ;     ;                                  CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                       T_WHITESPACE     \n                                 CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                         T_VARIABLE     $a                                 CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                       T_WHITESPACE                                        CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                                  =     =                                  CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                       T_WHITESPACE                                        CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                          T_LNUMBER     0                                  CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         4                                  ;     ;                                  CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
         6                       T_WHITESPACE     \n\n                               CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN
ternary.php:Internal formatter error: final state must be CTX_PHP or CTX_DEFAULT, got 'CTX_PHP / CTX_TERNARY_BEGIN / CTX_TERNARY_BEGIN'

Crashed on nullable return value

<?php
class A
{
    public function find(): ?array
    {

    }
}

Internal formatter error: final state must be CTX_PHP or CTX_DEFAULT, got 'CTX_PHP / CTX_CLASS / CTX_CLASS_METHOD_D / CTX_TERNARY_BEGIN'

^M as eol

Tried to use your tool, seem that it works but and when I do a git diff I see a lot of ^M

i++) {^M

  • echo "<option value='$i'";^M

I used the tool like this
find . -name "*.php" -exec phpcf apply {} \;

Formatting of mixed PHP-HTML content

Formatting of example like

<?php
require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php");
$APPLICATION->SetPageProperty(
    "title",
    "TItile"
);
$APPLICATION->SetPageProperty("NOT_SHOW_NAV_CHAIN", "Y");
$APPLICATION->SetTitle("Index");
?>
<div class="row">
    <div class="col-xs-6 col-sm-4 index_block">
        <div class="title_index_block"><span>menu</span></div>
        <?php
$APPLICATION->IncludeFile(
    $APPLICATION->GetCurDir() . "/include/include.php",
    Array(),
    Array(
        "MODE"      => "html",
        "NAME"      => "Content",
    )
);
?>
    </div>

causes internal formatter error.

How to select rules?

It is not clear how I can select rules or add own rules. I am not sure if I understand the source.
What exactly is the config file? How do I select which rules to apply? How to define new rules?

Example: how to replace all space indentations with tabs and reflow the code without unneccessary linebreaks?

Thanks!

Memmory limit

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/impl/Fsm.php on line 142
                                                                                        Call Stack:                                                                                 0.0004     397920   1. {main}() /data/data/com.termux/files/home/.local/bin/phpcf:0
    0.0274     422712   2. include('phar:///data/data/com.termux/files/home/.local/bin/phpcf/phpcf.php') /data/data/com.termux/files/home/.local/bin/phpcf:2                        0.0656     587624   3. Phpcf\Cli\Handler->handle(???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/phpcf.php:10                                                     0.1738    1397672   4. Phpcf\Cli\ActionApply->handle(???, ???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/cli/Handler.php:110
    0.1738    1397672   5. Phpcf\Cli\ActionApply->handleInternal(???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/cli/AbstractAction.php:25                        0.1739    1398048   6. Phpcf\Formatter->formatFile(???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/cli/ActionApply.php:19
    0.1769    2040672   7. Phpcf\Formatter->format(???, ???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/Formatter.php:111
    0.1774    2040832   8. Phpcf\Impl\Formatter->format(???, ???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/Formatter.php:253
   22.1273   88289056   9. Phpcf\Impl\Formatter->process() phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/impl/Formatter.php:240
   33.3083  131321976  10. Phpcf\Impl\Formatter->nextParsedToken() phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/impl/Formatter.php:1934
   33.3083  131321976  11. Phpcf\Impl\Formatter->setupContext() phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/impl/Formatter.php:1844
   33.3083  131321976  12. Phpcf\Impl\Fsm->transit(???) phar:///data/data/com.termux/files/home/.local/bin/phpcf/src/impl/Formatter.php:1850

Annotations are formatted in a wrong way

Input source code:

<?php
class Foo extends Bar
{
/**
* Execution callback
* @param string $world
* @return string
*/
public function hello($world)
{
return $world;
}
}

Applying formatter:

./phpcf apply ~/Projects/Foo.php

Result:

<?php
class Foo extends Bar
{
    /**
* Execution callback
* @param string $world
* @return string
*/
    public function hello($world)
    {
        return $world;
    }
}

Expected result:

<?php
class Foo extends Bar
{
    /**
     * Execution callback
     * @param string $world
     * @return string
     */
    public function hello($world)
    {
        return $world;
    }
}

false positive

phpcf complains, to use preg_split() instead of deprecated split() on code that looks like:
$desert['split'] = $banana->split || false;
You likely need to add code that checks for an opening ( parenthesis, to ensure a function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.