GithubHelp home page GithubHelp logo

Location of .php_cs about php-cs-fixer-ga HOT 9 CLOSED

oskarstark avatar oskarstark commented on July 22, 2024 1
Location of .php_cs

from php-cs-fixer-ga.

Comments (9)

roy-bongers avatar roy-bongers commented on July 22, 2024 1

I'm having the same problem. Running php-cs-fixer locally works as a charm (php 7.4) but in this container it fails with the preg_match error. You can reproduce this by cloning this repository: https://github.com/roy-bongers/certbot-transip-dns-01-validator and then running docker run --rm -it -w=/app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest

The problem disappears when I comment out ->name(['auth-hook', 'cleanup-hook', '*.php'])

This is my config:

<?php

$finder = Symfony\Component\Finder\Finder::create()
    ->in(__DIR__)
    ->exclude(['config', 'docs', 'logs', 'vendor'])
    ->name(['auth-hook', 'cleanup-hook', '*.php'])
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

return PhpCsFixer\Config::create()
    ->setRules(
        [
            '@Symfony'                          => true,
            'array_syntax'                      => ['syntax' => 'short'],
            'no_unused_imports'                 => true,
            'trailing_comma_in_multiline_array' => true,
            'increment_style'                   => ['style' => 'post'],
            'concat_space'                      => ['spacing' => 'one'],
            'single_line_throw'                 => false,
        ]
    )->setFinder($finder);

Edit: I've fixed it by not using an array syntax for ->name() but calling ->name multiple times. I don't understand why but it fixes my problem. Array's should be supported though: https://symfony.com/doc/current/components/finder.html

Solution:

$finder = Finder::create()
    ->in(__DIR__)
    ->exclude(['config', 'docs', 'logs', 'vendor'])
    ->name('auth-hook')
    ->name('cleanup-hook')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on July 22, 2024

Hi, please have a look at the second example in the README file. If this fixes your issue please don’t forget to come back an close this issue. Thanks.

from php-cs-fixer-ga.

rognales avatar rognales commented on July 22, 2024

I have update the workflow to refer my config, as shown below:-

PHP CS Fixer 2.16.3 Yellow Bird by Fabien Potencier and Dariusz Ruminski (83baf82)
Loaded config default from ".php_cs".

But the error message remains:-

In MultiplePcreFilterIterator.php line 86:
                                                              
  preg_match() expects parameter 2 to be string, array given  

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on July 22, 2024

Can you please post your config of PHP-CS-Fixer ?

from php-cs-fixer-ga.

rognales avatar rognales commented on July 22, 2024

Here's mine.

<?php

use PhpCsFixer\Finder;
use PhpCsFixer\Config;

// Directories to exclude when fixing files.
$exclude = [
    'bootstrap/cache',
    'vendor',
    'storage',
    'node_modules',
    'nbproject',
];

// Filename patterns to exclude when fixing files.
$notName = [
    '*.md',
    '*.yml',
    '*.xml',
    '_ide_helper.php',
    '_ide_helper_models.php',
    '.phpstorm.meta.php'
];

// Default rules set to use when fixing files.
// See : https://gistlog.co/sixlive/2862a2185c76988838acaa45687a575c
$rules = [
    '@PSR2' => true,
    'array_indentation' => true,
    'array_syntax' => [
        'syntax' => 'short',
    ],
    'no_blank_lines_after_phpdoc' => true,
    'no_extra_blank_lines' => [
        'tokens' => ['curly_brace_block', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'throw', 'use'],
    ],
    'no_multiline_whitespace_before_semicolons' => true,
    'no_short_echo_tag' => true,
    'no_unused_imports' => true,
    'no_useless_else' => true,
    'not_operator_with_successor_space' => true,
    'ordered_imports' => [
        'sortAlgorithm' => 'length',
    ],
    'phpdoc_add_missing_param_annotation' => true,
    'phpdoc_indent' => true,
    'phpdoc_no_package' => true,
    'phpdoc_order' => true,
    'phpdoc_separation' => true,
    'phpdoc_single_line_var_spacing' => true,
    'phpdoc_to_comment' => true,
    'phpdoc_trim' => true,
    'phpdoc_var_without_name' => true,
    'single_quote' => true,
    'ternary_operator_spaces' => true,
    'trailing_comma_in_multiline_array' => true,
    'trim_array_spaces' => true,
];

// Instantiate finder.
$finder = Finder::create()
    ->in(getcwd())
    ->exclude($exclude)
    ->name('*.php')
    ->notName($notName)
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

// Instantiate & return config.
return Config::create()
    ->setFinder($finder)
    ->setRules($rules);

from php-cs-fixer-ga.

emha avatar emha commented on July 22, 2024

@OskarStark @rognales I have the same problem and the same configuration. Any ideas/updates on this?

from php-cs-fixer-ga.

emha avatar emha commented on July 22, 2024

The problem seems to be the notName() function.

from php-cs-fixer-ga.

OskarStark avatar OskarStark commented on July 22, 2024

Hi, thanks for coming back, I am really not sure if this should be supported to PHP-Cs-Fixer team πŸ€”

@localheinz, do you have any clue?

from php-cs-fixer-ga.

localheinz avatar localheinz commented on July 22, 2024

@OskarStark

No idea at the moment!

from php-cs-fixer-ga.

Related Issues (20)

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.