* NEW: Add extrafields support to Link class
Link now declares isextrafieldmanaged and wires fetch_optionals()/
insertExtraFields()/deleteExtraFields() into fetch(), fetchAll(),
create(), update() and delete(), matching the llx_links_extrafields
table added previously.
* FIX: Several bugs in Link class review
- create(): wrong duplicate-record error message (copy-pasted from
Societe, referenced undefined $this->name) replaced by the generic
ErrorDuplicateField, consistent with update().
- create()/update(): missing "NoURL" translation key replaced by the
standard ErrorFieldRequired pattern.
- fetch(): guard against running an unfiltered query (no rowid, no
hashforshare) that could silently return an arbitrary link; a caller
in actions_linkedfiles.inc.php could hit this when 'linkid' was
missing from the request.
- actions_linkedfiles.inc.php: check fetch() result with `> 0` instead
of a truthy test, since -1 (error) is truthy in PHP.
- delete(): add User type hint (consistent with create()/update()) and
a $notrigger parameter to optionally skip the LINK_DELETE trigger.
- update(): fix copy-pasted docblock ("third party" -> "link").
* NEW: Add PHPUnit test for Link class
Covers create/fetch/update/fetchAll/count/delete, plus regression
tests for the two bugs fixed in the previous commit: create() rejects
an empty url, and fetch() rejects a call with neither rowid nor
hashforshare instead of returning an arbitrary record.
* FIX Phan false positive on $object in actions_linkedfiles.inc.php
Phan's ambient type inference for the loosely-typed global $object in
this shared include file was picking up CommonSocialNetworks (an
unrelated trait, not even a class), reported as undeclared
->id/->entity/->addThumbs()/->delThumbs() in a real CI Phan run on
this branch, once this file was analyzed on its own via the
changed-files file-list (this file has no prior baseline entry, so it
was apparently never previously exercised in isolation like this).
Force $object's type explicitly to CommonObject via the same
@phan-var-force string-literal idiom this file already uses for
$upload_dir/$upload_dirold/$confirm/$forceFullTextIndexation -
CommonObject genuinely declares addThumbs()/delThumbs(), which
resolves those two errors outright. $id/$entity remain reported as
PhanUndeclaredProperty (CommonObject itself does not declare them,
only its concrete subclasses do at runtime) - baseline-suppress that
for this file the same way it is already suppressed for the sibling
shared-include files actions_addupdatedelete.inc.php,
actions_massactions.inc.php and actions_sendmails.inc.php, which have
the exact same $object typing situation.
|
||
|---|---|---|
| .. | ||
| plugins | ||
| stubs | ||
| .gitignore | ||
| allow_phan_in_precommit.sh | ||
| baseline.txt | ||
| baseline_extended.txt | ||
| config.php | ||
| config_extended.php | ||
| config_fixer.php | ||
| PHAN.BAT | ||
| README.md | ||
| run-phan.sh | ||
| runPhanDocker.sh | ||
Static Code Checks using phan
Installation, running
run-phan.sh can install and run phan.
See instructions in run-phan.sh for installing (or just run it).
The configuration file in PROJECT_DIR/.phan/config.php also allows you to run
phan independently from the script.
Run options:
No option : Runs the minimum checks
Option 'full' : Runs all an extensive set of checks
Option '1' : Writes the baseline
Examples:
run-phan.shruns the default checksrun-phan.sh 1updates the baseline for the default checksrun-phan.sh fullruns the extended checksrun-phan.sh full 1updates the baseline for the extended checks
Baseline
The baseline.txt file in this directory defines the issues that are currently
excluded from the final report. In principle you should not add any more
exceptions to that file, but rather fix the issues or add phan annotations
that provide more information or to exclude specific cases.
Configuration
config.php : Default configuration file
config_extended.php : Configuration that enables more checks.
baseline.txt : Ignored issues (with config.php)
baseline_extended.txt : Ignored issues (with config_extended.php), not
currently in git