Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trainline
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
James Walker
trainline
Commits
bf41246a
Verified
Commit
bf41246a
authored
2 years ago
by
James Walker
Browse files
Options
Downloads
Patches
Plain Diff
Minor source revisions for PHP8 as revealed by PHPStan
parent
e727a63d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
PHPStan@v1
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/ConfigApp.php
+1
-1
1 addition, 1 deletion
src/ConfigApp.php
src/LoggerCli.php
+9
-1
9 additions, 1 deletion
src/LoggerCli.php
src/TestUnit.php
+15
-2
15 additions, 2 deletions
src/TestUnit.php
tests/FrameworkUnitTests.php
+1
-0
1 addition, 0 deletions
tests/FrameworkUnitTests.php
with
26 additions
and
4 deletions
src/ConfigApp.php
+
1
−
1
View file @
bf41246a
...
...
@@ -33,7 +33,7 @@ final class ConfigApp extends ConfigClass {
$path
=
(
getcwd
()
.
"/trainline.json"
);
if
(
file_exists
(
$path
)
&&
is_readable
(
$path
))
{
if
(
$content
=
file_get_contents
(
$path
))
{
return
json_decode
(
$content
,
true
,
JSON_THROW_ON_ERROR
);
return
((
array
)
json_decode
(
$content
,
true
,
JSON_THROW_ON_ERROR
)
)
;
}
}
return
[];
...
...
This diff is collapsed.
Click to expand it.
src/LoggerCli.php
+
9
−
1
View file @
bf41246a
...
...
@@ -70,7 +70,15 @@ final class LoggerCli implements Logger {
}
else
$this
->
Cli
->
green
()
->
inline
(
"All OK!"
);
$this
->
Cli
->
inline
(
" "
)
->
out
(
sprintf
(
/**
* @var CLImate $inlineCli
*
* This line is for PHPStan's benefit, as CLImate
* has no return type defined for `inline()` calls.
*/
$inlineCli
=
$this
->
Cli
->
inline
(
" "
);
$inlineCli
->
out
(
sprintf
(
"(%s test(s) in %s unit(s), %s%s OK)."
,
$run
->
count
(),
$run
->
countUnits
(),
...
...
This diff is collapsed.
Click to expand it.
src/TestUnit.php
+
15
−
2
View file @
bf41246a
...
...
@@ -21,7 +21,7 @@ final class TestUnit {
*/
public
function
__construct
(
protected
string
$cls
)
{
if
(
!
self
::
valid
(
$cls
))
{
throw
new
Exceptions\TestUnitException
(
$cls
);
self
::
handleInvalid
(
$cls
);
}
}
...
...
@@ -38,8 +38,13 @@ final class TestUnit {
* Get an instance of the test unit.
*/
public
function
getInstance
()
:
UnitInterface
{
$cls
=
$this
->
getClass
();
return
new
$cls
();
$instance
=
new
$cls
();
if
(
$instance
instanceof
UnitInterface
)
return
$instance
;
else
self
::
handleInvalid
(
$cls
);
}
...
...
@@ -50,6 +55,14 @@ final class TestUnit {
return
(
class_exists
(
$cls
)
&&
is_a
(
$cls
,
UnitInterface
::
CLASS
,
true
));
}
/**
* Handle an invalid class being used as a test unit.
*/
public
static
function
handleInvalid
(
string
$cls
)
:
never
{
throw
new
Exceptions\TestUnitException
(
$cls
);
}
}
?>
This diff is collapsed.
Click to expand it.
tests/FrameworkUnitTests.php
+
1
−
0
View file @
bf41246a
...
...
@@ -29,6 +29,7 @@ final class FrameworkUnitTests extends Unit {
final
public
function
testB
()
:
void
{}
final
public
function
__hiddenTest
()
:
void
{}
final
protected
function
protectedTest
()
:
void
{}
/** @phpstan-ignore-next-line (intentionally unused) */
private
function
privateTest
()
:
void
{}
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment