-
Notifications
You must be signed in to change notification settings - Fork 102
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
Refactor and rename #221
Draft
mikey179
wants to merge
18
commits into
master
Choose a base branch
from
refactor/rename_and_restructure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Refactor and rename #221
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
06139c8
refactor and rename
mikey179 64e1b8d
fix some phpstan issues
mikey179 ab527c1
return to previous notation
mikey179 688c395
return to previous notation
mikey179 c4535b2
remove leftover from debugging
mikey179 fe50757
remove trailing comma
mikey179 6a348e2
add comment
mikey179 4d72430
uncomment, was for testing purposes only
mikey179 97d1497
adjust to renamed classes
mikey179 bf2acc4
automatic fix of coding style violations with phpcbf
mikey179 bed6a3a
fix case
mikey179 d6804c6
add missing type hint
mikey179 c92dc22
get rid of Abstract in class name, use a better name
mikey179 53fbb70
introduce common interface for OpenedFile and ErroneousOpenedFile so …
mikey179 c9eac41
use fixed phpcs action
mikey179 9ba554b
add proper description for parameter
mikey179 a27c041
use renamed classes where they exist
mikey179 8a9f28f
remove org namespace and migration layer
mikey179 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of vfsStream. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @package bovigo\vfs | ||
*/ | ||
|
||
namespace bovigo\vfs; | ||
|
||
/** | ||
* Represents a basic entry in the file system. | ||
* | ||
* Due to simplicity reasons it extends Inode, even though that is not a correct | ||
* implementation if when looked from a domain point of view. | ||
* | ||
* @internal | ||
*/ | ||
abstract class BasicFile extends Inode | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
/** | ||
* path to to this file | ||
* | ||
* @var string|null | ||
*/ | ||
private $parentPath; | ||
|
||
public function __construct(string $name, int $permissions) | ||
{ | ||
$this->check($name); | ||
$this->name = $name; | ||
parent::__construct($permissions); | ||
} | ||
|
||
private function check(string $name) | ||
{ | ||
if (strstr($name, '/') !== false) { | ||
throw new vfsStreamException('Name can not contain /.'); | ||
} | ||
} | ||
|
||
/** | ||
* renames the file | ||
*/ | ||
public function rename(string $newName): void | ||
{ | ||
$this->check($newName); | ||
$this->name = $newName; | ||
} | ||
|
||
/** | ||
* @deprecated use name() instead | ||
*/ | ||
public function getName(): string | ||
{ | ||
return $this->name(); | ||
} | ||
|
||
/** | ||
* @api | ||
*/ | ||
public function name(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* checks whether the file can be applied to given name | ||
*/ | ||
public function appliesTo(string $name): bool | ||
{ | ||
return $this->name === $name; | ||
} | ||
|
||
/** | ||
* @deprecated use type() instead | ||
*/ | ||
public function getType(): int | ||
{ | ||
return $this->type(); | ||
} | ||
|
||
/** | ||
* returns the type of the file | ||
*/ | ||
abstract public function type(): int; | ||
|
||
/** | ||
* returns size of content | ||
*/ | ||
abstract public function size(): int; | ||
|
||
/** | ||
* sets parent path | ||
* | ||
* @internal only to be set by parent | ||
* | ||
* @since 1.2.0 | ||
*/ | ||
public function setParentPath(string $parentPath): void | ||
{ | ||
$this->parentPath = $parentPath; | ||
} | ||
|
||
/** | ||
* removes parent path | ||
* | ||
* @internal only to be set by parent | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
public function removeParentPath(): void | ||
{ | ||
$this->parentPath = null; | ||
} | ||
|
||
/** | ||
* returns path to this content | ||
* | ||
* @api | ||
* @since 1.2.0 | ||
*/ | ||
public function path(): string | ||
{ | ||
if ($this->parentPath === null) { | ||
return $this->name; | ||
} | ||
|
||
return $this->parentPath . '/' . $this->name; | ||
} | ||
|
||
/** | ||
* returns complete vfsStream url for this content | ||
* | ||
* @api | ||
* @since 1.2.0 | ||
*/ | ||
public function url(): string | ||
{ | ||
return vfsStream::url($this->path()); | ||
} | ||
|
||
/** | ||
* returns status of file | ||
* | ||
* @return int[]|false | ||
*/ | ||
public function stat() | ||
{ | ||
$atime = $this->fileatime(); | ||
$ctime = $this->filectime(); | ||
$mtime = $this->filemtime(); | ||
$size = $this->size(); | ||
if ($atime === -1 || $ctime === -1 || $mtime === -1 || $size === -1) { | ||
return false; | ||
} | ||
|
||
$fileStat = [ | ||
'dev' => 0, | ||
'ino' => spl_object_id($this), | ||
'mode' => $this->type() | $this->permissions(), | ||
'nlink' => 0, | ||
'uid' => $this->user(), | ||
'gid' => $this->group(), | ||
'rdev' => 0, | ||
'size' => $size, | ||
'atime' => $atime, | ||
'mtime' => $mtime, | ||
'ctime' => $ctime, | ||
'blksize' => -1, | ||
'blocks' => -1, | ||
]; | ||
|
||
return array_merge(array_values($fileStat), $fileStat); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Putting that here eliminates some code duplication in the streamwrapper class.