Comments (24)
Run composer global require object-calisthenics/phpcs-calisthenics-rules
and then
$COMPOSER_HOME/vendor/bin/phpcs src tests -sp --standard=$COMPOSER_HOME/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml
If $COMPOSER_HOME
is not defined, please have a look at https://getcomposer.org/doc/03-cli.md#composer-home to find the composer home directory on your computer.
from phpcs-calisthenics-rules.
I can send you a PR if you don't mind.
from phpcs-calisthenics-rules.
Hey, what exactly did you try? Code would be helpful
Usage is tested and works well
from phpcs-calisthenics-rules.
Usage is tested Is tested for phpcs composer package. In the composer case we just need to install phpcs using composer require.
what about global phpcs package?
In the global case,
- PHPCS installed via pear channels
- PHPCS installed via phar package
from phpcs-calisthenics-rules.
I'm not familliar with using phar or pear, since it doesn't support reliable versioning as comoser.
Could you add test for that into .travis.yml
under composer version test?
from phpcs-calisthenics-rules.
Can you be able to guide on how do I use this standard with multiple projects without including in every project?
from phpcs-calisthenics-rules.
What exactly do you mean?
from phpcs-calisthenics-rules.
Is this what you are looking for? https://getcomposer.org/doc/03-cli.md#global
from phpcs-calisthenics-rules.
This package is a custom standard for PHPCS. As per the documentation I need to require PHPCS and this package in every project to use the sniffs. If you have gone through the PHPCS composer package, I can use PHPCS in both ways global as well as local. So if I have phpcs installed globally, how can I install/ integrate this package / standard with PHPCS in a global way so that I don't have to add this package to all my project. I can directly use this standard from global installation?
from phpcs-calisthenics-rules.
I run the above command and received following error
PHP Fatal error: Uncaught Error: Class 'Nette\Utils\Strings' not found in /home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/Helper/Naming.php:43
Stack trace:
#0 /home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/Sniffs/NamingConventions/ElementNameMinimalLengthSniff.php(40): ObjectCalisthenics\Helper\Naming::getElementName(Object(PHP_CodeSniffer\Files\LocalFile), 87)
#1 /usr/share/php/PHP/CodeSniffer/src/Files/File.php(431): ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff->process(Object(PHP_CodeSniffer\Files\LocalFile), 87)
#2 /usr/share/php/PHP/CodeSniffer/src/Files/LocalFile.php(94): PHP_CodeSniffer\Files\File->process()
#3 /usr/share/php/PHP/CodeSniffer/src/Runner.php(566): PHP_CodeSniffer\Files\LocalFile->process()
#4 /usr/share/php/PHP/CodeSniffer/src/Runner.php(383): PHP_CodeSniffer\Runner->processFile(Object(PHP_CodeSniffer\Files\LocalFile))
#5 /usr/share/php/PHP/CodeSniffer/src/Runner.php(112): PHP_CodeSniffer\R in /home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/Helper/Naming.php on line 43
As per the requirement I should have Nette\Utils
package which was already installed via composer.
Here is the output of composer global show -i
guzzlehttp/guzzle 6.2.0 Guzzle is a PHP HTTP client library
guzzlehttp/promises 1.1.0 Guzzle promises library
guzzlehttp/psr7 1.3.0 PSR-7 message implementation
laravel/installer v1.3.3 Laravel application installer.
nette/utils v2.4.6 Nette Utility Classes
object-calisthenics/phpcs-calisthenics-rules v3.0.1 PHP CodeSniffer Object Calisthenics rules/sniffs
psr/http-message 1.0 Common interface for HTTP messages
squizlabs/php_codesniffer 3.0.1 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined s...
symfony/console v3.0.6 Symfony Console Component
symfony/polyfill-mbstring v1.1.1 Symfony polyfill for the Mbstring extension
symfony/process v3.0.6 Symfony Process Component
How can I solve this?
from phpcs-calisthenics-rules.
@rohanvakharia I've tried the same "composer global" setup and it works for me.
I also see Nette\Utils
is already there in your report.
What operating system do you use?
Not sure if bug in composer. Maybe ask in composer issues.
from phpcs-calisthenics-rules.
Ubuntu 16.04
from phpcs-calisthenics-rules.
Did you run /home/rohan/.config/composer/vendor/bin/phpcs src tests -sp --standard=/home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml
or vendor/bin/phpcs src tests -sp --standard=/home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml
?
from phpcs-calisthenics-rules.
/home/rohan/.config/composer/vendor/bin/phpcs src tests -sp --standard=/home/rohan/.config/composer/vendor/object-calisthenics/phpcs-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml
from phpcs-calisthenics-rules.
Btw, I'd recommend using composer create-project ...
approach, that will install project to standalone directory. There you have dependencies under control and you can use it in multiple other projects.
composer global ...
is more different to use
from phpcs-calisthenics-rules.
What's state is this in?
from phpcs-calisthenics-rules.
I have multiple projects where I need to run these rules.
I tried different approaches to run it but couldn't succeed except adding in the project composer file.
I have installed a PHPCS standalone(phar file) in my bin folder. That gives me an easy access anywhere from terminal and in sublime as well using linter.
The way you are telling me to use that, I will need to add the package in each and every project which is not possible for me.
from phpcs-calisthenics-rules.
The way you are telling me to use that, I will need to add the package in each and every project...
I will try install it step by step.
FAIL 😢
1. Install It
# composer create-project <package-name> <destination-directory>
composer create-project object-calisthenics/phpcs-calisthenics-rules object-calisthenics-rules
Now this package is located in /object-calisthenics-rules
directory.
ruleset.xml
is located in:
object-calisthenics-rules/src/ObjectCalisthenics/ruleset.xml
2. Run It with Own phar/bin
php_codesniffer/bin/phpcs standalone-directory/src -sp --standard=standalone-directory/src/ObjectCalisthenics/ruleset.xml
That fails with exception the same "Nette\Utils\Strings" exception:
This is caused by using extra classes that phpcs
is unable to load.
That's why composer is needed at least at some way.
SOLUTION 🍰
When you use vendor/bin/phpcs
that is in the same directory:
standalone-directory/vendor/bin/phpcs standalone-directory/src -sp --standard=standalone-directory/src/ObjectCalisthenics/ruleset.xml
All works fine:
And you can analyze any directory you need:
standalone-directory/vendor/bin/phpcs other-project -sp --standard=standalone-directory/src/ObjectCalisthenics/ruleset.xml
Can you try that?
from phpcs-calisthenics-rules.
Thank you for detailed solution.
It is a very good work around for my problem.
I have tried this solution where I need to install PHPCS package using composer in a standalone directory followed by object calisthenics package which will install a Nette\Utils
package as a dependecy.
Solution accepted.
Just a concern:
I was going through the code and found that you haven't used Nette\Utils
package that extensively.
Can't you remove the dependency from your package which will make your package work for the failing use case which you explained to me?
from phpcs-calisthenics-rules.
Solution accepted.
👍
Can't you remove the dependency from your package which will make your package work for the failing use case which you explained to me?
I though about this but though there are more external dependencies, that would have to be taken care of.
You can try that and if it works send PR. + We'll have to add a note about this to README for future generations to be careful, because adding dependencies is quite common.
I can send you a PR if you don't mind.
Sure, that would be great! 👏
from phpcs-calisthenics-rules.
Do you have an idea when do you get to this?
from phpcs-calisthenics-rules.
It won't take more than couple of days as I am working on client's project, will update you once it's done.
from phpcs-calisthenics-rules.
Thanks for the info.
from phpcs-calisthenics-rules.
Closing for time out. Feel free to reopen with PR.
from phpcs-calisthenics-rules.
Related Issues (20)
- Impossible to suppress ObjectCalisthenics.Metrics.MethodPerClassLimit HOT 1
- Only one level ? And what abouht try catch ? HOT 6
- Only one level ? But how can you manage to exit a foreach ? HOT 14
- Question about Fluent Interfaces HOT 6
- Upgrade to CodeSniffer 3
- Allow "up" for short method names
- Multiline function definition should probably be counted as 1 line HOT 12
- How to do overrides HOT 10
- Missing ObjectCalisthenics/Sniffs/Files/ClassElementLengthSniff.php HOT 13
- Release v3.0? HOT 4
- Missing dependency in v3.0 HOT 1
- Request: 2.* release with phpcodesniffer-standard HOT 6
- Nette\Utils\Strings not found HOT 6
- False positive of `ObjectCalisthenics\Sniffs\CodeAnalysis\OneObjectOperatorPerLineSniff` HOT 2
- Class 'Nette\Utils\Strings' not found possible problem with phpcs 3.2.3 ? HOT 4
- packagist.org don't contain v3.5.1 HOT 8
- Unexpected value on getStructureLengthInLines HOT 2
- Custom ruleset.xml HOT 7
- requires slevomat/coding-standard ^5.0.4 but it has already installed 6.0.1 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpcs-calisthenics-rules.