From 193da246b01c8ad302a1924e23bc4a8089302856 Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Sat, 28 Oct 2017 23:21:16 +0300 Subject: [PATCH 1/2] Refactor for new plugin --- composer.json | 22 +++++++----- phpunit.xml | 2 +- {src => source}/ImmutableClassesTrait.php | 0 {src => source}/macros.yay | 0 tests/MacroTest.php | 42 ++++++++++++++++++++--- tests/bootstrap.php | 18 ---------- tests/specs/fallbacks.spec | 8 +---- tests/specs/immutability.spec | 10 ++---- tests/stubs.php | 9 +++++ 9 files changed, 63 insertions(+), 48 deletions(-) rename {src => source}/ImmutableClassesTrait.php (100%) rename {src => source}/macros.yay (100%) delete mode 100644 tests/bootstrap.php create mode 100644 tests/stubs.php diff --git a/composer.json b/composer.json index db60c7c..b7d70c2 100644 --- a/composer.json +++ b/composer.json @@ -2,25 +2,29 @@ "type": "pre-macro", "name": "pre/immutable-classes", "license": "MIT", + "repositories": [ + { + "type": "path", + "url": "../pre-plugin" + } + ], "require": { - "pre/plugin": "^0.7.3" + "pre/plugin": "*" }, "autoload": { "psr-4": { - "Pre\\ImmutableClasses\\": "src" + "Pre\\ImmutableClasses\\": "source" } }, "require-dev": { "phpunit/phpunit": "^5.0|^6.0" }, "autoload-dev": { - "psr-4": { - "Pre\\ImmutableClasses\\": "tests" - } + "files": ["tests/stubs.php"] }, "extra": { - "macros": [ - "src/macros.yay" - ] - } + "macros": ["source/macros.yay"] + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/phpunit.xml b/phpunit.xml index 829414b..5543800 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,7 +2,7 @@ format($from))); + $this->assertEquals($this->format($expected), $actual); + } + + private function format($code) + { + return " Date: Sun, 29 Oct 2017 00:09:12 +0300 Subject: [PATCH 2/2] Use tagged plugin --- composer.json | 15 ++------------- source/macros.yay | 2 +- tests/MacroTest.php | 2 -- tests/specs/fallbacks.spec | 4 ++-- tests/stubs.php | 9 --------- 5 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 tests/stubs.php diff --git a/composer.json b/composer.json index b7d70c2..d3acb55 100644 --- a/composer.json +++ b/composer.json @@ -2,14 +2,8 @@ "type": "pre-macro", "name": "pre/immutable-classes", "license": "MIT", - "repositories": [ - { - "type": "path", - "url": "../pre-plugin" - } - ], "require": { - "pre/plugin": "*" + "pre/plugin": "^0.10.0" }, "autoload": { "psr-4": { @@ -19,12 +13,7 @@ "require-dev": { "phpunit/phpunit": "^5.0|^6.0" }, - "autoload-dev": { - "files": ["tests/stubs.php"] - }, "extra": { "macros": ["source/macros.yay"] - }, - "minimum-stability": "dev", - "prefer-stable": true + } } diff --git a/source/macros.yay b/source/macros.yay index df002f7..3e02d15 100644 --- a/source/macros.yay +++ b/source/macros.yay @@ -12,7 +12,7 @@ macro { } } -macro { +macro ·unsafe { function __call(···parameters) { immutability; ···body diff --git a/tests/MacroTest.php b/tests/MacroTest.php index 4f3ffe7..6e52754 100644 --- a/tests/MacroTest.php +++ b/tests/MacroTest.php @@ -2,8 +2,6 @@ use PHPUnit\Framework\TestCase; -putenv("PRE_BASE_DIR=" . realpath(__DIR__ . "/../")); - class MacroTest extends TestCase { /** diff --git a/tests/specs/fallbacks.spec b/tests/specs/fallbacks.spec index 958ae5f..60faf50 100644 --- a/tests/specs/fallbacks.spec +++ b/tests/specs/fallbacks.spec @@ -16,8 +16,8 @@ class MyImmutableClass public function __call($method, $parameters) { - if ($result·1 = $this->handleCallImmutableClassSetters($method, $parameters)) { - return $result·1; + if ($result = $this->handleCallImmutableClassSetters($method, $parameters)) { + return $result; } print "fallback"; diff --git a/tests/stubs.php b/tests/stubs.php deleted file mode 100644 index d714f68..0000000 --- a/tests/stubs.php +++ /dev/null @@ -1,9 +0,0 @@ -