-
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
base: master
Are you sure you want to change the base?
Refactor and rename #221
Conversation
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 added some comments throughout the diff to highlight some things I think are worth to mention or to discuss.
*/ | ||
abstract class vfsStreamAbstractContent implements vfsStreamContent | ||
class Inode |
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.
Like in a real filesystem , the inode contains all metadata about the file, except the filename and some other things that are specific to the type of file.
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 really like this
@@ -141,7 +94,7 @@ class vfsStreamWrapper | |||
*/ | |||
public static function register(): void | |||
{ | |||
self::$root = null; | |||
self::$root = Root::empty(); |
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 introduced a specific Root class so that some null checks could be eliminated. I believe this could be a starting point should we ever want to tackle the topic of partitions.
*/ | ||
public function seek(int $offset, int $whence): bool; |
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.
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 took me a minute to get used to. It's neat that it avoids the extra seeks before each read/write in OpenedFile.
* | ||
* @internal | ||
*/ | ||
final class Mode |
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.
Just some stuff extracted from the StreamWrapper class to reduce its size.
* | ||
* @return int[]|false | ||
*/ | ||
public function stat() |
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.
@@ -237,9 +169,19 @@ public function chmod(int $permissions): vfsStreamContent | |||
} | |||
|
|||
/** | |||
* returns permissions | |||
* @deprecated use permissions() instead |
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.
Just a suggestion, like with all getX()
methods which return just the value of a property.
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.
Maybe it's just me, but I like the get/set prefixes because it makes it very obvious what the method does.
I might just be lazy and not like reading a method's description to find out what it's doing. An example:
$file->lastAttributeModified($filectime); // takes parameter = setter
$file->filectime(); // no parameter = getter
// but then...
$file->resourceId($resource); // takes parameter, but is a getter not a setter
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.
You are right, resourceId($resource)
is not a good method name for what it does. Should be something like resourceIdOf($resource)
or resourceIdFor($resource)
I think.
Co-Authored-By: Luke <bizurkur@users.noreply.github.com>
…the latter doesn't need to extend the former without using any of its functionality
In my last commit I updated the org layer to load the new classes. However, I'm a bit unsure how to continue:
I'd like to hear your thoughts on this. |
I was a little curious about this, too. The rename does seem like it makes the old org layer somewhat pointless if all the files don't match up anymore. If the goal is to maintain an easy transition, putting this into 3.0 does sound like a better idea. If we go that route, then we can update the org files that don't have a match anymore to include "this file will be removed in 3.0" to the deprecation message. Then for any development, we'll just have to create a 2.x and remember to branch off of that. Merging any 2.x changes into 3.x could be fun... |
Yes, that's one of the thoughts I had - we might create a maintenance problem for us. So in case we opt for two major releases (not necessarily at the same time) we should limit the support time span for 2.0 - I'd even go to say that it should receive bug fixes only. |
Over the weekend I thought a bit about this and came up with the following idea:
This has some advantages:
What do you think? Have I overlooked anything that might pose a problem? |
That sounds way better and should have far fewer complications 👍 |
Also update changelog.
What is the status of this pr? I would like to start working on php8 compatibility. But this large move of files makes me feel that I have to wait for this PR. I reviewed the changes, I think this one is good to go... |
Agreed. What else is left in this PR? I'd like to get a migration path from 1.7.0 to 2.0.0 so we can finally EOL the 1.x series. |
If I remember correctly, within the plan I outlined above this should now be at point 3. Unfortunately for this PR I got pulled into a large project mid March and are lacking any time to continue working on this. I'm not sure if this one could be merged as is or if there were some other changes that should be done, something in the back of my mind tells me I wanted to look at something but I can't remember what it was. Probably it's ok to check with #227 if something needs to be done here before it should be merged so the change is consistent in 1.x and master. |
As discussed in #213 I took the opportunity to rename some classes. Also, in #220 (review) I mentioned I believe there's opportunity to restructure code. This is my attempt at that. It probably has some rough edges and I'm not sure it's a good idea to merge this big one. On the other hand, this is a big opportunity, as we will have a new major version anyway, and I managed to reduce the amount of code while all features are kept. Please have a look and let me know what you think.