Skip to content

Commit

Permalink
ID#323:
Browse files Browse the repository at this point in the history
- Introduced type declaration for various classes.
- Corrected implementation to comply w/ interface definition.
- Added fluent interface support.
  • Loading branch information
Christian Achatz committed May 18, 2018
1 parent e5e22dd commit 231133a
Show file tree
Hide file tree
Showing 37 changed files with 105 additions and 41 deletions.
2 changes: 1 addition & 1 deletion core/pagecontroller/Document.php
Expand Up @@ -110,7 +110,7 @@ class Document extends APFObject implements DomNode {
protected $parent = null;

/**
* @var string[][] $attributes XML attributes of the current node.
* @var string[] $attributes XML attributes of the current node.
*/
protected $attributes = [];

Expand Down
Expand Up @@ -112,6 +112,7 @@ public function onAfterAppend() {

public function reset() {
// nothing to do as client listeners cannot be reset
return $this;
}

}
Expand Up @@ -113,6 +113,7 @@ public function transform() {

public function reset() {
// nothing to do as client listeners cannot be reset
return $this;
}

}
Expand Up @@ -84,6 +84,7 @@ public function transform() {

public function reset() {
// nothing to do as client errors cannot be reset
return $this;
}

}
Expand Up @@ -219,6 +219,7 @@ public function onAfterAppend() {

public function reset() {
// nothing to do as client validation rule generation takes no user input
return $this;
}

}
4 changes: 2 additions & 2 deletions tools/form/FormControl.php
Expand Up @@ -366,7 +366,7 @@ public function isFilled();
* @version
* Version 0.1, 03.02.2010<br />
*/
public function appendCssClass($class);
public function appendCssClass(string $class);

/**
* Adds an additional attribute to the white list of the control.
Expand All @@ -380,7 +380,7 @@ public function appendCssClass($class);
* @version
* Version 0.1, 21.07.2010<br />
*/
public function addAttributeToWhiteList($name);
public function addAttributeToWhiteList(string $name);

/**
* Adds a set of additional attributes to the white list of the control.
Expand Down
12 changes: 6 additions & 6 deletions tools/form/FormControlFinder.php
Expand Up @@ -44,7 +44,7 @@ interface FormControlFinder {
* @version
* Version 0.1, 21.01.2007<br />
*/
public function getFormElementByID($id);
public function getFormElementByID(string $id);

/**
* Returns a list of form controls with the given name.
Expand All @@ -57,7 +57,7 @@ public function getFormElementByID($id);
* @version
* Version 0.1, 16.08.2010<br />
*/
public function getFormElementsByName($name);
public function getFormElementsByName(string $name);

/**
* Returns a list of form elements addressed by their tag name.
Expand All @@ -72,7 +72,7 @@ public function getFormElementsByName($name);
* Version 0.1, 14.06.2008 (API change: do use this function instead of getFormElementsByType()!)<br />
* Version 0.2, 12.12.2012 (Refactoring due to tag renaming)<br />
*/
public function getFormElementsByTagName($tagName);
public function getFormElementsByTagName(string $tagName);

/**
* Returns a list of form elements addressed by their implementation class name.
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getFormElementsByType(string $class): array;
* @version
* Version 0.1, 03.09.2008<br />
*/
public function getMarker($markerName);
public function getMarker(string $markerName);

/**
* Returns a reference on the form element identified by the given name.
Expand All @@ -115,7 +115,7 @@ public function getMarker($markerName);
* Version 0.1, 07.01.2007<br />
* Version 0.2, 12.09.2009 (Corrected debug message)<br />
*/
public function getFormElementByName($name);
public function getFormElementByName(string $name);

/**
* Let's you retrieve an &lt;form:getstring /&gt; tag instance with the specified name.
Expand All @@ -129,6 +129,6 @@ public function getFormElementByName($name);
* @version
* Version 0.1, 17.01.2012<br />
*/
public function getLabel($name);
public function getLabel(string $name);

}
2 changes: 2 additions & 0 deletions tools/form/FormElement.php
Expand Up @@ -63,6 +63,8 @@ public function isValid();
* <p/>
* What happens when resetting a form control is up to the dedicated implementation.
*
* @return $this This instance for further usage.
*
* @author Christian Achatz
* @version
* Version 0.1, 06.09.2014 (ID#206: Added interface enhancement to allow resetting)<br />
Expand Down
4 changes: 2 additions & 2 deletions tools/form/FormMarker.php
Expand Up @@ -41,7 +41,7 @@ interface FormMarker {
* @version
* Version 0.1, 23.08.2014<br />
*/
public function addContentAfter($content);
public function addContentAfter(string $content);

/**
* Allows you to add content (e.g. HTML, text) BEFORE the form marker.
Expand All @@ -54,5 +54,5 @@ public function addContentAfter($content);
* @version
* Version 0.1, 23.08.2014<br />
*/
public function addContentBefore($content);
public function addContentBefore(string $content);
}
2 changes: 2 additions & 0 deletions tools/form/HtmlForm.php
Expand Up @@ -110,6 +110,8 @@ public static function clearModelToFormControlMapper();
*
* @param string $action The action URL of the form.
*
* @return $this This instance for further usage.
*
* @author Christian Schäfer
* @version
* Version 0.1, 07.01.2007<br />
Expand Down
12 changes: 6 additions & 6 deletions tools/form/mixin/FormControlFinder.php
Expand Up @@ -46,7 +46,7 @@ trait FormControlFinder {
* @return FormControl A reference on the form element.
* @throws FormException In case the form element cannot be found.
*/
public function getFormElementByID($id) {
public function getFormElementByID(string $id) {

if (count($this->children) > 0) {
foreach ($this->children as &$child) {
Expand Down Expand Up @@ -89,7 +89,7 @@ public function getFormElementByID($id) {
* @return DynamicFormElementMarkerTag|DomNode The marker.
* @throws FormException In case the marker cannot be found.
*/
public function getMarker($markerName) {
public function getMarker(string $markerName) {
return $this->getFormElementByName($markerName);
}

Expand All @@ -99,7 +99,7 @@ public function getMarker($markerName) {
* @return FormControl A reference on the form element.
* @throws FormException In case the form element cannot be found.
*/
public function getFormElementByName($name) {
public function getFormElementByName(string $name) {

if (count($this->children) > 0) {
foreach ($this->children as &$child) {
Expand Down Expand Up @@ -142,7 +142,7 @@ public function getFormElementByName($name) {
* @return LanguageLabelTag The instance of the desired label.
* @throws FormException In case no label can be found.
*/
public function getLabel($name) {
public function getLabel(string $name) {
if (count($this->children) > 0) {
foreach ($this->children as &$child) {

Expand Down Expand Up @@ -183,7 +183,7 @@ public function getLabel($name) {
*
* @return FormControl[] The list of form controls with the given name.
*/
public function getFormElementsByName($name) {
public function getFormElementsByName(string $name) {
$elements = [];
if (count($this->children) > 0) {
foreach ($this->children as &$child) {
Expand All @@ -209,7 +209,7 @@ public function getFormElementsByName($name) {
* @return FormControl[] A list of references on the form elements.
* @throws FormException In case the form element cannot be found or desired tag is not registered.
*/
public function getFormElementsByTagName($tagName) {
public function getFormElementsByTagName(string $tagName) {

/* @var $form HtmlFormTag */
if ($this instanceof HtmlForm) {
Expand Down
6 changes: 3 additions & 3 deletions tools/form/multifileupload/biz/MultiFileUploadManager.php
Expand Up @@ -168,7 +168,7 @@ private function checkSessionFiles() {
* @param array $file
* @param boolean $js True, in case of java script upload, false otherwise.
*
* @return boolean
* @return boolean|array
* @throws FormException
*
* @author Werner Liemberger <wpublicmail@gmail.com>
Expand Down Expand Up @@ -311,7 +311,7 @@ private function getFileLink($uploadname) {
* @param string $dir - Zielverzeichnis
* @param string $name - Zieldateiname
*
* @return File::moveTo
* @return bool
*
* @author Werner Liemberger <wpublicmail@gmail.com>
* @version 1.0, 14.03.2011<br>
Expand Down Expand Up @@ -381,7 +381,7 @@ public function getFiles() {
*
* @param string $uploadname - Dateiname
*
* @return array
* @return mixed
*
* @author Werner Liemberger <wpublicmail@gmail.com>
* @version 1.0, 14.3.2011<br>
Expand Down
18 changes: 10 additions & 8 deletions tools/form/multifileupload/pres/taglib/MultiFileUploadTag.php
Expand Up @@ -174,8 +174,8 @@ public function transform() {
*/
private function createUploadButton() {
return '<div id="' . $this->uploadFieldName . '_file_upload_container"><input type="file" name="' . $this->uploadFieldName . '" id="' . $this->uploadFieldName . '" multiple="multiple" /><button>'
. $this->languageConfig->getValue('upload.button.label') . '</button><div class="uploadlabel">'
. $this->languageConfig->getValue('upload.label') . '</div></div>';
. $this->languageConfig->getValue('upload.button.label') . '</button><div class="uploadlabel">'
. $this->languageConfig->getValue('upload.label') . '</div></div>';
}

/**
Expand All @@ -188,8 +188,8 @@ private function createUploadButton() {
*/
private function createDialogFileDelete() {
return '<div class="confirm_delete ui-dialog-content ui-widget-content dialog_confirm_delete" title="'
. $this->languageConfig->getValue('delete.title') . '">'
. $this->languageConfig->getValue('delete.message') . '</div>';
. $this->languageConfig->getValue('delete.title') . '">'
. $this->languageConfig->getValue('delete.message') . '</div>';
}

/**
Expand All @@ -202,8 +202,8 @@ private function createDialogFileDelete() {
*/
private function createDialogFileSize() {
return '<div class="filesize_dialog ui-dialog-content ui-widget-content" title="'
. $this->languageConfig->getValue('filesize.title') . '">'
. $this->languageConfig->getValue('filesize.message') . ' ' . $this->manager->getMaxFileSizeWithUnit() . '</div>';
. $this->languageConfig->getValue('filesize.title') . '">'
. $this->languageConfig->getValue('filesize.message') . ' ' . $this->manager->getMaxFileSizeWithUnit() . '</div>';
}

/**
Expand All @@ -216,8 +216,8 @@ private function createDialogFileSize() {
*/
private function createDialogFileType() {
return '<div class="filetype_dialog ui-dialog-content ui-widget-content" title="'
. $this->languageConfig->getValue('filetype.title') . '">'
. $this->languageConfig->getValue('filetype.message') . ' ' . $this->createFileExtensionFromMimeType($this->manager->getMimeTypes()) . '</div>';
. $this->languageConfig->getValue('filetype.title') . '">'
. $this->languageConfig->getValue('filetype.message') . ' ' . $this->createFileExtensionFromMimeType($this->manager->getMimeTypes()) . '</div>';
}

/**
Expand Down Expand Up @@ -566,6 +566,8 @@ public function reset() {
$this->manager->deleteFile($file);
$this->manager->deleteFileFromSession($file);
}

return $this;
}

}
2 changes: 1 addition & 1 deletion tools/form/provider/csrf/CSRFHashProvider.php
Expand Up @@ -41,6 +41,6 @@ interface CSRFHashProvider {
* @version
* Version 0.1, 06.11.2010
*/
public function generateHash($salt);
public function generateHash(string $salt);

}
2 changes: 1 addition & 1 deletion tools/form/provider/csrf/EncryptedSIDHashProvider.php
Expand Up @@ -42,7 +42,7 @@ class EncryptedSIDHashProvider extends APFObject implements CSRFHashProvider {
* @version
* Version 0.1, 29.10.2010
*/
public function generateHash($salt) {
public function generateHash(string $salt) {
if (!defined('SID')) {
session_start();
}
Expand Down
6 changes: 4 additions & 2 deletions tools/form/taglib/AbstractFormControl.php
Expand Up @@ -312,6 +312,8 @@ public function isSent() {
public function reset() {
// reset value attribute as basic implementation as it applies in several cases
$this->setAttribute('value', '');

return $this;
}

public function isChecked() {
Expand Down Expand Up @@ -391,7 +393,7 @@ public function addValidator(FormValidator $validator) {
return $this;
}

public function addAttributeToWhiteList($name) {
public function addAttributeToWhiteList(string $name) {
$this->attributeWhiteList[] = $name;

return $this;
Expand All @@ -403,7 +405,7 @@ public function addAttributesToWhiteList(array $names) {
return $this;
}

public function appendCssClass($class) {
public function appendCssClass(string $class) {
$this->addAttribute('class', $class, ' ');

return $this;
Expand Down
1 change: 1 addition & 0 deletions tools/form/taglib/ButtonTag.php
Expand Up @@ -105,6 +105,7 @@ public function transform() {

public function reset() {
// nothing to do as buttons contain no user input.
return $this;
}

}
2 changes: 2 additions & 0 deletions tools/form/taglib/CheckBoxTag.php
Expand Up @@ -82,6 +82,8 @@ public function transform() {

public function reset() {
$this->uncheck();

return $this;
}

}
2 changes: 2 additions & 0 deletions tools/form/taglib/DateSelectorTag.php
Expand Up @@ -484,6 +484,8 @@ public function reset() {
$this->getYearControl()->reset();
$this->getMonthControl()->reset();
$this->getDayControl()->reset();

return $this;
}

}
5 changes: 3 additions & 2 deletions tools/form/taglib/DynamicFormElementMarkerTag.php
Expand Up @@ -40,7 +40,7 @@ public function transform() {
return '';
}

public function addContentBefore($content) {
public function addContentBefore(string $content) {
$objectId = $this->getObjectId();
$this->getParent()->setContent(str_replace(
'<' . $objectId . ' />',
Expand All @@ -51,7 +51,7 @@ public function addContentBefore($content) {
return $this;
}

public function addContentAfter($content) {
public function addContentAfter(string $content) {
$objectId = $this->getObjectId();
$this->getParent()->setContent(str_replace(
'<' . $objectId . ' />',
Expand All @@ -64,6 +64,7 @@ public function addContentAfter($content) {

public function reset() {
// nothing to do as markers don't generate output
return $this;
}

}
2 changes: 2 additions & 0 deletions tools/form/taglib/FileUploadTag.php
Expand Up @@ -249,6 +249,8 @@ public function getFile() {

public function reset() {
unset($_FILES[$this->getAttribute('name')]);

return $this;
}

/**
Expand Down
1 change: 1 addition & 0 deletions tools/form/taglib/FormControlObserverBase.php
Expand Up @@ -66,6 +66,7 @@ public function transform() {

public function reset() {
// nothing to do as observer tags create no visible output
return $this;
}

/**
Expand Down

0 comments on commit 231133a

Please sign in to comment.