Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'Nette\Utils\Strings' not found possible problem with phpcs 3.2.3 ? #83

Closed
widoz opened this issue Sep 24, 2018 · 4 comments
Closed

Comments

@widoz
Copy link

widoz commented Sep 24, 2018

I always get this when trying to run phpcs.

I read the code and seems everything ok but the class Strings doesn't exists.

Error: Class 'Nette\Utils\Strings' not found in /Users/user/Sites/sniffs/phpcs-calisthenics-rules/src/ObjectCalisthenics/Helper/Naming.php on line 43

Call Stack:
0.0006 392504 1. {main}() /usr/local/bin/phpcs.phar:0
0.0057 743384 2. PHP_CodeSniffer\Runner->runPHPCS() /usr/local/bin/phpcs.phar:6
0.1221 8372216 3. PHP_CodeSniffer\Runner->run() phar:///usr/local/bin/phpcs.phar/src/Runner.php:2
0.1291 8898144 4. PHP_CodeSniffer\Runner->processFile() phar:///usr/local/bin/phpcs.phar/src/Runner.php:2
0.1291 8898144 5. PHP_CodeSniffer\Files\LocalFile->process() phar:///usr/local/bin/phpcs.phar/src/Runner.php:2
0.1291 8898144 6. PHP_CodeSniffer\Files\LocalFile->process() phar:///usr/local/bin/phpcs.phar/src/Files/LocalFile.php:2
0.1516 9349616 7. ObjectCalisthenics\Sniffs\NamingConventions\ElementNameMinimalLengthSniff->process() phar:///usr/local/bin/phpcs.phar/src/Files/File.php:2
0.1521 9356928 8. ObjectCalisthenics\Helper\Naming::getElementName() /Users/user/Sites/sniffs/phpcs-calisthenics-rules/src/ObjectCalisthenics/Sniffs/NamingConventions/ElementNameMinimalLengthSniff.php:39

@TomasVotruba
Copy link
Contributor

TomasVotruba commented Sep 25, 2018

Hi, is Nette\Utils\Strings class autolaoded?

Is phpcs skipping the vendor/autoload.php?

@widoz
Copy link
Author

widoz commented Oct 3, 2018

Hi thanks for the reply and sorry for the delay.
I cloned the repo again and ran composer install --optimize-autoloader, updated the phpcs to the latest release 3.3.2. But now the issue is with PHP Fatal error: Uncaught Error: Class 'SlevomatCodingStandard\Helpers\ClassHelper' not found in /Users/guido/Sites/sniffs/phpcs-calisthenics-rules/src/ObjectCalisthenics/Sniffs/NamingConventions/NoSetterSniff.php:67 

Is phpcs skipping the vendor/autoload.php?

What do you mean exactly? If I remove the rules

<rule ref="ObjectCalisthenics.Metrics.MaxNestingLevel">
        <properties>
            <property name="maxNestingLevel" value="2"/>
        </properties>
    </rule>
    <rule ref="ObjectCalisthenics.ControlStructures.NoElse"/>
    <!--<rule ref="ObjectCalisthenics.NamingConventions.ElementNameMinimalLength"/>-->
    <!--<rule ref="ObjectCalisthenics.Classes.ForbiddenPublicProperty"/>-->
    <rule ref="ObjectCalisthenics.NamingConventions.NoSetter"/>
    <rule ref="ObjectCalisthenics.Metrics.PropertyPerClassLimit">
        <properties>
            <property name="maxCount" value="5"/>
        </properties>
    </rule>

Phpcs works as expected. You can view the file here https://github.com/widoz/unprefix/blob/refactor-php7/phpcs.xml

@widoz
Copy link
Author

widoz commented Oct 6, 2018

Hi @TomasVotruba it's me again,

Sorry for the double reply but I guess I found the problem. I don't know exactly where could be in terms of line of codes but using the latest version of phpcs seems causing the issue. I switched to the latest version for 3.2.x and phpcs is able to work correctly without problems.

@TomasVotruba
Copy link
Contributor

Hey,

that's great to hear! I tried to reproduce the issue and find myself stuck with autoloading problems. That's why I prefer ECS, where these problems doesn't exist.

I'm glad it works 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants