Extra declare strict types appears after every semicolon
See original GitHub issueIf declare_strict_types
setting is enabled and updating after every semi-colon is enabled, then typing a new line of code and entering a semi-colon will cause a line preceding the current line to appear so that you end up with this:
// some code
<?php declare(strict_types = 1);
$foo = 'bar';
// more code
The only way to fix this is to disable the extension, disable declare_strict_types
or disable php-cs-fixer.autoFixBySemicolon
in the VSCode settings.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Enabling 'strict_types' globally in PHP 7 - Stack Overflow
You can enable strict_types globally by using sed , awk or another tool of your choice to replace all <?php with <?php declare(strict_types=1); ......
Read more >semi - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Strict mode - JavaScript - MDN Web Docs
JavaScript's strict mode is a way to opt in to a restricted variant of JavaScript, thereby implicitly opting-out of "sloppy mode".
Read more >Understanding Automatic Semicolon Insertion in JavaScript
A Busy Person's Guide to Understanding Automatic Semicolon Insertion in JavaScript.
Read more >PSR-12: Extended Coding Style - PHP-FIG
There MUST be a space between type declaration and property name. A property declaration looks like the following: <?php namespace Vendor\Package; class ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
php-cs-fixer.autoFixBySemicolon
doesn’t work with paste, pastingdeclare(strict_types = 1);
with a new line every time. simply typing does not cause this problem.To check - paste something ending with a semicolon on non-empty line.
Pasting
;
at the start of the line, inserts<?php declare(strict_types=1);
with a new lineit’s ok!