From c07856219b4fa3b14f164db30a5ecc172f8a004a Mon Sep 17 00:00:00 2001 From: dantleech Date: Sat, 2 Jan 2021 22:04:34 +0000 Subject: [PATCH 01/12] Add common README sections (#7) --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 2095db24..f480f40c 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,16 @@ Assert::assertTrue($workspace->exists('lib/Foo/ClassTwo.php')); echo $workspace->getContents('/lib/Foo/ClassTwo.php'); ``` + +Contributing +------------ + +This package is open source and welcomes contributions! Feel free to open a +pull request on this repository. + +Support +------- + +- Create an issue on the main [Phpactor](https://github.com/phpactor/phpactor) repository. +- Join the `#phpactor` channel on the Slack [Symfony Devs](https://symfony.com/slack-invite) channel. + From 7ec658b793912eeb03cba8f954e46928e009a93b Mon Sep 17 00:00:00 2001 From: dantleech Date: Wed, 6 Jan 2021 22:10:03 +0000 Subject: [PATCH 02/12] Update gitignore (#8) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 217f2292..09bcb8b3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /composer.lock /.php_cs.cache /stubs +/.vscode \ No newline at end of file From 81bf70c4c891f50c7d91a720ec1b3d2a592960af Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 24 Jan 2021 17:48:36 +0000 Subject: [PATCH 03/12] Update coding standard (#9) --- .github/workflows/ci.yml | 2 +- .php_cs.dist | 7 +++- tests/Integration/WorkspaceTest.php | 50 ++++++++++++++--------------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 312b1c94..b30fc14d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: "Run friendsofphp/php-cs-fixer" - run: "vendor/bin/php-cs-fixer fix --dry-run --diff --verbose" + run: "vendor/bin/php-cs-fixer fix --dry-run --diff --verbose --allow-risky=yes" phpstan: name: "PHPStan (${{ matrix.php-version }})" diff --git a/.php_cs.dist b/.php_cs.dist index a3d5fa36..2820b890 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -4,7 +4,7 @@ $finder = PhpCsFixer\Finder::create() ->in('lib') ->in('tests') ->exclude([ - 'tests/Workspace' + 'tests/Workspace', ]) ; @@ -13,6 +13,11 @@ return PhpCsFixer\Config::create() '@PSR2' => true, 'no_unused_imports' => true, 'array_syntax' => ['syntax' => 'short'], + 'void_return' => true, + 'ordered_class_elements' => true, + 'single_quote' => true, + 'heredoc_indentation' => true, + 'global_namespace_import' => true, ]) ->setFinder($finder) ; diff --git a/tests/Integration/WorkspaceTest.php b/tests/Integration/WorkspaceTest.php index 818cc7eb..bdab2f75 100644 --- a/tests/Integration/WorkspaceTest.php +++ b/tests/Integration/WorkspaceTest.php @@ -13,26 +13,26 @@ protected function setUp(): void $this->workspace->reset(); } - public function testBuild() + public function testBuild(): void { $manifest = <<<'EOT' -// File: Foobar.php -workspace->loadManifest($manifest); @@ -43,7 +43,7 @@ class Barfoo $this->assertEquals('Hello World', $this->workspace->getContents('Expected.php')); } - public function testGetContentsNotExist() + public function testGetContentsNotExist(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('File "barbarbarbar" does not exist'); @@ -51,7 +51,7 @@ public function testGetContentsNotExist() $this->workspace->getContents('barbarbarbar'); } - public function testReset() + public function testReset(): void { $this->workspace->reset(); touch($this->workspace->path('Foobar.php')); @@ -67,31 +67,31 @@ public function testReset() $this->assertFalse($this->workspace->exists('Barfoo/Bazboo.php')); } - public function testMkdir() + public function testMkdir(): void { $this->workspace->mkdir('foobar'); $this->assertTrue($this->workspace->exists('foobar')); $this->assertFalse($this->workspace->exists('barfoo')); } - public function testPutFileContents() + public function testPutFileContents(): void { $this->workspace->put('foobar', 'foobar contents'); $this->assertTrue($this->workspace->exists('foobar')); $this->assertStringContainsString('foobar contents', $this->workspace->getContents('foobar')); } - public function testGetPathWithNoArgs() + public function testGetPathWithNoArgs(): void { $this->assertEquals($this->workspaceDir(), $this->workspace->path()); } - public function testGetPath() + public function testGetPath(): void { $this->assertEquals($this->workspaceDir() . '/foo', $this->workspace->path('foo')); } - public function testGetPathConcat() + public function testGetPathConcat(): void { $workspace = Workspace::create($this->workspaceDir() . '/foobar/'); $this->assertEquals($this->workspaceDir() . '/foobar/foo', $workspace->path('foo')); From f018178ba67b3cd4cdea742f4671b53b6e75b7b8 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 31 Jan 2021 16:45:14 +0000 Subject: [PATCH 04/12] Maestro adds support for PHP 8.0 (#6) --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 928c9b35..76916e69 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } ], "require": { - "php": "^7.3", + "php": "^7.3 || ^8.0", "webmozart/path-util": "^2.3" }, "require-dev": { @@ -44,4 +44,4 @@ "vendor/bin/phpunit" ] } -} \ No newline at end of file +} From e87a756bbdfb0dab81f2ab83e23d78aea468c236 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 31 Jan 2021 16:48:52 +0000 Subject: [PATCH 05/12] Maestro adds support for PHP 8.0 (#10) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b30fc14d..1b5084f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,7 @@ jobs: php-version: - '7.3' - '7.4' + - '8.0' steps: - From 1a2531b54a56f71fab270100d90d9ec6e27bff62 Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Sat, 6 Feb 2021 14:38:53 +0000 Subject: [PATCH 06/12] Update deps --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 09bcb8b3..e87ba04f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /composer.lock /.php_cs.cache /stubs -/.vscode \ No newline at end of file +/.vscode +.php_cs.cache \ No newline at end of file From b29299f23c4edbb2eca700cdba194d643d268ccd Mon Sep 17 00:00:00 2001 From: mamazu <14860264+mamazu@users.noreply.github.com> Date: Sun, 14 Aug 2022 17:19:34 +0200 Subject: [PATCH 07/12] Replace webmozart/path-util with symfony/filesystem (#11) --- composer.json | 5 ++++- lib/Workspace.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 76916e69..f34a46e6 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "require": { "php": "^7.3 || ^8.0", - "webmozart/path-util": "^2.3" + "symfony/filesystem": "^4.2 || ^5.0" }, "require-dev": { "dms/phpunit-arraysubset-asserts": "dev-master", @@ -43,5 +43,8 @@ "vendor/bin/phpstan analyse lib -c phpstan.neon", "vendor/bin/phpunit" ] + }, + "config": { + "allow-plugins": true } } diff --git a/lib/Workspace.php b/lib/Workspace.php index a1dabdc9..392f6fb9 100644 --- a/lib/Workspace.php +++ b/lib/Workspace.php @@ -7,7 +7,7 @@ use RecursiveIteratorIterator; use RuntimeException; use SplFileInfo; -use Webmozart\PathUtil\Path; +use Symfony\Component\Filesystem\Path; class Workspace { From 595830fe7be899d188e2eb927c2077a9cfbd8f5b Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Sun, 16 Oct 2022 10:48:01 +0200 Subject: [PATCH 08/12] Add better type hints --- lib/ExtractOffset.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ExtractOffset.php b/lib/ExtractOffset.php index 792f18f8..c9acd5c1 100644 --- a/lib/ExtractOffset.php +++ b/lib/ExtractOffset.php @@ -9,21 +9,21 @@ class ExtractOffset { /** - * @return array + * @return array{string,int,int} */ public static function fromSource(string $source, string $marker = '<>'): array { list($source, $offsetStart) = self::extractOffset($source, $marker); list($source, $offsetEnd) = self::extractOffset($source, $marker); - return [$source, $offsetStart, $offsetEnd]; + return [$source, (int)$offsetStart, (int)$offsetEnd]; } /** * Extract the byte offset from the given marked source * and remove the <> mark. * - * @return array + * @return array{string,int} */ private static function extractOffset(string $source, string $marker): array { From a92a71e8874698899b652295b7c3fcd5040ca8f3 Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Fri, 26 Jan 2024 16:30:26 +0000 Subject: [PATCH 09/12] Update composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f34a46e6..de4aed13 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ ], "require": { "php": "^7.3 || ^8.0", - "symfony/filesystem": "^4.2 || ^5.0" + "symfony/filesystem": "^4.2 || ^5.0 || ^6.0 || ^7.0" }, "require-dev": { "dms/phpunit-arraysubset-asserts": "dev-master", From 56554285ef5acb6b5bf62753d0dccb68b2401a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Fri, 1 Mar 2024 21:28:54 +0100 Subject: [PATCH 10/12] Replace uses of PHP_EOL with "\n" (#12) See phpactor/phpactor#2567. --- lib/Workspace.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Workspace.php b/lib/Workspace.php index 392f6fb9..1d89e306 100644 --- a/lib/Workspace.php +++ b/lib/Workspace.php @@ -118,7 +118,7 @@ public function loadManifest(string $manifest): void */ private function parseManifest(string $manifest): array { - $lines = explode(PHP_EOL, $manifest); + $lines = explode("\n", $manifest); $buffer = []; $currentFile = null; @@ -143,7 +143,7 @@ private function parseManifest(string $manifest): array } return array_map(function (array $lines) { - return implode(PHP_EOL, $lines); + return implode("\n", $lines); }, $buffer); } From 2b7ff3a9ef9cbc625fb9630e2b3e43cad335b6a7 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Mon, 23 Dec 2024 21:00:31 +0100 Subject: [PATCH 11/12] fix: Path::canonicalize all test workspace paths (#13) As part of port-to-windows effort, normalize paths used by tests. --- lib/Workspace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Workspace.php b/lib/Workspace.php index 1d89e306..5d0e6fe2 100644 --- a/lib/Workspace.php +++ b/lib/Workspace.php @@ -18,7 +18,7 @@ class Workspace public function __construct(string $path) { - $this->path = $path; + $this->path = Path::canonicalize($path); } public static function create(string $path): self From 7d081c8e187da3a86e835c28e82e0ce0dbfaef9c Mon Sep 17 00:00:00 2001 From: Daniel Leech Date: Tue, 24 Dec 2024 17:52:07 +0000 Subject: [PATCH 12/12] Fix missing property --- tests/Integration/WorkspaceTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Integration/WorkspaceTest.php b/tests/Integration/WorkspaceTest.php index bdab2f75..fda39efc 100644 --- a/tests/Integration/WorkspaceTest.php +++ b/tests/Integration/WorkspaceTest.php @@ -7,6 +7,11 @@ class WorkspaceTest extends IntegrationTestCase { + /** + * @var Workspace + */ + private $workspace; + protected function setUp(): void { $this->workspace = Workspace::create($this->workspaceDir());