1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Fix errors found by PHPStan

Test Plan: None.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D17377
This commit is contained in:
Jakub Vrana 2017-02-18 09:24:56 +00:00 committed by vrana
parent a439ea7190
commit 9f3cde4db7
20 changed files with 33 additions and 29 deletions

View file

@ -69,7 +69,7 @@ final class CalendarTimeUtil extends Phobject {
$today_epoch = PhabricatorTime::parseLocalTime('today', $user); $today_epoch = PhabricatorTime::parseLocalTime('today', $user);
$today = new DateTime('@'.$today_epoch); $today = new DateTime('@'.$today_epoch);
$today->setTimeZone($timezone); $today->setTimezone($timezone);
if (strtolower($start_day_str) == 'today' || if (strtolower($start_day_str) == 'today' ||
$today->format('l') == $start_day_str) { $today->format('l') == $start_day_str) {
@ -79,7 +79,7 @@ final class CalendarTimeUtil extends Phobject {
'last '.$start_day_str, 'last '.$start_day_str,
$user); $user);
$start_day = new DateTime('@'.$start_epoch); $start_day = new DateTime('@'.$start_epoch);
$start_day->setTimeZone($timezone); $start_day->setTimezone($timezone);
} }
return array( return array(
'today' => $today, 'today' => $today,

View file

@ -47,7 +47,7 @@ final class PhabricatorDaemonManagementRestartWorkflow
return $this->executeStartCommand( return $this->executeStartCommand(
array( array(
'reserve' => (float)$args->getArg('autoscale-reserve', 0.0), 'reserve' => (float)$args->getArg('autoscale-reserve'),
)); ));
} }

View file

@ -34,7 +34,7 @@ final class PhabricatorDaemonManagementStartWorkflow
array( array(
'keep-leases' => $args->getArg('keep-leases'), 'keep-leases' => $args->getArg('keep-leases'),
'force' => $args->getArg('force'), 'force' => $args->getArg('force'),
'reserve' => (float)$args->getArg('autoscale-reserve', 0.0), 'reserve' => (float)$args->getArg('autoscale-reserve'),
)); ));
} }

View file

@ -52,7 +52,7 @@ final class DiffusionBrowseQueryConduitAPIMethod
$commit, $commit,
$path); $path);
} catch (CommandException $e) { } catch (CommandException $e) {
$stderr = $e->getStdErr(); $stderr = $e->getStderr();
if (preg_match('/^fatal: Not a valid object name/', $stderr)) { if (preg_match('/^fatal: Not a valid object name/', $stderr)) {
// Grab two logs, since the first one is when the object was deleted. // Grab two logs, since the first one is when the object was deleted.
list($stdout) = $repository->execxLocalCommand( list($stdout) = $repository->execxLocalCommand(

View file

@ -446,7 +446,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$header->setHeader(pht('Branches')); $header->setHeader(pht('Branches'));
if ($more_branches) { if ($more_branches) {
$header->setSubHeader(pht('Showing %d branches.', $limit)); $header->setSubheader(pht('Showing %d branches.', $limit));
} }
$button = new PHUIButtonView(); $button = new PHUIButtonView();
@ -505,7 +505,7 @@ final class DiffusionRepositoryController extends DiffusionController {
$header->setHeader(pht('Tags')); $header->setHeader(pht('Tags'));
if ($more_tags) { if ($more_tags) {
$header->setSubHeader( $header->setSubheader(
pht('Showing the %d most recent tags.', $tag_limit)); pht('Showing the %d most recent tags.', $tag_limit));
} }

View file

@ -111,7 +111,6 @@ final class DiffusionCommitEditEngine
->setValue($object->getAuditorPHIDsForEdit()); ->setValue($object->getAuditorPHIDsForEdit());
$reason = $data->getCommitDetail('autocloseReason', false); $reason = $data->getCommitDetail('autocloseReason', false);
$reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED;
if ($reason !== false) { if ($reason !== false) {
switch ($reason) { switch ($reason) {
case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:

View file

@ -46,7 +46,7 @@ final class HeraldPreCommitContentAdapter extends HeraldPreCommitAdapter {
if ($this->changesets instanceof Exception) { if ($this->changesets instanceof Exception) {
$ex_class = get_class($this->changesets); $ex_class = get_class($this->changesets);
$ex_message = $this->changesets->getmessage(); $ex_message = $this->changesets->getMessage();
if ($type === 'name') { if ($type === 'name') {
return array("<{$ex_class}: {$ex_message}>"); return array("<{$ex_class}: {$ex_message}>");
} else { } else {

View file

@ -271,13 +271,13 @@ final class DiffusionLowLevelResolveRefsQuery
try { try {
list($stdout) = $future->resolvex(); list($stdout) = $future->resolvex();
} catch (CommandException $ex) { } catch (CommandException $ex) {
if (preg_match('/ambiguous identifier/', $ex->getStdErr())) { if (preg_match('/ambiguous identifier/', $ex->getStderr())) {
// This indicates that the ref ambiguously matched several things. // This indicates that the ref ambiguously matched several things.
// Eventually, it would be nice to return all of them, but it is // Eventually, it would be nice to return all of them, but it is
// unclear how to best do that. For now, treat it as a miss instead. // unclear how to best do that. For now, treat it as a miss instead.
continue; continue;
} }
if (preg_match('/unknown revision/', $ex->getStdErr())) { if (preg_match('/unknown revision/', $ex->getStderr())) {
// No matches for this ref. // No matches for this ref.
continue; continue;
} }

View file

@ -128,7 +128,7 @@ final class DivinerPHPAtomizer extends DivinerAtomizer {
private function parseParams(DivinerAtom $atom, AASTNode $func) { private function parseParams(DivinerAtom $atom, AASTNode $func) {
$params = $func $params = $func
->getChildByIndex(3, 'n_DECLARATAION_PARAMETER_LIST') ->getChildOfType(3, 'n_DECLARATAION_PARAMETER_LIST')
->selectDescendantsOfType('n_DECLARATION_PARAMETER'); ->selectDescendantsOfType('n_DECLARATION_PARAMETER');
$param_spec = array(); $param_spec = array();

View file

@ -340,6 +340,9 @@ final class PhabricatorMetaMTAMail
return $this->save(); return $this->save();
} }
/**
* @return this
*/
public function save() { public function save() {
if ($this->getID()) { if ($this->getID()) {
return parent::save(); return parent::save();

View file

@ -86,7 +86,7 @@ final class PhabricatorPhortuneManagementInvoiceWorkflow
$auto_range = $args->getArg('auto-range'); $auto_range = $args->getArg('auto-range');
$last_arg = $args->getArg('last'); $last_arg = $args->getArg('last');
$next_arg = $args->getARg('next'); $next_arg = $args->getArg('next');
if (!$auto_range && !$last_arg && !$next_arg) { if (!$auto_range && !$last_arg && !$next_arg) {
throw new PhutilArgumentUsageException( throw new PhutilArgumentUsageException(

View file

@ -233,7 +233,7 @@ final class PhabricatorRepositoryDiscoveryEngine
$limit, $limit,
$repository->getSubversionBaseURI($at_rev)); $repository->getSubversionBaseURI($at_rev));
} catch (CommandException $ex) { } catch (CommandException $ex) {
$stderr = $ex->getStdErr(); $stderr = $ex->getStderr();
if (preg_match('/(path|File) not found/', $stderr)) { if (preg_match('/(path|File) not found/', $stderr)) {
// We've gone all the way back through history and this path was not // We've gone all the way back through history and this path was not
// affected by earlier commits. // affected by earlier commits.

View file

@ -108,7 +108,7 @@ final class PhabricatorRepositoryMirrorEngine
->setCWD($repository->getLocalPath()) ->setCWD($repository->getLocalPath())
->resolvex(); ->resolvex();
} catch (CommandException $ex) { } catch (CommandException $ex) {
if (preg_match('/no changes found/', $ex->getStdOut())) { if (preg_match('/no changes found/', $ex->getStdout())) {
// mercurial says nothing changed, but that's good // mercurial says nothing changed, but that's good
} else { } else {
throw $ex; throw $ex;

View file

@ -471,7 +471,7 @@ final class PhabricatorRepositoryPullEngine
$future->resolvex(); $future->resolvex();
} catch (CommandException $ex) { } catch (CommandException $ex) {
$err = $ex->getError(); $err = $ex->getError();
$stdout = $ex->getStdOut(); $stdout = $ex->getStdout();
// NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the behavior // NOTE: Between versions 2.1 and 2.1.1, Mercurial changed the behavior
// of "hg pull" to return 1 in case of a successful pull with no changes. // of "hg pull" to return 1 in case of a successful pull with no changes.

View file

@ -111,7 +111,7 @@ final class PhabricatorMarkupEngine extends Phobject {
} }
if (!$keys) { if (!$keys) {
return; return $this;
} }
$objects = array_select_keys($this->objects, $keys); $objects = array_select_keys($this->objects, $keys);

View file

@ -1521,6 +1521,7 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery
/** /**
* @return this
* @task edgelogic * @task edgelogic
*/ */
public function withEdgeLogicConstraints($edge_type, array $constraints) { public function withEdgeLogicConstraints($edge_type, array $constraints) {

View file

@ -1094,12 +1094,12 @@ abstract class LiskDAO extends Phobject {
/** /**
* Save this object, forcing the query to use INSERT regardless of object * Save this object, forcing the query to use INSERT regardless of object
* state. * state.
* *
* @return this * @return this
* *
* @task save * @task save
*/ */
public function insert() { public function insert() {
$this->isEphemeralCheck(); $this->isEphemeralCheck();
@ -1108,12 +1108,12 @@ abstract class LiskDAO extends Phobject {
/** /**
* Save this object, forcing the query to use UPDATE regardless of object * Save this object, forcing the query to use UPDATE regardless of object
* state. * state.
* *
* @return this * @return this
* *
* @task save * @task save
*/ */
public function update() { public function update() {
$this->isEphemeralCheck(); $this->isEphemeralCheck();
@ -1192,6 +1192,7 @@ abstract class LiskDAO extends Phobject {
* Internal implementation of INSERT and REPLACE. * Internal implementation of INSERT and REPLACE.
* *
* @param const Either "INSERT" or "REPLACE", to force the desired mode. * @param const Either "INSERT" or "REPLACE", to force the desired mode.
* @return this
* *
* @task save * @task save
*/ */

View file

@ -64,7 +64,7 @@ final class PhabricatorTime extends Phobject {
public static function getTodayMidnightDateTime($viewer) { public static function getTodayMidnightDateTime($viewer) {
$timezone = new DateTimeZone($viewer->getTimezoneIdentifier()); $timezone = new DateTimeZone($viewer->getTimezoneIdentifier());
$today = new DateTime('@'.time()); $today = new DateTime('@'.time());
$today->setTimeZone($timezone); $today->setTimezone($timezone);
$year = $today->format('Y'); $year = $today->format('Y');
$month = $today->format('m'); $month = $today->format('m');
$day = $today->format('d'); $day = $today->format('d');
@ -74,7 +74,7 @@ final class PhabricatorTime extends Phobject {
public static function getDateTimeFromEpoch($epoch, PhabricatorUser $viewer) { public static function getDateTimeFromEpoch($epoch, PhabricatorUser $viewer) {
$datetime = new DateTime('@'.$epoch); $datetime = new DateTime('@'.$epoch);
$datetime->setTimeZone($viewer->getTimeZone()); $datetime->setTimezone($viewer->getTimeZone());
return $datetime; return $datetime;
} }

View file

@ -577,7 +577,7 @@ final class PHUICalendarMonthView extends AphrontView {
private function getTodayMidnight() { private function getTodayMidnight() {
$viewer = $this->getUser(); $viewer = $this->getUser();
$today = new DateTime('@'.time()); $today = new DateTime('@'.time());
$today->setTimeZone($viewer->getTimeZone()); $today->setTimezone($viewer->getTimeZone());
$today->setTime(0, 0, 0); $today->setTime(0, 0, 0);
return $today; return $today;

View file

@ -88,7 +88,7 @@ function phabricator_format_local_time($epoch, $user, $format) {
"raised an exception.", $epoch)); "raised an exception.", $epoch));
} }
$date->setTimeZone($zone); $date->setTimezone($zone);
return PhutilTranslator::getInstance()->translateDate($format, $date); return PhutilTranslator::getInstance()->translateDate($format, $date);
} }