Git Product home page Git Product logo

Comments (24)

UFOMelkor avatar UFOMelkor commented on May 20, 2024 1

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.

rohanvakharia avatar rohanvakharia commented on May 20, 2024 1

I can send you a PR if you don't mind.

from phpcs-calisthenics-rules.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

Hey, what exactly did you try? Code would be helpful

Usage is tested and works well

from phpcs-calisthenics-rules.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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,

from phpcs-calisthenics-rules.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

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.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

What exactly do you mean?

from phpcs-calisthenics-rules.

UFOMelkor avatar UFOMelkor commented on May 20, 2024

Is this what you are looking for? https://getcomposer.org/doc/03-cli.md#global

from phpcs-calisthenics-rules.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

@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.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

Ubuntu 16.04

from phpcs-calisthenics-rules.

UFOMelkor avatar UFOMelkor commented on May 20, 2024

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.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

/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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

What's state is this in?

from phpcs-calisthenics-rules.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

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:

image


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:

image

And you can analyze any directory you need:

standalone-directory/vendor/bin/phpcs other-project -sp --standard=standalone-directory/src/ObjectCalisthenics/ruleset.xml

image

Can you try that?

from phpcs-calisthenics-rules.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

Do you have an idea when do you get to this?

from phpcs-calisthenics-rules.

rohanvakharia avatar rohanvakharia commented on May 20, 2024

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.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

Thanks for the info.

from phpcs-calisthenics-rules.

TomasVotruba avatar TomasVotruba commented on May 20, 2024

Closing for time out. Feel free to reopen with PR.

from phpcs-calisthenics-rules.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.