diff --git a/src/Configuration/ConfigurationKeys.php b/src/Configuration/ConfigurationKeys.php index bb1c7d42..9712e58d 100644 --- a/src/Configuration/ConfigurationKeys.php +++ b/src/Configuration/ConfigurationKeys.php @@ -14,8 +14,12 @@ namespace Humbug\PhpScoper\Configuration; +use Humbug\PhpScoper\NotInstantiable; + final class ConfigurationKeys { + use NotInstantiable; + public const PREFIX_KEYWORD = 'prefix'; public const OUTPUT_DIR_KEYWORD = 'output-dir'; public const EXCLUDED_FILES_KEYWORD = 'exclude-files'; @@ -54,8 +58,4 @@ final class ConfigurationKeys self::FUNCTIONS_INTERNAL_SYMBOLS_KEYWORD, self::CONSTANTS_INTERNAL_SYMBOLS_KEYWORD, ]; - - private function __construct() - { - } } diff --git a/src/Configuration/SymbolsConfiguration.php b/src/Configuration/SymbolsConfiguration.php index 9e9d8671..dec9e854 100644 --- a/src/Configuration/SymbolsConfiguration.php +++ b/src/Configuration/SymbolsConfiguration.php @@ -14,11 +14,14 @@ namespace Humbug\PhpScoper\Configuration; +use Humbug\PhpScoper\NotInstantiable; use Humbug\PhpScoper\Symbol\NamespaceRegistry; use Humbug\PhpScoper\Symbol\SymbolRegistry; final class SymbolsConfiguration { + use NotInstantiable; + // To keep in sync with the default configuration set in src/scoper.inc.php.tpl public static function create( bool $exposeGlobalConstants = true, diff --git a/src/Console/Command/ChangeableDirectory.php b/src/Console/Command/ChangeableDirectory.php index 07e52866..10d52752 100644 --- a/src/Console/Command/ChangeableDirectory.php +++ b/src/Console/Command/ChangeableDirectory.php @@ -15,6 +15,7 @@ namespace Humbug\PhpScoper\Console\Command; use Fidry\Console\Input\IO; +use Humbug\PhpScoper\NotInstantiable; use InvalidArgumentException; use Symfony\Component\Console\Exception\RuntimeException; use Symfony\Component\Console\Input\InputOption; @@ -29,11 +30,9 @@ */ final class ChangeableDirectory { - private const WORKING_DIR_OPT = 'working-dir'; + use NotInstantiable; - private function __construct() - { - } + private const WORKING_DIR_OPT = 'working-dir'; public static function createOption(): InputOption { diff --git a/src/NotInstantiable.php b/src/NotInstantiable.php new file mode 100644 index 00000000..81e7ee81 --- /dev/null +++ b/src/NotInstantiable.php @@ -0,0 +1,25 @@ +, + * Pádraic Brady + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Humbug\PhpScoper; + +/** + * @private + */ +trait NotInstantiable +{ + private function __construct() + { + } +} diff --git a/src/PhpParser/Node/FullyQualifiedFactory.php b/src/PhpParser/Node/FullyQualifiedFactory.php index aec6e569..1b095215 100644 --- a/src/PhpParser/Node/FullyQualifiedFactory.php +++ b/src/PhpParser/Node/FullyQualifiedFactory.php @@ -14,12 +14,15 @@ namespace Humbug\PhpScoper\PhpParser\Node; +use Humbug\PhpScoper\NotInstantiable; use InvalidArgumentException; use PhpParser\Node\Name; use PhpParser\Node\Name\FullyQualified; final class FullyQualifiedFactory { + use NotInstantiable; + /** * @param string|string[]|Name|null $name1 * @param string|string[]|Name|null $name2 @@ -32,8 +35,4 @@ public static function concat($name1, $name2, array $attributes = []): FullyQual return FullyQualified::concat($name1, $name2, $attributes); } - - private function __construct() - { - } } diff --git a/src/PhpParser/Node/NameFactory.php b/src/PhpParser/Node/NameFactory.php index 375fa239..7b70181d 100644 --- a/src/PhpParser/Node/NameFactory.php +++ b/src/PhpParser/Node/NameFactory.php @@ -14,11 +14,14 @@ namespace Humbug\PhpScoper\PhpParser\Node; +use Humbug\PhpScoper\NotInstantiable; use InvalidArgumentException; use PhpParser\Node\Name; final class NameFactory { + use NotInstantiable; + /** * @param string|string[]|Name|null $name1 * @param string|string[]|Name|null $name2 @@ -31,8 +34,4 @@ public static function concat($name1, $name2, array $attributes = []): Name return Name::concat($name1, $name2, $attributes); } - - private function __construct() - { - } } diff --git a/src/PhpParser/NodeVisitor/NamespaceStmt/NamespaceManipulator.php b/src/PhpParser/NodeVisitor/NamespaceStmt/NamespaceManipulator.php index 04c74d06..a2a18da2 100644 --- a/src/PhpParser/NodeVisitor/NamespaceStmt/NamespaceManipulator.php +++ b/src/PhpParser/NodeVisitor/NamespaceStmt/NamespaceManipulator.php @@ -14,6 +14,7 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\NamespaceStmt; +use Humbug\PhpScoper\NotInstantiable; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Namespace_; use PhpParser\NodeVisitorAbstract; @@ -23,6 +24,8 @@ */ final class NamespaceManipulator extends NodeVisitorAbstract { + use NotInstantiable; + private const ORIGINAL_NAME_ATTRIBUTE = 'originalName'; public static function hasOriginalName(Namespace_ $namespace): bool @@ -43,8 +46,4 @@ public static function setOriginalName(Namespace_ $namespace, ?Name $originalNam { $namespace->setAttribute(self::ORIGINAL_NAME_ATTRIBUTE, $originalName); } - - private function __construct() - { - } } diff --git a/src/PhpParser/NodeVisitor/Resolver/OriginalNameResolver.php b/src/PhpParser/NodeVisitor/Resolver/OriginalNameResolver.php index be473507..071c9c86 100644 --- a/src/PhpParser/NodeVisitor/Resolver/OriginalNameResolver.php +++ b/src/PhpParser/NodeVisitor/Resolver/OriginalNameResolver.php @@ -14,10 +14,13 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Resolver; +use Humbug\PhpScoper\NotInstantiable; use PhpParser\Node\Name; final class OriginalNameResolver { + use NotInstantiable; + private const ORIGINAL_NAME_ATTRIBUTE = 'originalName'; public static function hasOriginalName(Name $namespace): bool @@ -33,8 +36,4 @@ public static function getOriginalName(Name $name): Name return $name->getAttribute(self::ORIGINAL_NAME_ATTRIBUTE); } - - private function __construct() - { - } } diff --git a/src/PhpParser/NodeVisitor/UseStmt/UseStmtManipulator.php b/src/PhpParser/NodeVisitor/UseStmt/UseStmtManipulator.php index 0ad2eb76..df13fe0d 100644 --- a/src/PhpParser/NodeVisitor/UseStmt/UseStmtManipulator.php +++ b/src/PhpParser/NodeVisitor/UseStmt/UseStmtManipulator.php @@ -14,6 +14,7 @@ namespace Humbug\PhpScoper\PhpParser\NodeVisitor\UseStmt; +use Humbug\PhpScoper\NotInstantiable; use PhpParser\Node\Name; use PhpParser\Node\Stmt\UseUse; use PhpParser\NodeVisitorAbstract; @@ -23,6 +24,8 @@ */ final class UseStmtManipulator extends NodeVisitorAbstract { + use NotInstantiable; + private const ORIGINAL_NAME_ATTRIBUTE = 'originalName'; public static function hasOriginalName(UseUse $use): bool @@ -43,8 +46,4 @@ public static function setOriginalName(UseUse $use, ?Name $originalName): void { $use->setAttribute(self::ORIGINAL_NAME_ATTRIBUTE, $originalName); } - - private function __construct() - { - } }