use of com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.StaticClosureCanBeUsedInspector in project phpinspectionsea by kalessil.
the class StaticClosureCanBeUsedInspectorTest method testIfFindsAllPatterns.
public void testIfFindsAllPatterns() {
myFixture.enableInspections(new StaticClosureCanBeUsedInspector());
myFixture.configureByFile("testData/fixtures/codeStyle/static-closure-use.php");
myFixture.testHighlighting(true, false, true);
myFixture.getAllQuickFixes().forEach(fix -> myFixture.launchAction(fix));
myFixture.setTestDataPath(".");
myFixture.checkResultByFile("testData/fixtures/codeStyle/static-closure-use.fixed.php");
}
use of com.kalessil.phpStorm.phpInspectionsEA.inspectors.codeStyle.StaticClosureCanBeUsedInspector in project phpinspectionsea by kalessil.
the class StaticClosureCanBeUsedInspectorTest method testIfFindsArrowFunctionPatterns.
public void testIfFindsArrowFunctionPatterns() {
final PhpLanguageLevel level = PhpLanguageLevel.parse("7.4");
if (level != null && level.getVersionString().equals("7.4")) {
/* looks like 7.4 feature were introduced in multiple batches */
final boolean hasArrowFunctions = Arrays.stream(PhpLanguageFeature.class.getEnumConstants()).anyMatch(f -> f.toString().contains("Arrow function"));
if (hasArrowFunctions) {
PhpProjectConfigurationFacade.getInstance(myFixture.getProject()).setLanguageLevel(level);
final StaticClosureCanBeUsedInspector inspection = new StaticClosureCanBeUsedInspector();
inspection.SUGGEST_FOR_SHORT_FUNCTIONS = true;
myFixture.enableInspections(inspection);
myFixture.configureByFile("testData/fixtures/codeStyle/static-closure-use.php74.php");
myFixture.testHighlighting(true, false, true);
}
}
}
Aggregations