Linguist: Some PHP files detected as Hacklang

Created on 14 Aug 2018  路  12Comments  路  Source: github/linguist

Preliminary Steps

Please confirm you have...

Problem Description

screen shot 2018-08-14 at 13 59 52

URL of the affected repository:

https://github.com/theel0ja/IPLookup/blob/fc18200e8678a3cc9fc071ecd6be10c8b95a3a10/src/add-to-flagfox.php

Last modified on:


2018-08-04

Expected language:


PHP

Detected language:


Hack

Most helpful comment

I mean it detects PHP files that contain only HTML as Hack files

All 12 comments

Thanks for the report.

Hack files can also use the .php extension. Since Linguist considers each file independently and that file only contains HTML code, it's going to be difficult (impossible?) for Linguist to understand that it is not a Hack file. You can use an override to change that behavior though.

I mean it detects PHP files that contain only HTML as Hack files

Yep, .php files can be either PHP or Hack since both languages use that extension. Linguist usually relies on the content to distinguish between the two. Since the file contains only HTML code, it fails to do so properly.

hey
i have this problem
https://github.com/Arkanic/warriorcats

@Arkanic https://github.com/github/linguist/issues/4229#issuecomment-412847227 applies to your case too.

hey
i have this problem
https://github.com/Arkanic/warriorcats

cause you created a php file that doesn't contain php code, so you need to add some php code

Yep, .php files can be either PHP or Hack since both languages use that extension. Linguist usually relies on the content to distinguish between the two. Since the file contains only HTML code, it fails to do so properly.

If it can't really decide based on the content, the fallback language should still be the far more popular and original language for that file extension. This is PHP and not Hack. I find the current behaviour very confusing. Took me some time to finally find this issue with an explanation.

I don't mind, it makes me look like I'm using some super secret language while.
Also experiencing this on certain .php files

Thank you

Thanks for this explanation

Should not it be detected as HTML then? What Hack has to do with this?

helpful

Was this page helpful?
0 / 5 - 0 ratings

Related issues

oliviertassinari picture oliviertassinari  路  5Comments

lucasrodes picture lucasrodes  路  6Comments

RafaelPAndrade picture RafaelPAndrade  路  4Comments

siscia picture siscia  路  6Comments

oldmud0 picture oldmud0  路  6Comments