PhpStorm: what are php-cs-fixer files and how to ignore them - phpstorm

I keep getting "Multiple definitions exist for class..." warnings in PhpStorm, and upon inspection, I see these a bunch of these huge php-cs-fixer files (100K+ lines) with the comment "This file is part of PHP CS Fixer.".
I found that there are multiple copies of several other files named phploc, composer, php-scoper, etc., under vendor/library_name/tools/ in various libraries for some reason. They are all huge compiled files that PhpStorm detects.
I tried ignoring these files in PhpStorm one by one, and once re-indexing finishes, these files disappear, leading me to believe they're IDE-generated files. However, it makes no sense the IDE would generate them and in turn include them hinting code.
composer.json
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.1"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
"pdepend/pdepend": "~2.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.8.0",
"phpstan/phpstan": ">=0.12.3 <=0.12.23",
"phpunit/phpunit": "^9",
"sebastian/phpcpd": "~5.0.0",
"squizlabs/php_codesniffer": "~3.5.4"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php",
"app/helper.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
}
},
"version": "2.4.0",
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"extra": {
"magento-force": "override"
}
}
PhpStorm ignored files (adding php-cs-fixer and phploc here somehow removed all/multiple copies from the vendor directories):

These files are in your vendor directory as you must have install your dependencies from sources, not distributions.
Let's use sebastian/code-unit as an example to see how it works:
the file obviously is in the repository: https://github.com/sebastianbergmann/code-unit/tree/1.0.8/tools
but excluded from being exported to distribution (the archive file you are actually downloading from GitHub when installing package): https://github.com/sebastianbergmann/code-unit/blob/1.0.8/.gitattributes#L6 - you can see that it's not present in file you download from https://github.com/sebastianbergmann/code-unit/releases/tag/1.0.8
So, you must have install your dependencies using composer install --prefer-source (or composer update --prefer-source as it's the other command with that option) and you want to use --prefer-dist or actually not using any of these flags as the latter is the default. You can find more information about it in official documentation: https://getcomposer.org/doc/03-cli.md#install-i
Remove your vendor directory and install dependencies once more without --prefer-source flag.
AFAIR there was also an issue when you did not have curl extension installed, then simply add this extension.

Related

use a different .zshrc for vscode internal terminal

I'm using zsh from vscode integrated terminal
i also use hyper terminal, warp and iterm2 for other purposes but i like to use the integreated terminal while in vscode. i actually enjoy my heavy .zshrc config on external terminals, but i often get the popup "your shell environment is taking too long to load" from vscode. Tbh, i don't mind the popup itself, but i think that a lot of the features that are useful outside vscode are not needed inside.
How can i set a different .zshrc to load only to be used by the vscode integreated terminal ?
tried conditional loading from my .zshrc but don't like it
tried setting it in the vscode-settings.json
this self-answer confused me more
this i think points in the right direction but i am not sure how to use task.json
my env:
macOS 13.1 22C65 arm64
Apple M1 Max
vscode (1.74.11ad8d514439d5077d2b0b7ee64d2ce82a9308e5a for arm64)
zsh 5.9 (arm-apple-darwin22.1.0)
These are the settings to change in “settings.json”:
I created 3 profiles:
zsh-minimal with the vscode minimal config -> new ZDOTDIR
zsh-full with my usual heavy config -> probably not necessary since it is $HOME by default i think
bash, just in case i fu everything
set to null old profiles ( zsh and zsh(2)) to delete them from profiles selection dropdown menu, as per official documentation.
“terminal.integrated.defaultProfile.osx”: “zsh-minimal”,
“terminal.integrated.profiles.osx”: {
"zsh-minimal": {
"title": "zsh-minimal",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiMagenta",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/.homesick/repos/MYUSERNAME-dotfiles/home/vscode_zsh"
},
},
"zsh-full": {
"title": "zsh-full",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiCyan",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/"
},
},
"bash": {
"title": "bash",
"path": "/bin/bash",
"icon": "terminal",
"color": "terminal.ansiWhite",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
},
"zsh": null,
"zsh (2)": null,
}

invalid composer.json metadata packagist

When I push new tag to my package to update my composer plugin it returns this error:
Update of failed, invalid composer.json metadata
[Composer\Repository\InvalidRepositoryException] Some branches
contained invalid data and were discarded, it is advised to review the
log and fix any issues present in branches
Here is my composer.json file:
{
"name": "package/name",
"description": "....",
"keywords": [
"...",
"...",
"..."
],
"homepage": "https://github.com/username/package-name",
"type": "composer-plugin",
"require": {
"php": "^7.4|^8.0",
"illuminate/support": "^7.0|^8.0|^9.0"
},
"require-dev": {
"composer/composer": "^2.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Package\\Name\\": "src/"
}
},
"authors": [
{
"name": "My name",
"email": "my#email.com"
}
],
"minimum-stability": "dev"
}
And when I run composer validate I get ./composer.json is valid.
As you can see there is no domain name mention whatsoever but error is returning my domain name as invalid which says: must be an http/https URL
Any idea?
You need to read the error message in full and with peace of mind (unfortunately you were hiding it from the question by encoding it as image/png).
Don't look into one revision, instead search the history for it:
$ git log -p -S 'funding' main composer.json
It should get you started to learn about the revisions that are related to "funding" in composer.json within the main branch.

How to Debug other project than "main"?

Using Visual Studio Code, I have two directories in my workspace (both node.js projects), but I can only launch one of them. The launch.json file exists in both folders, but only the first is available in debug menu. The launch.json files looks like that:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\app.js",
"outFiles": [
"${workspaceFolder}/**/*.js"
]
}
]
}
How can I start debugging the second folder of my workspace?
I removed the first folder from the workspace, started the only project left, then added the removed folder again. Now I have both projects in the launch configurations.
I have found two solutions. Both involve editing your *.code-workspace file.
As OP found, you can reorder the folders. In the *.code-workspace file, place the folder with the desired launch.json at the top of the list of folders.
"folders": [
{
"path": "..\\ProjectWithLaunchJson"
},
{
"path": "..\\MyOtherProject"
}
]
Alternatively, you can include the launch configuration in the *.code-workspace file.
"folders": [
:
:
],
"settings": {
"launch": {
"configurations": [
{
<copy your launch.json's configuration into here>
}
]
}
}
YMMV. I had to tweak the path to the executable. And I had to remove the preLaunchTask property since VS Code could not find the Task. VS Code's support for this will likely evolve.

Getting extension from private repo with composer

I have to create a private yii2 extension on BitBucket, and install it in my projects with composer.
The SSH is set up correctly as far as I can understand, it was not at first - and I got an error "repo not found or you do not have permission" (or something of the kind).
The composer finds the composer.json, I removed it to test and I got an error message that "valid composer.json not found".
Now when i run composer update in my Git Bash it just prints "Nothing to install or update" and nothing appears in my vendor/ folder.
I have no errors to go on here, any ideas are mostly welcome!
I've set up the repo and added the following files:
composer.json
{
"name": "ext. name",
"type": "yii2-extension",
"description": "My desc",
"authors": [
{
"name": "Jorgen",
"email": "jorgen#domain.com",
"homepage": "http://www.domain.com"
}
],
"minimum-stability": "stable",
"support": {
"source": "bitbucket.org/companyname/yii2-extensionname"
},
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "2.0.*"
},
"autoload": {
"psr-4": {
"companyname\\extensionname\\": ""
}
}
}
.gitignore
vendor/**
models/Test.php
<?php
namespace companyname\extensionname\models;
class Test
{
}
And I've added the following to my Yii2 project composer.json:
"repositories": [
{
"type": "vcs",
"url": "ssh://git#bitbucket.org/companyname/yii2-extensionname",
}
],
Update
So I figured out that if I add my repo in this format it's found and downloaded, but the autoloader-psr4.php file is not updated with my autoloading.
"repositories": [
{
"type": "package",
"package": {
"name": "vendor/yii2-extension-name",
"version": "master",
"source": {
"type": "git",
"url": "git#bitbucket.org:vendor/yii2-extension-name",
"reference": "origin/master"
}
}
}
When I have
"repositories": [
{
"type": "git",
"url": "https://bitbucket.org/vendor/yii2-extension-name"
}
],
I get the following error:
Problem 1
- The requested package vendor/yii2-extension-name could not be found in any version, there may be a typo in the package name.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion for more details.
Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
There is no typos, its found and downloaded when I use "package". But then the autoloader is not updated.I've also tried all sorts of variations with git#, https and ssh. It always works as a package, never as a git or vcs.
Edit: oh, and minimum-stability is set to dev while troubleshooting.
You must use the correct name:
{
"name": "vendor/yii2-extension-name",
"type": "yii2-extension",
That is usually your Bitbucket username followed by the name of your repository.
That will work with your repositories Composer setting:
"repositories": [
{
"type": "git",
"url": "https://bitbucket.org/vendor/yii2-extension-name"
}
],

How to modify composer.json for installing Gedmo Doctrine2 extensions in Symfony2

I'm trying to install to install the Gedmo Doctrine2 extensions in Symfony2 to use the translate composante.
I found a page online that show me how to do it (https://github.com/l3pp4rd/DoctrineExtensions/blob/master/doc/symfony2.md), but I'm not shure about a few things.
First, when I change the composer.json file, I noticed that I have
"psr-0": {
"": "src/",
"SymfonyStandard": "app/"
}
And the instruction tells me to add
"psr-0": {
"Acme": "src/"
}
I don't know if I need to change the "": "src/", ligne or if I add the new ligne, or if I just let it be like it is.
I would really help me if someone juste tell what my file should looks like, so here is my composer.json:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"": "src/",
"SymfonyStandard": "app/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"sensio/generator-bundle": "2.0.*",
"jms/security-extra-bundle": "1.0.*",
"gedmo/doctrine-extensions": "dev-master",
"incenteev/composer-parameter-handler": "~2.0",
"ircmaxell/password-compat": "^1.0"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.6-dev"
}
}
}
The other thing is that after that step, I need to run php composer.phar update gedmo/doctrine-extensions in composer, but I don't have a a composer.phar file, so I did insted composer update.
Is that O.K., or I need to do an other line?
You can simply use
composer require gedmo/doctrine-extensions
and the composer.json will be automatically modified.
Regarding "composer" vs "composer.phar": yes, they are the same, so you can use whatever you have.
To add more details: usually everyone rename "composer.phar" to "composer" and move it to a binaries location on the os (i.e. /usr/local/bin on Linux) so that it can be used as a common system command. That is probably your situation.
The instruction is unclear, you do not need to change the line
"psr-0": {
"": "src/",
"SymfonyStandard": "app/"
}
Just add "gedmo/doctrine-extensions": "dev-master" to the require section.
Then to run a composer update you should install composer if you have not yet done so (but if you have symfony installed, I think you do unless you followed the instructions in the tutorial in which case I would reinstall symfony the official way as the tutorial refers to an outdated repository)