-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
197 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.1.1 (15.10.2023) | ||
|
||
* Error constants (`PosixErrors`) | ||
|
||
## 0.1.0 (14.10.2023) | ||
|
||
* The interface (`IPosix`) | ||
|
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,148 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace axy\posix; | ||
|
||
use ReflectionClass; | ||
|
||
final class PosixErrors | ||
{ | ||
public const EPERM = 1; | ||
public const ENOENT = 2; | ||
public const ESRCH = 3; | ||
public const EINTR = 4; | ||
public const EIO = 5; | ||
public const ENXIO = 6; | ||
public const E2BIG = 7; | ||
public const ENOEXEC = 8; | ||
public const EBADF = 9; | ||
public const ECHILD = 10; | ||
public const EAGAIN = 11; | ||
public const ENOMEM = 12; | ||
public const EACCES = 13; | ||
public const EFAULT = 14; | ||
public const ENOTBLK = 15; | ||
public const EBUSY = 16; | ||
public const EEXIST = 17; | ||
public const EXDEV = 18; | ||
public const ENODEV = 19; | ||
public const ENOTDIR = 20; | ||
public const EISDIR = 21; | ||
public const EINVAL = 22; | ||
public const ENFILE = 23; | ||
public const EMFILE = 24; | ||
public const ENOTTY = 25; | ||
public const ETXTBSY = 26; | ||
public const EFBIG = 27; | ||
public const ENOSPC = 28; | ||
public const ESPIPE = 29; | ||
public const EROFS = 30; | ||
public const EMLINK = 31; | ||
public const EPIPE = 32; | ||
public const EDOM = 33; | ||
public const ERANGE = 34; | ||
public const EDEADLK = 35; | ||
public const ENAMETOOLONG = 36; | ||
public const ENOLCK = 37; | ||
public const ENOSYS = 38; | ||
public const ENOTEMPTY = 39; | ||
public const ELOOP = 40; | ||
public const ENOMSG = 42; | ||
public const EIDRM = 43; | ||
public const ECHRNG = 44; | ||
public const EL2NSYNC = 45; | ||
public const EL3HLT = 46; | ||
public const EL3RST = 47; | ||
public const ELNRNG = 48; | ||
public const EUNATCH = 49; | ||
public const ENOCSI = 50; | ||
public const EL2HLT = 51; | ||
public const EBADE = 52; | ||
public const EBADR = 53; | ||
public const EXFULL = 54; | ||
public const ENOANO = 55; | ||
public const EBADRQC = 56; | ||
public const EBADSLT = 57; | ||
public const EBFONT = 59; | ||
public const ENOSTR = 60; | ||
public const ENODATA = 61; | ||
public const ETIME = 62; | ||
public const ENOSR = 63; | ||
public const ENONET = 64; | ||
public const ENOPKG = 65; | ||
public const EREMOTE = 66; | ||
public const ENOLINK = 67; | ||
public const EADV = 68; | ||
public const ESRMNT = 69; | ||
public const ECOMM = 70; | ||
public const EPROTO = 71; | ||
public const EMULTIHOP = 72; | ||
public const EDOTDOT = 73; | ||
public const EBADMSG = 74; | ||
public const EOVERFLOW = 75; | ||
public const ENOTUNIQ = 76; | ||
public const EBADFD = 77; | ||
public const EREMCHG = 78; | ||
public const ELIBACC = 79; | ||
public const ELIBBAD = 80; | ||
public const ELIBSCN = 81; | ||
public const ELIBMAX = 82; | ||
public const ELIBEXEC = 83; | ||
public const EILSEQ = 84; | ||
public const ERESTART = 85; | ||
public const ESTRPIPE = 86; | ||
public const EUSERS = 87; | ||
public const ENOTSOCK = 88; | ||
public const EDESTADDRREQ = 89; | ||
public const EMSGSIZE = 90; | ||
public const EPROTOTYPE = 91; | ||
public const ENOPROTOOPT = 92; | ||
public const EPROTONOSUPPORT = 93; | ||
public const ESOCKTNOSUPPORT = 94; | ||
public const EOPNOTSUPP = 95; | ||
public const EPFNOSUPPORT = 96; | ||
public const EAFNOSUPPORT = 97; | ||
public const EADDRINUSE = 98; | ||
public const EADDRNOTAVAIL = 99; | ||
public const ENETDOWN = 100; | ||
public const ENETUNREACH = 101; | ||
public const ENETRESET = 102; | ||
public const ECONNABORTED = 103; | ||
public const ECONNRESET = 104; | ||
public const ENOBUFS = 105; | ||
public const EISCONN = 106; | ||
public const ENOTCONN = 107; | ||
public const ESHUTDOWN = 108; | ||
public const ETOOMANYREFS = 109; | ||
public const ETIMEDOUT = 110; | ||
public const ECONNREFUSED = 111; | ||
public const EHOSTDOWN = 112; | ||
public const EHOSTUNREACH = 113; | ||
public const EALREADY = 114; | ||
public const EINPROGRESS = 115; | ||
public const ESTALE = 116; | ||
public const EUCLEAN = 117; | ||
public const ENOTNAM = 118; | ||
public const ENAVAIL = 119; | ||
public const EISNAM = 120; | ||
public const EREMOTEIO = 121; | ||
public const EDQUOT = 122; | ||
public const ENOMEDIUM = 123; | ||
public const EMEDIUMTYPE = 124; | ||
public const ECANCELED = 125; | ||
public const ENOKEY = 126; | ||
public const EKEYEXPIRED = 127; | ||
public const EKEYREVOKED = 128; | ||
public const EKEYREJECTED = 129; | ||
public const EOWNERDEAD = 130; | ||
public const ENOTRECOVERABLE = 131; | ||
public const ERFKILL = 132; | ||
public const EHWPOISON = 133; | ||
|
||
public static function getConstName(int $code): ?string | ||
{ | ||
$class = new ReflectionClass(self::class); | ||
return array_search($code, $class->getConstants(), true) ?: null; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace axy\posix\tests; | ||
|
||
use axy\posix\PosixErrors; | ||
|
||
class PosixErrorsTest extends BaseTestCase | ||
{ | ||
public function testGetConstName(): void | ||
{ | ||
$this->assertSame('EDESTADDRREQ', PosixErrors::getConstName(PosixErrors::EDESTADDRREQ)); | ||
$this->assertSame('EADV', PosixErrors::getConstName(PosixErrors::EADV)); | ||
$this->assertNull(PosixErrors::getConstName(-5)); | ||
$this->assertNull(PosixErrors::getConstName(500)); | ||
} | ||
} |
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