Skip to content

Commit

Permalink
Fix build on php 7
Browse files Browse the repository at this point in the history
  • Loading branch information
hanneskod committed Mar 2, 2016
1 parent 3842b3f commit d3ced36
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
@@ -1,3 +1,5 @@
sudo: false

language: php

php:
Expand All @@ -7,7 +9,7 @@ php:
- 5.5

install:
- composer install --dev --prefer-source
- composer install

script:
- phpunit
19 changes: 12 additions & 7 deletions README.md
Expand Up @@ -5,15 +5,19 @@
[![Quality Score](https://img.shields.io/scrutinizer/g/hanneskod/classtools.svg?style=flat-square)](https://scrutinizer-ci.com/g/hanneskod/classtools)
[![Dependency Status](https://img.shields.io/gemnasium/hanneskod/classtools.svg?style=flat-square)](https://gemnasium.com/hanneskod/classtools)

Find, extract and process classes from file system.
Find, extract and process classes from the file system.

> Install using **[composer](http://getcomposer.org/)**. Exists as
> **[hanneskod/classtools](https://packagist.org/packages/hanneskod/classtools)**
> in the **[packagist](https://packagist.org/)** repository.
Installation
------------
Install using **[composer](http://getcomposer.org/)**. Exists as
**[hanneskod/classtools](https://packagist.org/packages/hanneskod/classtools)**
in the **[packagist](https://packagist.org/)** repository. From the command line
use:

composer require hanneskod/classtools:~1.0

## Iterator

Using the iterator
------------------
[ClassIterator](src/Iterator/ClassIterator.php) consumes a [symfony
finder](http://symfony.com/doc/current/components/finder.html) and scans files
for php classes, interfaces and traits.
Expand Down Expand Up @@ -117,7 +121,8 @@ echo $iter->minimize();
echo $iter->transform(new hanneskod\classtools\Transformer\MinimizingWriter);
```

## Transformer examples
Using the transformer
---------------------

### Wrap code in namespace

Expand Down
34 changes: 17 additions & 17 deletions tests/Iterator/ClassIteratorTest.php
Expand Up @@ -13,8 +13,8 @@ public static function setupBeforeClass()
MockFinder::setIterator(
new \ArrayIterator([
new MockSplFileInfo('<?php namespace foobar; use \\some\\name; class A {}'),
new MockSplFileInfo('<?php interface Int {}'),
new MockSplFileInfo('<?php class B implements Int {} class C extends \foobar\A implements Int {}')
new MockSplFileInfo('<?php interface Baz {}'),
new MockSplFileInfo('<?php class B implements Baz {} class C extends \foobar\A implements Baz {}')
])
);

Expand Down Expand Up @@ -92,24 +92,24 @@ public function testTypeFilter()
$classIterator = $this->getSystemUnderTest();

$result = iterator_to_array(
$classIterator->type('Int')
$classIterator->type('Baz')
);

$this->assertArrayNotHasKey(
'foobar\\A',
$result,
'foobar\\A does not implement Int'
'foobar\\A does not implement Baz'
);

$this->assertArrayHasKey(
'B',
$result,
'B does implement Int'
'B does implement Baz'
);

$result = iterator_to_array(
$classIterator
->type('Int')
->type('Baz')
->type('foobar\\A')
);

Expand All @@ -135,7 +135,7 @@ public function testNameFilter()
);

$this->assertArrayNotHasKey(
'Int',
'Baz',
$result
);

Expand All @@ -145,7 +145,7 @@ public function testNameFilter()
);

$result = iterator_to_array(
$classIterator->name('/I/')->name('/nt/')
$classIterator->name('/B/')->name('/az/')
);

$this->assertArrayNotHasKey(
Expand All @@ -154,7 +154,7 @@ public function testNameFilter()
);

$this->assertArrayHasKey(
'Int',
'Baz',
$result
);
}
Expand All @@ -168,7 +168,7 @@ public function testNamespaceFilter()
);

$this->assertArrayNotHasKey(
'Int',
'Baz',
$result
);

Expand All @@ -193,9 +193,9 @@ public function testWhereFilter()
);

$this->assertArrayHasKey(
'Int',
'Baz',
$result,
'Int is an interface'
'Baz is an interface'
);
}

Expand All @@ -208,9 +208,9 @@ public function testNotFilter()
);

$this->assertArrayNotHasKey(
'Int',
'Baz',
$result,
'Int is an interface (and thus not included using the not filter)'
'Baz is an interface (and thus not included using the not filter)'
);

$this->assertArrayHasKey(
Expand Down Expand Up @@ -247,17 +247,17 @@ class A
}
}
namespace {
interface Int
interface Baz
{
}
}
namespace {
class B implements \\Int
class B implements \\Baz
{
}
}
namespace {
class C extends \\foobar\\A implements \\Int
class C extends \\foobar\\A implements \\Baz
{
}
}
Expand Down

0 comments on commit d3ced36

Please sign in to comment.