-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generics for the event subscriber configuration arrays and adapters
- Loading branch information
Showing
19 changed files
with
66 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,11 @@ | |
/** | ||
* The AbstractTrackingListener provides generic functions for all listeners. | ||
* | ||
* @phpstan-template TConfig of array | ||
* @phpstan-template TEventAdapter of AdapterInterface | ||
* | ||
* @phpstan-extends MappedEventSubscriber<TConfig, TEventAdapter> | ||
* | ||
* @author Gediminas Morkevicius <[email protected]> | ||
*/ | ||
abstract class AbstractTrackingListener extends MappedEventSubscriber | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,12 +11,15 @@ | |
|
||
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use Gedmo\AbstractTrackingListener; | ||
use Gedmo\Blameable\Mapping\Event\BlameableAdapter; | ||
use Gedmo\Exception\InvalidArgumentException; | ||
|
||
/** | ||
* The Blameable listener handles the update of | ||
* dates on creation and update. | ||
* | ||
* @phpstan-extends AbstractTrackingListener<array, BlameableAdapter> | ||
* | ||
* @author Gediminas Morkevicius <[email protected]> | ||
* | ||
* @final since gedmo/doctrine-extensions 3.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,15 @@ | |
use Doctrine\Persistence\Mapping\ClassMetadata; | ||
use Gedmo\AbstractTrackingListener; | ||
use Gedmo\Exception\InvalidArgumentException; | ||
use Gedmo\IpTraceable\Mapping\Event\IpTraceableAdapter; | ||
use Gedmo\Mapping\Event\AdapterInterface; | ||
|
||
/** | ||
* The IpTraceable listener handles the update of | ||
* IPs on creation and update. | ||
* | ||
* @phpstan-extends AbstractTrackingListener<array, IpTraceableAdapter> | ||
* | ||
* @author Pierre-Charles Bertineau <[email protected]> | ||
* | ||
* @final since gedmo/doctrine-extensions 3.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,6 @@ | |
use Gedmo\Mapping\Driver\AttributeReader; | ||
use Gedmo\Mapping\Event\AdapterInterface; | ||
use Gedmo\Mapping\Event\ClockAwareAdapterInterface; | ||
use Gedmo\ReferenceIntegrity\Mapping\Validator as ReferenceIntegrityValidator; | ||
use Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorInterface; | ||
use Gedmo\Uploadable\Mapping\Validator as MappingValidator; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
use Psr\Clock\ClockInterface; | ||
use Symfony\Component\Cache\Adapter\ArrayAdapter; | ||
|
@@ -43,6 +40,9 @@ | |
* all extensions who maps additional metadata through | ||
* extended drivers | ||
* | ||
* @phpstan-template TConfig of array | ||
* @phpstan-template TEventAdapter of AdapterInterface | ||
* | ||
* @author Gediminas Morkevicius <[email protected]> | ||
*/ | ||
abstract class MappedEventSubscriber implements EventSubscriber | ||
|
@@ -115,24 +115,7 @@ public function __construct() | |
* | ||
* @return array<string, mixed> | ||
* | ||
* @phpstan-return array{ | ||
* useObjectClass?: class-string, | ||
* referenceIntegrity?: array<string, array<string, value-of<ReferenceIntegrityValidator::INTEGRITY_ACTIONS>>>, | ||
* filePathField?: string, | ||
* uploadable?: bool, | ||
* fileNameField?: string, | ||
* allowOverwrite?: bool, | ||
* appendNumber?: bool, | ||
* maxSize?: float, | ||
* path?: string, | ||
* pathMethod?: string, | ||
* allowedTypes?: string[], | ||
* disallowedTypes?: string[], | ||
* filenameGenerator?: MappingValidator::FILENAME_GENERATOR_*|class-string<FilenameGeneratorInterface>, | ||
* fileMimeTypeField?: string, | ||
* fileSizeField?: string, | ||
* callback?: string, | ||
* } | ||
* @phpstan-return TConfig | ||
*/ | ||
public function getConfiguration(ObjectManager $objectManager, $class) | ||
{ | ||
|
@@ -273,6 +256,8 @@ public function loadMetadataForObjectClass(ObjectManager $objectManager, $metada | |
* @throws InvalidArgumentException if event is not recognized | ||
* | ||
* @return AdapterInterface | ||
* | ||
* @phpstan-return TEventAdapter | ||
*/ | ||
protected function getEventAdapter(EventArgs $args) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,15 @@ | |
use Doctrine\Persistence\ObjectManager; | ||
use Gedmo\Exception\InvalidMappingException; | ||
use Gedmo\Exception\ReferenceIntegrityStrictException; | ||
use Gedmo\Mapping\Event\AdapterInterface; | ||
use Gedmo\Mapping\MappedEventSubscriber; | ||
use Gedmo\ReferenceIntegrity\Mapping\Validator; | ||
|
||
/** | ||
* The ReferenceIntegrity listener handles the reference integrity on related documents | ||
* | ||
* @phpstan-extends MappedEventSubscriber<array, AdapterInterface> | ||
* | ||
* @author Evert Harmeling <[email protected]> | ||
* | ||
* @final since gedmo/doctrine-extensions 3.11 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,10 +23,13 @@ | |
use Gedmo\Mapping\MappedEventSubscriber; | ||
use Gedmo\SoftDeleteable\Event\PostSoftDeleteEventArgs; | ||
use Gedmo\SoftDeleteable\Event\PreSoftDeleteEventArgs; | ||
use Gedmo\SoftDeleteable\Mapping\Event\SoftDeleteableAdapter; | ||
|
||
/** | ||
* SoftDeleteable listener | ||
* | ||
* @phpstan-extends MappedEventSubscriber<array, SoftDeleteableAdapter> | ||
* | ||
* @author Gustavo Falco <[email protected]> | ||
* @author Gediminas Morkevicius <[email protected]> | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,8 @@ | |
* | ||
* @author Gediminas Morkevicius <[email protected]> | ||
* | ||
* @phpstan-extends AbstractTrackingListener<array, TimestampableAdapter> | ||
* | ||
* @final since gedmo/doctrine-extensions 3.11 | ||
*/ | ||
class TimestampableListener extends AbstractTrackingListener | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ | |
use Gedmo\Uploadable\Event\UploadablePreFileProcessEventArgs; | ||
use Gedmo\Uploadable\FileInfo\FileInfoArray; | ||
use Gedmo\Uploadable\FileInfo\FileInfoInterface; | ||
use Gedmo\Uploadable\FilenameGenerator\FilenameGeneratorInterface; | ||
use Gedmo\Uploadable\Mapping\Validator; | ||
use Gedmo\Uploadable\MimeType\MimeTypeGuesser; | ||
use Gedmo\Uploadable\MimeType\MimeTypeGuesserInterface; | ||
|
@@ -46,6 +47,25 @@ | |
* | ||
* @author Gustavo Falco <[email protected]> | ||
* @author Gediminas Morkevicius <[email protected]> | ||
* | ||
* @phpstan-type UploadableConfiguration = array{ | ||
* filePathField?: string, | ||
* uploadable?: bool, | ||
* fileNameField?: string, | ||
* allowOverwrite?: bool, | ||
* appendNumber?: bool, | ||
* maxSize?: float, | ||
* path?: string, | ||
* pathMethod?: string, | ||
* allowedTypes?: string[], | ||
* disallowedTypes?: string[], | ||
* filenameGenerator?: Validator::FILENAME_GENERATOR_*|class-string<FilenameGeneratorInterface>, | ||
* fileMimeTypeField?: string, | ||
* fileSizeField?: string, | ||
* callback?: string, | ||
* } | ||
* | ||
* @phpstan-extends MappedEventSubscriber<UploadableConfiguration, AdapterInterface> | ||
*/ | ||
class UploadableListener extends MappedEventSubscriber | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters