Search in sources :

Example 1 with UnnecessaryCastingInspector

use of com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.UnnecessaryCastingInspector in project phpinspectionsea by kalessil.

the class UnnecessaryCastingInspectorTest method testIfFindsAllPatternsPhp8.

public void testIfFindsAllPatternsPhp8() {
    final PhpLanguageLevel level = PhpLanguageLevel.parse("8.0");
    if (level != null && level.getVersionString().equals("8.0")) {
        // PS 2020.2 introduced very limited PHP 8 support, hence we are checking the feature availability as well
        final boolean run = Arrays.stream(PhpLanguageFeature.class.getEnumConstants()).anyMatch(v -> v.toString().equals("NULLSAFE_DEREFERENCING"));
        if (run) {
            PhpProjectConfigurationFacade.getInstance(myFixture.getProject()).setLanguageLevel(level);
            myFixture.enableInspections(new UnnecessaryCastingInspector());
            myFixture.configureByFile("testData/fixtures/types/unnecessary-casting.php8.php");
            myFixture.testHighlighting(true, false, true);
        }
    }
}
Also used : UnnecessaryCastingInspector(com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.UnnecessaryCastingInspector) PhpLanguageLevel(com.jetbrains.php.config.PhpLanguageLevel)

Example 2 with UnnecessaryCastingInspector

use of com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.UnnecessaryCastingInspector in project phpinspectionsea by kalessil.

the class UnnecessaryCastingInspectorTest method testIfFindsAllPatterns.

public void testIfFindsAllPatterns() {
    myFixture.enableInspections(new UnnecessaryCastingInspector());
    myFixture.configureByFile("testData/fixtures/types/unnecessary-casting.php");
    myFixture.testHighlighting(true, false, true);
    myFixture.getAllQuickFixes().forEach(fix -> myFixture.launchAction(fix));
    myFixture.setTestDataPath(".");
    myFixture.checkResultByFile("testData/fixtures/types/unnecessary-casting.fixed.php");
}
Also used : UnnecessaryCastingInspector(com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.UnnecessaryCastingInspector)

Aggregations

UnnecessaryCastingInspector (com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.UnnecessaryCastingInspector)2 PhpLanguageLevel (com.jetbrains.php.config.PhpLanguageLevel)1