diff --git a/.travis.yml b/.travis.yml index 93abdd19..e934e976 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,4 +16,7 @@ notifications: email: - ci@andrewsville.cz -script: phpunit tests/TokenReflection \ No newline at end of file +before_script: + - composer update --dev + +script: phpunit tests/TokenReflection diff --git a/TokenReflection/Broker.php b/TokenReflection/Broker.php index 3b216901..6e670503 100644 --- a/TokenReflection/Broker.php +++ b/TokenReflection/Broker.php @@ -17,6 +17,8 @@ use TokenReflection\Broker, TokenReflection\Exception; use RecursiveDirectoryIterator, RecursiveIteratorIterator; +use Symfony\Component\Finder\Finder; +use Symfony\Component\Finder\SplFileInfo; // Detect if we have native traits support define('NATIVE_TRAITS', defined('T_TRAIT')); @@ -275,25 +277,24 @@ public function processDirectory($path, $filters = array(), $returnReflectionFil } try { - $result = array(); - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($realPath)) as $entry) { - if ($entry->isFile()) { - $process = empty($filters); - if (!$process) { - foreach ((array) $filters as $filter) { - $whitelisting = '!' !== $filter{0}; - if (fnmatch($whitelisting ? $filter : substr($filter, 1), $entry->getPathName(), FNM_NOESCAPE)) { - $process = $whitelisting; - } - } - } + $files = Finder::create()->files()->name('*.php')->ignoreVCS(true)->ignoreDotFiles(true)->ignoreUnreadableDirs(); - if ($process) { - $result[$entry->getPathName()] = $this->processFile($entry->getPathName(), $returnReflectionFile); - } + foreach ($filters as $filter) { + if ('!' === $filter{0}) { + $files->notPath(substr($filter,1)); + } else { + $files->path($filter); } } + $files->in($realPath); + + $result = array(); + foreach ($files as $entry) { + /** @var SplFileInfo $entry */ + $result[$entry->getPathName()] = $this->processFile($entry->getPathName(), $returnReflectionFile); + } + return $returnReflectionFile ? $result : true; } catch (Exception\ParseException $e) { throw $e; diff --git a/TokenReflection/ReflectionClass.php b/TokenReflection/ReflectionClass.php index a2c55a8d..aacbd9bd 100644 --- a/TokenReflection/ReflectionClass.php +++ b/TokenReflection/ReflectionClass.php @@ -1437,6 +1437,7 @@ public function setStaticPropertyValue($name, $value) */ public function __toString() { + try { $implements = ''; $interfaceNames = $this->getInterfaceNames(); if (count($interfaceNames) > 0) { @@ -1524,6 +1525,9 @@ public function __toString() $properties, $methods ); + } catch (\Exception $e) { + return __CLASS__; + } } /** diff --git a/TokenReflection/ReflectionMethod.php b/TokenReflection/ReflectionMethod.php index eddf5af1..e419a5bd 100644 --- a/TokenReflection/ReflectionMethod.php +++ b/TokenReflection/ReflectionMethod.php @@ -384,7 +384,7 @@ public function __toString() $prototype = ', prototype ' . $this->getPrototype()->getDeclaringClassName(); } catch (Exception\RuntimeException $e) { if ($declaringClassParent && $declaringClassParent->isInternal()) { - $internal = 'internal:' . $parentClass->getExtensionName(); + $internal = 'internal:' . $declaringClassParent->getExtensionName(); } } diff --git a/composer.json b/composer.json index 1569e612..a65744ac 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "require": { "php": ">=5.3.0", - "ext-tokenizer": "*" + "ext-tokenizer": "*", + "symfony/finder" : "@stable" }, "autoload": {