Skip to content

Commit 5639f4b

Browse files
committed
remove --php5 --php7 --php8 options
close #77
1 parent bb7f53d commit 5639f4b

File tree

6 files changed

+3
-56
lines changed

6 files changed

+3
-56
lines changed

CHANGELOG.md

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

33

44
* rename directory doc to docs.
5+
* Tests refactoring #75 by @pmaasz
6+
* remove --php5 --php7 --php8 options #78
57

68
## v1.3.1 (2024-07-05)
79

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@ OPTIONS
114114
--hide-private-properties hide private properties.
115115
--hide-private-methods hide private methods.
116116
--svg-topurl specifies the top URL when displaying the class as a link when outputting in SVG format.
117-
--php5 parse php source file as php5.
118-
--php7 parse php source file as php7.
119-
--php8 parse php source file as php8. (not supported)
120117
--header='header string' additional header string. You can specify multiple header values.
121118
--include='wildcard' include target file pattern. (default: `*.php`) You can specify multiple include patterns.
122119
--exclude='wildcard' exclude target file pattern. You can specify multiple exclude patterns.

bin/php-class-diagram

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ $options = getopt('hv', [
3434
'hide-private-properties',
3535
'hide-private-methods',
3636
'svg-topurl::',
37-
'php7',
38-
'php8',
3937
'header::',
4038
'include::',
4139
'exclude::',
@@ -64,9 +62,6 @@ OPTIONS
6462
--hide-private-properties hide private properties.
6563
--hide-private-methods hide private methods.
6664
--svg-topurl Specifies the top URL when displaying the class as a link when outputting in SVG format.
67-
--php5 parse php source file as php5.
68-
--php7 parse php source file as php7.
69-
--php8 parse php source file as php8. (not supported)
7065
--header='header string' additional header string. You can specify multiple header values.
7166
--include='wildcard' include target file pattern. (default: `*.php`) You can specify multiple include patterns.
7267
--exclude='wildcard' exclude target file pattern. You can specify multiple exclude patterns.

src/Config/Options.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ final class Options
99
/** @var array<string, mixed> */
1010
private array $opt;
1111

12-
public const PHP5 = 'php5';
13-
public const PHP7 = 'php7';
14-
public const PHP8 = 'php8';
15-
1612
public const DIAGRAM_CLASS = 'class';
1713
public const DIAGRAM_PACKAGE = 'package';
1814
public const DIAGRAM_JIG = 'jig';
@@ -91,21 +87,6 @@ public function classNameSummary(): bool
9187
return true;
9288
}
9389

94-
public function phpVersion(): string
95-
{
96-
if (isset($this->opt['php5'])) {
97-
return self::PHP5;
98-
}
99-
if (isset($this->opt['php7'])) {
100-
return self::PHP7;
101-
}
102-
if (isset($this->opt['php8'])) {
103-
return self::PHP8;
104-
}
105-
// default
106-
return self::PHP7;
107-
}
108-
10990
/**
11091
* @return string[] specified headers
11192
*/

src/Php/PhpReader.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ public static function parseFile(string $directory, string $filename, Options $o
3333
{
3434
$code = (string)file_get_contents($filename);
3535

36-
$targetVersion = match ($options->phpVersion()) {
37-
'php5' => ParserFactory::PREFER_PHP5,
38-
'php7', 'php8' => ParserFactory::PREFER_PHP7, // php-parser でまだ php8 がサポートされていない。
39-
default => throw new RuntimeException(sprintf("invalid php version %s\n", ParserFactory::PREFER_PHP7)),
40-
};
41-
42-
$parser = (new ParserFactory)->create($targetVersion);
36+
$parser = (new ParserFactory)->createForHostVersion();
4337
try {
4438
$ast = $parser->parse($code);
4539
$nameResolver = new NameResolver();

test/OptionsTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,6 @@ public function testClassNameSummaryDefault(): void
131131
$this->assertTrue($options->classNameSummary(), 'classNameSummary is default on.');
132132
}
133133

134-
public function testPhp7(): void
135-
{
136-
$opt = [
137-
'php7' => true,
138-
];
139-
140-
$options = new Options($opt);
141-
142-
$this->assertSame(Options::PHP7, $options->phpVersion(), 'php version is 7.');
143-
}
144-
145-
public function testPhp8(): void
146-
{
147-
$opt = [
148-
'php8' => true,
149-
];
150-
151-
$options = new Options($opt);
152-
153-
$this->assertSame(Options::PHP8, $options->phpVersion(), 'php version is 8.');
154-
}
155-
156134
/**
157135
* @dataProvider provideDiagrams
158136
*/

0 commit comments

Comments
 (0)