diff --git a/build/kint.phar b/build/kint.phar index 749763a0..309a62e4 100644 Binary files a/build/kint.phar and b/build/kint.phar differ diff --git a/src/Zval/Representation/SplFileInfoRepresentation.php b/src/Zval/Representation/SplFileInfoRepresentation.php index 44980d7e..6424ee6a 100644 --- a/src/Zval/Representation/SplFileInfoRepresentation.php +++ b/src/Zval/Representation/SplFileInfoRepresentation.php @@ -57,7 +57,7 @@ public function __construct(SplFileInfo $fileInfo) $this->path = $fileInfo->getPathname(); try { - if ($fileInfo->getRealPath()) { + if (\strlen($this->path) && $fileInfo->getRealPath()) { $this->perms = $fileInfo->getPerms(); $this->size = $fileInfo->getSize(); $this->owner = $fileInfo->getOwner(); diff --git a/tests/Zval/Representation/SplFileInfoRepresentationTest.php b/tests/Zval/Representation/SplFileInfoRepresentationTest.php index f903a835..71ea14a3 100644 --- a/tests/Zval/Representation/SplFileInfoRepresentationTest.php +++ b/tests/Zval/Representation/SplFileInfoRepresentationTest.php @@ -90,6 +90,7 @@ public function testConstructFile() $this->assertSame(__FILE__, $r->path); $this->assertSame(__FILE__, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('-rw-r--r--'), $r->flags); if ('file' === \filetype(__FILE__)) { $this->assertTrue($r->is_file); @@ -120,6 +121,7 @@ public function testConstructFileLink() $this->assertSame($f, $r->path); $this->assertSame(__FILE__, $r->realpath); $this->assertSame(__DIR__.'/testFileLink', $r->linktarget); + $this->assertSame(\str_split('lrw-r--r--'), $r->flags); if ('link' === \filetype($f)) { $this->assertTrue($r->is_file); @@ -150,6 +152,7 @@ public function testConstructLinkedFile() $this->assertSame($f, $r->path); $this->assertSame(__FILE__, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('-rw-r--r--'), $r->flags); if ('file' === \filetype($f)) { $this->assertTrue($r->is_file); @@ -178,6 +181,7 @@ public function testConstructDir() $this->assertSame(__DIR__, $r->path); $this->assertSame(__DIR__, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('drwxr-xr-x'), $r->flags); if ('dir' === \filetype(__DIR__)) { $this->assertFalse($r->is_file); @@ -211,6 +215,7 @@ public function testConstructOpenBaseDir() $this->assertFalse($r->is_file); $this->assertFalse($r->is_dir); $this->assertFalse($r->is_link); + $this->assertSame(\str_split('----------'), $r->flags); } /** @@ -233,6 +238,7 @@ public function testConstructDirLink() $this->assertSame($f, $r->path); $this->assertSame(\dirname(__DIR__), $r->realpath); $this->assertSame(__DIR__.'/testDirLink', $r->linktarget); + $this->assertSame(\str_split('lrwxr-xr-x'), $r->flags); if ('link' === \filetype($f)) { $this->assertFalse($r->is_file); @@ -263,6 +269,7 @@ public function testConstructLinkedDir() $this->assertSame($f, $r->path); $this->assertSame(__DIR__, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('drwxr-xr-x'), $r->flags); if ('dir' === \filetype($f)) { $this->assertFalse($r->is_file); @@ -293,6 +300,7 @@ public function testConstructPipe() $this->assertSame($f, $r->path); $this->assertSame($f, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('prwxr-xr-x'), $r->flags); if ('fifo' === \filetype($f)) { $this->assertFalse($r->is_file); @@ -323,6 +331,7 @@ public function testConstructSocket() $this->assertSame($f, $r->path); $this->assertSame($f, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('srwxr-xr-x'), $r->flags); if ('socket' === \filetype($f)) { $this->assertFalse($r->is_file); @@ -353,6 +362,7 @@ public function testConstructCharacterDevice() $this->assertSame($f, $r->path); $this->assertSame($f, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('crw-rw-rw-'), $r->flags); if ('char' === \filetype($f)) { $this->assertFalse($r->is_file); @@ -409,6 +419,7 @@ public function testConstructBlockDevice() $this->assertSame($f, $r->path); $this->assertSame($f, $r->realpath); $this->assertNull($r->linktarget); + $this->assertSame(\str_split('brw-rw----'), $r->flags); if ('block' === $type) { $this->assertFalse($r->is_file); @@ -446,6 +457,37 @@ public function testConstructNone() $this->assertFalse($r->is_file); $this->assertFalse($r->is_dir); $this->assertFalse($r->is_link); + $this->assertSame(\str_split('----------'), $r->flags); + } + + /** + * @covers \Kint\Zval\Representation\SplFileInfoRepresentation::__construct + * @covers \Kint\Zval\Representation\SplFileInfoRepresentation::getSize + * @covers \Kint\Zval\Representation\SplFileInfoRepresentation::getMTime + */ + public function testConstructEmpty() + { + $f = ''; + + $r = new SplFileInfoRepresentation(new SplFileInfo($f)); + + $this->assertNull($r->size); + $this->assertNull($r->getSize()); + $this->assertNull($r->ctime); + $this->assertNull($r->mtime); + $this->assertNull($r->getMTime()); + $this->assertNull($r->perms); + $this->assertNull($r->owner); + $this->assertNull($r->group); + $this->assertSame('Unknown file', $r->typename); + $this->assertSame('-', $r->typeflag); + $this->assertSame($f, $r->path); + $this->assertNull($r->realpath); + $this->assertNull($r->linktarget); + $this->assertFalse($r->is_file); + $this->assertFalse($r->is_dir); + $this->assertFalse($r->is_link); + $this->assertSame(\str_split('----------'), $r->flags); } /**