diff --git a/README.md b/README.md index 7d4f12e..3ee277f 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,240 @@ ``` composer require wearerequired/common-php ``` + +## Example + +```php +/** + * Bootstraps post type integrations. + */ +function bootstrap(): void { + add_action( 'init', __NAMESPACE__ . '\register_post_types' ); + add_action( 'init', __NAMESPACE__ . '\register_post_meta' ); + add_action( 'init', __NAMESPACE__ . '\register_taxonomies' ); + add_action( 'init', __NAMESPACE__ . '\register_taxonomy_for_object_types', 11 ); +} + +/** + * Registers custom post types. + */ +function register_post_types() { + $post_types = new Container(); + + $post_types->add( Profession::NAME, new Profession() ); + $post_types->add( School::NAME, new School() ); + $post_types->add( Office::NAME, new Office() ); + $post_types->add( Event::NAME, new Event() ); + $post_types->add( Apprenticeship::NAME, new Apprenticeship() ); + $post_types->add( TrialApprenticeship::NAME, new TrialApprenticeship() ); + $post_types->add( Organization::NAME, new Organization() ); + + $post_types->bootstrap(); +} + +/** + * Registers post meta. + */ +function register_post_meta() { + $post_meta = new Container(); + + $post_meta->add( PostMeta\ImportID::KEY, new PostMeta\ImportID() ); + $post_meta->add( PostMeta\ImportTimestamp::KEY, new PostMeta\ImportTimestamp() ); + + $post_meta->add( PostMeta\SchoolOfficeID::KEY, new PostMeta\SchoolOfficeID() ); + $post_meta->add( PostMeta\SchoolTelNumber::KEY, new PostMeta\SchoolTelNumber() ); + $post_meta->add( PostMeta\SchoolEmail::KEY, new PostMeta\SchoolEmail() ); + + $post_meta->add( PostMeta\OfficeStreet::KEY, new PostMeta\OfficeStreet() ); + $post_meta->add( PostMeta\OfficePOBox::KEY, new PostMeta\OfficePOBox() ); + $post_meta->add( PostMeta\OfficeEmail::KEY, new PostMeta\OfficeEmail() ); + $post_meta->add( PostMeta\OfficeTelNumber::KEY, new PostMeta\OfficeTelNumber() ); + $post_meta->add( PostMeta\OfficeFax::KEY, new PostMeta\OfficeFax() ); + $post_meta->add( PostMeta\OfficeContactURL::KEY, new PostMeta\OfficeContactURL() ); + $post_meta->add( PostMeta\OfficeOpeningHours::KEY, new PostMeta\OfficeOpeningHours() ); + $post_meta->add( PostMeta\OfficeSendCopyToConsultant::KEY, new PostMeta\OfficeSendCopyToConsultant() ); + + $post_meta->add( PostMeta\EventAdditionalInfo::KEY, new PostMeta\EventAdditionalInfo() ); + $post_meta->add( PostMeta\EventAddress::KEY, new PostMeta\EventAddress() ); + $post_meta->add( PostMeta\EventAuthor::KEY, new PostMeta\EventAuthor() ); + $post_meta->add( PostMeta\EventCity::KEY, new PostMeta\EventCity() ); + $post_meta->add( PostMeta\EventCode::KEY, new PostMeta\EventCode() ); + $post_meta->add( PostMeta\EventCreator::KEY, new PostMeta\EventCreator() ); + $post_meta->add( PostMeta\EventDepartment::KEY, new PostMeta\EventDepartment() ); + $post_meta->add( PostMeta\EventFeeInfoNoFees::KEY, new PostMeta\EventFeeInfoNoFees() ); + $post_meta->add( PostMeta\EventFeeInfoFee::KEY, new PostMeta\EventFeeInfoFee() ); + $post_meta->add( PostMeta\EventFeeInfoCurrency::KEY, new PostMeta\EventFeeInfoCurrency() ); + $post_meta->add( PostMeta\EventFeeInfoDescription::KEY, new PostMeta\EventFeeInfoDescription() ); + $post_meta->add( PostMeta\EventGuideDescr::KEY, new PostMeta\EventGuideDescr() ); + $post_meta->add( PostMeta\EventGuideFirstname::KEY, new PostMeta\EventGuideFirstname() ); + $post_meta->add( PostMeta\EventGuideLastname::KEY, new PostMeta\EventGuideLastname() ); + $post_meta->add( PostMeta\EventHostCity::KEY, new PostMeta\EventHostCity() ); + $post_meta->add( PostMeta\EventHostLastname::KEY, new PostMeta\EventHostLastname() ); + $post_meta->add( PostMeta\EventHostRegion::KEY, new PostMeta\EventHostRegion() ); + $post_meta->add( PostMeta\EventHostType::KEY, new PostMeta\EventHostType() ); + $post_meta->add( PostMeta\EventHostZip::KEY, new PostMeta\EventHostZip() ); + $post_meta->add( PostMeta\EventHostPhone::KEY, new PostMeta\EventHostPhone() ); + $post_meta->add( PostMeta\EventHostMail::KEY, new PostMeta\EventHostMail() ); + $post_meta->add( PostMeta\EventHostWebsite::KEY, new PostMeta\EventHostWebsite() ); + $post_meta->add( PostMeta\EventLocation::KEY, new PostMeta\EventLocation() ); + $post_meta->add( PostMeta\EventOrgDepartment::KEY, new PostMeta\EventOrgDepartment() ); + $post_meta->add( PostMeta\EventRegion::KEY, new PostMeta\EventRegion() ); + $post_meta->add( PostMeta\EventRegistrationLink::KEY, new PostMeta\EventRegistrationLink() ); + $post_meta->add( PostMeta\EventRegistrationMail::KEY, new PostMeta\EventRegistrationMail() ); + $post_meta->add( PostMeta\EventRegistrationName::KEY, new PostMeta\EventRegistrationName() ); + $post_meta->add( PostMeta\EventHasRegistration::KEY, new PostMeta\EventHasRegistration() ); + $post_meta->add( PostMeta\EventRegistrationPhone::KEY, new PostMeta\EventRegistrationPhone() ); + $post_meta->add( PostMeta\EventSeatsMax::KEY, new PostMeta\EventSeatsMax() ); + $post_meta->add( PostMeta\EventSeatsMin::KEY, new PostMeta\EventSeatsMin() ); + $post_meta->add( PostMeta\EventSeatsAvailable::KEY, new PostMeta\EventSeatsAvailable() ); + $post_meta->add( PostMeta\EventSpeakers::KEY, new PostMeta\EventSpeakers() ); + $post_meta->add( PostMeta\EventUnid::KEY, new PostMeta\EventUnid() ); + $post_meta->add( PostMeta\EventZip::KEY, new PostMeta\EventZip() ); + $post_meta->add( PostMeta\EventDateStart::KEY, new PostMeta\EventDateStart() ); + $post_meta->add( PostMeta\EventDateEnd::KEY, new PostMeta\EventDateEnd() ); + $post_meta->add( PostMeta\EventDates::KEY, new PostMeta\EventDates() ); + $post_meta->add( PostMeta\EventIsOnline::KEY, new PostMeta\EventIsOnline() ); + $post_meta->add( PostMeta\EventTargetAudience::KEY, new PostMeta\EventTargetAudience() ); + $post_meta->add( PostMeta\EventSwissdocIDs::KEY, new PostMeta\EventSwissdocIDs() ); + + $post_meta->add( PostMeta\SwissdocNumber::KEY, new PostMeta\SwissdocNumber() ); + + $post_meta->add( PostMeta\Zip::KEY, new PostMeta\Zip() ); + $post_meta->add( PostMeta\City::KEY, new PostMeta\City() ); + $post_meta->add( PostMeta\Lat::KEY, new PostMeta\Lat() ); + $post_meta->add( PostMeta\Lng::KEY, new PostMeta\Lng() ); + + $post_meta->add( PostMeta\ProfessionSNI::KEY, new PostMeta\ProfessionSNI() ); + $post_meta->add( PostMeta\ProfessionCompletedApprenticeshipContracts::KEY, new PostMeta\ProfessionCompletedApprenticeshipContracts() ); + $post_meta->add( PostMeta\ProfessionVideoURLs::KEY, new PostMeta\ProfessionVideoURLs() ); + $post_meta->add( PostMeta\ProfessionPodcastURLs::KEY, new PostMeta\ProfessionPodcastURLs() ); + $post_meta->add( PostMeta\ProfessionSkipImport::KEY, new PostMeta\ProfessionSkipImport() ); + $post_meta->add( PostMeta\ProfessionSchoolRequirementsURL::KEY, new PostMeta\ProfessionSchoolRequirementsURL() ); + $post_meta->add( PostMeta\ProfessionHint::KEY, new PostMeta\ProfessionHint() ); + $post_meta->add( PostMeta\ProfessionForeignLanguage::KEY, new PostMeta\ProfessionForeignLanguage() ); + + $post_meta->add( PostMeta\OrganizationLogoURL::KEY, new PostMeta\OrganizationLogoURL() ); + + $post_meta->bootstrap(); +} + +/** + * Registers custom taxonomies. + */ +function register_taxonomies(): void { + $taxonomies = new Container(); + + $taxonomies->add( ProfessionField::NAME, new ProfessionField() ); + $taxonomies->add( ProfessionInterest::NAME, new ProfessionInterest() ); + $taxonomies->add( ProfessionSector::NAME, new ProfessionSector() ); + $taxonomies->add( ProfessionAlternativeTitle::NAME, new ProfessionAlternativeTitle() ); + $taxonomies->add( ProfessionDuration::NAME, new ProfessionDuration() ); + $taxonomies->add( ProfessionQualification::NAME, new ProfessionQualification() ); + $taxonomies->add( ProfessionBilingualEducation::NAME, new ProfessionBilingualEducation() ); + $taxonomies->add( EventSpeaker::NAME, new EventSpeaker() ); + $taxonomies->add( EventAudience::NAME, new EventAudience() ); + $taxonomies->add( EventTopic::NAME, new EventTopic() ); + $taxonomies->add( EventStatus::NAME, new EventStatus() ); + $taxonomies->add( Swissdoc::NAME, new Swissdoc() ); + $taxonomies->add( ApprenticeshipOrganization::NAME, new ApprenticeshipOrganization() ); + $taxonomies->add( UserNationality::NAME, new UserNationality() ); + $taxonomies->add( UserLanguage::NAME, new UserLanguage() ); + $taxonomies->add( ApprenticeshipYear::NAME, new ApprenticeshipYear() ); + $taxonomies->add( LinkDistrictOrganizationApprenticeship::NAME, new LinkDistrictOrganizationApprenticeship() ); + $taxonomies->add( LinkDistrictOrganizationTrialApprenticeship::NAME, new LinkDistrictOrganizationTrialApprenticeship() ); + $taxonomies->add( LinkSwissdocOrganizationApprenticeship::NAME, new LinkSwissdocOrganizationApprenticeship() ); + $taxonomies->add( LinkSwissdocOrganizationTrialApprenticeship::NAME, new LinkSwissdocOrganizationTrialApprenticeship() ); + $taxonomies->add( OrganizationEmail::NAME, new OrganizationEmail() ); + + $district = new District(); + $taxonomies->add( District::NAME, $district ); + + $meta_position = new TermMeta\Position(); + $meta_position->register(); + add_action( + 'admin_init', + static function () use ( $district, $meta_position ): void { + $meta_position_ui = new Admin\PositionTermUI( + $district, + $meta_position + ); + $meta_position_ui->register(); + } + ); + + $meta_zip = new TermMeta\Zip(); + $meta_zip->register(); + add_action( + 'admin_init', + static function () use ( $district, $meta_zip ): void { + $meta_zip_ui = new Admin\ZipTermUI( + $district, + $meta_zip + ); + $meta_zip_ui->register(); + } + ); + + $meta_city = new TermMeta\City(); + $meta_city->register(); + add_action( + 'admin_init', + static function () use ( $district, $meta_city ): void { + $meta_city_ui = new Admin\CityTermUI( + $district, + $meta_city + ); + $meta_city_ui->register(); + } + ); + + $taxonomies->bootstrap(); +} + +/** + * Registers taxonomies for object types. + */ +function register_taxonomy_for_object_types(): void { + register_taxonomy_for_object_type( ProfessionField::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionField::NAME, PostType\Event::NAME ); + + register_taxonomy_for_object_type( ProfessionInterest::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionSector::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionAlternativeTitle::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionDuration::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionQualification::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( ProfessionBilingualEducation::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( EventSpeaker::NAME, PostType\Event::NAME ); + register_taxonomy_for_object_type( EventAudience::NAME, PostType\Event::NAME ); + register_taxonomy_for_object_type( EventTopic::NAME, PostType\Event::NAME ); + register_taxonomy_for_object_type( EventStatus::NAME, PostType\Event::NAME ); + + register_taxonomy_for_object_type( District::NAME, PostType\School::NAME ); + register_taxonomy_for_object_type( District::NAME, PostType\Office::NAME ); + register_taxonomy_for_object_type( District::NAME, PostType\Apprenticeship::NAME ); + register_taxonomy_for_object_type( District::NAME, PostType\TrialApprenticeship::NAME ); + register_taxonomy_for_object_type( District::NAME, PostType\Event::NAME ); + register_taxonomy_for_object_type( District::NAME, PostType\Organization::NAME ); + + register_taxonomy_for_object_type( Swissdoc::NAME, PostType\Profession::NAME ); + register_taxonomy_for_object_type( Swissdoc::NAME, PostType\Apprenticeship::NAME ); + register_taxonomy_for_object_type( Swissdoc::NAME, PostType\TrialApprenticeship::NAME ); + + register_taxonomy_for_object_type( ApprenticeshipOrganization::NAME, PostType\Apprenticeship::NAME ); + register_taxonomy_for_object_type( ApprenticeshipOrganization::NAME, PostType\TrialApprenticeship::NAME ); + register_taxonomy_for_object_type( ApprenticeshipOrganization::NAME, PostType\Organization::NAME ); + register_taxonomy_for_object_type( ApprenticeshipOrganization::NAME, PostType\Event::NAME ); + + register_taxonomy_for_object_type( LinkDistrictOrganizationApprenticeship::NAME, PostType\Organization::NAME ); + register_taxonomy_for_object_type( LinkDistrictOrganizationTrialApprenticeship::NAME, PostType\Organization::NAME ); + register_taxonomy_for_object_type( LinkSwissdocOrganizationApprenticeship::NAME, PostType\Organization::NAME ); + register_taxonomy_for_object_type( LinkSwissdocOrganizationTrialApprenticeship::NAME, PostType\Organization::NAME ); + + register_taxonomy_for_object_type( OrganizationEmail::NAME, PostType\Organization::NAME ); + + register_taxonomy_for_object_type( ApprenticeshipYear::NAME, PostType\Apprenticeship::NAME ); + + register_taxonomy_for_object_type( UserNationality::NAME, 'user' ); + register_taxonomy_for_object_type( UserLanguage::NAME, 'user' ); +} +``` diff --git a/composer.json b/composer.json index 41a716e..6d4e165 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,6 @@ } }, "scripts": { - "analyze": "vendor/bin/phpstan analyze --no-progress" + "analyze": "vendor/bin/phpstan analyze --no-progress --memory-limit 1G" } } diff --git a/inc/Admin/AjaxAction.php b/inc/Admin/AjaxAction.php index d5671e4..5ae0b51 100644 --- a/inc/Admin/AjaxAction.php +++ b/inc/Admin/AjaxAction.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common\Admin; use Required\Common\Contracts\Registrable; @@ -16,7 +18,7 @@ */ abstract class AjaxAction implements Registrable { - public const ACTION = 'ajax-action'; + public const string ACTION = 'ajax-action'; /** * Whether the Ajax action can be called unauthenticated. @@ -32,7 +34,7 @@ abstract class AjaxAction implements Registrable { * * @param bool $allow Whether the Ajax action can be called unauthenticated. */ - public function allow_unauthenticated( bool $allow ) { + public function allow_unauthenticated( bool $allow ): void { $this->allow_unauthenticated = $allow; } @@ -41,7 +43,7 @@ public function allow_unauthenticated( bool $allow ) { * * @since 0.1.0 */ - abstract public function callback(); + abstract public function callback(): void; /** * Registers the action. diff --git a/inc/Admin/Page.php b/inc/Admin/Page.php index a4ebb22..21756a6 100644 --- a/inc/Admin/Page.php +++ b/inc/Admin/Page.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common\Admin; use Required\Common\Contracts\Registrable; @@ -22,10 +24,8 @@ class Page implements Registrable { * @since 0.1.0 * * @see is_admin() - * - * @var int */ - public const ADMIN = 1; + public const int ADMIN = 1; /** * Type of admin page. @@ -33,10 +33,8 @@ class Page implements Registrable { * @since 0.1.0 * * @see is_network_admin() - * - * @var int */ - public const ADMIN_NETWORK = 2; + public const int ADMIN_NETWORK = 2; /** * Type of admin page. @@ -44,10 +42,8 @@ class Page implements Registrable { * @since 0.1.0 * * @see is_user_admin() - * - * @var int */ - public const ADMIN_USER = 3; + public const int ADMIN_USER = 3; /** * Type of admin screen. @@ -56,7 +52,7 @@ class Page implements Registrable { * * @var int */ - private $admin; + private int $admin; /** * The text to be displayed in the title tags of the page when the menu is selected. @@ -65,7 +61,7 @@ class Page implements Registrable { * * @var string */ - private $title; + private string $title; /** * The text to be used for the menu. @@ -74,7 +70,7 @@ class Page implements Registrable { * * @var string */ - private $menu_title; + private string $menu_title; /** * The capability required for this menu to be displayed to the user. @@ -83,7 +79,7 @@ class Page implements Registrable { * * @var string */ - private $capability; + private string $capability; /** * The slug name to refer to this menu by (should be unique for this menu). @@ -92,7 +88,7 @@ class Page implements Registrable { * * @var string */ - private $menu_slug; + private string $menu_slug; /** * The view to render the admin page. @@ -101,7 +97,7 @@ class Page implements Registrable { * * @var \Required\Common\Admin\PageView */ - private $view; + private PageView $view; /** * The slug name for the parent menu (or the file name of a standard WordPress admin page). @@ -110,7 +106,7 @@ class Page implements Registrable { * * @var string */ - private $parent_slug; + private string $parent_slug; /** * The icon to be used for the menu. @@ -119,7 +115,7 @@ class Page implements Registrable { * * @var string */ - private $icon; + private string $icon; /** * The position in the menu order this one should appear. @@ -128,25 +124,25 @@ class Page implements Registrable { * * @var null|int */ - private $position; + private ?int $position; /** * The page's hook_suffix. * * @since 0.1.0 * - * @var string + * @var string|false */ - private $hook_name; + private string|false $hook_name = false; /** * Callback to be called when page is loaded. * * @since 0.1.0 * - * @var string + * @var callable|null */ - private $on_load_callback; + private $on_load_callback = null; /** * Constructor. @@ -163,7 +159,7 @@ class Page implements Registrable { * @param string $icon Optional. The icon to be used for the menu. * @param null|int $position Optional. The position in the menu order this one should appear. */ - public function __construct( int $admin, string $title, string $menu_title, string $capability, string $menu_slug, PageView $view, string $parent_slug = '', string $icon = '', $position = null ) { + public function __construct( int $admin, string $title, string $menu_title, string $capability, string $menu_slug, PageView $view, string $parent_slug = '', string $icon = '', ?int $position = null ) { $this->admin = $admin; $this->title = $title; $this->menu_title = $menu_title; @@ -179,10 +175,8 @@ public function __construct( int $admin, string $title, string $menu_title, stri * Returns the action for registering the page. * * @since 0.1.0 - * - * @return string */ - private function get_action() { + private function get_action(): string { switch ( $this->admin ) { case static::ADMIN: return 'admin_menu'; @@ -203,11 +197,11 @@ private function get_action() { * * @since 0.1.0 * - * @return callable Callback for adding the page to the admin menu. + * @return \Closure Callback for adding the page to the admin menu. */ - private function get_callback() { + private function get_callback(): \Closure { if ( $this->parent_slug ) { - return function() { + return function (): void { $this->hook_name = add_submenu_page( $this->parent_slug, $this->title, @@ -217,7 +211,7 @@ private function get_callback() { [ $this->view, 'render' ] ); - if ( $this->hook_name && is_callable( $this->on_load_callback ) ) { + if ( $this->hook_name && \is_callable( $this->on_load_callback ) ) { add_action( "load-{$this->hook_name}", $this->on_load_callback @@ -225,7 +219,7 @@ private function get_callback() { } }; } else { - return function() { + return function (): void { $this->hook_name = add_menu_page( $this->title, $this->menu_title, @@ -236,7 +230,7 @@ private function get_callback() { $this->position ); - if ( $this->hook_name && is_callable( $this->on_load_callback ) ) { + if ( $this->hook_name && \is_callable( $this->on_load_callback ) ) { add_action( "load-{$this->hook_name}", $this->on_load_callback @@ -251,9 +245,9 @@ private function get_callback() { * * @since 0.1.0 * - * @return string The hook name of the menu page. + * @return string|false The hook name of the menu page. */ - public function get_hook_name() { + public function get_hook_name(): string|false { return $this->hook_name; } @@ -264,7 +258,7 @@ public function get_hook_name() { * * @return \Required\Common\Admin\PageView The view of the page. */ - public function get_view() { + public function get_view(): PageView { return $this->view; } @@ -275,7 +269,7 @@ public function get_view() { * * @param callable $callback Callback called when page is loaded. */ - public function on_load( callable $callback ) { + public function on_load( callable $callback ): void { $this->on_load_callback = $callback; } diff --git a/inc/Admin/PageView.php b/inc/Admin/PageView.php index 2923d8f..99323e5 100644 --- a/inc/Admin/PageView.php +++ b/inc/Admin/PageView.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common\Admin; /** @@ -19,5 +21,5 @@ interface PageView { * * @since 0.1.0 */ - public function render(); + public function render(): void; } diff --git a/inc/Admin/PostAction.php b/inc/Admin/PostAction.php index 15b5c42..0b4c166 100644 --- a/inc/Admin/PostAction.php +++ b/inc/Admin/PostAction.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common\Admin; use Required\Common\Contracts\Registrable; @@ -16,14 +18,14 @@ */ abstract class PostAction implements Registrable { - public const ACTION = 'post-action'; + public const string ACTION = 'post-action'; /** * The callback of the action. * * @since 0.1.0 */ - abstract public function callback(); + abstract public function callback(): void; /** * Registers the action. @@ -43,7 +45,7 @@ public function register(): bool { * * @return string URL to admin-post.php. */ - public static function url() { + public static function url(): string { return admin_url( 'admin-post.php?action=' . static::ACTION ); } } diff --git a/inc/Container.php b/inc/Container.php index 6936e5e..a3761e5 100644 --- a/inc/Container.php +++ b/inc/Container.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common; use Required\Common\Contracts\Registrable; @@ -22,9 +24,9 @@ class Container { * * @since 0.1.0 * - * @var \Required\Common\Contracts\Registrable[] + * @var array */ - private $values = []; + private array $values = []; /** * Whether this container is $bootstrapped. @@ -33,18 +35,18 @@ class Container { * * @var bool */ - private $bootstrapped = false; + private bool $bootstrapped = false; /** * Adds a new registrable object to the container. * * @since 0.1.0 * - * @param string $name Name of the registrable object. - * @param \Required\Common\Contracts\Registrable $callable Registrable object. + * @param string $name Name of the registrable object. + * @param \Required\Common\Contracts\Registrable $registrable Registrable object. */ - public function add( $name, Registrable $callable ) { - $this->values[ $name ] = $callable; + public function add( string $name, Registrable $registrable ): void { + $this->values[ $name ] = $registrable; } /** diff --git a/inc/Contracts/PostType.php b/inc/Contracts/PostType.php index 0875984..e3c53c1 100644 --- a/inc/Contracts/PostType.php +++ b/inc/Contracts/PostType.php @@ -13,4 +13,10 @@ * @since 0.3.2 */ interface PostType { + /** + * Post type name. + * + * Implementations are expected to override this. + */ + public const string NAME = ''; } diff --git a/inc/Contracts/Registrable.php b/inc/Contracts/Registrable.php index 9366a4b..0a8709d 100644 --- a/inc/Contracts/Registrable.php +++ b/inc/Contracts/Registrable.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common\Contracts; /** diff --git a/inc/Contracts/ShortcodeView.php b/inc/Contracts/ShortcodeView.php deleted file mode 100644 index c7c2e02..0000000 --- a/inc/Contracts/ShortcodeView.php +++ /dev/null @@ -1,28 +0,0 @@ -post_type(), - static::KEY, - $this->get_args() - ); - } - - /** - * Gets post meta arguments for this post meta object. - * - * @since 0.1.0 - * - * @see register_meta() For the supported arguments. - * - * @return array Post meta arguments. - */ - protected function get_args(): array { - return [ - 'type' => $this->type(), - 'description' => $this->description(), - 'single' => $this->is_single(), - 'default' => $this->default(), - 'sanitize_callback' => [ $this, 'sanitize' ], - 'auth_callback' => [ $this, 'auth' ], - 'show_in_rest' => $this->show_in_rest(), - ]; - } - - /** - * The post type to register a meta key for. - * - * Pass an empty string to register the meta key across all existing post types. - * - * @since 0.1.0 - * - * @return string Post type to register a meta key for. - */ - protected function post_type(): string { - return ''; - } - - /** - * The type of data associated with this meta key. - * - * Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'. - * - * @since 0.1.0 - * - * @return string Type of the data. - */ - protected function type(): string { - return 'string'; - } - - /** - * A description of the data attached to this meta key. - * - * @since 0.1.0 - * - * @return string Description of the data. - */ - protected function description(): string { - return ''; - } - - /** - * Whether the meta key has one value per object, or an array of values per object. - * - * @since 0.1.0 - * - * @return bool Whether the meta key has one value per object. - */ - protected function is_single(): bool { - return false; - } - - /** - * The default value if no value has been set yet. - * - * @since 0.1.0 - * - * @return mixed The default value. - */ - protected function default() { - return ''; - } - - /** - * Sanitization of the post meta data. - * - * @since 0.1.0 - * - * @param mixed $meta_value Meta value to sanitize. - * @param string $meta_key Meta key. - * @param string $object_type Object type. - * @return mixed Sanitized meta value. - */ - public function sanitize( $meta_value, $meta_key, $object_type ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - return $meta_value; - } - - /** - * Whether the user is allowed to edit meta. - * - * @since 0.1.0 - * - * @param bool $allowed Whether the user can add the post meta. Default false. - * @param string $meta_key The meta key. - * @param int $object_id Object ID. - * @param int $user_id User ID. - * @param string $cap Capability name. - * @param array $caps User capabilities. - * @return bool False if the key is protected, true otherwise. - */ - public function auth( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - return ! is_protected_meta( $meta_key, 'post' ); - } - - /** - * Whether data associated with this meta key can be considered public and - * should be accessible via the REST API. - * - * When registering complex meta values this argument may optionally be an - * array with 'schema' or 'prepare_callback' keys instead of a boolean. - * - * @since 0.1.0 - * - * @return bool|array Whether the data is public. - */ - protected function show_in_rest() { - return false; - } -} diff --git a/inc/Legacy/PostType.php b/inc/Legacy/PostType.php deleted file mode 100644 index 0a13eab..0000000 --- a/inc/Legacy/PostType.php +++ /dev/null @@ -1,51 +0,0 @@ -get_args() - ); - return ! is_wp_error( $post_type ); - } - - return true; - } - - /** - * Gets post type arguments for this post type object. - * - * @since 0.1.0 - * - * @return array Post type arguments. - */ - abstract protected function get_args(): array; -} diff --git a/inc/Legacy/Taxonomy.php b/inc/Legacy/Taxonomy.php deleted file mode 100644 index e5601aa..0000000 --- a/inc/Legacy/Taxonomy.php +++ /dev/null @@ -1,83 +0,0 @@ -get_object_types(), - $this->get_args() - ); - return ! is_wp_error( $taxonomy ); - } - - return true; - } - - /** - * Sets object types the taxonomy is associated with. - * - * @since 0.1.0 - * - * @param array|string $object_type Object type or array of object types with which the taxonomy should be associated. - */ - public function set_object_types( $object_type ) { - $this->object_types = (array) $object_type; - } - - /** - * Gets object types the taxonomy is associated with. - * - * @since 0.1.0 - * - * @return array Object types the taxonomy is associated with. - */ - public function get_object_types() { - return $this->object_types; - } - - /** - * Gets taxonomy arguments for this taxonomy object. - * - * @since 0.1.0 - * - * @return array Taxonomy arguments. - */ - abstract protected function get_args(); -} diff --git a/inc/Legacy/TermMeta.php b/inc/Legacy/TermMeta.php deleted file mode 100644 index d9021e8..0000000 --- a/inc/Legacy/TermMeta.php +++ /dev/null @@ -1,167 +0,0 @@ -taxonomy(), - static::KEY, - $this->get_args() - ); - } - - /** - * Gets term meta arguments for this term meta object. - * - * @since 0.1.0 - * - * @see register_meta() For the supported arguments. - * - * @return array Term meta arguments. - */ - protected function get_args(): array { - return [ - 'type' => $this->type(), - 'description' => $this->description(), - 'single' => $this->is_single(), - 'default' => $this->default(), - 'sanitize_callback' => [ $this, 'sanitize' ], - 'auth_callback' => [ $this, 'auth' ], - 'show_in_rest' => $this->show_in_rest(), - ]; - } - - /** - * The taxonomy to register a meta key for. - * - * Pass an empty string to register the meta key across all existing taxonomies. - * - * @since 0.1.0 - * - * @return string Taxonomy to register a meta key for. - */ - protected function taxonomy(): string { - return ''; - } - - /** - * The type of data associated with this meta key. - * - * Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'. - * - * @since 0.1.0 - * - * @return string Type of the data. - */ - protected function type(): string { - return 'string'; - } - - /** - * A description of the data attached to this meta key. - * - * @since 0.1.0 - * - * @return string Description of the data. - */ - protected function description(): string { - return ''; - } - - /** - * Whether the meta key has one value per object, or an array of values per object. - * - * @since 0.1.0 - * - * @return bool Whether the meta key has one value per object. - */ - protected function is_single(): bool { - return false; - } - - /** - * The default value if no value has been set yet. - * - * @since 0.1.0 - * - * @return mixed The default value. - */ - protected function default() { - return ''; - } - - /** - * Sanitization of the term meta data. - * - * @since 0.1.0 - * - * @param mixed $meta_value Meta value to sanitize. - * @param string $meta_key Meta key. - * @param string $object_type Object type. - * @return mixed Sanitized meta value. - */ - public function sanitize( $meta_value, $meta_key, $object_type ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - return $meta_value; - } - - /** - * Whether the user is allowed to edit meta. - * - * @since 0.1.0 - * - * @param bool $allowed Whether the user can add the term meta. Default false. - * @param string $meta_key The meta key. - * @param int $object_id Object ID. - * @param int $user_id User ID. - * @param string $cap Capability name. - * @param array $caps User capabilities. - * @return bool False if the key is protected, true otherwise. - */ - public function auth( $allowed, $meta_key, $object_id, $user_id, $cap, $caps ): bool { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable - return ! is_protected_meta( $meta_key, 'term' ); - } - - /** - * Whether data associated with this meta key can be considered public and - * should be accessible via the REST API. - * - * When registering complex meta values this argument may optionally be an - * array with 'schema' or 'prepare_callback' keys instead of a boolean. - * - * @since 0.1.0 - * - * @return bool|array Whether the data is public. - */ - protected function show_in_rest() { - return false; - } -} diff --git a/inc/PostMeta.php b/inc/PostMeta.php index 25ae138..bc08451 100644 --- a/inc/PostMeta.php +++ b/inc/PostMeta.php @@ -23,7 +23,7 @@ abstract class PostMeta implements Registrable, PostMetaInterface { /** * Post meta key. */ - public const KEY = null; + public const string KEY = ''; /** * Registers the object. @@ -33,10 +33,30 @@ abstract class PostMeta implements Registrable, PostMetaInterface { * @return bool Whether the post meta was registered successfully. */ public function register(): bool { + if ( static::KEY === '' ) { + return false; + } + + /** + * @phpstan-var array{ + * object_subtype?: string, + * type?: string, + * label?: string, + * description?: string, + * single?: bool, + * default?: mixed, + * sanitize_callback?: callable, + * auth_callback?: callable, + * show_in_rest?: bool|array, + * revisions_enabled?: bool, + * } $args + */ + $args = $this->get_args()->toArray(); + return register_post_meta( $this->post_type(), static::KEY, - $this->get_args()->toArray() + $args ); } @@ -57,7 +77,7 @@ protected function get_args(): PostMetaArgs { $args->single = $this->is_single(); $args->default = $this->default(); $args->sanitize_callback = [ $this, 'sanitize' ]; - $args->auth_callback = [ $this, 'auth' ]; + $args->auth_callback = [ $this, 'auth_callback' ]; $args->show_in_rest = $this->show_in_rest(); return $args; @@ -83,7 +103,7 @@ protected function post_type(): string { * * @since 0.1.0 * - * @return string Type of the data. + * @return 'array'|'boolean'|'integer'|'number'|'object'|'string' Type of the data. */ protected function type(): string { return PostMetaArgs::TYPE_STRING; @@ -118,7 +138,7 @@ protected function is_single(): bool { * * @return mixed The default value. */ - protected function default() { + protected function default(): mixed { return ''; } @@ -132,7 +152,7 @@ protected function default() { * @param string $object_type Object type. * @return mixed Sanitized meta value. */ - public function sanitize( $meta_value, string $meta_key, string $object_type ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + public function sanitize( mixed $meta_value, string $meta_key, string $object_type ): mixed { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return $meta_value; } @@ -153,6 +173,21 @@ public function auth( bool $allowed, string $meta_key, int $object_id, int $user return ! is_protected_meta( $meta_key, 'post' ); } + /** + * Adapter for the narrower `johnbillion/args` auth callback signature. + * + * @since 0.1.0 + * + * @param bool $allowed Whether the user can add the post meta. + * @param string $meta_key The meta key. + * @param string $object_type Object type. + * @param string $object_subtype Object subtype. + * @return bool Whether the user is allowed to edit meta. + */ + public function auth_callback( bool $allowed, string $meta_key, string $object_type, string $object_subtype = '' ): bool { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + return $this->auth( $allowed, $meta_key, 0, 0, '', [] ); + } + /** * Whether data associated with this meta key can be considered public and * should be accessible via the REST API. @@ -163,11 +198,11 @@ public function auth( bool $allowed, string $meta_key, int $object_id, int $user * @since 0.1.0 * * @return bool|array{ - * schema: mixed[], - * prepare_callback: callable(mixed,\WP_REST_Request,mixed[]): mixed, + * schema: array, + * prepare_callback: callable(mixed,\WP_REST_Request>,array): mixed, * } */ - protected function show_in_rest() { + protected function show_in_rest(): array|bool { return false; } } diff --git a/inc/PostType.php b/inc/PostType.php index 1860fb6..e473519 100644 --- a/inc/PostType.php +++ b/inc/PostType.php @@ -20,7 +20,7 @@ */ abstract class PostType implements Registrable, PostTypeInterface { - public const NAME = 'post'; + public const string NAME = 'post'; /** * Creates a post type object. @@ -30,10 +30,57 @@ abstract class PostType implements Registrable, PostTypeInterface { * @return bool Whether the post type was registered successfully. */ public function register(): bool { - if ( ! post_type_exists( static::NAME ) ) { + /** @var lowercase-string&non-empty-string $name */ + $name = static::NAME; + + if ( ! post_type_exists( $name ) ) { + /** + * WordPress stubs currently treat this as an array shape. `johnbillion/args` + * returns a plain `array`, so we assert the expected shape here. + * + * @phpstan-var array{ + * label?: string, + * labels?: string[], + * description?: string, + * public?: bool, + * hierarchical?: bool, + * exclude_from_search?: bool, + * publicly_queryable?: bool, + * show_ui?: bool, + * show_in_menu?: bool|string, + * show_in_nav_menus?: bool, + * show_in_admin_bar?: bool, + * show_in_rest?: bool, + * rest_base?: string, + * rest_namespace?: string, + * rest_controller_class?: string, + * autosave_rest_controller_class?: string|bool, + * revisions_rest_controller_class?: string|bool, + * late_route_registration?: bool, + * menu_position?: int, + * menu_icon?: string, + * capability_type?: string|array, + * capabilities?: string[], + * map_meta_cap?: bool, + * supports?: array|false, + * register_meta_box_cb?: callable, + * taxonomies?: string[], + * has_archive?: bool|string, + * rewrite?: bool|array{slug?: string, with_front?: bool, feeds?: bool, pages?: bool, ep_mask?: int}, + * query_var?: string|bool, + * can_export?: bool, + * delete_with_user?: bool, + * template?: array, + * template_lock?: string|false, + * _builtin?: bool, + * _edit_link?: string, + * } $args + */ + $args = $this->get_args()->toArray(); + $post_type = register_post_type( - static::NAME, - $this->get_args()->toArray() + $name, + $args ); return ! is_wp_error( $post_type ); } diff --git a/inc/Shortcode.php b/inc/Shortcode.php deleted file mode 100644 index bb2a6f8..0000000 --- a/inc/Shortcode.php +++ /dev/null @@ -1,55 +0,0 @@ -view = $view; - } - - /** - * Creates a shortcode object. - * - * @since 0.1.0 - * - * @return bool Whether shortcode was registered successfully. - */ - public function register(): bool { - add_shortcode( - static::TAG, - [ $this->view, 'render' ] - ); - return shortcode_exists( static::TAG ); - } -} diff --git a/inc/Taxonomy.php b/inc/Taxonomy.php index 077ddfe..689b176 100644 --- a/inc/Taxonomy.php +++ b/inc/Taxonomy.php @@ -20,16 +20,10 @@ */ abstract class Taxonomy implements Registrable, TaxonomyInterface { - public const NAME = 'category'; + public const string NAME = 'category'; - /** - * Object types the taxonomy is associated with. - * - * @since 0.1.0 - * - * @var array - */ - protected $object_types = []; + /** @var array */ + protected array $object_types = []; /** * Creates a taxonomy object. @@ -39,11 +33,47 @@ abstract class Taxonomy implements Registrable, TaxonomyInterface { * @return bool Whether the taxonomy was registered successfully. */ public function register(): bool { - if ( ! taxonomy_exists( static::NAME ) ) { + $name = static::NAME; + + if ( ! taxonomy_exists( $name ) ) { + /** + * WordPress stubs currently treat this as an array shape. `johnbillion/args` + * returns a plain `array`, so we assert the expected shape here. + * + * @phpstan-var array{ + * labels?: string[], + * description?: string, + * public?: bool, + * publicly_queryable?: bool, + * hierarchical?: bool, + * show_ui?: bool, + * show_in_menu?: bool, + * show_in_nav_menus?: bool, + * show_in_rest?: bool, + * rest_base?: string, + * rest_namespace?: string, + * rest_controller_class?: string, + * show_tagcloud?: bool, + * show_in_quick_edit?: bool, + * show_admin_column?: bool, + * meta_box_cb?: bool|callable, + * meta_box_sanitize_cb?: callable, + * capabilities?: array{manage_terms?: string, edit_terms?: string, delete_terms?: string, assign_terms?: string}, + * rewrite?: bool|array{slug?: string, with_front?: bool, hierarchical?: bool, ep_mask?: int}, + * query_var?: string|bool, + * update_count_callback?: callable, + * default_term?: string|array{name?: string, slug?: string, description?: string}, + * sort?: bool, + * args?: array, + * _builtin?: bool, + * } $args + */ + $args = $this->get_args()->toArray(); + $taxonomy = register_taxonomy( - static::NAME, + $name, $this->get_object_types(), - $this->get_args()->toArray() + $args ); return ! is_wp_error( $taxonomy ); } @@ -58,8 +88,8 @@ public function register(): bool { * * @param string[]|string $object_type Object type or array of object types with which the taxonomy should be associated. */ - public function set_object_types( $object_type ): void { - $this->object_types = (array) $object_type; + public function set_object_types( array|string $object_type ): void { + $this->object_types = array_map( 'strval', (array) $object_type ); } /** diff --git a/inc/TermMeta.php b/inc/TermMeta.php index 15b5a4f..89d71a4 100644 --- a/inc/TermMeta.php +++ b/inc/TermMeta.php @@ -23,7 +23,7 @@ abstract class TermMeta implements Registrable, TermMetaInterface { /** * Term meta key. */ - public const KEY = null; + public const string KEY = ''; /** * Registers the object. @@ -33,10 +33,30 @@ abstract class TermMeta implements Registrable, TermMetaInterface { * @return bool Whether the term meta was registered successfully. */ public function register(): bool { + if ( static::KEY === '' ) { + return false; + } + + /** + * @phpstan-var array{ + * object_subtype?: string, + * type?: string, + * label?: string, + * description?: string, + * single?: bool, + * default?: mixed, + * sanitize_callback?: callable, + * auth_callback?: callable, + * show_in_rest?: bool|array, + * revisions_enabled?: bool, + * } $args + */ + $args = $this->get_args()->toArray(); + return register_term_meta( $this->taxonomy(), static::KEY, - $this->get_args()->toArray() + $args ); } @@ -57,7 +77,7 @@ protected function get_args(): TermMetaArgs { $args->single = $this->is_single(); $args->default = $this->default(); $args->sanitize_callback = [ $this, 'sanitize' ]; - $args->auth_callback = [ $this, 'auth' ]; + $args->auth_callback = [ $this, 'auth_callback' ]; $args->show_in_rest = $this->show_in_rest(); return $args; @@ -83,7 +103,7 @@ protected function taxonomy(): string { * * @since 0.1.0 * - * @return string Type of the data. + * @return 'array'|'boolean'|'integer'|'number'|'object'|'string' Type of the data. */ protected function type(): string { return TermMetaArgs::TYPE_STRING; @@ -118,7 +138,7 @@ protected function is_single(): bool { * * @return mixed The default value. */ - protected function default() { + protected function default(): mixed { return ''; } @@ -132,7 +152,7 @@ protected function default() { * @param string $object_type Object type. * @return mixed Sanitized meta value. */ - public function sanitize( $meta_value, string $meta_key, string $object_type ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + public function sanitize( mixed $meta_value, string $meta_key, string $object_type ): mixed { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable return $meta_value; } @@ -153,6 +173,21 @@ public function auth( bool $allowed, string $meta_key, int $object_id, int $user return ! is_protected_meta( $meta_key, 'term' ); } + /** + * Adapter for the narrower `johnbillion/args` auth callback signature. + * + * @since 0.1.0 + * + * @param bool $allowed Whether the user can add the term meta. + * @param string $meta_key The meta key. + * @param string $object_type Object type. + * @param string $object_subtype Object subtype. + * @return bool Whether the user is allowed to edit meta. + */ + public function auth_callback( bool $allowed, string $meta_key, string $object_type, string $object_subtype = '' ): bool { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + return $this->auth( $allowed, $meta_key, 0, 0, '', [] ); + } + /** * Whether data associated with this meta key can be considered public and * should be accessible via the REST API. @@ -163,11 +198,11 @@ public function auth( bool $allowed, string $meta_key, int $object_id, int $user * @since 0.1.0 * * @return bool|array{ - * schema: mixed[], - * prepare_callback: callable(mixed,\WP_REST_Request,mixed[]): mixed, + * schema: array, + * prepare_callback: callable(mixed,\WP_REST_Request>,array): mixed, * } */ - protected function show_in_rest() { + protected function show_in_rest(): array|bool { return false; } } diff --git a/inc/TermMetaAdminUI.php b/inc/TermMetaAdminUI.php index e3bd628..4fc3b68 100644 --- a/inc/TermMetaAdminUI.php +++ b/inc/TermMetaAdminUI.php @@ -5,6 +5,8 @@ * @since 0.1.0 */ +declare( strict_types=1 ); + namespace Required\Common; use Required\Common\Contracts\Registrable; @@ -24,14 +26,14 @@ abstract class TermMetaAdminUI implements Registrable { * * @var \Required\Common\Contracts\Taxonomy */ - protected $taxonomy; + protected Taxonomy $taxonomy; /** * The term meta. * * @var \Required\Common\Contracts\TermMeta */ - protected $term_meta; + protected TermMeta $term_meta; /** * Constructor. @@ -67,7 +69,7 @@ public function register(): bool { // List table. add_filter( "manage_edit-{$taxonomy}_columns", [ $this, 'add_column' ] ); add_filter( "manage_edit-{$taxonomy}_sortable_columns", [ $this, 'add_sortable_column' ] ); - add_action( "manage_edit-{$taxonomy}_custom_column", [ $this, 'render_column' ] ); + add_filter( "manage_{$taxonomy}_custom_column", [ $this, 'render_column' ], 10, 3 ); return true; } @@ -79,7 +81,7 @@ public function register(): bool { * * @param int $term_id Term ID. */ - abstract public function add( int $term_id ); + abstract public function add( int $term_id ): void; /** * Updates an existing term meta. @@ -88,14 +90,14 @@ abstract public function add( int $term_id ); * * @param int $term_id Term ID. */ - abstract public function update( int $term_id ); + abstract public function update( int $term_id ): void; /** * Renders field when adding a new term. * * @since 0.1.0 */ - abstract public function render_add_field(); + abstract public function render_add_field(): void; /** * Renders field when editing a term. @@ -104,15 +106,15 @@ abstract public function render_add_field(); * * @param \WP_Term $term Current term object. */ - abstract public function render_edit_field( WP_Term $term ); + abstract public function render_edit_field( WP_Term $term ): void; /** * Adds the term meta to the list of list table columns. * * @since 0.1.0 * - * @param array $columns An array of columns. - * @return array An array of columns. + * @param array $columns An array of columns. + * @return array An array of columns. */ public function add_column( array $columns ): array { return $columns; @@ -123,8 +125,8 @@ public function add_column( array $columns ): array { * * @since 0.1.0 * - * @param array $sortable_columns An array of sortable columns. - * @return array An array of sortable columns. + * @param array $sortable_columns An array of sortable columns. + * @return array An array of sortable columns. */ public function add_sortable_column( array $sortable_columns ): array { return $sortable_columns; @@ -135,8 +137,12 @@ public function add_sortable_column( array $sortable_columns ): array { * * @since 0.1.0 * + * @param string $output Custom column output. Default empty. * @param string $column_name Name of the column. * @param int $term_id Term ID. + * @return string The column output. */ - public function render_column( string $column_name, int $term_id ) {} // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + public function render_column( string $output, string $column_name, int $term_id ): string { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable + return $output; + } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 91b7fb8..db6ba7c 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,7 +4,9 @@ . - + + + diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 99f3173..04ebabf 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -4,4 +4,4 @@ parameters: level: max inferPrivatePropertyTypeFromConstructor: true paths: - - src/ + - inc/