From bb3a0ba327d8157a1a13146bccdca82537fb96ec Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 14 Sep 2019 11:48:20 +0200 Subject: [PATCH] Documented basic immutable/mutation-free interfaces and services in the package --- src/ProxyManager/Exception/DisabledMethodException.php | 2 ++ src/ProxyManager/Exception/ExceptionInterface.php | 2 ++ src/ProxyManager/Exception/FileNotWritableException.php | 2 ++ src/ProxyManager/Exception/InvalidProxiedClassException.php | 2 ++ src/ProxyManager/Exception/InvalidProxyDirectoryException.php | 2 ++ src/ProxyManager/Exception/UnsupportedProxiedClassException.php | 2 ++ src/ProxyManager/FileLocator/FileLocator.php | 2 ++ src/ProxyManager/Generator/ClassGenerator.php | 2 ++ src/ProxyManager/Generator/MagicMethodGenerator.php | 2 ++ src/ProxyManager/Generator/MethodGenerator.php | 2 ++ src/ProxyManager/Generator/Util/IdentifierSuffixer.php | 2 ++ .../Generator/Util/ProxiedMethodReturnExpression.php | 2 ++ src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php | 2 ++ src/ProxyManager/Inflector/ClassNameInflector.php | 2 ++ src/ProxyManager/Inflector/ClassNameInflectorInterface.php | 2 ++ src/ProxyManager/Inflector/Util/ParameterEncoder.php | 2 ++ src/ProxyManager/Inflector/Util/ParameterHasher.php | 2 ++ src/ProxyManager/Proxy/Exception/RemoteObjectException.php | 2 ++ src/ProxyManager/ProxyGenerator/Assertion/CanProxyAssertion.php | 2 ++ src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php | 2 ++ src/ProxyManager/ProxyGenerator/Util/Properties.php | 2 ++ src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php | 2 ++ src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php | 2 ++ .../ProxyGenerator/Util/UnsetPropertiesGenerator.php | 2 ++ src/ProxyManager/Signature/Exception/ExceptionInterface.php | 2 ++ .../Signature/Exception/InvalidSignatureException.php | 2 ++ .../Signature/Exception/MissingSignatureException.php | 2 ++ src/ProxyManager/Signature/SignatureChecker.php | 2 ++ src/ProxyManager/Signature/SignatureCheckerInterface.php | 2 ++ src/ProxyManager/Signature/SignatureGenerator.php | 2 ++ src/ProxyManager/Signature/SignatureGeneratorInterface.php | 2 ++ src/ProxyManager/Stub/EmptyClassStub.php | 2 ++ src/ProxyManager/Version.php | 2 ++ 33 files changed, 66 insertions(+) diff --git a/src/ProxyManager/Exception/DisabledMethodException.php b/src/ProxyManager/Exception/DisabledMethodException.php index 6d65cec88..a78ed8063 100644 --- a/src/ProxyManager/Exception/DisabledMethodException.php +++ b/src/ProxyManager/Exception/DisabledMethodException.php @@ -9,6 +9,8 @@ /** * Exception for forcefully disabled methods + * + * @psalm-immutable */ class DisabledMethodException extends BadMethodCallException implements ExceptionInterface { diff --git a/src/ProxyManager/Exception/ExceptionInterface.php b/src/ProxyManager/Exception/ExceptionInterface.php index 869628628..53cedb84a 100644 --- a/src/ProxyManager/Exception/ExceptionInterface.php +++ b/src/ProxyManager/Exception/ExceptionInterface.php @@ -8,6 +8,8 @@ /** * Base exception class for the proxy manager + * + * @psalm-immutable */ interface ExceptionInterface extends Throwable { diff --git a/src/ProxyManager/Exception/FileNotWritableException.php b/src/ProxyManager/Exception/FileNotWritableException.php index bb58c9ae8..73634902a 100644 --- a/src/ProxyManager/Exception/FileNotWritableException.php +++ b/src/ProxyManager/Exception/FileNotWritableException.php @@ -9,6 +9,8 @@ /** * Exception for non writable files + * + * @psalm-immutable */ class FileNotWritableException extends UnexpectedValueException implements ExceptionInterface { diff --git a/src/ProxyManager/Exception/InvalidProxiedClassException.php b/src/ProxyManager/Exception/InvalidProxiedClassException.php index 1ce3b5eb5..f7d99c643 100644 --- a/src/ProxyManager/Exception/InvalidProxiedClassException.php +++ b/src/ProxyManager/Exception/InvalidProxiedClassException.php @@ -14,6 +14,8 @@ /** * Exception for invalid proxied classes + * + * @psalm-immutable */ class InvalidProxiedClassException extends InvalidArgumentException implements ExceptionInterface { diff --git a/src/ProxyManager/Exception/InvalidProxyDirectoryException.php b/src/ProxyManager/Exception/InvalidProxyDirectoryException.php index d1ed4b6d4..64d799a88 100644 --- a/src/ProxyManager/Exception/InvalidProxyDirectoryException.php +++ b/src/ProxyManager/Exception/InvalidProxyDirectoryException.php @@ -9,6 +9,8 @@ /** * Exception for invalid directories + * + * @psalm-immutable */ class InvalidProxyDirectoryException extends InvalidArgumentException implements ExceptionInterface { diff --git a/src/ProxyManager/Exception/UnsupportedProxiedClassException.php b/src/ProxyManager/Exception/UnsupportedProxiedClassException.php index 847386d79..5b287b727 100644 --- a/src/ProxyManager/Exception/UnsupportedProxiedClassException.php +++ b/src/ProxyManager/Exception/UnsupportedProxiedClassException.php @@ -14,6 +14,8 @@ /** * Exception for invalid proxied classes + * + * @psalm-immutable */ class UnsupportedProxiedClassException extends LogicException implements ExceptionInterface { diff --git a/src/ProxyManager/FileLocator/FileLocator.php b/src/ProxyManager/FileLocator/FileLocator.php index e9c2cbf23..58cab59da 100644 --- a/src/ProxyManager/FileLocator/FileLocator.php +++ b/src/ProxyManager/FileLocator/FileLocator.php @@ -11,6 +11,8 @@ /** * {@inheritDoc} + * + * @psalm-immutable */ class FileLocator implements FileLocatorInterface { diff --git a/src/ProxyManager/Generator/ClassGenerator.php b/src/ProxyManager/Generator/ClassGenerator.php index 05199de79..160b8a675 100644 --- a/src/ProxyManager/Generator/ClassGenerator.php +++ b/src/ProxyManager/Generator/ClassGenerator.php @@ -10,6 +10,8 @@ /** * Class generator that ensures that interfaces/classes that are implemented/extended are FQCNs + * + * @psalm-external-mutation-free */ class ClassGenerator extends ZendClassGenerator { diff --git a/src/ProxyManager/Generator/MagicMethodGenerator.php b/src/ProxyManager/Generator/MagicMethodGenerator.php index 48e5c9233..50daa7810 100644 --- a/src/ProxyManager/Generator/MagicMethodGenerator.php +++ b/src/ProxyManager/Generator/MagicMethodGenerator.php @@ -9,6 +9,8 @@ /** * Method generator for magic methods + * + * @psalm-external-mutation-free */ class MagicMethodGenerator extends MethodGenerator { diff --git a/src/ProxyManager/Generator/MethodGenerator.php b/src/ProxyManager/Generator/MethodGenerator.php index 00353fc94..d01925f34 100644 --- a/src/ProxyManager/Generator/MethodGenerator.php +++ b/src/ProxyManager/Generator/MethodGenerator.php @@ -10,6 +10,8 @@ /** * Method generator that fixes minor quirks in ZF2's method generator + * + * @psalm-external-mutation-free */ class MethodGenerator extends ZendMethodGenerator { diff --git a/src/ProxyManager/Generator/Util/IdentifierSuffixer.php b/src/ProxyManager/Generator/Util/IdentifierSuffixer.php index d518efc0d..9bfeaeb46 100644 --- a/src/ProxyManager/Generator/Util/IdentifierSuffixer.php +++ b/src/ProxyManager/Generator/Util/IdentifierSuffixer.php @@ -16,6 +16,8 @@ * with a deterministic attached suffix, * in order to prevent property name collisions * and tampering from userland + * + * @psalm-immutable */ abstract class IdentifierSuffixer { diff --git a/src/ProxyManager/Generator/Util/ProxiedMethodReturnExpression.php b/src/ProxyManager/Generator/Util/ProxiedMethodReturnExpression.php index f8c661292..ac7cbdd25 100644 --- a/src/ProxyManager/Generator/Util/ProxiedMethodReturnExpression.php +++ b/src/ProxyManager/Generator/Util/ProxiedMethodReturnExpression.php @@ -10,6 +10,8 @@ * Utility class to generate return expressions in method, given a method signature. * * This is required since return expressions may be forbidden by the method signature (void). + * + * @psalm-immutable */ final class ProxiedMethodReturnExpression { diff --git a/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php b/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php index a7d00b716..808b393ba 100644 --- a/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php +++ b/src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php @@ -11,6 +11,8 @@ /** * Utility class capable of generating unique * valid class/property/method identifiers + * + * @psalm-immutable */ abstract class UniqueIdentifierGenerator { diff --git a/src/ProxyManager/Inflector/ClassNameInflector.php b/src/ProxyManager/Inflector/ClassNameInflector.php index 15f622f85..3ee5e4f5e 100644 --- a/src/ProxyManager/Inflector/ClassNameInflector.php +++ b/src/ProxyManager/Inflector/ClassNameInflector.php @@ -13,6 +13,8 @@ /** * {@inheritDoc} + * + * @psalm-immutable */ final class ClassNameInflector implements ClassNameInflectorInterface { diff --git a/src/ProxyManager/Inflector/ClassNameInflectorInterface.php b/src/ProxyManager/Inflector/ClassNameInflectorInterface.php index cf69a1110..8390e895f 100644 --- a/src/ProxyManager/Inflector/ClassNameInflectorInterface.php +++ b/src/ProxyManager/Inflector/ClassNameInflectorInterface.php @@ -8,6 +8,8 @@ /** * Interface for a proxy- to user-class and user- to proxy-class name inflector + * + * @psalm-immutable */ interface ClassNameInflectorInterface { diff --git a/src/ProxyManager/Inflector/Util/ParameterEncoder.php b/src/ProxyManager/Inflector/Util/ParameterEncoder.php index 10f6340cf..094d27d52 100644 --- a/src/ProxyManager/Inflector/Util/ParameterEncoder.php +++ b/src/ProxyManager/Inflector/Util/ParameterEncoder.php @@ -9,6 +9,8 @@ /** * Encodes parameters into a class-name safe string + * + * @psalm-immutable */ class ParameterEncoder { diff --git a/src/ProxyManager/Inflector/Util/ParameterHasher.php b/src/ProxyManager/Inflector/Util/ParameterHasher.php index d657cd6ab..39468f558 100644 --- a/src/ProxyManager/Inflector/Util/ParameterHasher.php +++ b/src/ProxyManager/Inflector/Util/ParameterHasher.php @@ -9,6 +9,8 @@ /** * Converts given parameters into a likely unique hash + * + * @psalm-immutable */ class ParameterHasher { diff --git a/src/ProxyManager/Proxy/Exception/RemoteObjectException.php b/src/ProxyManager/Proxy/Exception/RemoteObjectException.php index 3100eefb8..21f67ae06 100644 --- a/src/ProxyManager/Proxy/Exception/RemoteObjectException.php +++ b/src/ProxyManager/Proxy/Exception/RemoteObjectException.php @@ -10,6 +10,8 @@ * Remote object exception * * @deprecated this exception is not in use anymore, and should not be relied upon + * + * @psalm-immutable */ class RemoteObjectException extends RuntimeException { diff --git a/src/ProxyManager/ProxyGenerator/Assertion/CanProxyAssertion.php b/src/ProxyManager/ProxyGenerator/Assertion/CanProxyAssertion.php index 901f375dc..3eb3f0aa9 100644 --- a/src/ProxyManager/ProxyGenerator/Assertion/CanProxyAssertion.php +++ b/src/ProxyManager/ProxyGenerator/Assertion/CanProxyAssertion.php @@ -12,6 +12,8 @@ /** * Assertion that verifies that a class can be proxied + * + * @psalm-immutable */ final class CanProxyAssertion { diff --git a/src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php b/src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php index 62e58ab88..fa6283476 100644 --- a/src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php +++ b/src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php @@ -9,6 +9,8 @@ /** * Internal utility class - allows fetching a method from a given class, if it exists + * + * @psalm-immutable */ final class GetMethodIfExists { diff --git a/src/ProxyManager/ProxyGenerator/Util/Properties.php b/src/ProxyManager/ProxyGenerator/Util/Properties.php index 3dbee7d91..0a5b4e573 100644 --- a/src/ProxyManager/ProxyGenerator/Util/Properties.php +++ b/src/ProxyManager/ProxyGenerator/Util/Properties.php @@ -18,6 +18,8 @@ /** * DTO containing the list of all non-static proxy properties and utility methods to access them * in various formats/collections + * + * @psalm-immutable */ final class Properties { diff --git a/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php b/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php index 721c833b0..4450bcd7c 100644 --- a/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php +++ b/src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php @@ -15,6 +15,8 @@ /** * Utility class used to filter methods that can be proxied + * + * @psalm-immutable */ final class ProxiedMethodsFilter { diff --git a/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php b/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php index f87750e5d..fb349caaa 100644 --- a/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php +++ b/src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php @@ -12,6 +12,8 @@ * Generates code necessary to simulate a fatal error in case of unauthorized * access to class members in magic methods even when in child classes and dealing * with protected members. + * + * @psalm-immutable */ class PublicScopeSimulator { diff --git a/src/ProxyManager/ProxyGenerator/Util/UnsetPropertiesGenerator.php b/src/ProxyManager/ProxyGenerator/Util/UnsetPropertiesGenerator.php index d55844cc9..0d0edf4df 100644 --- a/src/ProxyManager/ProxyGenerator/Util/UnsetPropertiesGenerator.php +++ b/src/ProxyManager/ProxyGenerator/Util/UnsetPropertiesGenerator.php @@ -14,6 +14,8 @@ /** * Generates code necessary to unset all the given properties from a particular given instance string name + * + * @psalm-immutable */ final class UnsetPropertiesGenerator { diff --git a/src/ProxyManager/Signature/Exception/ExceptionInterface.php b/src/ProxyManager/Signature/Exception/ExceptionInterface.php index 21e805832..9055f2944 100644 --- a/src/ProxyManager/Signature/Exception/ExceptionInterface.php +++ b/src/ProxyManager/Signature/Exception/ExceptionInterface.php @@ -6,6 +6,8 @@ /** * Exception marker for exceptions from the signature sub-component + * + * @psalm-immutable */ interface ExceptionInterface { diff --git a/src/ProxyManager/Signature/Exception/InvalidSignatureException.php b/src/ProxyManager/Signature/Exception/InvalidSignatureException.php index 78c197b25..23cd6ec9d 100644 --- a/src/ProxyManager/Signature/Exception/InvalidSignatureException.php +++ b/src/ProxyManager/Signature/Exception/InvalidSignatureException.php @@ -11,6 +11,8 @@ /** * Exception for invalid provided signatures + * + * @psalm-immutable */ class InvalidSignatureException extends UnexpectedValueException implements ExceptionInterface { diff --git a/src/ProxyManager/Signature/Exception/MissingSignatureException.php b/src/ProxyManager/Signature/Exception/MissingSignatureException.php index 514b1b61c..0892940db 100644 --- a/src/ProxyManager/Signature/Exception/MissingSignatureException.php +++ b/src/ProxyManager/Signature/Exception/MissingSignatureException.php @@ -11,6 +11,8 @@ /** * Exception for no found signatures + * + * @psalm-immutable */ class MissingSignatureException extends UnexpectedValueException implements ExceptionInterface { diff --git a/src/ProxyManager/Signature/SignatureChecker.php b/src/ProxyManager/Signature/SignatureChecker.php index 8be7e2685..9c3c8cb4a 100644 --- a/src/ProxyManager/Signature/SignatureChecker.php +++ b/src/ProxyManager/Signature/SignatureChecker.php @@ -12,6 +12,8 @@ /** * Generator for signatures to be used to check the validity of generated code + * + * @psalm-external-mutation-free */ final class SignatureChecker implements SignatureCheckerInterface { diff --git a/src/ProxyManager/Signature/SignatureCheckerInterface.php b/src/ProxyManager/Signature/SignatureCheckerInterface.php index b33142537..d3b6e6e72 100644 --- a/src/ProxyManager/Signature/SignatureCheckerInterface.php +++ b/src/ProxyManager/Signature/SignatureCheckerInterface.php @@ -10,6 +10,8 @@ /** * Generator for signatures to be used to check the validity of generated code + * + * @psalm-immutable */ interface SignatureCheckerInterface { diff --git a/src/ProxyManager/Signature/SignatureGenerator.php b/src/ProxyManager/Signature/SignatureGenerator.php index 1d448a9ef..0cf39de1b 100644 --- a/src/ProxyManager/Signature/SignatureGenerator.php +++ b/src/ProxyManager/Signature/SignatureGenerator.php @@ -9,6 +9,8 @@ /** * {@inheritDoc} + * + * @psalm-immutable */ final class SignatureGenerator implements SignatureGeneratorInterface { diff --git a/src/ProxyManager/Signature/SignatureGeneratorInterface.php b/src/ProxyManager/Signature/SignatureGeneratorInterface.php index 101a345f7..07c28d2d5 100644 --- a/src/ProxyManager/Signature/SignatureGeneratorInterface.php +++ b/src/ProxyManager/Signature/SignatureGeneratorInterface.php @@ -6,6 +6,8 @@ /** * Generator for signatures to be used to check the validity of generated code + * + * @psalm-immutable */ interface SignatureGeneratorInterface { diff --git a/src/ProxyManager/Stub/EmptyClassStub.php b/src/ProxyManager/Stub/EmptyClassStub.php index 28a82f5f1..8e0fe2fff 100644 --- a/src/ProxyManager/Stub/EmptyClassStub.php +++ b/src/ProxyManager/Stub/EmptyClassStub.php @@ -6,6 +6,8 @@ /** * Just an empty instantiable class + * + * @psalm-immutable */ final class EmptyClassStub { diff --git a/src/ProxyManager/Version.php b/src/ProxyManager/Version.php index a6f2c95a8..085cdc6ef 100644 --- a/src/ProxyManager/Version.php +++ b/src/ProxyManager/Version.php @@ -11,6 +11,8 @@ * Version class - to be adjusted when a new release is created. * * Note that we cannot check the version at runtime via `git` because that would cause a lot of I/O operations. + * + * @psalm-immutable */ final class Version {