From 52c693cee14f9677a6b94c0b9fce0e4c19fce596 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 10 Oct 2019 11:01:54 -0700 Subject: [PATCH] adds better CS rules --- .php_cs.dist | 4 ++++ dialogflow/test/sessionEntityTypeTest.php | 2 +- spanner/src/read_write_transaction.php | 4 ++-- speech/test/speechTest.php | 4 ++-- texttospeech/test/textToSpeechTest.php | 12 ++++++------ vision/src/detect_crop_hints.php | 2 +- vision/src/detect_crop_hints_gcs.php | 2 +- vision/src/detect_document_text.php | 2 +- vision/src/detect_document_text_gcs.php | 2 +- vision/src/detect_face.php | 4 ++-- vision/src/detect_face_gcs.php | 4 ++-- vision/src/detect_safe_search.php | 2 +- vision/src/detect_safe_search_gcs.php | 2 +- vision/src/detect_text.php | 2 +- vision/src/detect_text_gcs.php | 2 +- vision/vision.php | 2 +- 16 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 7d05e50196..da7f224bd6 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -6,6 +6,10 @@ return PhpCsFixer\Config::create() 'concat_space' => ['spacing' => 'one'], 'no_unused_imports' => true, 'method_argument_space' => false, + 'whitespace_after_comma_in_array' => true, + 'method_argument_space' => [ + 'keep_multiple_spaces_after_comma' => true + ], ]) ->setFinder( PhpCsFixer\Finder::create() diff --git a/dialogflow/test/sessionEntityTypeTest.php b/dialogflow/test/sessionEntityTypeTest.php index 2a3c72c376..5511b188a1 100644 --- a/dialogflow/test/sessionEntityTypeTest.php +++ b/dialogflow/test/sessionEntityTypeTest.php @@ -37,7 +37,7 @@ public static function setUpBeforeClass() public function testCreateSessionEntityType() { - $response = $this->runCommand('entity-type-create',[ + $response = $this->runCommand('entity-type-create', [ 'display-name' => self::$entityTypeDisplayName ]); $this->runCommand('session-entity-type-create', [ diff --git a/spanner/src/read_write_transaction.php b/spanner/src/read_write_transaction.php index 98ee8031a2..c688250fa8 100644 --- a/spanner/src/read_write_transaction.php +++ b/spanner/src/read_write_transaction.php @@ -56,7 +56,7 @@ function read_write_transaction($instanceId, $databaseId) $transferAmount = 200000; // Read the second album's budget. - $secondAlbumKey = [2,2]; + $secondAlbumKey = [2, 2]; $secondAlbumKeySet = $spanner->keySet(['keys' => [$secondAlbumKey]]); $secondAlbumResult = $t->read( 'Albums', @@ -74,7 +74,7 @@ function read_write_transaction($instanceId, $databaseId) ); } - $firstAlbumKey = [1,1]; + $firstAlbumKey = [1, 1]; $firstAlbumKeySet = $spanner->keySet(['keys' => [$firstAlbumKey]]); $firstAlbumResult = $t->read( 'Albums', diff --git a/speech/test/speechTest.php b/speech/test/speechTest.php index bb47eaac06..7c4118c467 100644 --- a/speech/test/speechTest.php +++ b/speech/test/speechTest.php @@ -54,14 +54,14 @@ public function testTranscribeModel() [$path, 'video'] ); // $this->assertContains('the weather outside is sunny',$output); - $this->assertContains('how old is the Brooklyn Bridge',$output); + $this->assertContains('how old is the Brooklyn Bridge', $output); } public function testTranscribePunctuation() { $path = __DIR__ . '/data/audio32KHz.raw'; $output = $this->runSnippet('transcribe_auto_punctuation', [$path]); - $this->assertContains('How old is the Brooklyn Bridge',$output); + $this->assertContains('How old is the Brooklyn Bridge', $output); } /** @dataProvider provideTranscribe */ diff --git a/texttospeech/test/textToSpeechTest.php b/texttospeech/test/textToSpeechTest.php index 703ee144fa..31559d06f8 100644 --- a/texttospeech/test/textToSpeechTest.php +++ b/texttospeech/test/textToSpeechTest.php @@ -40,7 +40,7 @@ public function testSynthesizeSsml() ['Hello there.'] ); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } @@ -49,7 +49,7 @@ public function testSynthesizeText() $output = $this->runSnippet('synthesize_text', ['hello there']); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } @@ -60,7 +60,7 @@ public function testSynthesizeTextEffectsProfile() ['hello there', 'telephony-class-application'] ); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } @@ -70,7 +70,7 @@ public function testSynthesizeSsmlFile() $output = $this->runSnippet('synthesize_ssml_file', [$path]); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } @@ -80,7 +80,7 @@ public function testSynthesizeTextFile() $output = $this->runSnippet('synthesize_text_file', [$path]); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } @@ -92,7 +92,7 @@ public function testSynthesizeTextEffectsProfileFile() [$path, 'telephony-class-application'] ); $this->assertContains('Audio content written to', $output); - $this->assertGreaterThan(0,filesize('output.mp3')); + $this->assertGreaterThan(0, filesize('output.mp3')); unlink('output.mp3'); } } diff --git a/vision/src/detect_crop_hints.php b/vision/src/detect_crop_hints.php index 280c8097e7..a541d16a8a 100644 --- a/vision/src/detect_crop_hints.php +++ b/vision/src/detect_crop_hints.php @@ -42,7 +42,7 @@ function detect_crop_hints($path) $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); } } else { print('No crop hints' . PHP_EOL); diff --git a/vision/src/detect_crop_hints_gcs.php b/vision/src/detect_crop_hints_gcs.php index 70a8f49bc7..6553e05041 100644 --- a/vision/src/detect_crop_hints_gcs.php +++ b/vision/src/detect_crop_hints_gcs.php @@ -41,7 +41,7 @@ function detect_crop_hints_gcs($path) $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); } } else { print('No crop hints' . PHP_EOL); diff --git a/vision/src/detect_document_text.php b/vision/src/detect_document_text.php index 7523605a0e..5049f46609 100644 --- a/vision/src/detect_document_text.php +++ b/vision/src/detect_document_text.php @@ -56,7 +56,7 @@ function detect_document_text($path) $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); print(PHP_EOL); } } diff --git a/vision/src/detect_document_text_gcs.php b/vision/src/detect_document_text_gcs.php index f6117e3a04..5a2d106ef4 100644 --- a/vision/src/detect_document_text_gcs.php +++ b/vision/src/detect_document_text_gcs.php @@ -55,7 +55,7 @@ function detect_document_text_gcs($path) $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); print(PHP_EOL); } diff --git a/vision/src/detect_face.php b/vision/src/detect_face.php index b52481e828..b966767a30 100644 --- a/vision/src/detect_face.php +++ b/vision/src/detect_face.php @@ -38,7 +38,7 @@ function detect_face($path, $outFile = null) # names of likelihood from google.cloud.vision.enums $likelihoodName = ['UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY', - 'POSSIBLE','LIKELY', 'VERY_LIKELY']; + 'POSSIBLE', 'LIKELY', 'VERY_LIKELY']; printf("%d faces found:" . PHP_EOL, count($faces)); foreach ($faces as $face) { @@ -57,7 +57,7 @@ function detect_face($path, $outFile = null) foreach ($vertices as $vertex) { $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); print(PHP_EOL); } // [END vision_face_detection] diff --git a/vision/src/detect_face_gcs.php b/vision/src/detect_face_gcs.php index 5d5223ac66..6c846c68b3 100644 --- a/vision/src/detect_face_gcs.php +++ b/vision/src/detect_face_gcs.php @@ -32,7 +32,7 @@ function detect_face_gcs($path) # names of likelihood from google.cloud.vision.enums $likelihoodName = ['UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY', - 'POSSIBLE','LIKELY', 'VERY_LIKELY']; + 'POSSIBLE', 'LIKELY', 'VERY_LIKELY']; printf("%d faces found:" . PHP_EOL, count($faces)); foreach ($faces as $face) { @@ -51,7 +51,7 @@ function detect_face_gcs($path) foreach ($vertices as $vertex) { $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); print(PHP_EOL); } diff --git a/vision/src/detect_safe_search.php b/vision/src/detect_safe_search.php index fc79d362e9..4ba903872d 100644 --- a/vision/src/detect_safe_search.php +++ b/vision/src/detect_safe_search.php @@ -39,7 +39,7 @@ function detect_safe_search($path) # names of likelihood from google.cloud.vision.enums $likelihoodName = ['UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY', - 'POSSIBLE','LIKELY', 'VERY_LIKELY']; + 'POSSIBLE', 'LIKELY', 'VERY_LIKELY']; printf("Adult: %s" . PHP_EOL, $likelihoodName[$adult]); printf("Medical: %s" . PHP_EOL, $likelihoodName[$medical]); diff --git a/vision/src/detect_safe_search_gcs.php b/vision/src/detect_safe_search_gcs.php index a9a64603fa..d271106d0a 100644 --- a/vision/src/detect_safe_search_gcs.php +++ b/vision/src/detect_safe_search_gcs.php @@ -39,7 +39,7 @@ function detect_safe_search_gcs($path) # names of likelihood from google.cloud.vision.enums $likelihoodName = ['UNKNOWN', 'VERY_UNLIKELY', 'UNLIKELY', - 'POSSIBLE','LIKELY', 'VERY_LIKELY']; + 'POSSIBLE', 'LIKELY', 'VERY_LIKELY']; printf("Adult: %s" . PHP_EOL, $likelihoodName[$adult]); printf("Medical: %s" . PHP_EOL, $likelihoodName[$medical]); diff --git a/vision/src/detect_text.php b/vision/src/detect_text.php index 8e3d50e810..d07bf62b76 100644 --- a/vision/src/detect_text.php +++ b/vision/src/detect_text.php @@ -41,7 +41,7 @@ function detect_text($path) foreach ($vertices as $vertex) { $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); } $imageAnnotator->close(); diff --git a/vision/src/detect_text_gcs.php b/vision/src/detect_text_gcs.php index 046b0285b2..93f594af8d 100644 --- a/vision/src/detect_text_gcs.php +++ b/vision/src/detect_text_gcs.php @@ -40,7 +40,7 @@ function detect_text_gcs($path) foreach ($vertices as $vertex) { $bounds[] = sprintf('(%d,%d)', $vertex->getX(), $vertex->getY()); } - print('Bounds: ' . join(', ',$bounds) . PHP_EOL); + print('Bounds: ' . join(', ', $bounds) . PHP_EOL); } if ($error = $response->getError()) { diff --git a/vision/vision.php b/vision/vision.php index 96ca742caa..a360b1f043 100644 --- a/vision/vision.php +++ b/vision/vision.php @@ -255,7 +255,7 @@ ->setCode(function ($input, $output) { $path = $input->getArgument('path'); $output = $input->getArgument('output'); - detect_pdf_gcs($path,$output); + detect_pdf_gcs($path, $output); }) );