Skip to content

Commit 33bd505

Browse files
authored
Merge pull request #10 from phpactor/maestro-sync
Update Meta and CI
2 parents 524af90 + 033d63c commit 33bd505

19 files changed

+77
-47
lines changed

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
vendor/
2-
composer.lock
3-
phpunit.xml
4-
composer.phar
5-
tests/Integration/workspace
1+
/vendor
2+
/tests/Workspace
3+
/tests/Assets/workspace
4+
/phpbench.json
5+
/composer.lock
6+
/.php_cs.cache

.php_cs.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('lib')
5+
->in('tests')
6+
->exclude([
7+
'Integration/Composer/project'
8+
])
9+
;
10+
11+
return PhpCsFixer\Config::create()
12+
->setRules([
13+
'@PSR2' => true,
14+
'no_unused_imports' => true,
15+
'array_syntax' => ['syntax' => 'short'],
16+
])
17+
->setFinder($finder)
18+
;
19+

.travis.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
language: php
2+
23
php:
3-
- 7.0
44
- 7.1
5-
5+
- 7.2
6+
- 7.3
7+
68
sudo: false
79

810
cache:
9-
directories:
10-
- $HOME/.composer/cache
11+
directories:
12+
- $HOME/.composer/cache
1113

1214
before_script:
13-
- composer install
15+
- composer install
1416

15-
script:
16-
- phpunit
17+
script:
18+
- ./vendor/bin/php-cs-fixer fix --dry-run
19+
- ./vendor/bin/phpstan analyse lib -c phpstan.neon
20+
- ./vendor/bin/phpunit
21+

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
"webmozart/path-util": "^2.3"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^6.1",
17-
"symfony/filesystem": "^3.2"
16+
"phpunit/phpunit": "~7.0",
17+
"symfony/filesystem": "^3.2",
18+
"friendsofphp/php-cs-fixer": "~2.15.0",
19+
"phpstan/phpstan": "~0.11.0"
1820
},
1921
"autoload": {
2022
"psr-4": {

lib/Adapter/Composer/ComposerClassToFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Phpactor\ClassFileConverter\Domain\ClassToFile;
66
use Composer\Autoload\ClassLoader;
77
use Phpactor\ClassFileConverter\Domain\ClassName;
8-
use Phpactor\ClassFileConverter\Domain\FilePath;
98
use Phpactor\ClassFileConverter\Domain\FilePathCandidates;
109
use Psr\Log\LoggerInterface;
1110
use Psr\Log\NullLogger;
@@ -103,7 +102,8 @@ private function getFileCandidates(ClassName $className, array $prefixes)
103102
$paths = array_map(function ($path) {
104103
if (!file_exists($path)) {
105104
$this->logger->warning(sprintf(
106-
'Composer mapped path "%s" does not exist', $path
105+
'Composer mapped path "%s" does not exist',
106+
$path
107107
));
108108

109109
return $path;

lib/Adapter/Composer/ComposerFileToClass.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ private function populateCandidates(FilePath $filePath, array $prefixes)
7373
{
7474
$candidates = [];
7575
foreach ($prefixes as $classPrefix => $pathPrefixes) {
76-
7776
$pathPrefixes = (array) $pathPrefixes;
7877

7978
// remove any relativeness from the paths
@@ -85,7 +84,6 @@ private function populateCandidates(FilePath $filePath, array $prefixes)
8584
}, $pathPrefixes);
8685

8786
foreach ($pathPrefixes as $pathPrefix) {
88-
8987
if ((string) $filePath == $pathPrefix) {
9088
$candidates[] = [ $pathPrefix, $classPrefix ];
9189
continue;

lib/Adapter/Composer/Psr0NameInflector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function inflectToRelativePath(string $prefix, ClassName $className, stri
1414
$className = implode('\\', $elements);
1515
}
1616

17-
$relativePath = str_replace('\\', '/', $className).'.php';
17+
$relativePath = str_replace('\\', '/', (string) $className).'.php';
1818

1919
return FilePath::fromParts([$mappedPath, $relativePath]);
2020
}

lib/Adapter/Simple/ClassScanner.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Phpactor\ClassFileConverter\Adapter\Simple;
44

5+
use RuntimeException;
6+
57
/**
68
* Return the class name from a file.
79
*
@@ -17,6 +19,13 @@ public function getClassNameFromFile($file)
1719

1820
$fp = fopen($file, 'r');
1921

22+
if (false === $fp) {
23+
throw new RuntimeException(sprintf(
24+
'Could not open file "%s"',
25+
$file
26+
));
27+
}
28+
2029
$class = $namespace = $buffer = '';
2130
$i = 0;
2231

lib/Adapter/Simple/SimpleClassToFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function classToFileCandidates(ClassName $className): FilePathCandidates
4444
if (ClassName::fromString(
4545
$this->classScanner->getClassNameFromFile($phpFile->getPathName())
4646
) == $className) {
47-
$candidates[] = FilePath::fromString($phpFile->getPathName());
47+
$candidates[] = FilePath::fromString($phpFile->getPathName());
4848
}
4949
}
5050

lib/Adapter/Simple/SimpleFileToClass.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Phpactor\ClassFileConverter\Domain\ClassNameCandidates;
77
use Phpactor\ClassFileConverter\Domain\FilePath;
88
use Phpactor\ClassFileConverter\Domain\ClassName;
9-
use Phpactor\ClassFileConverter\Adapter\Simple\ClassScanner;
109

1110
class SimpleFileToClass implements FileToClass
1211
{

0 commit comments

Comments
 (0)