mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-12-17 18:30:39 +00:00
Simplify normalization of "params" key
The isset() check was odd and confusing. I think I added it in Ie572809 to be able to run the normalizer independend from the validator. But the "params" element is required anyway. It makes much more sense to enforce it in the normalizer as well. Even if this currently doesn't make a difference in real-world scenarios, it makes the code easier to read. Change-Id: If4eb2f3985c56146d74e760996ad983be12b921a
This commit is contained in:
parent
221efa374b
commit
db9c989e10
|
@ -30,13 +30,13 @@ class TemplateDataNormalizer {
|
|||
$data->sets ??= [];
|
||||
$data->maps ??= (object)[];
|
||||
$data->format ??= null;
|
||||
$data->params ??= (object)[];
|
||||
|
||||
$this->normaliseInterfaceText( $data->description );
|
||||
foreach ( $data->sets as $setObj ) {
|
||||
$this->normaliseInterfaceText( $setObj->label );
|
||||
}
|
||||
|
||||
if ( isset( $data->params ) ) {
|
||||
foreach ( $data->params as $param ) {
|
||||
if ( isset( $param->inherits ) && isset( $data->params->{ $param->inherits } ) ) {
|
||||
$parent = $data->params->{ $param->inherits };
|
||||
|
@ -52,7 +52,6 @@ class TemplateDataNormalizer {
|
|||
$this->normalizeParameter( $param );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizeParameter( stdClass $paramObj ): void {
|
||||
$paramObj->label ??= null;
|
||||
|
|
|
@ -341,7 +341,7 @@ class TemplateDataValidator {
|
|||
'array' );
|
||||
}
|
||||
|
||||
if ( !count( $setObj->params ) ) {
|
||||
if ( !$setObj->params ) {
|
||||
return Status::newFatal( 'templatedata-invalid-empty-array',
|
||||
"sets.{$setNr}.params" );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue