Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 030b066

Browse files
feat: add php project heuristics(bootstrap, illuminate) (#556)
1 parent ae67d81 commit 030b066

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

‎src/main/kotlin/app/extractors/Heuristics.kt‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ val Perl6Regex = Regex(
122122
val PhpRegex = Regex(
123123
"^<\\?(?:php)?"
124124
)
125+
val PhpIlluminateRegex = Regex(
126+
"(Auth|Bootstrap|Bus|Console|Events|Exceptions|Http|Providers" +
127+
"|Support|Testing|Validation)")
125128
val PicoLispRegex = Regex(
126129
"^\\((de|class|rel|code|data|must)\\s",
127130
RegexOption.MULTILINE
@@ -235,6 +238,11 @@ val k8sExp = { buf: String ->
235238
&& buf.contains("metadata")
236239
}
237240

241+
val bootstrapWebpackExp = { buf: String ->
242+
// Handling php projects with bootstrap Webpack.
243+
buf.contains("/******/ (function(modules) { // webpackBootstrap")
244+
}
245+
238246
/**
239247
* Heuristics to detect a programming language by file extension and content.
240248
* Inspired by GitHub Liguist heuristics (https://github.com/github/linguist).
@@ -638,8 +646,11 @@ val HeuristicsMap = mapOf<String, (String, String) -> ExtractorInterface?>(
638646
"jl" to { _, _ ->
639647
CommonExtractor(Lang.JULIA)
640648
},
641-
"js" to { _, _ ->
642-
JavascriptExtractor()
649+
"js" to { buf, _ ->
650+
if (bootstrapWebpackExp(buf)) {
651+
null
652+
}
653+
else JavascriptExtractor()
643654
},
644655
"jsx" to { _, _ ->
645656
JavascriptExtractor()
@@ -793,10 +804,13 @@ val HeuristicsMap = mapOf<String, (String, String) -> ExtractorInterface?>(
793804
"pde" to { _, _ ->
794805
CommonExtractor(Lang.PROCESSING)
795806
},
796-
"php" to { buf, _ ->
807+
"php" to { buf, path ->
797808
if (buf.contains("<?hh")) {
798809
CommonExtractor(Lang.HACK)
799-
} else {
810+
} else if (PhpIlluminateRegex.containsMatchIn(path)) {
811+
null
812+
}
813+
else {
800814
PhpExtractor()
801815
}
802816
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /