Verified Commit 11ef5e6b authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise operation...

Issue #2911379 by Spokje, ProFire, mstrelan: Unneccessary bitwise operation for file permissions check on Windows

(cherry picked from commit 2b2aebcd)
parent 5a2ddf59
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -144,18 +144,6 @@ public function providerTestBasename() {
  protected function assertFilePermissions(int $expected_mode, string $uri, string $message = ''): void {
    // Mask out all but the last three octets.
    $actual_mode = fileperms($uri) & 0777;

    // PHP on Windows has limited support for file permissions. Usually each of
    // "user", "group" and "other" use one octal digit (3 bits) to represent the
    // read/write/execute bits. On Windows, chmod() ignores the "group" and
    // "other" bits, and fileperms() returns the "user" bits in all three
    // positions. $expected_mode is updated to reflect this.
    if (substr(PHP_OS, 0, 3) == 'WIN') {
      // Reset the "group" and "other" bits.
      $expected_mode = $expected_mode & 0700;
      // Shift the "user" bits to the "group" and "other" positions also.
      $expected_mode = $expected_mode | $expected_mode >> 3 | $expected_mode >> 6;
    }
    $this->assertSame($expected_mode, $actual_mode, $message);
  }