phpro / grumphp-shim Goto Github PK
View Code? Open in Web Editor NEWThis repository provides easy way to install GrumPHP without the risk of conflicting dependencies.
License: MIT License
This repository provides easy way to install GrumPHP without the risk of conflicting dependencies.
License: MIT License
Hi,
When we require grum-shim with php7.1 we have a problem with the grumphp.phar file
It's seems that the grumphp.phar in grumphp-shim is compiled with version 0.22 of grumphp which require php7.3
In grumpphp-shim 0.22 there is a dependency on php7.1 (here) then composer accept this version.
After that, on git commit we got this error :
php composer.phar remove phpro/grumphp-shim
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
Box Requirements Checker
========================
> Using PHP 7.1.33
> PHP is using the following php.ini file:
WARNING: No configuration file (php.ini) used by PHP!
> Checking Box requirements:
E...
[ERROR] Your system is not ready to run the application.
Fix the following mandatory requirements:
=========================================
* The application requires the version "^7.3" or greater.
GrumPHP can not sniff your commits! (invalid-exit-code)
With the changes in #2 (c597994) it's no longer possible to call the shell-script if the current working directory is not vendor/bin
Command:
vendor/bin/grumphp
Error:
PHP Warning: require(phar://grumphp.phar/.box/bin/check-requirements.php): failed to open stream: phar error: invalid url or non-existent phar "phar://grumphp.phar/.box/bin/check-requirements.php" in /path/to/my/project/vendor/phpro/grumphp-shim/grumphp on line 9
Hi! Can PHP 7 support be restored to this shim the same way it was restored to the main package with the v1.11.0 release? I maintain a library that, sadly, still has to support 7.4. Thanks.
Q | A |
---|---|
Version | 1.13.0 SHIM |
Bug? | yes |
New feature? | no |
Question? | no |
Documentation? | no |
Related tickets |
I'm trying to create an extension, using GrumPHP\Extension\ExtensionInterface
.
My installation uses the shim
version of the package.
When I try to create the extension, I get an error:
PHP Fatal error: Declaration of App\MyGrumTask\ExtensionLoader::load(Symfony\Component\DependencyInjection\ContainerBuilder $container): void must be compatible with GrumPHP\Extension\ExtensionInterface::load(_HumbugBox2e6990dfd7a2\Symfony\Component\DependencyInjection\ContainerBuilder $container): void
My IDE wants me to change the method signature to _HumbugBox2e6990dfd7a2\Symfony\Component\DependencyInjection\ContainerBuilder
!
Is this something to do with the shim packaging?
Thanks
See symfony/symfony#42089 and phpro/soap-client#383 for context:
PHP Fatal error: Uncaught Error: Call to undefined function normalizer_is_normalized() in phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/string/UnicodeString.php:35
Stack trace:
#0 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Helper/Helper.php(56): _HumbugBox9b65161bc655\Symfony\Component\String\UnicodeString->__construct()
#1 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Helper/Helper.php(122): _HumbugBox9b65161bc655\Symfony\Component\Console\Helper\Helper::width()
#2 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Style/SymfonyStyle.php(69): _HumbugBox9b65161bc655\Symfony\Component\Console\Helper\Helper::strlenWithoutDecoration()
#3 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/Middleware/GroupByPriorityMiddleware.php(30): _HumbugBox9b65161bc655\Symfony\Component\Console\Style\SymfonyStyle->title()
#4 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(42): GrumPHP\Runner\Middleware\GroupByPriorityMiddleware->handle()
#5 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/Middleware/EventDispatchingRunnerMiddleware.php(26): GrumPHP\Runner\MiddlewareStack::GrumPHP\Runner\{closure}()
#6 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(42): GrumPHP\Runner\Middleware\EventDispatchingRunnerMiddleware->handle()
#7 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/Middleware/ReportingRunnerMiddleware.php(22): GrumPHP\Runner\MiddlewareStack::GrumPHP\Runner\{closure}()
#8 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(42): GrumPHP\Runner\Middleware\ReportingRunnerMiddleware->handle()
#9 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/Middleware/TasksFilteringRunnerMiddleware.php(13): GrumPHP\Runner\MiddlewareStack::GrumPHP\Runner\{closure}()
#10 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(42): GrumPHP\Runner\Middleware\TasksFilteringRunnerMiddleware->handle()
#11 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/Middleware/FixCodeMiddleware.php(22): GrumPHP\Runner\MiddlewareStack::GrumPHP\Runner\{closure}()
#12 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(42): GrumPHP\Runner\Middleware\FixCodeMiddleware->handle()
#13 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/MiddlewareStack.php(31): GrumPHP\Runner\MiddlewareStack::GrumPHP\Runner\{closure}()
#14 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Runner/TaskRunner.php(25): GrumPHP\Runner\MiddlewareStack->handle()
#15 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/src/Console/Command/RunCommand.php(67): GrumPHP\Runner\TaskRunner->run()
#16 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Command/Command.php(228): GrumPHP\Console\Command\RunCommand->execute()
#17 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Application.php(840): _HumbugBox9b65161bc655\Symfony\Component\Console\Command\Command->run()
#18 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Application.php(251): _HumbugBox9b65161bc655\Symfony\Component\Console\Application->doRunCommand()
#19 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/console/Application.php(152): _HumbugBox9b65161bc655\Symfony\Component\Console\Application->doRun()
#20 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/bin/grumphp(35): _HumbugBox9b65161bc655\Symfony\Component\Console\Application->run()
#21 phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/bin/grumphp(36): _HumbugBox9b65161bc655\{closure}()
#22 D:\a\soap-client\soap-client\vendor\bin\grumphp(21) : eval()'d code(12): require('...')
#23 D:\a\soap-client\soap-client\vendor\bin\grumphp(21): eval()
#24 {main}
thrown in phar://D:/a/soap-client/soap-client/vendor/phpro/grumphp-shim/grumphp.phar/vendor/symfony/string/UnicodeString.php on line 35
Error: Process completed with exit code 1.
Feedback:
The component requires
symfony/polyfill-intl-normalizer
so thatext-intl
is not needed.
You should find whysymfony/polyfill-intl-normalizer
is not installed.
I suppose it's listed in the "replace" section of a composer.json file.
First, I think it's great that there's a Composer plugin for Grumphp. Kudos. Next, I have found that the vendor/bin/grumphp
file starts off with $(which php)
which effectively nutralizes any benefits that may be present in using the pure Composer package phpro/grumphp
which utilizes git_hook_variables, and therefore allows for configuring Grumphp for a native php stack/Vagrant/Docker.
This Composer plugin doesn't, from my experiments and what I can tell, support being ran on Vagrant/Docker.
My sample grumphp.yml
file:
parameters:
git_hook_variables:
EXEC_GRUMPHP_COMMAND: 'docker exec php-fpm php'
tasks: { phpunit: null }
My resulting .git/hooks/pre-commit
:
#!/bin/sh
#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#
# Fetch the GIT diff and format it as command input:
DIFF=$(git -c diff.mnemonicprefix=false --no-pager diff -r -p -m -M --full-index --no-color --staged | cat)
# Grumphp env vars
export GRUMPHP_GIT_WORKING_DIR=$(git rev-parse --show-toplevel)
# Run GrumPHP
(cd "./" && printf "%s\n" "${DIFF}" | 'docker' 'exec' 'php-fpm' 'php' 'vendor/phpro/grumphp-shim/grumphp' 'git:pre-commit' '--skip-success-output')
Sample output:
me@computer$ git status
On branch feature/JIRA-123-local-dev-environment
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: app/code/Vendor/Module/Block/Adminhtml/Import.php
no changes added to commit (use "git add" and/or "git commit -a")
me@computer$ git commit -am "test2"
$(which php) "$(dirname "$0")/grumphp.phar" $@
$(which php) "$(dirname "$0")/grumphp.phar" $@
[feature/JIRA-123-local-dev-environment bc5a88ad] test2
3 files changed, 58 insertions(+), 2 deletions(-)
The above git commands were ran from my host machine, and didn't prevent the git operations, but also didn't work as I would expect (executing via the php executable within the specified docker container).
When I use phpro/grumphp
instead of phpro/grumphp-shim
, use the same grumphp.yml
file, and end up with the same .git/hooks/pre-commit
shown above, and commit file changes from my host machine, the following is output:
git commit -am "test"
GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!
Running task 1/1: Phpunit... ✔
GrumPHP detected a commit-msg command.
GrumPHP is sniffing your code!
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀▀▓▓▓▓▓▓▓▓▓▓▓▓█▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████████▄
▄████████▀▀▀▀▀ ██████████
███████▀ ██████▀
▐████ ██▌ ██ ████▌
▐█▌ ███
█▌ ▄▄ ▄▄ ▐███
███ ▄▄▄▄▄▄▄▄▄▄▄▄ ▐███
██▄ ▐███████████████████████████
█▀█████████▌▀▀▀▀▀▀▀▀▀██████████▌▐
███████████▄▄▄▄▄▄▄███████████▌
▐█████████████████████████████
█████████████████████████████
██ █████████████████████▐██▀
▀ ▐███████████████████▌ ▐▀
████▀████████▀▐███
▀█▌ ▐█████ ▐█▌
██▀ ▐▀
_ _ _ _ _
/ \ | | | __ _ ___ ___ __| | |
/ _ \ | | | / _` |/ _ \ / _ \ / _` | |
/ ___ \| | | | (_| | (_) | (_) | (_| |_|
/_/ \_\_|_| \__, |\___/ \___/ \__,_(_)
|___/
[feature/JIRA-123-local-dev-environment b6ca0ab4] test
3 files changed, 240 insertions(+), 2 deletions(-)
This Composer plugin does solve dealing with "dependency hell," which is great. I just think that in order to be more available to more realistic and modern development environments, that the git_hook_variables
( at the least ) should be incorporated here.
I have a config with git_blacklist and now, using PHP 8.1, I get this error:
preg_match($pattern = '/^0+$/', $subject = NULL) phar:///sites/shm/vendor/phpro/grumphp-shim/grumphp.phar/vendor/gitonomy/gitlib/src/Gitonomy/Git/Parser/DiffParser.php:87
Could Gitonomy be updated?
NB turns out, it isn't linked to git_blacklist , might be more global.
The default ruleset for twigCS gets scoped.
Resulting in errors:
Snippet:
class TwigCs extends \GrumPHP\Task\AbstractExternalTask
{
public static function getConfigurableOptions() : \_HumbugBoxdfa46d19239b\Symfony\Component\OptionsResolver\OptionsResolver
{
$resolver->setDefaults(
[
//.....
'ruleset' => '_HumbugBoxdfa46d19239b\\FriendsOfTwig\\Twigcs\\Ruleset\\Official',
//.....
]
);
return $resolver;
}
...
This specific class could be namespaced if it does not break anything else.
WHen I created custom task and implement TskInterface. I saw that in shim version its chainging names to Humbug.
Is tehre a way to create custom tasks and still use grumphp-shim??
$:~/projects/company$ dphp ./bin/grumphp run --tasks=very_custom_phpstan
PHP Fatal error: Uncaught TypeError: Return value of VeryCustom\Bundle\CoreBundle\GrumPHP\Task\VeryCustomPhpStan::getConfigurableOptions() must be an instance of _HumbugBox8bc289e4b8e0\Symfony\Component\OptionsResolver\OptionsResolver, instance of Symfony\Component\OptionsResolver\OptionsResolver returned in /var/www/company/src/VeryCustom/Bundle/CoreBundle/GrumPHP/Task/VeryCustomPhpStan.php:47
Stack trace:
#0 phar:///var/www/company/vendor/phpro/grumphp-shim/grumphp.phar/src/Configuration/Resolver/TaskConfigResolver.php(50): VeryCustom\Bundle\CoreBundle\GrumPHP\Task\VeryCustomPhpStan::getConfigurableOptions()
#1 phar:///var/www/company/vendor/phpro/grumphp-shim/grumphp.phar/src/Configuration/Resolver/TaskConfigResolver.php(32): GrumPHP\Configuration\Resolver\TaskConfigResolver->fetchByName('very_custom_phpstan')
#2 phar:///var/www/company/vendor/phpro/grumphp-shim/grumphp.phar/src/Configuration/Compiler/TaskCompilerPass.php(48): GrumPHP\Configuration\Resolver\TaskConfigResolver->resolve('very_custom_phpstan', Array)
#3 phar:///var/www/company/vendor/phpro/grumphp-shim/grumphp.phar/src/Tas in /var/www/company/src/VeryCustom/Bundle/CoreBundle/GrumPHP/Task/VeryCustomPhpStan.php on line 47
I get this error when trying to composer require phpro/grumphp-shim
PHP Warning: Cannot declare interface Stringable, because the name is already in use in phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php on line 12
PHP Stack trace:
PHP 1. {main}() /app/vendor/phpro/grumphp-shim/grumphp.phar:0
but it does install ok, and I don't see the error again when running grumphp. Everything seems to work ok.
Hello,
I'm trying to update the Nix package with the new Composer builder, and it's failing at validating the composer.lock
file.
Here's how to reproduce it locally:
❯ cd ~/Code/tmp/grumphp
❯ git co v2.1.0
Note: switching to 'v2.1.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at b190443f 2.1.0 release
❯ wget https://github.com/phpro/grumphp-shim/raw/v2.1.0/phar.composer.lock
--2023-10-05 22:51:16-- https://github.com/phpro/grumphp-shim/raw/v2.1.0/phar.composer.lock
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/phpro/grumphp-shim/v2.1.0/phar.composer.lock [following]
--2023-10-05 22:51:16-- https://raw.githubusercontent.com/phpro/grumphp-shim/v2.1.0/phar.composer.lock
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.111.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 255034 (249K) [text/plain]
Saving to: ‘phar.composer.lock’
phar.composer.lock 100%[====================================================================================================>] 249.06K --.-KB/s in 0.06s
2023-10-05 22:51:16 (4.26 MB/s) - ‘phar.composer.lock’ saved [255034/255034]
❯ mv phar.composer.lock composer.lock
❯ composer validate
./composer.json is valid but your composer.lock has some errors
# Lock file errors
- The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update` or `composer update <package name>`.
~/C/t/grumphp > [email protected] > [email protected] ✘
Here's the diff of the updated composer.lock
:
From 6053048951b7cef38c9af346069a601f023a50ca Mon Sep 17 00:00:00 2001
From: Pol Dellaiera <[email protected]>
Date: Fri, 6 Oct 2023 08:48:24 +0200
Subject: [PATCH] composer.lock
---
composer.lock | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/composer.lock b/composer.lock
index 96b692c3..46c38857 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8a069c630e6ddbc4475db9a992430539",
+ "content-hash": "44ce311f8f7cdc1321afb8c4f4dc346f",
"packages": [
{
"name": "amphp/amp",
@@ -7087,8 +7087,5 @@
"composer-plugin-api": "~2.0"
},
"platform-dev": [],
- "platform-overrides": {
- "php": "8.1"
- },
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.6.0"
}
--
2.42.0
Do you think you could have some time to look at it?
Related PRs:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.