WikiLambda
MediaWiki WikiLambda extension
Loading...
Searching...
No Matches
MediaWiki\Extension\WikiLambda\Diff\ZObjectListDiffer Class Reference
+ Inheritance diagram for MediaWiki\Extension\WikiLambda\Diff\ZObjectListDiffer:
+ Collaboration diagram for MediaWiki\Extension\WikiLambda\Diff\ZObjectListDiffer:

Public Member Functions

 setZObjectDiffer (ZObjectDiffer $zObjectDiffer)
 Setter for the differ service that will calculate the diffs for every idem of the list.
 
 doDiff (array $oldArray, array $newArray)
 

Member Function Documentation

◆ doDiff()

MediaWiki\Extension\WikiLambda\Diff\ZObjectListDiffer::doDiff ( array $oldArray,
array $newArray )
See also
Differ::doDiff

Compares the difference between two Typed Lists

Parameters
array$oldArrayThe first array
array$newArrayThe second array
Exceptions
Exception
Returns
DiffOp[]

TODO (T338250): According to T312259 the items in a list can be reordered.

Current implementation will find diffs between the items on the same position when the two lists have identical length.

If we want to find position changes and flag them as such, we should calculate the edit matrix also when the count of elements is the same in $newArray and $oldArray.

This would give us some matrix edit count like the following:

| 0 1 1 | | 1 1 0 | | 1 0 1 |

Where the zero edits are not in the matrix diagonal. This would probably flag a couple of indexChange edits such as:

[ list.1, indexChange, [1, 2] ] [ list.2, indexChange, [2, 1] ]

However, this means that for equal length arrays the complexity of finding a diff would directly go from O(n) to O(n2).

◆ setZObjectDiffer()

MediaWiki\Extension\WikiLambda\Diff\ZObjectListDiffer::setZObjectDiffer ( ZObjectDiffer $zObjectDiffer)

Setter for the differ service that will calculate the diffs for every idem of the list.

Parameters
ZObjectDiffer$zObjectDiffer

The documentation for this class was generated from the following file: