Skip to content
Snippets Groups Projects
Verified Commit 64fb3ff5 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3438846 by mondrake: Add return typehints for classes that inherit from Composer

parent 28d407eb
No related branches found
No related tags found
29 merge requests!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493
Pipeline #138785 canceled
Pipeline: drupal

#138792

    <?php <?php
    declare(strict_types=1);
    namespace Drupal\Composer\Plugin\VendorHardening; namespace Drupal\Composer\Plugin\VendorHardening;
    use Composer\Composer; use Composer\Composer;
    ...@@ -58,7 +60,7 @@ class VendorHardeningPlugin implements PluginInterface, EventSubscriberInterface ...@@ -58,7 +60,7 @@ class VendorHardeningPlugin implements PluginInterface, EventSubscriberInterface
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    public function activate(Composer $composer, IOInterface $io) { public function activate(Composer $composer, IOInterface $io): void {
    $this->composer = $composer; $this->composer = $composer;
    $this->io = $io; $this->io = $io;
    ...@@ -69,19 +71,19 @@ public function activate(Composer $composer, IOInterface $io) { ...@@ -69,19 +71,19 @@ public function activate(Composer $composer, IOInterface $io) {
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    public function deactivate(Composer $composer, IOInterface $io) { public function deactivate(Composer $composer, IOInterface $io): void {
    } }
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    public function uninstall(Composer $composer, IOInterface $io) { public function uninstall(Composer $composer, IOInterface $io): void {
    } }
    /** /**
    * {@inheritdoc} * {@inheritdoc}
    */ */
    public static function getSubscribedEvents() { public static function getSubscribedEvents(): array {
    return [ return [
    ScriptEvents::POST_AUTOLOAD_DUMP => 'onPostAutoloadDump', ScriptEvents::POST_AUTOLOAD_DUMP => 'onPostAutoloadDump',
    ScriptEvents::POST_UPDATE_CMD => 'onPostCmd', ScriptEvents::POST_UPDATE_CMD => 'onPostCmd',
    ...@@ -99,7 +101,7 @@ public static function getSubscribedEvents() { ...@@ -99,7 +101,7 @@ public static function getSubscribedEvents() {
    * @param \Composer\Script\Event $event * @param \Composer\Script\Event $event
    * The Composer event. * The Composer event.
    */ */
    public function onPostAutoloadDump(Event $event) { public function onPostAutoloadDump(Event $event): void {
    $this->writeAccessRestrictionFiles($this->composer->getConfig()->get('vendor-dir')); $this->writeAccessRestrictionFiles($this->composer->getConfig()->get('vendor-dir'));
    } }
    ...@@ -109,7 +111,7 @@ public function onPostAutoloadDump(Event $event) { ...@@ -109,7 +111,7 @@ public function onPostAutoloadDump(Event $event) {
    * @param \Composer\Script\Event $event * @param \Composer\Script\Event $event
    * The Composer event. * The Composer event.
    */ */
    public function onPostCmd(Event $event) { public function onPostCmd(Event $event): void {
    $this->cleanAllPackages(); $this->cleanAllPackages();
    } }
    ...@@ -119,7 +121,7 @@ public function onPostCmd(Event $event) { ...@@ -119,7 +121,7 @@ public function onPostCmd(Event $event) {
    * @param \Composer\Installer\PackageEvent $event * @param \Composer\Installer\PackageEvent $event
    * The package event. * The package event.
    */ */
    public function onPrePackageInstall(PackageEvent $event) { public function onPrePackageInstall(PackageEvent $event): void {
    /** @var \Composer\Package\CompletePackage $package */ /** @var \Composer\Package\CompletePackage $package */
    $package = $event->getOperation()->getPackage(); $package = $event->getOperation()->getPackage();
    $this->removeBinBeforeCleanup($package); $this->removeBinBeforeCleanup($package);
    ...@@ -131,7 +133,7 @@ public function onPrePackageInstall(PackageEvent $event) { ...@@ -131,7 +133,7 @@ public function onPrePackageInstall(PackageEvent $event) {
    * @param \Composer\Installer\PackageEvent $event * @param \Composer\Installer\PackageEvent $event
    * The package event. * The package event.
    */ */
    public function onPrePackageUpdate(PackageEvent $event) { public function onPrePackageUpdate(PackageEvent $event): void {
    /** @var \Composer\Package\CompletePackage $package */ /** @var \Composer\Package\CompletePackage $package */
    $package = $event->getOperation()->getTargetPackage(); $package = $event->getOperation()->getTargetPackage();
    $this->removeBinBeforeCleanup($package); $this->removeBinBeforeCleanup($package);
    ...@@ -143,7 +145,7 @@ public function onPrePackageUpdate(PackageEvent $event) { ...@@ -143,7 +145,7 @@ public function onPrePackageUpdate(PackageEvent $event) {
    * @param \Composer\Installer\PackageEvent $event * @param \Composer\Installer\PackageEvent $event
    * The package event. * The package event.
    */ */
    public function onPostPackageInstall(PackageEvent $event) { public function onPostPackageInstall(PackageEvent $event): void {
    $this->cleanPackage($event->getOperation()->getPackage()); $this->cleanPackage($event->getOperation()->getPackage());
    } }
    ...@@ -153,7 +155,7 @@ public function onPostPackageInstall(PackageEvent $event) { ...@@ -153,7 +155,7 @@ public function onPostPackageInstall(PackageEvent $event) {
    * @param \Composer\Installer\PackageEvent $event * @param \Composer\Installer\PackageEvent $event
    * The package event. * The package event.
    */ */
    public function onPostPackageUpdate(PackageEvent $event) { public function onPostPackageUpdate(PackageEvent $event): void {
    $this->cleanPackage($event->getOperation()->getTargetPackage()); $this->cleanPackage($event->getOperation()->getTargetPackage());
    } }
    ...@@ -166,7 +168,7 @@ public function onPostPackageUpdate(PackageEvent $event) { ...@@ -166,7 +168,7 @@ public function onPostPackageUpdate(PackageEvent $event) {
    * @param \Composer\Package\BasePackage $package * @param \Composer\Package\BasePackage $package
    * The package we're cleaning up. * The package we're cleaning up.
    */ */
    protected function removeBinBeforeCleanup(BasePackage $package) { protected function removeBinBeforeCleanup(BasePackage $package): void {
    // We can process AliasPackage and Package objects, and they share the // We can process AliasPackage and Package objects, and they share the
    // BasePackage parent class. However, since there is no common interface for // BasePackage parent class. However, since there is no common interface for
    // these package types that allow for the setBinaries() method, and since // these package types that allow for the setBinaries() method, and since
    ...@@ -208,7 +210,7 @@ protected function removeBinBeforeCleanup(BasePackage $package) { ...@@ -208,7 +210,7 @@ protected function removeBinBeforeCleanup(BasePackage $package) {
    * @return string[] * @return string[]
    * Bin files to remove, with the file as both the key and the value. * Bin files to remove, with the file as both the key and the value.
    */ */
    protected function findBinOverlap($binaries, $clean_paths) { protected function findBinOverlap(array $binaries, array $clean_paths): array {
    // Make a filesystem model to explore. This is a keyed array that looks like // Make a filesystem model to explore. This is a keyed array that looks like
    // all the places that will be removed by cleanup. 'tests/src' becomes // all the places that will be removed by cleanup. 'tests/src' becomes
    // $filesystem['tests']['src'] = TRUE; // $filesystem['tests']['src'] = TRUE;
    ...@@ -250,7 +252,7 @@ protected function findBinOverlap($binaries, $clean_paths) { ...@@ -250,7 +252,7 @@ protected function findBinOverlap($binaries, $clean_paths) {
    * @return \Composer\Package\PackageInterface[] * @return \Composer\Package\PackageInterface[]
    * The list of installed packages. * The list of installed packages.
    */ */
    protected function getInstalledPackages() { protected function getInstalledPackages(): array {
    return $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); return $this->composer->getRepositoryManager()->getLocalRepository()->getPackages();
    } }
    ...@@ -264,7 +266,7 @@ protected function getInstalledPackages() { ...@@ -264,7 +266,7 @@ protected function getInstalledPackages() {
    * Path to the install path for the package, relative to the project. This * Path to the install path for the package, relative to the project. This
    * accounts for changes made by composer/installers, if any. * accounts for changes made by composer/installers, if any.
    */ */
    protected function getInstallPathForPackage(PackageInterface $package) { protected function getInstallPathForPackage(PackageInterface $package): string {
    return $this->composer->getInstallationManager()->getInstallPath($package); return $this->composer->getInstallationManager()->getInstallPath($package);
    } }
    ...@@ -273,7 +275,7 @@ protected function getInstallPathForPackage(PackageInterface $package) { ...@@ -273,7 +275,7 @@ protected function getInstallPathForPackage(PackageInterface $package) {
    * *
    * This applies in the context of a post-command event. * This applies in the context of a post-command event.
    */ */
    public function cleanAllPackages() { public function cleanAllPackages(): void {
    // Get a list of all the packages available after the update or install // Get a list of all the packages available after the update or install
    // command. // command.
    $installed_packages = []; $installed_packages = [];
    ...@@ -309,7 +311,7 @@ public function cleanAllPackages() { ...@@ -309,7 +311,7 @@ public function cleanAllPackages() {
    * @param \Composer\Package\PackageInterface $package * @param \Composer\Package\PackageInterface $package
    * The package to clean. * The package to clean.
    */ */
    public function cleanPackage(PackageInterface $package) { public function cleanPackage(PackageInterface $package): void {
    // Normalize package names to lower case. // Normalize package names to lower case.
    $package_name = strtolower($package->getName()); $package_name = strtolower($package->getName());
    if (isset($this->packagesAlreadyCleaned[$package_name])) { if (isset($this->packagesAlreadyCleaned[$package_name])) {
    ...@@ -332,7 +334,7 @@ public function cleanPackage(PackageInterface $package) { ...@@ -332,7 +334,7 @@ public function cleanPackage(PackageInterface $package) {
    * @param string $paths_for_package * @param string $paths_for_package
    * List of directories in $package_name to remove * List of directories in $package_name to remove
    */ */
    protected function cleanPathsForPackage(PackageInterface $package, $paths_for_package) { protected function cleanPathsForPackage(PackageInterface $package, $paths_for_package): void {
    // Whatever happens here, this package counts as cleaned so that we don't // Whatever happens here, this package counts as cleaned so that we don't
    // process it more than once. // process it more than once.
    $package_name = strtolower($package->getName()); $package_name = strtolower($package->getName());
    ...@@ -373,7 +375,7 @@ protected function cleanPathsForPackage(PackageInterface $package, $paths_for_pa ...@@ -373,7 +375,7 @@ protected function cleanPathsForPackage(PackageInterface $package, $paths_for_pa
    * @param string $vendor_dir * @param string $vendor_dir
    * Path to vendor directory. * Path to vendor directory.
    */ */
    public function writeAccessRestrictionFiles($vendor_dir) { public function writeAccessRestrictionFiles(string $vendor_dir): void {
    $this->io->writeError('<info>Hardening vendor directory with .htaccess and web.config files.</info>'); $this->io->writeError('<info>Hardening vendor directory with .htaccess and web.config files.</info>');
    // Prevent access to vendor directory on Apache servers. // Prevent access to vendor directory on Apache servers.
    FileSecurity::writeHtaccess($vendor_dir, TRUE); FileSecurity::writeHtaccess($vendor_dir, TRUE);
    ......
    ...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
    # Skip some dependencies' DebugClassLoader forward compatibility warnings. # Skip some dependencies' DebugClassLoader forward compatibility warnings.
    %Method "Behat\\[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% %Method "Behat\\[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    %Method "Composer\\EventDispatcher\\EventSubscriberInterface::getSubscribedEvents\(\)" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    %Method "Composer\\Plugin\\PluginInterface::(activate|deactivate|uninstall)\(\)" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    %Method "Doctrine\\Common\\Annotations\\Reader::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% %Method "Doctrine\\Common\\Annotations\\Reader::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    %Method "Twig\\Extension\\ExtensionInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% %Method "Twig\\Extension\\ExtensionInterface::[^"]+" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    %Method "Twig\\Loader\\FilesystemLoader::findTemplate\(\)" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message% %Method "Twig\\Loader\\FilesystemLoader::findTemplate\(\)" might add "[^"]+" as a native return type declaration in the future. Do the same in (child class|implementation) "[^"]+" now to avoid errors or add an explicit @return annotation to suppress this message%
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment