Conditions | 1 |
Paths | 1 |
Total Lines | 523 |
Code Lines | 500 |
Lines | 0 |
Ratio | 0 % |
Changes | 12 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
388 | public function testDumpVersionsWithoutPackageSourceDetails() : void |
||
389 | { |
||
390 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
391 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
392 | $repositoryManager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); |
||
393 | $installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock(); |
||
394 | $repository = $this->createMock(InstalledRepositoryInterface::class); |
||
395 | |||
396 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true); |
||
397 | |||
398 | $expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions'; |
||
399 | |||
400 | /** @noinspection MkdirRaceConditionInspection */ |
||
401 | mkdir($expectedPath, 0777, true); |
||
402 | |||
403 | $locker |
||
404 | ->expects(self::any()) |
||
405 | ->method('getLockData') |
||
406 | ->willReturn([ |
||
407 | 'packages' => [ |
||
408 | [ |
||
409 | 'name' => 'ocramius/package-versions', |
||
410 | 'version' => '1.0.0', |
||
411 | ], |
||
412 | [ |
||
413 | 'name' => 'foo/bar', |
||
414 | 'version' => '1.2.3', |
||
415 | 'dist' => ['reference' => 'abc123'], // version defined in the dist, this time |
||
416 | ], |
||
417 | [ |
||
418 | 'name' => 'baz/tab', |
||
419 | 'version' => '4.5.6', // source missing |
||
420 | ], |
||
421 | ], |
||
422 | ]); |
||
423 | |||
424 | $repositoryManager->expects(self::any())->method('getLocalRepository')->willReturn($repository); |
||
425 | |||
426 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
427 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
428 | $this->composer->expects(self::any())->method('getRepositoryManager')->willReturn($repositoryManager); |
||
429 | $this->composer->expects(self::any())->method('getPackage')->willReturn($this->getRootPackageMock()); |
||
430 | $this->composer->expects(self::any())->method('getInstallationManager')->willReturn($installManager); |
||
431 | |||
432 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
433 | |||
434 | Installer::dumpVersionsClass(new Event( |
||
435 | 'post-install-cmd', |
||
436 | $this->composer, |
||
437 | $this->io |
||
438 | )); |
||
439 | |||
440 | $expectedSource = <<<'PHP' |
||
441 | <?php |
||
442 | |||
443 | declare(strict_types=1); |
||
444 | |||
445 | namespace PackageVersions; |
||
446 | |||
447 | use OutOfBoundsException; |
||
448 | |||
449 | /** |
||
450 | * This class is generated by ocramius/package-versions, specifically by |
||
451 | * @see \PackageVersions\Installer |
||
452 | * |
||
453 | * This file is overwritten at every run of `composer install` or `composer update`. |
||
454 | */ |
||
455 | final class Versions |
||
456 | { |
||
457 | public const ROOT_PACKAGE_NAME = 'root/package'; |
||
458 | /** |
||
459 | * Array of all available composer packages. |
||
460 | * Dont read this array from your calling code, but use the \PackageVersions\Versions::getVersion() method instead. |
||
461 | * |
||
462 | * @var array<string, string> |
||
463 | * @internal |
||
464 | */ |
||
465 | public const VERSIONS = array ( |
||
466 | 'ocramius/package-versions' => '1.0.0@', |
||
467 | 'foo/bar' => '1.2.3@abc123', |
||
468 | 'baz/tab' => '4.5.6@', |
||
469 | 'some-replaced/package' => '1.3.5@aaabbbcccddd', |
||
470 | 'root/package' => '1.3.5@aaabbbcccddd', |
||
471 | ); |
||
472 | |||
473 | private function __construct() |
||
474 | { |
||
475 | } |
||
476 | |||
477 | /** |
||
478 | * @throws OutOfBoundsException If a version cannot be located. |
||
479 | * |
||
480 | * @psalm-param key-of<self::VERSIONS> $packageName |
||
481 | * @psalm-pure |
||
482 | */ |
||
483 | public static function getVersion(string $packageName) : string |
||
484 | { |
||
485 | if (isset(self::VERSIONS[$packageName])) { |
||
486 | return self::VERSIONS[$packageName]; |
||
487 | } |
||
488 | |||
489 | throw new OutOfBoundsException( |
||
490 | 'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files' |
||
491 | ); |
||
492 | } |
||
493 | } |
||
494 | |||
495 | PHP; |
||
496 | |||
497 | self::assertSame($expectedSource, file_get_contents($expectedPath . '/Versions.php')); |
||
498 | |||
499 | $this->rmDir($vendorDir); |
||
500 | } |
||
501 | |||
502 | /** |
||
503 | * @throws RuntimeException |
||
504 | * |
||
505 | * @dataProvider rootPackageProvider |
||
506 | */ |
||
507 | public function testDumpsVersionsClassToSpecificLocation(RootPackageInterface $rootPackage, bool $inVendor) : void |
||
508 | { |
||
509 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
510 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
511 | $repositoryManager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); |
||
512 | $installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock(); |
||
513 | $repository = $this->createMock(InstalledRepositoryInterface::class); |
||
514 | |||
515 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true) . '/vendor'; |
||
516 | |||
517 | /** @noinspection MkdirRaceConditionInspection */ |
||
518 | mkdir($vendorDir, 0777, true); |
||
519 | |||
520 | /** @noinspection RealpathInSteamContextInspection */ |
||
521 | $expectedPath = $inVendor |
||
522 | ? $vendorDir . '/ocramius/package-versions/src/PackageVersions' |
||
523 | : realpath($vendorDir . '/..') . '/src/PackageVersions'; |
||
524 | |||
525 | /** @noinspection MkdirRaceConditionInspection */ |
||
526 | mkdir($expectedPath, 0777, true); |
||
527 | |||
528 | $locker |
||
529 | ->expects(self::any()) |
||
530 | ->method('getLockData') |
||
531 | ->willReturn([ |
||
532 | 'packages' => [ |
||
533 | [ |
||
534 | 'name' => 'ocramius/package-versions', |
||
535 | 'version' => '1.0.0', |
||
536 | ], |
||
537 | ], |
||
538 | 'packages-dev' => [], |
||
539 | ]); |
||
540 | |||
541 | $repositoryManager->expects(self::any())->method('getLocalRepository')->willReturn($repository); |
||
542 | |||
543 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
544 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
545 | $this->composer->expects(self::any())->method('getRepositoryManager')->willReturn($repositoryManager); |
||
546 | $this->composer->expects(self::any())->method('getPackage')->willReturn($rootPackage); |
||
547 | $this->composer->expects(self::any())->method('getInstallationManager')->willReturn($installManager); |
||
548 | |||
549 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
550 | |||
551 | Installer::dumpVersionsClass(new Event( |
||
552 | 'post-install-cmd', |
||
553 | $this->composer, |
||
554 | $this->io |
||
555 | )); |
||
556 | |||
557 | self::assertStringMatchesFormat( |
||
558 | '%Aclass Versions%A1.2.3@%A', |
||
559 | file_get_contents($expectedPath . '/Versions.php') |
||
560 | ); |
||
561 | |||
562 | $this->rmDir($vendorDir); |
||
563 | } |
||
564 | |||
565 | /** |
||
566 | * @return bool[][]|RootPackageInterface[][] the root package and whether the versions class is to be generated in |
||
567 | * the vendor dir or not |
||
568 | */ |
||
569 | public function rootPackageProvider() : array |
||
570 | { |
||
571 | $baseRootPackage = new RootPackage('root/package', '1.2.3', '1.2.3'); |
||
572 | $aliasRootPackage = new RootAliasPackage($baseRootPackage, '1.2.3', '1.2.3'); |
||
573 | $indirectAliasRootPackage = new RootAliasPackage($aliasRootPackage, '1.2.3', '1.2.3'); |
||
574 | $packageVersionsRootPackage = new RootPackage('ocramius/package-versions', '1.2.3', '1.2.3'); |
||
575 | $aliasPackageVersionsRootPackage = new RootAliasPackage($packageVersionsRootPackage, '1.2.3', '1.2.3'); |
||
576 | $indirectAliasPackageVersionsRootPackage = new RootAliasPackage( |
||
577 | $aliasPackageVersionsRootPackage, |
||
578 | '1.2.3', |
||
579 | '1.2.3' |
||
580 | ); |
||
581 | |||
582 | return [ |
||
583 | 'root package is not ocramius/package-versions' => [ |
||
584 | $baseRootPackage, |
||
585 | true, |
||
586 | ], |
||
587 | 'alias root package is not ocramius/package-versions' => [ |
||
588 | $aliasRootPackage, |
||
589 | true, |
||
590 | ], |
||
591 | 'indirect alias root package is not ocramius/package-versions' => [ |
||
592 | $indirectAliasRootPackage, |
||
593 | true, |
||
594 | ], |
||
595 | 'root package is ocramius/package-versions' => [ |
||
596 | $packageVersionsRootPackage, |
||
597 | false, |
||
598 | ], |
||
599 | 'alias root package is ocramius/package-versions' => [ |
||
600 | $aliasPackageVersionsRootPackage, |
||
601 | false, |
||
602 | ], |
||
603 | 'indirect alias root package is ocramius/package-versions' => [ |
||
604 | $indirectAliasPackageVersionsRootPackage, |
||
605 | false, |
||
606 | ], |
||
607 | ]; |
||
608 | } |
||
609 | |||
610 | public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired() : void |
||
611 | { |
||
612 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
613 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
614 | $repositoryManager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); |
||
615 | $installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock(); |
||
616 | $repository = $this->createMock(InstalledRepositoryInterface::class); |
||
617 | $package = $this->createMock(RootPackageInterface::class); |
||
618 | |||
619 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true); |
||
620 | |||
621 | $expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions'; |
||
622 | |||
623 | /** @noinspection MkdirRaceConditionInspection */ |
||
624 | mkdir($expectedPath, 0777, true); |
||
625 | |||
626 | $locker |
||
627 | ->expects(self::any()) |
||
628 | ->method('getLockData') |
||
629 | ->willReturn([ |
||
630 | 'packages' => [ |
||
631 | [ |
||
632 | 'name' => 'foo/bar', |
||
633 | 'version' => '1.2.3', |
||
634 | 'dist' => ['reference' => 'abc123'], // version defined in the dist, this time |
||
635 | ], |
||
636 | [ |
||
637 | 'name' => 'baz/tab', |
||
638 | 'version' => '4.5.6', // source missing |
||
639 | ], |
||
640 | ], |
||
641 | ]); |
||
642 | |||
643 | $repositoryManager->expects(self::any())->method('getLocalRepository')->willReturn($repository); |
||
644 | |||
645 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
646 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
647 | $this->composer->expects(self::any())->method('getRepositoryManager')->willReturn($repositoryManager); |
||
648 | $this->composer->expects(self::any())->method('getPackage')->willReturn($package); |
||
649 | $this->composer->expects(self::any())->method('getInstallationManager')->willReturn($installManager); |
||
650 | |||
651 | $package->expects(self::any())->method('getName')->willReturn('root/package'); |
||
652 | $package->expects(self::any())->method('getVersion')->willReturn('1.3.5'); |
||
653 | $package->expects(self::any())->method('getSourceReference')->willReturn('aaabbbcccddd'); |
||
654 | $package->expects(self::any())->method('getReplaces')->willReturn([]); |
||
655 | |||
656 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
657 | |||
658 | Installer::dumpVersionsClass(new Event( |
||
659 | 'post-install-cmd', |
||
660 | $this->composer, |
||
661 | $this->io |
||
662 | )); |
||
663 | |||
664 | self::assertFileNotExists($expectedPath . '/Versions.php'); |
||
665 | |||
666 | $this->rmDir($vendorDir); |
||
667 | } |
||
668 | |||
669 | /** |
||
670 | * @group #41 |
||
671 | * @group #46 |
||
672 | */ |
||
673 | public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval() : void |
||
674 | { |
||
675 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
676 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
677 | $package = $this->createMock(RootPackageInterface::class); |
||
678 | $package->expects(self::any())->method('getReplaces')->willReturn([]); |
||
679 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true); |
||
680 | $expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions'; |
||
681 | |||
682 | $locker |
||
683 | ->expects(self::any()) |
||
684 | ->method('getLockData') |
||
685 | ->willReturn([ |
||
686 | 'packages' => [ |
||
687 | [ |
||
688 | 'name' => 'ocramius/package-versions', |
||
689 | 'version' => '1.0.0', |
||
690 | ], |
||
691 | ], |
||
692 | ]); |
||
693 | |||
694 | $package->expects(self::any())->method('getName')->willReturn('root/package'); |
||
695 | |||
696 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
697 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
698 | $this->composer->expects(self::any())->method('getPackage')->willReturn($package); |
||
699 | |||
700 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
701 | |||
702 | Installer::dumpVersionsClass(new Event( |
||
703 | 'post-install-cmd', |
||
704 | $this->composer, |
||
705 | $this->io |
||
706 | )); |
||
707 | |||
708 | self::assertFileNotExists($expectedPath . '/Versions.php'); |
||
709 | self::assertFileNotExists($expectedPath . '/Versions.php'); |
||
710 | } |
||
711 | |||
712 | public function testGeneratedVersionFileAccessRights() : void |
||
713 | { |
||
714 | if (strpos(PHP_OS, 'WIN') === 0) { |
||
715 | $this->markTestSkipped('Windows is kinda "meh" at file access levels'); |
||
716 | } |
||
717 | |||
718 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
719 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
720 | $repositoryManager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); |
||
721 | $installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock(); |
||
722 | $repository = $this->createMock(InstalledRepositoryInterface::class); |
||
723 | $package = $this->createMock(RootPackageInterface::class); |
||
724 | $package->expects(self::any())->method('getReplaces')->willReturn([]); |
||
725 | |||
726 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true); |
||
727 | |||
728 | $expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions'; |
||
729 | |||
730 | /** @noinspection MkdirRaceConditionInspection */ |
||
731 | mkdir($expectedPath, 0777, true); |
||
732 | |||
733 | $locker |
||
734 | ->expects(self::any()) |
||
735 | ->method('getLockData') |
||
736 | ->willReturn([ |
||
737 | 'packages' => [ |
||
738 | [ |
||
739 | 'name' => 'ocramius/package-versions', |
||
740 | 'version' => '1.0.0', |
||
741 | ], |
||
742 | ], |
||
743 | ]); |
||
744 | |||
745 | $repositoryManager->expects(self::any())->method('getLocalRepository')->willReturn($repository); |
||
746 | |||
747 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
748 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
749 | $this->composer->expects(self::any())->method('getRepositoryManager')->willReturn($repositoryManager); |
||
750 | $this->composer->expects(self::any())->method('getPackage')->willReturn($package); |
||
751 | $this->composer->expects(self::any())->method('getInstallationManager')->willReturn($installManager); |
||
752 | |||
753 | $package->expects(self::any())->method('getName')->willReturn('root/package'); |
||
754 | $package->expects(self::any())->method('getVersion')->willReturn('1.3.5'); |
||
755 | $package->expects(self::any())->method('getSourceReference')->willReturn('aaabbbcccddd'); |
||
756 | |||
757 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
758 | |||
759 | Installer::dumpVersionsClass(new Event( |
||
760 | 'post-install-cmd', |
||
761 | $this->composer, |
||
762 | $this->io |
||
763 | )); |
||
764 | |||
765 | $filePath = $expectedPath . '/Versions.php'; |
||
766 | |||
767 | self::assertFileExists($filePath); |
||
768 | self::assertSame('0664', substr(sprintf('%o', fileperms($filePath)), -4)); |
||
769 | |||
770 | $this->rmDir($vendorDir); |
||
771 | } |
||
772 | |||
773 | private function rmDir(string $directory) : void |
||
774 | { |
||
775 | if (! is_dir($directory)) { |
||
776 | unlink($directory); |
||
777 | |||
778 | return; |
||
779 | } |
||
780 | |||
781 | array_map( |
||
782 | function ($item) use ($directory) : void { |
||
783 | $this->rmDir($directory . '/' . $item); |
||
784 | }, |
||
785 | array_filter( |
||
786 | scandir($directory), |
||
787 | static function (string $dirItem) { |
||
788 | return ! in_array($dirItem, ['.', '..'], true); |
||
789 | } |
||
790 | ) |
||
791 | ); |
||
792 | |||
793 | rmdir($directory); |
||
794 | } |
||
795 | |||
796 | /** |
||
797 | * @group composer/composer#5237 |
||
798 | */ |
||
799 | public function testWillEscapeRegexParsingOfClassDefinitions() : void |
||
800 | { |
||
801 | self::assertSame( |
||
802 | 1, |
||
803 | preg_match_all( |
||
804 | '{^((?:final\s+)?(?:\s*))class\s+(\S+)}mi', |
||
805 | file_get_contents((new ReflectionClass(Installer::class))->getFileName()) |
||
806 | ) |
||
807 | ); |
||
808 | } |
||
809 | |||
810 | public function testGetVersionsIsNotNormalizedForRootPackage() : void |
||
811 | { |
||
812 | $config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); |
||
813 | $locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock(); |
||
814 | $repositoryManager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->getMock(); |
||
815 | $installManager = $this->getMockBuilder(InstallationManager::class)->disableOriginalConstructor()->getMock(); |
||
816 | $repository = $this->createMock(InstalledRepositoryInterface::class); |
||
817 | |||
818 | $vendorDir = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true); |
||
819 | |||
820 | $expectedPath = $vendorDir . '/ocramius/package-versions/src/PackageVersions'; |
||
821 | |||
822 | /** @noinspection MkdirRaceConditionInspection */ |
||
823 | mkdir($expectedPath, 0777, true); |
||
824 | |||
825 | $locker |
||
826 | ->expects(self::any()) |
||
827 | ->method('getLockData') |
||
828 | ->willReturn([ |
||
829 | 'packages' => [ |
||
830 | [ |
||
831 | 'name' => 'ocramius/package-versions', |
||
832 | 'version' => '1.0.0', |
||
833 | ], |
||
834 | ], |
||
835 | ]); |
||
836 | |||
837 | $repositoryManager->expects(self::any())->method('getLocalRepository')->willReturn($repository); |
||
838 | |||
839 | $this->composer->expects(self::any())->method('getConfig')->willReturn($config); |
||
840 | $this->composer->expects(self::any())->method('getLocker')->willReturn($locker); |
||
841 | $this->composer->expects(self::any())->method('getRepositoryManager')->willReturn($repositoryManager); |
||
842 | $this->composer->expects(self::any())->method('getPackage')->willReturn($this->getRootPackageMock()); |
||
843 | $this->composer->expects(self::any())->method('getInstallationManager')->willReturn($installManager); |
||
844 | |||
845 | $config->expects(self::any())->method('get')->with('vendor-dir')->willReturn($vendorDir); |
||
846 | |||
847 | Installer::dumpVersionsClass(new Event( |
||
848 | 'post-install-cmd', |
||
849 | $this->composer, |
||
850 | $this->io |
||
851 | )); |
||
852 | |||
853 | $expectedSource = <<<'PHP' |
||
854 | <?php |
||
855 | |||
856 | declare(strict_types=1); |
||
857 | |||
858 | namespace PackageVersions; |
||
859 | |||
860 | use OutOfBoundsException; |
||
861 | |||
862 | /** |
||
863 | * This class is generated by ocramius/package-versions, specifically by |
||
864 | * @see \PackageVersions\Installer |
||
865 | * |
||
866 | * This file is overwritten at every run of `composer install` or `composer update`. |
||
867 | */ |
||
868 | final class Versions |
||
869 | { |
||
870 | public const ROOT_PACKAGE_NAME = 'root/package'; |
||
871 | /** |
||
872 | * Array of all available composer packages. |
||
873 | * Dont read this array from your calling code, but use the \PackageVersions\Versions::getVersion() method instead. |
||
874 | * |
||
875 | * @var array<string, string> |
||
876 | * @internal |
||
877 | */ |
||
878 | public const VERSIONS = array ( |
||
879 | 'ocramius/package-versions' => '1.0.0@', |
||
880 | 'some-replaced/package' => '1.3.5@aaabbbcccddd', |
||
881 | 'root/package' => '1.3.5@aaabbbcccddd', |
||
882 | ); |
||
883 | |||
884 | private function __construct() |
||
885 | { |
||
886 | } |
||
887 | |||
888 | /** |
||
889 | * @throws OutOfBoundsException If a version cannot be located. |
||
890 | * |
||
891 | * @psalm-param key-of<self::VERSIONS> $packageName |
||
892 | * @psalm-pure |
||
893 | */ |
||
894 | public static function getVersion(string $packageName) : string |
||
895 | { |
||
896 | if (isset(self::VERSIONS[$packageName])) { |
||
897 | return self::VERSIONS[$packageName]; |
||
898 | } |
||
899 | |||
900 | throw new OutOfBoundsException( |
||
901 | 'Required package "' . $packageName . '" is not installed: check your ./vendor/composer/installed.json and/or ./composer.lock files' |
||
902 | ); |
||
903 | } |
||
904 | } |
||
905 | |||
906 | PHP; |
||
907 | |||
908 | self::assertSame($expectedSource, file_get_contents($expectedPath . '/Versions.php')); |
||
909 | |||
910 | $this->rmDir($vendorDir); |
||
911 | } |
||
929 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.