Skip to content

Commit 3d1c232

Browse files
committed
Ran php-cs-fixer
1 parent 74568d1 commit 3d1c232

37 files changed

+192
-206
lines changed

scripts/ReleaseUpdater.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,32 @@ public function __construct(string $changelogPath, string $composerConfigPath, s
6060

6161
public function updateChangelog(string $version)
6262
{
63-
$content = \file_get_contents($this->changelogPath);
63+
$content = file_get_contents($this->changelogPath);
6464

65-
$pendingChangesStart = \mb_strpos($content, self::PENDING_CHANGES_START);
66-
$pendingChangesEnd = \mb_strpos($content, self::PENDING_CHANGES_END);
65+
$pendingChangesStart = mb_strpos($content, self::PENDING_CHANGES_START);
66+
$pendingChangesEnd = mb_strpos($content, self::PENDING_CHANGES_END);
6767

68-
if (\false === $pendingChangesStart || \false === $pendingChangesEnd) {
68+
if (false === $pendingChangesStart || false === $pendingChangesEnd) {
6969
throw new Exception('ERROR: Cannot reliably determine the changelog section to edit, aborting.');
7070
}
7171

7272
$changelog = $this->createUpdatedChangelog($version, $content, $pendingChangesStart, $pendingChangesEnd);
7373

74-
\file_put_contents($this->changelogPath, $changelog);
74+
file_put_contents($this->changelogPath, $changelog);
7575
}
7676

7777
private function createUpdatedChangelog(string $version, string $content, int $contentStart, int $contentEnd): string
7878
{
79-
$extractFrom = $contentStart + \mb_strlen(self::PENDING_CHANGES_START);
80-
$extractLength = $contentEnd - $contentStart - \mb_strlen(self::PENDING_CHANGES_START);
79+
$extractFrom = $contentStart + mb_strlen(self::PENDING_CHANGES_START);
80+
$extractLength = $contentEnd - $contentStart - mb_strlen(self::PENDING_CHANGES_START);
8181

82-
$newReleaseChanges = \trim(\mb_substr($content, $extractFrom, $extractLength));
82+
$newReleaseChanges = trim(mb_substr($content, $extractFrom, $extractLength));
8383

84-
$changelogStart = \trim(\mb_substr($content, 0, $contentStart));
85-
$changelogEnd = \trim(\mb_substr($content, $contentEnd + \mb_strlen(self::PENDING_CHANGES_END)));
84+
$changelogStart = trim(mb_substr($content, 0, $contentStart));
85+
$changelogEnd = trim(mb_substr($content, $contentEnd + mb_strlen(self::PENDING_CHANGES_END)));
8686

87-
$unreleasedLineStart = \mb_strpos($changelogStart, '## [Unreleased]');
88-
$changelogStart = \trim(\mb_substr($changelogStart, 0, $unreleasedLineStart));
87+
$unreleasedLineStart = mb_strpos($changelogStart, '## [Unreleased]');
88+
$changelogStart = trim(mb_substr($changelogStart, 0, $unreleasedLineStart));
8989

9090
$changelogTemplate = '[START]
9191
@@ -102,22 +102,22 @@ private function createUpdatedChangelog(string $version, string $content, int $c
102102
[END]
103103
';
104104

105-
$tempPath = \tempnam(\sys_get_temp_dir(), 'changelog-');
106-
\file_put_contents($tempPath, $newReleaseChanges);
107-
\system('pbcopy < '.$tempPath);
105+
$tempPath = tempnam(sys_get_temp_dir(), 'changelog-');
106+
file_put_contents($tempPath, $newReleaseChanges);
107+
system('pbcopy < '.$tempPath);
108108

109-
return \strtr($changelogTemplate, [
109+
return strtr($changelogTemplate, [
110110
'[START]' => $changelogStart,
111-
'[UNRELEASED_HEADER]' => \sprintf(self::UNRELEASED_CHANGES_HEADER, $this->githubUrl, $version),
111+
'[UNRELEASED_HEADER]' => sprintf(self::UNRELEASED_CHANGES_HEADER, $this->githubUrl, $version),
112112
'[PENDING_CHANGES_START]' => self::PENDING_CHANGES_START,
113113
'[PENDING_CHANGES_PLACEHOLDER]' => self::PENDING_CHANGES_PLACEHOLDER,
114114
'[PENDING_CHANGES_END]' => self::PENDING_CHANGES_END,
115-
'[NEW_RELEASE_HEADER]' => \sprintf(
115+
'[NEW_RELEASE_HEADER]' => sprintf(
116116
self::NEW_RELEASE_HEADER,
117117
$version,
118118
$this->githubUrl,
119119
$version,
120-
\date('Y-m-d')
120+
date('Y-m-d')
121121
),
122122
'[NEW_RELEASE_CHANGES]' => $newReleaseChanges,
123123
'[END]' => $changelogEnd,
@@ -126,14 +126,14 @@ private function createUpdatedChangelog(string $version, string $content, int $c
126126

127127
public function updateComposerAliasVersion(string $composerAliasVersion)
128128
{
129-
$json = \file_get_contents($this->composerConfigPath);
130-
$contents = \json_decode($json, \true);
129+
$json = file_get_contents($this->composerConfigPath);
130+
$contents = json_decode($json, true);
131131

132132
$contents['extra']['branch-alias']['dev-master'] = $composerAliasVersion.'-dev';
133133

134-
\file_put_contents(
134+
file_put_contents(
135135
$this->composerConfigPath,
136-
\json_encode($contents, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)."\n"
136+
json_encode($contents, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES)."\n"
137137
);
138138
}
139139
}

scripts/TestCase.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Contentful\Tests;
1313

1414
use Contentful\Core\Api\Link;
15+
1516
use function GuzzleHttp\json_decode as guzzle_json_decode;
1617
use function GuzzleHttp\json_encode as guzzle_json_encode;
18+
1719
use PHPUnit\Framework\TestCase as BaseTestCase;
1820

1921
/**
@@ -34,7 +36,7 @@ class TestCase extends BaseTestCase
3436
*/
3537
protected function markTestAsPassed()
3638
{
37-
$this->assertTrue(\true, 'Test case did not throw an exception and passed.');
39+
$this->assertTrue(true, 'Test case did not throw an exception and passed.');
3840
}
3941

4042
/**
@@ -53,7 +55,7 @@ protected function assertLink(string $id, string $linkType, Link $link, string $
5355
*/
5456
protected function assertJsonFixtureEqualsJsonObject(string $file, $object, string $message = '')
5557
{
56-
$dir = $this->convertClassToFixturePath(\debug_backtrace()[1]['class']);
58+
$dir = $this->convertClassToFixturePath(debug_backtrace()[1]['class']);
5759

5860
$this->assertJsonStringEqualsJsonFile($dir.'/'.$file, guzzle_json_encode($object), $message);
5961
}
@@ -63,16 +65,13 @@ protected function assertJsonFixtureEqualsJsonObject(string $file, $object, stri
6365
*/
6466
protected function assertJsonFixtureEqualsJsonString(string $file, string $string, string $message = '')
6567
{
66-
$dir = $this->convertClassToFixturePath(\debug_backtrace()[1]['class']);
68+
$dir = $this->convertClassToFixturePath(debug_backtrace()[1]['class']);
6769

6870
$this->assertJsonStringEqualsJsonFile($dir.'/'.$file, $string, $message);
6971
}
7072

7173
/**
7274
* Asserts that any two variables will be serialized to the same JSON structure.
73-
*
74-
* @param $expected
75-
* @param $object
7675
*/
7776
protected function assertJsonStructuresAreEqual($expected, $object, string $message = '')
7877
{
@@ -85,24 +84,24 @@ protected function assertJsonStructuresAreEqual($expected, $object, string $mess
8584

8685
protected function getFixtureContent(string $file): string
8786
{
88-
$dir = $this->convertClassToFixturePath(\debug_backtrace()[1]['class']);
87+
$dir = $this->convertClassToFixturePath(debug_backtrace()[1]['class']);
8988

90-
return \file_get_contents($dir.'/'.$file);
89+
return file_get_contents($dir.'/'.$file);
9190
}
9291

9392
/**
9493
* @return array|null
9594
*/
9695
protected function getParsedFixture(string $file)
9796
{
98-
$dir = $this->convertClassToFixturePath(\debug_backtrace()[1]['class']);
97+
$dir = $this->convertClassToFixturePath(debug_backtrace()[1]['class']);
9998

100-
return guzzle_json_decode(\file_get_contents($dir.'/'.$file), \true);
99+
return guzzle_json_decode(file_get_contents($dir.'/'.$file), true);
101100
}
102101

103102
protected function getTestFixturesPath(): string
104103
{
105-
return $this->convertClassToFixturePath(\debug_backtrace()[1]['class']);
104+
return $this->convertClassToFixturePath(debug_backtrace()[1]['class']);
106105
}
107106

108107
/**
@@ -118,17 +117,17 @@ protected function convertClassToFixturePath(string $class): string
118117
}
119118

120119
// Removes the initial common namespace prefix
121-
$extractedClass = \str_replace('Contentful\\Tests\\', '', $class);
120+
$extractedClass = str_replace('Contentful\\Tests\\', '', $class);
122121
// Removes the initial library specific prefix (Core, Delivery, Management, etc)
123-
$extractedClass = \mb_substr($extractedClass, \mb_strpos($extractedClass, '\\') + 1);
122+
$extractedClass = mb_substr($extractedClass, mb_strpos($extractedClass, '\\') + 1);
124123
// Converts the namespace separator to the directory separator, as defined in PSR-4
125-
$extractedClass = \str_replace('\\', \DIRECTORY_SEPARATOR, $extractedClass);
124+
$extractedClass = str_replace('\\', \DIRECTORY_SEPARATOR, $extractedClass);
126125
// Removes the "Test" suffix from the class name
127-
$extractedClass = \mb_substr($extractedClass, 0, -4);
126+
$extractedClass = mb_substr($extractedClass, 0, -4);
128127

129128
// Uses the path of the class to determine the starting point of the tests
130129
$reflection = new \ReflectionClass($class);
131-
$testsPath = \str_replace($extractedClass.'Test.php', '', $reflection->getFileName());
130+
$testsPath = str_replace($extractedClass.'Test.php', '', $reflection->getFileName());
132131

133132
return self::$classMap[$class] = $testsPath.'/Fixtures/'.$extractedClass;
134133
}

scripts/create-redirector.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,33 @@
99

1010
declare(strict_types=1);
1111

12-
$travisRepoSlug = \getenv('TRAVIS_REPO_SLUG');
12+
$travisRepoSlug = getenv('TRAVIS_REPO_SLUG');
1313
$indexFile = $argv[1];
1414

15-
$shellOutput = \shell_exec('git tag');
16-
$tags = \explode("\n", $shellOutput);
17-
$tags = \array_filter($tags, function ($tag) {
18-
return '' !== \trim($tag);
15+
$shellOutput = shell_exec('git tag');
16+
$tags = explode("\n", $shellOutput);
17+
$tags = array_filter($tags, function ($tag) {
18+
return '' !== trim($tag);
1919
});
2020

2121
// We remove all non-stable versions from the list as we don't want to direct the docs to them by default
22-
$tags = \array_filter($tags, function ($tag) {
23-
return false === \mb_strpos($tag, '-');
22+
$tags = array_filter($tags, function ($tag) {
23+
return false === mb_strpos($tag, '-');
2424
});
2525

26-
\usort($tags, function ($a, $b) {
27-
return \version_compare($b, $a);
26+
usort($tags, function ($a, $b) {
27+
return version_compare($b, $a);
2828
});
2929

3030
$tags[] = 'master';
3131

3232
$newestTag = $tags[0];
33-
$repoParts = \explode('/', $travisRepoSlug);
33+
$repoParts = explode('/', $travisRepoSlug);
3434
$repoOwner = $repoParts[0];
3535
$repoName = $repoParts[1];
3636

3737
$html = '<meta http-equiv="refresh" content="0; url=https://'.$repoOwner.'.github.io/'.$repoName.'/api/'.$newestTag.'" />';
3838

39-
\file_put_contents($indexFile, $html);
39+
file_put_contents($indexFile, $html);
4040

4141
echo 'Created index file redirecting to '.$newestTag.'.'."\n";

scripts/php-cs-fixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use PhpCsFixer\Finder;
1414

1515
return function (string $packageName, bool $usePhp7, array $directories, array $exclude = []): Config {
16-
$year = \date('Y');
16+
$year = date('Y');
1717

1818
$fileHeaderComment = <<<COMMENT
1919
This file is part of the contentful/$packageName package.
@@ -76,7 +76,7 @@
7676
$rules['ternary_to_null_coalescing'] = true;
7777
}
7878

79-
$cache = \tempnam(\sys_get_temp_dir(), $packageName).'-php_cs.cache';
79+
$cache = tempnam(sys_get_temp_dir(), $packageName).'-php_cs.cache';
8080

8181
return (new Config())
8282
->setFinder($finder)

scripts/release.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,29 @@ function message(string $message = '')
2828

2929
$version = $argv[1];
3030
$pattern = '/^(?<version>[0-9]+\.[0-9]+\.[0-9]+)(?<prerelease>-[0-9a-zA-Z.]+)?(?<build>\+[0-9a-zA-Z.]+)?$/';
31-
if (!\preg_match($pattern, $version)) {
31+
if (!preg_match($pattern, $version)) {
3232
exit_message('ERROR: Provided version is not a valid semver identifier, aborting.', 1);
3333
}
3434

35-
$composerAliasVersion = \null;
35+
$composerAliasVersion = null;
3636
if (isset($argv[2])) {
3737
$composerAliasVersion = $argv[2];
3838
$pattern = '/^(?<version>[0-9]+\.[0-9]+\.[0-9]+)$/';
39-
if (!\preg_match($pattern, $composerAliasVersion)) {
39+
if (!preg_match($pattern, $composerAliasVersion)) {
4040
exit_message('ERROR: Provided master alias version is not a valid semver identifier, aborting.', 1);
4141
}
4242
}
4343

44-
$changelogPath = \getcwd().'/CHANGELOG.md';
45-
$composerConfigPath = \getcwd().'/composer.json';
46-
$url = \shell_exec('git remote get-url origin');
47-
$url = \str_replace('github.com:', 'github.com/', $url);
48-
$url = 'https://'.\mb_substr($url, 4, -5);
44+
$changelogPath = getcwd().'/CHANGELOG.md';
45+
$composerConfigPath = getcwd().'/composer.json';
46+
$url = shell_exec('git remote get-url origin');
47+
$url = str_replace('github.com:', 'github.com/', $url);
48+
$url = 'https://'.mb_substr($url, 4, -5);
4949

5050
try {
5151
$updater = new ReleaseUpdater($changelogPath, $composerConfigPath, $url);
5252
$updater->updateChangelog($version);
53-
if (\null !== $composerAliasVersion) {
53+
if (null !== $composerAliasVersion) {
5454
$updater->updateComposerAliasVersion($composerAliasVersion);
5555
}
5656
} catch (\Exception $exception) {
@@ -59,20 +59,20 @@ function message(string $message = '')
5959

6060
message();
6161
message('Committing changes to changelog');
62-
\system('git add '.$changelogPath);
63-
\shell_exec('git commit --message="chore(release): Prepare version '.$version.'"');
62+
system('git add '.$changelogPath);
63+
shell_exec('git commit --message="chore(release): Prepare version '.$version.'"');
6464
message('Changes committed!');
6565
message();
6666

6767
message('Creating git tag');
68-
\shell_exec('git tag --sign '.$version.' --message="'.$version.'"');
68+
shell_exec('git tag --sign '.$version.' --message="'.$version.'"');
6969
message('Tag created!');
7070
message();
7171

72-
if (\null !== $composerAliasVersion) {
72+
if (null !== $composerAliasVersion) {
7373
message('Committing changes to composer.json');
74-
\shell_exec('git add '.$composerConfigPath);
75-
\shell_exec('git commit --message="chore(release): Prepare development of next version"');
74+
shell_exec('git add '.$composerConfigPath);
75+
shell_exec('git commit --message="chore(release): Prepare development of next version"');
7676
message('Changes committed!');
7777
message();
7878
}

src/Api/BaseClient.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public function __construct(
7575
$this->getExceptionNamespace()
7676
);
7777

78-
if ('/' === \mb_substr($host, -1)) {
79-
$host = \mb_substr($host, 0, -1);
78+
if ('/' === mb_substr($host, -1)) {
79+
$host = mb_substr($host, 0, -1);
8080
}
8181
$this->host = $host;
8282

@@ -126,7 +126,7 @@ protected function callApi(string $method, string $uri, array $options = []): ar
126126
*/
127127
private function logMessage(Message $message)
128128
{
129-
$logMessage = \sprintf(
129+
$logMessage = sprintf(
130130
'%s %s (%.3Fs)',
131131
$message->getRequest()->getMethod(),
132132
(string) $message->getRequest()->getUri(),
@@ -153,7 +153,7 @@ private function parseResponse(ResponseInterface $response = null)
153153
: null;
154154

155155
return $body
156-
? \json_decode($body, true)
156+
? json_decode($body, true)
157157
: [];
158158
}
159159

@@ -257,8 +257,8 @@ protected static function getVersionForPackage(string $package): string
257257
;
258258

259259
// Removes the ".x-dev" part which is inserted during development
260-
if ('.x-dev' === \mb_substr($shortVersion, -6)) {
261-
$shortVersion = \mb_substr($shortVersion, 0, -6).'-dev';
260+
if ('.x-dev' === mb_substr($shortVersion, -6)) {
261+
$shortVersion = mb_substr($shortVersion, 0, -6).'-dev';
262262
}
263263

264264
return $shortVersion;

0 commit comments

Comments
 (0)