Skip to content

System error: "Failed to create directory "/tmp/cache/PHPStan" (Constant FILE_BINARY is deprecated) #8103

Description

@ProcessEight

Environment

  • Rector 0.17.7 (installed as composer dependency)
  • Composer version 2.2.21 2023-02-15 13:07:40
  • PHP 8.1.17 (cli) (built: Mar 16 2023 14:37:57) (NTS)
    Copyright (c) The PHP Group
    Zend Engine v4.1.17, Copyright (c) Zend Technologies
  • Ubuntu 18.04.6 LTS 64-bit

What should happen?
Rector processes the files in the given path and produces a diff output of the changes it has made. The command is:

$ rector process --autoload-file /var/www/html/wearemagneto/projects/hstv/html/vendor/autoload.php --config /var/www/html/wearemagneto/projects/hstv/html/rector.php /var/www/html/wearemagneto/projects/hstv/html/app/code/HSTV/Criteo/

The rector.php config file is:

<?php

declare(strict_types=1);

use Magento2\Rector\Src\ReplaceMbStrposNullLimit;
use Magento2\Rector\Src\ReplaceNewDateTimeNull;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector;
use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
use Rector\Php80\Rector\ClassMethod\SetStateToStaticRector;
use Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector;
use Magento2\Rector\Src\ReplacePregSplitNullLimit;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->phpVersion(PhpVersion::PHP_81);
[rector-bug-report.txt](https://github.com/rectorphp/rector/files/12228693/rector-bug-report.txt)

    $rectorConfig->sets([LevelSetList::UP_TO_PHP_81]);

    // get services (needed for register a single rule)
    $services = $rectorConfig->services();

    // register a single rule
    $services->set(FinalPrivateToPrivateVisibilityRector::class);
    $services->set(OptionalParametersAfterRequiredRector::class);
    $services->set(SetStateToStaticRector::class);
    $services->set(StringableForToStringRector::class);
    $services->set(Php81ResourceReturnToObjectRector::class);
    $services->set(ReplacePregSplitNullLimit::class);
    $services->set(ReplaceMbStrposNullLimit::class);
    $services->set(ReplaceNewDateTimeNull::class);
};

What actually happens?
Some file are processed successfully, but others fail with a fatal error: 'System error: "Failed to create directory "/tmp/cache/PHPStan" (Constant FILE_BINARY is deprecated)':

Running rector with debug flag produces this output:

 [ERROR] Could not process "/var/www/html/wearemagneto/projects/hstv/html/app/code/HSTV/Criteo/ViewModel/Checkout.php"  
         file, due to:                                                                                                  
         "System error: "Failed to create directory "/tmp/cache/PHPStan" (Constant FILE_BINARY is deprecated)."         
                                                                                                                        
         Stack trace:                                                                                                   
         #0                                                                                                             
         /var/www/html/wearemagneto/projects/hstv/html/vendor/bitexpert/phpstan-magento/src/bitExpert/PHPStan/Magento/Au
         toload/Cache/FileCacheStorage.php(61):                                                                         
         bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->makeDir('/tmp/cache/PHPStan/ff/74')                 
         #1 phar://vendor/rector/rector/vendor/phpstan/phpstan/phpstan.phar/src/Cache/Cache.php(28):                    
         bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage->save('HSTV\\Criteo\\ViewModel\\Magento\\Sales\\Mode 
         l\\OrderFactory', '', '<?php\nnamespace HSTV\\Criteo\\ViewModel\\Magento\\Sales\\Model;\n\n/**\n * Factory     
         class for @see \\HSTV\\Criteo\\ViewModel\\Magento\\Sales\\Model\\Order\n */\nclass OrderFactory\n{\n    /**\n  
           * Create class instance with specified parameters\n     *\n     * @param array $data\n     * @return Order\n 
            */\n    public function create(array $data = array()) {}\n}\n')

Full output and stack trace is included in the attached file.

rector-bug-report.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions