Skip to content

Commit 54e8b26

Browse files
author
HugoFara
committed
chore(backend): removes deprecated functions.
1 parent bfbad50 commit 54e8b26

File tree

13 files changed

+36
-420
lines changed

13 files changed

+36
-420
lines changed

.psalm/stubs.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,6 @@ function getVersionNumber(): string {}
7373
// They delegate to namespaced implementations.
7474
// =============================================================================
7575

76-
// ---------------------------------------------------------------------------
77-
// From TextParsingService.php (global namespace section)
78-
// ---------------------------------------------------------------------------
79-
80-
/**
81-
* @param array $matches
82-
* @param string $noSentenceEnd
83-
* @return string
84-
* @see \Lwt\Services\TextParsingService::findLatinSentenceEnd()
85-
*/
86-
function find_latin_sentence_end($matches, $noSentenceEnd): string {}
87-
88-
// ---------------------------------------------------------------------------
89-
// From MediaService.php (global namespace section)
90-
// ---------------------------------------------------------------------------
91-
9276
// ---------------------------------------------------------------------------
9377
// From ExportService.php / export_helpers.php
9478
// ---------------------------------------------------------------------------
@@ -102,19 +86,6 @@ function find_latin_sentence_end($matches, $noSentenceEnd): string {}
10286
*/
10387
function getWordTagList(int $wid, string $before = ' ', int $brack = 1, int $tohtml = 1): string {}
10488

105-
/**
106-
* @param string $s
107-
* @param string $regexword
108-
* @return string
109-
*/
110-
function maskTermInSentence($s, $regexword): string {}
111-
112-
/**
113-
* @param string $s
114-
* @return string
115-
*/
116-
function replTabNl($s): string {}
117-
11889
/**
11990
* @param string $ann
12091
* @return string|false

phpdoc.dist.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
<path>.</path>
1616
</source>
1717
<ignore hidden="true" symlinks="true">
18-
<path>vendor</path>
18+
<path>vendor/*</path>
19+
<path>.psalm/*</path>
1920
</ignore>
2021
<default-package-name>Lwt</default-package-name>
2122
</api>

src/backend/Core/Database/TextParsing.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515

1616
namespace Lwt\Database;
1717

18-
require_once __DIR__ . '/../../Services/TextParsingService.php';
19-
2018
use Lwt\Core\Globals;
2119
use Lwt\Core\StringUtils;
2220
use Lwt\Core\Utils\ErrorHandler;
2321
use Lwt\Database\QueryBuilder;
2422
use Lwt\Database\UserScopedQuery;
23+
use Lwt\Services\TextParsingService;
2524

2625
/**
2726
* Text parsing and processing utilities.
@@ -514,13 +513,10 @@ private static function applyWordSplitting(
514513
string $termchar
515514
): string {
516515
// "\r" => Sentence delimiter, "\t" and "\n" => Word delimiter
516+
$service = new TextParsingService();
517517
$text = preg_replace_callback(
518518
"/(\S+)\s*((\.+)|([$splitSentence]))([]'`\"”)‘’‹›“„«»』」]*)(?=(\s*)(\S+|$))/u",
519-
// Arrow functions were introduced in PHP 7.4
520-
//fn ($matches) => find_latin_sentence_end($matches, $noSentenceEnd)
521-
function ($matches) use ($noSentenceEnd) {
522-
return \find_latin_sentence_end($matches, $noSentenceEnd);
523-
},
519+
fn ($matches) => $service->findLatinSentenceEnd($matches, $noSentenceEnd),
524520
$text
525521
);
526522
// Paragraph delimiters become a combination of ¶ and carriage return \r

src/backend/Services/ExportService.php

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -427,98 +427,3 @@ private function sendDownloadResponse(string $content, string $filename): never
427427
}
428428

429429
} // End namespace Lwt\Services
430-
431-
// =============================================================================
432-
// Legacy Function Wrappers (for backward compatibility)
433-
// =============================================================================
434-
435-
namespace {
436-
437-
use Lwt\Services\ExportService;
438-
439-
/**
440-
* Export terms to Anki format.
441-
*
442-
* @param string $sql SQL query to retrieve terms
443-
*
444-
* @return never
445-
*
446-
* @deprecated Use ExportService::exportAnki() instead
447-
*/
448-
function ankiExport(string $sql)
449-
{
450-
(new ExportService())->exportAnki($sql);
451-
}
452-
453-
/**
454-
* Export terms to TSV format.
455-
*
456-
* @param string $sql SQL query to retrieve terms
457-
*
458-
* @return never
459-
*
460-
* @deprecated Use ExportService::exportTsv() instead
461-
*/
462-
function tsvExport(string $sql)
463-
{
464-
(new ExportService())->exportTsv($sql);
465-
}
466-
467-
/**
468-
* Export terms using flexible template.
469-
*
470-
* @param string $sql SQL query to retrieve terms
471-
*
472-
* @return never
473-
*
474-
* @deprecated Use ExportService::exportFlexible() instead
475-
*/
476-
function flexibleExport(string $sql)
477-
{
478-
(new ExportService())->exportFlexible($sql);
479-
}
480-
481-
/**
482-
* Replace all whitespace characters with simple space.
483-
*
484-
* @param string $s String to parse
485-
*
486-
* @return string String with normalized whitespace
487-
*
488-
* @deprecated Use ExportService::replaceTabNewline() instead
489-
*/
490-
function replTabNl(string $s): string
491-
{
492-
return ExportService::replaceTabNewline($s);
493-
}
494-
495-
/**
496-
* Mask the term in a sentence by replacing characters with bullets.
497-
*
498-
* @param string $s Sentence with term marked by {} brackets
499-
* @param string $regexword Regex pattern for word characters
500-
*
501-
* @return string Sentence with term characters replaced by bullets
502-
*
503-
* @deprecated Use ExportService::maskTermInSentence() instead
504-
*/
505-
function maskTermInSentence(string $s, string $regexword): string
506-
{
507-
return ExportService::maskTermInSentence($s, $regexword);
508-
}
509-
510-
/**
511-
* Mask the term in a sentence by replacing it with "[...]".
512-
*
513-
* @param string $s Sentence with term marked by {} brackets
514-
*
515-
* @return string Sentence with term replaced by "[...]"
516-
*
517-
* @deprecated Use ExportService::maskTermInSentenceV2() instead
518-
*/
519-
function maskTermInSentenceV2(string $s): string
520-
{
521-
return ExportService::maskTermInSentenceV2($s);
522-
}
523-
524-
} // End global namespace

src/backend/Services/SentenceService.php

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -758,78 +758,6 @@ public function renderExampleSentencesArea(int $lang, string $termlc, string $ta
758758

759759
use Lwt\Services\SentenceService;
760760

761-
/**
762-
* Return a SQL string to find sentences containing a word.
763-
*
764-
* @param string $wordlc Word to look for in lowercase
765-
* @param int $lid Language ID
766-
*
767-
* @return string Query in SQL format
768-
*
769-
* @see SentenceService::buildSentencesContainingWordQuery()
770-
*/
771-
function sentencesContainingWordLcQuery(string $wordlc, int $lid): string
772-
{
773-
$service = new SentenceService();
774-
return $service->buildSentencesContainingWordQuery($wordlc, $lid);
775-
}
776-
777-
778-
/**
779-
* Perform a SQL query to find sentences containing a word.
780-
*
781-
* @param int|null $wid Word ID or mode
782-
* @param string $wordlc Word to look for in lowercase
783-
* @param int $lid Language ID
784-
* @param int $limit Maximum number of sentences to return
785-
*
786-
* @return \mysqli_result|false Query result or false on failure
787-
*
788-
* @see SentenceService::findSentencesFromWord()
789-
*/
790-
function sentencesFromWord(?int $wid, string $wordlc, int $lid, int $limit = -1): \mysqli_result|false
791-
{
792-
$service = new SentenceService();
793-
return $service->findSentencesFromWord($wid, $wordlc, $lid, $limit);
794-
}
795-
796-
/**
797-
* Format the sentence(s) $seid containing $wordlc highlighting $wordlc.
798-
*
799-
* @param int $seid Sentence ID
800-
* @param string $wordlc Term text in lower case
801-
* @param int $mode Mode for sentence context
802-
*
803-
* @return string[] [0]=html, word in bold, [1]=text, word in {}
804-
*
805-
* @see SentenceService::formatSentence()
806-
*/
807-
function getSentence(int $seid, string $wordlc, int $mode): array
808-
{
809-
$service = new SentenceService();
810-
return $service->formatSentence($seid, $wordlc, $mode);
811-
}
812-
813-
/**
814-
* Return sentences containing a word.
815-
*
816-
* @param int $lang Language ID
817-
* @param string $wordlc Word to look for in lowercase
818-
* @param int|null $wid Word ID
819-
* @param int|null $mode Sentences to get
820-
* @param int $limit Maximum number of sentences to return
821-
*
822-
* @return string[][] Array of sentences found
823-
*
824-
* @see SentenceService::getSentencesWithWord()
825-
*/
826-
function sentencesWithWord(int $lang, string $wordlc, ?int $wid, ?int $mode = 0, int $limit = 20): array
827-
{
828-
$service = new SentenceService();
829-
return $service->getSentencesWithWord($lang, $wordlc, $wid, $mode, $limit);
830-
}
831-
832-
833761
/**
834762
* Prepare the area for example sentences of a word.
835763
*
@@ -846,24 +774,4 @@ function exampleSentencesArea(int $lang, string $termlc, string $selector, int $
846774
echo $service->renderExampleSentencesArea($lang, $termlc, $selector, $wid);
847775
}
848776

849-
850-
/**
851-
* Show 20 sentences containing $wordlc.
852-
*
853-
* @param int $lang Language ID
854-
* @param string $wordlc Term in lower case.
855-
* @param int|null $wid Word ID
856-
* @param string $jsctlname Path for the textarea
857-
* @param int $mode Mode for sentence context
858-
*
859-
* @return string HTML-formatted string
860-
*
861-
* @see SentenceService::get20Sentences()
862-
*/
863-
function get20Sentences(int $lang, string $wordlc, ?int $wid, string $jsctlname, int $mode): string
864-
{
865-
$service = new SentenceService();
866-
return $service->get20Sentences($lang, $wordlc, $wid, $jsctlname, $mode);
867-
}
868-
869777
} // End global namespace

0 commit comments

Comments
 (0)