Skip to content

Commit

Permalink
Code doc with psalm, and manual changes.
Browse files Browse the repository at this point in the history
psalm configuration was also updated to remove warnings.
  • Loading branch information
HugoFara committed Apr 1, 2024
1 parent 1f5d309 commit 4379b7e
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion do_test_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function do_test_get_identifier($selection, $sess_testsql, $lang, $text): array
*
* @return string SQL projection (selection) string
*/
function do_test_get_test_sql($selection, $sess_testsql, $lang, $text)
function do_test_get_test_sql($selection, $sess_testsql, $lang, $text): string
{
$identifier = do_test_get_identifier($selection, $sess_testsql, $lang, $text);
$testsql = do_test_test_get_projection($identifier[0], $identifier[1]);
Expand Down
5 changes: 3 additions & 2 deletions do_text_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,9 @@ function do_text_text_content($textid, $only_body = true): void
}

/*
* Uncoment to use as a page, deprecated behavior in LWT-fork, will be removed in 3.0.0
if (isset($_REQUEST['text'])) {
Uncoment to use as a page, deprecated behavior in LWT-fork, will be removed in 3.0.0
if (isset($_REQUEST['text'])) {
do_text_text_content($_REQUEST['text'], false);
}
*/
Expand Down
2 changes: 1 addition & 1 deletion edit_archivedtexts.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Manage archived texts
*
* Call: edit_archivedtexts.php?....
Expand Down
3 changes: 2 additions & 1 deletion edit_languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ function load_language($lgid)
return $language;
}

function edit_languages_displayThirdPartyVoiceAPI() {
function edit_languages_displayThirdPartyVoiceAPI(): void
{
?>
<h2>Third-Party Voice API</h2>
<p>
Expand Down
2 changes: 1 addition & 1 deletion edit_tags.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Manage tags
*
* Call: edit_tags.php?....
Expand Down
2 changes: 1 addition & 1 deletion edit_texttags.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Manage tags
*
* Call: edit_texttags.php?....
Expand Down
5 changes: 1 addition & 4 deletions edit_word.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,7 @@ function change_term_display($wid, $translation, $hex): void
}

// INS/UPD
/*
* @return void
*/
function edit_word_do_operation($translation, $fromAnn)
function edit_word_do_operation($translation, $fromAnn): void
{
$hex = null;
$textlc = trim(prepare_textdata($_REQUEST["WoTextLC"]));
Expand Down
13 changes: 6 additions & 7 deletions ggl.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

/*
* \file
* \brief Google Translate interface
/**
* Google Translate interface
*
* Call: ggl.php?text=[text]&sl=[source language]&tl=[target language] ... translate text
* ... sent=[int] ... single sentence mode.
Expand All @@ -26,7 +25,7 @@

use function Lwt\Includes\getGoogleTimeToken;

/*
/**
* Translate a single sentence using Google Translate.
*
* @param string $text Text to translate
Expand All @@ -46,7 +45,7 @@ function translate_sentence($text, $translation): void
<?php
}

/*
/**
* Translate input text using Google Translate.
*
* @param string $text Text to translate
Expand Down Expand Up @@ -110,7 +109,7 @@ function translate_term($text, $file, $sl, $tl): void
<?php
}

/*
/**
* Translate input text using Google Translate.
*
* @param string $text Text to translate
Expand Down Expand Up @@ -147,7 +146,7 @@ function translate_text($text, $sl, $tl, $sentence_mode): void
echo $gglink;
}

/*
/**
* Translate input text using Google Translate.
*
* @param string $text Text to translate
Expand Down
2 changes: 1 addition & 1 deletion glosbe_api.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Call Glosbe Translation API, analyze and present JSON results
* for easily filling the "new word form"
*
Expand Down
6 changes: 2 additions & 4 deletions inc/database_connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,6 @@ function (k,v) {
*
* @param int[] $wl All the different expression length in the language.
*
* @return string SQL-formatted query string
*
* @global string $tbpref Database table prefix
*/
function checkExpressions($wl): void
Expand Down Expand Up @@ -1818,7 +1816,7 @@ function update_database($dbname)
}


/*
/**
* Add a prefix to table in a SQL query string.
*
* @param string $sql_line SQL string to prefix.
Expand Down Expand Up @@ -2160,7 +2158,7 @@ function get_database_prefixes(&$tbpref)
}

/**
* @var mysqli $DBCONNECTION Connection to the database
* @var \mysqli $DBCONNECTION Connection to the database
*/
$DBCONNECTION = connect_to_database(
$server, $userid, $passwd, $dbname, $socket ?? ""
Expand Down
24 changes: 13 additions & 11 deletions inc/session_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,19 +726,19 @@ function get_selected($value, $selval): string

/**
* Create a projection operator do perform word test.
*
*
* @param string $key Type of test.
* - 'words': selection from words
* - 'texts': selection from texts
* - 'lang': selection from language
* - 'text': selection from single text
* @param array|int $value Object to select.
*
*
* @return string SQL projection necessary
*
*
* @global string $tbpref
*/
function do_test_test_get_projection($key, $value)
function do_test_test_get_projection($key, $value): string
{
global $tbpref;
$testsql = null;
Expand Down Expand Up @@ -2202,7 +2202,7 @@ function textwordcount($textID): void
*
* @param int $textid Text ID
*
* @return string HTML result
* @return int Number of words
*
* @global string $tbpref
*/
Expand Down Expand Up @@ -2769,11 +2769,11 @@ function getScriptDirectionTag($lid): string
* @param string|int $lid Language ID
* @param int $len Number of words in the expression
*
* @return (string|int)[] Each found multi-word details
* @return (int|string)[][] Each found multi-word details
*
* @global string $tbpref Table name prefix
*
* @psalm-return list{array<int, string>, list{0?: string,...}}
* @psalm-return list{0?: array{SeID: int, TxID: int, position: int, term: string},...}
*/
function findMecabExpression($text, $lid): array
{
Expand Down Expand Up @@ -2935,9 +2935,11 @@ function insertExpressionFromMeCab($textlc, $lid, $wid, $len, $mode): array
* @param string $textlc Text to insert in lower case
* @param string|int $lid Language ID
*
* @return (string|int)[] Each inserted mutli-word details
* @return (int|null|string)[][] Each inserted mutli-word details
*
* @global string $tbpref Table name prefix
*
* @psalm-return list{0?: array{SeID: int, SeTxID: int, position: int, term: null|string, term_display: null|string},...}
*/
function findStandardExpression($textlc, $lid): array
{
Expand Down Expand Up @@ -3587,12 +3589,12 @@ function create_save_ann($textid): string

/**
* Truncate the database, remove all data belonging by the current user.
*
*
* Keep settings.
*
*
* @global $tbpref
*/
function truncateUserDatabase()
function truncateUserDatabase(): void
{
global $tbpref;
runsql("TRUNCATE {$tbpref}archivedtexts", '');
Expand Down
2 changes: 1 addition & 1 deletion inline_edit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Call: inline_edit.php?...
* ...
*
Expand Down
2 changes: 1 addition & 1 deletion install_demo.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Install LWT Demo Database
*
* Call: install_demo.php
Expand Down
2 changes: 1 addition & 1 deletion new_word.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* New word, created while reading or testing
*
* Call: new_word.php?...
Expand Down
2 changes: 1 addition & 1 deletion print_text.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Print a text
*
* Call: print_text.php?text=[textid]&...
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<psalm
errorLevel="4"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
Expand Down
2 changes: 1 addition & 1 deletion set_word_on_hover.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* PHP version 8.1
*
* @category Helper_Frame
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Preferences / Settings
*
* Call: settings.php?....
Expand Down
2 changes: 1 addition & 1 deletion show_word.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Show term
*
* Call: show_word.php?wid=...&ann=...
Expand Down
2 changes: 1 addition & 1 deletion src/js/audio_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @license Unlicense
*/

/*
/**
* An audio controller.
*/
const lwt_audio_controller = {
Expand Down
2 changes: 1 addition & 1 deletion statistics.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Display statistics
*
* Call: statistics.php
Expand Down
2 changes: 1 addition & 1 deletion table_set_management.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

/*
/**
* Analyse DB tables, and manage Table Sets
*
* Call: table_set_management.php
Expand Down

0 comments on commit 4379b7e

Please sign in to comment.