From c8dc29de73497dd5f0fd32dac2e58c3bef0baa45 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 27 Jul 2023 09:56:34 +0100 Subject: [PATCH 1/8] Add ARMV7 and ARMV8 differentiators --- src/System/System.php | 56 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/src/System/System.php b/src/System/System.php index 445aec3..cfb6514 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 isArnV8(): 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::isArnV8(); break; default: From 831a80e9389841e153e4214f650b113ef8d5728d Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 27 Jul 2023 10:24:54 +0100 Subject: [PATCH 2/8] Update Tests --- src/System/System.php | 4 ++-- tests/System/SystemTest.php | 8 ++++++-- .../{SystemTestARM.php => SystemTestARM64.php} | 12 ++++++++---- tests/System/SystemTestPPC.php | 8 ++++++-- tests/System/SystemTestX86.php | 8 ++++++-- 5 files changed, 28 insertions(+), 12 deletions(-) rename tests/System/{SystemTestARM.php => SystemTestARM64.php} (61%) diff --git a/src/System/System.php b/src/System/System.php index cfb6514..3fef281 100644 --- a/src/System/System.php +++ b/src/System/System.php @@ -153,7 +153,7 @@ public static function isArmV7(): bool * * @return bool */ - public static function isArnV8(): bool + public static function isArmV8(): bool { return (bool) preg_match(self::RegexARMV8, self::getArch()); } @@ -203,7 +203,7 @@ public static function isArch(string $arch): bool return self::isArmV7(); break; case self::ARMV8: - return self::isArnV8(); + 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/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)); From 90050f0bf2d0fffa2a4070c34e6d72704a2beb8c Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 27 Jul 2023 10:31:57 +0100 Subject: [PATCH 3/8] Add V7 and V8 tests --- phpunit.xml | 10 +++++-- tests/System/SystemTestARMV7.php | 47 ++++++++++++++++++++++++++++++++ tests/System/SystemTestARMV8.php | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 tests/System/SystemTestARMV7.php create mode 100644 tests/System/SystemTestARMV8.php 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/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()); + } +} From 0130abd468bc495f5f83ab890e56e495e36b8669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 30 Jul 2023 08:03:43 +0000 Subject: [PATCH 4/8] Upgrade to PHP 8 --- .travis.yml | 1 - composer.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 912d3d6..f9e9b78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ arch: - arm64 php: -- 7.4 - 8.0 - 8.0.23 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": { From f0a3affc46d14c5291e4b1a91fc7d11c329be798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 30 Jul 2023 08:03:49 +0000 Subject: [PATCH 5/8] PHP 8 docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 | From d84a9c7731fa36f8d7df9209c5bec10deee435e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 30 Jul 2023 08:10:15 +0000 Subject: [PATCH 6/8] Dev stability --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a91747d..e8a0096 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "keywords": ["php","framework", "upf", "utopia", "system"], "license": "MIT", - "minimum-stability": "stable", + "minimum-stability": "dev", "authors": [ { "name": "Eldad Fux", From 2920d16b2a6849ba59fb7e1a995031b3e83de08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Sun, 30 Jul 2023 08:13:02 +0000 Subject: [PATCH 7/8] Mark stable --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e8a0096..a91747d 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "keywords": ["php","framework", "upf", "utopia", "system"], "license": "MIT", - "minimum-stability": "dev", + "minimum-stability": "stable", "authors": [ { "name": "Eldad Fux", From eb392791fd5e87765ff353a16ed2eb886cf079f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 7 Aug 2023 11:08:41 +0200 Subject: [PATCH 8/8] Fix CI/CD --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f9e9b78..92f4b5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,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