Skip to content

Commit

Permalink
Merge pull request #502 from Ocramius/feature/immutability-psalm-anno…
Browse files Browse the repository at this point in the history
…tations

Documented basic immutable/mutation-free interfaces and services in the package
  • Loading branch information
Ocramius authored Jan 7, 2020
2 parents 8dd34a6 + bb3a0ba commit 406ca12
Show file tree
Hide file tree
Showing 33 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ProxyManager/Exception/DisabledMethodException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Exception for forcefully disabled methods
*
* @psalm-immutable
*/
class DisabledMethodException extends BadMethodCallException implements ExceptionInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Base exception class for the proxy manager
*
* @psalm-immutable
*/
interface ExceptionInterface extends Throwable
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Exception/FileNotWritableException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Exception for non writable files
*
* @psalm-immutable
*/
class FileNotWritableException extends UnexpectedValueException implements ExceptionInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Exception/InvalidProxiedClassException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/**
* Exception for invalid proxied classes
*
* @psalm-immutable
*/
class InvalidProxiedClassException extends InvalidArgumentException implements ExceptionInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Exception/InvalidProxyDirectoryException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Exception for invalid directories
*
* @psalm-immutable
*/
class InvalidProxyDirectoryException extends InvalidArgumentException implements ExceptionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/**
* Exception for invalid proxied classes
*
* @psalm-immutable
*/
class UnsupportedProxiedClassException extends LogicException implements ExceptionInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/FileLocator/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* {@inheritDoc}
*
* @psalm-immutable
*/
class FileLocator implements FileLocatorInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Generator/ClassGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Generator/MagicMethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Method generator for magic methods
*
* @psalm-external-mutation-free
*/
class MagicMethodGenerator extends MethodGenerator
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Generator/MethodGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Method generator that fixes minor quirks in ZF2's method generator
*
* @psalm-external-mutation-free
*/
class MethodGenerator extends ZendMethodGenerator
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Generator/Util/IdentifierSuffixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Generator/Util/UniqueIdentifierGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
/**
* Utility class capable of generating unique
* valid class/property/method identifiers
*
* @psalm-immutable
*/
abstract class UniqueIdentifierGenerator
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Inflector/ClassNameInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/**
* {@inheritDoc}
*
* @psalm-immutable
*/
final class ClassNameInflector implements ClassNameInflectorInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Inflector/ClassNameInflectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/**
* Interface for a proxy- to user-class and user- to proxy-class name inflector
*
* @psalm-immutable
*/
interface ClassNameInflectorInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Inflector/Util/ParameterEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Encodes parameters into a class-name safe string
*
* @psalm-immutable
*/
class ParameterEncoder
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Inflector/Util/ParameterHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Converts given parameters into a likely unique hash
*
* @psalm-immutable
*/
class ParameterHasher
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Proxy/Exception/RemoteObjectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

/**
* Assertion that verifies that a class can be proxied
*
* @psalm-immutable
*/
final class CanProxyAssertion
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/ProxyGenerator/Util/GetMethodIfExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* Internal utility class - allows fetching a method from a given class, if it exists
*
* @psalm-immutable
*/
final class GetMethodIfExists
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/ProxyGenerator/Util/Properties.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/ProxyGenerator/Util/ProxiedMethodsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

/**
* Utility class used to filter methods that can be proxied
*
* @psalm-immutable
*/
final class ProxiedMethodsFilter
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/ProxyGenerator/Util/PublicScopeSimulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Signature/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* Exception marker for exceptions from the signature sub-component
*
* @psalm-immutable
*/
interface ExceptionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* Exception for invalid provided signatures
*
* @psalm-immutable
*/
class InvalidSignatureException extends UnexpectedValueException implements ExceptionInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

/**
* Exception for no found signatures
*
* @psalm-immutable
*/
class MissingSignatureException extends UnexpectedValueException implements ExceptionInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Signature/SignatureChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Signature/SignatureCheckerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

/**
* Generator for signatures to be used to check the validity of generated code
*
* @psalm-immutable
*/
interface SignatureCheckerInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Signature/SignatureGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* {@inheritDoc}
*
* @psalm-immutable
*/
final class SignatureGenerator implements SignatureGeneratorInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Signature/SignatureGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* Generator for signatures to be used to check the validity of generated code
*
* @psalm-immutable
*/
interface SignatureGeneratorInterface
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Stub/EmptyClassStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

/**
* Just an empty instantiable class
*
* @psalm-immutable
*/
final class EmptyClassStub
{
Expand Down
2 changes: 2 additions & 0 deletions src/ProxyManager/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* Version class
*
* 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
{
Expand Down

0 comments on commit 406ca12

Please sign in to comment.