-
Notifications
You must be signed in to change notification settings - Fork 29
Fixed CND parsing under Windows OS #48
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
Changes from all commits
90ba062
113920a
6697102
6167cef
1c423fd
84d9fb2
d4925ae
9836c70
e2b9689
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,24 +4,35 @@ | |
|
||
/** | ||
* @author Daniel Barsotti <daniel.barsotti@liip.ch> | ||
* @author Nikola Petkanski <nikola@petkanski.com> | ||
*/ | ||
class FileReader extends BufferReader | ||
{ | ||
protected $fileName; | ||
/** | ||
* @var string | ||
*/ | ||
protected $filePath; | ||
|
||
public function __construct($fileName) | ||
/** | ||
* @param string $path | ||
* @throws \InvalidArgumentException | ||
*/ | ||
public function __construct($path) | ||
{ | ||
if (!file_exists($fileName)) { | ||
throw new \InvalidArgumentException(sprintf("Invalid file '%s'", $fileName)); | ||
if (!file_exists($path)) { | ||
throw new \InvalidArgumentException(sprintf("Invalid file '%s'", $path)); | ||
} | ||
|
||
$this->fileName = $fileName; | ||
$this->path = $path; | ||
|
||
parent::__construct(file_get_contents($fileName)); | ||
parent::__construct(file_get_contents($path)); | ||
} | ||
|
||
public function getFileName() | ||
/** | ||
* @return string | ||
*/ | ||
public function getPath() | ||
{ | ||
return $this->fileName; | ||
return $this->path; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getting the file location is not needed anywhere. i suggest we simply drop the getter method. $fileName was good enough for me, but if you have a strong opinion then lets just rename it to $path. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it's a path to the file and not it's name. $path sounds good. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Test\Foobar; | ||
|
||
class TestClass | ||
{ | ||
/** | ||
* Block comment | ||
*/ | ||
public function testMethod($testParam) | ||
{ | ||
// Line comment | ||
$string = 'This is a "Test // string"'; | ||
return "Test string"; | ||
} | ||
|
||
// String in "comment" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This is a test file... | ||
|
||
...containing dummy content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think we need a field and getter for the eol, rather use the PHP_EOL directly below. end-of-line is handled by php for us, i think that is good enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the issue is that PHP_EOL is different depending on which OS you are running the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah ok, you wanted the test to test both. then lets just have a member variable but not use a getter method each time.
and lets have the constructor accept an optional $eolMarker that defaults to PHP_EOL. it could be useful for somebody in edge cases.