Skip to content

Commit

Permalink
cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ubermichael committed Oct 20, 2020
1 parent 8c13657 commit d31421f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.idea
/.idea
/composer.lock
/vendor
/.php_cs.cache
2 changes: 1 addition & 1 deletion .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $finder = PhpCsFixer\Finder::create()
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setUsingCache(true)
->setCacheFile(__DIR__. '/../../var/cache/php_cs.cache')
->setCacheFile(__DIR__. '/.php_cs.cache')
->setFinder($finder)
->setRules([
'@PhpCsFixer' => true,
Expand Down
22 changes: 12 additions & 10 deletions UtilBundle/Tests/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class BaseCase extends WebTestCase {
protected $references;

/**
* @var array|string[]|SplFileInfo[]
* @var array|SplFileInfo[]|string[]
*/
protected $cleanup;

Expand Down Expand Up @@ -68,17 +68,19 @@ protected function getReference(string $id, $reload = false) {
return $this->entityManager->find(get_class($object), $object->getId());
}

protected function cleanup($files) {
if( ! is_array($files)) {
protected function cleanup($files) : void {
if ( ! is_array($files)) {
$files = [$files];
}
foreach($files as $file) {
if($file instanceof \SplFileInfo) {
foreach ($files as $file) {
if ($file instanceof \SplFileInfo) {
$this->cleanup[] = $file->getRealPath();
} else if(is_string($file)) {
$this->cleanup[] = $file;
} else {
throw new \Exception("Cannot clean up " . get_class($file));
if (is_string($file)) {
$this->cleanup[] = $file;
} else {
throw new \Exception('Cannot clean up ' . get_class($file));
}
}
}
}
Expand Down Expand Up @@ -106,8 +108,8 @@ protected function tearDown() : void {
$this->entityManager = null;
}
parent::tearDown();
foreach($this->cleanup as $path) {
if(file_exists($path)) {
foreach ($this->cleanup as $path) {
if (file_exists($path)) {
unlink($path);
}
}
Expand Down
2 changes: 1 addition & 1 deletion UtilBundle/Twig/TextExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function camelTitle($name) {
}

public function byteSize($bytes) {
if( ! $bytes) {
if ( ! $bytes) {
return '0b';
}
$units = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
Expand Down

0 comments on commit d31421f

Please sign in to comment.