Skip to content

Commit

Permalink
Fix: GetNamespace no longer checks if class|interface|trait is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartherbert committed Sep 17, 2017
1 parent eac156a commit e84176a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Expand Up @@ -156,6 +156,10 @@
- added `Error`
- added `TypeError`

### Fixes

* `GetNamespace` no longer cares if the class|interface|trait name has been declared to PHP

### Refactor

Before refactoring, we checked Packagist to make sure that these changes would not break anything that depends upon The Missing Bits.
Expand Down
5 changes: 0 additions & 5 deletions src/TypeInspectors/GetNamespace.php
Expand Up @@ -91,11 +91,6 @@ public static function from($item)
throw new InvalidArgumentException("\$item must be an object, or a class/interface/trait name");
}

// make sure we have something we can work with
if (!class_exists($item) && !interface_exists($item) && !trait_exists($item)) {
throw new InvalidArgumentException("{$item} is not a declared class");
}

// okay, what do we have?
$pos = strrpos($item, '\\');
if ($pos) {
Expand Down
24 changes: 0 additions & 24 deletions tests/TypeInspectors/GetNamespaceTest.php
Expand Up @@ -205,30 +205,6 @@ public function testReturnsEmptyStringForClassesWithNoNamespace($data, $expected
$this->assertEquals($expectedNamespace, $actualNamespace);
}

/**
* @covers ::getNamespace
* @covers ::from
* @dataProvider provideNonDefinedClassesToTest
* @expectedException InvalidArgumentException
*/
public function test_throws_InvalidArgumentException_if_class_not_defined($data)
{
// ----------------------------------------------------------------
// setup your test

$this->assertTrue(is_string($data));
$unit = new GetNamespace();

// ----------------------------------------------------------------
// perform the change

$unit->getNamespace($data);

// ----------------------------------------------------------------
// test the results

}

/**
* @covers ::getNamespace
* @covers ::from
Expand Down

0 comments on commit e84176a

Please sign in to comment.