diff --git a/.travis.yml b/.travis.yml index 912d3d6..92f4b5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ arch: - arm64 php: -- 7.4 - 8.0 - 8.0.23 @@ -24,4 +23,4 @@ script: - vendor/bin/phpunit --configuration phpunit.xml --testsuite General - vendor/bin/psalm --show-info=true - if [ "$TRAVIS_CPU_ARCH" = "amd64" ]; then vendor/bin/phpunit --configuration phpunit.xml --testsuite X86; fi -- if [ "$TRAVIS_CPU_ARCH" = "arm64" ]; then vendor/bin/phpunit --configuration phpunit.xml --testsuite ARM; fi +- if [ "$TRAVIS_CPU_ARCH" = "arm64" ]; then vendor/bin/phpunit --configuration phpunit.xml --testsuite ARM64; fi diff --git a/README.md b/README.md index f32c9ce..47488cb 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ echo System::isX86(); // bool ## System Requirements -Utopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible. +Utopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible. ## Supported Methods | | getCPUCores | getCPUUsage | getMemoryTotal | getMemoryFree | getDiskTotal | getDiskFree | getIOUsage | getNetworkUsage | diff --git a/composer.json b/composer.json index 13b46be..a91747d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "format": "./vendor/bin/pint" }, "require": { - "php": ">=7.4", + "php": ">=8.0.0", "laravel/pint": "1.2.*" }, "require-dev": { diff --git a/phpunit.xml b/phpunit.xml index 6e927d8..7afd0dc 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,8 +18,14 @@ tests/System/SystemTestPPC.php - - tests/System/SystemTestARM.php + + tests/System/SystemTestARM64.php + + + tests/System/SystemTestARMV7.php + + + tests/System/SystemTestARMV8.php \ No newline at end of file diff --git a/src/System/System.php b/src/System/System.php index 445aec3..3fef281 100644 --- a/src/System/System.php +++ b/src/System/System.php @@ -10,11 +10,19 @@ class System public const PPC = 'ppc'; - public const ARM = 'arm'; + public const ARM64 = 'arm64'; + + public const ARMV7 = 'armv7'; + + public const ARMV8 = 'armv8'; private const RegExX86 = '/(x86*|i386|i686)/'; - private const RegExARM = '/(aarch*|arm*)/'; + private const RegexARM64 = '/(aarch64)/'; + + private const RegexARMV7 = '/(armv7)/'; + + private const RegexARMV8 = '/(armv8)/'; private const RegExPPC = '/(ppc*)/'; @@ -96,8 +104,12 @@ public static function getArchEnum(): string case preg_match(self::RegExPPC, $arch): return System::PPC; break; - case preg_match(self::RegExARM, $arch): - return System::ARM; + case preg_match(self::RegexARM64, $arch): + return System::ARM64; + case preg_match(self::ARMV7, $arch): + return System::ARMV7; + case preg_match(self::ARMV8, $arch): + return System::ARMV8; break; default: @@ -117,13 +129,33 @@ public static function getHostname(): string } /** - * Checks if the system is running on an ARM architecture. + * Checks if the system is running on an ARM64 architecture. + * + * @return bool + */ + public static function isArm64(): bool + { + return (bool) preg_match(self::RegexARM64, self::getArch()); + } + + /** + * Checks if the system is running on an ARMV7 architecture. + * + * @return bool + */ + public static function isArmV7(): bool + { + return (bool) preg_match(self::RegexARMV7, self::getArch()); + } + + /** + * Checks if the system is running on an ARM64 architecture. * * @return bool */ - public static function isArm(): bool + public static function isArmV8(): bool { - return (bool) preg_match(self::RegExARM, self::getArch()); + return (bool) preg_match(self::RegexARMV8, self::getArch()); } /** @@ -164,8 +196,14 @@ public static function isArch(string $arch): bool case self::PPC: return self::isPPC(); break; - case self::ARM: - return self::isArm(); + case self::ARM64: + return self::isArm64(); + break; + case self::ARMV7: + return self::isArmV7(); + break; + case self::ARMV8: + return self::isArmV8(); break; default: diff --git a/tests/System/SystemTest.php b/tests/System/SystemTest.php index 15f0959..b6fdd08 100644 --- a/tests/System/SystemTest.php +++ b/tests/System/SystemTest.php @@ -33,10 +33,14 @@ public function testOs() $this->assertIsString(System::getArch()); $this->assertIsString(System::getArchEnum()); $this->assertIsString(System::getHostname()); - $this->assertIsBool(System::isArm()); + $this->assertIsBool(System::isArm64()); + $this->assertIsBool(System::isArmV7()); + $this->assertIsBool(System::isArmV8()); $this->assertIsBool(System::isPPC()); $this->assertIsBool(System::isX86()); - $this->assertIsBool(System::isArch(System::ARM)); + $this->assertIsBool(System::isArch(System::ARM64)); + $this->assertIsBool(System::isArch(System::ARMV7)); + $this->assertIsBool(System::isArch(System::ARMV8)); $this->assertIsBool(System::isArch(System::X86)); $this->assertIsBool(System::isArch(System::PPC)); $this->expectException('Exception'); diff --git a/tests/System/SystemTestARM.php b/tests/System/SystemTestARM64.php similarity index 61% rename from tests/System/SystemTestARM.php rename to tests/System/SystemTestARM64.php index be1b129..a3426cf 100644 --- a/tests/System/SystemTestARM.php +++ b/tests/System/SystemTestARM64.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase; use Utopia\System\System; -class SystemTestARM extends TestCase +class SystemTestARM64 extends TestCase { public function setUp(): void { @@ -30,14 +30,18 @@ public function tearDown(): void public function testOs() { - $this->assertTrue(System::isArm()); + $this->assertTrue(System::isArm64()); + $this->assertFalse(System::isArmV7()); + $this->assertFalse(System::isArmV8()); $this->assertFalse(System::isPPC()); $this->assertFalse(System::isX86()); - $this->assertTrue(System::isArch(System::ARM)); + $this->assertTrue(System::isArch(System::ARM64)); + $this->assertFalse(System::isArch(System::ARMV7)); + $this->assertFalse(System::isArch(System::ARMV8)); $this->assertFalse(System::isArch(System::PPC)); $this->assertFalse(System::isArch(System::X86)); - $this->assertEquals(System::ARM, System::getArchEnum()); + $this->assertEquals(System::ARM64, System::getArchEnum()); } } diff --git a/tests/System/SystemTestARMV7.php b/tests/System/SystemTestARMV7.php new file mode 100644 index 0000000..0a93c78 --- /dev/null +++ b/tests/System/SystemTestARMV7.php @@ -0,0 +1,47 @@ + + * + * @version 1.0 RC4 + * + * @license The MIT License (MIT) + */ + +namespace Utopia\Tests; + +use PHPUnit\Framework\TestCase; +use Utopia\System\System; + +class SystemTestARMV7 extends TestCase +{ + public function setUp(): void + { + } + + public function tearDown(): void + { + } + + public function testOs() + { + $this->assertFalse(System::isArm64()); + $this->assertTrue(System::isArmV7()); + $this->assertFalse(System::isArmV8()); + $this->assertFalse(System::isPPC()); + $this->assertFalse(System::isX86()); + + $this->assertFalse(System::isArch(System::ARM64)); + $this->assertTrue(System::isArch(System::ARMV7)); + $this->assertFalse(System::isArch(System::ARMV8)); + $this->assertFalse(System::isArch(System::PPC)); + $this->assertFalse(System::isArch(System::X86)); + + $this->assertEquals(System::ARMV7, System::getArchEnum()); + } +} diff --git a/tests/System/SystemTestARMV8.php b/tests/System/SystemTestARMV8.php new file mode 100644 index 0000000..2535f8a --- /dev/null +++ b/tests/System/SystemTestARMV8.php @@ -0,0 +1,47 @@ + + * + * @version 1.0 RC4 + * + * @license The MIT License (MIT) + */ + +namespace Utopia\Tests; + +use PHPUnit\Framework\TestCase; +use Utopia\System\System; + +class SystemTestARMV8 extends TestCase +{ + public function setUp(): void + { + } + + public function tearDown(): void + { + } + + public function testOs() + { + $this->assertFalse(System::isArm64()); + $this->assertFalse(System::isArmV7()); + $this->assertTrue(System::isArmV8()); + $this->assertFalse(System::isPPC()); + $this->assertFalse(System::isX86()); + + $this->assertFalse(System::isArch(System::ARM64)); + $this->assertFalse(System::isArch(System::ARMV7)); + $this->assertTrue(System::isArch(System::ARMV8)); + $this->assertFalse(System::isArch(System::PPC)); + $this->assertFalse(System::isArch(System::X86)); + + $this->assertEquals(System::ARMV8, System::getArchEnum()); + } +} diff --git a/tests/System/SystemTestPPC.php b/tests/System/SystemTestPPC.php index 93997ed..4d2bb43 100644 --- a/tests/System/SystemTestPPC.php +++ b/tests/System/SystemTestPPC.php @@ -30,11 +30,15 @@ public function tearDown(): void public function testOs() { - $this->assertFalse(System::isArm()); + $this->assertFalse(System::isArm64()); + $this->assertFalse(System::isArmV7()); + $this->assertFalse(System::isArmV8()); $this->assertTrue(System::isPPC()); $this->assertFalse(System::isX86()); - $this->assertFalse(System::isArch(System::ARM)); + $this->assertFalse(System::isArch(System::ARM64)); + $this->assertFalse(System::isArch(System::ARMV7)); + $this->assertFalse(System::isArch(System::ARMV8)); $this->assertTrue(System::isArch(System::PPC)); $this->assertFalse(System::isArch(System::X86)); diff --git a/tests/System/SystemTestX86.php b/tests/System/SystemTestX86.php index dedaecd..b6a6667 100644 --- a/tests/System/SystemTestX86.php +++ b/tests/System/SystemTestX86.php @@ -30,11 +30,15 @@ public function tearDown(): void public function testOs() { - $this->assertFalse(System::isArm()); + $this->assertFalse(System::isArm64()); + $this->assertFalse(System::isArmV7()); + $this->assertFalse(System::isArmV8()); $this->assertFalse(System::isPPC()); $this->assertTrue(System::isX86()); - $this->assertFalse(System::isArch(System::ARM)); + $this->assertFalse(System::isArch(System::ARM64)); + $this->assertFalse(System::isArch(System::ARMV7)); + $this->assertFalse(System::isArch(System::ARMV8)); $this->assertFalse(System::isArch(System::PPC)); $this->assertTrue(System::isArch(System::X86));