Avoid use of assignments bare inside statements

Either use them in a subroutine call or put parentheses around the assignment.
This commit is contained in:
Alexei Sorokin
2020-09-08 12:42:51 +03:00
parent d0f96a7023
commit adc689cb15
15 changed files with 934 additions and 791 deletions

View File

@@ -67,7 +67,10 @@ call_user_func(function () {
// Find composer.json
if (is_file($path . '/composer.json')) {
if ($cfg = json_decode(file_get_contents($path . '/composer.json'), true)) {
if (!empty($cfg = json_decode(
file_get_contents($path . '/composer.json'),
true
))) {
if (isset($cfg['name']) && $cfg['name'] === 'psy/psysh') {
// We're inside the psysh project. Let's use the local
// Composer autoload.
@@ -82,7 +85,10 @@ call_user_func(function () {
// Or a composer.lock
if (is_file($path . '/composer.lock')) {
if ($cfg = json_decode(file_get_contents($path . '/composer.lock'), true)) {
if (!empty($cfg = json_decode(
file_get_contents($path . '/composer.lock'),
true
))) {
foreach (array_merge($cfg['packages'], $cfg['packages-dev']) as $pkg) {
if (isset($pkg['name']) && $pkg['name'] === 'psy/psysh') {
// We're inside a project which requires psysh. We'll

View File

@@ -1,21 +1,23 @@
#!/usr/bin/env php
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/*
* StatusNet - a distributed open-source microblogging tool
* Copyright (C) 2010 StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @copyright 2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
define('INSTALLDIR', dirname(__DIR__));
@@ -71,16 +73,19 @@ function get_max_profile_id()
*/
function get_missing_profiles($start, $end)
{
$query = sprintf("SELECT id FROM profile WHERE id BETWEEN %d AND %d",
$start, $end);
$query = sprintf(
'SELECT id FROM profile WHERE id BETWEEN %d AND %d',
$start,
$end
);
$profile = new Profile();
$profile->query($query);
$all = range($start, $end);
$known = array();
while ($row = $profile->fetch()) {
$known[] = intval($profile->id);
$known = [];
while ($profile->fetch()) {
$known[] = (int) $profile->id;
}
unset($profile);
@@ -164,4 +169,3 @@ for ($start = $begin; $start <= $final; $start += $chunk) {
}
echo "done.\n";