From 130b5a029fcf6608c462d9fd2e7429e45436a5e5 Mon Sep 17 00:00:00 2001 From: freek Date: Fri, 28 Jul 2017 23:41:36 -0400 Subject: [PATCH] avoid aliasing interfaces --- CHANGELOG.md | 4 ++++ src/ShortClassNames.php | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e74ba8..08de19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-tinker-tools` will be documented in this file +## 1.0.1 - 2017-07-28 + +- avoid aliasing interfaces + ## 1.0.0 - 2017-05-22 - initial release diff --git a/src/ShortClassNames.php b/src/ShortClassNames.php index ee41c9d..6a0b6c2 100644 --- a/src/ShortClassNames.php +++ b/src/ShortClassNames.php @@ -2,6 +2,8 @@ namespace Spatie\TinkerTools; +use ReflectionClass; + class ShortClassNames { /** @var \Illuminate\Support\Collection */ @@ -36,7 +38,11 @@ public function registerAutoloader() public function aliasClass($findClass) { $class = $this->classes->first(function ($class) use ($findClass) { - return $class['name'] === $findClass; + if ($class['name'] !== $findClass) { + return false; + }; + + return ! (new ReflectionClass($class['fqcn']))->isInterface(); }); if (! $class) {