From 4b3abc282a0610c992a59bcf01556e74bfa532df Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 7 Apr 2015 12:42:48 -0600 Subject: [PATCH] PSR Fixes --- system/src/Grav/Common/Page/Media.php | 2 -- .../Grav/Common/Page/Medium/ImageMedium.php | 24 ++++++++++++------- system/src/Grav/Common/Page/Medium/Link.php | 1 + system/src/Grav/Common/Page/Medium/Medium.php | 20 +++++++++++----- .../Grav/Common/Page/Medium/MediumFactory.php | 3 ++- system/src/Grav/Common/Page/Page.php | 1 - system/src/Grav/Common/Page/Pages.php | 6 ----- 7 files changed, 32 insertions(+), 25 deletions(-) diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index 15296c9ac..1495eddbd 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -98,13 +98,11 @@ class Media extends Getters // Build missing alternatives if (!empty($types['alternative'])) { - $alternatives = $types['alternative']; $max = max(array_keys($alternatives)); for ($i=2; $i < $max; $i++) { - if (isset($alternatives[$i])) { continue; } diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index 76854fe1d..5dbe114ca 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -24,7 +24,7 @@ class ImageMedium extends Medium /** * @var int */ - protected $quality = 85; + protected $quality = DEFAULT_IMG_QUALITY; /** * @var boolean @@ -76,7 +76,7 @@ class ImageMedium extends Medium /** * Add meta file for the medium. * - * @param $format + * @param $filepath * @return $this */ public function addMetaFile($filepath) @@ -92,13 +92,16 @@ class ImageMedium extends Medium /** * Return PATH to image. * - * @return string path to image + * @param bool $reset + * @return string path to image */ public function path($reset = true) { $output = $this->saveImage(); - if ($reset) $this->reset(); + if ($reset) { + $this->reset(); + } return $output; } @@ -113,7 +116,9 @@ class ImageMedium extends Medium { $output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->saveImage()); - if ($reset) $this->reset(); + if ($reset) { + $this->reset(); + } return self::$grav['base_url'] . $output . $this->urlHash(); } @@ -178,7 +183,7 @@ class ImageMedium extends Medium } $this->format = 'guess'; - $this->quality = 85; + $this->quality = DEFAULT_IMG_QUALITY; $this->debug_watermarked = false; @@ -262,7 +267,8 @@ class ImageMedium extends Medium * @param string $sizes * @return $this */ - public function sizes($sizes = null) { + public function sizes($sizes = null) + { if ($sizes) { $this->attributes['sizes'] = $sizes; @@ -312,7 +318,8 @@ class ImageMedium extends Medium call_user_func_array([$medium, $method], $args_copy); } - } catch (\BadFunctionCallException $e) { } + } catch (\BadFunctionCallException $e) { + } return $this; } @@ -320,7 +327,6 @@ class ImageMedium extends Medium /** * Gets medium image, resets image manipulation operations. * - * @param string $variable * @return $this */ protected function image() diff --git a/system/src/Grav/Common/Page/Medium/Link.php b/system/src/Grav/Common/Page/Medium/Link.php index 88c8bb08d..1262bddf9 100644 --- a/system/src/Grav/Common/Page/Medium/Link.php +++ b/system/src/Grav/Common/Page/Medium/Link.php @@ -12,6 +12,7 @@ class Link implements RenderableInterface * @var array */ protected $attributes = []; + protected $source; /** * Construct. diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index 52f8e8e95..e001ec3c6 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -4,6 +4,7 @@ namespace Grav\Common\Page\Medium; use Grav\Common\File\CompiledYamlFile; use Grav\Common\GravTrait; use Grav\Common\Data\Data; +use Grav\Common\Data\Blueprint; /** * The Medium is a general class for multimedia objects in Grav pages, specific implementations will derive from @@ -32,6 +33,8 @@ class Medium extends Data implements RenderableInterface */ protected $thumbnailTypes = [ 'page', 'default' ]; + protected $thumbnailType = null; + /** * @var Medium[] */ @@ -105,7 +108,9 @@ class Medium extends Data implements RenderableInterface */ public function path($reset = true) { - if ($reset) $this->reset(); + if ($reset) { + $this->reset(); + } return $this->get('filepath'); } @@ -120,7 +125,9 @@ class Medium extends Data implements RenderableInterface { $output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('filepath')); - if ($reset) $this->reset(); + if ($reset) { + $this->reset(); + } return self::$grav['base_url'] . $output . $this->urlHash(); } @@ -158,8 +165,6 @@ class Medium extends Data implements RenderableInterface */ public function parsedownElement($title = null, $alt = null, $class = null, $reset = true) { - $element; - $attributes = $this->attributes; $style = ''; @@ -249,8 +254,10 @@ class Medium extends Data implements RenderableInterface */ public function display($mode = 'source') { - if ($this->mode === $mode) + if ($this->mode === $mode) { return $this; + } + $this->mode = $mode; @@ -266,8 +273,9 @@ class Medium extends Data implements RenderableInterface */ public function thumbnail($type = 'auto') { - if ($type !== 'auto' && !in_array($type, $this->thumbnailTypes)) + if ($type !== 'auto' && !in_array($type, $this->thumbnailTypes)) { return $this; + } if ($this->thumbnailType !== $type) { $this->_thumbnail = null; diff --git a/system/src/Grav/Common/Page/Medium/MediumFactory.php b/system/src/Grav/Common/Page/Medium/MediumFactory.php index e26b8110a..9ff05d4b9 100644 --- a/system/src/Grav/Common/Page/Medium/MediumFactory.php +++ b/system/src/Grav/Common/Page/Medium/MediumFactory.php @@ -113,8 +113,9 @@ class MediumFactory */ public static function scaledFromMedium($medium, $from, $to) { - if (! $medium instanceof ImageMedium) + if (! $medium instanceof ImageMedium) { return $medium; + } if ($to > $from) { return $medium; diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 44a5665e2..95b558f18 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -960,7 +960,6 @@ class Page // Build an array of meta objects.. foreach ((array)$page_header->metadata as $key => $value) { - // If this is a property type metadata: "og", "twitter", "facebook" etc if (is_array($value)) { foreach ($value as $property => $prop_value) { diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index bbff00e8d..fd70981d6 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -523,7 +523,6 @@ class Pages /** @var \DirectoryIterator $file */ foreach ($iterator as $file) { - if ($file->isDot()) { continue; } @@ -531,14 +530,12 @@ class Pages $name = $file->getFilename(); if ($file->isFile()) { - // Update the last modified if it's newer than already found if ($file->getBasename() !== '.DS_Store' && ($modified = $file->getMTime()) > $last_modified) { $last_modified = $modified; } if (Utils::endsWith($name, CONTENT_EXT)) { - $page->init($file); $content_exists = true; @@ -547,7 +544,6 @@ class Pages } } } elseif ($file->isDir()) { - if (!$page->path()) { $page->path($file->getPath()); } @@ -593,7 +589,6 @@ class Pages // Build routes and taxonomy map. /** @var $page Page */ foreach ($this->instances as $page) { - $parent = $page->parent(); if ($parent) { @@ -643,7 +638,6 @@ class Pages } foreach ($pages as $key => $info) { - $child = isset($this->instances[$key]) ? $this->instances[$key] : null; if (!$child) { throw new \RuntimeException("Page does not exist: {$key}");