Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Insight] Verify if all php files contain declare(strict_types=1); #7

Closed
nunomaduro opened this issue Apr 3, 2019 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@nunomaduro
Copy link
Owner

To solve this issue, you should create a pull request adding the following insight: Verify if all php files contain declare(strict_types=1);.

This will be later an optional Insight.

@nunomaduro nunomaduro added the enhancement New feature or request label Apr 3, 2019
@seriquynh
Copy link
Contributor

You can add `declare(strict_types=1); " directive to all php files by using the friendsofphp/php-cs-fixer package.

This is the sample of .php_cs file

<?php

$finder = PhpCsFixer\Finder::create()
    ->files()
    ->name('*.php')
    ->exclude('tests/fixtures')
    ->in(__DIR__.'/src')
    ->in(__DIR__.'/tests')
;

return PhpCsFixer\Config::create()
    ->setUsingCache(true)
    ->setRiskyAllowed(true)
    ->setFinder($finder)
    ->setRules([
        'declare_strict_types' => true,
    ])
;

@nunomaduro
Copy link
Owner Author

I am not find of tools that touch on my code automatically. Specially because that directive changes the behaviour of the code itself. Ideally would be cool to find a phpcs sniff for this, and add it here:

ObjectOperatorIndentSniff::class,
.

@seriquynh
Copy link
Contributor

I don't really understand all stuff here. I am a little bit busy, too but I will spend time reading phpinsights source code soon and then try to think about a solution. I have created my own sniffs before. It may be helpful.

@nunomaduro
Copy link
Owner Author

It's done already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants