@@ -43,95 +43,95 @@ |
||
43 | 43 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
44 | 44 | |
45 | 45 | /** @return mixed */ |
46 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
46 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
47 | 47 | $services ??= MediaWikiServices::getInstance(); |
48 | - return $services->getService( $name ); |
|
48 | + return $services->getService($name); |
|
49 | 49 | } |
50 | 50 | |
51 | - public static function getLogger( ?MediaWikiServices $services = null ): LoggerInterface { |
|
52 | - return self::getService( $services, self::LOGGER ); |
|
51 | + public static function getLogger(?MediaWikiServices $services = null): LoggerInterface { |
|
52 | + return self::getService($services, self::LOGGER); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
56 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
55 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
56 | + return self::getService($services, self::LOGGING_HELPER); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function getConstraintStore( |
60 | 60 | ?MediaWikiServices $services = null |
61 | 61 | ): ConstraintStore { |
62 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
62 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
63 | 63 | } |
64 | 64 | |
65 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
66 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
65 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
66 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function getCheckResultSerializer( |
70 | 70 | ?MediaWikiServices $services = null |
71 | 71 | ): CheckResultSerializer { |
72 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
72 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function getCheckResultDeserializer( |
76 | 76 | ?MediaWikiServices $services = null |
77 | 77 | ): CheckResultDeserializer { |
78 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
78 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public static function getViolationMessageSerializer( |
82 | 82 | ?MediaWikiServices $services = null |
83 | 83 | ): ViolationMessageSerializer { |
84 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
84 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public static function getViolationMessageDeserializer( |
88 | 88 | ?MediaWikiServices $services = null |
89 | 89 | ): ViolationMessageDeserializer { |
90 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
90 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public static function getConstraintParameterParser( |
94 | 94 | ?MediaWikiServices $services = null |
95 | 95 | ): ConstraintParameterParser { |
96 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
96 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public static function getConnectionCheckerHelper( |
100 | 100 | ?MediaWikiServices $services = null |
101 | 101 | ): ConnectionCheckerHelper { |
102 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
102 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
103 | 103 | } |
104 | 104 | |
105 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
106 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
105 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
106 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
107 | 107 | } |
108 | 108 | |
109 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
110 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
109 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
110 | + return self::getService($services, self::SPARQL_HELPER); |
|
111 | 111 | } |
112 | 112 | |
113 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
114 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
113 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
114 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function getDelegatingConstraintChecker( |
118 | 118 | ?MediaWikiServices $services = null |
119 | 119 | ): DelegatingConstraintChecker { |
120 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
120 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
121 | 121 | } |
122 | 122 | |
123 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
124 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
123 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
124 | + return self::getService($services, self::RESULTS_SOURCE); |
|
125 | 125 | } |
126 | 126 | |
127 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
128 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
127 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
128 | + return self::getService($services, self::EXPIRY_LOCK); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | public static function getViolationMessageRendererFactory( |
132 | 132 | ?MediaWikiServices $services = null |
133 | 133 | ): ViolationMessageRendererFactory { |
134 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
134 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | * then using the main DBLoadBalancer service may be incorrect. |
25 | 25 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
26 | 26 | */ |
27 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
27 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
28 | 28 | $this->lb = $lb; |
29 | 29 | $this->dbName = $dbName; |
30 | 30 | } |
31 | 31 | |
32 | - private function encodeConstraintParameters( array $constraintParameters ): string { |
|
33 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
32 | + private function encodeConstraintParameters(array $constraintParameters): string { |
|
33 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
34 | 34 | |
35 | - if ( strlen( $json ) > 50000 ) { |
|
36 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
35 | + if (strlen($json) > 50000) { |
|
36 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $json; |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @throws DBUnexpectedError |
46 | 46 | */ |
47 | - public function insertBatch( array $constraints ) { |
|
48 | - if ( !$constraints ) { |
|
47 | + public function insertBatch(array $constraints) { |
|
48 | + if (!$constraints) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $accumulator = array_map( |
53 | - function ( Constraint $constraint ) { |
|
53 | + function(Constraint $constraint) { |
|
54 | 54 | return [ |
55 | 55 | 'constraint_guid' => $constraint->getConstraintId(), |
56 | 56 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
57 | 57 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
58 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ), |
|
58 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()), |
|
59 | 59 | ]; |
60 | 60 | }, |
61 | 61 | $constraints |
62 | 62 | ); |
63 | 63 | |
64 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
64 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
65 | 65 | $dbw->newInsertQueryBuilder() |
66 | - ->insertInto( 'wbqc_constraints' ) |
|
67 | - ->rows( $accumulator ) |
|
68 | - ->caller( __METHOD__ ) |
|
66 | + ->insertInto('wbqc_constraints') |
|
67 | + ->rows($accumulator) |
|
68 | + ->caller(__METHOD__) |
|
69 | 69 | ->execute(); |
70 | 70 | } |
71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @throws DBUnexpectedError |
78 | 78 | */ |
79 | - public function deleteForProperty( NumericPropertyId $propertyId ) { |
|
80 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
79 | + public function deleteForProperty(NumericPropertyId $propertyId) { |
|
80 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
81 | 81 | $dbw->newDeleteQueryBuilder() |
82 | - ->deleteFrom( 'wbqc_constraints' ) |
|
83 | - ->where( [ |
|
82 | + ->deleteFrom('wbqc_constraints') |
|
83 | + ->where([ |
|
84 | 84 | 'pid' => $propertyId->getNumericId(), |
85 | - ] ) |
|
86 | - ->caller( __METHOD__ ) |
|
85 | + ]) |
|
86 | + ->caller(__METHOD__) |
|
87 | 87 | ->execute(); |
88 | 88 | } |
89 | 89 |