Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix linebreak on Windows #39

Merged

Conversation

UFOMelkor
Copy link
Member

Hi,

I think there is an error when using PHP_EOL. By using \n as linebreak on windows there are 0 lines found. With count(file($filename)) the problem does not appear. I'm not sure how to make a test case for this because it depends on the environment …

@Halleck45
Copy link
Collaborator

Be careful, you broke the build.

What is the auto_detect_line_endings value of your php.ini ?

I think you're right, but I prefer a better solution. For example:

// this is a not tested example
if(ini_get('auto_detect_line_endings')) {
    $loc = substr_count($content, PHP_EOL)
} else {
    $loc = sizeof(preg_split('/\r\n|\r|\n/', $content));
}

// or at least:

$loc = sizeof(preg_split('/\r\n|\r|\n/', $content));

There is a dicussion on this topic here

@UFOMelkor
Copy link
Member Author

$loc = sizeof(preg_split('/\r\n|\r|\n/', $content)); also breaks the build but it might be quite useful because we need to change line 63 too.

Just for my information: How do you get the test data? tests/resources/f1.php contains 34 lines, you're testing against 33 lines. Not counting the <?php?
What about CLOC? I count 16 CLOC, you're testing against 14, counting tests/resources/f1.php#L13-15 just as single line. I'm not really deep insight metrics so you might help me a bit :-)

@UFOMelkor UFOMelkor force-pushed the hotfix/unix-linebreak-in-windows branch from d81cd1c to 674f3e8 Compare August 27, 2014 16:44
@UFOMelkor
Copy link
Member Author

@Halleck45 Seems to work now :-)

@Halleck45
Copy link
Collaborator

Ok. Thank's for your work !

Halleck45 pushed a commit that referenced this pull request Aug 29, 2014
@Halleck45 Halleck45 merged commit b5db9f6 into phpmetrics:master Aug 29, 2014
@UFOMelkor UFOMelkor deleted the hotfix/unix-linebreak-in-windows branch August 29, 2014 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants