-
-
Notifications
You must be signed in to change notification settings - Fork 688
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
PHAR improvements #389
PHAR improvements #389
Conversation
composer.json
Outdated
"phpstan": "vendor/bin/phpstan.phar analyse packages src tests --level max --configuration phpstan.neon" | ||
"phpstan": "vendor/bin/phpstan.phar analyse packages src tests --level max --configuration phpstan.neon", | ||
"compile-phar": [ | ||
"rm -f rector.phar", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reasons we've talked about and WTF like #319 (comment)
I'd recommend to use nested directory for build, e.g. common build
, so file in build/rector.phar
would fail on missing vendor/autoload.php
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And what about bin/rector.phar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In /bin
only bin files should be. build
is for the extra generated stuff
Don't worry, it will be usable as vendor/bin/rector.phar
in the end.
services: | ||
Rector\Rector\Dynamic\NamespaceReplacerRector: | ||
$oldToNewNamespaces: | ||
'Jean85': '%prefix%Jean85' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very creative use of Rector, like it 👍
Love the param! :)
There could be dynamic Rector (via RectorProvider), that would replace every namespace node with prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every except specified would be even better:) We don't need to prefix Rector itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see :) That would require new Rector, probably NamespacePrefixerRector
services:
Rector\Rector\Dynamic\NamespaceReplacerRector:
!Rector: Prefixed # all but "Rector" prefix by "Prefixed"
What do you need to know from me to write it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will know that, after I try it:) But I feel like performance is bigger issue here, can we somehow speed it up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First things first. When PHAR is done, we can improve performance.
Doing both at same time improved neither of both, tried for you :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm with Tomas here. Let's first fix this PHAR issue, than we can join forces together and make Rector as fast as we can 💪
Added test for |
|
|
||
$this->assertNotCount(0, $resource); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edobarnas Here it's needed to override getContainerLoader()
in AppKernel
with own PharAwaretGlobFileLoader
class:
final class RectorKernel extends Kernel
{
/**
* @param ContainerInterface|ContainerBuilder $container
*/
protected function getContainerLoader(ContainerInterface $container): DelegatingLoader
{
$kernelFileLocator = new FileLocator($this);
$loaderResolver = new LoaderResolver([
// @todo - create this clsas
return PharAwareGlobFileLoader($container, $kernelFileLocator));
// ...
]);
return new DelegatingLoader($loaderResolver);
}
}
As done in here https://github.com/symplify/packagebuilder#10-do-you-need-to-merge-parameters-in-yaml-files-instead-of-override
PharAwareGlobFileLoader
might look like this:
namespace Symfony\Component\Config\Loader\GlobFileLoader;
final class PharAwareGlobFileLoader extends GlobFileLoader
{
protected function glob(string $pattern, bool $recursive, &$resource = null, bool $ignoreErrors = false)
{
// override parent glob() method logic to not-use "glob" function
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think @mssimi ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check GlobResource usages, I think it is not only used in loader.
Follow up in #449 |
rectorphp/rector-src@95e6a5e [CodingStyle] Handle FuncGetArgsToVariadicParamRector in Method/Static Call (#389)
Related to #319
Simplified and greatly improved performance of PHAR building script by using rsync.
Add composer script to build PHAR.
You can now ignore PHAR files in .pharignore.
Included an example for prefixing vendors using rector(performance is bad here so example is just for small folder).
Atm there is problem with autowring in PHAR as Symfony uses glob and it is not supported by PHAR.
At least this class will have to be re-implemented. I may add test for it later.