From 58b228633ba1c205039d6f4eb90e59d1696eeb98 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Dec 2019 11:12:49 +0545 Subject: [PATCH 1/9] Fix 'Function ReflectionType::__toString() is deprecated' --- lib/private/AppFramework/Utility/ControllerMethodReflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index 6842778d6127..908b25193642 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -64,7 +64,7 @@ public function reflect($object, $method) { if (\method_exists($param, 'getType')) { $type = $param->getType(); if ($type !== null) { - $this->types[$param->getName()] = (string) $type; + $this->types[$param->getName()] = $type->getName(); } } From b52bdb6fe3885d5bbf8cc479f213c8484f7d0ded Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Dec 2019 11:13:22 +0545 Subject: [PATCH 2/9] Fix 'stripos(): Non-string needles will be interpreted as strings in the future' --- tests/lib/Util/User/MemoryAccountMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/Util/User/MemoryAccountMapper.php b/tests/lib/Util/User/MemoryAccountMapper.php index 2deb31fd34b9..c2f1e66c7603 100644 --- a/tests/lib/Util/User/MemoryAccountMapper.php +++ b/tests/lib/Util/User/MemoryAccountMapper.php @@ -76,7 +76,7 @@ public function search($fieldName, $pattern, $limit, $offset) { return self::$accounts; } $match = \array_filter(self::$accounts, function (Account $a) use ($pattern) { - return \stripos($a->getUserId(), $pattern); + return \stripos($a->getUserId(), (string) $pattern); }); return $match; From 34c17e307129187e9a8f4f32380c14c21f0c0434 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Dec 2019 12:07:57 +0545 Subject: [PATCH 3/9] Fix 'Trying to access array offset on value of type bool' --- lib/private/Files/Cache/Cache.php | 2 +- tests/lib/Cache/FileCacheTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 4584ea0655ba..c0f201b19c35 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -111,7 +111,7 @@ public function getNumericStorageId() { * get the stored metadata of a file or folder * * @param string | int $file either the path of a file or folder or the file id for a file or folder - * @return ICacheEntry|false the cache entry as array of false if the file is not found in the cache + * @return ICacheEntry|false the cache entry as array or false if the file is not found in the cache */ public function get($file) { if (\is_string($file) or $file == '') { diff --git a/tests/lib/Cache/FileCacheTest.php b/tests/lib/Cache/FileCacheTest.php index 8e0b623b75b6..b7126ad4a368 100644 --- a/tests/lib/Cache/FileCacheTest.php +++ b/tests/lib/Cache/FileCacheTest.php @@ -84,8 +84,8 @@ protected function setUp(): void { } protected function tearDown(): void { - if ($this->instance) { - $this->instance->remove('hack', 'hack'); + if ($this->instance->get('hack') !== null) { + $this->instance->remove('hack'); } parent::tearDown(); From b64502b8d59edb816ff20abd89e7331eefc8b743 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Dec 2019 17:46:19 +0545 Subject: [PATCH 4/9] Pass real core.key core.crt in SignAppTest to fix 'Trying to access array offset on value of type bool' --- tests/lib/Command/Integrity/SignAppTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/lib/Command/Integrity/SignAppTest.php b/tests/lib/Command/Integrity/SignAppTest.php index de4c4f94dffd..c03289d0135d 100644 --- a/tests/lib/Command/Integrity/SignAppTest.php +++ b/tests/lib/Command/Integrity/SignAppTest.php @@ -221,23 +221,23 @@ public function testExecute() { ->expects($this->at(1)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); $inputInterface ->expects($this->at(2)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')); $this->fileAccessHelper ->expects($this->at(0)) ->method('file_get_contents') - ->with('privateKey') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); + ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key') + ->will($this->returnValue(\file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'))); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') - ->with('certificate') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')); + ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt') + ->will($this->returnValue(\file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'))); $this->checker ->expects($this->once()) From 0cde06bfe15355803a34d96d6fd395ee14e70033 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 19 Dec 2019 13:49:39 +0545 Subject: [PATCH 5/9] In ControllerMethodReflector type is a \ReflectionNamedType --- lib/private/AppFramework/Utility/ControllerMethodReflector.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/private/AppFramework/Utility/ControllerMethodReflector.php b/lib/private/AppFramework/Utility/ControllerMethodReflector.php index 908b25193642..626064bc2c88 100644 --- a/lib/private/AppFramework/Utility/ControllerMethodReflector.php +++ b/lib/private/AppFramework/Utility/ControllerMethodReflector.php @@ -63,6 +63,7 @@ public function reflect($object, $method) { // over phpdoc annotations if (\method_exists($param, 'getType')) { $type = $param->getType(); + '@phan-var \ReflectionNamedType $type'; if ($type !== null) { $this->types[$param->getName()] = $type->getName(); } From cdb2c5e1065d1001a4743c2c565e3da4e40181f2 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 8 Jan 2020 10:15:27 +0545 Subject: [PATCH 6/9] Pass real core.key core.crt in SignCoreTest to fix 'Trying to access array offset on value of type bool' --- tests/lib/Command/Integrity/SignCoreTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/lib/Command/Integrity/SignCoreTest.php b/tests/lib/Command/Integrity/SignCoreTest.php index 04cdd01f3eda..a5a9bc0b5c32 100644 --- a/tests/lib/Command/Integrity/SignCoreTest.php +++ b/tests/lib/Command/Integrity/SignCoreTest.php @@ -172,12 +172,12 @@ public function testExecute() { ->expects($this->at(0)) ->method('getOption') ->with('privateKey') - ->will($this->returnValue('privateKey')); + ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); $inputInterface ->expects($this->at(1)) ->method('getOption') ->with('certificate') - ->will($this->returnValue('certificate')); + ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')); $inputInterface ->expects($this->at(2)) ->method('getOption') @@ -187,13 +187,13 @@ public function testExecute() { $this->fileAccessHelper ->expects($this->at(0)) ->method('file_get_contents') - ->with('privateKey') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key')); + ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key') + ->will($this->returnValue(\file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.key'))); $this->fileAccessHelper ->expects($this->at(1)) ->method('file_get_contents') - ->with('certificate') - ->will($this->returnValue(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt')); + ->with(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt') + ->will($this->returnValue(\file_get_contents(\OC::$SERVERROOT . '/tests/data/integritycheck/core.crt'))); $this->checker ->expects($this->once()) From fda4d102dae688a3126e75fc934296e71165cae5 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 8 Jan 2020 10:30:15 +0545 Subject: [PATCH 7/9] Fix 'Trying to access array offset on value of type bool' in CacheTest --- tests/lib/Files/Cache/CacheTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index d98f8c802a69..2b691586a787 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -248,8 +248,12 @@ public function testRootFolderSizeForNonHomeStorage() { // clean up $this->cache->remove(''); - $this->cache->remove($dir1); - $this->cache->remove($dir2); + if ($this->cache->get($dir1)) { + $this->cache->remove($dir1); + } + if ($this->cache->get($dir2)) { + $this->cache->remove($dir2); + } $this->assertFalse($this->cache->inCache($dir1)); $this->assertFalse($this->cache->inCache($dir2)); From f4db855ba815e31ac8a5ec89b316840bf57ccb5c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 8 Jan 2020 10:32:46 +0545 Subject: [PATCH 8/9] Fix 'Trying to access array offset on value of type bool' in HomeCacheTest --- tests/lib/Files/Cache/HomeCacheTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/lib/Files/Cache/HomeCacheTest.php b/tests/lib/Files/Cache/HomeCacheTest.php index 3b94eb1557b3..09a5464e3aef 100644 --- a/tests/lib/Files/Cache/HomeCacheTest.php +++ b/tests/lib/Files/Cache/HomeCacheTest.php @@ -102,9 +102,15 @@ public function testRootFolderSizeIgnoresUnknownUpdate() { // clean up $this->cache->remove(''); - $this->cache->remove('files'); - $this->cache->remove($dir1); - $this->cache->remove($dir2); + if ($this->cache->get('files')) { + $this->cache->remove('files'); + } + if ($this->cache->get($dir1)) { + $this->cache->remove($dir1); + } + if ($this->cache->get($dir2)) { + $this->cache->remove($dir2); + } $this->assertFalse($this->cache->inCache('files')); $this->assertFalse($this->cache->inCache($dir1)); @@ -132,7 +138,9 @@ public function testRootFolderSizeIsFilesSize() { // clean up $this->cache->remove(''); - $this->cache->remove($dir1); + if ($this->cache->get($dir1)) { + $this->cache->remove($dir1); + } $this->assertFalse($this->cache->inCache($dir1)); } From 0434cca0264b67eab480c75e8f438eee6d39d0da Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 8 Jan 2020 10:51:55 +0545 Subject: [PATCH 9/9] Fix 'Trying to access array offset on value of type bool' in CacheJailTest --- tests/lib/Files/Cache/Wrapper/CacheJailTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php index 4eccd0baa88a..f3d11f8e2547 100644 --- a/tests/lib/Files/Cache/Wrapper/CacheJailTest.php +++ b/tests/lib/Files/Cache/Wrapper/CacheJailTest.php @@ -30,6 +30,12 @@ public function setUp(): void { $this->cache = new \OC\Files\Cache\Wrapper\CacheJail($this->sourceCache, 'foo'); } + protected function tearDown(): void { + if ($this->sourceCache) { + $this->sourceCache->clear(); + } + } + public function testSearchOutsideJail() { $file1 = 'foo/foobar'; $file2 = 'folder/foobar';