зеркало из https://github.com/nextcloud/cookbook.git
style: Run PHP fixer
Signed-off-by: Sebastian Fey <info@sebastianfey.de>
This commit is contained in:
Родитель
0016f46bfe
Коммит
4d5a5bc0ed
|
@ -58,7 +58,7 @@ class AcceptHeaderParsingHelper {
|
|||
|
||||
usort($weightedParts, function ($a, $b) {
|
||||
$tmp = $a['weight'] - $b['weight'];
|
||||
if ($tmp < - 0.001) {
|
||||
if ($tmp < -0.001) {
|
||||
return -1;
|
||||
} elseif ($tmp > 0.001) {
|
||||
return 1;
|
||||
|
|
|
@ -116,7 +116,7 @@ class DownloadHelper {
|
|||
* @throws NoDownloadWasCarriedOutException if there was no successful download carried out before calling this method.
|
||||
*/
|
||||
public function getContentType(): ?string {
|
||||
if (! $this->downloaded) {
|
||||
if (!$this->downloaded) {
|
||||
throw new NoDownloadWasCarriedOutException();
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class DownloadHelper {
|
|||
* @throws NoDownloadWasCarriedOutException if there was no successful download carried out before calling this method.
|
||||
*/
|
||||
public function getStatus(): int {
|
||||
if (! $this->downloaded) {
|
||||
if (!$this->downloaded) {
|
||||
throw new NoDownloadWasCarriedOutException();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class CleanCategoryFilter extends AbstractJSONFilter {
|
|||
}
|
||||
|
||||
public function apply(array &$json): bool {
|
||||
if (! isset($json['recipeCategory'])) {
|
||||
if (!isset($json['recipeCategory'])) {
|
||||
$json['recipeCategory'] = '';
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class FixInstructionsFilter extends AbstractJSONFilter {
|
|||
}
|
||||
|
||||
public function apply(array &$json): bool {
|
||||
if (! isset($json[self::INSTRUCTIONS])) {
|
||||
if (!isset($json[self::INSTRUCTIONS])) {
|
||||
$json[self::INSTRUCTIONS] = [];
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class FixKeywordsFilter extends AbstractJSONFilter {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!is_string($json[self::KEYWORDS]) && ! is_array($json[self::KEYWORDS])) {
|
||||
if (!is_string($json[self::KEYWORDS]) && !is_array($json[self::KEYWORDS])) {
|
||||
$this->logger->info($this->l->t('Could not parse the keywords for recipe {recipe}.', ['recipe' => $json['name']]));
|
||||
$json[self::KEYWORDS] = '';
|
||||
return true;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace OCA\Cookbook\Helper\Filter\JSON;
|
|||
class RecipeIdCopyFilter extends AbstractJSONFilter {
|
||||
public function apply(array &$json): bool {
|
||||
$copy = $json;
|
||||
if (! isset($json['id'])) {
|
||||
if (!isset($json['id'])) {
|
||||
$json['id'] = $json['recipe_id'];
|
||||
}
|
||||
return $json !== $copy;
|
||||
|
|
|
@ -60,7 +60,7 @@ class HttpJsonLdParser extends AbstractHtmlParser {
|
|||
throw new HtmlParsingException($this->l->t('JSON cannot be decoded.'));
|
||||
}
|
||||
|
||||
if ($json === false || $json === true || ! is_array($json)) {
|
||||
if ($json === false || $json === true || !is_array($json)) {
|
||||
throw new HtmlParsingException($this->l->t('No recipe was found.'));
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ class HtmlToDomParser {
|
|||
*/
|
||||
foreach ($errors as $error) {
|
||||
if (isset($ret[$error->code])) {
|
||||
$ret[$error->code]['count'] ++;
|
||||
$ret[$error->code]['count']++;
|
||||
} else {
|
||||
$ret[$error->code] = [
|
||||
'count' => 1,
|
||||
|
|
|
@ -129,7 +129,7 @@ class UserFolderHelper {
|
|||
);
|
||||
}
|
||||
|
||||
if (! $node->isCreatable()) {
|
||||
if (!$node->isCreatable()) {
|
||||
throw new UserFolderNotWritableException(
|
||||
$this->l->t('User cannot create recipe folder')
|
||||
);
|
||||
|
|
|
@ -26,7 +26,7 @@ class Version000000Date20210427082010 extends SimpleMigrationStep {
|
|||
$schema = $schemaClosure();
|
||||
|
||||
$categoriesTable = $schema->getTable('cookbook_categories');
|
||||
if (! $categoriesTable->hasIndex('categories_recipe_idx')) {
|
||||
if (!$categoriesTable->hasIndex('categories_recipe_idx')) {
|
||||
$categoriesTable->addIndex([
|
||||
'user_id',
|
||||
'recipe_id',
|
||||
|
@ -34,7 +34,7 @@ class Version000000Date20210427082010 extends SimpleMigrationStep {
|
|||
}
|
||||
|
||||
$keywordsTable = $schema->getTable('cookbook_keywords');
|
||||
if (! $keywordsTable->hasIndex('keywords_recipe_idx')) {
|
||||
if (!$keywordsTable->hasIndex('keywords_recipe_idx')) {
|
||||
$keywordsTable->addIndex([
|
||||
'user_id',
|
||||
'recipe_id',
|
||||
|
|
|
@ -97,7 +97,7 @@ class Version000000Date20210701093123 extends SimpleMigrationStep {
|
|||
if ($namesTable->hasPrimaryKey()) {
|
||||
$namesTable->dropPrimaryKey();
|
||||
}
|
||||
if (! $namesTable->hasIndex('names_recipe_idx')) {
|
||||
if (!$namesTable->hasIndex('names_recipe_idx')) {
|
||||
$namesTable->addUniqueIndex([
|
||||
'recipe_id',
|
||||
'user_id'
|
||||
|
|
|
@ -33,7 +33,7 @@ class Version000000Date20220703174647 extends SimpleMigrationStep {
|
|||
|
||||
$table = $schema->getTable('cookbook_names');
|
||||
|
||||
if (! $table->hasColumn('date_created')) {
|
||||
if (!$table->hasColumn('date_created')) {
|
||||
$table->addColumn('date_created', 'datetime_immutable', [
|
||||
'notnull' => false,
|
||||
]);
|
||||
|
|
|
@ -21,13 +21,13 @@ class JsonService {
|
|||
* @return bool true, if $obj is an object and optionally satisfies the type check
|
||||
*/
|
||||
public function isSchemaObject($obj, string $type = null, bool $checkContext = true, bool $uniqueType = true): bool {
|
||||
if (! is_array($obj)) {
|
||||
if (!is_array($obj)) {
|
||||
// Objects must bve encoded as arrays in JSON
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($checkContext) {
|
||||
if (!isset($obj['@context']) || ! preg_match('@^https?://schema\.org/?$@', $obj['@context'])) {
|
||||
if (!isset($obj['@context']) || !preg_match('@^https?://schema\.org/?$@', $obj['@context'])) {
|
||||
// We have no correct context property
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ class RecipeService {
|
|||
|
||||
$recipe_file->putContent(json_encode($json));
|
||||
|
||||
if (! is_null($importedHtml)) {
|
||||
if (!is_null($importedHtml)) {
|
||||
// We imported a recipe. Save the import html file as a backup
|
||||
$importFile = $recipe_folder->newFile('import.html');
|
||||
$importFile->putContent($importedHtml);
|
||||
|
@ -423,7 +423,7 @@ class RecipeService {
|
|||
*/
|
||||
private function addDatesToRecipes(array &$recipes) {
|
||||
foreach ($recipes as $i => $recipe) {
|
||||
if (! array_key_exists('dateCreated', $recipe) || ! array_key_exists('dateModified', $recipe)) {
|
||||
if (!array_key_exists('dateCreated', $recipe) || !array_key_exists('dateModified', $recipe)) {
|
||||
$r = $this->getRecipeById($recipe['recipe_id']);
|
||||
$recipes[$i]['dateCreated'] = $r['dateCreated'];
|
||||
$recipes[$i]['dateModified'] = $r['dateModified'];
|
||||
|
|
|
@ -78,7 +78,7 @@ abstract class AbstractMigrationTestCase extends TestCase {
|
|||
|
||||
// Reinstall app partially (just before the migration)
|
||||
$migrationBefore = $this->getPreviousMigrationName();
|
||||
if (! empty($migrationBefore)) {
|
||||
if (!empty($migrationBefore)) {
|
||||
// We need to run a migration beforehand
|
||||
$this->migrationService->migrate($migrationBefore);
|
||||
$this->renewSchema();
|
||||
|
@ -101,7 +101,7 @@ abstract class AbstractMigrationTestCase extends TestCase {
|
|||
}
|
||||
|
||||
private function hideMigrations() {
|
||||
if (! file_exists(self::TMP_MIGRATIONS)) {
|
||||
if (!file_exists(self::TMP_MIGRATIONS)) {
|
||||
mkdir(self::TMP_MIGRATIONS);
|
||||
}
|
||||
|
||||
|
|
|
@ -208,11 +208,11 @@ class ThumbnailFileHelperTest extends TestCase {
|
|||
$f->method('get')->willReturnMap($fileMap);
|
||||
|
||||
$cnt = 0;
|
||||
if (! $thumbExists) {
|
||||
$cnt ++;
|
||||
if (!$thumbExists) {
|
||||
$cnt++;
|
||||
}
|
||||
if (! $miniExists) {
|
||||
$cnt ++;
|
||||
if (!$miniExists) {
|
||||
$cnt++;
|
||||
}
|
||||
$newFileMap = [
|
||||
['thumb.jpg', null, $thumb],
|
||||
|
|
Загрузка…
Ссылка в новой задаче