@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @codeCoverageIgnore This method is not supported. |
36 | 36 | */ |
37 | 37 | public function getType() { |
38 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
38 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function getEntityId() { |
@@ -46,35 +46,35 @@ discard block |
||
46 | 46 | * @codeCoverageIgnore This method is not supported. |
47 | 47 | */ |
48 | 48 | public function getStatementPropertyId() { |
49 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
49 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @codeCoverageIgnore This method is not supported. |
54 | 54 | */ |
55 | 55 | public function getStatementGuid() { |
56 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
56 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @codeCoverageIgnore This method is not supported. |
61 | 61 | */ |
62 | 62 | public function getSnakPropertyId() { |
63 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
63 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @codeCoverageIgnore This method is not supported. |
68 | 68 | */ |
69 | 69 | public function getSnakHash() { |
70 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
70 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * @codeCoverageIgnore This method is not supported. |
75 | 75 | */ |
76 | - public function &getMainArray( array &$container ) { |
|
77 | - throw new LogicException( 'EntityContextCursor cannot store check results' ); |
|
76 | + public function &getMainArray(array &$container) { |
|
77 | + throw new LogicException('EntityContextCursor cannot store check results'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | * @param array|null $result must be null |
84 | 84 | * @param array[] &$container |
85 | 85 | */ |
86 | - public function storeCheckResultInArray( array $result = null, array &$container ) { |
|
87 | - if ( $result !== null ) { |
|
88 | - throw new LogicException( 'EntityContextCursor cannot store check results' ); |
|
86 | + public function storeCheckResultInArray(array $result = null, array &$container) { |
|
87 | + if ($result !== null) { |
|
88 | + throw new LogicException('EntityContextCursor cannot store check results'); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // this ensures that the claims array is present in the $container, |
92 | 92 | // populating it if necessary, even though we ignore the return value |
93 | - $this->getClaimsArray( $container ); |
|
93 | + $this->getClaimsArray($container); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | } |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @param DatabaseUpdater $updater |
30 | 30 | */ |
31 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
32 | - $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' ); |
|
33 | - $updater->addExtensionField( 'wbqc_constraints', 'constraint_id', __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' ); |
|
31 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
32 | + $updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql'); |
|
33 | + $updater->addExtensionField('wbqc_constraints', 'constraint_id', __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql'); |
|
34 | 34 | } |
35 | 35 | |
36 | - public static function onWikibaseChange( Change $change ) { |
|
36 | + public static function onWikibaseChange(Change $change) { |
|
37 | 37 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
38 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
39 | - self::isConstraintStatementsChange( $config, $change ) |
|
38 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
39 | + self::isConstraintStatementsChange($config, $change) |
|
40 | 40 | ) { |
41 | 41 | /** @var EntityChange $change */ |
42 | 42 | $title = Title::newMainPage(); |
43 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
43 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
44 | 44 | JobQueueGroup::singleton()->push( |
45 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
45 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
51 | - if ( !( $change instanceof EntityChange ) || |
|
50 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
51 | + if (!($change instanceof EntityChange) || |
|
52 | 52 | $change->getAction() !== EntityChange::UPDATE || |
53 | - !( $change->getEntityId() instanceof PropertyId ) |
|
53 | + !($change->getEntityId() instanceof PropertyId) |
|
54 | 54 | ) { |
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $info = $change->getInfo(); |
59 | 59 | |
60 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
60 | + if (!array_key_exists('compactDiff', $info)) { |
|
61 | 61 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
62 | 62 | // so we only know that the change *might* affect the constraint statements |
63 | 63 | return true; |
@@ -66,19 +66,19 @@ discard block |
||
66 | 66 | /** @var EntityDiffChangedAspects $aspects */ |
67 | 67 | $aspects = $info['compactDiff']; |
68 | 68 | |
69 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
70 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
69 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
70 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
73 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
74 | 74 | $repo = WikibaseRepo::getDefaultInstance(); |
75 | 75 | |
76 | 76 | $entityContentFactory = $repo->getEntityContentFactory(); |
77 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
78 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
79 | - if ( $entityId !== null ) { |
|
77 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
78 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
79 | + if ($entityId !== null) { |
|
80 | 80 | $resultsCache = ResultsCache::getDefaultInstance(); |
81 | - $resultsCache->delete( $entityId ); |
|
81 | + $resultsCache->delete($entityId); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * @param int $timestamp UTC timestamp (seconds since the Epoch) |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public static function isGadgetEnabledForUserName( $userName, $timestamp ) { |
|
91 | + public static function isGadgetEnabledForUserName($userName, $timestamp) { |
|
92 | 92 | $initial = $userName[0]; |
93 | 93 | |
94 | - if ( $initial === 'Z' ) { |
|
94 | + if ($initial === 'Z') { |
|
95 | 95 | $firstWeek = 0; |
96 | - } elseif ( $initial >= 'W' && $initial < 'Z' ) { |
|
96 | + } elseif ($initial >= 'W' && $initial < 'Z') { |
|
97 | 97 | $firstWeek = 1; |
98 | - } elseif ( $initial >= 'T' && $initial < 'W' ) { |
|
98 | + } elseif ($initial >= 'T' && $initial < 'W') { |
|
99 | 99 | $firstWeek = 2; |
100 | - } elseif ( $initial >= 'N' && $initial < 'T' ) { |
|
100 | + } elseif ($initial >= 'N' && $initial < 'T') { |
|
101 | 101 | $firstWeek = 3; |
102 | - } elseif ( $initial >= 'E' && $initial < 'N' ) { |
|
102 | + } elseif ($initial >= 'E' && $initial < 'N') { |
|
103 | 103 | $firstWeek = 4; |
104 | 104 | } else { |
105 | 105 | $firstWeek = 5; |
@@ -117,29 +117,29 @@ discard block |
||
117 | 117 | return $timestamp >= $threshold; |
118 | 118 | } |
119 | 119 | |
120 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
120 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
121 | 121 | $repo = WikibaseRepo::getDefaultInstance(); |
122 | 122 | |
123 | 123 | $lookup = $repo->getEntityNamespaceLookup(); |
124 | 124 | $title = $out->getTitle(); |
125 | - if ( $title === null ) { |
|
125 | + if ($title === null) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
129 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
132 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
136 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
137 | 137 | |
138 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
138 | + if (!$out->getUser()->isLoggedIn()) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | - if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) { |
|
142 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
141 | + if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) { |
|
142 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param array &$vars |
149 | 149 | * @param OutputPage $out |
150 | 150 | */ |
151 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
151 | + public static function addVariables(&$vars, OutputPage $out) { |
|
152 | 152 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
153 | 153 | |
154 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
155 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
156 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
154 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
155 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
156 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | } |