Fork me on GitHub
a Sensio Labs Product

Folding Bike (v3.89.0) edition

Rule declare_strict_types

Force strict types declaration in all files.

Warning

Using this rule is risky

Forcing strict types will stop non strict code from working.

Configuration

preserve_existing_declaration

Whether existing strict_types=? should be preserved and not overridden.

Allowed types: bool

Default value: false

Examples

Example #1

Default configuration.

--- Original
+++ New
-<?php
+<?php declare(strict_types=1);
\ No newline at end of file

Example #2

With configuration: ['preserve_existing_declaration' => false].

--- Original
+++ New
 <?php
-declare(Strict_Types=0);
+declare(strict_types=1);

Example #3

With configuration: ['preserve_existing_declaration' => true].

--- Original
+++ New
 <?php
-declare(Strict_Types=0);
+declare(strict_types=0);

Rule sets

The rule is part of the following rule sets:

References

The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.