@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

In charts, make "min" and "max" into pure functions and formally mark pure functions as pure

Summary:
Depends on D20814. Currently, "min()" and "max()" are still "min(f, n)". This is no longer consistent with the construction of functions a function-generators that are composed at top level.

Turn them into "min(n)" and "max(n)" (i.e., not higher-order functions).

Then, mark all the functions which are pure mathematical functions and not higher-order as "pure". These functions have no function parameters and do not reference external data. For now, this distinction has no immediate implications, but it will simplify the next change (which tracks where data came from when it originated from an external source -- these pure functions never have any source information, since they only apply pure mathematical transformations to data).

Test Plan: Loaded a burnup chart, nothing seemed obviously broken.

Subscribers: yelirekim

Differential Revision: https://secure.phabricator.com/D20815

+48 -52
+9 -7
src/__phutil_library_map__.php
··· 4422 4422 'PhabricatorProjectsWatchersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsWatchersSearchEngineAttachment.php', 4423 4423 'PhabricatorPronounSetting' => 'applications/settings/setting/PhabricatorPronounSetting.php', 4424 4424 'PhabricatorProtocolLog' => 'infrastructure/log/PhabricatorProtocolLog.php', 4425 + 'PhabricatorPureChartFunction' => 'applications/fact/chart/PhabricatorPureChartFunction.php', 4425 4426 'PhabricatorPygmentSetupCheck' => 'applications/config/check/PhabricatorPygmentSetupCheck.php', 4426 4427 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', 4427 4428 'PhabricatorQueryConstraint' => 'infrastructure/query/constraint/PhabricatorQueryConstraint.php', ··· 9155 9156 'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting', 9156 9157 'PhabricatorConsoleApplication' => 'PhabricatorApplication', 9157 9158 'PhabricatorConsoleContentSource' => 'PhabricatorContentSource', 9158 - 'PhabricatorConstantChartFunction' => 'PhabricatorChartFunction', 9159 + 'PhabricatorConstantChartFunction' => 'PhabricatorPureChartFunction', 9159 9160 'PhabricatorContactNumbersSettingsPanel' => 'PhabricatorSettingsPanel', 9160 9161 'PhabricatorContentSource' => 'Phobject', 9161 9162 'PhabricatorContentSourceModule' => 'PhabricatorConfigModule', ··· 9167 9168 'PhabricatorCoreCreateTransaction' => 'PhabricatorCoreTransactionType', 9168 9169 'PhabricatorCoreTransactionType' => 'PhabricatorModularTransactionType', 9169 9170 'PhabricatorCoreVoidTransaction' => 'PhabricatorModularTransactionType', 9170 - 'PhabricatorCosChartFunction' => 'PhabricatorChartFunction', 9171 + 'PhabricatorCosChartFunction' => 'PhabricatorPureChartFunction', 9171 9172 'PhabricatorCountFact' => 'PhabricatorFact', 9172 9173 'PhabricatorCountdown' => array( 9173 9174 'PhabricatorCountdownDAO', ··· 10068 10069 'PhabricatorMarkupInterface', 10069 10070 ), 10070 10071 'PhabricatorMarkupPreviewController' => 'PhabricatorController', 10071 - 'PhabricatorMaxChartFunction' => 'PhabricatorChartFunction', 10072 + 'PhabricatorMaxChartFunction' => 'PhabricatorPureChartFunction', 10072 10073 'PhabricatorMemeEngine' => 'Phobject', 10073 10074 'PhabricatorMemeRemarkupRule' => 'PhutilRemarkupRule', 10074 10075 'PhabricatorMentionRemarkupRule' => 'PhutilRemarkupRule', ··· 10135 10136 'PhabricatorMetronome' => 'Phobject', 10136 10137 'PhabricatorMetronomeTestCase' => 'PhabricatorTestCase', 10137 10138 'PhabricatorMetronomicTriggerClock' => 'PhabricatorTriggerClock', 10138 - 'PhabricatorMinChartFunction' => 'PhabricatorChartFunction', 10139 + 'PhabricatorMinChartFunction' => 'PhabricatorPureChartFunction', 10139 10140 'PhabricatorModularTransaction' => 'PhabricatorApplicationTransaction', 10140 10141 'PhabricatorModularTransactionType' => 'Phobject', 10141 10142 'PhabricatorMonogramDatasourceEngineExtension' => 'PhabricatorDatasourceEngineExtension', ··· 10950 10951 'PhabricatorProjectsWatchersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 10951 10952 'PhabricatorPronounSetting' => 'PhabricatorSelectSetting', 10952 10953 'PhabricatorProtocolLog' => 'Phobject', 10954 + 'PhabricatorPureChartFunction' => 'PhabricatorChartFunction', 10953 10955 'PhabricatorPygmentSetupCheck' => 'PhabricatorSetupCheck', 10954 10956 'PhabricatorQuery' => 'Phobject', 10955 10957 'PhabricatorQueryConstraint' => 'Phobject', ··· 11208 11210 'PhabricatorPolicyInterface', 11209 11211 ), 11210 11212 'PhabricatorSavedQueryQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 11211 - 'PhabricatorScaleChartFunction' => 'PhabricatorChartFunction', 11213 + 'PhabricatorScaleChartFunction' => 'PhabricatorPureChartFunction', 11212 11214 'PhabricatorScheduleTaskTriggerAction' => 'PhabricatorTriggerAction', 11213 11215 'PhabricatorScopedEnv' => 'Phobject', 11214 11216 'PhabricatorSearchAbstractDocument' => 'Phobject', ··· 11299 11301 'PhabricatorSetupIssue' => 'Phobject', 11300 11302 'PhabricatorSetupIssueUIExample' => 'PhabricatorUIExample', 11301 11303 'PhabricatorSetupIssueView' => 'AphrontView', 11302 - 'PhabricatorShiftChartFunction' => 'PhabricatorChartFunction', 11304 + 'PhabricatorShiftChartFunction' => 'PhabricatorPureChartFunction', 11303 11305 'PhabricatorShortSite' => 'PhabricatorSite', 11304 11306 'PhabricatorShowFiletreeSetting' => 'PhabricatorSelectSetting', 11305 11307 'PhabricatorSignDocumentsUserLogType' => 'PhabricatorUserLogType', 11306 11308 'PhabricatorSimpleEditType' => 'PhabricatorEditType', 11307 - 'PhabricatorSinChartFunction' => 'PhabricatorChartFunction', 11309 + 'PhabricatorSinChartFunction' => 'PhabricatorPureChartFunction', 11308 11310 'PhabricatorSite' => 'AphrontSite', 11309 11311 'PhabricatorSlackAuthProvider' => 'PhabricatorOAuth2AuthProvider', 11310 11312 'PhabricatorSlowvoteApplication' => 'PhabricatorApplication',
+1 -1
src/applications/fact/chart/PhabricatorConstantChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorConstantChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'constant'; 7 7
+1 -1
src/applications/fact/chart/PhabricatorCosChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorCosChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'cos'; 7 7
+7 -16
src/applications/fact/chart/PhabricatorMaxChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorMaxChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'max'; 7 7 8 8 protected function newArguments() { 9 9 return array( 10 10 $this->newArgument() 11 - ->setName('x') 12 - ->setType('function'), 13 - $this->newArgument() 14 11 ->setName('max') 15 12 ->setType('number'), 16 13 ); 17 14 } 18 15 19 - public function getDomain() { 20 - return $this->getArgument('x')->getDomain(); 21 - } 22 - 23 - public function newInputValues(PhabricatorChartDataQuery $query) { 24 - return $this->getArgument('x')->newInputValues($query); 25 - } 26 - 27 16 public function evaluateFunction(array $xv) { 28 - $yv = $this->getArgument('x')->evaluateFunction($xv); 29 17 $max = $this->getArgument('max'); 30 18 31 - foreach ($yv as $k => $y) { 32 - if ($y > $max) { 33 - $yv[$k] = null; 19 + $yv = array(); 20 + foreach ($xv as $x) { 21 + if ($x > $max) { 22 + $yv[] = null; 23 + } else { 24 + $yv[] = $x; 34 25 } 35 26 } 36 27
+7 -16
src/applications/fact/chart/PhabricatorMinChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorMinChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'min'; 7 7 8 8 protected function newArguments() { 9 9 return array( 10 10 $this->newArgument() 11 - ->setName('x') 12 - ->setType('function'), 13 - $this->newArgument() 14 11 ->setName('min') 15 12 ->setType('number'), 16 13 ); 17 14 } 18 15 19 - public function getDomain() { 20 - return $this->getArgument('x')->getDomain(); 21 - } 22 - 23 - public function newInputValues(PhabricatorChartDataQuery $query) { 24 - return $this->getArgument('x')->newInputValues($query); 25 - } 26 - 27 16 public function evaluateFunction(array $xv) { 28 - $yv = $this->getArgument('x')->evaluateFunction($xv); 29 17 $min = $this->getArgument('min'); 30 18 31 - foreach ($yv as $k => $y) { 32 - if ($y < $min) { 33 - $yv[$k] = null; 19 + $yv = array(); 20 + foreach ($xv as $x) { 21 + if ($x < $min) { 22 + $yv[] = null; 23 + } else { 24 + $yv[] = $x; 34 25 } 35 26 } 36 27
+4
src/applications/fact/chart/PhabricatorPureChartFunction.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorPureChartFunction 4 + extends PhabricatorChartFunction {}
+1 -1
src/applications/fact/chart/PhabricatorScaleChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorScaleChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'scale'; 7 7
+1 -1
src/applications/fact/chart/PhabricatorShiftChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorShiftChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'shift'; 7 7
+1 -1
src/applications/fact/chart/PhabricatorSinChartFunction.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorSinChartFunction 4 - extends PhabricatorChartFunction { 4 + extends PhabricatorPureChartFunction { 5 5 6 6 const FUNCTIONKEY = 'sin'; 7 7
+16 -8
src/applications/project/chart/PhabricatorProjectBurndownChartEngine.php
··· 32 32 if ($project_phids) { 33 33 foreach ($project_phids as $project_phid) { 34 34 $function = $this->newFunction( 35 - 'min', 36 35 array( 37 36 'accumulate', 38 37 array('fact', 'tasks.open-count.assign.project', $project_phid), 39 38 ), 40 - 0); 39 + array( 40 + 'min', 41 + 0, 42 + )); 41 43 42 44 $function->getFunctionLabel() 43 45 ->setName(pht('Tasks Moved Into Project')) ··· 47 49 $functions[] = $function; 48 50 49 51 $function = $this->newFunction( 50 - 'min', 51 52 array( 52 53 'accumulate', 53 54 array('fact', 'tasks.open-count.status.project', $project_phid), 54 55 ), 55 - 0); 56 + array( 57 + 'min', 58 + 0, 59 + )); 56 60 57 61 $function->getFunctionLabel() 58 62 ->setName(pht('Tasks Reopened')) ··· 68 72 array('fact', 'tasks.open-count.create.project', $project_phid), 69 73 ), 70 74 array( 71 - 'max', 72 75 array( 73 76 'accumulate', 74 77 array('fact', 'tasks.open-count.status.project', $project_phid), 75 78 ), 76 - 0, 79 + array( 80 + 'max', 81 + 0, 82 + ), 77 83 ), 78 84 array( 79 - 'max', 80 85 array( 81 86 'accumulate', 82 87 array('fact', 'tasks.open-count.assign.project', $project_phid), 83 88 ), 84 - 0, 89 + array( 90 + 'max', 91 + 0, 92 + ), 85 93 )); 86 94 87 95 $function->getFunctionLabel()