From d1987fc710b3ec4908fc977f67d682735e96c622 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 10 Jan 2018 16:18:06 -0500 Subject: [PATCH 1/2] Handle syncing errors more consistently --- composer.json | 4 ++-- src/Command/SyncKitsuWithMal.php | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 7f13f0ca..4192c657 100644 --- a/composer.json +++ b/composer.json @@ -41,9 +41,9 @@ "robmorgan/phinx": "^0.9.1", "sebastian/phpcpd": "^3.0", "spatie/phpunit-snapshot-assertions": "^1.2.0", - "squizlabs/php_codesniffer": "^3.0.0@beta", + "squizlabs/php_codesniffer": "^3.2.2", "symfony/var-dumper": "^4.0.1", - "theseer/phpdox": "^0.10.1", + "theseer/phpdox": "^0.11.0", "filp/whoops": "^2.1" }, "scripts": { diff --git a/src/Command/SyncKitsuWithMal.php b/src/Command/SyncKitsuWithMal.php index c4638bc5..d97b6e5f 100644 --- a/src/Command/SyncKitsuWithMal.php +++ b/src/Command/SyncKitsuWithMal.php @@ -49,7 +49,7 @@ class SyncKitsuWithMal extends BaseCommand { protected $malModel; /** - * Run the image conversion script + * Run the Kitsu <=> MAL sync script * * @param array $args * @param array $options @@ -112,7 +112,6 @@ class SyncKitsuWithMal extends BaseCommand { if ( ! empty($data['updateKitsu'])) { - // print_r($data['updateKitsu']); $count = count($data['updateKitsu']); $this->echoBox("Updating {$count} outdated Kitsu {$type} list items"); $this->updateKitsuListItems($data['updateKitsu'], $type); @@ -467,14 +466,16 @@ class SyncKitsuWithMal extends BaseCommand { foreach($responses as $key => $response) { + $responseData = Json::decode($response); + $id = $itemsToUpdate[$key]['id']; - if ($response->getStatus() === 200) + if ( ! array_key_exists('errors', $responseData)) { $this->echoBox("Successfully updated Kitsu {$type} list item with id: {$id}"); } else { - echo $response->getBody(); + dump($responseData); $this->echoBox("Failed to update Kitsu {$type} list item with id: {$id}"); } } @@ -495,7 +496,7 @@ class SyncKitsuWithMal extends BaseCommand { foreach($responses as $key => $response) { $id = $itemsToUpdate[$key]['mal_id']; - if ($response->getBody() === 'Updated') + if ($response === 'Updated') { $this->echoBox("Successfully updated MAL {$type} list item with id: {$id}"); } @@ -518,14 +519,17 @@ class SyncKitsuWithMal extends BaseCommand { foreach($responses as $key => $response) { + $responseData = Json::decode($response); + $id = $itemsToAdd[$key]['id']; - if ($response->getStatus() === 201) + + if ( ! array_key_exists('errors', $responseData)) { $this->echoBox("Successfully created Kitsu {$type} list item with id: {$id}"); } else { - echo $response->getBody(); + dump($responseData); $this->echoBox("Failed to create Kitsu {$type} list item with id: {$id}"); } } @@ -547,7 +551,7 @@ class SyncKitsuWithMal extends BaseCommand { foreach($responses as $key => $response) { $id = $itemsToAdd[$key]['mal_id']; - if ($response->getBody() === 'Created') + if ($response === 'Created') { $this->echoBox("Successfully created MAL {$type} list item with id: {$id}"); } @@ -557,4 +561,4 @@ class SyncKitsuWithMal extends BaseCommand { } } } -} \ No newline at end of file +} From fb8db698a6cd78dcdc5d0685d7d44ead62f433d0 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Wed, 10 Jan 2018 16:24:00 -0500 Subject: [PATCH 2/2] Fix some documentation generation issues --- build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php | 2 +- phpdoc.dist.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php b/build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php index 03687d7d..8071f31e 100644 --- a/build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php +++ b/build/CodeIgniter/Sniffs/WhiteSpace/ElseOnNewLineSniff.php @@ -71,7 +71,7 @@ class ElseOnNewLineSniff implements Sniff $previous_non_blank_token = $tokens[$previous_non_blank_token_ptr]; if ($previous_non_blank_token['line'] === $else_token['line']) { $error = '"' . $else_token['content'] . '" should be on a new line.'; - $phpcsFile->addError($error, $stackPtr); + $phpcsFile->addError($error, $stackPtr, 123423); } }//end process() diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml index c909515f..6dc2f5aa 100644 --- a/phpdoc.dist.xml +++ b/phpdoc.dist.xml @@ -12,7 +12,7 @@ src - + vendor/aviat/ion/src + vendor/container-interop/container-interop/src \ No newline at end of file