From 4ea127a7697b1c42133e6309d4036942b77486c6 Mon Sep 17 00:00:00 2001
From: Michael Oehlhof <typo3@oehlhof.de>
Date: Sun, 1 Mar 2015 13:21:26 +0100
Subject: [PATCH] [TASK] Code cleanup: ColorpickerController.php

backend/classes/Controller/Wizard/ColorpickerController.php
To get it "green" in PhpStorm several changes were made:

- set correct return type in PhpDoc comment
- makeInstance of GraphicalFunctions to call non-static function
  imageCreateFromFile
- change local variable names to lowerCamelCase

Resolves: #65431
Releases: master
Change-Id: I54182c8ed17423e1cbc1c97e424d92a58dd5e3a9
Reviewed-on: http://review.typo3.org/37404
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
---
 .../Wizard/ColorpickerController.php          | 30 ++++++++++++-------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php b/typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
index ffd04d1e386f..ebf73a8d7729 100644
--- a/typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
+++ b/typo3/sysext/backend/Classes/Controller/Wizard/ColorpickerController.php
@@ -111,6 +111,11 @@ class ColorpickerController extends AbstractWizardController {
 	 */
 	public $content;
 
+	/**
+	 * @var string
+	 */
+	protected $exampleImg;
+
 	/**
 	 * Constructor
 	 */
@@ -303,7 +308,7 @@ class ColorpickerController extends AbstractWizardController {
 	/**
 	 * Creates a color matrix table
 	 *
-	 * @return void
+	 * @return string
 	 */
 	public function colorMatrix() {
 		$steps = 51;
@@ -341,7 +346,7 @@ class ColorpickerController extends AbstractWizardController {
 	/**
 	 * Creates a selector box with all HTML color names.
 	 *
-	 * @return void
+	 * @return string
 	 */
 	public function colorList() {
 		// Initialize variables:
@@ -366,14 +371,16 @@ class ColorpickerController extends AbstractWizardController {
 	/**
 	 * Creates a color image selector
 	 *
-	 * @return void
+	 * @return string
 	 */
 	public function colorImage() {
 		// Handling color-picker image if any:
 		if (!$this->imageError) {
 			if ($this->pickerImage) {
 				if (GeneralUtility::_POST('coords_x')) {
-					$this->colorValue = '#' . $this->getIndex(\TYPO3\CMS\Core\Imaging\GraphicalFunctions::imageCreateFromFile($this->pickerImage), GeneralUtility::_POST('coords_x'), GeneralUtility::_POST('coords_y'));
+					/* @var $image \TYPO3\CMS\Core\Imaging\GraphicalFunctions */
+					$image = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\GraphicalFunctions::class);
+					$this->colorValue = '#' . $this->getIndex($image->imageCreateFromFile($this->pickerImage), GeneralUtility::_POST('coords_x'), GeneralUtility::_POST('coords_y'));
 				}
 				$pickerFormImage = '
 				<p class="c-head">' . $this->getLanguageService()->getLL('colorpicker_fromImage', TRUE) . '</p>
@@ -400,18 +407,19 @@ class ColorpickerController extends AbstractWizardController {
 	 */
 	public function getIndex($im, $x, $y) {
 		$rgb = ImageColorAt($im, $x, $y);
-		$colorrgb = imagecolorsforindex($im, $rgb);
-		$index['r'] = dechex($colorrgb['red']);
-		$index['g'] = dechex($colorrgb['green']);
-		$index['b'] = dechex($colorrgb['blue']);
+		$colorRgb = imagecolorsforindex($im, $rgb);
+		$index['r'] = dechex($colorRgb['red']);
+		$index['g'] = dechex($colorRgb['green']);
+		$index['b'] = dechex($colorRgb['blue']);
+		$hexValue = array();
 		foreach ($index as $value) {
 			if (strlen($value) == 1) {
-				$hexvalue[] = strtoupper('0' . $value);
+				$hexValue[] = strtoupper('0' . $value);
 			} else {
-				$hexvalue[] = strtoupper($value);
+				$hexValue[] = strtoupper($value);
 			}
 		}
-		$hex = implode('', $hexvalue);
+		$hex = implode('', $hexValue);
 		return $hex;
 	}
 
-- 
GitLab