-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
#1727: Introduce internal class wrapping SplFileInfo #29461
Changes from 1 commit
5a500f3
bc24c44
9f02257
0b6ba91
89e7f22
beae26b
3752c1e
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 |
---|---|---|
@@ -0,0 +1,296 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\MediaGallerySynchronization\Model\Filesystem; | ||
|
||
/** | ||
* Class FileInfo | ||
*/ | ||
class FileInfo extends \SplFileInfo | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $path; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $filename; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $extension; | ||
|
||
/** | ||
* @var $basename | ||
*/ | ||
private $basename; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $pathname; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $perms; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $inode; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $size; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $owner; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $group; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $aTime; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $mTime; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
private $cTime; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $type; | ||
|
||
/** | ||
* @var false|string | ||
*/ | ||
private $realPath; | ||
|
||
/** | ||
* @var \SplFileInfo | ||
*/ | ||
private $fileInfo; | ||
|
||
/** | ||
* @var \SplFileInfo | ||
*/ | ||
private $pathInfo; | ||
|
||
/** | ||
* FileInfo constructor. | ||
* @param string $file_name | ||
* @param string $path | ||
* @param string $filename | ||
* @param string $extension | ||
* @param string $basename | ||
* @param string $pathname | ||
* @param int $perms | ||
* @param int $inode | ||
* @param int $size | ||
* @param int $owner | ||
* @param int $group | ||
* @param int $aTime | ||
* @param int $mTime | ||
* @param int $cTime | ||
* @param string $type | ||
* @param false|string $realPath | ||
* @param \SplFileInfo $fileInfo | ||
* @param \SplFileInfo $pathInfo | ||
*/ | ||
public function __construct( | ||
string $file_name, | ||
string $path, | ||
string $filename, | ||
string $extension, | ||
string $basename, | ||
string $pathname, | ||
int $perms, | ||
int $inode, | ||
int $size, | ||
int $owner, | ||
int $group, | ||
int $aTime, | ||
int $mTime, | ||
int $cTime, | ||
string $type, | ||
$realPath, | ||
\SplFileInfo $fileInfo, | ||
\SplFileInfo $pathInfo | ||
) { | ||
parent::__construct($file_name); | ||
$this->path = $path; | ||
$this->filename = $filename; | ||
$this->extension = $extension; | ||
$this->basename = $basename; | ||
$this->pathname = $pathname; | ||
$this->perms = $perms; | ||
$this->inode = $inode; | ||
$this->size = $size; | ||
$this->owner = $owner; | ||
$this->group = $group; | ||
$this->aTime = $aTime; | ||
$this->mTime = $mTime; | ||
$this->cTime = $cTime; | ||
$this->type = $type; | ||
$this->realPath = $realPath; | ||
$this->fileInfo = $fileInfo; | ||
$this->pathInfo = $pathInfo; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPath(): string | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getFilename(): string | ||
{ | ||
return $this->filename; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getExtension(): string | ||
{ | ||
return $this->extension; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getBasename($suffix = null): string | ||
{ | ||
return $this->basename; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPathname(): string | ||
{ | ||
return $this->pathname; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPerms(): int | ||
{ | ||
return $this->perms; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getInode(): int | ||
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. I don't think |
||
{ | ||
return $this->inode; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getSize(): int | ||
{ | ||
return $this->size; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getOwner(): int | ||
{ | ||
return $this->owner; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getGroup(): int | ||
{ | ||
return $this->group; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getATime(): int | ||
{ | ||
return $this->aTime; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getMTime(): int | ||
{ | ||
return $this->mTime; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getCTime(): int | ||
{ | ||
return $this->cTime; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getRealPath() | ||
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. Strict type is missing |
||
{ | ||
return $this->realPath; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getFileInfo($class_name = null): \SplFileInfo | ||
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. Please remove the functions that are not currently needed (additional functions can be added to this class later if they will be required). Also please remove the |
||
{ | ||
return $this->fileInfo; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getPathInfo($class_name = null): \SplFileInfo | ||
{ | ||
return $this->pathInfo; | ||
} | ||
} |
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.
It would be better to use ccomposition instead of inheritance
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.
This class does not need to extend
\SplFileInfo
please remove the inheritance