8000 Improved FileResource and DirectoryResource by javiereguiluz · Pull Request #17598 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Improved FileResource and DirectoryResource #17598

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed the errors pointed by reviewers
  • Loading branch information
javiereguiluz committed Feb 3, 2016
commit 294522dbb19bb62cae452b68d69783d89b9353f7
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($resource, $pattern = null)
$this->resource = realpath($resource);
$this->pattern = $pattern;

if (!is_dir($this->resource)) {
if (false === $this->resource || !is_dir($this->resource)) {
throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $resource));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Config/Resource/FileResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct($resource)
{
$this->resource = realpath($resource);

if (!file_exists($this->resource)) {
if (false === $this->resource) {
throw new \InvalidArgumentException(sprintf('The "%s" file does not exist.', $resource));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usually you write it the other way round: The file "%s" does not exist. (same for directory)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. Changed. Thanks.

}
}
Expand All @@ -46,11 +46,11 @@ public function __construct($resource)
*/
public function __toString()
{
return (string) $this->resource;
return $this->resource;
}

/**
* @return string|false The canonicalized, absolute path to the resource or false if the resource does not exist.
* @return string The canonicalized, absolute path to the resource.
*/
public function getResource()
{
Expand All @@ -62,7 +62,7 @@ public function getResource()
*/
public function isFresh($timestamp)
{
if (false === $this->resource || !file_exists($this->resource)) {
if (!file_exists($this->resource)) {
return false;
}

Expand Down
0