use of com.jetbrains.php.config.PhpLanguageLevel in project phpinspectionsea by kalessil.
the class CascadeStringReplacementInspectorTest method testIfFindsPhp74Patterns.
public void testIfFindsPhp74Patterns() {
final PhpLanguageLevel level = PhpLanguageLevel.parse("7.4");
if (level != null && level.getVersionString().equals("7.4")) {
PhpProjectConfigurationFacade.getInstance(myFixture.getProject()).setLanguageLevel(level);
final CascadeStringReplacementInspector inspector = new CascadeStringReplacementInspector();
inspector.USE_SHORT_ARRAYS_SYNTAX = true;
myFixture.enableInspections(inspector);
myFixture.configureByFile("testData/fixtures/api/strings/cascade-str-replace.74.php");
myFixture.testHighlighting(true, false, true);
myFixture.getAllQuickFixes().forEach(fix -> myFixture.launchAction(fix));
myFixture.setTestDataPath(".");
myFixture.checkResultByFile("testData/fixtures/api/strings/cascade-str-replace.74.fixed.php");
}
}
use of com.jetbrains.php.config.PhpLanguageLevel 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);
}
}
}
use of com.jetbrains.php.config.PhpLanguageLevel 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);
}
}
}
use of com.jetbrains.php.config.PhpLanguageLevel in project phpinspectionsea by kalessil.
the class IsCountableCanBeUsedInspectorTest method testIfFindsAllPatterns.
public void testIfFindsAllPatterns() {
final PhpLanguageLevel level = PhpLanguageLevel.parse("7.4");
if (level != null && level.getVersionString().equals("7.4")) {
PhpProjectConfigurationFacade.getInstance(myFixture.getProject()).setLanguageLevel(level);
myFixture.enableInspections(new IsCountableCanBeUsedInspector());
myFixture.configureByFile("testData/fixtures/api/is-countable.php");
myFixture.testHighlighting(true, false, true);
}
}
use of com.jetbrains.php.config.PhpLanguageLevel in project phpinspectionsea by kalessil.
the class ArrayUniqueCanBeUsedInspectorTest method testIfFindsAllPatterns.
public void testIfFindsAllPatterns() {
final PhpLanguageLevel level = PhpLanguageLevel.parse("7.2");
if (level != null && level.getVersionString().equals("7.2")) {
PhpProjectConfigurationFacade.getInstance(myFixture.getProject()).setLanguageLevel(level);
myFixture.enableInspections(new ArrayUniqueCanBeUsedInspector());
myFixture.configureByFile("testData/fixtures/api/array-unique.php");
myFixture.testHighlighting(true, false, true);
myFixture.getAllQuickFixes().forEach(fix -> myFixture.launchAction(fix));
myFixture.setTestDataPath(".");
myFixture.checkResultByFile("testData/fixtures/api/array-unique.fixed.php");
}
}
Aggregations