Skip to content

Instantly share code, notes, and snippets.

@inilim
Last active February 5, 2026 05:54
Show Gist options
  • Select an option

  • Save inilim/fe1e960bea861ca07c6bf8e2a28d46a4 to your computer and use it in GitHub Desktop.

Select an option

Save inilim/fe1e960bea861ca07c6bf8e2a28d46a4 to your computer and use it in GitHub Desktop.
Enum for extension php "inotify"
<?php
enum InotifyEnum: int
{
case ACCESS = \IN_ACCESS;
case MODIFY = \IN_MODIFY;
case ATTRIB = \IN_ATTRIB;
case CLOSE_WRITE = \IN_CLOSE_WRITE;
case CLOSE_NOWRITE = \IN_CLOSE_NOWRITE;
case OPEN = \IN_OPEN;
case MOVED_TO = \IN_MOVED_TO;
case MOVED_FROM = \IN_MOVED_FROM;
case CREATE = \IN_CREATE;
case DELETE = \IN_DELETE;
case DELETE_SELF = \IN_DELETE_SELF;
case MOVE_SELF = \IN_MOVE_SELF;
case CLOSE = \IN_CLOSE;
case MOVE = \IN_MOVE;
case ALL_EVENTS = \IN_ALL_EVENTS;
case UNMOUNT = \IN_UNMOUNT;
case Q_OVERFLOW = \IN_Q_OVERFLOW;
case IGNORED = \IN_IGNORED;
case ISDIR = \IN_ISDIR;
case ONLYDIR = \IN_ONLYDIR;
case DONT_FOLLOW = \IN_DONT_FOLLOW;
case MASK_ADD = \IN_MASK_ADD;
case ONESHOT = \IN_ONESHOT;
function desc(): string
{
return match ($this) {
self::ACCESS => 'File was accessed (read)',
self::MODIFY => 'File was modified',
self::ATTRIB => 'Metadata changed (e.g. permissions, mtime, etc.)',
self::CLOSE_WRITE => 'File opened for writing was closed',
self::CLOSE_NOWRITE => 'File not opened for writing was closed',
self::OPEN => 'File was opened',
self::MOVED_TO => 'File moved into watched directory',
self::MOVED_FROM => 'File moved out of watched directory',
self::CREATE => 'File or directory created in watched directory',
self::DELETE => 'File or directory deleted in watched directory',
self::DELETE_SELF => 'Watched file or directory was deleted',
self::MOVE_SELF => 'Watch file or directory was moved',
self::CLOSE => 'Equals to IN_CLOSE_WRITE | IN_CLOSE_NOWRITE',
self::MOVE => 'Equals to IN_MOVED_FROM | IN_MOVED_TO',
self::ALL_EVENTS => 'Bitmask of all the above constants',
self::UNMOUNT => 'File system containing watched object was unmounted',
self::Q_OVERFLOW => 'Event queue overflowed (wd is -1 for this event)',
self::IGNORED => 'Watch was removed (explicitly by inotify_rm_watch() or because file was removed or filesystem unmounted',
self::ISDIR => 'Subject of this event is a directory',
self::ONLYDIR => 'Only watch pathname if it is a directory (Since Linux 2.6.15)',
self::DONT_FOLLOW => 'Do not dereference pathname if it is a symlink (Since Linux 2.6.15)',
self::MASK_ADD => 'Add events to watch mask for this pathname if it already exists (instead of replacing mask).',
self::ONESHOT => 'Monitor pathname for one event, then remove from watch list.',
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment