hippophp / hippo Goto Github PK
View Code? Open in Web Editor NEWPHP standards checker.
Home Page: https://james.brooks.page
License: MIT License
PHP standards checker.
Home Page: https://james.brooks.page
License: MIT License
In order to make reporters testable without hassle, we should refactor reporters to use FileSystem
. The FileSystem
could be then stubbed in the tests, without resorting to dealing with real files nor output capturing. CLIReporter
could use FileSystem
to put its output in a meta-file php://output
and still work as expected.
Getting the same thing twice from context should run factory only once.
We need to test if it's true.
Returning from CheckContext@getSyntaxTree
is a PhpParser\Parser
class, which isn't very useful as it doesn't allow traversing of the tree nodes.
This should be improved so that the return is a custom class extending from traverser which checks can implement.
Because the check jumps to T_USE
an anonymous function such as:
array_map(function() use ($foo) {
});
Will be picked up too.
We'll obviously need to add the checks themselves. For now we should focus on PSR standards as these are the better standards to have.
Basically, everything under PSR should be able to be checked for. We should be able to create a basic PSR check then have the other standards extend from them, de-duplicating a lot of code.
Following list uses this syntax to describe possible configuration options, with the assumption that the check is enabled. I.e. something like space/no character means that user can set it to either space, or no character, and the "no character" option will throw errors if it finds a space.
&&
/and
elseif
vs else if
$a = $b = 5;
(be careful around for loops)$a = 5; $b = 6;
(be careful around lambdas and default parameters)use
statementsnamespace
in the file<?php
or <?
or <?=
<?
<?=
array()
true
, false
, and null
should be in lowercase.catch
block empty._
\n
, \r
or \r\n
, or check for consistency only.for
loop after ;
(can it be merged to any other check?){
and }
if
for
foreach
do
while
else
(be careful, } else {
might behave different from the rest. This suggests that configuration should to be aware of each keyword separately...)switch
class
/interface
/trait
function
(be careful around lambdas)Right now, having any violation at all results in exit code 1.
This should be the case only if --strict
option is enabled. Otherwise, let warnings and such pass.
When you run ./hippo foo
it'll error explaining that foo
isn't a file, however the same warning is printed twice, but worded differently.
$ ./hippo foo
File not found: File does not exist: foo
We need to create an interface to lay out the API to how Hippo should be accessed. HippoTextUI
is fine, but only useful for CLI, so how do you access Hippo within your own project? It's pretty cumbersome.
We need an abstract check test case for testing the checks themselves.
In regards to a test for BitwiseCheck
:
all you need is create dummy File with two &&, run a check on it (like CheckRunner does -- perhaps add some protected utility methods to AbstractCheckTestCase?) and check in an assertion for two violations
Having hippo
as a command accessible globally would be neat. I'm not sure how to do this though since composer.json
already includes the bin
values.
BitwiseCheck
belongs in the styles
directory which can be done once #36 is merged.
XMLReporter
is currently not implemented. We should either remove it or implement it.
I'm not sure what CheckstyleReporter
is for - I mean, it serializes into XML, so how is it different from XMLReporter
?
If these two are going to do the same, only one should stay.
We need a CLI frontend for testing.
Checks seem to inherit the token list position, so sometimes you need to rewind the iterator before you can start checking the code.
My feeling is that each check should be passed the token list iterator from the beginning.
The HHVM tests have failed for some reason; https://travis-ci.org/HippoPHP/Hippo/jobs/39542616
1) Hippo\Tests\FileTest::testGetLinesVaryingEol
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => '<?php echo 1;\n'
1 => 'echo 2
+ echo 3
'
- 2 => 'echo 3\n'
- 3 => ''
+ 2 => false
)
/home/travis/build/HippoPHP/Hippo/tests/Hippo/Tests/FileTest.php:59
How can I specify I don't care about:
(info) : Prefer single quotes to double
and
(error) : Line is too long.
And ignore them.
Once HippoPHP/Tokenizer has been worked on, we need to drop out the existing tokenization code in favour of the new Tokenizer package.
Tokenizer.php
is currently dependent on token_get_all
which doesn't support the custom tokens we'll need for checks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.