exercism / exercism/php

Namespaces and PSR-4 compliance

Đang mở
#283 16 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
167
Fork
150
Merge trung bình
3 ngày 6 giờ
Pull request đã merge (30 ngày)
2

Mô tả

One of the points I am missing in the exercises of this track is the concept of namespaces (PSR-4 compatibility). Therefore, I would like to discuss and propose the following change.

### Suggestion

Each exercise separates actual business logic from tests by having separate `src` and `test` directories. The `README.md` stays in the exercise's root folder. The example solution (and coming stub file) are going into `src` and the test file into `test`.

> The terminating class name corresponds to a file name ending in .php. The file name MUST match the case of the terminating class name.

Since there is no definition for declaration of functions pertaining to the filename, two possible solutions are crossing my mind. Either name the file `functions.php` or `exercise-name.php` - both residing within the exercise's namespace. Here I am interested in suggestions, since I haven't used a file collecting various functions in years.

### Example

Taking Bob as an example, this would result in the following structure:

- `/src` → namespace `Exercism\Bob`
- `Bob.php` (stub file)
- `example.php` (example solution)
- `/test` → namespace `ExercismTest\Bob`
- `BobTest.php`
- `README.md`

### Looking for feedback

My intention is to provide an even greater learning experience for the student within a modern (meaning current) environment.

It would be great to get some feedback on the suggestion over all and possible side effects I might not have fully considered yet (like implications on test automation etc.). Thank you!

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.