Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ZObjectFilterIsRunnable
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 pass
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * WikiLambda ZObject Authorization Filter: Is Runnable Function
4 *
5 * @file
6 * @ingroup Extensions
7 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
8 * @license MIT
9 */
10
11namespace MediaWiki\Extension\WikiLambda\Authorization;
12
13use MediaWiki\Extension\WikiLambda\Registry\ZTypeRegistry;
14use MediaWiki\Extension\WikiLambda\ZObjectContent\ZObjectContent;
15use MediaWiki\Extension\WikiLambda\ZObjects\ZTypedList;
16use MediaWiki\Title\Title;
17
18class ZObjectFilterIsRunnable implements ZObjectFilter {
19
20    /**
21     * ZObject filter that checks whether the edited function is a running function.
22     * A running function is that which has attached implementations.
23     *
24     * @param ZObjectContent $fromContent
25     * @param ZObjectContent $toContent
26     * @param Title $title
27     * @param array $args
28     * @return bool
29     */
30    public static function pass( $fromContent, $toContent, $title, $args = [] ): bool {
31        $implementations = $fromContent
32            ->getInnerZObject()
33            ->getValueByKey( ZTypeRegistry::Z_FUNCTION_IMPLEMENTATIONS );
34        '@phan-var ZTypedList $implementations';
35        return !$implementations->isEmpty();
36    }
37}