added type hinting

This commit is contained in:
Roland Gruber 2017-09-17 10:17:13 +02:00
parent 166c9b285a
commit d7f967352b
6 changed files with 30 additions and 28 deletions

View File

@ -177,7 +177,7 @@ $_SESSION['header'] .= "<meta http-equiv=\"pragma\" content=\"no-cache\">\n <me
* @param \LAM\ENV\LAMLicenseValidator $licenseValidator license validator
* @param string $error_message error message to display
*/
function display_LoginPage($config_object, $cfgMain, $licenseValidator, $error_message) {
function display_LoginPage(LAMConfig $config_object, LAMCfgMain $cfgMain, $licenseValidator, $error_message) {
logNewMessage(LOG_DEBUG, "Display login page");
// generate 256 bit key and initialization vector for user/passwd-encryption
if(function_exists('openssl_random_pseudo_bytes') && ($cfgMain->encryptSession == 'true')) {

View File

@ -15,6 +15,7 @@ use \htmlInputFileUpload;
use \htmlHelpLink;
use \htmlInputField;
use \htmlHiddenInput;
use \LAM\TYPES\TypeManager;
/*
$Id$
@ -89,7 +90,7 @@ if(isset($_POST['createNewTemplate'])) {
exit();
}
$typeManager = new \LAM\TYPES\TypeManager();
$typeManager = new TypeManager();
$types = $typeManager->getConfiguredTypes();
$sortedTypes = array();
foreach ($types as $type) {
@ -319,7 +320,7 @@ include '../main_header.php';
$scope = $templateClasses[$i]['scope'];
$importOptions = array();
foreach ($configProfiles as $profile) {
$typeManagerImport = new \LAM\TYPES\TypeManager($serverProfiles[$profile]);
$typeManagerImport = new TypeManager($serverProfiles[$profile]);
$typesImport = $typeManagerImport->getConfiguredTypesForScope($scope);
foreach ($typesImport as $typeImport) {
if (($profile != $_SESSION['config']->getName()) || ($typeImport->getId() != $typeId)) {
@ -374,7 +375,7 @@ include '../main_header.php';
$container->addElement(new htmlOutputText(_("Target server profile")), true);
$exportOptions = array();
foreach ($configProfiles as $profile) {
$typeManagerExport = new \LAM\TYPES\TypeManager($serverProfiles[$profile]);
$typeManagerExport = new TypeManager($serverProfiles[$profile]);
$typesExport = $typeManagerExport->getConfiguredTypesForScope($scope);
foreach ($typesExport as $typeExport) {
if (($profile != $_SESSION['config']->getName()) || ($typeExport->getId() != $typeId)) {
@ -430,15 +431,15 @@ include '../main_footer.php';
* @param string $typeId type id
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param \LAM\TYPES\TypeManager $typeManager type manager
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function importStructures($typeId, $options, &$serverProfiles, &$typeManager) {
function importStructures($typeId, $options, &$serverProfiles, TypeManager &$typeManager) {
foreach ($options as $option) {
$sourceConfName = $option['conf'];
$sourceTypeId = $option['typeId'];
$sourceName = $option['name'];
$sourceTypeManager = new \LAM\TYPES\TypeManager($serverProfiles[$sourceConfName]);
$sourceTypeManager = new TypeManager($serverProfiles[$sourceConfName]);
$sourceType = $sourceTypeManager->getConfiguredType($sourceTypeId);
$targetType = $typeManager->getConfiguredType($typeId);
if (($sourceType != null) && ($targetType != null)) {
@ -460,10 +461,10 @@ function importStructures($typeId, $options, &$serverProfiles, &$typeManager) {
* @param string $name profile name
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param \LAM\TYPES\TypeManager $typeManager type manager
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function exportStructures($typeId, $name, $options, &$serverProfiles, &$typeManager) {
function exportStructures($typeId, $name, $options, &$serverProfiles, TypeManager &$typeManager) {
$sourceType = $typeManager->getConfiguredType($typeId);
if ($sourceType == null) {
return null;
@ -480,7 +481,7 @@ function exportStructures($typeId, $name, $options, &$serverProfiles, &$typeMana
}
else {
$targetTypeId = $option['typeId'];
$targetTypeManager = new \LAM\TYPES\TypeManager($serverProfiles[$targetConfName]);
$targetTypeManager = new TypeManager($serverProfiles[$targetConfName]);
$targetType = $targetTypeManager->getConfiguredType($targetTypeId);
if ($targetType != null) {
try {

View File

@ -496,7 +496,7 @@ function translateFieldIDToName($id, $scope, $availablePDFFields) {
*
* @param PDFStructure $structure
*/
function updateBasicSettings(&$structure) {
function updateBasicSettings(PDFStructure &$structure) {
// set headline
if (isset($_POST['headline'])) {
$structure->setTitle(str_replace('<', '', str_replace('>', '', $_POST['headline'])));
@ -516,7 +516,7 @@ function updateBasicSettings(&$structure) {
*
* @param PDFStructure $structure
*/
function updateSectionTitles(&$structure) {
function updateSectionTitles(PDFStructure &$structure) {
$sections = $structure->getSections();
foreach ($_POST as $key => $value) {
if (strpos($key, 'section_') === 0) {
@ -531,7 +531,7 @@ function updateSectionTitles(&$structure) {
*
* @param PDFStructure $structure
*/
function addSection(&$structure) {
function addSection(PDFStructure &$structure) {
$sections = $structure->getSections();
// add a new text field
if(isset($_POST['add_text'])) {
@ -570,7 +570,7 @@ function addSection(&$structure) {
*
* @param PDFStructure $structure
*/
function addSectionEntry(&$structure) {
function addSectionEntry(PDFStructure &$structure) {
if(isset($_POST['add_new_field'])) {
$field = new PDFSectionEntry($_POST['new_field']);
$sections = $structure->getSections();
@ -587,7 +587,7 @@ function addSectionEntry(&$structure) {
*
* @param PDFStructure $structure
*/
function removeItem(&$structure) {
function removeItem(PDFStructure &$structure) {
$sections = $structure->getSections();
foreach ($_POST as $key => $value) {
// remove section
@ -617,7 +617,7 @@ function removeItem(&$structure) {
*
* @param PDFStructure $structure
*/
function moveUp(&$structure) {
function moveUp(PDFStructure &$structure) {
$sections = $structure->getSections();
foreach ($_POST as $key => $value) {
// move section
@ -649,7 +649,7 @@ function moveUp(&$structure) {
*
* @param PDFStructure $structure
*/
function moveDown(&$structure) {
function moveDown(PDFStructure &$structure) {
$sections = $structure->getSections();
foreach ($_POST as $key => $value) {
// move section

View File

@ -14,6 +14,7 @@ use \htmlOutputText;
use \htmlHelpLink;
use \htmlHiddenInput;
use \htmlInputField;
use \LAM\TYPES\TypeManager;
/*
$Id$
@ -67,7 +68,7 @@ if (!empty($_POST)) {
validateSecurityToken();
}
$typeManager = new \LAM\TYPES\TypeManager();
$typeManager = new TypeManager();
$types = $typeManager->getConfiguredTypes();
$profileClasses = array();
$profileClassesTemp = array();
@ -274,7 +275,7 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
$scope = $profileClasses[$i]['scope'];
$importOptions = array();
foreach ($configProfiles as $profile) {
$typeManagerImport = new \LAM\TYPES\TypeManager($serverProfiles[$profile]);
$typeManagerImport = new TypeManager($serverProfiles[$profile]);
$typesImport = $typeManagerImport->getConfiguredTypesForScope($scope);
foreach ($typesImport as $typeImport) {
if (($profile != $_SESSION['config']->getName()) || ($typeImport->getId() != $typeId)) {
@ -329,7 +330,7 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
$container->addElement(new htmlOutputText(_("Target server profile")), true);
$exportOptions = array();
foreach ($configProfiles as $profile) {
$typeManagerExport = new \LAM\TYPES\TypeManager($serverProfiles[$profile]);
$typeManagerExport = new TypeManager($serverProfiles[$profile]);
$typesExport = $typeManagerExport->getConfiguredTypesForScope($scope);
foreach ($typesExport as $typeExport) {
if (($profile != $_SESSION['config']->getName()) || ($typeExport->getId() != $typeId)) {
@ -385,15 +386,15 @@ include '../main_footer.php';
* @param string $typeId type id
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param \LAM\TYPES\TypeManager $typeManager type manager
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function importProfiles($typeId, $options, &$serverProfiles, &$typeManager) {
function importProfiles($typeId, $options, &$serverProfiles, TypeManager &$typeManager) {
foreach ($options as $option) {
$sourceConfName = $option['conf'];
$sourceTypeId = $option['typeId'];
$sourceName = $option['name'];
$sourceTypeManager = new \LAM\TYPES\TypeManager($serverProfiles[$sourceConfName]);
$sourceTypeManager = new TypeManager($serverProfiles[$sourceConfName]);
$sourceType = $sourceTypeManager->getConfiguredType($sourceTypeId);
$targetType = $typeManager->getConfiguredType($typeId);
if (($sourceType != null) && ($targetType != null)) {
@ -415,10 +416,10 @@ function importProfiles($typeId, $options, &$serverProfiles, &$typeManager) {
* @param string $name profile name
* @param array $options options
* @param \LAMConfig[] $serverProfiles server profiles (name => profile object)
* @param \LAM\TYPES\TypeManager $typeManager type manager
* @param TypeManager $typeManager type manager
* @return \htmlStatusMessage message or null
*/
function exportProfiles($typeId, $name, $options, &$serverProfiles, &$typeManager) {
function exportProfiles($typeId, $name, $options, &$serverProfiles, TypeManager &$typeManager) {
$sourceType = $typeManager->getConfiguredType($typeId);
if ($sourceType == null) {
return null;
@ -435,7 +436,7 @@ function exportProfiles($typeId, $name, $options, &$serverProfiles, &$typeManage
}
else {
$targetTypeId = $option['typeId'];
$targetTypeManager = new \LAM\TYPES\TypeManager($serverProfiles[$targetConfName]);
$targetTypeManager = new TypeManager($serverProfiles[$targetConfName]);
$targetType = $targetTypeManager->getConfiguredType($targetTypeId);
if ($targetType != null) {
try {

View File

@ -282,7 +282,7 @@ include '../main_footer.php';
* @param array $selectedModules selected modules for upload
* @param htmlTable $container table container
*/
function massPrintBackButton($typeId, $selectedModules, &$container) {
function massPrintBackButton($typeId, $selectedModules, htmlTable &$container) {
$backButton = new htmlButton('submit', _('Back'));
$backButton->setIconClass('backButton');
$container->addElement($backButton);

View File

@ -256,7 +256,7 @@ include '../main_footer.php';
* @param \LAM\TYPES\ConfiguredType $type account type
* @param array $selectedModules list of selected account modules
*/
function showMainPage($type, $selectedModules) {
function showMainPage(\LAM\TYPES\ConfiguredType $type, $selectedModules) {
$scope = $type->getScope();
echo '<div class="' . $scope . '-bright smallPaddingContent">';
// get input fields from modules