Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Changes file mode
<?php chmod(string $filename, int $permissions): bool
<?php         if (! is_null($mode)) {

            chmod($tempPath, $mode);

        } else {

            chmod($tempPath, 0777 - umask());

        }
<?php         if (! is_null($mode)) {

            chmod($tempPath, $mode);

        } else {

            chmod($tempPath, 0777 - umask());

        }



        file_put_contents($tempPath, $content);
<?php     public function chmod($path, $mode = null)

    {

        if ($mode) {

            return chmod($path, $mode);

        }



        return substr(sprintf('%o', fileperms($path)), -4);
<?php     {

        $this->filesystem->write('foo.txt', 'Hello World');



        chmod(__DIR__.'/tmp/foo.txt', 0400);



        $adapter = new FilesystemAdapter($this->filesystem, $this->adapter, ['throw' => true]);
<?php             return;

        } finally {

            chmod(__DIR__.'/tmp/foo.txt', 0600);

        }



        $this->fail('Exception was not thrown.');
<?php         symlink($tempFile, $symlink);




        chmod($symlinkDir, 0555);




        $umask = 0131;
<?php         umask($originalUmask);




        chmod($symlinkDir, 0777 - $originalUmask);

    }



    public function testSetChmod()
<?php     public function testGetChmod()

    {

        file_put_contents(self::$tempDir.'/file.txt', 'Hello World');

        chmod(self::$tempDir.'/file.txt', 0755);



        $files = new Filesystem;

        $filePermission = $files->chmod(self::$tempDir.'/file.txt');
<?php     {

        file_put_contents(self::$tempDir.'/foo.txt', 'foo');

        $files = new Filesystem;

        @chmod(self::$tempDir.'/foo.txt', 0444);

        $this->assertFalse($files->isWritable(self::$tempDir.'/foo.txt'));

        @chmod(self::$tempDir.'/foo.txt', 0777);

        $this->assertTrue($files->isWritable(self::$tempDir.'/foo.txt'));
<?php         $files = new Filesystem;

        @chmod(self::$tempDir.'/foo.txt', 0444);

        $this->assertFalse($files->isWritable(self::$tempDir.'/foo.txt'));

        @chmod(self::$tempDir.'/foo.txt', 0777);

        $this->assertTrue($files->isWritable(self::$tempDir.'/foo.txt'));

    }
<?php         if (DIRECTORY_SEPARATOR === '\\') {

            $this->assertTrue($files->isReadable(self::$tempDir.'/foo.txt'));

        } else {

            @chmod(self::$tempDir.'/foo.txt', 0000);

            $this->assertFalse($files->isReadable(self::$tempDir.'/foo.txt'));

            @chmod(self::$tempDir.'/foo.txt', 0777);

            $this->assertTrue($files->isReadable(self::$tempDir.'/foo.txt'));
<?php         } else {

            @chmod(self::$tempDir.'/foo.txt', 0000);

            $this->assertFalse($files->isReadable(self::$tempDir.'/foo.txt'));

            @chmod(self::$tempDir.'/foo.txt', 0777);

            $this->assertTrue($files->isReadable(self::$tempDir.'/foo.txt'));

        }

        $this->assertFalse($files->isReadable(self::$tempDir.'/doesnotexist.txt'));